@ogis/waymark-js 3.0.0-alpha → 3.0.2

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,8 +1,8 @@
1
- (function(ci,sa){typeof exports=="object"&&typeof module<"u"?sa(exports):typeof define=="function"&&define.amd?define(["exports"],sa):(ci=typeof globalThis<"u"?globalThis:ci||self,sa(ci.WaymarkJS={}))})(this,function(ci){"use strict";function sa(me={}){if(!me||!me.geometry)return null;switch(me.geometry.type){case"Point":return"marker";case"LineString":case"MultiLineString":return"line";case"Polygon":case"MultiPolygon":return"shape";default:return"shape"}}const nu="0123456789ABCDEFGHJKMNPQRSTVWXYZ",wl=32,Xd=16,su=10,au=0xffffffffffff;var vs;(function(me){me.Base32IncorrectEncoding="B32_ENC_INVALID",me.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",me.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",me.EncodeTimeNegative="ENC_TIME_NEG",me.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",me.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",me.PRNGDetectFailure="PRNG_DETECT",me.ULIDInvalid="ULID_INVALID",me.Unexpected="UNEXPECTED",me.UUIDInvalid="UUID_INVALID"})(vs||(vs={}));class ho extends Error{constructor(j,J){super(`${J} (${j})`),this.name="ULIDError",this.code=j}}function Yd(me){const j=Math.floor(me()*wl)%wl;return nu.charAt(j)}function Kd(me){const j=Jd(),J=j&&(j.crypto||j.msCrypto)||null;if(typeof(J==null?void 0:J.getRandomValues)=="function")return()=>{const de=new Uint8Array(1);return J.getRandomValues(de),de[0]/256};if(typeof(J==null?void 0:J.randomBytes)=="function")return()=>J.randomBytes(1).readUInt8()/256;throw new ho(vs.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Jd(){return tp()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Qd(me,j){let J="";for(;me>0;me--)J=Yd(j)+J;return J}function ep(me,j=su){if(isNaN(me))throw new ho(vs.EncodeTimeValueMalformed,`Time must be a number: ${me}`);if(me>au)throw new ho(vs.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${au}: ${me}`);if(me<0)throw new ho(vs.EncodeTimeNegative,`Time must be positive: ${me}`);if(Number.isInteger(me)===!1)throw new ho(vs.EncodeTimeValueMalformed,`Time must be an integer: ${me}`);let J,de="";for(let Ve=j;Ve>0;Ve--)J=me%wl,de=nu.charAt(J)+de,me=(me-J)/wl;return de}function tp(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Fc(me,j){const J=Kd(),de=Date.now();return ep(de,su)+Qd(Xd,J)}const ip={maxZoom:18,style:"https://tiles.openfreemap.org/styles/bright",attributionControl:!1},bs={padding:{top:50,bottom:50,left:50,right:50},duration:500},rp={duration:500},aa={duration:500};var Tl={exports:{}};/**
1
+ (function(ci,sa){typeof exports=="object"&&typeof module<"u"?sa(exports):typeof define=="function"&&define.amd?define(["exports"],sa):(ci=typeof globalThis<"u"?globalThis:ci||self,sa(ci.WaymarkJS={}))})(this,function(ci){"use strict";function sa(me={}){if(!me||!me.geometry)return null;switch(me.geometry.type){case"Point":case"MultiPoint":return"marker";case"LineString":case"MultiLineString":return"line";case"Polygon":case"MultiPolygon":return"shape";default:return null}}const nu="0123456789ABCDEFGHJKMNPQRSTVWXYZ",wl=32,Xd=16,su=10,au=0xffffffffffff;var vs;(function(me){me.Base32IncorrectEncoding="B32_ENC_INVALID",me.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",me.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",me.EncodeTimeNegative="ENC_TIME_NEG",me.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",me.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",me.PRNGDetectFailure="PRNG_DETECT",me.ULIDInvalid="ULID_INVALID",me.Unexpected="UNEXPECTED",me.UUIDInvalid="UUID_INVALID"})(vs||(vs={}));class ho extends Error{constructor(j,J){super(`${J} (${j})`),this.name="ULIDError",this.code=j}}function Yd(me){const j=Math.floor(me()*wl)%wl;return nu.charAt(j)}function Kd(me){const j=Jd(),J=j&&(j.crypto||j.msCrypto)||null;if(typeof(J==null?void 0:J.getRandomValues)=="function")return()=>{const de=new Uint8Array(1);return J.getRandomValues(de),de[0]/256};if(typeof(J==null?void 0:J.randomBytes)=="function")return()=>J.randomBytes(1).readUInt8()/256;throw new ho(vs.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Jd(){return tp()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Qd(me,j){let J="";for(;me>0;me--)J=Yd(j)+J;return J}function ep(me,j=su){if(isNaN(me))throw new ho(vs.EncodeTimeValueMalformed,`Time must be a number: ${me}`);if(me>au)throw new ho(vs.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${au}: ${me}`);if(me<0)throw new ho(vs.EncodeTimeNegative,`Time must be positive: ${me}`);if(Number.isInteger(me)===!1)throw new ho(vs.EncodeTimeValueMalformed,`Time must be an integer: ${me}`);let J,de="";for(let je=j;je>0;je--)J=me%wl,de=nu.charAt(J)+de,me=(me-J)/wl;return de}function tp(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Bc(me,j){const J=Kd(),de=Date.now();return ep(de,su)+Qd(Xd,J)}const ip={maxZoom:18,style:"https://tiles.openfreemap.org/styles/bright",attributionControl:{compact:!0}},bs={padding:{top:50,bottom:50,left:50,right:50},duration:500},rp={duration:500},aa={duration:500};var Tl={exports:{}};/**
2
2
  * MapLibre GL JS
3
3
  * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.7.1/LICENSE.txt
4
- */var np=Tl.exports,ou;function sp(){return ou||(ou=1,function(me,j){(function(J,de){me.exports=de()})(np,function(){var J={},de={};function Ve(C,c,be){if(de[C]=be,C==="index"){var ct="var sharedModule = {}; ("+de.shared+")(sharedModule); ("+de.worker+")(sharedModule);",ut={};return de.shared(ut),de.index(J,ut),typeof window<"u"&&J.setWorkerUrl(window.URL.createObjectURL(new Blob([ct],{type:"text/javascript"}))),J}}Ve("shared",["exports"],function(C){function c(r,t,i,s){return new(i||(i=Promise))(function(o,d){function p(x){try{g(s.next(x))}catch(v){d(v)}}function m(x){try{g(s.throw(x))}catch(v){d(v)}}function g(x){var v;x.done?o(x.value):(v=x.value,v instanceof i?v:new i(function(T){T(v)})).then(p,m)}g((s=s.apply(r,t||[])).next())})}function be(r,t){this.x=r,this.y=t}function ct(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ut,pt;typeof SuppressedError=="function"&&SuppressedError,be.prototype={clone(){return new be(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,t){return this.clone()._rotateAround(r,t)},matMult(r){return this.clone()._matMult(r)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const t=r.x-this.x,i=r.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,t){return Math.atan2(this.x*t-this.y*r,this.x*r+this.y*t)},_matMult(r){const t=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=t,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const t=Math.cos(r),i=Math.sin(r),s=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=s,this},_rotateAround(r,t){const i=Math.cos(r),s=Math.sin(r),o=t.y+s*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-s*(this.y-t.y),this.y=o,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:be},be.convert=function(r){if(r instanceof be)return r;if(Array.isArray(r))return new be(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new be(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};var Ee=function(){if(pt)return ut;function r(t,i,s,o){this.cx=3*t,this.bx=3*(s-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(o-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=i,this.p2x=s,this.p2y=o}return pt=1,ut=r,r.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,i){if(i===void 0&&(i=1e-6),t<0)return 0;if(t>1)return 1;for(var s=t,o=0;o<8;o++){var d=this.sampleCurveX(s)-t;if(Math.abs(d)<i)return s;var p=this.sampleCurveDerivativeX(s);if(Math.abs(p)<1e-6)break;s-=d/p}var m=0,g=1;for(s=t,o=0;o<20&&(d=this.sampleCurveX(s),!(Math.abs(d-t)<i));o++)t>d?m=s:g=s,s=.5*(g-m)+m;return s},solve:function(t,i){return this.sampleCurveY(this.solveCurveX(t,i))}},ut}(),se=ct(Ee);let Mt,ei;function Ri(){return Mt==null&&(Mt=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Mt}function Ci(){if(ei==null&&(ei=!1,Ri())){const t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<5*5;s++){const o=4*s;t.fillStyle=`rgb(${o},${o+1},${o+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}const i=t.getImageData(0,0,5,5).data;for(let s=0;s<5*5*4;s++)if(s%4!=3&&i[s]!==s){ei=!0;break}}}return ei||!1}var It=1e-6,ft=typeof Float32Array<"u"?Float32Array:Array;function Ot(){var r=new ft(9);return ft!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function $i(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Sr(){var r=new ft(3);return ft!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function jn(r){var t=r[0],i=r[1],s=r[2];return Math.sqrt(t*t+i*i+s*s)}function oa(r,t,i){var s=new ft(3);return s[0]=r,s[1]=t,s[2]=i,s}function Ts(r,t,i){return r[0]=t[0]+i[0],r[1]=t[1]+i[1],r[2]=t[2]+i[2],r}function pr(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r[2]=t[2]*i,r}function Br(r,t,i){var s=t[0],o=t[1],d=t[2],p=i[0],m=i[1],g=i[2];return r[0]=o*g-d*m,r[1]=d*p-s*g,r[2]=s*m-o*p,r}var fr,Or=jn;function Ps(r,t,i){var s=t[0],o=t[1],d=t[2],p=t[3];return r[0]=i[0]*s+i[4]*o+i[8]*d+i[12]*p,r[1]=i[1]*s+i[5]*o+i[9]*d+i[13]*p,r[2]=i[2]*s+i[6]*o+i[10]*d+i[14]*p,r[3]=i[3]*s+i[7]*o+i[11]*d+i[15]*p,r}function cn(){var r=new ft(4);return ft!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function hn(r,t,i,s){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",d=Math.PI/360;t*=d,s*=d,i*=d;var p=Math.sin(t),m=Math.cos(t),g=Math.sin(i),x=Math.cos(i),v=Math.sin(s),T=Math.cos(s);switch(o){case"xyz":r[0]=p*x*T+m*g*v,r[1]=m*g*T-p*x*v,r[2]=m*x*v+p*g*T,r[3]=m*x*T-p*g*v;break;case"xzy":r[0]=p*x*T-m*g*v,r[1]=m*g*T-p*x*v,r[2]=m*x*v+p*g*T,r[3]=m*x*T+p*g*v;break;case"yxz":r[0]=p*x*T+m*g*v,r[1]=m*g*T-p*x*v,r[2]=m*x*v-p*g*T,r[3]=m*x*T+p*g*v;break;case"yzx":r[0]=p*x*T+m*g*v,r[1]=m*g*T+p*x*v,r[2]=m*x*v-p*g*T,r[3]=m*x*T-p*g*v;break;case"zxy":r[0]=p*x*T-m*g*v,r[1]=m*g*T+p*x*v,r[2]=m*x*v+p*g*T,r[3]=m*x*T-p*g*v;break;case"zyx":r[0]=p*x*T-m*g*v,r[1]=m*g*T+p*x*v,r[2]=m*x*v-p*g*T,r[3]=m*x*T+p*g*v;break;default:throw new Error("Unknown angle order "+o)}return r}function un(){var r=new ft(2);return ft!=Float32Array&&(r[0]=0,r[1]=0),r}function la(r,t){var i=new ft(2);return i[0]=r,i[1]=t,i}Sr(),fr=new ft(4),ft!=Float32Array&&(fr[0]=0,fr[1]=0,fr[2]=0,fr[3]=0),Sr(),oa(1,0,0),oa(0,1,0),cn(),cn(),Ot(),un();const gt=8192;function dn(r,t,i){return t*(gt/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function mi(r,t){return(r%t+t)%t}function pn(r,t,i){return r*(1-i)+t*i}function mr(r){if(r<=0)return 0;if(r>=1)return 1;const t=r*r,i=t*r;return 4*(r<.5?i:3*(r-t)+i-.75)}function jr(r,t,i,s){const o=new se(r,t,i,s);return d=>o.solve(d)}const fn=jr(.25,.1,.25,1);function Ei(r,t,i){return Math.min(i,Math.max(t,r))}function Nn(r,t,i){const s=i-t,o=((r-t)%s+s)%s+t;return o===t?i:o}function Zi(r,...t){for(const i of t)for(const s in i)r[s]=i[s];return r}let Yi=1;function Vn(r,t,i){const s={};for(const o in r)s[o]=t.call(this,r[o],o,r);return s}function Un(r,t,i){const s={};for(const o in r)t.call(this,r[o],o,r)&&(s[o]=r[o]);return s}function Fi(r){return Array.isArray(r)?r.map(Fi):typeof r=="object"&&r?Vn(r,Fi):r}const Dt={};function jt(r){Dt[r]||(typeof console<"u"&&console.warn(r),Dt[r]=!0)}function Ki(r,t,i){return(i.y-r.y)*(t.x-r.x)>(t.y-r.y)*(i.x-r.x)}function gr(r){return typeof WorkerGlobalScope<"u"&&r!==void 0&&r instanceof WorkerGlobalScope}let mn=null;function _r(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}const yr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function $n(r,t,i,s,o){return c(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const d=new VideoFrame(r,{timestamp:0});try{const p=d==null?void 0:d.format;if(!p||!p.startsWith("BGR")&&!p.startsWith("RGB"))throw new Error(`Unrecognized format ${p}`);const m=p.startsWith("BGR"),g=new Uint8ClampedArray(s*o*4);if(yield d.copyTo(g,function(x,v,T,M,E){const A=4*Math.max(-v,0),L=(Math.max(0,T)-T)*M*4+A,F=4*M,V=Math.max(0,v),Q=Math.max(0,T);return{rect:{x:V,y:Q,width:Math.min(x.width,v+M)-V,height:Math.min(x.height,T+E)-Q},layout:[{offset:L,stride:F}]}}(r,t,i,s,o)),m)for(let x=0;x<g.length;x+=4){const v=g[x];g[x]=g[x+2],g[x+2]=v}return g}finally{d.close()}})}let Nr,Vr;function Ur(r,t,i,s){return r.addEventListener(t,i,s),{unsubscribe:()=>{r.removeEventListener(t,i,s)}}}function gn(r){return r*Math.PI/180}function $r(r){return r/Math.PI*180}const Zr={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Gr={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},Zn="AbortError";function ee(){return new Error(Zn)}const z={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function D(r){return z.REGISTERED_PROTOCOLS[r.substring(0,r.indexOf("://"))]}const R="global-dispatcher";class Z extends Error{constructor(t,i,s,o){super(`AJAXError: ${i} (${t}): ${s}`),this.status=t,this.statusText=i,this.url=s,this.body=o}}const Y=()=>gr(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,ie=function(r,t){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const s=D(r.url);if(s)return s(r,t);if(gr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:R},t)}if(!(/^file:/.test(i=r.url)||/^file:/.test(Y())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,o){return c(this,void 0,void 0,function*(){const d=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:Y(),signal:o.signal});let p,m;s.type!=="json"||d.headers.has("Accept")||d.headers.set("Accept","application/json");try{p=yield fetch(d)}catch(x){throw new Z(0,x.message,s.url,new Blob)}if(!p.ok){const x=yield p.blob();throw new Z(p.status,p.statusText,s.url,x)}m=s.type==="arrayBuffer"||s.type==="image"?p.arrayBuffer():s.type==="json"?p.json():p.text();const g=yield m;if(o.signal.aborted)throw ee();return{data:g,cacheControl:p.headers.get("Cache-Control"),expires:p.headers.get("Expires")}})}(r,t);if(gr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:R},t)}var i;return function(s,o){return new Promise((d,p)=>{var m;const g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(const x in s.headers)g.setRequestHeader(x,s.headers[x]);s.type==="json"&&(g.responseType="text",!((m=s.headers)===null||m===void 0)&&m.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{p(new Error(g.statusText))},g.onload=()=>{if(!o.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)}d({data:x,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{const x=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});p(new Z(g.status,g.statusText,s.url,x))}},o.signal.addEventListener("abort",()=>{g.abort(),p(ee())}),g.send(s.body)})}(r,t)};function le(r){if(!r||r.indexOf("://")<=0||r.indexOf("data:image/")===0||r.indexOf("blob:")===0)return!0;const t=new URL(r),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function re(r,t,i){i[r]&&i[r].indexOf(t)!==-1||(i[r]=i[r]||[],i[r].push(t))}function fe(r,t,i){if(i&&i[r]){const s=i[r].indexOf(t);s!==-1&&i[r].splice(s,1)}}class ve{constructor(t,i={}){Zi(this,i),this.type=t}}class _e extends ve{constructor(t,i={}){super("error",Zi({error:t},i))}}class Re{on(t,i){return this._listeners=this._listeners||{},re(t,i,this._listeners),{unsubscribe:()=>{this.off(t,i)}}}off(t,i){return fe(t,i,this._listeners),fe(t,i,this._oneTimeListeners),this}once(t,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},re(t,i,this._oneTimeListeners),this):new Promise(s=>this.once(t,s))}fire(t,i){typeof t=="string"&&(t=new ve(t,i||{}));const s=t.type;if(this.listens(s)){t.target=this;const o=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const m of o)m.call(this,t);const d=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const m of d)fe(s,m,this._oneTimeListeners),m.call(this,t);const p=this._eventedParent;p&&(Zi(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(t))}else t instanceof _e&&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,i){return this._eventedParent=t,this._eventedParentData=i,this}}var ne={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const qe=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Qe(r,t){const i={};for(const s in r)s!=="ref"&&(i[s]=r[s]);return qe.forEach(s=>{s in t&&(i[s]=t[s])}),i}function Oe(r,t){if(Array.isArray(r)){if(!Array.isArray(t)||r.length!==t.length)return!1;for(let i=0;i<r.length;i++)if(!Oe(r[i],t[i]))return!1;return!0}if(typeof r=="object"&&r!==null&&t!==null){if(typeof t!="object"||Object.keys(r).length!==Object.keys(t).length)return!1;for(const i in r)if(!Oe(r[i],t[i]))return!1;return!0}return r===t}function He(r,t){r.push(t)}function Tt(r,t,i){He(i,{command:"addSource",args:[r,t[r]]})}function Ht(r,t,i){He(t,{command:"removeSource",args:[r]}),i[r]=!0}function Xt(r,t,i,s){Ht(r,i,s),Tt(r,t,i)}function Nt(r,t,i){let s;for(s in r[i])if(Object.prototype.hasOwnProperty.call(r[i],s)&&s!=="data"&&!Oe(r[i][s],t[i][s]))return!1;for(s in t[i])if(Object.prototype.hasOwnProperty.call(t[i],s)&&s!=="data"&&!Oe(r[i][s],t[i][s]))return!1;return!0}function rt(r,t,i,s,o,d){r=r||{},t=t||{};for(const p in r)Object.prototype.hasOwnProperty.call(r,p)&&(Oe(r[p],t[p])||i.push({command:d,args:[s,p,t[p],o]}));for(const p in t)Object.prototype.hasOwnProperty.call(t,p)&&!Object.prototype.hasOwnProperty.call(r,p)&&(Oe(r[p],t[p])||i.push({command:d,args:[s,p,t[p],o]}))}function ot(r){return r.id}function Ut(r,t){return r[t.id]=t,r}class Te{constructor(t,i,s,o){this.message=(t?`${t}: `:"")+s,o&&(this.identifier=o),i!=null&&i.__line__&&(this.line=i.__line__)}}function gi(r,...t){for(const i of t)for(const s in i)r[s]=i[s];return r}class At extends Error{constructor(t,i){super(i),this.message=i,this.key=t}}class qr{constructor(t,i=[]){this.parent=t,this.bindings={};for(const[s,o]of i)this.bindings[s]=o}concat(t){return new qr(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)}}const Gn={kind:"null"},ke={kind:"number"},et={kind:"string"},Je={kind:"boolean"},hi={kind:"color"},_n={kind:"projectionDefinition"},Wr={kind:"object"},Ye={kind:"value"},ca={kind:"collator"},Hr={kind:"formatted"},ha={kind:"padding"},xr={kind:"colorArray"},qn={kind:"numberArray"},Rt={kind:"resolvedImage"},ua={kind:"variableAnchorOffsetCollection"};function Ai(r,t){return{kind:"array",itemType:r,N:t}}function vt(r){if(r.kind==="array"){const t=vt(r.itemType);return typeof r.N=="number"?`array<${t}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${t}>`}return r.kind}const Ml=[Gn,ke,et,Je,hi,_n,Hr,Wr,Ai(Ye),ha,qn,xr,Rt,ua];function Ss(r,t){if(t.kind==="error")return null;if(r.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!Ss(r.itemType,t.itemType))&&(typeof r.N!="number"||r.N===t.N))return null}else{if(r.kind===t.kind)return null;if(r.kind==="value"){for(const i of Ml)if(!Ss(i,t))return null}}return`Expected ${vt(r)} but found ${vt(t)} instead.`}function uo(r,t){return t.some(i=>i.kind===r.kind)}function Xr(r,t){return t.some(i=>i==="null"?r===null:i==="array"?Array.isArray(r):i==="object"?r&&!Array.isArray(r)&&typeof r=="object":i===typeof r)}function Yr(r,t){return r.kind==="array"&&t.kind==="array"?r.itemType.kind===t.itemType.kind&&typeof r.N=="number":r.kind===t.kind}const po=.96422,Il=.82521,Cl=4/29,Wn=6/29,El=3*Wn*Wn,Zc=Wn*Wn*Wn,Gc=Math.PI/180,qc=180/Math.PI;function fo(r){return(r%=360)<0&&(r+=360),r}function Hn([r,t,i,s]){let o,d;const p=go((.2225045*(r=mo(r))+.7168786*(t=mo(t))+.0606169*(i=mo(i)))/1);r===t&&t===i?o=d=p:(o=go((.4360747*r+.3850649*t+.1430804*i)/po),d=go((.0139322*r+.0971045*t+.7141733*i)/Il));const m=116*p-16;return[m<0?0:m,500*(o-p),200*(p-d),s]}function mo(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function go(r){return r>Zc?Math.pow(r,1/3):r/El+Cl}function Xn([r,t,i,s]){let o=(r+16)/116,d=isNaN(t)?o:o+t/500,p=isNaN(i)?o:o-i/200;return o=1*yo(o),d=po*yo(d),p=Il*yo(p),[_o(3.1338561*d-1.6168667*o-.4906146*p),_o(-.9787684*d+1.9161415*o+.033454*p),_o(.0719453*d-.2289914*o+1.4052427*p),s]}function _o(r){return(r=r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055)<0?0:r>1?1:r}function yo(r){return r>Wn?r*r*r:El*(r-Cl)}const Wc=Object.hasOwn||function(r,t){return Object.prototype.hasOwnProperty.call(r,t)};function Yn(r,t){return Wc(r,t)?r[t]:void 0}function Ms(r){return parseInt(r.padEnd(2,r),16)/255}function Ji(r,t){return tt(t?r/100:r,0,1)}function tt(r,t,i){return Math.min(Math.max(t,r),i)}function yn(r){return!r.some(Number.isNaN)}const Kr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Mr(r,t,i){return r+i*(t-r)}function xn(r,t,i){return r.map((s,o)=>Mr(s,t[o],i))}class it{constructor(t,i,s,o=1,d=!0){this.r=t,this.g=i,this.b=s,this.a=o,d||(this.r*=o,this.g*=o,this.b*=o,o||this.overwriteGetter("rgb",[t,i,s,o]))}static parse(t){if(t instanceof it)return t;if(typeof t!="string")return;const i=function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const o=Yn(Kr,s);if(o){const[p,m,g]=o;return[p/255,m/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const p=s.length<6?1:2;let m=1;return[Ms(s.slice(m,m+=p)),Ms(s.slice(m,m+=p)),Ms(s.slice(m,m+=p)),Ms(s.slice(m,m+p)||"ff")]}if(s.startsWith("rgb")){const p=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){const[m,g,x,v,T,M,E,A,L,F,V,Q]=p,W=[v||" ",E||" ",F].join("");if(W===" "||W===" /"||W===",,"||W===",,,"){const X=[x,M,L].join(""),ce=X==="%%%"?100:X===""?255:0;if(ce){const pe=[tt(+g/ce,0,1),tt(+T/ce,0,1),tt(+A/ce,0,1),V?Ji(+V,Q):1];if(yn(pe))return pe}}return}}const d=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[p,m,g,x,v,T,M,E,A]=d,L=[g||" ",v||" ",M].join("");if(L===" "||L===" /"||L===",,"||L===",,,"){const F=[+m,tt(+x,0,100),tt(+T,0,100),E?Ji(+E,A):1];if(yn(F))return function([V,Q,W,X]){function ce(pe){const xe=(pe+V/30)%12,Ae=Q*Math.min(W,1-W);return W-Ae*Math.max(-1,Math.min(xe-3,9-xe,1))}return V=fo(V),Q/=100,W/=100,[ce(0),ce(8),ce(4),X]}(F)}}}(t);return i?new it(...i,!1):void 0}get rgb(){const{r:t,g:i,b:s,a:o}=this,d=o||1/0;return this.overwriteGetter("rgb",[t/d,i/d,s/d,o])}get hcl(){return this.overwriteGetter("hcl",function(t){const[i,s,o,d]=Hn(t),p=Math.sqrt(s*s+o*o);return[Math.round(1e4*p)?fo(Math.atan2(o,s)*qc):NaN,p,i,d]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Hn(this.rgb))}overwriteGetter(t,i){return Object.defineProperty(this,t,{value:i}),i}toString(){const[t,i,s,o]=this.rgb;return`rgba(${[t,i,s].map(d=>Math.round(255*d)).join(",")},${o})`}static interpolate(t,i,s,o="rgb"){switch(o){case"rgb":{const[d,p,m,g]=xn(t.rgb,i.rgb,s);return new it(d,p,m,g,!1)}case"hcl":{const[d,p,m,g]=t.hcl,[x,v,T,M]=i.hcl;let E,A;if(isNaN(d)||isNaN(x))isNaN(d)?isNaN(x)?E=NaN:(E=x,m!==1&&m!==0||(A=v)):(E=d,T!==1&&T!==0||(A=p));else{let W=x-d;x>d&&W>180?W-=360:x<d&&d-x>180&&(W+=360),E=d+s*W}const[L,F,V,Q]=function([W,X,ce,pe]){return W=isNaN(W)?0:W*Gc,Xn([ce,Math.cos(W)*X,Math.sin(W)*X,pe])}([E,A??Mr(p,v,s),Mr(m,T,s),Mr(g,M,s)]);return new it(L,F,V,Q,!1)}case"lab":{const[d,p,m,g]=Xn(xn(t.lab,i.lab,s));return new it(d,p,m,g,!1)}}}}it.black=new it(0,0,0,1),it.white=new it(1,1,1,1),it.transparent=new it(0,0,0,0),it.red=new it(1,0,0,1);class vn{constructor(t,i,s){this.sensitivity=t?i?"variant":"case":i?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,i){return this.collator.compare(t,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const da=["bottom","center","top"];class pa{constructor(t,i,s,o,d,p){this.text=t,this.image=i,this.scale=s,this.fontStack=o,this.textColor=d,this.verticalAlign=p}}class bi{constructor(t){this.sections=t}static fromString(t){return new bi([new pa(t,null,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 ti{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof ti)return t;if(typeof t=="number")return new ti([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const i of t)if(typeof i!="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 ti(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){return new ti(xn(t.values,i.values,s))}}class wi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof wi)return t;if(typeof t=="number")return new wi([t]);if(Array.isArray(t)){for(const i of t)if(typeof i!="number")return;return new wi(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){return new wi(xn(t.values,i.values,s))}}class $t{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof $t)return t;if(typeof t=="string"){const s=it.parse(t);return s?new $t([s]):void 0}if(!Array.isArray(t))return;const i=[];for(const s of t){if(typeof s!="string")return;const o=it.parse(s);if(!o)return;i.push(o)}return new $t(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s,o="rgb"){const d=[];if(t.values.length!=i.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let p=0;p<t.values.length;p++)d.push(it.interpolate(t.values[p],i.values[p],s,o));return new $t(d)}}class bt extends Error{constructor(t){super(t),this.name="RuntimeError"}toJSON(){return this.message}}const Al=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Ti{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ti)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let i=0;i<t.length;i+=2){const s=t[i],o=t[i+1];if(typeof s!="string"||!Al.has(s)||!Array.isArray(o)||o.length!==2||typeof o[0]!="number"||typeof o[1]!="number")return}return new Ti(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){const o=t.values,d=i.values;if(o.length!==d.length)throw new bt(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`);const p=[];for(let m=0;m<o.length;m+=2){if(o[m]!==d[m])throw new bt(`Cannot interpolate values containing mismatched anchors. from[${m}]: ${o[m]}, to[${m}]: ${d[m]}`);p.push(o[m]);const[g,x]=o[m+1],[v,T]=d[m+1];p.push([Mr(g,v,s),Mr(x,T,s)])}return new Ti(p)}}class Bi{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Bi({name:t,available:!1}):null}}class _i{constructor(t,i,s){this.from=t,this.to=i,this.transition=s}static interpolate(t,i,s){return new _i(t,i,s)}static parse(t){return t instanceof _i?t:Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number"?new _i(t[0],t[1],t[2]):typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number"?new _i(t.from,t.to,t.transition):typeof t=="string"?new _i(t,t,1):void 0}}function Pt(r,t,i,s){return typeof r=="number"&&r>=0&&r<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof i=="number"&&i>=0&&i<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[r,t,i,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[r,t,i,s]:[r,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function bn(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof _i||r instanceof it||r instanceof vn||r instanceof bi||r instanceof ti||r instanceof wi||r instanceof $t||r instanceof Ti||r instanceof Bi)return!0;if(Array.isArray(r)){for(const t of r)if(!bn(t))return!1;return!0}if(typeof r=="object"){for(const t in r)if(!bn(r[t]))return!1;return!0}return!1}function Ue(r){if(r===null)return Gn;if(typeof r=="string")return et;if(typeof r=="boolean")return Je;if(typeof r=="number")return ke;if(r instanceof it)return hi;if(r instanceof _i)return _n;if(r instanceof vn)return ca;if(r instanceof bi)return Hr;if(r instanceof ti)return ha;if(r instanceof wi)return qn;if(r instanceof $t)return xr;if(r instanceof Ti)return ua;if(r instanceof Bi)return Rt;if(Array.isArray(r)){const t=r.length;let i;for(const s of r){const o=Ue(s);if(i){if(i===o)continue;i=Ye;break}i=o}return Ai(i||Ye,t)}return Wr}function We(r){const t=typeof r;return r===null?"":t==="string"||t==="number"||t==="boolean"?String(r):r instanceof it||r instanceof _i||r instanceof bi||r instanceof ti||r instanceof wi||r instanceof $t||r instanceof Ti||r instanceof Bi?r.toString():JSON.stringify(r)}class Ir{constructor(t,i){this.type=t,this.value=i}static parse(t,i){if(t.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!bn(t[1]))return i.error("invalid value");const s=t[1];let o=Ue(s);const d=i.expectedType;return o.kind!=="array"||o.N!==0||!d||d.kind!=="array"||typeof d.N=="number"&&d.N!==0||(o=d),new Ir(o,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const lt={string:et,number:ke,boolean:Je,object:Wr};class Oi{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let s,o=1;const d=t[0];if(d==="array"){let m,g;if(t.length>2){const x=t[1];if(typeof x!="string"||!(x in lt)||x==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);m=lt[x],o++}else m=Ye;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);g=t[2],o++}s=Ai(m,g)}else{if(!lt[d])throw new Error(`Types doesn't contain name = ${d}`);s=lt[d]}const p=[];for(;o<t.length;o++){const m=i.parse(t[o],o,Ye);if(!m)return null;p.push(m)}return new Oi(s,p)}evaluate(t){for(let i=0;i<this.args.length;i++){const s=this.args[i].evaluate(t);if(!Ss(this.type,Ue(s)))return s;if(i===this.args.length-1)throw new bt(`Expected value to be of type ${vt(this.type)}, but found ${vt(Ue(s))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const vr={"to-boolean":Je,"to-color":hi,"to-number":ke,"to-string":et};class br{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const s=t[0];if(!vr[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 i.error("Expected one argument.");const o=vr[s],d=[];for(let p=1;p<t.length;p++){const m=i.parse(t[p],p,Ye);if(!m)return null;d.push(m)}return new br(o,d)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let i,s;for(const o of this.args){if(i=o.evaluate(t),s=null,i instanceof it)return i;if(typeof i=="string"){const d=t.parseColor(i);if(d)return d}else if(Array.isArray(i)&&(s=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:Pt(i[0],i[1],i[2],i[3]),!s))return new it(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new bt(s||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"padding":{let i;for(const s of this.args){i=s.evaluate(t);const o=ti.parse(i);if(o)return o}throw new bt(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"numberArray":{let i;for(const s of this.args){i=s.evaluate(t);const o=wi.parse(i);if(o)return o}throw new bt(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"colorArray":{let i;for(const s of this.args){i=s.evaluate(t);const o=$t.parse(i);if(o)return o}throw new bt(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"variableAnchorOffsetCollection":{let i;for(const s of this.args){i=s.evaluate(t);const o=Ti.parse(i);if(o)return o}throw new bt(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"number":{let i=null;for(const s of this.args){if(i=s.evaluate(t),i===null)return 0;const o=Number(i);if(!isNaN(o))return o}throw new bt(`Could not convert ${JSON.stringify(i)} to number.`)}case"formatted":return bi.fromString(We(this.args[0].evaluate(t)));case"resolvedImage":return Bi.fromString(We(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return We(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const fa=["Unknown","Point","LineString","Polygon"];class xo{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?fa[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 i=this._parseColorCache.get(t);return i||(i=it.parse(t),this._parseColorCache.set(t,i)),i}}class Kn{constructor(t,i,s=[],o,d=new qr,p=[]){this.registry=t,this.path=s,this.key=s.map(m=>`[${m}]`).join(""),this.scope=d,this.errors=p,this.expectedType=o,this._isConstant=i}parse(t,i,s,o,d={}){return i?this.concat(i,s,o)._parse(t,d):this._parse(t,d)}_parse(t,i){function s(o,d,p){return p==="assert"?new Oi(d,[o]):p==="coerce"?new br(d,[o]):o}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=t[0];if(typeof o!="string")return this.error(`Expression name must be a string, but found ${typeof o} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const d=this.registry[o];if(d){let p=d.parse(t,this);if(!p)return null;if(this.expectedType){const m=this.expectedType,g=p.type;if(m.kind!=="string"&&m.kind!=="number"&&m.kind!=="boolean"&&m.kind!=="object"&&m.kind!=="array"||g.kind!=="value"){if(m.kind==="projectionDefinition"&&["string","array"].includes(g.kind)||["color","formatted","resolvedImage"].includes(m.kind)&&["value","string"].includes(g.kind)||["padding","numberArray"].includes(m.kind)&&["value","number","array"].includes(g.kind)||m.kind==="colorArray"&&["value","string","array"].includes(g.kind)||m.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(g.kind))p=s(p,m,i.typeAnnotation||"coerce");else if(this.checkSubtype(m,g))return null}else p=s(p,m,i.typeAnnotation||"assert")}if(!(p instanceof Ir)&&p.type.kind!=="resolvedImage"&&this._isConstant(p)){const m=new xo;try{p=new Ir(p.type,p.evaluate(m))}catch(g){return this.error(g.message),null}}return p}return this.error(`Unknown expression "${o}". 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,i,s){const o=typeof t=="number"?this.path.concat(t):this.path,d=s?this.scope.concat(s):this.scope;return new Kn(this.registry,this._isConstant,o,i||null,d,this.errors)}error(t,...i){const s=`${this.key}${i.map(o=>`[${o}]`).join("")}`;this.errors.push(new At(s,t))}checkSubtype(t,i){const s=Ss(t,i);return s&&this.error(s),s}}class Is{constructor(t,i){this.type=i.type,this.bindings=[].concat(t),this.result=i}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const i of this.bindings)t(i[1]);t(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const s=[];for(let d=1;d<t.length-1;d+=2){const p=t[d];if(typeof p!="string")return i.error(`Expected string, but found ${typeof p} instead.`,d);if(/[^a-zA-Z0-9_]/.test(p))return i.error("Variable names must contain only alphanumeric characters or '_'.",d);const m=i.parse(t[d+1],d+1);if(!m)return null;s.push([p,m])}const o=i.parse(t[t.length-1],t.length-1,i.expectedType,s);return o?new Is(s,o):null}outputDefined(){return this.result.outputDefined()}}class ma{constructor(t,i){this.type=i.type,this.name=t,this.boundExpression=i}static parse(t,i){if(t.length!==2||typeof t[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const s=t[1];return i.scope.has(s)?new ma(s,i.scope.get(s)):i.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 ga{constructor(t,i,s){this.type=t,this.index=i,this.input=s}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,ke),o=i.parse(t[2],2,Ai(i.expectedType||Ye));return s&&o?new ga(o.type.itemType,s,o):null}evaluate(t){const i=this.index.evaluate(t),s=this.input.evaluate(t);if(i<0)throw new bt(`Array index out of bounds: ${i} < 0.`);if(i>=s.length)throw new bt(`Array index out of bounds: ${i} > ${s.length-1}.`);if(i!==Math.floor(i))throw new bt(`Array index must be an integer, but found ${i} instead.`);return s[i]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class _a{constructor(t,i){this.type=Je,this.needle=t,this.haystack=i}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,Ye),o=i.parse(t[2],2,Ye);return s&&o?uo(s.type,[Je,et,ke,Gn,Ye])?new _a(s,o):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${vt(s.type)} instead`):null}evaluate(t){const i=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!Xr(i,["boolean","string","number","null"]))throw new bt(`Expected first argument to be of type boolean, string, number or null, but found ${vt(Ue(i))} instead.`);if(!Xr(s,["string","array"]))throw new bt(`Expected second argument to be of type array or string, but found ${vt(Ue(s))} instead.`);return s.indexOf(i)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class Qi{constructor(t,i,s){this.type=ke,this.needle=t,this.haystack=i,this.fromIndex=s}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,Ye),o=i.parse(t[2],2,Ye);if(!s||!o)return null;if(!uo(s.type,[Je,et,ke,Gn,Ye]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${vt(s.type)} instead`);if(t.length===4){const d=i.parse(t[3],3,ke);return d?new Qi(s,o,d):null}return new Qi(s,o)}evaluate(t){const i=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!Xr(i,["boolean","string","number","null"]))throw new bt(`Expected first argument to be of type boolean, string, number or null, but found ${vt(Ue(i))} instead.`);let o;if(this.fromIndex&&(o=this.fromIndex.evaluate(t)),Xr(s,["string"])){const d=s.indexOf(i,o);return d===-1?-1:[...s.slice(0,d)].length}if(Xr(s,["array"]))return s.indexOf(i,o);throw new bt(`Expected second argument to be of type array or string, but found ${vt(Ue(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class ii{constructor(t,i,s,o,d,p){this.inputType=t,this.type=i,this.input=s,this.cases=o,this.outputs=d,this.otherwise=p}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let s,o;i.expectedType&&i.expectedType.kind!=="value"&&(o=i.expectedType);const d={},p=[];for(let x=2;x<t.length-1;x+=2){let v=t[x];const T=t[x+1];Array.isArray(v)||(v=[v]);const M=i.concat(x);if(v.length===0)return M.error("Expected at least one branch label.");for(const A of v){if(typeof A!="number"&&typeof A!="string")return M.error("Branch labels must be numbers or strings.");if(typeof A=="number"&&Math.abs(A)>Number.MAX_SAFE_INTEGER)return M.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof A=="number"&&Math.floor(A)!==A)return M.error("Numeric branch labels must be integer values.");if(s){if(M.checkSubtype(s,Ue(A)))return null}else s=Ue(A);if(d[String(A)]!==void 0)return M.error("Branch labels must be unique.");d[String(A)]=p.length}const E=i.parse(T,x,o);if(!E)return null;o=o||E.type,p.push(E)}const m=i.parse(t[1],1,Ye);if(!m)return null;const g=i.parse(t[t.length-1],t.length-1,o);return g?m.type.kind!=="value"&&i.concat(1).checkSubtype(s,m.type)?null:new ii(s,o,m,d,p,g):null}evaluate(t){const i=this.input.evaluate(t);return(Ue(i)===this.inputType&&this.outputs[this.cases[i]]||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 Jn{constructor(t,i,s){this.type=t,this.branches=i,this.otherwise=s}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);const o=[];for(let p=1;p<t.length-1;p+=2){const m=i.parse(t[p],p,Je);if(!m)return null;const g=i.parse(t[p+1],p+1,s);if(!g)return null;o.push([m,g]),s=s||g.type}const d=i.parse(t[t.length-1],t.length-1,s);if(!d)return null;if(!s)throw new Error("Can't infer output type");return new Jn(s,o,d)}evaluate(t){for(const[i,s]of this.branches)if(i.evaluate(t))return s.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[i,s]of this.branches)t(i),t(s);t(this.otherwise)}outputDefined(){return this.branches.every(([t,i])=>i.outputDefined())&&this.otherwise.outputDefined()}}class Cs{constructor(t,i,s,o){this.type=t,this.input=i,this.beginIndex=s,this.endIndex=o}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,Ye),o=i.parse(t[2],2,ke);if(!s||!o)return null;if(!uo(s.type,[Ai(Ye),et,Ye]))return i.error(`Expected first argument to be of type array or string, but found ${vt(s.type)} instead`);if(t.length===4){const d=i.parse(t[3],3,ke);return d?new Cs(s.type,s,o,d):null}return new Cs(s.type,s,o)}evaluate(t){const i=this.input.evaluate(t),s=this.beginIndex.evaluate(t);let o;if(this.endIndex&&(o=this.endIndex.evaluate(t)),Xr(i,["string"]))return[...i].slice(s,o).join("");if(Xr(i,["array"]))return i.slice(s,o);throw new bt(`Expected first argument to be of type array or string, but found ${vt(Ue(i))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function wn(r,t){const i=r.length-1;let s,o,d=0,p=i,m=0;for(;d<=p;)if(m=Math.floor((d+p)/2),s=r[m],o=r[m+1],s<=t){if(m===i||t<o)return m;d=m+1}else{if(!(s>t))throw new bt("Input is not a number.");p=m-1}return 0}class Ft{constructor(t,i,s){this.type=t,this.input=i,this.labels=[],this.outputs=[];for(const[o,d]of s)this.labels.push(o),this.outputs.push(d)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");const s=i.parse(t[1],1,ke);if(!s)return null;const o=[];let d=null;i.expectedType&&i.expectedType.kind!=="value"&&(d=i.expectedType);for(let p=1;p<t.length;p+=2){const m=p===1?-1/0:t[p],g=t[p+1],x=p,v=p+1;if(typeof m!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',x);if(o.length&&o[o.length-1][0]>=m)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);const T=i.parse(g,v,d);if(!T)return null;d=d||T.type,o.push([m,T])}return new Ft(d,s,o)}evaluate(t){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(t);const o=this.input.evaluate(t);if(o<=i[0])return s[0].evaluate(t);const d=i.length;return o>=i[d-1]?s[d-1].evaluate(t):s[wn(i,o)].evaluate(t)}eachChild(t){t(this.input);for(const i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function kl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Es,vo,Hc=function(){if(vo)return Es;function r(t,i,s,o){this.cx=3*t,this.bx=3*(s-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(o-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=i,this.p2x=s,this.p2y=o}return vo=1,Es=r,r.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,i){if(i===void 0&&(i=1e-6),t<0)return 0;if(t>1)return 1;for(var s=t,o=0;o<8;o++){var d=this.sampleCurveX(s)-t;if(Math.abs(d)<i)return s;var p=this.sampleCurveDerivativeX(s);if(Math.abs(p)<1e-6)break;s-=d/p}var m=0,g=1;for(s=t,o=0;o<20&&(d=this.sampleCurveX(s),!(Math.abs(d-t)<i));o++)t>d?m=s:g=s,s=.5*(g-m)+m;return s},solve:function(t,i){return this.sampleCurveY(this.solveCurveX(t,i))}},Es}(),Qn=kl(Hc);class ui{constructor(t,i,s,o,d){this.type=t,this.operator=i,this.interpolation=s,this.input=o,this.labels=[],this.outputs=[];for(const[p,m]of d)this.labels.push(p),this.outputs.push(m)}static interpolationFactor(t,i,s,o){let d=0;if(t.name==="exponential")d=As(i,t.base,s,o);else if(t.name==="linear")d=As(i,1,s,o);else if(t.name==="cubic-bezier"){const p=t.controlPoints;d=new Qn(p[0],p[1],p[2],p[3]).solve(As(i,1,s,o))}return d}static parse(t,i){let[s,o,d,...p]=t;if(!Array.isArray(o)||o.length===0)return i.error("Expected an interpolation type expression.",1);if(o[0]==="linear")o={name:"linear"};else if(o[0]==="exponential"){const x=o[1];if(typeof x!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:x}}else{if(o[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const x=o.slice(1);if(x.length!==4||x.some(v=>typeof v!="number"||v<0||v>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:x}}}if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(d=i.parse(d,2,ke),!d)return null;const m=[];let g=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||i.expectedType==xr?i.expectedType&&i.expectedType.kind!=="value"&&(g=i.expectedType):g=hi;for(let x=0;x<p.length;x+=2){const v=p[x],T=p[x+1],M=x+3,E=x+4;if(typeof v!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',M);if(m.length&&m[m.length-1][0]>=v)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',M);const A=i.parse(T,E,g);if(!A)return null;g=g||A.type,m.push([v,A])}return Yr(g,ke)||Yr(g,_n)||Yr(g,hi)||Yr(g,ha)||Yr(g,qn)||Yr(g,xr)||Yr(g,ua)||Yr(g,Ai(ke))?new ui(g,s,o,d,m):i.error(`Type ${vt(g)} is not interpolatable.`)}evaluate(t){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(t);const o=this.input.evaluate(t);if(o<=i[0])return s[0].evaluate(t);const d=i.length;if(o>=i[d-1])return s[d-1].evaluate(t);const p=wn(i,o),m=ui.interpolationFactor(this.interpolation,o,i[p],i[p+1]),g=s[p].evaluate(t),x=s[p+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Mr(g,x,m);case"color":return it.interpolate(g,x,m);case"padding":return ti.interpolate(g,x,m);case"colorArray":return $t.interpolate(g,x,m);case"numberArray":return wi.interpolate(g,x,m);case"variableAnchorOffsetCollection":return Ti.interpolate(g,x,m);case"array":return xn(g,x,m);case"projectionDefinition":return _i.interpolate(g,x,m)}case"interpolate-hcl":switch(this.type.kind){case"color":return it.interpolate(g,x,m,"hcl");case"colorArray":return $t.interpolate(g,x,m,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return it.interpolate(g,x,m,"lab");case"colorArray":return $t.interpolate(g,x,m,"lab")}}}eachChild(t){t(this.input);for(const i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function As(r,t,i,s){const o=s-i,d=r-i;return o===0?0:t===1?d/o:(Math.pow(t,d)-1)/(Math.pow(t,o)-1)}const wr={color:it.interpolate,number:Mr,padding:ti.interpolate,numberArray:wi.interpolate,colorArray:$t.interpolate,variableAnchorOffsetCollection:Ti.interpolate,array:xn};class ks{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let s=null;const o=i.expectedType;o&&o.kind!=="value"&&(s=o);const d=[];for(const m of t.slice(1)){const g=i.parse(m,1+d.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,d.push(g)}if(!s)throw new Error("No output type");const p=o&&d.some(m=>Ss(o,m.type));return new ks(p?Ye:s,d)}evaluate(t){let i,s=null,o=0;for(const d of this.args)if(o++,s=d.evaluate(t),s&&s instanceof Bi&&!s.available&&(i||(i=s.name),s=null,o===this.args.length&&(s=i)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function zs(r,t){return r==="=="||r==="!="?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 Ls(r,t,i,s){return s.compare(t,i)===0}function yi(r,t,i){const s=r!=="=="&&r!=="!=";return class Hd{constructor(d,p,m){this.type=Je,this.lhs=d,this.rhs=p,this.collator=m,this.hasUntypedArgument=d.type.kind==="value"||p.type.kind==="value"}static parse(d,p){if(d.length!==3&&d.length!==4)return p.error("Expected two or three arguments.");const m=d[0];let g=p.parse(d[1],1,Ye);if(!g)return null;if(!zs(m,g.type))return p.concat(1).error(`"${m}" comparisons are not supported for type '${vt(g.type)}'.`);let x=p.parse(d[2],2,Ye);if(!x)return null;if(!zs(m,x.type))return p.concat(2).error(`"${m}" comparisons are not supported for type '${vt(x.type)}'.`);if(g.type.kind!==x.type.kind&&g.type.kind!=="value"&&x.type.kind!=="value")return p.error(`Cannot compare types '${vt(g.type)}' and '${vt(x.type)}'.`);s&&(g.type.kind==="value"&&x.type.kind!=="value"?g=new Oi(x.type,[g]):g.type.kind!=="value"&&x.type.kind==="value"&&(x=new Oi(g.type,[x])));let v=null;if(d.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(d[3],3,ca),!v)return null}return new Hd(g,x,v)}evaluate(d){const p=this.lhs.evaluate(d),m=this.rhs.evaluate(d);if(s&&this.hasUntypedArgument){const g=Ue(p),x=Ue(m);if(g.kind!==x.kind||g.kind!=="string"&&g.kind!=="number")throw new bt(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${g.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const g=Ue(p),x=Ue(m);if(g.kind!=="string"||x.kind!=="string")return t(d,p,m)}return this.collator?i(d,p,m,this.collator.evaluate(d)):t(d,p,m)}eachChild(d){d(this.lhs),d(this.rhs),this.collator&&d(this.collator)}outputDefined(){return!0}}}const zl=yi("==",function(r,t,i){return t===i},Ls),ya=yi("!=",function(r,t,i){return t!==i},function(r,t,i,s){return!Ls(0,t,i,s)}),Xc=yi("<",function(r,t,i){return t<i},function(r,t,i,s){return s.compare(t,i)<0}),bo=yi(">",function(r,t,i){return t>i},function(r,t,i,s){return s.compare(t,i)>0}),Yc=yi("<=",function(r,t,i){return t<=i},function(r,t,i,s){return s.compare(t,i)<=0}),Kc=yi(">=",function(r,t,i){return t>=i},function(r,t,i,s){return s.compare(t,i)>=0});class xa{constructor(t,i,s){this.type=ca,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=i}static parse(t,i){if(t.length!==2)return i.error("Expected one argument.");const s=t[1];if(typeof s!="object"||Array.isArray(s))return i.error("Collator options argument must be an object.");const o=i.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Je);if(!o)return null;const d=i.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Je);if(!d)return null;let p=null;return s.locale&&(p=i.parse(s.locale,1,et),!p)?null:new xa(o,d,p)}evaluate(t){return new vn(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 wo{constructor(t,i,s,o,d){this.type=et,this.number=t,this.locale=i,this.currency=s,this.minFractionDigits=o,this.maxFractionDigits=d}static parse(t,i){if(t.length!==3)return i.error("Expected two arguments.");const s=i.parse(t[1],1,ke);if(!s)return null;const o=t[2];if(typeof o!="object"||Array.isArray(o))return i.error("NumberFormat options argument must be an object.");let d=null;if(o.locale&&(d=i.parse(o.locale,1,et),!d))return null;let p=null;if(o.currency&&(p=i.parse(o.currency,1,et),!p))return null;let m=null;if(o["min-fraction-digits"]&&(m=i.parse(o["min-fraction-digits"],1,ke),!m))return null;let g=null;return o["max-fraction-digits"]&&(g=i.parse(o["max-fraction-digits"],1,ke),!g)?null:new wo(s,d,p,m,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 Tn{constructor(t){this.type=Hr,this.sections=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const s=t[1];if(!Array.isArray(s)&&typeof s=="object")return i.error("First argument must be an image or text section.");const o=[];let d=!1;for(let p=1;p<=t.length-1;++p){const m=t[p];if(d&&typeof m=="object"&&!Array.isArray(m)){d=!1;let g=null;if(m["font-scale"]&&(g=i.parse(m["font-scale"],1,ke),!g))return null;let x=null;if(m["text-font"]&&(x=i.parse(m["text-font"],1,Ai(et)),!x))return null;let v=null;if(m["text-color"]&&(v=i.parse(m["text-color"],1,hi),!v))return null;let T=null;if(m["vertical-align"]){if(typeof m["vertical-align"]=="string"&&!da.includes(m["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${m["vertical-align"]}' instead.`);if(T=i.parse(m["vertical-align"],1,et),!T)return null}const M=o[o.length-1];M.scale=g,M.font=x,M.textColor=v,M.verticalAlign=T}else{const g=i.parse(t[p],1,Ye);if(!g)return null;const x=g.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");d=!0,o.push({content:g,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Tn(o)}evaluate(t){return new bi(this.sections.map(i=>{const s=i.content.evaluate(t);return Ue(s)===Rt?new pa("",s,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(t):null):new pa(We(s),null,i.scale?i.scale.evaluate(t):null,i.font?i.font.evaluate(t).join(","):null,i.textColor?i.textColor.evaluate(t):null,i.verticalAlign?i.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const i of this.sections)t(i.content),i.scale&&t(i.scale),i.font&&t(i.font),i.textColor&&t(i.textColor),i.verticalAlign&&t(i.verticalAlign)}outputDefined(){return!1}}class To{constructor(t){this.type=Rt,this.input=t}static parse(t,i){if(t.length!==2)return i.error("Expected two arguments.");const s=i.parse(t[1],1,et);return s?new To(s):i.error("No image name provided.")}evaluate(t){const i=this.input.evaluate(t),s=Bi.fromString(i);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(i)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class va{constructor(t){this.type=ke,this.input=t}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=i.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${vt(s.type)} instead.`):new va(s):null}evaluate(t){const i=this.input.evaluate(t);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new bt(`Expected value to be of type string or array, but found ${vt(Ue(i))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const er=8192;function Jc(r,t){const i=(180+r[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r[1]*Math.PI/360)))/360,o=Math.pow(2,t.z);return[Math.round(i*o*er),Math.round(s*o*er)]}function ba(r,t){const i=Math.pow(2,t.z);return[(o=(r[0]/er+t.x)/i,360*o-180),(s=(r[1]/er+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,o}function Ds(r,t){r[0]=Math.min(r[0],t[0]),r[1]=Math.min(r[1],t[1]),r[2]=Math.max(r[2],t[0]),r[3]=Math.max(r[3],t[1])}function Rs(r,t){return!(r[0]<=t[0]||r[2]>=t[2]||r[1]<=t[1]||r[3]>=t[3])}function Qc(r,t,i){const s=r[0]-t[0],o=r[1]-t[1],d=r[0]-i[0],p=r[1]-i[1];return s*p-d*o==0&&s*d<=0&&o*p<=0}function wa(r,t,i,s){return(o=[s[0]-i[0],s[1]-i[1]])[0]*(d=[t[0]-r[0],t[1]-r[1]])[1]-o[1]*d[0]!=0&&!(!Dl(r,t,i,s)||!Dl(i,s,r,t));var o,d}function eh(r,t,i){for(const s of i)for(let o=0;o<s.length-1;++o)if(wa(r,t,s[o],s[o+1]))return!0;return!1}function Pn(r,t,i=!1){let s=!1;for(const m of t)for(let g=0;g<m.length-1;g++){if(Qc(r,m[g],m[g+1]))return i;(d=m[g])[1]>(o=r)[1]!=(p=m[g+1])[1]>o[1]&&o[0]<(p[0]-d[0])*(o[1]-d[1])/(p[1]-d[1])+d[0]&&(s=!s)}var o,d,p;return s}function Ll(r,t){for(const i of t)if(Pn(r,i))return!0;return!1}function Po(r,t){for(const i of r)if(!Pn(i,t))return!1;for(let i=0;i<r.length-1;++i)if(eh(r[i],r[i+1],t))return!1;return!0}function th(r,t){for(const i of t)if(Po(r,i))return!0;return!1}function Dl(r,t,i,s){const o=s[0]-i[0],d=s[1]-i[1],p=(r[0]-i[0])*d-o*(r[1]-i[1]),m=(t[0]-i[0])*d-o*(t[1]-i[1]);return p>0&&m<0||p<0&&m>0}function So(r,t,i){const s=[];for(let o=0;o<r.length;o++){const d=[];for(let p=0;p<r[o].length;p++){const m=Jc(r[o][p],i);Ds(t,m),d.push(m)}s.push(d)}return s}function Rl(r,t,i){const s=[];for(let o=0;o<r.length;o++){const d=So(r[o],t,i);s.push(d)}return s}function Ta(r,t,i,s){if(r[0]<i[0]||r[0]>i[2]){const o=.5*s;let d=r[0]-i[0]>o?-s:i[0]-r[0]>o?s:0;d===0&&(d=r[0]-i[2]>o?-s:i[2]-r[0]>o?s:0),r[0]+=d}Ds(t,r)}function Fl(r,t,i,s){const o=Math.pow(2,s.z)*er,d=[s.x*er,s.y*er],p=[];for(const m of r)for(const g of m){const x=[g.x+d[0],g.y+d[1]];Ta(x,t,i,o),p.push(x)}return p}function Bl(r,t,i,s){const o=Math.pow(2,s.z)*er,d=[s.x*er,s.y*er],p=[];for(const g of r){const x=[];for(const v of g){const T=[v.x+d[0],v.y+d[1]];Ds(t,T),x.push(T)}p.push(x)}if(t[2]-t[0]<=o/2){(m=t)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const g of p)for(const x of g)Ta(x,t,i,o)}var m;return p}class Sn{constructor(t,i){this.type=Je,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(bn(t[1])){const s=t[1];if(s.type==="FeatureCollection"){const o=[];for(const d of s.features){const{type:p,coordinates:m}=d.geometry;p==="Polygon"&&o.push(m),p==="MultiPolygon"&&o.push(...m)}if(o.length)return new Sn(s,{type:"MultiPolygon",coordinates:o})}else if(s.type==="Feature"){const o=s.geometry.type;if(o==="Polygon"||o==="MultiPolygon")return new Sn(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Sn(s,s)}return i.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(i,s){const o=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],p=i.canonicalID();if(s.type==="Polygon"){const m=So(s.coordinates,d,p),g=Fl(i.geometry(),o,d,p);if(!Rs(o,d))return!1;for(const x of g)if(!Pn(x,m))return!1}if(s.type==="MultiPolygon"){const m=Rl(s.coordinates,d,p),g=Fl(i.geometry(),o,d,p);if(!Rs(o,d))return!1;for(const x of g)if(!Ll(x,m))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(i,s){const o=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],p=i.canonicalID();if(s.type==="Polygon"){const m=So(s.coordinates,d,p),g=Bl(i.geometry(),o,d,p);if(!Rs(o,d))return!1;for(const x of g)if(!Po(x,m))return!1}if(s.type==="MultiPolygon"){const m=Rl(s.coordinates,d,p),g=Bl(i.geometry(),o,d,p);if(!Rs(o,d))return!1;for(const x of g)if(!th(x,m))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Mo=class{constructor(r=[],t=(i,s)=>i<s?-1:i>s?1:0){if(this.data=r,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;const r=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),r}peek(){return this.data[0]}_up(r){const{data:t,compare:i}=this,s=t[r];for(;r>0;){const o=r-1>>1,d=t[o];if(i(s,d)>=0)break;t[r]=d,r=o}t[r]=s}_down(r){const{data:t,compare:i}=this,s=this.length>>1,o=t[r];for(;r<s;){let d=1+(r<<1);const p=d+1;if(p<this.length&&i(t[p],t[d])<0&&(d=p),i(t[d],o)>=0)break;t[r]=t[d],r=d}t[r]=o}};function Io(r,t,i=0,s=r.length-1,o=ih){for(;s>i;){if(s-i>600){const g=s-i+1,x=t-i+1,v=Math.log(g),T=.5*Math.exp(2*v/3),M=.5*Math.sqrt(v*T*(g-T)/g)*(x-g/2<0?-1:1);Io(r,t,Math.max(i,Math.floor(t-x*T/g+M)),Math.min(s,Math.floor(t+(g-x)*T/g+M)),o)}const d=r[t];let p=i,m=s;for(Fs(r,i,t),o(r[s],d)>0&&Fs(r,i,s);p<m;){for(Fs(r,p,m),p++,m--;o(r[p],d)<0;)p++;for(;o(r[m],d)>0;)m--}o(r[i],d)===0?Fs(r,i,m):(m++,Fs(r,m,s)),m<=t&&(i=m+1),t<=m&&(s=m-1)}}function Fs(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}function ih(r,t){return r<t?-1:r>t?1:0}function Bs(r,t){if(r.length<=1)return[r];const i=[];let s,o;for(const d of r){const p=rh(d);p!==0&&(d.area=Math.abs(p),o===void 0&&(o=p<0),o===p<0?(s&&i.push(s),s=[d]):s.push(d))}if(s&&i.push(s),t>1)for(let d=0;d<i.length;d++)i[d].length<=t||(Io(i[d],t,1,i[d].length-1,Ol),i[d]=i[d].slice(0,t));return i}function Ol(r,t){return t.area-r.area}function rh(r){let t=0;for(let i,s,o=0,d=r.length,p=d-1;o<d;p=o++)i=r[o],s=r[p],t+=(s.x-i.x)*(i.y+s.y);return t}const jl=1/298.257223563,Nl=jl*(2-jl),Co=Math.PI/180;class Eo{constructor(t){const i=6378.137*Co*1e3,s=Math.cos(t*Co),o=1/(1-Nl*(1-s*s)),d=Math.sqrt(o);this.kx=i*d*s,this.ky=i*d*o*(1-Nl)}distance(t,i){const s=this.wrap(t[0]-i[0])*this.kx,o=(t[1]-i[1])*this.ky;return Math.sqrt(s*s+o*o)}pointOnLine(t,i){let s,o,d,p,m=1/0;for(let g=0;g<t.length-1;g++){let x=t[g][0],v=t[g][1],T=this.wrap(t[g+1][0]-x)*this.kx,M=(t[g+1][1]-v)*this.ky,E=0;T===0&&M===0||(E=(this.wrap(i[0]-x)*this.kx*T+(i[1]-v)*this.ky*M)/(T*T+M*M),E>1?(x=t[g+1][0],v=t[g+1][1]):E>0&&(x+=T/this.kx*E,v+=M/this.ky*E)),T=this.wrap(i[0]-x)*this.kx,M=(i[1]-v)*this.ky;const A=T*T+M*M;A<m&&(m=A,s=x,o=v,d=g,p=E)}return{point:[s,o],index:d,t:Math.max(0,Math.min(1,p))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function Vl(r,t){return t[0]-r[0]}function Pa(r){return r[1]-r[0]+1}function Cr(r,t){return r[1]>=r[0]&&r[1]<t}function ht(r,t){if(r[0]>r[1])return[null,null];const i=Pa(r);if(t){if(i===2)return[r,null];const o=Math.floor(i/2);return[[r[0],r[0]+o],[r[0]+o,r[1]]]}if(i===1)return[r,null];const s=Math.floor(i/2)-1;return[[r[0],r[0]+s],[r[0]+s+1,r[1]]]}function Ao(r,t){if(!Cr(t,r.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)Ds(i,r[s]);return i}function ko(r){const t=[1/0,1/0,-1/0,-1/0];for(const i of r)for(const s of i)Ds(t,s);return t}function Ul(r){return r[0]!==-1/0&&r[1]!==-1/0&&r[2]!==1/0&&r[3]!==1/0}function zo(r,t,i){if(!Ul(r)||!Ul(t))return NaN;let s=0,o=0;return r[2]<t[0]&&(s=t[0]-r[2]),r[0]>t[2]&&(s=r[0]-t[2]),r[1]>t[3]&&(o=r[1]-t[3]),r[3]<t[1]&&(o=t[1]-r[3]),i.distance([0,0],[s,o])}function Mn(r,t,i){const s=i.pointOnLine(t,r);return i.distance(r,s.point)}function Lo(r,t,i,s,o){const d=Math.min(Mn(r,[i,s],o),Mn(t,[i,s],o)),p=Math.min(Mn(i,[r,t],o),Mn(s,[r,t],o));return Math.min(d,p)}function nh(r,t,i,s,o){if(!Cr(t,r.length)||!Cr(s,i.length))return 1/0;let d=1/0;for(let p=t[0];p<t[1];++p){const m=r[p],g=r[p+1];for(let x=s[0];x<s[1];++x){const v=i[x],T=i[x+1];if(wa(m,g,v,T))return 0;d=Math.min(d,Lo(m,g,v,T,o))}}return d}function sh(r,t,i,s,o){if(!Cr(t,r.length)||!Cr(s,i.length))return NaN;let d=1/0;for(let p=t[0];p<=t[1];++p)for(let m=s[0];m<=s[1];++m)if(d=Math.min(d,o.distance(r[p],i[m])),d===0)return d;return d}function ah(r,t,i){if(Pn(r,t,!0))return 0;let s=1/0;for(const o of t){const d=o[0],p=o[o.length-1];if(d!==p&&(s=Math.min(s,Mn(r,[p,d],i)),s===0))return s;const m=i.pointOnLine(o,r);if(s=Math.min(s,i.distance(r,m.point)),s===0)return s}return s}function oh(r,t,i,s){if(!Cr(t,r.length))return NaN;for(let d=t[0];d<=t[1];++d)if(Pn(r[d],i,!0))return 0;let o=1/0;for(let d=t[0];d<t[1];++d){const p=r[d],m=r[d+1];for(const g of i)for(let x=0,v=g.length,T=v-1;x<v;T=x++){const M=g[T],E=g[x];if(wa(p,m,M,E))return 0;o=Math.min(o,Lo(p,m,M,E,s))}}return o}function $l(r,t){for(const i of r)for(const s of i)if(Pn(s,t,!0))return!0;return!1}function lh(r,t,i,s=1/0){const o=ko(r),d=ko(t);if(s!==1/0&&zo(o,d,i)>=s)return s;if(Rs(o,d)){if($l(r,t))return 0}else if($l(t,r))return 0;let p=1/0;for(const m of r)for(let g=0,x=m.length,v=x-1;g<x;v=g++){const T=m[v],M=m[g];for(const E of t)for(let A=0,L=E.length,F=L-1;A<L;F=A++){const V=E[F],Q=E[A];if(wa(T,M,V,Q))return 0;p=Math.min(p,Lo(T,M,V,Q,i))}}return p}function Zl(r,t,i,s,o,d){if(!d)return;const p=zo(Ao(s,d),o,i);p<t&&r.push([p,d,[0,0]])}function Sa(r,t,i,s,o,d,p){if(!d||!p)return;const m=zo(Ao(s,d),Ao(o,p),i);m<t&&r.push([m,d,p])}function Ma(r,t,i,s,o=1/0){let d=Math.min(s.distance(r[0],i[0][0]),o);if(d===0)return d;const p=new Mo([[0,[0,r.length-1],[0,0]]],Vl),m=ko(i);for(;p.length>0;){const g=p.pop();if(g[0]>=d)continue;const x=g[1],v=t?50:100;if(Pa(x)<=v){if(!Cr(x,r.length))return NaN;if(t){const T=oh(r,x,i,s);if(isNaN(T)||T===0)return T;d=Math.min(d,T)}else for(let T=x[0];T<=x[1];++T){const M=ah(r[T],i,s);if(d=Math.min(d,M),d===0)return 0}}else{const T=ht(x,t);Zl(p,d,s,r,m,T[0]),Zl(p,d,s,r,m,T[1])}}return d}function Ia(r,t,i,s,o,d=1/0){let p=Math.min(d,o.distance(r[0],i[0]));if(p===0)return p;const m=new Mo([[0,[0,r.length-1],[0,i.length-1]]],Vl);for(;m.length>0;){const g=m.pop();if(g[0]>=p)continue;const x=g[1],v=g[2],T=t?50:100,M=s?50:100;if(Pa(x)<=T&&Pa(v)<=M){if(!Cr(x,r.length)&&Cr(v,i.length))return NaN;let E;if(t&&s)E=nh(r,x,i,v,o),p=Math.min(p,E);else if(t&&!s){const A=r.slice(x[0],x[1]+1);for(let L=v[0];L<=v[1];++L)if(E=Mn(i[L],A,o),p=Math.min(p,E),p===0)return p}else if(!t&&s){const A=i.slice(v[0],v[1]+1);for(let L=x[0];L<=x[1];++L)if(E=Mn(r[L],A,o),p=Math.min(p,E),p===0)return p}else E=sh(r,x,i,v,o),p=Math.min(p,E)}else{const E=ht(x,t),A=ht(v,s);Sa(m,p,o,r,i,E[0],A[0]),Sa(m,p,o,r,i,E[0],A[1]),Sa(m,p,o,r,i,E[1],A[0]),Sa(m,p,o,r,i,E[1],A[1])}}return p}function Do(r){return r.type==="MultiPolygon"?r.coordinates.map(t=>({type:"Polygon",coordinates:t})):r.type==="MultiLineString"?r.coordinates.map(t=>({type:"LineString",coordinates:t})):r.type==="MultiPoint"?r.coordinates.map(t=>({type:"Point",coordinates:t})):[r]}class In{constructor(t,i){this.type=ke,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(bn(t[1])){const s=t[1];if(s.type==="FeatureCollection")return new In(s,s.features.map(o=>Do(o.geometry)).flat());if(s.type==="Feature")return new In(s,Do(s.geometry));if("type"in s&&"coordinates"in s)return new In(s,Do(s))}return i.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(i,s){const o=i.geometry(),d=o.flat().map(g=>ba([g.x,g.y],i.canonical));if(o.length===0)return NaN;const p=new Eo(d[0][1]);let m=1/0;for(const g of s){switch(g.type){case"Point":m=Math.min(m,Ia(d,!1,[g.coordinates],!1,p,m));break;case"LineString":m=Math.min(m,Ia(d,!1,g.coordinates,!0,p,m));break;case"Polygon":m=Math.min(m,Ma(d,!1,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries);if(t.geometryType()==="LineString")return function(i,s){const o=i.geometry(),d=o.flat().map(g=>ba([g.x,g.y],i.canonical));if(o.length===0)return NaN;const p=new Eo(d[0][1]);let m=1/0;for(const g of s){switch(g.type){case"Point":m=Math.min(m,Ia(d,!0,[g.coordinates],!1,p,m));break;case"LineString":m=Math.min(m,Ia(d,!0,g.coordinates,!0,p,m));break;case"Polygon":m=Math.min(m,Ma(d,!0,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries);if(t.geometryType()==="Polygon")return function(i,s){const o=i.geometry();if(o.length===0||o[0].length===0)return NaN;const d=Bs(o,0).map(g=>g.map(x=>x.map(v=>ba([v.x,v.y],i.canonical)))),p=new Eo(d[0][0][0][1]);let m=1/0;for(const g of s)for(const x of d){switch(g.type){case"Point":m=Math.min(m,Ma([g.coordinates],!1,x,p,m));break;case"LineString":m=Math.min(m,Ma(g.coordinates,!0,x,p,m));break;case"Polygon":m=Math.min(m,lh(x,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Os{constructor(t){this.type=Ye,this.key=t}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=t[1];return s==null?i.error("Global state property must be defined."):typeof s!="string"?i.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new Os(s)}evaluate(t){var i;const s=(i=t.globals)===null||i===void 0?void 0:i.globalState;return s&&Object.keys(s).length!==0?Yn(s,this.key):null}eachChild(){}outputDefined(){return!1}}const es={"==":zl,"!=":ya,">":bo,"<":Xc,">=":Kc,"<=":Yc,array:Oi,at:ga,boolean:Oi,case:Jn,coalesce:ks,collator:xa,format:Tn,image:To,in:_a,"index-of":Qi,interpolate:ui,"interpolate-hcl":ui,"interpolate-lab":ui,length:va,let:Is,literal:Ir,match:ii,number:Oi,"number-format":wo,object:Oi,slice:Cs,step:Ft,string:Oi,"to-boolean":br,"to-color":br,"to-number":br,"to-string":br,var:ma,within:Sn,distance:In,"global-state":Os};class Gi{constructor(t,i,s,o){this.name=t,this.type=i,this._evaluate=s,this.args=o}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,i){const s=t[0],o=Gi.definitions[s];if(!o)return i.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const d=Array.isArray(o)?o[0]:o.type,p=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,m=p.filter(([x])=>!Array.isArray(x)||x.length===t.length-1);let g=null;for(const[x,v]of m){g=new Kn(i.registry,Ca,i.path,null,i.scope);const T=[];let M=!1;for(let E=1;E<t.length;E++){const A=t[E],L=Array.isArray(x)?x[E-1]:x.type,F=g.parse(A,1+T.length,L);if(!F){M=!0;break}T.push(F)}if(!M)if(Array.isArray(x)&&x.length!==T.length)g.error(`Expected ${x.length} arguments, but found ${T.length} instead.`);else{for(let E=0;E<T.length;E++){const A=Array.isArray(x)?x[E]:x.type,L=T[E];g.concat(E+1).checkSubtype(A,L.type)}if(g.errors.length===0)return new Gi(s,d,v,T)}}if(m.length===1)i.errors.push(...g.errors);else{const x=(m.length?m:p).map(([T])=>{return M=T,Array.isArray(M)?`(${M.map(vt).join(", ")})`:`(${vt(M.type)}...)`;var M}).join(" | "),v=[];for(let T=1;T<t.length;T++){const M=i.parse(t[T],1+v.length);if(!M)return null;v.push(vt(M.type))}i.error(`Expected arguments of type ${x}, but found (${v.join(", ")}) instead.`)}return null}static register(t,i){Gi.definitions=i;for(const s in i)t[s]=Gi}}function Gl(r,[t,i,s,o]){t=t.evaluate(r),i=i.evaluate(r),s=s.evaluate(r);const d=o?o.evaluate(r):1,p=Pt(t,i,s,d);if(p)throw new bt(p);return new it(t/255,i/255,s/255,d,!1)}function ql(r,t){return r in t}function Ro(r,t){const i=t[r];return i===void 0?null:i}function Cn(r){return{type:r}}function Ca(r){if(r instanceof ma)return Ca(r.boundExpression);if(r instanceof Gi&&r.name==="error"||r instanceof xa||r instanceof Sn||r instanceof In||r instanceof Os)return!1;const t=r instanceof br||r instanceof Oi;let i=!0;return r.eachChild(s=>{i=t?i&&Ca(s):i&&s instanceof Ir}),!!i&&Ea(r)&&Aa(r,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Ea(r){if(r instanceof Gi&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||/^filter-/.test(r.name))||r instanceof Sn||r instanceof In)return!1;let t=!0;return r.eachChild(i=>{t&&!Ea(i)&&(t=!1)}),t}function js(r){if(r instanceof Gi&&r.name==="feature-state")return!1;let t=!0;return r.eachChild(i=>{t&&!js(i)&&(t=!1)}),t}function Aa(r,t){if(r instanceof Gi&&t.indexOf(r.name)>=0)return!1;let i=!0;return r.eachChild(s=>{i&&!Aa(s,t)&&(i=!1)}),i}function Wl(r){return{result:"success",value:r}}function ts(r){return{result:"error",value:r}}function Jr(r){return r["property-type"]==="data-driven"||r["property-type"]==="cross-faded-data-driven"}function Hl(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function Fo(r){return!!r.expression&&r.expression.interpolated}function nt(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function Ns(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&Ue(r)===Wr}function ch(r){return r}function Xl(r,t){const i=r.stops&&typeof r.stops[0][0]=="object",s=i||!(i||r.property!==void 0),o=r.type||(Fo(t)?"exponential":"interval"),d=function(v){switch(v.type){case"color":return it.parse;case"padding":return ti.parse;case"numberArray":return wi.parse;case"colorArray":return $t.parse;default:return null}}(t);if(d&&((r=gi({},r)).stops&&(r.stops=r.stops.map(v=>[v[0],d(v[1])])),r.default=d(r.default?r.default:t.default)),r.colorSpace&&(p=r.colorSpace)!=="rgb"&&p!=="hcl"&&p!=="lab")throw new Error(`Unknown color space: "${r.colorSpace}"`);var p;const m=function(v){switch(v){case"exponential":return Kl;case"interval":return hh;case"categorical":return Yl;case"identity":return uh;default:throw new Error(`Unknown function type "${v}"`)}}(o);let g,x;if(o==="categorical"){g=Object.create(null);for(const v of r.stops)g[v[0]]=v[1];x=typeof r.stops[0][0]}if(i){const v={},T=[];for(let A=0;A<r.stops.length;A++){const L=r.stops[A],F=L[0].zoom;v[F]===void 0&&(v[F]={zoom:F,type:r.type,property:r.property,default:r.default,stops:[]},T.push(F)),v[F].stops.push([L[0].value,L[1]])}const M=[];for(const A of T)M.push([v[A].zoom,Xl(v[A],t)]);const E={name:"linear"};return{kind:"composite",interpolationType:E,interpolationFactor:ui.interpolationFactor.bind(void 0,E),zoomStops:M.map(A=>A[0]),evaluate:({zoom:A},L)=>Kl({stops:M,base:r.base},t,A).evaluate(A,L)}}if(s){const v=o==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:ui.interpolationFactor.bind(void 0,v),zoomStops:r.stops.map(T=>T[0]),evaluate:({zoom:T})=>m(r,t,T,g,x)}}return{kind:"source",evaluate(v,T){const M=T&&T.properties?T.properties[r.property]:void 0;return M===void 0?Qr(r.default,t.default):m(r,t,M,g,x)}}}function Qr(r,t,i){return r!==void 0?r:t!==void 0?t:i!==void 0?i:void 0}function Yl(r,t,i,s,o){return Qr(typeof i===o?s[i]:void 0,r.default,t.default)}function hh(r,t,i){if(nt(i)!=="number")return Qr(r.default,t.default);const s=r.stops.length;if(s===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[s-1][0])return r.stops[s-1][1];const o=wn(r.stops.map(d=>d[0]),i);return r.stops[o][1]}function Kl(r,t,i){const s=r.base!==void 0?r.base:1;if(nt(i)!=="number")return Qr(r.default,t.default);const o=r.stops.length;if(o===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[o-1][0])return r.stops[o-1][1];const d=wn(r.stops.map(v=>v[0]),i),p=function(v,T,M,E){const A=E-M,L=v-M;return A===0?0:T===1?L/A:(Math.pow(T,L)-1)/(Math.pow(T,A)-1)}(i,s,r.stops[d][0],r.stops[d+1][0]),m=r.stops[d][1],g=r.stops[d+1][1],x=wr[t.type]||ch;return typeof m.evaluate=="function"?{evaluate(...v){const T=m.evaluate.apply(void 0,v),M=g.evaluate.apply(void 0,v);if(T!==void 0&&M!==void 0)return x(T,M,p,r.colorSpace)}}:x(m,g,p,r.colorSpace)}function uh(r,t,i){switch(t.type){case"color":i=it.parse(i);break;case"formatted":i=bi.fromString(i.toString());break;case"resolvedImage":i=Bi.fromString(i.toString());break;case"padding":i=ti.parse(i);break;case"colorArray":i=$t.parse(i);break;case"numberArray":i=wi.parse(i);break;default:nt(i)===t.type||t.type==="enum"&&t.values[i]||(i=void 0)}return Qr(i,r.default,t.default)}Gi.register(es,{error:[{kind:"error"},[et],(r,[t])=>{throw new bt(t.evaluate(r))}],typeof:[et,[Ye],(r,[t])=>vt(Ue(t.evaluate(r)))],"to-rgba":[Ai(ke,4),[hi],(r,[t])=>{const[i,s,o,d]=t.evaluate(r).rgb;return[255*i,255*s,255*o,d]}],rgb:[hi,[ke,ke,ke],Gl],rgba:[hi,[ke,ke,ke,ke],Gl],has:{type:Je,overloads:[[[et],(r,[t])=>ql(t.evaluate(r),r.properties())],[[et,Wr],(r,[t,i])=>ql(t.evaluate(r),i.evaluate(r))]]},get:{type:Ye,overloads:[[[et],(r,[t])=>Ro(t.evaluate(r),r.properties())],[[et,Wr],(r,[t,i])=>Ro(t.evaluate(r),i.evaluate(r))]]},"feature-state":[Ye,[et],(r,[t])=>Ro(t.evaluate(r),r.featureState||{})],properties:[Wr,[],r=>r.properties()],"geometry-type":[et,[],r=>r.geometryType()],id:[Ye,[],r=>r.id()],zoom:[ke,[],r=>r.globals.zoom],"heatmap-density":[ke,[],r=>r.globals.heatmapDensity||0],elevation:[ke,[],r=>r.globals.elevation||0],"line-progress":[ke,[],r=>r.globals.lineProgress||0],accumulated:[Ye,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[ke,Cn(ke),(r,t)=>{let i=0;for(const s of t)i+=s.evaluate(r);return i}],"*":[ke,Cn(ke),(r,t)=>{let i=1;for(const s of t)i*=s.evaluate(r);return i}],"-":{type:ke,overloads:[[[ke,ke],(r,[t,i])=>t.evaluate(r)-i.evaluate(r)],[[ke],(r,[t])=>-t.evaluate(r)]]},"/":[ke,[ke,ke],(r,[t,i])=>t.evaluate(r)/i.evaluate(r)],"%":[ke,[ke,ke],(r,[t,i])=>t.evaluate(r)%i.evaluate(r)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(r,[t,i])=>Math.pow(t.evaluate(r),i.evaluate(r))],sqrt:[ke,[ke],(r,[t])=>Math.sqrt(t.evaluate(r))],log10:[ke,[ke],(r,[t])=>Math.log(t.evaluate(r))/Math.LN10],ln:[ke,[ke],(r,[t])=>Math.log(t.evaluate(r))],log2:[ke,[ke],(r,[t])=>Math.log(t.evaluate(r))/Math.LN2],sin:[ke,[ke],(r,[t])=>Math.sin(t.evaluate(r))],cos:[ke,[ke],(r,[t])=>Math.cos(t.evaluate(r))],tan:[ke,[ke],(r,[t])=>Math.tan(t.evaluate(r))],asin:[ke,[ke],(r,[t])=>Math.asin(t.evaluate(r))],acos:[ke,[ke],(r,[t])=>Math.acos(t.evaluate(r))],atan:[ke,[ke],(r,[t])=>Math.atan(t.evaluate(r))],min:[ke,Cn(ke),(r,t)=>Math.min(...t.map(i=>i.evaluate(r)))],max:[ke,Cn(ke),(r,t)=>Math.max(...t.map(i=>i.evaluate(r)))],abs:[ke,[ke],(r,[t])=>Math.abs(t.evaluate(r))],round:[ke,[ke],(r,[t])=>{const i=t.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[ke,[ke],(r,[t])=>Math.floor(t.evaluate(r))],ceil:[ke,[ke],(r,[t])=>Math.ceil(t.evaluate(r))],"filter-==":[Je,[et,Ye],(r,[t,i])=>r.properties()[t.value]===i.value],"filter-id-==":[Je,[Ye],(r,[t])=>r.id()===t.value],"filter-type-==":[Je,[et],(r,[t])=>r.geometryType()===t.value],"filter-<":[Je,[et,Ye],(r,[t,i])=>{const s=r.properties()[t.value],o=i.value;return typeof s==typeof o&&s<o}],"filter-id-<":[Je,[Ye],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i<s}],"filter->":[Je,[et,Ye],(r,[t,i])=>{const s=r.properties()[t.value],o=i.value;return typeof s==typeof o&&s>o}],"filter-id->":[Je,[Ye],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i>s}],"filter-<=":[Je,[et,Ye],(r,[t,i])=>{const s=r.properties()[t.value],o=i.value;return typeof s==typeof o&&s<=o}],"filter-id-<=":[Je,[Ye],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i<=s}],"filter->=":[Je,[et,Ye],(r,[t,i])=>{const s=r.properties()[t.value],o=i.value;return typeof s==typeof o&&s>=o}],"filter-id->=":[Je,[Ye],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i>=s}],"filter-has":[Je,[Ye],(r,[t])=>t.value in r.properties()],"filter-has-id":[Je,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[Je,[Ai(et)],(r,[t])=>t.value.indexOf(r.geometryType())>=0],"filter-id-in":[Je,[Ai(Ye)],(r,[t])=>t.value.indexOf(r.id())>=0],"filter-in-small":[Je,[et,Ai(Ye)],(r,[t,i])=>i.value.indexOf(r.properties()[t.value])>=0],"filter-in-large":[Je,[et,Ai(Ye)],(r,[t,i])=>function(s,o,d,p){for(;d<=p;){const m=d+p>>1;if(o[m]===s)return!0;o[m]>s?p=m-1:d=m+1}return!1}(r.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Je,overloads:[[[Je,Je],(r,[t,i])=>t.evaluate(r)&&i.evaluate(r)],[Cn(Je),(r,t)=>{for(const i of t)if(!i.evaluate(r))return!1;return!0}]]},any:{type:Je,overloads:[[[Je,Je],(r,[t,i])=>t.evaluate(r)||i.evaluate(r)],[Cn(Je),(r,t)=>{for(const i of t)if(i.evaluate(r))return!0;return!1}]]},"!":[Je,[Je],(r,[t])=>!t.evaluate(r)],"is-supported-script":[Je,[et],(r,[t])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(t.evaluate(r))}],upcase:[et,[et],(r,[t])=>t.evaluate(r).toUpperCase()],downcase:[et,[et],(r,[t])=>t.evaluate(r).toLowerCase()],concat:[et,Cn(Ye),(r,t)=>t.map(i=>We(i.evaluate(r))).join("")],"resolved-locale":[et,[ca],(r,[t])=>t.evaluate(r).resolvedLocale()]});class Bo{constructor(t,i){this.expression=t,this._warningHistory={},this._evaluator=new xo,this._defaultValue=i?function(s){if(s.type==="color"&&Ns(s.default))return new it(0,0,0,0);switch(s.type){case"color":return it.parse(s.default)||null;case"padding":return ti.parse(s.default)||null;case"numberArray":return wi.parse(s.default)||null;case"colorArray":return $t.parse(s.default)||null;case"variableAnchorOffsetCollection":return Ti.parse(s.default)||null;case"projectionDefinition":return _i.parse(s.default)||null;default:return s.default===void 0?null:s.default}}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null}evaluateWithoutErrorHandling(t,i,s,o,d,p){return this._evaluator.globals=t,this._evaluator.feature=i,this._evaluator.featureState=s,this._evaluator.canonical=o,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(t,i,s,o,d,p){this._evaluator.globals=t,this._evaluator.feature=i||null,this._evaluator.featureState=s||null,this._evaluator.canonical=o,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p||null;try{const m=this.expression.evaluate(this._evaluator);if(m==null||typeof m=="number"&&m!=m)return this._defaultValue;if(this._enumValues&&!(m in this._enumValues))throw new bt(`Expected value to be one of ${Object.keys(this._enumValues).map(g=>JSON.stringify(g)).join(", ")}, but found ${JSON.stringify(m)} instead.`);return m}catch(m){return this._warningHistory[m.message]||(this._warningHistory[m.message]=!0,typeof console<"u"&&console.warn(m.message)),this._defaultValue}}}function ka(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in es}function Vs(r,t){const i=new Kn(es,Ca,[],t?function(o){const d={color:hi,string:et,number:ke,enum:et,boolean:Je,formatted:Hr,padding:ha,numberArray:qn,colorArray:xr,projectionDefinition:_n,resolvedImage:Rt,variableAnchorOffsetCollection:ua};return o.type==="array"?Ai(d[o.value]||Ye,o.length):d[o.type]}(t):void 0),s=i.parse(r,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?Wl(new Bo(s,t)):ts(i.errors)}class Us{constructor(t,i){this.kind=t,this._styleExpression=i,this.isStateDependent=t!=="constant"&&!js(i.expression),this.globalStateRefs=Gs(i.expression)}evaluateWithoutErrorHandling(t,i,s,o,d,p){return this._styleExpression.evaluateWithoutErrorHandling(t,i,s,o,d,p)}evaluate(t,i,s,o,d,p){return this._styleExpression.evaluate(t,i,s,o,d,p)}}class Oo{constructor(t,i,s,o){this.kind=t,this.zoomStops=s,this._styleExpression=i,this.isStateDependent=t!=="camera"&&!js(i.expression),this.globalStateRefs=Gs(i.expression),this.interpolationType=o}evaluateWithoutErrorHandling(t,i,s,o,d,p){return this._styleExpression.evaluateWithoutErrorHandling(t,i,s,o,d,p)}evaluate(t,i,s,o,d,p){return this._styleExpression.evaluate(t,i,s,o,d,p)}interpolationFactor(t,i,s){return this.interpolationType?ui.interpolationFactor(this.interpolationType,t,i,s):0}}function Jl(r,t){const i=Vs(r,t);if(i.result==="error")return i;const s=i.value.expression,o=Ea(s);if(!o&&!Jr(t))return ts([new At("","data expressions not supported")]);const d=Aa(s,["zoom"]);if(!d&&!Hl(t))return ts([new At("","zoom expressions not supported")]);const p=Zs(s);return p||d?p instanceof At?ts([p]):p instanceof ui&&!Fo(t)?ts([new At("",'"interpolate" expressions cannot be used with this property')]):Wl(p?new Oo(o?"camera":"composite",i.value,p.labels,p instanceof ui?p.interpolation:void 0):new Us(o?"constant":"source",i.value)):ts([new At("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class $s{constructor(t,i){this._parameters=t,this._specification=i,gi(this,Xl(this._parameters,this._specification))}static deserialize(t){return new $s(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Zs(r){let t=null;if(r instanceof Is)t=Zs(r.result);else if(r instanceof ks){for(const i of r.args)if(t=Zs(i),t)break}else(r instanceof Ft||r instanceof ui)&&r.input instanceof Gi&&r.input.name==="zoom"&&(t=r);return t instanceof At||r.eachChild(i=>{const s=Zs(i);s instanceof At?t=s:!t&&s?t=new At("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new At("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Gs(r,t=new Set){return r instanceof Os&&t.add(r.key),r.eachChild(i=>{Gs(i,t)}),t}function za(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const t of r.slice(1))if(!za(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}const jo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function En(r){if(r==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};za(r)||(r=An(r));const t=Vs(r,jo);if(t.result==="error")throw new Error(t.value.map(i=>`${i.key}: ${i.message}`).join(", "));return{filter:(i,s,o)=>t.value.evaluate(i,s,{},o),needGeometry:La(r),getGlobalStateRefs:()=>Gs(t.value.expression)}}function No(r,t){return r<t?-1:r>t?1:0}function La(r){if(!Array.isArray(r))return!1;if(r[0]==="within"||r[0]==="distance")return!0;for(let t=1;t<r.length;t++)if(La(r[t]))return!0;return!1}function An(r){if(!r)return!0;const t=r[0];return r.length<=1?t!=="any":t==="=="?Vo(r[1],r[2],"=="):t==="!="?Da(Vo(r[1],r[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Vo(r[1],r[2],t):t==="any"?(i=r.slice(1),["any"].concat(i.map(An))):t==="all"?["all"].concat(r.slice(1).map(An)):t==="none"?["all"].concat(r.slice(1).map(An).map(Da)):t==="in"?Ql(r[1],r.slice(2)):t==="!in"?Da(Ql(r[1],r.slice(2))):t==="has"?ec(r[1]):t!=="!has"||Da(ec(r[1]));var i}function Vo(r,t,i){switch(r){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,r,t]}}function Ql(r,t){if(t.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(i=>typeof i!=typeof t[0])?["filter-in-large",r,["literal",t.sort(No)]]:["filter-in-small",r,["literal",t]]}}function ec(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function Da(r){return["!",r]}function Uo(r){const t=typeof r;if(t==="number"||t==="boolean"||t==="string"||r==null)return JSON.stringify(r);if(Array.isArray(r)){let o="[";for(const d of r)o+=`${Uo(d)},`;return`${o}]`}const i=Object.keys(r).sort();let s="{";for(let o=0;o<i.length;o++)s+=`${JSON.stringify(i[o])}:${Uo(r[i[o]])},`;return`${s}}`}function dh(r){let t="";for(const i of qe)t+=`/${Uo(r[i])}`;return t}function $o(r){const t=r.value;return t?[new Te(r.key,t,"constants have been deprecated as of v8")]:[]}function kt(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function Tr(r){if(Array.isArray(r))return r.map(Tr);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const t={};for(const i in r)t[i]=Tr(r[i]);return t}return kt(r)}function qi(r){const t=r.key,i=r.value,s=r.valueSpec||{},o=r.objectElementValidators||{},d=r.style,p=r.styleSpec,m=r.validateSpec;let g=[];const x=nt(i);if(x!=="object")return[new Te(t,i,`object expected, ${x} found`)];for(const v in i){const T=v.split(".")[0],M=Yn(s,T)||s["*"];let E;if(Yn(o,T))E=o[T];else if(Yn(s,T))E=m;else if(o["*"])E=o["*"];else{if(!s["*"]){g.push(new Te(t,i[v],`unknown property "${v}"`));continue}E=m}g=g.concat(E({key:(t&&`${t}.`)+v,value:i[v],valueSpec:M,style:d,styleSpec:p,object:i,objectKey:v,validateSpec:m},i))}for(const v in s)o[v]||s[v].required&&s[v].default===void 0&&i[v]===void 0&&g.push(new Te(t,i,`missing required property "${v}"`));return g}function Ra(r){const t=r.value,i=r.valueSpec,s=r.style,o=r.styleSpec,d=r.key,p=r.arrayElementValidator||r.validateSpec;if(nt(t)!=="array")return[new Te(d,t,`array expected, ${nt(t)} found`)];if(i.length&&t.length!==i.length)return[new Te(d,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new Te(d,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let m={type:i.value,values:i.values};o.$version<7&&(m.function=i.function),nt(i.value)==="object"&&(m=i.value);let g=[];for(let x=0;x<t.length;x++)g=g.concat(p({array:t,arrayIndex:x,value:t[x],valueSpec:m,validateSpec:r.validateSpec,style:s,styleSpec:o,key:`${d}[${x}]`}));return g}function qs(r){const t=r.key,i=r.value,s=r.valueSpec;let o=nt(i);return o==="number"&&i!=i&&(o="NaN"),o!=="number"?[new Te(t,i,`number expected, ${o} found`)]:"minimum"in s&&i<s.minimum?[new Te(t,i,`${i} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&i>s.maximum?[new Te(t,i,`${i} is greater than the maximum value ${s.maximum}`)]:[]}function tc(r){const t=r.valueSpec,i=kt(r.value.type);let s,o,d,p={};const m=i!=="categorical"&&r.value.property===void 0,g=!m,x=nt(r.value.stops)==="array"&&nt(r.value.stops[0])==="array"&&nt(r.value.stops[0][0])==="object",v=qi({key:r.key,value:r.value,valueSpec:r.styleSpec.function,validateSpec:r.validateSpec,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function(E){if(i==="identity")return[new Te(E.key,E.value,'identity function may not have a "stops" property')];let A=[];const L=E.value;return A=A.concat(Ra({key:E.key,value:L,valueSpec:E.valueSpec,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec,arrayElementValidator:T})),nt(L)==="array"&&L.length===0&&A.push(new Te(E.key,L,"array must have at least one stop")),A},default:function(E){return E.validateSpec({key:E.key,value:E.value,valueSpec:t,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec})}}});return i==="identity"&&m&&v.push(new Te(r.key,r.value,'missing required property "property"')),i==="identity"||r.value.stops||v.push(new Te(r.key,r.value,'missing required property "stops"')),i==="exponential"&&r.valueSpec.expression&&!Fo(r.valueSpec)&&v.push(new Te(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(g&&!Jr(r.valueSpec)?v.push(new Te(r.key,r.value,"property functions not supported")):m&&!Hl(r.valueSpec)&&v.push(new Te(r.key,r.value,"zoom functions not supported"))),i!=="categorical"&&!x||r.value.property!==void 0||v.push(new Te(r.key,r.value,'"property" property is required')),v;function T(E){let A=[];const L=E.value,F=E.key;if(nt(L)!=="array")return[new Te(F,L,`array expected, ${nt(L)} found`)];if(L.length!==2)return[new Te(F,L,`array length 2 expected, length ${L.length} found`)];if(x){if(nt(L[0])!=="object")return[new Te(F,L,`object expected, ${nt(L[0])} found`)];if(L[0].zoom===void 0)return[new Te(F,L,"object stop key must have zoom")];if(L[0].value===void 0)return[new Te(F,L,"object stop key must have value")];if(d&&d>kt(L[0].zoom))return[new Te(F,L[0].zoom,"stop zoom values must appear in ascending order")];kt(L[0].zoom)!==d&&(d=kt(L[0].zoom),o=void 0,p={}),A=A.concat(qi({key:`${F}[0]`,value:L[0],valueSpec:{zoom:{}},validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec,objectElementValidators:{zoom:qs,value:M}}))}else A=A.concat(M({key:`${F}[0]`,value:L[0],validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec},L));return ka(Tr(L[1]))?A.concat([new Te(`${F}[1]`,L[1],"expressions are not allowed in function stops.")]):A.concat(E.validateSpec({key:`${F}[1]`,value:L[1],valueSpec:t,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec}))}function M(E,A){const L=nt(E.value),F=kt(E.value),V=E.value!==null?E.value:A;if(s){if(L!==s)return[new Te(E.key,V,`${L} stop domain type must match previous stop domain type ${s}`)]}else s=L;if(L!=="number"&&L!=="string"&&L!=="boolean")return[new Te(E.key,V,"stop domain value must be a number, string, or boolean")];if(L!=="number"&&i!=="categorical"){let Q=`number expected, ${L} found`;return Jr(t)&&i===void 0&&(Q+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Te(E.key,V,Q)]}return i!=="categorical"||L!=="number"||isFinite(F)&&Math.floor(F)===F?i!=="categorical"&&L==="number"&&o!==void 0&&F<o?[new Te(E.key,V,"stop domain values must appear in ascending order")]:(o=F,i==="categorical"&&F in p?[new Te(E.key,V,"stop domain values must be unique")]:(p[F]=!0,[])):[new Te(E.key,V,`integer expected, found ${F}`)]}}function kn(r){const t=(r.expressionContext==="property"?Jl:Vs)(Tr(r.value),r.valueSpec);if(t.result==="error")return t.value.map(s=>new Te(`${r.key}${s.key}`,r.value,s.message));const i=t.value.expression||t.value._styleExpression.expression;if(r.expressionContext==="property"&&r.propertyKey==="text-font"&&!i.outputDefined())return[new Te(r.key,r.value,`Invalid data expression for "${r.propertyKey}". Output values must be contained as literals within the expression.`)];if(r.expressionContext==="property"&&r.propertyType==="layout"&&!js(i))return[new Te(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter"&&!js(i))return[new Te(r.key,r.value,'"feature-state" data expressions are not supported with filters.')];if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!Aa(i,["zoom","feature-state"]))return[new Te(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!Ea(i))return[new Te(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Fa(r){const t=r.key,i=r.value,s=nt(i);return s!=="string"?[new Te(t,i,`color expected, ${s} found`)]:it.parse(String(i))?[]:[new Te(t,i,`color expected, "${i}" found`)]}function Er(r){const t=r.key,i=r.value,s=r.valueSpec,o=[];return Array.isArray(s.values)?s.values.indexOf(kt(i))===-1&&o.push(new Te(t,i,`expected one of [${s.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(s.values).indexOf(kt(i))===-1&&o.push(new Te(t,i,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(i)} found`)),o}function Zo(r){return za(Tr(r.value))?kn(gi({},r,{expressionContext:"filter",valueSpec:{value:"boolean"}})):ic(r)}function ic(r){const t=r.value,i=r.key;if(nt(t)!=="array")return[new Te(i,t,`array expected, ${nt(t)} found`)];const s=r.styleSpec;let o,d=[];if(t.length<1)return[new Te(i,t,"filter array must have at least 1 element")];switch(d=d.concat(Er({key:`${i}[0]`,value:t[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),kt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&kt(t[1])==="$type"&&d.push(new Te(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&d.push(new Te(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(o=nt(t[1]),o!=="string"&&d.push(new Te(`${i}[1]`,t[1],`string expected, ${o} found`)));for(let p=2;p<t.length;p++)o=nt(t[p]),kt(t[1])==="$type"?d=d.concat(Er({key:`${i}[${p}]`,value:t[p],valueSpec:s.geometry_type,style:r.style,styleSpec:r.styleSpec})):o!=="string"&&o!=="number"&&o!=="boolean"&&d.push(new Te(`${i}[${p}]`,t[p],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let p=1;p<t.length;p++)d=d.concat(ic({key:`${i}[${p}]`,value:t[p],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":o=nt(t[1]),t.length!==2?d.push(new Te(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):o!=="string"&&d.push(new Te(`${i}[1]`,t[1],`string expected, ${o} found`))}return d}function rc(r,t){const i=r.key,s=r.validateSpec,o=r.style,d=r.styleSpec,p=r.value,m=r.objectKey,g=d[`${t}_${r.layerType}`];if(!g)return[];const x=m.match(/^(.*)-transition$/);if(t==="paint"&&x&&g[x[1]]&&g[x[1]].transition)return s({key:i,value:p,valueSpec:d.transition,style:o,styleSpec:d});const v=r.valueSpec||g[m];if(!v)return[new Te(i,p,`unknown property "${m}"`)];let T;if(nt(p)==="string"&&Jr(v)&&!v.tokens&&(T=/^{([^}]+)}$/.exec(p)))return[new Te(i,p,`"${m}" does not support interpolation syntax
5
- Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(T[1])} }\`.`)];const M=[];return r.layerType==="symbol"&&(m==="text-field"&&o&&!o.glyphs&&M.push(new Te(i,p,'use of "text-field" requires a style "glyphs" property')),m==="text-font"&&Ns(Tr(p))&&kt(p.type)==="identity"&&M.push(new Te(i,p,'"text-font" does not support identity functions'))),M.concat(s({key:r.key,value:p,valueSpec:v,style:o,styleSpec:d,expressionContext:"property",propertyType:t,propertyKey:m}))}function nc(r){return rc(r,"paint")}function sc(r){return rc(r,"layout")}function ac(r){let t=[];const i=r.value,s=r.key,o=r.style,d=r.styleSpec;if(nt(i)!=="object")return[new Te(s,i,`object expected, ${nt(i)} found`)];i.type||i.ref||t.push(new Te(s,i,'either "type" or "ref" is required'));let p=kt(i.type);const m=kt(i.ref);if(i.id){const g=kt(i.id);for(let x=0;x<r.arrayIndex;x++){const v=o.layers[x];kt(v.id)===g&&t.push(new Te(s,i.id,`duplicate layer id "${i.id}", previously used at line ${v.id.__line__}`))}}if("ref"in i){let g;["type","source","source-layer","filter","layout"].forEach(x=>{x in i&&t.push(new Te(s,i[x],`"${x}" is prohibited for ref layers`))}),o.layers.forEach(x=>{kt(x.id)===m&&(g=x)}),g?g.ref?t.push(new Te(s,i.ref,"ref cannot reference another ref layer")):p=kt(g.type):t.push(new Te(s,i.ref,`ref layer "${m}" not found`))}else if(p!=="background")if(i.source){const g=o.sources&&o.sources[i.source],x=g&&kt(g.type);g?x==="vector"&&p==="raster"?t.push(new Te(s,i.source,`layer "${i.id}" requires a raster source`)):x!=="raster-dem"&&p==="hillshade"||x!=="raster-dem"&&p==="color-relief"?t.push(new Te(s,i.source,`layer "${i.id}" requires a raster-dem source`)):x==="raster"&&p!=="raster"?t.push(new Te(s,i.source,`layer "${i.id}" requires a vector source`)):x!=="vector"||i["source-layer"]?x==="raster-dem"&&p!=="hillshade"&&p!=="color-relief"?t.push(new Te(s,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):p!=="line"||!i.paint||!i.paint["line-gradient"]||x==="geojson"&&g.lineMetrics||t.push(new Te(s,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Te(s,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Te(s,i.source,`source "${i.source}" not found`))}else t.push(new Te(s,i,'missing required property "source"'));return t=t.concat(qi({key:s,value:i,valueSpec:d.layer,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,objectElementValidators:{"*":()=>[],type:()=>r.validateSpec({key:`${s}.type`,value:i.type,valueSpec:d.layer.type,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,object:i,objectKey:"type"}),filter:Zo,layout:g=>qi({layer:i,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>sc(gi({layerType:p},x))}}),paint:g=>qi({layer:i,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>nc(gi({layerType:p},x))}})}})),t}function tr(r){const t=r.value,i=r.key,s=nt(t);return s!=="string"?[new Te(i,t,`string expected, ${s} found`)]:[]}const is={promoteId:function({key:r,value:t}){if(nt(t)==="string")return tr({key:r,value:t});{const i=[];for(const s in t)i.push(...tr({key:`${r}.${s}`,value:t[s]}));return i}}};function ki(r){const t=r.value,i=r.key,s=r.styleSpec,o=r.style,d=r.validateSpec;if(!t.type)return[new Te(i,t,'"type" is required')];const p=kt(t.type);let m;switch(p){case"vector":case"raster":return m=qi({key:i,value:t,valueSpec:s[`source_${p.replace("-","_")}`],style:r.style,styleSpec:s,objectElementValidators:is,validateSpec:d}),m;case"raster-dem":return m=function(g){var x;const v=(x=g.sourceName)!==null&&x!==void 0?x:"",T=g.value,M=g.styleSpec,E=M.source_raster_dem,A=g.style;let L=[];const F=nt(T);if(T===void 0)return L;if(F!=="object")return L.push(new Te("source_raster_dem",T,`object expected, ${F} found`)),L;const V=kt(T.encoding)==="custom",Q=["redFactor","greenFactor","blueFactor","baseShift"],W=g.value.encoding?`"${g.value.encoding}"`:"Default";for(const X in T)!V&&Q.includes(X)?L.push(new Te(X,T[X],`In "${v}": "${X}" is only valid when "encoding" is set to "custom". ${W} encoding found`)):E[X]?L=L.concat(g.validateSpec({key:X,value:T[X],valueSpec:E[X],validateSpec:g.validateSpec,style:A,styleSpec:M})):L.push(new Te(X,T[X],`unknown property "${X}"`));return L}({sourceName:i,value:t,style:r.style,styleSpec:s,validateSpec:d}),m;case"geojson":if(m=qi({key:i,value:t,valueSpec:s.source_geojson,style:o,styleSpec:s,validateSpec:d,objectElementValidators:is}),t.cluster)for(const g in t.clusterProperties){const[x,v]=t.clusterProperties[g],T=typeof x=="string"?[x,["accumulated"],["get",g]]:x;m.push(...kn({key:`${i}.${g}.map`,value:v,expressionContext:"cluster-map"})),m.push(...kn({key:`${i}.${g}.reduce`,value:T,expressionContext:"cluster-reduce"}))}return m;case"video":return qi({key:i,value:t,valueSpec:s.source_video,style:o,validateSpec:d,styleSpec:s});case"image":return qi({key:i,value:t,valueSpec:s.source_image,style:o,validateSpec:d,styleSpec:s});case"canvas":return[new Te(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Er({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function rs(r){const t=r.value,i=r.styleSpec,s=i.light,o=r.style;let d=[];const p=nt(t);if(t===void 0)return d;if(p!=="object")return d=d.concat([new Te("light",t,`object expected, ${p} found`)]),d;for(const m in t){const g=m.match(/^(.*)-transition$/);d=d.concat(g&&s[g[1]]&&s[g[1]].transition?r.validateSpec({key:m,value:t[m],valueSpec:i.transition,validateSpec:r.validateSpec,style:o,styleSpec:i}):s[m]?r.validateSpec({key:m,value:t[m],valueSpec:s[m],validateSpec:r.validateSpec,style:o,styleSpec:i}):[new Te(m,t[m],`unknown property "${m}"`)])}return d}function Go(r){const t=r.value,i=r.styleSpec,s=i.sky,o=r.style,d=nt(t);if(t===void 0)return[];if(d!=="object")return[new Te("sky",t,`object expected, ${d} found`)];let p=[];for(const m in t)p=p.concat(s[m]?r.validateSpec({key:m,value:t[m],valueSpec:s[m],style:o,styleSpec:i}):[new Te(m,t[m],`unknown property "${m}"`)]);return p}function oc(r){const t=r.value,i=r.styleSpec,s=i.terrain,o=r.style;let d=[];const p=nt(t);if(t===void 0)return d;if(p!=="object")return d=d.concat([new Te("terrain",t,`object expected, ${p} found`)]),d;for(const m in t)d=d.concat(s[m]?r.validateSpec({key:m,value:t[m],valueSpec:s[m],validateSpec:r.validateSpec,style:o,styleSpec:i}):[new Te(m,t[m],`unknown property "${m}"`)]);return d}function lc(r){let t=[];const i=r.value,s=r.key;if(Array.isArray(i)){const o=[],d=[];for(const p in i)i[p].id&&o.includes(i[p].id)&&t.push(new Te(s,i,`all the sprites' ids must be unique, but ${i[p].id} is duplicated`)),o.push(i[p].id),i[p].url&&d.includes(i[p].url)&&t.push(new Te(s,i,`all the sprites' URLs must be unique, but ${i[p].url} is duplicated`)),d.push(i[p].url),t=t.concat(qi({key:`${s}[${p}]`,value:i[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:r.validateSpec}));return t}return tr({key:s,value:i})}function ns(r){return t=r.value,t&&t.constructor===Object?[]:[new Te(r.key,r.value,`object expected, ${nt(r.value)} found`)];var t}const qo={"*":()=>[],array:Ra,boolean:function(r){const t=r.value,i=r.key,s=nt(t);return s!=="boolean"?[new Te(i,t,`boolean expected, ${s} found`)]:[]},number:qs,color:Fa,constants:$o,enum:Er,filter:Zo,function:tc,layer:ac,object:qi,source:ki,light:rs,sky:Go,terrain:oc,projection:function(r){const t=r.value,i=r.styleSpec,s=i.projection,o=r.style,d=nt(t);if(t===void 0)return[];if(d!=="object")return[new Te("projection",t,`object expected, ${d} found`)];let p=[];for(const m in t)p=p.concat(s[m]?r.validateSpec({key:m,value:t[m],valueSpec:s[m],style:o,styleSpec:i}):[new Te(m,t[m],`unknown property "${m}"`)]);return p},projectionDefinition:function(r){const t=r.key;let i=r.value;i=i instanceof String?i.valueOf():i;const s=nt(i);return s!=="array"||function(o){return Array.isArray(o)&&o.length===3&&typeof o[0]=="string"&&typeof o[1]=="string"&&typeof o[2]=="number"}(i)||function(o){return!!["interpolate","step","literal"].includes(o[0])}(i)?["array","string"].includes(s)?[]:[new Te(t,i,`projection expected, invalid type "${s}" found`)]:[new Te(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:tr,formatted:function(r){return tr(r).length===0?[]:kn(r)},resolvedImage:function(r){return tr(r).length===0?[]:kn(r)},padding:function(r){const t=r.key,i=r.value;if(nt(i)==="array"){if(i.length<1||i.length>4)return[new Te(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const s={type:"number"};let o=[];for(let d=0;d<i.length;d++)o=o.concat(r.validateSpec({key:`${t}[${d}]`,value:i[d],validateSpec:r.validateSpec,valueSpec:s}));return o}return qs({key:t,value:i,valueSpec:{}})},numberArray:function(r){const t=r.key,i=r.value;if(nt(i)==="array"){const s={type:"number"};if(i.length<1)return[new Te(t,i,"array length at least 1 expected, length 0 found")];let o=[];for(let d=0;d<i.length;d++)o=o.concat(r.validateSpec({key:`${t}[${d}]`,value:i[d],validateSpec:r.validateSpec,valueSpec:s}));return o}return qs({key:t,value:i,valueSpec:{}})},colorArray:function(r){const t=r.key,i=r.value;if(nt(i)==="array"){if(i.length<1)return[new Te(t,i,"array length at least 1 expected, length 0 found")];let s=[];for(let o=0;o<i.length;o++)s=s.concat(Fa({key:`${t}[${o}]`,value:i[o]}));return s}return Fa({key:t,value:i})},variableAnchorOffsetCollection:function(r){const t=r.key,i=r.value,s=nt(i),o=r.styleSpec;if(s!=="array"||i.length<1||i.length%2!=0)return[new Te(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let d=[];for(let p=0;p<i.length;p+=2)d=d.concat(Er({key:`${t}[${p}]`,value:i[p],valueSpec:o.layout_symbol["text-anchor"]})),d=d.concat(Ra({key:`${t}[${p+1}]`,value:i[p+1],valueSpec:{length:2,value:"number"},validateSpec:r.validateSpec,style:r.style,styleSpec:o}));return d},sprite:lc,state:ns};function ss(r){const t=r.value,i=r.valueSpec,s=r.styleSpec;return r.validateSpec=ss,i.expression&&Ns(kt(t))?tc(r):i.expression&&ka(Tr(t))?kn(r):i.type&&qo[i.type]?qo[i.type](r):qi(gi({},r,{valueSpec:i.type?s[i.type]:i}))}function cc(r){const t=r.value,i=r.key,s=tr(r);return s.length||(t.indexOf("{fontstack}")===-1&&s.push(new Te(i,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&s.push(new Te(i,t,'"glyphs" url must include a "{range}" token'))),s}function zi(r,t=ne){let i=[];return i=i.concat(ss({key:"",value:r,valueSpec:t.$root,styleSpec:t,style:r,validateSpec:ss,objectElementValidators:{glyphs:cc,"*":()=>[]}})),r.constants&&(i=i.concat($o({key:"constants",value:r.constants}))),as(i)}function ir(r){return function(t){return r({...t,validateSpec:ss})}}function as(r){return[].concat(r).sort((t,i)=>t.line-i.line)}function rr(r){return function(...t){return as(r.apply(this,t))}}zi.source=rr(ir(ki)),zi.sprite=rr(ir(lc)),zi.glyphs=rr(ir(cc)),zi.light=rr(ir(rs)),zi.sky=rr(ir(Go)),zi.terrain=rr(ir(oc)),zi.state=rr(ir(ns)),zi.layer=rr(ir(ac)),zi.filter=rr(ir(Zo)),zi.paintProperty=rr(ir(nc)),zi.layoutProperty=rr(ir(sc));const os=zi,ph=os.light,Ws=os.sky,fh=os.paintProperty,mh=os.layoutProperty;function Hs(r,t){let i=!1;if(t&&t.length)for(const s of t)r.fire(new _e(new Error(s.message))),i=!0;return i}class Xs{constructor(t,i,s){const o=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const p=new Int32Array(this.arrayBuffer);t=p[0],this.d=(i=p[1])+2*(s=p[2]);for(let g=0;g<this.d*this.d;g++){const x=p[3+g],v=p[3+g+1];o.push(x===v?null:p.subarray(x,v))}const m=p[3+o.length+1];this.keys=p.subarray(p[3+o.length],m),this.bboxes=p.subarray(m),this.insert=this._insertReadonly}else{this.d=i+2*s;for(let p=0;p<this.d*this.d;p++)o.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=s,this.scale=i/t,this.uid=0;const d=s/i*t;this.min=-d,this.max=t+d}insert(t,i,s,o,d){this._forEachCell(i,s,o,d,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(i),this.bboxes.push(s),this.bboxes.push(o),this.bboxes.push(d)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,i,s,o,d,p){this.cells[d].push(p)}query(t,i,s,o,d){const p=this.min,m=this.max;if(t<=p&&i<=p&&m<=s&&m<=o&&!d)return Array.prototype.slice.call(this.keys);{const g=[];return this._forEachCell(t,i,s,o,this._queryCell,g,{},d),g}}_queryCell(t,i,s,o,d,p,m,g){const x=this.cells[d];if(x!==null){const v=this.keys,T=this.bboxes;for(let M=0;M<x.length;M++){const E=x[M];if(m[E]===void 0){const A=4*E;(g?g(T[A+0],T[A+1],T[A+2],T[A+3]):t<=T[A+2]&&i<=T[A+3]&&s>=T[A+0]&&o>=T[A+1])?(m[E]=!0,p.push(v[E])):m[E]=!1}}}}_forEachCell(t,i,s,o,d,p,m,g){const x=this._convertToCellCoord(t),v=this._convertToCellCoord(i),T=this._convertToCellCoord(s),M=this._convertToCellCoord(o);for(let E=x;E<=T;E++)for(let A=v;A<=M;A++){const L=this.d*A+E;if((!g||g(this._convertFromCellCoord(E),this._convertFromCellCoord(A),this._convertFromCellCoord(E+1),this._convertFromCellCoord(A+1)))&&d.call(this,t,i,s,o,L,p,m,g))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,i=3+this.cells.length+1+1;let s=0;for(let p=0;p<this.cells.length;p++)s+=this.cells[p].length;const o=new Int32Array(i+s+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;let d=i;for(let p=0;p<t.length;p++){const m=t[p];o[3+p]=d,o.set(m,d),d+=m.length}return o[3+t.length]=d,o.set(this.keys,d),d+=this.keys.length,o[3+t.length+1]=d,o.set(this.bboxes,d),d+=this.bboxes.length,o.buffer}static serialize(t,i){const s=t.toArrayBuffer();return i&&i.push(s),{buffer:s}}static deserialize(t){return new Xs(t.buffer)}}const nr={};function ze(r,t,i={}){if(nr[r])throw new Error(`${r} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:r,writeable:!1}),nr[r]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}ze("Object",Object),ze("Set",Set),ze("TransferableGridIndex",Xs),ze("Color",it),ze("Error",Error),ze("AJAXError",Z),ze("ResolvedImage",Bi),ze("StylePropertyFunction",$s),ze("StyleExpression",Bo,{omit:["_evaluator"]}),ze("ZoomDependentExpression",Oo),ze("ZoomConstantExpression",Us),ze("CompoundExpression",Gi,{omit:["_evaluate"]});for(const r in es)es[r]._classRegistryKey||ze(`Expression_${r}`,es[r]);function Wo(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}function Ba(r){return r.$name||r.constructor._classRegistryKey}function Ho(r){return!function(t){if(t===null||typeof t!="object")return!1;const i=Ba(t);return!(!i||i==="Object")}(r)&&(r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||r instanceof Boolean||r instanceof Number||r instanceof String||r instanceof Date||r instanceof RegExp||r instanceof Blob||r instanceof Error||Wo(r)||_r(r)||ArrayBuffer.isView(r)||r instanceof ImageData)}function ls(r,t){if(Ho(r))return(Wo(r)||_r(r))&&t&&t.push(r),ArrayBuffer.isView(r)&&t&&t.push(r.buffer),r instanceof ImageData&&t&&t.push(r.data.buffer),r;if(Array.isArray(r)){const d=[];for(const p of r)d.push(ls(p,t));return d}if(typeof r!="object")throw new Error("can't serialize object of type "+typeof r);const i=Ba(r);if(!i)throw new Error(`can't serialize object of unregistered class ${r.constructor.name}`);if(!nr[i])throw new Error(`${i} is not registered.`);const{klass:s}=nr[i],o=s.serialize?s.serialize(r,t):{};if(s.serialize){if(t&&o===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const d in r){if(!r.hasOwnProperty(d)||nr[i].omit.indexOf(d)>=0)continue;const p=r[d];o[d]=nr[i].shallow.indexOf(d)>=0?p:ls(p,t)}r instanceof Error&&(o.message=r.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(o.$name=i),o}function zn(r){if(Ho(r))return r;if(Array.isArray(r))return r.map(zn);if(typeof r!="object")throw new Error("can't deserialize object of type "+typeof r);const t=Ba(r)||"Object";if(!nr[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=nr[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(r);const s=Object.create(i.prototype);for(const o of Object.keys(r)){if(o==="$name")continue;const d=r[o];s[o]=nr[t].shallow.indexOf(o)>=0?d:zn(d)}return s}class Oa{constructor(){this.first=!0}update(t,i){const s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=i):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=i),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=s,!0))}}const st={"Latin-1 Supplement":r=>r>=128&&r<=255,"Hangul Jamo":r=>r>=4352&&r<=4607,Khmer:r=>r>=6016&&r<=6143,"General Punctuation":r=>r>=8192&&r<=8303,"Letterlike Symbols":r=>r>=8448&&r<=8527,"Number Forms":r=>r>=8528&&r<=8591,"Miscellaneous Technical":r=>r>=8960&&r<=9215,"Control Pictures":r=>r>=9216&&r<=9279,"Optical Character Recognition":r=>r>=9280&&r<=9311,"Enclosed Alphanumerics":r=>r>=9312&&r<=9471,"Geometric Shapes":r=>r>=9632&&r<=9727,"Miscellaneous Symbols":r=>r>=9728&&r<=9983,"Miscellaneous Symbols and Arrows":r=>r>=11008&&r<=11263,"Ideographic Description Characters":r=>r>=12272&&r<=12287,"CJK Symbols and Punctuation":r=>r>=12288&&r<=12351,Hiragana:r=>r>=12352&&r<=12447,Katakana:r=>r>=12448&&r<=12543,Kanbun:r=>r>=12688&&r<=12703,"CJK Strokes":r=>r>=12736&&r<=12783,"Enclosed CJK Letters and Months":r=>r>=12800&&r<=13055,"CJK Compatibility":r=>r>=13056&&r<=13311,"Yijing Hexagram Symbols":r=>r>=19904&&r<=19967,"CJK Unified Ideographs":r=>r>=19968&&r<=40959,"Hangul Syllables":r=>r>=44032&&r<=55215,"Private Use Area":r=>r>=57344&&r<=63743,"Vertical Forms":r=>r>=65040&&r<=65055,"CJK Compatibility Forms":r=>r>=65072&&r<=65103,"Small Form Variants":r=>r>=65104&&r<=65135,"Halfwidth and Fullwidth Forms":r=>r>=65280&&r<=65519};function ja(r){for(const t of r)if(Yo(t.charCodeAt(0)))return!0;return!1}function gh(r){for(const t of r)if(!hc(t.charCodeAt(0)))return!1;return!0}function Na(r){const t=r.map(i=>{try{return new RegExp(`\\p{sc=${i}}`,"u").source}catch{return null}}).filter(i=>i);return new RegExp(t.join("|"),"u")}const _h=Na(["Arab","Dupl","Mong","Ougr","Syrc"]);function hc(r){return!_h.test(String.fromCodePoint(r))}const Xo=Na(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Yo(r){return!(r!==746&&r!==747&&(r<4352||!(st["CJK Compatibility Forms"](r)&&!(r>=65097&&r<=65103)||st["CJK Compatibility"](r)||st["CJK Strokes"](r)||!(!st["CJK Symbols and Punctuation"](r)||r>=12296&&r<=12305||r>=12308&&r<=12319||r===12336)||st["Enclosed CJK Letters and Months"](r)||st["Ideographic Description Characters"](r)||st.Kanbun(r)||st.Katakana(r)&&r!==12540||!(!st["Halfwidth and Fullwidth Forms"](r)||r===65288||r===65289||r===65293||r>=65306&&r<=65310||r===65339||r===65341||r===65343||r>=65371&&r<=65503||r===65507||r>=65512&&r<=65519)||!(!st["Small Form Variants"](r)||r>=65112&&r<=65118||r>=65123&&r<=65126)||st["Vertical Forms"](r)||st["Yijing Hexagram Symbols"](r)||new RegExp("\\p{sc=Cans}","u").test(String.fromCodePoint(r))||new RegExp("\\p{sc=Hang}","u").test(String.fromCodePoint(r))||Xo.test(String.fromCodePoint(r)))))}function uc(r){return!(Yo(r)||function(t){return!!(st["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||st["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||st["Letterlike Symbols"](t)||st["Number Forms"](t)||st["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||st["Control Pictures"](t)&&t!==9251||st["Optical Character Recognition"](t)||st["Enclosed Alphanumerics"](t)||st["Geometric Shapes"](t)||st["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||st["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||st["CJK Symbols and Punctuation"](t)||st.Katakana(t)||st["Private Use Area"](t)||st["CJK Compatibility Forms"](t)||st["Small Form Variants"](t)||st["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(r))}const dc=Na(["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 Ko(r){return dc.test(String.fromCodePoint(r))}function pc(r,t){return!(!t&&Ko(r)||r>=2304&&r<=3583||r>=3840&&r<=4255||st.Khmer(r))}function fc(r){for(const t of r)if(Ko(t.charCodeAt(0)))return!0;return!1}const sr=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(r){this.pluginStatus=r.pluginStatus,this.pluginURL=r.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(r){if(sr.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=r.applyArabicShaping,this.processBidirectionalText=r.processBidirectionalText,this.processStyledBidirectionalText=r.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(r,t){return c(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if(r.pluginStatus!=="loading")return this.setState(r),r;const i=r.pluginURL,s=new Promise(d=>{this.loadScriptResolve=d});t(i);const o=new Promise(d=>setTimeout(()=>d(),this.TIMEOUT));if(yield Promise.race([s,o]),this.isParsed()){const d={pluginStatus:"loaded",pluginURL:i};return this.setState(d),d}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${i}`)})}};class wt{constructor(t,i){this.zoom=t,i?(this.now=i.now||0,this.fadeDuration=i.fadeDuration||0,this.zoomHistory=i.zoomHistory||new Oa,this.transition=i.transition||{},this.globalState=i.globalState||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Oa,this.transition={},this.globalState={})}isSupportedScript(t){return function(i,s){for(const o of i)if(!pc(o.charCodeAt(0),s))return!1;return!0}(t,sr.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,i=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:i+(1-i)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*i}}}class cs{constructor(t,i){this.property=t,this.value=i,this.expression=function(s,o){if(Ns(s))return new $s(s,o);if(ka(s)){const d=Jl(s,o);if(d.result==="error")throw new Error(d.value.map(p=>`${p.key}: ${p.message}`).join(", "));return d.value}{let d=s;return o.type==="color"&&typeof s=="string"?d=it.parse(s):o.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?o.type!=="numberArray"||typeof s!="number"&&!Array.isArray(s)?o.type!=="colorArray"||typeof s!="string"&&!Array.isArray(s)?o.type==="variableAnchorOffsetCollection"&&Array.isArray(s)?d=Ti.parse(s):o.type==="projectionDefinition"&&typeof s=="string"&&(d=_i.parse(s)):d=$t.parse(s):d=wi.parse(s):d=ti.parse(s),{globalStateRefs:new Set,kind:"constant",evaluate:()=>d}}}(i===void 0?t.specification.default:i,t.specification),this._evaluate=this.expression.evaluate}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,i,s){return this.property.possiblyEvaluate(this,t,i,s)}setGlobalState(t){this.expression.evaluate=(i,s,o,d,p,m)=>(i.globalState=t,this._evaluate.call(this.expression,i,s,o,d,p,m))}}class Jo{constructor(t){this.property=t,this.value=new cs(t,void 0)}transitioned(t,i){return new Qo(this.property,this.value,i,Zi({},t.transition,this.transition),t.now)}untransitioned(){return new Qo(this.property,this.value,null,{},0)}}class mc{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return Fi(this._values[t].value.value)}setValue(t,i){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Jo(this._values[t].property)),this._values[t].value=new cs(this._values[t].property,i===null?void 0:Fi(i))}getTransition(t){return Fi(this._values[t].transition)}setTransition(t,i){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Jo(this._values[t].property)),this._values[t].transition=Fi(i)||void 0}serialize(){const t={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(t[i]=s);const o=this.getTransition(i);o!==void 0&&(t[`${i}-transition`]=o)}return t}transitioned(t,i){const s=new el(this._properties);for(const o of Object.keys(this._values))s._values[o]=this._values[o].transitioned(t,i._values[o]);return s}untransitioned(){const t=new el(this._properties);for(const i of Object.keys(this._values))t._values[i]=this._values[i].untransitioned();return t}}class Qo{constructor(t,i,s,o,d){this.property=t,this.value=i,this.begin=d+o.delay||0,this.end=this.begin+o.duration||0,t.specification.transition&&(o.delay||o.duration)&&(this.prior=s)}possiblyEvaluate(t,i,s){const o=t.now||0,d=this.value.possiblyEvaluate(t,i,s),p=this.prior;if(p){if(o>this.end)return this.prior=null,d;if(this.value.isDataDriven())return this.prior=null,d;if(o<this.begin)return p.possiblyEvaluate(t,i,s);{const m=(o-this.begin)/(this.end-this.begin);return this.property.interpolate(p.possiblyEvaluate(t,i,s),d,mr(m))}}return d}}class el{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,i,s){const o=new Va(this._properties);for(const d of Object.keys(this._values))o._values[d]=this._values[d].possiblyEvaluate(t,i,s);return o}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class gc{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState={}}hasValue(t){return this._values[t].value!==void 0}getValue(t){return Fi(this._values[t].value)}setValue(t,i){this._values[t]=new cs(this._values[t].property,i===null?void 0:Fi(i)),this._values[t].setGlobalState(this._globalState)}serialize(){const t={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(t[i]=s)}return t}possiblyEvaluate(t,i,s){const o=new Va(this._properties);for(const d of Object.keys(this._values))o._values[d]=this._values[d].possiblyEvaluate(t,i,s);return o}setGlobalState(t){this._globalState=t;for(const i of Object.values(this._values))i.setGlobalState(t)}}class Pr{constructor(t,i,s){this.property=t,this.value=i,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,i,s,o){return this.property.evaluate(this.value,this.parameters,t,i,s,o)}}class Va{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Fe{constructor(t){this.specification=t}possiblyEvaluate(t,i){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(i)}interpolate(t,i,s){const o=wr[this.specification.type];return o?o(t,i,s):t}}class Ne{constructor(t,i){this.specification=t,this.overrides=i}possiblyEvaluate(t,i,s,o){return new Pr(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(i,null,{},s,o)}:t.expression,i)}interpolate(t,i,s){if(t.value.kind!=="constant"||i.value.kind!=="constant")return t;if(t.value.value===void 0||i.value.value===void 0)return new Pr(this,{kind:"constant",value:void 0},t.parameters);const o=wr[this.specification.type];if(o){const d=o(t.value.value,i.value.value,s);return new Pr(this,{kind:"constant",value:d},t.parameters)}return t}evaluate(t,i,s,o,d,p){return t.kind==="constant"?t.value:t.evaluate(i,s,o,d,p)}}class Ua extends Ne{possiblyEvaluate(t,i,s,o){if(t.value===void 0)return new Pr(this,{kind:"constant",value:void 0},i);if(t.expression.kind==="constant"){const d=t.expression.evaluate(i,null,{},s,o),p=t.property.specification.type==="resolvedImage"&&typeof d!="string"?d.name:d,m=this._calculate(p,p,p,i);return new Pr(this,{kind:"constant",value:m},i)}if(t.expression.kind==="camera"){const d=this._calculate(t.expression.evaluate({zoom:i.zoom-1}),t.expression.evaluate({zoom:i.zoom}),t.expression.evaluate({zoom:i.zoom+1}),i);return new Pr(this,{kind:"constant",value:d},i)}return new Pr(this,t.expression,i)}evaluate(t,i,s,o,d,p){if(t.kind==="source"){const m=t.evaluate(i,s,o,d,p);return this._calculate(m,m,m,i)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(i.zoom)-1},s,o),t.evaluate({zoom:Math.floor(i.zoom)},s,o),t.evaluate({zoom:Math.floor(i.zoom)+1},s,o),i):t.value}_calculate(t,i,s,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:s,to:i}}interpolate(t){return t}}class en{constructor(t){this.specification=t}possiblyEvaluate(t,i,s,o){if(t.value!==void 0){if(t.expression.kind==="constant"){const d=t.expression.evaluate(i,null,{},s,o);return this._calculate(d,d,d,i)}return this._calculate(t.expression.evaluate(new wt(Math.floor(i.zoom-1),i)),t.expression.evaluate(new wt(Math.floor(i.zoom),i)),t.expression.evaluate(new wt(Math.floor(i.zoom+1),i)),i)}}_calculate(t,i,s,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:s,to:i}}interpolate(t){return t}}class $a{constructor(t){this.specification=t}possiblyEvaluate(t,i,s,o){return!!t.expression.evaluate(i,null,{},s,o)}interpolate(){return!1}}class Pi{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const i in t){const s=t[i];s.specification.overridable&&this.overridableProperties.push(i);const o=this.defaultPropertyValues[i]=new cs(s,void 0),d=this.defaultTransitionablePropertyValues[i]=new Jo(s);this.defaultTransitioningPropertyValues[i]=d.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=o.possiblyEvaluate({})}}}ze("DataDrivenProperty",Ne),ze("DataConstantProperty",Fe),ze("CrossFadedDataDrivenProperty",Ua),ze("CrossFadedProperty",en),ze("ColorRampProperty",$a);const _c="-transition";class Wi extends Re{constructor(t,i){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,this._globalState={},t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=En(t.filter)),i.layout&&(this._unevaluatedLayout=new gc(i.layout)),i.paint)){this._transitionablePaint=new mc(i.paint);for(const s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(const s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Va(i.paint)}}setFilter(t){this.filter=t,this._featureFilter=En(t)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){const t=new Set;if(this._unevaluatedLayout)for(const i in this._unevaluatedLayout._values){const s=this._unevaluatedLayout._values[i];for(const o of s.getGlobalStateRefs())t.add(o)}for(const i of this._featureFilter.getGlobalStateRefs())t.add(i);return t}getPaintAffectingGlobalStateRefs(){var t;const i=new globalThis.Map;if(this._transitionablePaint)for(const s in this._transitionablePaint._values){const o=this._transitionablePaint._values[s].value;for(const d of o.getGlobalStateRefs()){const p=(t=i.get(d))!==null&&t!==void 0?t:[];p.push({name:s,value:o.value}),i.set(d,p)}}return i}setLayoutProperty(t,i,s={}){i!=null&&this._validate(mh,`layers.${this.id}.layout.${t}`,t,i,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,i):this.visibility=i)}getPaintProperty(t){return t.endsWith(_c)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,i,s={}){if(i!=null&&this._validate(fh,`layers.${this.id}.paint.${t}`,t,i,s))return!1;if(t.endsWith(_c))return this._transitionablePaint.setTransition(t.slice(0,-11),i||void 0),!1;{const o=this._transitionablePaint._values[t],d=o.property.specification["property-type"]==="cross-faded-data-driven",p=o.value.isDataDriven(),m=o.value;this._transitionablePaint.setValue(t,i),this._handleSpecialPaintPropertyUpdate(t);const g=this._transitionablePaint._values[t].value;return g.isDataDriven()||p||d||this._handleOverridablePaintPropertyUpdate(t,m,g)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,i,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,i){t.globalState=this._globalState,t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,i)}setGlobalState(t){this._globalState=t,this._unevaluatedLayout&&this._unevaluatedLayout.setGlobalState(t)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),Un(t,(i,s)=>!(i===void 0||s==="layout"&&!Object.keys(i).length||s==="paint"&&!Object.keys(i).length))}_validate(t,i,s,o,d={}){return(!d||d.validate!==!1)&&Hs(this,t.call(os,{key:i,layerType:this.type,objectKey:s,value:o,styleSpec:ne,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const i=this.paint.get(t);if(i instanceof Pr&&Jr(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}}const yh={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ys{constructor(t,i){this._structArray=t,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class _t{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,i){return t._trim(),i&&(t.isTransferred=!0,i.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const i=Object.create(this.prototype);return i.arrayBuffer=t.arrayBuffer,i.length=t.length,i.capacity=t.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Bt(r,t=1){let i=0,s=0;return{members:r.map(o=>{const d=yh[o.type].BYTES_PER_ELEMENT,p=i=Za(i,Math.max(t,d)),m=o.components||1;return s=Math.max(s,d),i+=d*m,{name:o.name,type:o.type,components:m,offset:p}}),size:Za(i,Math.max(s,t)),alignment:t}}function Za(r,t){return Math.ceil(r/t)*t}class hs extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const o=2*t;return this.int16[o+0]=i,this.int16[o+1]=s,t}}hs.prototype.bytesPerElement=4,ze("StructArrayLayout2i4",hs);class us extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=3*t;return this.int16[d+0]=i,this.int16[d+1]=s,this.int16[d+2]=o,t}}us.prototype.bytesPerElement=6,ze("StructArrayLayout3i6",us);class tl extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o){const d=this.length;return this.resize(d+1),this.emplace(d,t,i,s,o)}emplace(t,i,s,o,d){const p=4*t;return this.int16[p+0]=i,this.int16[p+1]=s,this.int16[p+2]=o,this.int16[p+3]=d,t}}tl.prototype.bytesPerElement=8,ze("StructArrayLayout4i8",tl);class ds extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,i,s,o,d,p)}emplace(t,i,s,o,d,p,m){const g=6*t;return this.int16[g+0]=i,this.int16[g+1]=s,this.int16[g+2]=o,this.int16[g+3]=d,this.int16[g+4]=p,this.int16[g+5]=m,t}}ds.prototype.bytesPerElement=12,ze("StructArrayLayout2i4i12",ds);class Ln extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,i,s,o,d,p)}emplace(t,i,s,o,d,p,m){const g=4*t,x=8*t;return this.int16[g+0]=i,this.int16[g+1]=s,this.uint8[x+4]=o,this.uint8[x+5]=d,this.uint8[x+6]=p,this.uint8[x+7]=m,t}}Ln.prototype.bytesPerElement=8,ze("StructArrayLayout2i4ub8",Ln);class Ks extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const o=2*t;return this.float32[o+0]=i,this.float32[o+1]=s,t}}Ks.prototype.bytesPerElement=8,ze("StructArrayLayout2f8",Ks);class Ga extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p,m,g,x,v){const T=this.length;return this.resize(T+1),this.emplace(T,t,i,s,o,d,p,m,g,x,v)}emplace(t,i,s,o,d,p,m,g,x,v,T){const M=10*t;return this.uint16[M+0]=i,this.uint16[M+1]=s,this.uint16[M+2]=o,this.uint16[M+3]=d,this.uint16[M+4]=p,this.uint16[M+5]=m,this.uint16[M+6]=g,this.uint16[M+7]=x,this.uint16[M+8]=v,this.uint16[M+9]=T,t}}Ga.prototype.bytesPerElement=20,ze("StructArrayLayout10ui20",Ga);class Dn extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p,m,g,x,v,T,M){const E=this.length;return this.resize(E+1),this.emplace(E,t,i,s,o,d,p,m,g,x,v,T,M)}emplace(t,i,s,o,d,p,m,g,x,v,T,M,E){const A=12*t;return this.int16[A+0]=i,this.int16[A+1]=s,this.int16[A+2]=o,this.int16[A+3]=d,this.uint16[A+4]=p,this.uint16[A+5]=m,this.uint16[A+6]=g,this.uint16[A+7]=x,this.int16[A+8]=v,this.int16[A+9]=T,this.int16[A+10]=M,this.int16[A+11]=E,t}}Dn.prototype.bytesPerElement=24,ze("StructArrayLayout4i4ui4i24",Dn);class il extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=3*t;return this.float32[d+0]=i,this.float32[d+1]=s,this.float32[d+2]=o,t}}il.prototype.bytesPerElement=12,ze("StructArrayLayout3f12",il);class rl extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint32[1*t+0]=i,t}}rl.prototype.bytesPerElement=4,ze("StructArrayLayout1ul4",rl);class qa extends _t{_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,i,s,o,d,p,m,g,x){const v=this.length;return this.resize(v+1),this.emplace(v,t,i,s,o,d,p,m,g,x)}emplace(t,i,s,o,d,p,m,g,x,v){const T=10*t,M=5*t;return this.int16[T+0]=i,this.int16[T+1]=s,this.int16[T+2]=o,this.int16[T+3]=d,this.int16[T+4]=p,this.int16[T+5]=m,this.uint32[M+3]=g,this.uint16[T+8]=x,this.uint16[T+9]=v,t}}qa.prototype.bytesPerElement=20,ze("StructArrayLayout6i1ul2ui20",qa);class nl extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,i,s,o,d,p)}emplace(t,i,s,o,d,p,m){const g=6*t;return this.int16[g+0]=i,this.int16[g+1]=s,this.int16[g+2]=o,this.int16[g+3]=d,this.int16[g+4]=p,this.int16[g+5]=m,t}}nl.prototype.bytesPerElement=12,ze("StructArrayLayout2i2i2i12",nl);class h extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d){const p=this.length;return this.resize(p+1),this.emplace(p,t,i,s,o,d)}emplace(t,i,s,o,d,p){const m=4*t,g=8*t;return this.float32[m+0]=i,this.float32[m+1]=s,this.float32[m+2]=o,this.int16[g+6]=d,this.int16[g+7]=p,t}}h.prototype.bytesPerElement=16,ze("StructArrayLayout2f1f2i16",h);class e extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,i,s,o,d,p)}emplace(t,i,s,o,d,p,m){const g=16*t,x=4*t,v=8*t;return this.uint8[g+0]=i,this.uint8[g+1]=s,this.float32[x+1]=o,this.float32[x+2]=d,this.int16[v+6]=p,this.int16[v+7]=m,t}}e.prototype.bytesPerElement=16,ze("StructArrayLayout2ub2f2i16",e);class n extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=3*t;return this.uint16[d+0]=i,this.uint16[d+1]=s,this.uint16[d+2]=o,t}}n.prototype.bytesPerElement=6,ze("StructArrayLayout3ui6",n);class a extends _t{_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,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V){const Q=this.length;return this.resize(Q+1),this.emplace(Q,t,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V)}emplace(t,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q){const W=24*t,X=12*t,ce=48*t;return this.int16[W+0]=i,this.int16[W+1]=s,this.uint16[W+2]=o,this.uint16[W+3]=d,this.uint32[X+2]=p,this.uint32[X+3]=m,this.uint32[X+4]=g,this.uint16[W+10]=x,this.uint16[W+11]=v,this.uint16[W+12]=T,this.float32[X+7]=M,this.float32[X+8]=E,this.uint8[ce+36]=A,this.uint8[ce+37]=L,this.uint8[ce+38]=F,this.uint32[X+10]=V,this.int16[W+22]=Q,t}}a.prototype.bytesPerElement=48,ze("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",a);class l extends _t{_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,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q,W,X,ce,pe,xe,Ae,Pe,Ie,Be,Me){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,t,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q,W,X,ce,pe,xe,Ae,Pe,Ie,Be,Me)}emplace(t,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q,W,X,ce,pe,xe,Ae,Pe,Ie,Be,Me,Ce){const ge=32*t,$e=16*t;return this.int16[ge+0]=i,this.int16[ge+1]=s,this.int16[ge+2]=o,this.int16[ge+3]=d,this.int16[ge+4]=p,this.int16[ge+5]=m,this.int16[ge+6]=g,this.int16[ge+7]=x,this.uint16[ge+8]=v,this.uint16[ge+9]=T,this.uint16[ge+10]=M,this.uint16[ge+11]=E,this.uint16[ge+12]=A,this.uint16[ge+13]=L,this.uint16[ge+14]=F,this.uint16[ge+15]=V,this.uint16[ge+16]=Q,this.uint16[ge+17]=W,this.uint16[ge+18]=X,this.uint16[ge+19]=ce,this.uint16[ge+20]=pe,this.uint16[ge+21]=xe,this.uint16[ge+22]=Ae,this.uint32[$e+12]=Pe,this.float32[$e+13]=Ie,this.float32[$e+14]=Be,this.uint16[ge+30]=Me,this.uint16[ge+31]=Ce,t}}l.prototype.bytesPerElement=64,ze("StructArrayLayout8i15ui1ul2f2ui64",l);class u extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.float32[1*t+0]=i,t}}u.prototype.bytesPerElement=4,ze("StructArrayLayout1f4",u);class f extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=3*t;return this.uint16[6*t+0]=i,this.float32[d+1]=s,this.float32[d+2]=o,t}}f.prototype.bytesPerElement=12,ze("StructArrayLayout1ui2f12",f);class _ extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=4*t;return this.uint32[2*t+0]=i,this.uint16[d+2]=s,this.uint16[d+3]=o,t}}_.prototype.bytesPerElement=8,ze("StructArrayLayout1ul2ui8",_);class y extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const o=2*t;return this.uint16[o+0]=i,this.uint16[o+1]=s,t}}y.prototype.bytesPerElement=4,ze("StructArrayLayout2ui4",y);class b extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint16[1*t+0]=i,t}}b.prototype.bytesPerElement=2,ze("StructArrayLayout1ui2",b);class w extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s,o){const d=this.length;return this.resize(d+1),this.emplace(d,t,i,s,o)}emplace(t,i,s,o,d){const p=4*t;return this.float32[p+0]=i,this.float32[p+1]=s,this.float32[p+2]=o,this.float32[p+3]=d,t}}w.prototype.bytesPerElement=16,ze("StructArrayLayout4f16",w);class S extends Ys{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new be(this.anchorPointX,this.anchorPointY)}}S.prototype.size=20;class P extends qa{get(t){return new S(this,t)}}ze("CollisionBoxArray",P);class I extends Ys{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(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]}}I.prototype.size=48;class k extends a{get(t){return new I(this,t)}}ze("PlacedSymbolArray",k);class O extends Ys{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(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]}}O.prototype.size=64;class B extends l{get(t){return new O(this,t)}}ze("SymbolInstanceArray",B);class N extends u{getoffsetX(t){return this.float32[1*t+0]}}ze("GlyphOffsetArray",N);class U extends us{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}ze("SymbolLineVertexArray",U);class q extends Ys{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}q.prototype.size=12;class $ extends f{get(t){return new q(this,t)}}ze("TextAnchorOffsetArray",$);class H extends Ys{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}H.prototype.size=8;class K extends _{get(t){return new H(this,t)}}ze("FeatureIndexArray",K);class G extends hs{}class te extends hs{}class ue extends hs{}class ae extends ds{}class oe extends Ln{}class he extends Ks{}class we extends Ga{}class Se extends Dn{}class ye extends il{}class Le extends rl{}class Ke extends nl{}class dt extends e{}class yt extends n{}class mt extends y{}const Ct=Bt([{name:"a_pos",components:2,type:"Int16"}],4),{members:zt}=Ct;class Xe{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,i,s,o){const d=this.segments[this.segments.length-1];return t>Xe.MAX_VERTEX_ARRAY_LENGTH&&jt(`Max vertices per segment is ${Xe.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Xe.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!d||d.vertexLength+t>Xe.MAX_VERTEX_ARRAY_LENGTH||d.sortKey!==o?this.createNewSegment(i,s,o):d}createNewSegment(t,i,s){const o={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(o.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(o),o}getOrCreateLatestSegment(t,i,s){return this.prepareSegment(0,t,i,s)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const t of this.segments)for(const i in t.vaos)t.vaos[i].destroy()}static simpleSegment(t,i,s,o){return new Xe([{vertexOffset:t,primitiveOffset:i,vertexLength:s,primitiveLength:o,vaos:{},sortKey:0}])}}function xt(r,t){return 256*(r=Ei(Math.floor(r),0,255))+Ei(Math.floor(t),0,255)}Xe.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ze("SegmentVector",Xe);const Zt=Bt([{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 Yt,ri,Si,ar={exports:{}},tn={exports:{}},rn={exports:{}},ps=function(){if(Si)return ar.exports;Si=1;var r=(Yt||(Yt=1,tn.exports=function(i,s){var o,d,p,m,g,x,v,T;for(d=i.length-(o=3&i.length),p=s,g=3432918353,x=461845907,T=0;T<d;)v=255&i.charCodeAt(T)|(255&i.charCodeAt(++T))<<8|(255&i.charCodeAt(++T))<<16|(255&i.charCodeAt(++T))<<24,++T,p=27492+(65535&(m=5*(65535&(p=(p^=v=(65535&(v=(v=(65535&v)*g+(((v>>>16)*g&65535)<<16)&4294967295)<<15|v>>>17))*x+(((v>>>16)*x&65535)<<16)&4294967295)<<13|p>>>19))+((5*(p>>>16)&65535)<<16)&4294967295))+((58964+(m>>>16)&65535)<<16);switch(v=0,o){case 3:v^=(255&i.charCodeAt(T+2))<<16;case 2:v^=(255&i.charCodeAt(T+1))<<8;case 1:p^=v=(65535&(v=(v=(65535&(v^=255&i.charCodeAt(T)))*g+(((v>>>16)*g&65535)<<16)&4294967295)<<15|v>>>17))*x+(((v>>>16)*x&65535)<<16)&4294967295}return p^=i.length,p=2246822507*(65535&(p^=p>>>16))+((2246822507*(p>>>16)&65535)<<16)&4294967295,p=3266489909*(65535&(p^=p>>>13))+((3266489909*(p>>>16)&65535)<<16)&4294967295,(p^=p>>>16)>>>0}),tn.exports),t=(ri||(ri=1,rn.exports=function(i,s){for(var o,d=i.length,p=s^d,m=0;d>=4;)o=1540483477*(65535&(o=255&i.charCodeAt(m)|(255&i.charCodeAt(++m))<<8|(255&i.charCodeAt(++m))<<16|(255&i.charCodeAt(++m))<<24))+((1540483477*(o>>>16)&65535)<<16),p=1540483477*(65535&p)+((1540483477*(p>>>16)&65535)<<16)^(o=1540483477*(65535&(o^=o>>>24))+((1540483477*(o>>>16)&65535)<<16)),d-=4,++m;switch(d){case 3:p^=(255&i.charCodeAt(m+2))<<16;case 2:p^=(255&i.charCodeAt(m+1))<<8;case 1:p=1540483477*(65535&(p^=255&i.charCodeAt(m)))+((1540483477*(p>>>16)&65535)<<16)}return p=1540483477*(65535&(p^=p>>>13))+((1540483477*(p>>>16)&65535)<<16),(p^=p>>>15)>>>0}),rn.exports);return ar.exports=r,ar.exports.murmur3=r,ar.exports.murmur2=t,ar.exports}(),fs=ct(ps);class Rn{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,i,s,o){this.ids.push(Fn(t)),this.positions.push(i,s,o)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const i=Fn(t);let s=0,o=this.ids.length-1;for(;s<o;){const p=s+o>>1;this.ids[p]>=i?o=p:s=p+1}const d=[];for(;this.ids[s]===i;)d.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return d}static serialize(t,i){const s=new Float64Array(t.ids),o=new Uint32Array(t.positions);return Li(s,o,0,s.length-1),i&&i.push(s.buffer,o.buffer),{ids:s,positions:o}}static deserialize(t){const i=new Rn;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}}function Fn(r){const t=+r;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:fs(String(r))}function Li(r,t,i,s){for(;i<s;){const o=r[i+s>>1];let d=i-1,p=s+1;for(;;){do d++;while(r[d]<o);do p--;while(r[p]>o);if(d>=p)break;or(r,d,p),or(t,3*d,3*p),or(t,3*d+1,3*p+1),or(t,3*d+2,3*p+2)}p-i<s-p?(Li(r,t,i,p),i=p+1):(Li(r,t,p+1,s),s=p)}}function or(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}ze("FeaturePositionMap",Rn);class Mi{constructor(t,i){this.gl=t.gl,this.location=i}}class nn extends Mi{constructor(t,i){super(t,i),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Gt extends Mi{constructor(t,i){super(t,i),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 Kt extends Mi{constructor(t,i){super(t,i),this.current=it.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))}}const Hi=new Float32Array(16);function qt(r){return[xt(255*r.r,255*r.g),xt(255*r.b,255*r.a)]}class Js{constructor(t,i,s){this.value=t,this.uniformNames=i.map(o=>`u_${o}`),this.type=s}setUniform(t,i,s){t.set(s.constantOr(this.value))}getBinding(t,i,s){return this.type==="color"?new Kt(t,i):new nn(t,i)}}class ms{constructor(t,i){this.uniformNames=i.map(s=>`u_${s}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,i){this.pixelRatioFrom=i.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=i.tlbr,this.patternTo=t.tlbr}setUniform(t,i,s,o){const d=o==="u_pattern_to"?this.patternTo:o==="u_pattern_from"?this.patternFrom:o==="u_pixel_ratio_to"?this.pixelRatioTo:o==="u_pixel_ratio_from"?this.pixelRatioFrom:null;d&&t.set(d)}getBinding(t,i,s){return s.substr(0,9)==="u_pattern"?new Gt(t,i):new nn(t,i)}}class Ar{constructor(t,i,s,o){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=i.map(d=>({name:`a_${d}`,type:"Float32",components:s==="color"?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(t,i,s){const o=this.paintVertexArray.length,d=this.expression.evaluate(new wt(0,s),i,{},s.canonical,[],s.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(o,t,d)}updatePaintArray(t,i,s,o,d){const p=this.expression.evaluate(new wt(0,d),s,o);this._setPaintValue(t,i,p)}_setPaintValue(t,i,s){if(this.type==="color"){const o=qt(s);for(let d=t;d<i;d++)this.paintVertexArray.emplace(d,o[0],o[1])}else{for(let o=t;o<i;o++)this.paintVertexArray.emplace(o,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 lr{constructor(t,i,s,o,d,p){this.expression=t,this.uniformNames=i.map(m=>`u_${m}_t`),this.type=s,this.useIntegerZoom=o,this.zoom=d,this.maxValue=0,this.paintVertexAttributes=i.map(m=>({name:`a_${m}`,type:"Float32",components:s==="color"?4:2,offset:0})),this.paintVertexArray=new p}populatePaintArray(t,i,s){const o=this.expression.evaluate(new wt(this.zoom,s),i,{},s.canonical,[],s.formattedSection),d=this.expression.evaluate(new wt(this.zoom+1,s),i,{},s.canonical,[],s.formattedSection),p=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(p,t,o,d)}updatePaintArray(t,i,s,o,d){const p=this.expression.evaluate(new wt(this.zoom,d),s,o),m=this.expression.evaluate(new wt(this.zoom+1,d),s,o);this._setPaintValue(t,i,p,m)}_setPaintValue(t,i,s,o){if(this.type==="color"){const d=qt(s),p=qt(o);for(let m=t;m<i;m++)this.paintVertexArray.emplace(m,d[0],d[1],p[0],p[1])}else{for(let d=t;d<i;d++)this.paintVertexArray.emplace(d,s,o);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(o))}}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,i){const s=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,o=Ei(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);t.set(o)}getBinding(t,i,s){return new nn(t,i)}}class sn{constructor(t,i,s,o,d,p){this.expression=t,this.type=i,this.useIntegerZoom=s,this.zoom=o,this.layerId=p,this.zoomInPaintVertexArray=new d,this.zoomOutPaintVertexArray=new d}populatePaintArray(t,i,s){const o=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(o,t,i.patterns&&i.patterns[this.layerId],s.imagePositions)}updatePaintArray(t,i,s,o,d){this._setPaintValues(t,i,s.patterns&&s.patterns[this.layerId],d.imagePositions)}_setPaintValues(t,i,s,o){if(!o||!s)return;const{min:d,mid:p,max:m}=s,g=o[d],x=o[p],v=o[m];if(g&&x&&v)for(let T=t;T<i;T++)this.zoomInPaintVertexArray.emplace(T,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(T,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,Zt.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Zt.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class yc{constructor(t,i,s){this.binders={},this._buffers=[];const o=[];for(const d in t.paint._values){if(!s(d))continue;const p=t.paint.get(d);if(!(p instanceof Pr&&Jr(p.property.specification)))continue;const m=xc(d,t.type),g=p.value,x=p.property.specification.type,v=p.property.useIntegerZoom,T=p.property.specification["property-type"],M=T==="cross-faded"||T==="cross-faded-data-driven";if(g.kind==="constant")this.binders[d]=M?new ms(g.value,m):new Js(g.value,m,x),o.push(`/u_${d}`);else if(g.kind==="source"||M){const E=sl(d,x,"source");this.binders[d]=M?new sn(g,x,v,i,E,t.id):new Ar(g,m,x,E),o.push(`/a_${d}`)}else{const E=sl(d,x,"composite");this.binders[d]=new lr(g,m,x,v,i,E),o.push(`/z_${d}`)}}this.cacheKey=o.sort().join("")}getMaxValue(t){const i=this.binders[t];return i instanceof Ar||i instanceof lr?i.maxValue:0}populatePaintArrays(t,i,s){for(const o in this.binders){const d=this.binders[o];(d instanceof Ar||d instanceof lr||d instanceof sn)&&d.populatePaintArray(t,i,s)}}setConstantPatternPositions(t,i){for(const s in this.binders){const o=this.binders[s];o instanceof ms&&o.setConstantPatternPositions(t,i)}}updatePaintArrays(t,i,s,o,d){let p=!1;for(const m in t){const g=i.getPositions(m);for(const x of g){const v=s.feature(x.index);for(const T in this.binders){const M=this.binders[T];if((M instanceof Ar||M instanceof lr||M instanceof sn)&&M.expression.isStateDependent===!0){const E=o.paint.get(T);M.expression=E.value,M.updatePaintArray(x.start,x.end,v,t[m],d),p=!0}}}}return p}defines(){const t=[];for(const i in this.binders){const s=this.binders[i];(s instanceof Js||s instanceof ms)&&t.push(...s.uniformNames.map(o=>`#define HAS_UNIFORM_${o}`))}return t}getBinderAttributes(){const t=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof Ar||s instanceof lr)for(let o=0;o<s.paintVertexAttributes.length;o++)t.push(s.paintVertexAttributes[o].name);else if(s instanceof sn)for(let o=0;o<Zt.members.length;o++)t.push(Zt.members[o].name)}return t}getBinderUniforms(){const t=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof Js||s instanceof ms||s instanceof lr)for(const o of s.uniformNames)t.push(o)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,i){const s=[];for(const o in this.binders){const d=this.binders[o];if(d instanceof Js||d instanceof ms||d instanceof lr){for(const p of d.uniformNames)if(i[p]){const m=d.getBinding(t,i[p],p);s.push({name:p,property:o,binding:m})}}}return s}setUniforms(t,i,s,o){for(const{name:d,property:p,binding:m}of i)this.binders[p].setUniform(m,o,s.get(p),d)}updatePaintBuffers(t){this._buffers=[];for(const i in this.binders){const s=this.binders[i];if(t&&s instanceof sn){const o=t.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;o&&this._buffers.push(o)}else(s instanceof Ar||s instanceof lr)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(t){for(const i in this.binders){const s=this.binders[i];(s instanceof Ar||s instanceof lr||s instanceof sn)&&s.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const i=this.binders[t];(i instanceof Ar||i instanceof lr||i instanceof sn)&&i.destroy()}}}class ji{constructor(t,i,s=()=>!0){this.programConfigurations={};for(const o of t)this.programConfigurations[o.id]=new yc(o,i,s);this.needsUpload=!1,this._featureMap=new Rn,this._bufferOffset=0}populatePaintArrays(t,i,s,o){for(const d in this.programConfigurations)this.programConfigurations[d].populatePaintArrays(t,i,o);i.id!==void 0&&this._featureMap.add(i.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,i,s,o){for(const d of s)this.needsUpload=this.programConfigurations[d.id].updatePaintArrays(t,this._featureMap,i,d,o)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function xc(r,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"]}[r]||[r.replace(`${t}-`,"").replace(/-/g,"_")]}function sl(r,t,i){const s={color:{source:Ks,composite:w},number:{source:u,composite:Ks}},o=function(d){return{"line-pattern":{source:we,composite:we},"fill-pattern":{source:we,composite:we},"fill-extrusion-pattern":{source:we,composite:we}}[d]}(r);return o&&o[i]||s[t][i]}ze("ConstantBinder",Js),ze("CrossFadedConstantBinder",ms),ze("SourceExpressionBinder",Ar),ze("CrossFadedCompositeBinder",sn),ze("CompositeExpressionBinder",lr),ze("ProgramConfiguration",yc,{omit:["_buffers"]}),ze("ProgramConfigurationSet",ji);const Wa=Math.pow(2,14)-1,Ha=-Wa-1;function an(r){const t=gt/r.extent,i=r.loadGeometry();for(let s=0;s<i.length;s++){const o=i[s];for(let d=0;d<o.length;d++){const p=o[d],m=Math.round(p.x*t),g=Math.round(p.y*t);p.x=Ei(m,Ha,Wa),p.y=Ei(g,Ha,Wa),(m<p.x||m>p.x+1||g<p.y||g>p.y+1)&&jt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function kr(r,t){return{type:r.type,id:r.id,properties:r.properties,geometry:t?an(r):[]}}const fu=-32768;function Pp(r,t,i,s,o){r.emplaceBack(fu+8*t+s,fu+8*i+o)}class xh{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new te,this.indexArray=new yt,this.segments=new Xe,this.programConfigurations=new ji(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){const o=this.layers[0],d=[];let p=null,m=!1,g=o.type==="heatmap";if(o.type==="circle"){const v=o;p=v.layout.get("circle-sort-key"),m=!p.isConstant(),g=g||v.paint.get("circle-pitch-alignment")==="map"}const x=g?i.subdivisionGranularity.circle:1;for(const{feature:v,id:T,index:M,sourceLayerIndex:E}of t){const A=this.layers[0]._featureFilter.needGeometry,L=kr(v,A);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom,{globalState:this.globalState}),L,s))continue;const F=m?p.evaluate(L,{},s):void 0,V={id:T,properties:v.properties,type:v.type,sourceLayerIndex:E,index:M,geometry:A?L.geometry:an(v),patterns:{},sortKey:F};d.push(V)}m&&d.sort((v,T)=>v.sortKey-T.sortKey);for(const v of d){const{geometry:T,index:M,sourceLayerIndex:E}=v,A=t[M].feature;this.addFeature(v,T,M,s,x),i.featureIndex.insert(A,T,M,E,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,zt),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,i,s,o,d=1){let p;switch(d){case 1:p=[0,7];break;case 3:p=[0,2,5,7];break;case 5:p=[0,1,3,4,6,7];break;case 7:p=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${d}; valid values are 1, 3, 5, 7.`)}const m=p.length;for(const g of i)for(const x of g){const v=x.x,T=x.y;if(v<0||v>=gt||T<0||T>=gt)continue;const M=this.segments.prepareSegment(m*m,this.layoutVertexArray,this.indexArray,t.sortKey),E=M.vertexLength;for(let A=0;A<m;A++)for(let L=0;L<m;L++)Pp(this.layoutVertexArray,v,T,p[L],p[A]);for(let A=0;A<m-1;A++)for(let L=0;L<m-1;L++){const F=E+A*m+L,V=E+(A+1)*m+L;this.indexArray.emplaceBack(F,V+1,F+1),this.indexArray.emplaceBack(F,V,V+1)}M.vertexLength+=m*m,M.primitiveLength+=(m-1)*(m-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:{},canonical:o,globalState:this.globalState})}}function mu(r,t){for(let i=0;i<r.length;i++)if(Xa(t,r[i]))return!0;for(let i=0;i<t.length;i++)if(Xa(r,t[i]))return!0;return!!vh(r,t)}function Sp(r,t,i){return!!Xa(r,t)||!!bh(t,r,i)}function gu(r,t){if(r.length===1)return yu(t,r[0]);for(let i=0;i<t.length;i++){const s=t[i];for(let o=0;o<s.length;o++)if(Xa(r,s[o]))return!0}for(let i=0;i<r.length;i++)if(yu(t,r[i]))return!0;for(let i=0;i<t.length;i++)if(vh(r,t[i]))return!0;return!1}function Mp(r,t,i){if(r.length>1){if(vh(r,t))return!0;for(let s=0;s<t.length;s++)if(bh(t[s],r,i))return!0}for(let s=0;s<r.length;s++)if(bh(r[s],t,i))return!0;return!1}function vh(r,t){if(r.length===0||t.length===0)return!1;for(let i=0;i<r.length-1;i++){const s=r[i],o=r[i+1];for(let d=0;d<t.length-1;d++)if(Ip(s,o,t[d],t[d+1]))return!0}return!1}function Ip(r,t,i,s){return Ki(r,i,s)!==Ki(t,i,s)&&Ki(r,t,i)!==Ki(r,t,s)}function bh(r,t,i){const s=i*i;if(t.length===1)return r.distSqr(t[0])<s;for(let o=1;o<t.length;o++)if(_u(r,t[o-1],t[o])<s)return!0;return!1}function _u(r,t,i){const s=t.distSqr(i);if(s===0)return r.distSqr(t);const o=((r.x-t.x)*(i.x-t.x)+(r.y-t.y)*(i.y-t.y))/s;return r.distSqr(o<0?t:o>1?i:i.sub(t)._mult(o)._add(t))}function yu(r,t){let i,s,o,d=!1;for(let p=0;p<r.length;p++){i=r[p];for(let m=0,g=i.length-1;m<i.length;g=m++)s=i[m],o=i[g],s.y>t.y!=o.y>t.y&&t.x<(o.x-s.x)*(t.y-s.y)/(o.y-s.y)+s.x&&(d=!d)}return d}function Xa(r,t){let i=!1;for(let s=0,o=r.length-1;s<r.length;o=s++){const d=r[s],p=r[o];d.y>t.y!=p.y>t.y&&t.x<(p.x-d.x)*(t.y-d.y)/(p.y-d.y)+d.x&&(i=!i)}return i}function Cp(r,t,i){const s=i[0],o=i[2];if(r.x<s.x&&t.x<s.x||r.x>o.x&&t.x>o.x||r.y<s.y&&t.y<s.y||r.y>o.y&&t.y>o.y)return!1;const d=Ki(r,t,i[0]);return d!==Ki(r,t,i[1])||d!==Ki(r,t,i[2])||d!==Ki(r,t,i[3])}function al(r,t,i){const s=t.paint.get(r).value;return s.kind==="constant"?s.value:i.programConfigurations.get(t.id).getMaxValue(r)}function vc(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function bc(r,t,i,s,o){if(!t[0]&&!t[1])return r;const d=be.convert(t)._mult(o);i==="viewport"&&d._rotate(-s);const p=[];for(let m=0;m<r.length;m++)p.push(r[m].sub(d));return p}let xu,vu;ze("CircleBucket",xh,{omit:["layers"]});var Ep={get paint(){return vu=vu||new Pi({"circle-radius":new Ne(ne.paint_circle["circle-radius"]),"circle-color":new Ne(ne.paint_circle["circle-color"]),"circle-blur":new Ne(ne.paint_circle["circle-blur"]),"circle-opacity":new Ne(ne.paint_circle["circle-opacity"]),"circle-translate":new Fe(ne.paint_circle["circle-translate"]),"circle-translate-anchor":new Fe(ne.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Fe(ne.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Fe(ne.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ne(ne.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ne(ne.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ne(ne.paint_circle["circle-stroke-opacity"])})},get layout(){return xu=xu||new Pi({"circle-sort-key":new Ne(ne.layout_circle["circle-sort-key"])})}};class Ap extends Wi{constructor(t){super(t,Ep)}createBucket(t){return new xh(t)}queryRadius(t){const i=t;return al("circle-radius",this,i)+al("circle-stroke-width",this,i)+vc(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:o,transform:d,pixelsToTileUnits:p,unwrappedTileID:m,getElevation:g}){const x=bc(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-d.bearingInRadians,p),v=this.paint.get("circle-radius").evaluate(i,s)+this.paint.get("circle-stroke-width").evaluate(i,s),T=this.paint.get("circle-pitch-alignment")==="map",M=T?x:function(A,L,F,V){return A.map(Q=>bu(Q,L,F,V))}(x,d,m,g),E=T?v*p:v;for(const A of o)for(const L of A){const F=T?L:bu(L,d,m,g);let V=E;const Q=d.projectTileCoordinates(L.x,L.y,m,g).signedDistanceFromCamera;if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?V*=Q/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(V*=d.cameraToCenterDistance/Q),Sp(M,F,V))return!0}return!1}}function bu(r,t,i,s){const o=t.projectTileCoordinates(r.x,r.y,i,s).point;return new be((.5*o.x+.5)*t.width,(.5*-o.y+.5)*t.height)}class wu extends xh{}let Tu;ze("HeatmapBucket",wu,{omit:["layers"]});var kp={get paint(){return Tu=Tu||new Pi({"heatmap-radius":new Ne(ne.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ne(ne.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Fe(ne.paint_heatmap["heatmap-intensity"]),"heatmap-color":new $a(ne.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Fe(ne.paint_heatmap["heatmap-opacity"])})}};function wh(r,{width:t,height:i},s,o){if(o){if(o instanceof Uint8ClampedArray)o=new Uint8Array(o.buffer);else if(o.length!==t*i*s)throw new RangeError(`mismatched image size. expected: ${o.length} but got: ${t*i*s}`)}else o=new Uint8Array(t*i*s);return r.width=t,r.height=i,r.data=o,r}function Pu(r,{width:t,height:i},s){if(t===r.width&&i===r.height)return;const o=wh({},{width:t,height:i},s);Th(r,o,{x:0,y:0},{x:0,y:0},{width:Math.min(r.width,t),height:Math.min(r.height,i)},s),r.width=t,r.height=i,r.data=o.data}function Th(r,t,i,s,o,d){if(o.width===0||o.height===0)return t;if(o.width>r.width||o.height>r.height||i.x>r.width-o.width||i.y>r.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>t.width||o.height>t.height||s.x>t.width-o.width||s.y>t.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const p=r.data,m=t.data;if(p===m)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g<o.height;g++){const x=((i.y+g)*r.width+i.x)*d,v=((s.y+g)*t.width+s.x)*d;for(let T=0;T<o.width*d;T++)m[v+T]=p[x+T]}return t}class ol{constructor(t,i){wh(this,t,1,i)}resize(t){Pu(this,t,1)}clone(){return new ol({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,s,o,d){Th(t,i,s,o,d,1)}}class Ni{constructor(t,i){wh(this,t,4,i)}resize(t){Pu(this,t,4)}replace(t,i){i?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Ni({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,s,o,d){Th(t,i,s,o,d,4)}setPixel(t,i,s){const o=4*(t*this.width+i);this.data[o+0]=Math.round(255*s.r/s.a),this.data[o+1]=Math.round(255*s.g/s.a),this.data[o+2]=Math.round(255*s.b/s.a),this.data[o+3]=Math.round(255*s.a)}}function Su(r){const t={},i=r.resolution||256,s=r.clips?r.clips.length:1,o=r.image||new Ni({width:i,height:s});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const d=(p,m,g)=>{t[r.evaluationKey]=g;const x=r.expression.evaluate(t);o.setPixel(p/4/i,m/4,x)};if(r.clips)for(let p=0,m=0;p<s;++p,m+=4*i)for(let g=0,x=0;g<i;g++,x+=4){const v=g/(i-1),{start:T,end:M}=r.clips[p];d(m,x,T*(1-v)+M*v)}else for(let p=0,m=0;p<i;p++,m+=4)d(0,m,p/(i-1));return o}ze("AlphaImage",ol),ze("RGBAImage",Ni);const Ph="big-fb";class zp extends Wi{createBucket(t){return new wu(t)}constructor(t){super(t,kp),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Su({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Ph)&&this.heatmapFbos.delete(Ph)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let Mu;var Lp={get paint(){return Mu=Mu||new Pi({"hillshade-illumination-direction":new Fe(ne.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Fe(ne.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Fe(ne.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Fe(ne.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Fe(ne.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Fe(ne.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Fe(ne.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Fe(ne.paint_hillshade["hillshade-method"])})}};class Dp extends Wi{constructor(t){super(t,Lp),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,i=this.paint.get("hillshade-illumination-altitude").values,s=this.paint.get("hillshade-highlight-color").values,o=this.paint.get("hillshade-shadow-color").values;const d=Math.max(t.length,i.length,s.length,o.length);t=t.concat(Array(d-t.length).fill(t.at(-1))),i=i.concat(Array(d-i.length).fill(i.at(-1))),s=s.concat(Array(d-s.length).fill(s.at(-1))),o=o.concat(Array(d-o.length).fill(o.at(-1)));const p=i.map(gn);return{directionRadians:t.map(gn),altitudeRadians:p,shadowColor:o,highlightColor:s}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}let Iu;var Rp={get paint(){return Iu=Iu||new Pi({"color-relief-opacity":new Fe(ne["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new $a(ne["paint_color-relief"]["color-relief-color"])})}};class Sh{constructor(t,i,s,o){this.context=t,this.format=s,this.texture=t.gl.createTexture(),this.update(i,o)}update(t,i,s){const{width:o,height:d}=t,p=!(this.size&&this.size[0]===o&&this.size[1]===d||s),{context:m}=this,{gl:g}=m;if(this.useMipmap=!!(i&&i.useMipmap),g.bindTexture(g.TEXTURE_2D,this.texture),m.pixelStoreUnpackFlipY.set(!1),m.pixelStoreUnpack.set(1),m.pixelStoreUnpackPremultiplyAlpha.set(this.format===g.RGBA&&(!i||i.premultiply!==!1)),p)this.size=[o,d],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||_r(t)?g.texImage2D(g.TEXTURE_2D,0,this.format,this.format,g.UNSIGNED_BYTE,t):g.texImage2D(g.TEXTURE_2D,0,this.format,o,d,0,this.format,g.UNSIGNED_BYTE,t.data);else{const{x,y:v}=s||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||_r(t)?g.texSubImage2D(g.TEXTURE_2D,0,x,v,g.RGBA,g.UNSIGNED_BYTE,t):g.texSubImage2D(g.TEXTURE_2D,0,x,v,o,d,g.RGBA,g.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&g.generateMipmap(g.TEXTURE_2D),m.pixelStoreUnpackFlipY.setDefault(),m.pixelStoreUnpack.setDefault(),m.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(t,i,s){const{context:o}=this,{gl:d}=o;d.bindTexture(d.TEXTURE_2D,this.texture),s!==d.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=d.LINEAR),t!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,s||t),this.filter=t),i!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,i),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,i),this.wrap=i)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Cu{constructor(t,i,s,o=1,d=1,p=1,m=0){if(this.uid=t,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void jt(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;const g=this.dim=i.height-2;switch(this.data=new Uint32Array(i.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=o,this.greenFactor=d,this.blueFactor=p,this.baseShift=m;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++){const T=this.get(x,v);T>this.max&&(this.max=T),T<this.min&&(this.min=T)}}get(t,i){const s=new Uint8Array(this.data.buffer),o=4*this._idx(t,i);return this.unpack(s[o],s[o+1],s[o+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,i){if(t<-1||t>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(t+1)}unpack(t,i,s){return t*this.redFactor+i*this.greenFactor+s*this.blueFactor-this.baseShift}pack(t){return Eu(t,this.getUnpackVector())}getPixels(){return new Ni({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,i,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let o=i*this.dim,d=i*this.dim+this.dim,p=s*this.dim,m=s*this.dim+this.dim;switch(i){case-1:o=d-1;break;case 1:d=o+1}switch(s){case-1:p=m-1;break;case 1:m=p+1}const g=-i*this.dim,x=-s*this.dim;for(let v=p;v<m;v++)for(let T=o;T<d;T++)this.data[this._idx(T,v)]=t.data[this._idx(T+g,v+x)]}}function Eu(r,t){const i=t[0],s=t[1],o=t[2],d=t[3],p=Math.min(i,s,o),m=Math.round((r+d)/p);return{r:Math.floor(m*p/i)%256,g:Math.floor(m*p/s)%256,b:Math.floor(m*p/o)%256}}ze("DEMData",Cu);class Fp extends Wi{constructor(t){super(t,Rp)}_createColorRamp(t){const i={elevationStops:[],colorStops:[]},s=this._transitionablePaint._values["color-relief-color"].value.expression;if(s instanceof Us&&s._styleExpression.expression instanceof ui){this.colorRampExpression=s;const p=s._styleExpression.expression;i.elevationStops=p.labels,i.colorStops=[];for(const m of i.elevationStops)i.colorStops.push(p.evaluate({globals:{elevation:m}}))}if(i.elevationStops.length<1&&(i.elevationStops=[0],i.colorStops=[it.transparent]),i.elevationStops.length<2&&(i.elevationStops.push(i.elevationStops[0]+1),i.colorStops.push(i.colorStops[0])),i.elevationStops.length<=t)return i;const o={elevationStops:[],colorStops:[]},d=(i.elevationStops.length-1)/(t-1);for(let p=0;p<i.elevationStops.length-.5;p+=d)o.elevationStops.push(i.elevationStops[Math.round(p)]),o.colorStops.push(i.colorStops[Math.round(p)]);return jt(`Too many colors in specification of ${this.id} color-relief layer, may not render properly.`),o}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,i,s){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const o=this._createColorRamp(i),d=new Ni({width:o.colorStops.length,height:1}),p=new Ni({width:o.colorStops.length,height:1});for(let m=0;m<o.elevationStops.length;m++){const g=Eu(o.elevationStops[m],s);p.setPixel(0,m,new it(g.r/255,g.g/255,g.b/255,1)),d.setPixel(0,m,o.colorStops[m])}return this.colorRampTextures={elevationTexture:new Sh(t,p,t.gl.RGBA),colorTexture:new Sh(t,d,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return this.visibility!=="none"&&!!this.colorRampTextures}}const Bp=Bt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Op}=Bp;function Mh(r,t,i){const s=i.patternDependencies;let o=!1;for(const d of t){const p=d.paint.get(`${r}-pattern`);p.isConstant()||(o=!0);const m=p.constantOr(null);m&&(o=!0,s[m.to]=!0,s[m.from]=!0)}return o}function Ih(r,t,i,s,o){const{zoom:d,globalState:p}=s,m=o.patternDependencies;for(const g of t){const x=g.paint.get(`${r}-pattern`).value;if(x.kind!=="constant"){let v=x.evaluate({zoom:d-1,globalState:p},i,{},o.availableImages),T=x.evaluate({zoom:d,globalState:p},i,{},o.availableImages),M=x.evaluate({zoom:d+1,globalState:p},i,{},o.availableImages);v=v&&v.name?v.name:v,T=T&&T.name?T.name:T,M=M&&M.name?M.name:M,m[v]=!0,m[T]=!0,m[M]=!0,i.patterns[g.id]={min:v,mid:T,max:M}}}return i}function Au(r,t,i,s,o){let d;if(o===function(p,m,g,x){let v=0;for(let T=m,M=g-x;T<g;T+=x)v+=(p[M]-p[T])*(p[T+1]+p[M+1]),M=T;return v}(r,t,i,s)>0)for(let p=t;p<i;p+=s)d=Du(p/s|0,r[p],r[p+1],d);else for(let p=i-s;p>=t;p-=s)d=Du(p/s|0,r[p],r[p+1],d);return d&&Ya(d,d.next)&&(ul(d),d=d.next),d}function Qs(r,t){if(!r)return r;t||(t=r);let i,s=r;do if(i=!1,s.steiner||!Ya(s,s.next)&&Vt(s.prev,s,s.next)!==0)s=s.next;else{if(ul(s),s=t=s.prev,s===s.next)break;i=!0}while(i||s!==t);return t}function ll(r,t,i,s,o,d,p){if(!r)return;!p&&d&&function(g,x,v,T){let M=g;do M.z===0&&(M.z=Ch(M.x,M.y,x,v,T)),M.prevZ=M.prev,M.nextZ=M.next,M=M.next;while(M!==g);M.prevZ.nextZ=null,M.prevZ=null,function(E){let A,L=1;do{let F,V=E;E=null;let Q=null;for(A=0;V;){A++;let W=V,X=0;for(let pe=0;pe<L&&(X++,W=W.nextZ,W);pe++);let ce=L;for(;X>0||ce>0&&W;)X!==0&&(ce===0||!W||V.z<=W.z)?(F=V,V=V.nextZ,X--):(F=W,W=W.nextZ,ce--),Q?Q.nextZ=F:E=F,F.prevZ=Q,Q=F;V=W}Q.nextZ=null,L*=2}while(A>1)}(M)}(r,s,o,d);let m=r;for(;r.prev!==r.next;){const g=r.prev,x=r.next;if(d?Np(r,s,o,d):jp(r))t.push(g.i,r.i,x.i),ul(r),r=x.next,m=x.next;else if((r=x)===m){p?p===1?ll(r=Vp(Qs(r),t),t,i,s,o,d,2):p===2&&Up(r,t,i,s,o,d):ll(Qs(r),t,i,s,o,d,1);break}}}function jp(r){const t=r.prev,i=r,s=r.next;if(Vt(t,i,s)>=0)return!1;const o=t.x,d=i.x,p=s.x,m=t.y,g=i.y,x=s.y,v=Math.min(o,d,p),T=Math.min(m,g,x),M=Math.max(o,d,p),E=Math.max(m,g,x);let A=s.next;for(;A!==t;){if(A.x>=v&&A.x<=M&&A.y>=T&&A.y<=E&&cl(o,m,d,g,p,x,A.x,A.y)&&Vt(A.prev,A,A.next)>=0)return!1;A=A.next}return!0}function Np(r,t,i,s){const o=r.prev,d=r,p=r.next;if(Vt(o,d,p)>=0)return!1;const m=o.x,g=d.x,x=p.x,v=o.y,T=d.y,M=p.y,E=Math.min(m,g,x),A=Math.min(v,T,M),L=Math.max(m,g,x),F=Math.max(v,T,M),V=Ch(E,A,t,i,s),Q=Ch(L,F,t,i,s);let W=r.prevZ,X=r.nextZ;for(;W&&W.z>=V&&X&&X.z<=Q;){if(W.x>=E&&W.x<=L&&W.y>=A&&W.y<=F&&W!==o&&W!==p&&cl(m,v,g,T,x,M,W.x,W.y)&&Vt(W.prev,W,W.next)>=0||(W=W.prevZ,X.x>=E&&X.x<=L&&X.y>=A&&X.y<=F&&X!==o&&X!==p&&cl(m,v,g,T,x,M,X.x,X.y)&&Vt(X.prev,X,X.next)>=0))return!1;X=X.nextZ}for(;W&&W.z>=V;){if(W.x>=E&&W.x<=L&&W.y>=A&&W.y<=F&&W!==o&&W!==p&&cl(m,v,g,T,x,M,W.x,W.y)&&Vt(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;X&&X.z<=Q;){if(X.x>=E&&X.x<=L&&X.y>=A&&X.y<=F&&X!==o&&X!==p&&cl(m,v,g,T,x,M,X.x,X.y)&&Vt(X.prev,X,X.next)>=0)return!1;X=X.nextZ}return!0}function Vp(r,t){let i=r;do{const s=i.prev,o=i.next.next;!Ya(s,o)&&zu(s,i,i.next,o)&&hl(s,o)&&hl(o,s)&&(t.push(s.i,i.i,o.i),ul(i),ul(i.next),i=r=o),i=i.next}while(i!==r);return Qs(i)}function Up(r,t,i,s,o,d){let p=r;do{let m=p.next.next;for(;m!==p.prev;){if(p.i!==m.i&&Wp(p,m)){let g=Lu(p,m);return p=Qs(p,p.next),g=Qs(g,g.next),ll(p,t,i,s,o,d,0),void ll(g,t,i,s,o,d,0)}m=m.next}p=p.next}while(p!==r)}function $p(r,t){let i=r.x-t.x;return i===0&&(i=r.y-t.y,i===0)&&(i=(r.next.y-r.y)/(r.next.x-r.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Zp(r,t){const i=function(o,d){let p=d;const m=o.x,g=o.y;let x,v=-1/0;if(Ya(o,p))return p;do{if(Ya(o,p.next))return p.next;if(g<=p.y&&g>=p.next.y&&p.next.y!==p.y){const L=p.x+(g-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(L<=m&&L>v&&(v=L,x=p.x<p.next.x?p:p.next,L===m))return x}p=p.next}while(p!==d);if(!x)return null;const T=x,M=x.x,E=x.y;let A=1/0;p=x;do{if(m>=p.x&&p.x>=M&&m!==p.x&&ku(g<E?m:v,g,M,E,g<E?v:m,g,p.x,p.y)){const L=Math.abs(g-p.y)/(m-p.x);hl(p,o)&&(L<A||L===A&&(p.x>x.x||p.x===x.x&&Gp(x,p)))&&(x=p,A=L)}p=p.next}while(p!==T);return x}(r,t);if(!i)return t;const s=Lu(i,r);return Qs(s,s.next),Qs(i,i.next)}function Gp(r,t){return Vt(r.prev,r,t.prev)<0&&Vt(t.next,r,r.next)<0}function Ch(r,t,i,s,o){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-i)*o|0)|r<<8))|r<<4))|r<<2))|r<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function qp(r){let t=r,i=r;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==r);return i}function ku(r,t,i,s,o,d,p,m){return(o-p)*(t-m)>=(r-p)*(d-m)&&(r-p)*(s-m)>=(i-p)*(t-m)&&(i-p)*(d-m)>=(o-p)*(s-m)}function cl(r,t,i,s,o,d,p,m){return!(r===p&&t===m)&&ku(r,t,i,s,o,d,p,m)}function Wp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!function(i,s){let o=i;do{if(o.i!==i.i&&o.next.i!==i.i&&o.i!==s.i&&o.next.i!==s.i&&zu(o,o.next,i,s))return!0;o=o.next}while(o!==i);return!1}(r,t)&&(hl(r,t)&&hl(t,r)&&function(i,s){let o=i,d=!1;const p=(i.x+s.x)/2,m=(i.y+s.y)/2;do o.y>m!=o.next.y>m&&o.next.y!==o.y&&p<(o.next.x-o.x)*(m-o.y)/(o.next.y-o.y)+o.x&&(d=!d),o=o.next;while(o!==i);return d}(r,t)&&(Vt(r.prev,r,t.prev)||Vt(r,t.prev,t))||Ya(r,t)&&Vt(r.prev,r,r.next)>0&&Vt(t.prev,t,t.next)>0)}function Vt(r,t,i){return(t.y-r.y)*(i.x-t.x)-(t.x-r.x)*(i.y-t.y)}function Ya(r,t){return r.x===t.x&&r.y===t.y}function zu(r,t,i,s){const o=Tc(Vt(r,t,i)),d=Tc(Vt(r,t,s)),p=Tc(Vt(i,s,r)),m=Tc(Vt(i,s,t));return o!==d&&p!==m||!(o!==0||!wc(r,i,t))||!(d!==0||!wc(r,s,t))||!(p!==0||!wc(i,r,s))||!(m!==0||!wc(i,t,s))}function wc(r,t,i){return t.x<=Math.max(r.x,i.x)&&t.x>=Math.min(r.x,i.x)&&t.y<=Math.max(r.y,i.y)&&t.y>=Math.min(r.y,i.y)}function Tc(r){return r>0?1:r<0?-1:0}function hl(r,t){return Vt(r.prev,r,r.next)<0?Vt(r,t,r.next)>=0&&Vt(r,r.prev,t)>=0:Vt(r,t,r.prev)<0||Vt(r,r.next,t)<0}function Lu(r,t){const i=Eh(r.i,r.x,r.y),s=Eh(t.i,t.x,t.y),o=r.next,d=t.prev;return r.next=t,t.prev=r,i.next=o,o.prev=i,s.next=i,i.prev=s,d.next=s,s.prev=d,s}function Du(r,t,i,s){const o=Eh(r,t,i);return s?(o.next=s.next,o.prev=s,s.next.prev=o,s.next=o):(o.prev=o,o.next=o),o}function ul(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Eh(r,t,i){return{i:r,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Ka{constructor(t,i){if(i>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=i}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class Pc{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}Pc.noSubdivision=new Pc({fill:new Ka(0,0),line:new Ka(0,0),tile:new Ka(0,0),stencil:new Ka(0,0),circle:1}),ze("SubdivisionGranularityExpression",Ka),ze("SubdivisionGranularitySetting",Pc);const Ja=-32768,dl=32767;class Hp{constructor(t,i){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=gt/t,this._canonical=i}_getKey(t,i){return(t+=32768)<<16|i+32768}_vertexToIndex(t,i){if(t<-32768||i<-32768||t>32767||i>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const s=0|Math.round(t),o=0|Math.round(i),d=this._getKey(s,o);if(this._vertexDictionary.has(d))return this._vertexDictionary.get(d);const p=this._vertexBuffer.length/2;return this._vertexDictionary.set(d,p),this._vertexBuffer.push(s,o),p}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(o,d){const p=[];for(let m=0;m<d.length;m+=3){const g=d[m],x=d[m+1],v=d[m+2],T=o[2*g],M=o[2*g+1];(o[2*x]-T)*(o[2*v+1]-M)-(o[2*x+1]-M)*(o[2*v]-T)>0?(p.push(g),p.push(v),p.push(x)):(p.push(g),p.push(x),p.push(v))}return p}(this._vertexBuffer,t);const i=[],s=t.length;for(let o=0;o<s;o+=3){const d=[t[o+0],t[o+1],t[o+2]],p=[this._vertexBuffer[2*t[o+0]+0],this._vertexBuffer[2*t[o+0]+1],this._vertexBuffer[2*t[o+1]+0],this._vertexBuffer[2*t[o+1]+1],this._vertexBuffer[2*t[o+2]+0],this._vertexBuffer[2*t[o+2]+1]];let m=1/0,g=1/0,x=-1/0,v=-1/0;for(let L=0;L<3;L++){const F=p[2*L],V=p[2*L+1];m=Math.min(m,F),x=Math.max(x,F),g=Math.min(g,V),v=Math.max(v,V)}if(m===x||g===v)continue;const T=Math.floor(m/this._granularityCellSize),M=Math.ceil(x/this._granularityCellSize),E=Math.floor(g/this._granularityCellSize),A=Math.ceil(v/this._granularityCellSize);if(T!==M||E!==A)for(let L=E;L<A;L++){const F=this._scanlineGenerateVertexRingForCellRow(L,p,d);Xp(this._vertexBuffer,F,i)}else i.push(...d)}return i}_scanlineGenerateVertexRingForCellRow(t,i,s){const o=t*this._granularityCellSize,d=o+this._granularityCellSize,p=[];for(let m=0;m<3;m++){const g=i[2*m],x=i[2*m+1],v=i[2*(m+1)%6],T=i[(2*(m+1)+1)%6],M=i[2*(m+2)%6],E=i[(2*(m+2)+1)%6],A=v-g,L=T-x,F=A===0,V=L===0,Q=(o-x)/L,W=(d-x)/L,X=Math.min(Q,W),ce=Math.max(Q,W);if(!V&&(X>=1||ce<=0)||V&&(x<o||x>d)){T>=o&&T<=d&&p.push(s[(m+1)%3]);continue}!V&&X>0&&p.push(this._vertexToIndex(g+A*X,x+L*X));const pe=g+A*Math.max(X,0),xe=g+A*Math.min(ce,1);F||this._generateIntraEdgeVertices(p,g,x,v,T,pe,xe),!V&&ce<1&&p.push(this._vertexToIndex(g+A*ce,x+L*ce)),(V||T>=o&&T<=d)&&p.push(s[(m+1)%3]),!V&&(T<=o||T>=d)&&this._generateInterEdgeVertices(p,g,x,v,T,M,E,xe,o,d)}return p}_generateIntraEdgeVertices(t,i,s,o,d,p,m){const g=o-i,x=d-s,v=x===0,T=v?Math.min(i,o):Math.min(p,m),M=v?Math.max(i,o):Math.max(p,m),E=Math.floor(T/this._granularityCellSize)+1,A=Math.ceil(M/this._granularityCellSize)-1;if(v?i<o:p<m)for(let L=E;L<=A;L++){const F=L*this._granularityCellSize;t.push(this._vertexToIndex(F,s+x*(F-i)/g))}else for(let L=A;L>=E;L--){const F=L*this._granularityCellSize;t.push(this._vertexToIndex(F,s+x*(F-i)/g))}}_generateInterEdgeVertices(t,i,s,o,d,p,m,g,x,v){const T=d-s,M=p-o,E=m-d,A=(x-d)/E,L=(v-d)/E,F=Math.min(A,L),V=Math.max(A,L),Q=o+M*F;let W=Math.floor(Math.min(Q,g)/this._granularityCellSize)+1,X=Math.ceil(Math.max(Q,g)/this._granularityCellSize)-1,ce=g<Q;const pe=E===0;if(pe&&(m===x||m===v))return;if(pe||F>=1||V<=0){const Ae=s-m,Pe=p+(i-p)*Math.min((x-m)/Ae,(v-m)/Ae);W=Math.floor(Math.min(Pe,g)/this._granularityCellSize)+1,X=Math.ceil(Math.max(Pe,g)/this._granularityCellSize)-1,ce=g<Pe}const xe=T>0?v:x;if(ce)for(let Ae=W;Ae<=X;Ae++)t.push(this._vertexToIndex(Ae*this._granularityCellSize,xe));else for(let Ae=X;Ae>=W;Ae--)t.push(this._vertexToIndex(Ae*this._granularityCellSize,xe))}_generateOutline(t){const i=[];for(const s of t){const o=ea(s,this._granularity,!0),d=this._pointArrayToIndices(o),p=[];for(let m=1;m<d.length;m++)p.push(d[m-1]),p.push(d[m]);i.push(p)}return i}_handlePoles(t){let i=!1,s=!1;this._canonical&&(this._canonical.y===0&&(i=!0),this._canonical.y===(1<<this._canonical.z)-1&&(s=!0)),(i||s)&&this._fillPoles(t,i,s)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let i=0;i<t.length;i+=2){const s=t[i+1];s===Ja&&(t[i+1]=-32767),s===dl&&(t[i+1]=32766)}}_generatePoleQuad(t,i,s,o,d,p){o>d!=(p===Ja)?(t.push(i),t.push(s),t.push(this._vertexToIndex(o,p)),t.push(s),t.push(this._vertexToIndex(d,p)),t.push(this._vertexToIndex(o,p))):(t.push(s),t.push(i),t.push(this._vertexToIndex(o,p)),t.push(this._vertexToIndex(d,p)),t.push(s),t.push(this._vertexToIndex(o,p)))}_fillPoles(t,i,s){const o=this._vertexBuffer,d=gt,p=t.length;for(let m=2;m<p;m+=3){const g=t[m-2],x=t[m-1],v=t[m],T=o[2*g],M=o[2*g+1],E=o[2*x],A=o[2*x+1],L=o[2*v],F=o[2*v+1];i&&(M===0&&A===0&&this._generatePoleQuad(t,g,x,T,E,Ja),A===0&&F===0&&this._generatePoleQuad(t,x,v,E,L,Ja),F===0&&M===0&&this._generatePoleQuad(t,v,g,L,T,Ja)),s&&(M===d&&A===d&&this._generatePoleQuad(t,g,x,T,E,dl),A===d&&F===d&&this._generatePoleQuad(t,x,v,E,L,dl),F===d&&M===d&&this._generatePoleQuad(t,v,g,L,T,dl))}}_initializeVertices(t){for(let i=0;i<t.length;i+=2)this._vertexToIndex(t[i],t[i+1])}subdividePolygonInternal(t,i){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:s,holeIndices:o}=function(m){const g=[],x=[];for(const v of m)if(v.length!==0){v!==m[0]&&g.push(x.length/2);for(let T=0;T<v.length;T++)x.push(v[T].x),x.push(v[T].y)}return{flattened:x,holeIndices:g}}(t);let d;this._initializeVertices(s);try{const m=function(x,v,T=2){const M=v&&v.length,E=M?v[0]*T:x.length;let A=Au(x,0,E,T,!0);const L=[];if(!A||A.next===A.prev)return L;let F,V,Q;if(M&&(A=function(W,X,ce,pe){const xe=[];for(let Ae=0,Pe=X.length;Ae<Pe;Ae++){const Ie=Au(W,X[Ae]*pe,Ae<Pe-1?X[Ae+1]*pe:W.length,pe,!1);Ie===Ie.next&&(Ie.steiner=!0),xe.push(qp(Ie))}xe.sort($p);for(let Ae=0;Ae<xe.length;Ae++)ce=Zp(xe[Ae],ce);return ce}(x,v,A,T)),x.length>80*T){F=x[0],V=x[1];let W=F,X=V;for(let ce=T;ce<E;ce+=T){const pe=x[ce],xe=x[ce+1];pe<F&&(F=pe),xe<V&&(V=xe),pe>W&&(W=pe),xe>X&&(X=xe)}Q=Math.max(W-F,X-V),Q=Q!==0?32767/Q:0}return ll(A,L,T,F,V,Q,0),L}(s,o),g=this._convertIndices(s,m);d=this._subdivideTrianglesScanline(g)}catch(m){console.error(m)}let p=[];return i&&(p=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(d),{verticesFlattened:this._vertexBuffer,indicesTriangles:d,indicesLineList:p}}_convertIndices(t,i){const s=[];for(let o=0;o<i.length;o++)s.push(this._vertexToIndex(t[2*i[o]],t[2*i[o]+1]));return s}_pointArrayToIndices(t){const i=[];for(let s=0;s<t.length;s++){const o=t[s];i.push(this._vertexToIndex(o.x,o.y))}return i}}function Ru(r,t,i,s=!0){return new Hp(i,t).subdividePolygonInternal(r,s)}function ea(r,t,i=!1){if(!r||r.length<1)return[];if(r.length<2)return[];const s=r[0],o=r[r.length-1],d=i&&(s.x!==o.x||s.y!==o.y);if(t<2)return d?[...r,r[0]]:[...r];const p=Math.floor(gt/t),m=[];m.push(new be(r[0].x,r[0].y));const g=r.length,x=d?g:g-1;for(let v=0;v<x;v++){const T=r[v],M=v<g-1?r[v+1]:r[0],E=T.x,A=T.y,L=M.x,F=M.y,V=E!==L,Q=A!==F;if(!V&&!Q)continue;const W=L-E,X=F-A,ce=Math.abs(W),pe=Math.abs(X);let xe=E,Ae=A;for(;;){const Ie=W>0?(Math.floor(xe/p)+1)*p:(Math.ceil(xe/p)-1)*p,Be=X>0?(Math.floor(Ae/p)+1)*p:(Math.ceil(Ae/p)-1)*p,Me=Math.abs(xe-Ie),Ce=Math.abs(Ae-Be),ge=Math.abs(xe-L),$e=Math.abs(Ae-F),Ge=V?Me/ce:Number.POSITIVE_INFINITY,je=Q?Ce/pe:Number.POSITIVE_INFINITY;if((ge<=Me||!V)&&($e<=Ce||!Q))break;if(Ge<je&&V||!Q){xe=Ie,Ae+=X*Ge;const De=new be(xe,Math.round(Ae));m[m.length-1].x===De.x&&m[m.length-1].y===De.y||m.push(De)}else{xe+=W*je,Ae=Be;const De=new be(Math.round(xe),Ae);m[m.length-1].x===De.x&&m[m.length-1].y===De.y||m.push(De)}}const Pe=new be(L,F);m[m.length-1].x===Pe.x&&m[m.length-1].y===Pe.y||m.push(Pe)}return m}function Xp(r,t,i){if(t.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,o=r[2*t[0]];for(let g=1;g<t.length;g++){const x=r[2*t[g]];x<o&&(o=x,s=g)}const d=t.length;let p=s,m=(p+1)%d;for(;;){const g=p-1>=0?p-1:d-1,x=(m+1)%d,v=r[2*t[g]],T=r[2*t[x]],M=r[2*t[p]],E=r[2*t[p]+1],A=r[2*t[m]+1];let L=!1;if(v<T)L=!0;else if(v>T)L=!1;else{const F=A-E,V=-(r[2*t[m]]-M),Q=E<A?1:-1;((v-M)*F+(r[2*t[g]+1]-E)*V)*Q>((T-M)*F+(r[2*t[x]+1]-E)*V)*Q&&(L=!0)}if(L){const F=t[g],V=t[p],Q=t[m];F!==V&&F!==Q&&V!==Q&&i.push(Q,V,F),p--,p<0&&(p=d-1)}else{const F=t[x],V=t[p],Q=t[m];F!==V&&F!==Q&&V!==Q&&i.push(Q,V,F),m++,m>=d&&(m=0)}if(g===x)break}}function Fu(r,t,i,s,o,d,p,m,g){const x=o.length/2,v=p&&m&&g;if(x<Xe.MAX_VERTEX_ARRAY_LENGTH){const T=t.prepareSegment(x,i,s),M=T.vertexLength;for(let L=0;L<d.length;L+=3)s.emplaceBack(M+d[L],M+d[L+1],M+d[L+2]);let E,A;T.vertexLength+=x,T.primitiveLength+=d.length/3,v&&(A=p.prepareSegment(x,i,m),E=A.vertexLength,A.vertexLength+=x);for(let L=0;L<o.length;L+=2)r(o[L],o[L+1]);if(v)for(let L=0;L<g.length;L++){const F=g[L];for(let V=1;V<F.length;V+=2)m.emplaceBack(E+F[V-1],E+F[V]);A.primitiveLength+=F.length/2}}else(function(T,M,E,A,L,F){const V=[];for(let pe=0;pe<A.length/2;pe++)V.push(-1);const Q={count:0};let W=0,X=T.getOrCreateLatestSegment(M,E),ce=X.vertexLength;for(let pe=2;pe<L.length;pe+=3){const xe=L[pe-2],Ae=L[pe-1],Pe=L[pe];let Ie=V[xe]<W,Be=V[Ae]<W,Me=V[Pe]<W;X.vertexLength+((Ie?1:0)+(Be?1:0)+(Me?1:0))>Xe.MAX_VERTEX_ARRAY_LENGTH&&(X=T.createNewSegment(M,E),W=Q.count,Ie=!0,Be=!0,Me=!0,ce=0);const Ce=pl(V,A,F,Q,xe,Ie,X),ge=pl(V,A,F,Q,Ae,Be,X),$e=pl(V,A,F,Q,Pe,Me,X);E.emplaceBack(ce+Ce-W,ce+ge-W,ce+$e-W),X.primitiveLength++}})(t,i,s,o,d,r),v&&function(T,M,E,A,L,F){const V=[];for(let pe=0;pe<A.length/2;pe++)V.push(-1);const Q={count:0};let W=0,X=T.getOrCreateLatestSegment(M,E),ce=X.vertexLength;for(let pe=0;pe<L.length;pe++){const xe=L[pe];for(let Ae=1;Ae<L[pe].length;Ae+=2){const Pe=xe[Ae-1],Ie=xe[Ae];let Be=V[Pe]<W,Me=V[Ie]<W;X.vertexLength+((Be?1:0)+(Me?1:0))>Xe.MAX_VERTEX_ARRAY_LENGTH&&(X=T.createNewSegment(M,E),W=Q.count,Be=!0,Me=!0,ce=0);const Ce=pl(V,A,F,Q,Pe,Be,X),ge=pl(V,A,F,Q,Ie,Me,X);E.emplaceBack(ce+Ce-W,ce+ge-W),X.primitiveLength++}}}(p,i,m,o,g,r),t.forceNewSegmentOnNextPrepare(),p==null||p.forceNewSegmentOnNextPrepare()}function pl(r,t,i,s,o,d,p){if(d){const m=s.count;return i(t[2*o],t[2*o+1]),r[o]=s.count,s.count++,p.vertexLength++,m}return r[o]}class Ah{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ue,this.indexArray=new yt,this.indexArray2=new mt,this.programConfigurations=new ji(t.layers,t.zoom),this.segments=new Xe,this.segments2=new Xe,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.hasPattern=Mh("fill",this.layers,i);const o=this.layers[0].layout.get("fill-sort-key"),d=!o.isConstant(),p=[];for(const{feature:m,id:g,index:x,sourceLayerIndex:v}of t){const T=this.layers[0]._featureFilter.needGeometry,M=kr(m,T);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom,{globalState:this.globalState}),M,s))continue;const E=d?o.evaluate(M,{},s,i.availableImages):void 0,A={id:g,properties:m.properties,type:m.type,sourceLayerIndex:v,index:x,geometry:T?M.geometry:an(m),patterns:{},sortKey:E};p.push(A)}d&&p.sort((m,g)=>m.sortKey-g.sortKey);for(const m of p){const{geometry:g,index:x,sourceLayerIndex:v}=m;if(this.hasPattern){const T=Ih("fill",this.layers,m,{zoom:this.zoom,globalState:this.globalState},i);this.patternFeatures.push(T)}else this.addFeature(m,g,x,s,{},i.subdivisionGranularity);i.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}addFeatures(t,i,s){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,i,s,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Op),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,i,s,o,d,p){for(const m of Bs(i,500)){const g=Ru(m,o,p.fill.getGranularityForZoomLevel(o.z)),x=this.layoutVertexArray;Fu((v,T)=>{x.emplaceBack(v,T)},this.segments,this.layoutVertexArray,this.indexArray,g.verticesFlattened,g.indicesTriangles,this.segments2,this.indexArray2,g.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:d,canonical:o,globalState:this.globalState})}}let Bu,Ou;ze("FillBucket",Ah,{omit:["layers","patternFeatures"]});var Yp={get paint(){return Ou=Ou||new Pi({"fill-antialias":new Fe(ne.paint_fill["fill-antialias"]),"fill-opacity":new Ne(ne.paint_fill["fill-opacity"]),"fill-color":new Ne(ne.paint_fill["fill-color"]),"fill-outline-color":new Ne(ne.paint_fill["fill-outline-color"]),"fill-translate":new Fe(ne.paint_fill["fill-translate"]),"fill-translate-anchor":new Fe(ne.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ua(ne.paint_fill["fill-pattern"])})},get layout(){return Bu=Bu||new Pi({"fill-sort-key":new Ne(ne.layout_fill["fill-sort-key"])})}};class Kp extends Wi{constructor(t){super(t,Yp)}recalculate(t,i){super.recalculate(t,i);const 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 Ah(t)}queryRadius(){return vc(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:i,transform:s,pixelsToTileUnits:o}){return gu(bc(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,o),i)}isTileClipped(){return!0}}const Jp=Bt([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Qp=Bt([{name:"a_centroid",components:2,type:"Int16"}],4),{members:ef}=Jp;class Qa{constructor(t,i,s,o,d){this.properties={},this.extent=s,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=o,this._values=d,t.readFields(tf,this,i)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const i=t.readVarint()+t.pos,s=[];let o,d=1,p=0,m=0,g=0;for(;t.pos<i;){if(p<=0){const x=t.readVarint();d=7&x,p=x>>3}if(p--,d===1||d===2)m+=t.readSVarint(),g+=t.readSVarint(),d===1&&(o&&s.push(o),o=[]),o&&o.push(new be(m,g));else{if(d!==7)throw new Error(`unknown command ${d}`);o&&o.push(o[0].clone())}}return o&&s.push(o),s}bbox(){const t=this._pbf;t.pos=this._geometry;const i=t.readVarint()+t.pos;let s=1,o=0,d=0,p=0,m=1/0,g=-1/0,x=1/0,v=-1/0;for(;t.pos<i;){if(o<=0){const T=t.readVarint();s=7&T,o=T>>3}if(o--,s===1||s===2)d+=t.readSVarint(),p+=t.readSVarint(),d<m&&(m=d),d>g&&(g=d),p<x&&(x=p),p>v&&(v=p);else if(s!==7)throw new Error(`unknown command ${s}`)}return[m,x,g,v]}toGeoJSON(t,i,s){const o=this.extent*Math.pow(2,s),d=this.extent*t,p=this.extent*i,m=this.loadGeometry();function g(M){return[360*(M.x+d)/o-180,360/Math.PI*Math.atan(Math.exp((1-2*(M.y+p)/o)*Math.PI))-90]}function x(M){return M.map(g)}let v;if(this.type===1){const M=[];for(const A of m)M.push(A[0]);const E=x(M);v=M.length===1?{type:"Point",coordinates:E[0]}:{type:"MultiPoint",coordinates:E}}else if(this.type===2){const M=m.map(x);v=M.length===1?{type:"LineString",coordinates:M[0]}:{type:"MultiLineString",coordinates:M}}else{if(this.type!==3)throw new Error("unknown feature type");{const M=function(A){const L=A.length;if(L<=1)return[A];const F=[];let V,Q;for(let W=0;W<L;W++){const X=rf(A[W]);X!==0&&(Q===void 0&&(Q=X<0),Q===X<0?(V&&F.push(V),V=[A[W]]):V&&V.push(A[W]))}return V&&F.push(V),F}(m),E=[];for(const A of M)E.push(A.map(x));v=E.length===1?{type:"Polygon",coordinates:E[0]}:{type:"MultiPolygon",coordinates:E}}}const T={type:"Feature",geometry:v,properties:this.properties};return this.id!=null&&(T.id=this.id),T}}function tf(r,t,i){r===1?t.id=i.readVarint():r===2?function(s,o){const d=s.readVarint()+s.pos;for(;s.pos<d;){const p=o._keys[s.readVarint()],m=o._values[s.readVarint()];o.properties[p]=m}}(i,t):r===3?t.type=i.readVarint():r===4&&(t._geometry=i.pos)}function rf(r){let t=0;for(let i,s,o=0,d=r.length,p=d-1;o<d;p=o++)i=r[o],s=r[p],t+=(s.x-i.x)*(i.y+s.y);return t}Qa.types=["Unknown","Point","LineString","Polygon"];class ju{constructor(t,i){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(nf,this,i),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const i=this._pbf.readVarint()+this._pbf.pos;return new Qa(this._pbf,i,this.extent,this._keys,this._values)}}function nf(r,t,i){r===15?t.version=i.readVarint():r===1?t.name=i.readString():r===5?t.extent=i.readVarint():r===2?t._features.push(i.pos):r===3?t._keys.push(i.readString()):r===4&&t._values.push(function(s){let o=null;const d=s.readVarint()+s.pos;for(;s.pos<d;){const p=s.readVarint()>>3;o=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}if(o==null)throw new Error("unknown feature value");return o}(i))}class Nu{constructor(t,i){this.layers=t.readFields(sf,{},i)}}function sf(r,t,i){if(r===3){const s=new ju(i,i.readVarint()+i.pos);s.length&&(t[s.name]=s)}}const kh=Math.pow(2,13);function fl(r,t,i,s,o,d,p,m){r.emplaceBack(t,i,2*Math.floor(s*kh)+p,o*kh*2,d*kh*2,Math.round(m))}class zh{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ae,this.centroidVertexArray=new G,this.indexArray=new yt,this.programConfigurations=new ji(t.layers,t.zoom),this.segments=new Xe,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.features=[],this.hasPattern=Mh("fill-extrusion",this.layers,i);for(const{feature:o,id:d,index:p,sourceLayerIndex:m}of t){const g=this.layers[0]._featureFilter.needGeometry,x=kr(o,g);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom,{globalState:this.globalState}),x,s))continue;const v={id:d,sourceLayerIndex:m,index:p,geometry:g?x.geometry:an(o),properties:o.properties,type:o.type,patterns:{}};this.hasPattern?this.features.push(Ih("fill-extrusion",this.layers,v,{zoom:this.zoom,globalState:this.globalState},i)):this.addFeature(v,v.geometry,p,s,{},i.subdivisionGranularity),i.featureIndex.insert(o,v.geometry,p,m,this.index,!0)}}addFeatures(t,i,s){for(const o of this.features){const{geometry:d}=o;this.addFeature(o,d,o.index,i,s,t.subdivisionGranularity)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}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,ef),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Qp.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,i,s,o,d,p){for(const m of Bs(i,500)){const g={x:0,y:0,sampleCount:0},x=this.layoutVertexArray.length;this.processPolygon(g,o,t,m,p);const v=this.layoutVertexArray.length-x,T=Math.floor(g.x/g.sampleCount),M=Math.floor(g.y/g.sampleCount);for(let E=0;E<v;E++)this.centroidVertexArray.emplaceBack(T,M)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:d,canonical:o,globalState:this.globalState})}processPolygon(t,i,s,o,d){if(o.length<1||Vu(o[0]))return;for(const T of o)T.length!==0&&af(t,T);const p={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},m=d.fill.getGranularityForZoomLevel(i.z),g=Qa.types[s.type]==="Polygon";for(const T of o){if(T.length===0||Vu(T))continue;const M=ea(T,m,g);this._generateSideFaces(M,p)}if(!g)return;const x=Ru(o,i,m,!1),v=this.layoutVertexArray;Fu((T,M)=>{fl(v,T,M,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,x.verticesFlattened,x.indicesTriangles)}_generateSideFaces(t,i){let s=0;for(let o=1;o<t.length;o++){const d=t[o],p=t[o-1];if(of(d,p))continue;i.segment.vertexLength+4>Xe.MAX_VERTEX_ARRAY_LENGTH&&(i.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const m=d.sub(p)._perp()._unit(),g=p.dist(d);s+g>32768&&(s=0),fl(this.layoutVertexArray,d.x,d.y,m.x,m.y,0,0,s),fl(this.layoutVertexArray,d.x,d.y,m.x,m.y,0,1,s),s+=g,fl(this.layoutVertexArray,p.x,p.y,m.x,m.y,0,0,s),fl(this.layoutVertexArray,p.x,p.y,m.x,m.y,0,1,s);const x=i.segment.vertexLength;this.indexArray.emplaceBack(x,x+2,x+1),this.indexArray.emplaceBack(x+1,x+2,x+3),i.segment.vertexLength+=4,i.segment.primitiveLength+=2}}}function af(r,t){for(let i=0;i<t.length;i++){const s=t[i];i===t.length-1&&t[0].x===s.x&&t[0].y===s.y||(r.x+=s.x,r.y+=s.y,r.sampleCount++)}}function of(r,t){return r.x===t.x&&(r.x<0||r.x>gt)||r.y===t.y&&(r.y<0||r.y>gt)}function Vu(r){return r.every(t=>t.x<0)||r.every(t=>t.x>gt)||r.every(t=>t.y<0)||r.every(t=>t.y>gt)}let Uu;ze("FillExtrusionBucket",zh,{omit:["layers","features"]});var lf={get paint(){return Uu=Uu||new Pi({"fill-extrusion-opacity":new Fe(ne["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ne(ne["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Fe(ne["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Fe(ne["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ua(ne["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ne(ne["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ne(ne["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Fe(ne["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class cf extends Wi{constructor(t){super(t,lf)}createBucket(t){return new zh(t)}queryRadius(){return vc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:o,transform:d,pixelsToTileUnits:p,pixelPosMatrix:m}){const g=bc(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-d.bearingInRadians,p),x=this.paint.get("fill-extrusion-height").evaluate(i,s),v=this.paint.get("fill-extrusion-base").evaluate(i,s),T=function(E,A){const L=[];for(const F of E){const V=[F.x,F.y,0,1];Ps(V,V,A),L.push(new be(V[0]/V[3],V[1]/V[3]))}return L}(g,m),M=function(E,A,L,F){const V=[],Q=[],W=F[8]*A,X=F[9]*A,ce=F[10]*A,pe=F[11]*A,xe=F[8]*L,Ae=F[9]*L,Pe=F[10]*L,Ie=F[11]*L;for(const Be of E){const Me=[],Ce=[];for(const ge of Be){const $e=ge.x,Ge=ge.y,je=F[0]*$e+F[4]*Ge+F[12],De=F[1]*$e+F[5]*Ge+F[13],at=F[2]*$e+F[6]*Ge+F[14],Lt=F[3]*$e+F[7]*Ge+F[15],Jt=at+ce,vi=Lt+pe,hr=je+xe,Vi=De+Ae,di=at+Pe,Et=Lt+Ie,si=new be((je+W)/vi,(De+X)/vi);si.z=Jt/vi,Me.push(si);const pi=new be(hr/Et,Vi/Et);pi.z=di/Et,Ce.push(pi)}V.push(Me),Q.push(Ce)}return[V,Q]}(o,v,x,m);return function(E,A,L){let F=1/0;gu(L,A)&&(F=$u(L,A[0]));for(let V=0;V<A.length;V++){const Q=A[V],W=E[V];for(let X=0;X<Q.length-1;X++){const ce=Q[X],pe=[ce,Q[X+1],W[X+1],W[X],ce];mu(L,pe)&&(F=Math.min(F,$u(L,pe)))}}return F!==1/0&&F}(M[0],M[1],T)}}function ml(r,t){return r.x*t.x+r.y*t.y}function $u(r,t){if(r.length===1){let i=0;const s=t[i++];let o;for(;!o||s.equals(o);)if(o=t[i++],!o)return 1/0;for(;i<t.length;i++){const d=t[i],p=r[0],m=o.sub(s),g=d.sub(s),x=p.sub(s),v=ml(m,m),T=ml(m,g),M=ml(g,g),E=ml(x,m),A=ml(x,g),L=v*M-T*T,F=(M*E-T*A)/L,V=(v*A-T*E)/L,Q=s.z*(1-F-V)+o.z*F+d.z*V;if(isFinite(Q))return Q}return 1/0}{let i=1/0;for(const s of t)i=Math.min(i,s.z);return i}}const hf=Bt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:uf}=hf,df=Bt([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:pf}=df,ff=Math.cos(Math.PI/180*37.5),Zu=Math.pow(2,14)/.5;class Lh{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new oe,this.layoutVertexArray2=new he,this.indexArray=new yt,this.programConfigurations=new ji(t.layers,t.zoom),this.segments=new Xe,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.hasPattern=Mh("line",this.layers,i);const o=this.layers[0].layout.get("line-sort-key"),d=!o.isConstant(),p=[];for(const{feature:m,id:g,index:x,sourceLayerIndex:v}of t){const T=this.layers[0]._featureFilter.needGeometry,M=kr(m,T);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom,{globalState:this.globalState}),M,s))continue;const E=d?o.evaluate(M,{},s):void 0,A={id:g,properties:m.properties,type:m.type,sourceLayerIndex:v,index:x,geometry:T?M.geometry:an(m),patterns:{},sortKey:E};p.push(A)}d&&p.sort((m,g)=>m.sortKey-g.sortKey);for(const m of p){const{geometry:g,index:x,sourceLayerIndex:v}=m;if(this.hasPattern){const T=Ih("line",this.layers,m,{zoom:this.zoom,globalState:this.globalState},i);this.patternFeatures.push(T)}else this.addFeature(m,g,x,s,{},i.subdivisionGranularity);i.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}addFeatures(t,i,s){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,i,s,t.subdivisionGranularity)}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,pf)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,uf),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,i,s,o,d,p){const m=this.layers[0].layout,g=m.get("line-join").evaluate(t,{}),x=m.get("line-cap"),v=m.get("line-miter-limit"),T=m.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const M of i)this.addLine(M,t,g,x,v,T,o,p);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:d,canonical:o,globalState:this.globalState})}addLine(t,i,s,o,d,p,m,g){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=ea(t,m?g.line.getGranularityForZoomLevel(m.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let W=0;W<t.length-1;W++)this.totalDistance+=t[W].dist(t[W+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const x=Qa.types[i.type]==="Polygon";let v=t.length;for(;v>=2&&t[v-1].equals(t[v-2]);)v--;let T=0;for(;T<v-1&&t[T].equals(t[T+1]);)T++;if(v<(x?3:2))return;s==="bevel"&&(d=1.05);const M=this.overscaling<=16?122880/(512*this.overscaling):0,E=this.segments.prepareSegment(10*v,this.layoutVertexArray,this.indexArray);let A,L,F,V,Q;this.e1=this.e2=-1,x&&(A=t[v-2],Q=t[T].sub(A)._unit()._perp());for(let W=T;W<v;W++){if(F=W===v-1?x?t[T+1]:void 0:t[W+1],F&&t[W].equals(F))continue;Q&&(V=Q),A&&(L=A),A=t[W],Q=F?F.sub(A)._unit()._perp():V,V=V||Q;let X=V.add(Q);X.x===0&&X.y===0||X._unit();const ce=V.x*Q.x+V.y*Q.y,pe=X.x*Q.x+X.y*Q.y,xe=pe!==0?1/pe:1/0,Ae=2*Math.sqrt(2-2*pe),Pe=pe<ff&&L&&F,Ie=V.x*Q.y-V.y*Q.x>0;if(Pe&&W>T){const Ce=A.dist(L);if(Ce>2*M){const ge=A.sub(A.sub(L)._mult(M/Ce)._round());this.updateDistance(L,ge),this.addCurrentVertex(ge,V,0,0,E),L=ge}}const Be=L&&F;let Me=Be?s:x?"butt":o;if(Be&&Me==="round"&&(xe<p?Me="miter":xe<=2&&(Me="fakeround")),Me==="miter"&&xe>d&&(Me="bevel"),Me==="bevel"&&(xe>2&&(Me="flipbevel"),xe<d&&(Me="miter")),L&&this.updateDistance(L,A),Me==="miter")X._mult(xe),this.addCurrentVertex(A,X,0,0,E);else if(Me==="flipbevel"){if(xe>100)X=Q.mult(-1);else{const Ce=xe*V.add(Q).mag()/V.sub(Q).mag();X._perp()._mult(Ce*(Ie?-1:1))}this.addCurrentVertex(A,X,0,0,E),this.addCurrentVertex(A,X.mult(-1),0,0,E)}else if(Me==="bevel"||Me==="fakeround"){const Ce=-Math.sqrt(xe*xe-1),ge=Ie?Ce:0,$e=Ie?0:Ce;if(L&&this.addCurrentVertex(A,V,ge,$e,E),Me==="fakeround"){const Ge=Math.round(180*Ae/Math.PI/20);for(let je=1;je<Ge;je++){let De=je/Ge;if(De!==.5){const Lt=De-.5;De+=De*Lt*(De-1)*((1.0904+ce*(ce*(3.55645-1.43519*ce)-3.2452))*Lt*Lt+(.848013+ce*(.215638*ce-1.06021)))}const at=Q.sub(V)._mult(De)._add(V)._unit()._mult(Ie?-1:1);this.addHalfVertex(A,at.x,at.y,!1,Ie,0,E)}}F&&this.addCurrentVertex(A,Q,-ge,-$e,E)}else if(Me==="butt")this.addCurrentVertex(A,X,0,0,E);else if(Me==="square"){const Ce=L?1:-1;this.addCurrentVertex(A,X,Ce,Ce,E)}else Me==="round"&&(L&&(this.addCurrentVertex(A,V,0,0,E),this.addCurrentVertex(A,V,1,1,E,!0)),F&&(this.addCurrentVertex(A,Q,-1,-1,E,!0),this.addCurrentVertex(A,Q,0,0,E)));if(Pe&&W<v-1){const Ce=A.dist(F);if(Ce>2*M){const ge=A.add(F.sub(A)._mult(M/Ce)._round());this.updateDistance(A,ge),this.addCurrentVertex(ge,Q,0,0,E),A=ge}}}}addCurrentVertex(t,i,s,o,d,p=!1){const m=i.y*o-i.x,g=-i.y-i.x*o;this.addHalfVertex(t,i.x+i.y*s,i.y-i.x*s,p,!1,s,d),this.addHalfVertex(t,m,g,p,!0,-o,d),this.distance>Zu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,i,s,o,d,p))}addHalfVertex({x:t,y:i},s,o,d,p,m,g){const x=.5*(this.lineClips?this.scaledDistance*(Zu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(d?1:0),(i<<1)+(p?1:0),Math.round(63*s)+128,Math.round(63*o)+128,1+(m===0?0:m<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const v=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,v,this.e2),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,i){this.distance+=t.dist(i),this.updateScaledDistance()}}let Gu,qu;ze("LineBucket",Lh,{omit:["layers","patternFeatures"]});var Wu={get paint(){return qu=qu||new Pi({"line-opacity":new Ne(ne.paint_line["line-opacity"]),"line-color":new Ne(ne.paint_line["line-color"]),"line-translate":new Fe(ne.paint_line["line-translate"]),"line-translate-anchor":new Fe(ne.paint_line["line-translate-anchor"]),"line-width":new Ne(ne.paint_line["line-width"]),"line-gap-width":new Ne(ne.paint_line["line-gap-width"]),"line-offset":new Ne(ne.paint_line["line-offset"]),"line-blur":new Ne(ne.paint_line["line-blur"]),"line-dasharray":new en(ne.paint_line["line-dasharray"]),"line-pattern":new Ua(ne.paint_line["line-pattern"]),"line-gradient":new $a(ne.paint_line["line-gradient"])})},get layout(){return Gu=Gu||new Pi({"line-cap":new Fe(ne.layout_line["line-cap"]),"line-join":new Ne(ne.layout_line["line-join"]),"line-miter-limit":new Fe(ne.layout_line["line-miter-limit"]),"line-round-limit":new Fe(ne.layout_line["line-round-limit"]),"line-sort-key":new Ne(ne.layout_line["line-sort-key"])})}};class mf extends Ne{possiblyEvaluate(t,i){return i=new wt(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,zoomHistory:i.zoomHistory,transition:i.transition}),super.possiblyEvaluate(t,i)}evaluate(t,i,s,o){return i=Zi({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(t,i,s,o)}}let Sc;class gf extends Wi{constructor(t){super(t,Wu),this.gradientVersion=0,Sc||(Sc=new mf(Wu.paint.properties["line-width"].specification),Sc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const i=this.gradientExpression();this.stepInterpolant=!!function(s){return s._styleExpression!==void 0}(i)&&i._styleExpression.expression instanceof Ft,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,i){super.recalculate(t,i),this.paint._values["line-floorwidth"]=Sc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Lh(t)}queryRadius(t){const i=t,s=Hu(al("line-width",this,i),al("line-gap-width",this,i)),o=al("line-offset",this,i);return s/2+Math.abs(o)+vc(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:o,transform:d,pixelsToTileUnits:p}){const m=bc(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-d.bearingInRadians,p),g=p/2*Hu(this.paint.get("line-width").evaluate(i,s),this.paint.get("line-gap-width").evaluate(i,s)),x=this.paint.get("line-offset").evaluate(i,s);return x&&(o=function(v,T){const M=[];for(let E=0;E<v.length;E++){const A=v[E],L=[];for(let F=0;F<A.length;F++){const V=A[F-1],Q=A[F],W=A[F+1],X=F===0?new be(0,0):Q.sub(V)._unit()._perp(),ce=F===A.length-1?new be(0,0):W.sub(Q)._unit()._perp(),pe=X._add(ce)._unit(),xe=pe.x*ce.x+pe.y*ce.y;xe!==0&&pe._mult(1/xe),L.push(pe._mult(T)._add(Q))}M.push(L)}return M}(o,x*p)),function(v,T,M){for(let E=0;E<T.length;E++){const A=T[E];if(v.length>=3){for(let L=0;L<A.length;L++)if(Xa(v,A[L]))return!0}if(Mp(v,A,M))return!0}return!1}(m,o,g)}isTileClipped(){return!0}}function Hu(r,t){return t>0?t+2*r:r}const _f=Bt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),yf=Bt([{name:"a_projected_pos",components:3,type:"Float32"}],4);Bt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const xf=Bt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Bt([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Xu=Bt([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),vf=Bt([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function bf(r,t,i){return r.sections.forEach(s=>{s.text=function(o,d,p){const m=d.layout.get("text-transform").evaluate(p,{});return m==="uppercase"?o=o.toLocaleUpperCase():m==="lowercase"&&(o=o.toLocaleLowerCase()),sr.applyArabicShaping&&(o=sr.applyArabicShaping(o)),o}(s.text,t,i)}),r}Bt([{name:"triangle",components:3,type:"Uint16"}]),Bt([{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"}]),Bt([{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"}]),Bt([{type:"Float32",name:"offsetX"}]),Bt([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Bt([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const gl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var ni=24;const Dh=4294967296,Yu=1/Dh,Ku=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class Rh{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,i,s=this.length){for(;this.pos<s;){const o=this.readVarint(),d=o>>3,p=this.pos;this.type=7&o,t(d,i,this),this.pos===p&&this.skip(o)}return i}readMessage(t,i){return this.readFields(t,i,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Dh;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Dh;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const i=this.buf;let s,o;return o=i[this.pos++],s=127&o,o<128?s:(o=i[this.pos++],s|=(127&o)<<7,o<128?s:(o=i[this.pos++],s|=(127&o)<<14,o<128?s:(o=i[this.pos++],s|=(127&o)<<21,o<128?s:(o=i[this.pos],s|=(15&o)<<28,function(d,p,m){const g=m.buf;let x,v;if(v=g[m.pos++],x=(112&v)>>4,v<128||(v=g[m.pos++],x|=(127&v)<<3,v<128)||(v=g[m.pos++],x|=(127&v)<<10,v<128)||(v=g[m.pos++],x|=(127&v)<<17,v<128)||(v=g[m.pos++],x|=(127&v)<<24,v<128)||(v=g[m.pos++],x|=(1&v)<<31,v<128))return eo(d,x,p);throw new Error("Expected varint not more than 10 bytes")}(s,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){const t=this.readVarint()+this.pos,i=this.pos;return this.pos=t,t-i>=12&&Ku?Ku.decode(this.buf.subarray(i,t)):function(s,o,d){let p="",m=o;for(;m<d;){const g=s[m];let x,v,T,M=null,E=g>239?4:g>223?3:g>191?2:1;if(m+E>d)break;E===1?g<128&&(M=g):E===2?(x=s[m+1],(192&x)==128&&(M=(31&g)<<6|63&x,M<=127&&(M=null))):E===3?(x=s[m+1],v=s[m+2],(192&x)==128&&(192&v)==128&&(M=(15&g)<<12|(63&x)<<6|63&v,(M<=2047||M>=55296&&M<=57343)&&(M=null))):E===4&&(x=s[m+1],v=s[m+2],T=s[m+3],(192&x)==128&&(192&v)==128&&(192&T)==128&&(M=(15&g)<<18|(63&x)<<12|(63&v)<<6|63&T,(M<=65535||M>=1114112)&&(M=null))),M===null?(M=65533,E=1):M>65535&&(M-=65536,p+=String.fromCharCode(M>>>10&1023|55296),M=56320|1023&M),p+=String.fromCharCode(M),m+=E}return p}(this.buf,i,t)}readBytes(){const t=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,t);return this.pos=t,i}readPackedVarint(t=[],i){const s=this.readPackedEnd();for(;this.pos<s;)t.push(this.readVarint(i));return t}readPackedSVarint(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(t){const i=7&t;if(i===0)for(;this.buf[this.pos++]>127;);else if(i===2)this.pos=this.readVarint()+this.pos;else if(i===5)this.pos+=4;else{if(i!==1)throw new Error(`Unimplemented type: ${i}`);this.pos+=8}}writeTag(t,i){this.writeVarint(t<<3|i)}realloc(t){let i=this.length||16;for(;i<this.pos+t;)i*=2;if(i!==this.length){const s=new Uint8Array(i);s.set(this.buf),this.buf=s,this.dataView=new DataView(s.buffer),this.length=i}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Yu),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Yu),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(i,s){let o,d;if(i>=0?(o=i%4294967296|0,d=i/4294967296|0):(o=~(-i%4294967296),d=~(-i/4294967296),4294967295^o?o=o+1|0:(o=0,d=d+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(p,m,g){g.buf[g.pos++]=127&p|128,p>>>=7,g.buf[g.pos++]=127&p|128,p>>>=7,g.buf[g.pos++]=127&p|128,p>>>=7,g.buf[g.pos++]=127&p|128,g.buf[g.pos]=127&(p>>>=7)}(o,0,s),function(p,m){const g=(7&p)<<4;m.buf[m.pos++]|=g|((p>>>=3)?128:0),p&&(m.buf[m.pos++]=127&p|((p>>>=7)?128:0),p&&(m.buf[m.pos++]=127&p|((p>>>=7)?128:0),p&&(m.buf[m.pos++]=127&p|((p>>>=7)?128:0),p&&(m.buf[m.pos++]=127&p|((p>>>=7)?128:0),p&&(m.buf[m.pos++]=127&p)))))}(d,s)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const i=this.pos;this.pos=function(o,d,p){for(let m,g,x=0;x<d.length;x++){if(m=d.charCodeAt(x),m>55295&&m<57344){if(!g){m>56319||x+1===d.length?(o[p++]=239,o[p++]=191,o[p++]=189):g=m;continue}if(m<56320){o[p++]=239,o[p++]=191,o[p++]=189,g=m;continue}m=g-55296<<10|m-56320|65536,g=null}else g&&(o[p++]=239,o[p++]=191,o[p++]=189,g=null);m<128?o[p++]=m:(m<2048?o[p++]=m>>6|192:(m<65536?o[p++]=m>>12|224:(o[p++]=m>>18|240,o[p++]=m>>12&63|128),o[p++]=m>>6&63|128),o[p++]=63&m|128)}return p}(this.buf,t,this.pos);const s=this.pos-i;s>=128&&Ju(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const i=t.length;this.writeVarint(i),this.realloc(i);for(let s=0;s<i;s++)this.buf[this.pos++]=t[s]}writeRawMessage(t,i){this.pos++;const s=this.pos;t(i,this);const o=this.pos-s;o>=128&&Ju(s,o,this),this.pos=s-1,this.writeVarint(o),this.pos+=o}writeMessage(t,i,s){this.writeTag(t,2),this.writeRawMessage(i,s)}writePackedVarint(t,i){i.length&&this.writeMessage(t,wf,i)}writePackedSVarint(t,i){i.length&&this.writeMessage(t,Tf,i)}writePackedBoolean(t,i){i.length&&this.writeMessage(t,Mf,i)}writePackedFloat(t,i){i.length&&this.writeMessage(t,Pf,i)}writePackedDouble(t,i){i.length&&this.writeMessage(t,Sf,i)}writePackedFixed32(t,i){i.length&&this.writeMessage(t,If,i)}writePackedSFixed32(t,i){i.length&&this.writeMessage(t,Cf,i)}writePackedFixed64(t,i){i.length&&this.writeMessage(t,Ef,i)}writePackedSFixed64(t,i){i.length&&this.writeMessage(t,Af,i)}writeBytesField(t,i){this.writeTag(t,2),this.writeBytes(i)}writeFixed32Field(t,i){this.writeTag(t,5),this.writeFixed32(i)}writeSFixed32Field(t,i){this.writeTag(t,5),this.writeSFixed32(i)}writeFixed64Field(t,i){this.writeTag(t,1),this.writeFixed64(i)}writeSFixed64Field(t,i){this.writeTag(t,1),this.writeSFixed64(i)}writeVarintField(t,i){this.writeTag(t,0),this.writeVarint(i)}writeSVarintField(t,i){this.writeTag(t,0),this.writeSVarint(i)}writeStringField(t,i){this.writeTag(t,2),this.writeString(i)}writeFloatField(t,i){this.writeTag(t,5),this.writeFloat(i)}writeDoubleField(t,i){this.writeTag(t,1),this.writeDouble(i)}writeBooleanField(t,i){this.writeVarintField(t,+i)}}function eo(r,t,i){return i?4294967296*t+(r>>>0):4294967296*(t>>>0)+(r>>>0)}function Ju(r,t,i){const s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(s);for(let o=i.pos-1;o>=r;o--)i.buf[o+s]=i.buf[o]}function wf(r,t){for(let i=0;i<r.length;i++)t.writeVarint(r[i])}function Tf(r,t){for(let i=0;i<r.length;i++)t.writeSVarint(r[i])}function Pf(r,t){for(let i=0;i<r.length;i++)t.writeFloat(r[i])}function Sf(r,t){for(let i=0;i<r.length;i++)t.writeDouble(r[i])}function Mf(r,t){for(let i=0;i<r.length;i++)t.writeBoolean(r[i])}function If(r,t){for(let i=0;i<r.length;i++)t.writeFixed32(r[i])}function Cf(r,t){for(let i=0;i<r.length;i++)t.writeSFixed32(r[i])}function Ef(r,t){for(let i=0;i<r.length;i++)t.writeFixed64(r[i])}function Af(r,t){for(let i=0;i<r.length;i++)t.writeSFixed64(r[i])}function kf(r,t,i){r===1&&i.readMessage(zf,t)}function zf(r,t,i){if(r===3){const{id:s,bitmap:o,width:d,height:p,left:m,top:g,advance:x}=i.readMessage(Lf,{});t.push({id:s,bitmap:new ol({width:d+6,height:p+6},o),metrics:{width:d,height:p,left:m,top:g,advance:x}})}}function Lf(r,t,i){r===1?t.id=i.readVarint():r===2?t.bitmap=i.readBytes():r===3?t.width=i.readVarint():r===4?t.height=i.readVarint():r===5?t.left=i.readSVarint():r===6?t.top=i.readSVarint():r===7&&(t.advance=i.readVarint())}function Qu(r){let t=0,i=0;for(const p of r)t+=p.w*p.h,i=Math.max(i,p.w);r.sort((p,m)=>m.h-p.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let o=0,d=0;for(const p of r)for(let m=s.length-1;m>=0;m--){const g=s[m];if(!(p.w>g.w||p.h>g.h)){if(p.x=g.x,p.y=g.y,d=Math.max(d,p.y+p.h),o=Math.max(o,p.x+p.w),p.w===g.w&&p.h===g.h){const x=s.pop();x&&m<s.length&&(s[m]=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:o,h:d,fill:t/(o*d)||0}}class Fh{constructor(t,{pixelRatio:i,version:s,stretchX:o,stretchY:d,content:p,textFitWidth:m,textFitHeight:g}){this.paddedRect=t,this.pixelRatio=i,this.stretchX=o,this.stretchY=d,this.content=p,this.version=s,this.textFitWidth=m,this.textFitHeight=g}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class ed{constructor(t,i){const s={},o={};this.haveRenderCallbacks=[];const d=[];this.addImages(t,s,d),this.addImages(i,o,d);const{w:p,h:m}=Qu(d),g=new Ni({width:p||1,height:m||1});for(const x in t){const v=t[x],T=s[x].paddedRect;Ni.copy(v.data,g,{x:0,y:0},{x:T.x+1,y:T.y+1},v.data)}for(const x in i){const v=i[x],T=o[x].paddedRect,M=T.x+1,E=T.y+1,A=v.data.width,L=v.data.height;Ni.copy(v.data,g,{x:0,y:0},{x:M,y:E},v.data),Ni.copy(v.data,g,{x:0,y:L-1},{x:M,y:E-1},{width:A,height:1}),Ni.copy(v.data,g,{x:0,y:0},{x:M,y:E+L},{width:A,height:1}),Ni.copy(v.data,g,{x:A-1,y:0},{x:M-1,y:E},{width:1,height:L}),Ni.copy(v.data,g,{x:0,y:0},{x:M+A,y:E},{width:1,height:L})}this.image=g,this.iconPositions=s,this.patternPositions=o}addImages(t,i,s){for(const o in t){const d=t[o],p={x:0,y:0,w:d.data.width+2,h:d.data.height+2};s.push(p),i[o]=new Fh(p,d),d.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(t,i){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in t.updatedImages)this.patchUpdatedImage(this.iconPositions[s],t.getImage(s),i),this.patchUpdatedImage(this.patternPositions[s],t.getImage(s),i)}patchUpdatedImage(t,i,s){if(!t||!i||t.version===i.version)return;t.version=i.version;const[o,d]=t.tl;s.update(i.data,void 0,{x:o,y:d})}}var gs;ze("ImagePosition",Fh),ze("ImageAtlas",ed),C.ao=void 0,(gs=C.ao||(C.ao={}))[gs.none=0]="none",gs[gs.horizontal=1]="horizontal",gs[gs.vertical=2]="vertical",gs[gs.horizontalOnly=3]="horizontalOnly";class _l{constructor(){this.scale=1,this.fontStack="",this.imageName=null,this.verticalAlign="bottom"}static forText(t,i,s){const o=new _l;return o.scale=t||1,o.fontStack=i,o.verticalAlign=s||"bottom",o}static forImage(t,i){const s=new _l;return s.imageName=t,s.verticalAlign=i||"bottom",s}}class to{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,i){const s=new to;for(let o=0;o<t.sections.length;o++){const d=t.sections[o];d.image?s.addImageSection(d):s.addTextSection(d,i)}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 i="";for(let s=0;s<t.length;s++){const o=t.charCodeAt(s+1)||null,d=t.charCodeAt(s-1)||null;i+=o&&uc(o)&&!gl[t[s+1]]||d&&uc(d)&&!gl[t[s-1]]||!gl[t[s]]?t[s]:gl[t[s]]}return i}(this.text)}trim(){let t=0;for(let s=0;s<this.text.length&&Ic[this.text.charCodeAt(s)];s++)t++;let i=this.text.length;for(let s=this.text.length-1;s>=0&&s>=t&&Ic[this.text.charCodeAt(s)];s--)i--;this.text=this.text.substring(t,i),this.sectionIndex=this.sectionIndex.slice(t,i)}substring(t,i){const s=new to;return s.text=this.text.substring(t,i),s.sectionIndex=this.sectionIndex.slice(t,i),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,i)=>Math.max(t,this.sections[i].scale),0)}getMaxImageSize(t){let i=0,s=0;for(let o=0;o<this.length();o++){const d=this.getSection(o);if(d.imageName){const p=t[d.imageName];if(!p)continue;const m=p.displaySize;i=Math.max(i,m[0]),s=Math.max(s,m[1])}}return{maxImageWidth:i,maxImageHeight:s}}addTextSection(t,i){this.text+=t.text,this.sections.push(_l.forText(t.scale,t.fontStack||i,t.verticalAlign));const s=this.sections.length-1;for(let o=0;o<t.text.length;++o)this.sectionIndex.push(s)}addImageSection(t){const i=t.image?t.image.name:"";if(i.length===0)return void jt("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push(_l.forImage(i,t.verticalAlign)),this.sectionIndex.push(this.sections.length-1)):jt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Mc(r,t,i,s,o,d,p,m,g,x,v,T,M,E,A){const L=to.fromFeature(r,o);let F;T===C.ao.vertical&&L.verticalizePunctuation();const{processBidirectionalText:V,processStyledBidirectionalText:Q}=sr;if(V&&L.sections.length===1){F=[];const ce=V(L.toString(),Bh(L,x,d,t,s,E));for(const pe of ce){const xe=new to;xe.text=pe,xe.sections=L.sections;for(let Ae=0;Ae<pe.length;Ae++)xe.sectionIndex.push(0);F.push(xe)}}else if(Q){F=[];const ce=Q(L.text,L.sectionIndex,Bh(L,x,d,t,s,E));for(const pe of ce){const xe=new to;xe.text=pe[0],xe.sectionIndex=pe[1],xe.sections=L.sections,F.push(xe)}}else F=function(ce,pe){const xe=[],Ae=ce.text;let Pe=0;for(const Ie of pe)xe.push(ce.substring(Pe,Ie)),Pe=Ie;return Pe<Ae.length&&xe.push(ce.substring(Pe,Ae.length)),xe}(L,Bh(L,x,d,t,s,E));const W=[],X={positionedLines:W,text:L.toString(),top:v[1],bottom:v[1],left:v[0],right:v[0],writingMode:T,iconsInText:!1,verticalizable:!1};return function(ce,pe,xe,Ae,Pe,Ie,Be,Me,Ce,ge,$e,Ge){let je=0,De=0,at=0,Lt=0;const Jt=Me==="right"?1:Me==="left"?0:.5,vi=ni/Ge;let hr=0;for(const Et of Pe){Et.trim();const si=Et.getMaxScale(),pi={positionedGlyphs:[],lineOffset:0};ce.positionedLines[hr]=pi;const fi=pi.positionedGlyphs;let Di=0;if(!Et.length()){De+=Ie,++hr;continue}const ur=Bf(Ae,Et,vi);for(let Ui=0;Ui<Et.length();Ui++){const Qt=Et.getSection(Ui),oi=Et.getSectionIndex(Ui),li=Et.getCharCode(Ui),Wt=Of(Ce,$e,li);let St;if(Qt.imageName){if(ce.iconsInText=!0,Qt.scale=Qt.scale*vi,St=Nf(Qt,Wt,si,ur,Ae),!St)continue;Di=Math.max(Di,St.imageOffset)}else if(St=jf(Qt,li,Wt,ur,pe,xe),!St)continue;const{rect:zr,metrics:so,baselineOffset:Lr}=St;fi.push({glyph:li,imageName:Qt.imageName,x:je,y:De+Lr+-17,vertical:Wt,scale:Qt.scale,fontStack:Qt.fontStack,sectionIndex:oi,metrics:so,rect:zr}),Wt?(ce.verticalizable=!0,je+=(Qt.imageName?so.advance:ni)*Qt.scale+ge):je+=so.advance*Qt.scale+ge}fi.length!==0&&(at=Math.max(je-ge,at),Vf(fi,0,fi.length-1,Jt)),je=0,pi.lineOffset=Math.max(Di,(si-1)*ni);const ai=Ie*si+Di;De+=ai,Lt=Math.max(ai,Lt),++hr}const{horizontalAlign:Vi,verticalAlign:di}=Oh(Be);(function(Et,si,pi,fi,Di,ur,ai,Ui,Qt){const oi=(si-pi)*Di;let li=0;li=ur!==ai?-Ui*fi- -17:-fi*Qt*ai+.5*ai;for(const Wt of Et)for(const St of Wt.positionedGlyphs)St.x+=oi,St.y+=li})(ce.positionedLines,Jt,Vi,di,at,Lt,Ie,De,Pe.length),ce.top+=-di*De,ce.bottom=ce.top+De,ce.left+=-Vi*at,ce.right=ce.left+at}(X,t,i,s,F,p,m,g,T,x,M,A),!function(ce){for(const pe of ce)if(pe.positionedGlyphs.length!==0)return!1;return!0}(W)&&X}const Ic={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Df={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},Rf={40:!0};function td(r,t,i,s,o,d){if(t.imageName){const p=s[t.imageName];return p?p.displaySize[0]*t.scale*ni/d+o:0}{const p=i[t.fontStack],m=p&&p[r];return m?m.metrics.advance*t.scale+o:0}}function id(r,t,i,s){const o=Math.pow(r-t,2);return s?r<t?o/2:2*o:o+Math.abs(i)*i}function Ff(r,t,i){let s=0;return r===10&&(s-=1e4),i&&(s+=150),r!==40&&r!==65288||(s+=50),t!==41&&t!==65289||(s+=50),s}function rd(r,t,i,s,o,d){let p=null,m=id(t,i,o,d);for(const g of s){const x=id(t-g.x,i,o,d)+g.badness;x<=m&&(p=g,m=x)}return{index:r,x:t,priorBreak:p,badness:m}}function nd(r){return r?nd(r.priorBreak).concat(r.index):[]}function Bh(r,t,i,s,o,d){if(!r)return[];const p=[],m=function(T,M,E,A,L,F){let V=0;for(let Q=0;Q<T.length();Q++){const W=T.getSection(Q);V+=td(T.getCharCode(Q),W,A,L,M,F)}return V/Math.max(1,Math.ceil(V/E))}(r,t,i,s,o,d),g=r.text.indexOf("​")>=0;let x=0;for(let T=0;T<r.length();T++){const M=r.getSection(T),E=r.getCharCode(T);if(Ic[E]||(x+=td(E,M,s,o,t,d)),T<r.length()-1){const A=!((v=E)<11904)&&(!!st["CJK Compatibility Forms"](v)||!!st["CJK Compatibility"](v)||!!st["CJK Strokes"](v)||!!st["CJK Symbols and Punctuation"](v)||!!st["Enclosed CJK Letters and Months"](v)||!!st["Halfwidth and Fullwidth Forms"](v)||!!st["Ideographic Description Characters"](v)||!!st["Vertical Forms"](v)||Xo.test(String.fromCodePoint(v)));(Df[E]||A||M.imageName||T!==r.length()-2&&Rf[r.getCharCode(T+1)])&&p.push(rd(T+1,x,m,p,Ff(E,r.getCharCode(T+1),A&&g),!1))}}var v;return nd(rd(r.length(),x,m,p,0,!0))}function Oh(r){let t=.5,i=.5;switch(r){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(r){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function Bf(r,t,i){const s=t.getMaxScale()*ni,{maxImageWidth:o,maxImageHeight:d}=t.getMaxImageSize(r),p=Math.max(s,d*i);return{verticalLineContentWidth:Math.max(s,o*i),horizontalLineContentHeight:p}}function sd(r){switch(r){case"top":return 0;case"center":return .5;default:return 1}}function Of(r,t,i){return!(r===C.ao.horizontal||!t&&!Yo(i)||t&&(Ic[i]||(s=i,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(s)))));var s}function jf(r,t,i,s,o,d){const p=d[r.fontStack],m=function(x,v,T,M){if(x&&x.rect)return x;const E=v[T.fontStack],A=E&&E[M];return A?{rect:null,metrics:A.metrics}:null}(p&&p[t],o,r,t);if(m===null)return null;let g;if(i)g=s.verticalLineContentWidth-r.scale*ni;else{const x=sd(r.verticalAlign);g=(s.horizontalLineContentHeight-r.scale*ni)*x}return{rect:m.rect,metrics:m.metrics,baselineOffset:g}}function Nf(r,t,i,s,o){const d=o[r.imageName];if(!d)return null;const p=d.paddedRect,m=d.displaySize,g={width:m[0],height:m[1],left:1,top:-3,advance:t?m[1]:m[0]};let x;if(t)x=s.verticalLineContentWidth-m[1]*r.scale;else{const v=sd(r.verticalAlign);x=(s.horizontalLineContentHeight-m[1]*r.scale)*v}return{rect:p,metrics:g,baselineOffset:x,imageOffset:(t?m[0]:m[1])*r.scale-ni*i}}function Vf(r,t,i,s){if(s===0)return;const o=r[i],d=(r[i].x+o.metrics.advance*o.scale)*s;for(let p=t;p<=i;p++)r[p].x-=d}function Uf(r,t,i){const{horizontalAlign:s,verticalAlign:o}=Oh(i),d=t[0]-r.displaySize[0]*s,p=t[1]-r.displaySize[1]*o;return{image:r,top:p,bottom:p+r.displaySize[1],left:d,right:d+r.displaySize[0]}}function ad(r){var t,i;let s=r.left,o=r.top,d=r.right-s,p=r.bottom-o;const m=(t=r.image.textFitWidth)!==null&&t!==void 0?t:"stretchOrShrink",g=(i=r.image.textFitHeight)!==null&&i!==void 0?i:"stretchOrShrink",x=(r.image.content[2]-r.image.content[0])/(r.image.content[3]-r.image.content[1]);if(g==="proportional"){if(m==="stretchOnly"&&d/p<x||m==="proportional"){const v=Math.ceil(p*x);s*=v/d,d=v}}else if(m==="proportional"&&g==="stretchOnly"&&x!==0&&d/p>x){const v=Math.ceil(d/x);o*=v/p,p=v}return{x1:s,y1:o,x2:s+d,y2:o+p}}function od(r,t,i,s,o,d){const p=r.image;let m;if(p.content){const F=p.content,V=p.pixelRatio||1;m=[F[0]/V,F[1]/V,p.displaySize[0]-F[2]/V,p.displaySize[1]-F[3]/V]}const g=t.left*d,x=t.right*d;let v,T,M,E;i==="width"||i==="both"?(E=o[0]+g-s[3],T=o[0]+x+s[1]):(E=o[0]+(g+x-p.displaySize[0])/2,T=E+p.displaySize[0]);const A=t.top*d,L=t.bottom*d;return i==="height"||i==="both"?(v=o[1]+A-s[0],M=o[1]+L+s[2]):(v=o[1]+(A+L-p.displaySize[1])/2,M=v+p.displaySize[1]),{image:p,top:v,right:T,bottom:M,left:E,collisionPadding:m}}const Bn=128,_s=32640;function ld(r,t){const{expression:i}=t;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new wt(r+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:o}=i;let d=0;for(;d<s.length&&s[d]<=r;)d++;d=Math.max(0,d-1);let p=d;for(;p<s.length&&s[p]<r+1;)p++;p=Math.min(s.length-1,p);const m=s[d],g=s[p];return i.kind==="composite"?{kind:"composite",minZoom:m,maxZoom:g,interpolationType:o}:{kind:"camera",minZoom:m,maxZoom:g,minSize:i.evaluate(new wt(m)),maxSize:i.evaluate(new wt(g)),interpolationType:o}}}function jh(r,t,i){let s="never";const o=r.get(t);return o?s=o:r.get(i)&&(s="always"),s}const $f=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Cc(r,t,i,s,o,d,p,m,g,x,v,T,M){const E=m?Math.min(_s,Math.round(m[0])):0,A=m?Math.min(_s,Math.round(m[1])):0;r.emplaceBack(t,i,Math.round(32*s),Math.round(32*o),d,p,(E<<1)+(g?1:0),A,16*x,16*v,256*T,256*M)}function Nh(r,t,i){r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i)}function Zf(r){for(const t of r.sections)if(fc(t.text))return!0;return!1}class Vh{constructor(t){this.layoutVertexArray=new Se,this.indexArray=new yt,this.programConfigurations=t,this.segments=new Xe,this.dynamicLayoutVertexArray=new ye,this.opacityVertexArray=new Le,this.hasVisibleVertices=!1,this.placedSymbolArray=new k}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,i,s,o){this.isEmpty()||(s&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,_f.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,yf.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,$f,!0),this.opacityVertexBuffer.itemSize=1),(s||o)&&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())}}ze("SymbolBuffers",Vh);class Uh{constructor(t,i,s){this.layoutVertexArray=new t,this.layoutAttributes=i,this.indexArray=new s,this.segments=new Xe,this.collisionVertexArray=new dt}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,xf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ze("CollisionBuffers",Uh);class io{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.globalState=t.globalState,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=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ld(this.zoom,i["text-size"]),this.iconSizeData=ld(this.zoom,i["icon-size"]);const s=this.layers[0].layout,o=s.get("symbol-sort-key"),d=s.get("symbol-z-order");this.canOverlap=jh(s,"text-overlap","text-allow-overlap")!=="never"||jh(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=d!=="viewport-y"&&!o.isConstant(),this.sortFeaturesByY=(d==="viewport-y"||d==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map(p=>C.ao[p])),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.sourceID=t.sourceID}createArrays(){this.text=new Vh(new ji(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new Vh(new ji(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new N,this.lineVertexArray=new U,this.symbolInstances=new B,this.textAnchorOffsets=new $}calculateGlyphDependencies(t,i,s,o,d){for(let p=0;p<t.length;p++)if(i[t.charCodeAt(p)]=!0,(s||o)&&d){const m=gl[t.charAt(p)];m&&(i[m.charCodeAt(0)]=!0)}}populate(t,i,s){const o=this.layers[0],d=o.layout,p=d.get("text-font"),m=d.get("text-field"),g=d.get("icon-image"),x=(m.value.kind!=="constant"||m.value.value instanceof bi&&!m.value.value.isEmpty()||m.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,T=d.get("symbol-sort-key");if(this.features=[],!x&&!v)return;const M=i.iconDependencies,E=i.glyphDependencies,A=i.availableImages,L=new wt(this.zoom,{globalState:this.globalState});for(const{feature:F,id:V,index:Q,sourceLayerIndex:W}of t){const X=o._featureFilter.needGeometry,ce=kr(F,X);if(!o._featureFilter.filter(L,ce,s))continue;let pe,xe;if(X||(ce.geometry=an(F)),x){const Pe=o.getValueAndResolveTokens("text-field",ce,s,A),Ie=bi.factory(Pe),Be=this.hasRTLText=this.hasRTLText||Zf(Ie);(!Be||sr.getRTLTextPluginStatus()==="unavailable"||Be&&sr.isParsed())&&(pe=bf(Ie,o,ce))}if(v){const Pe=o.getValueAndResolveTokens("icon-image",ce,s,A);xe=Pe instanceof Bi?Pe:Bi.fromString(Pe)}if(!pe&&!xe)continue;const Ae=this.sortFeaturesByKey?T.evaluate(ce,{},s):void 0;if(this.features.push({id:V,text:pe,icon:xe,index:Q,sourceLayerIndex:W,geometry:ce.geometry,properties:F.properties,type:Qa.types[F.type],sortKey:Ae}),xe&&(M[xe.name]=!0),pe){const Pe=p.evaluate(ce,{},s).join(","),Ie=d.get("text-rotation-alignment")!=="viewport"&&d.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(C.ao.vertical)>=0;for(const Be of pe.sections)if(Be.image)M[Be.image.name]=!0;else{const Me=ja(pe.toString()),Ce=Be.fontStack||Pe,ge=E[Ce]=E[Ce]||{};this.calculateGlyphDependencies(Be.text,ge,Ie,this.allowVerticalPlacement,Me)}}}d.get("symbol-placement")==="line"&&(this.features=function(F){const V={},Q={},W=[];let X=0;function ce(Pe){W.push(F[Pe]),X++}function pe(Pe,Ie,Be){const Me=Q[Pe];return delete Q[Pe],Q[Ie]=Me,W[Me].geometry[0].pop(),W[Me].geometry[0]=W[Me].geometry[0].concat(Be[0]),Me}function xe(Pe,Ie,Be){const Me=V[Ie];return delete V[Ie],V[Pe]=Me,W[Me].geometry[0].shift(),W[Me].geometry[0]=Be[0].concat(W[Me].geometry[0]),Me}function Ae(Pe,Ie,Be){const Me=Be?Ie[0][Ie[0].length-1]:Ie[0][0];return`${Pe}:${Me.x}:${Me.y}`}for(let Pe=0;Pe<F.length;Pe++){const Ie=F[Pe],Be=Ie.geometry,Me=Ie.text?Ie.text.toString():null;if(!Me){ce(Pe);continue}const Ce=Ae(Me,Be),ge=Ae(Me,Be,!0);if(Ce in Q&&ge in V&&Q[Ce]!==V[ge]){const $e=xe(Ce,ge,Be),Ge=pe(Ce,ge,W[$e].geometry);delete V[Ce],delete Q[ge],Q[Ae(Me,W[Ge].geometry,!0)]=Ge,W[$e].geometry=null}else Ce in Q?pe(Ce,ge,Be):ge in V?xe(Ce,ge,Be):(ce(Pe),V[Ce]=X-1,Q[ge]=X-1)}return W.filter(Pe=>Pe.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((F,V)=>F.sortKey-V.sortKey)}update(t,i,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,i,this.layers,{imagePositions:s,globalState:this.globalState}),this.icon.programConfigurations.updatePaintArrays(t,i,this.layers,{imagePositions:s,globalState:this.globalState}))}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,i){const s=this.lineVertexArray.length;if(t.segment!==void 0){let o=t.dist(i[t.segment+1]),d=t.dist(i[t.segment]);const p={};for(let m=t.segment+1;m<i.length;m++)p[m]={x:i[m].x,y:i[m].y,tileUnitDistanceFromAnchor:o},m<i.length-1&&(o+=i[m+1].dist(i[m]));for(let m=t.segment||0;m>=0;m--)p[m]={x:i[m].x,y:i[m].y,tileUnitDistanceFromAnchor:d},m>0&&(d+=i[m-1].dist(i[m]));for(let m=0;m<i.length;m++){const g=p[m];this.lineVertexArray.emplaceBack(g.x,g.y,g.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(t,i,s,o,d,p,m,g,x,v,T,M){const E=t.indexArray,A=t.layoutVertexArray,L=t.segments.prepareSegment(4*i.length,A,E,this.canOverlap?p.sortKey:void 0),F=this.glyphOffsetArray.length,V=L.vertexLength,Q=this.allowVerticalPlacement&&m===C.ao.vertical?Math.PI/2:0,W=p.text&&p.text.sections;for(let X=0;X<i.length;X++){const{tl:ce,tr:pe,bl:xe,br:Ae,tex:Pe,pixelOffsetTL:Ie,pixelOffsetBR:Be,minFontScaleX:Me,minFontScaleY:Ce,glyphOffset:ge,isSDF:$e,sectionIndex:Ge}=i[X],je=L.vertexLength,De=ge[1];Cc(A,g.x,g.y,ce.x,De+ce.y,Pe.x,Pe.y,s,$e,Ie.x,Ie.y,Me,Ce),Cc(A,g.x,g.y,pe.x,De+pe.y,Pe.x+Pe.w,Pe.y,s,$e,Be.x,Ie.y,Me,Ce),Cc(A,g.x,g.y,xe.x,De+xe.y,Pe.x,Pe.y+Pe.h,s,$e,Ie.x,Be.y,Me,Ce),Cc(A,g.x,g.y,Ae.x,De+Ae.y,Pe.x+Pe.w,Pe.y+Pe.h,s,$e,Be.x,Be.y,Me,Ce),Nh(t.dynamicLayoutVertexArray,g,Q),E.emplaceBack(je,je+2,je+1),E.emplaceBack(je+1,je+2,je+3),L.vertexLength+=4,L.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(ge[0]),X!==i.length-1&&Ge===i[X+1].sectionIndex||t.programConfigurations.populatePaintArrays(A.length,p,p.index,{imagePositions:{},canonical:M,formattedSection:W&&W[Ge],globalState:this.globalState})}t.placedSymbolArray.emplaceBack(g.x,g.y,F,this.glyphOffsetArray.length-F,V,x,v,g.segment,s?s[0]:0,s?s[1]:0,o[0],o[1],m,0,!1,0,T)}_addCollisionDebugVertex(t,i,s,o,d,p){return i.emplaceBack(0,0),t.emplaceBack(s.x,s.y,o,d,Math.round(p.x),Math.round(p.y))}addCollisionDebugVertices(t,i,s,o,d,p,m){const g=d.segments.prepareSegment(4,d.layoutVertexArray,d.indexArray),x=g.vertexLength,v=d.layoutVertexArray,T=d.collisionVertexArray,M=m.anchorX,E=m.anchorY;this._addCollisionDebugVertex(v,T,p,M,E,new be(t,i)),this._addCollisionDebugVertex(v,T,p,M,E,new be(s,i)),this._addCollisionDebugVertex(v,T,p,M,E,new be(s,o)),this._addCollisionDebugVertex(v,T,p,M,E,new be(t,o)),g.vertexLength+=4;const A=d.indexArray;A.emplaceBack(x,x+1),A.emplaceBack(x+1,x+2),A.emplaceBack(x+2,x+3),A.emplaceBack(x+3,x),g.primitiveLength+=4}addDebugCollisionBoxes(t,i,s,o){for(let d=t;d<i;d++){const p=this.collisionBoxArray.get(d);this.addCollisionDebugVertices(p.x1,p.y1,p.x2,p.y2,o?this.textCollisionBox:this.iconCollisionBox,p.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Uh(Ke,Xu.members,mt),this.iconCollisionBox=new Uh(Ke,Xu.members,mt);for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.addDebugCollisionBoxes(i.textBoxStartIndex,i.textBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.iconBoxStartIndex,i.iconBoxEndIndex,i,!1),this.addDebugCollisionBoxes(i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex,i,!1)}}_deserializeCollisionBoxesForSymbol(t,i,s,o,d,p,m,g,x){const v={};for(let T=i;T<s;T++){const M=t.get(T);v.textBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},v.textFeatureIndex=M.featureIndex;break}for(let T=o;T<d;T++){const M=t.get(T);v.verticalTextBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},v.verticalTextFeatureIndex=M.featureIndex;break}for(let T=p;T<m;T++){const M=t.get(T);v.iconBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},v.iconFeatureIndex=M.featureIndex;break}for(let T=g;T<x;T++){const M=t.get(T);v.verticalIconBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},v.verticalIconFeatureIndex=M.featureIndex;break}return v}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const s=this.symbolInstances.get(i);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,i){const s=t.placedSymbolArray.get(i),o=s.vertexStartIndex+4*s.numGlyphs;for(let d=s.vertexStartIndex;d<o;d+=4)t.indexArray.emplaceBack(d,d+2,d+1),t.indexArray.emplaceBack(d+1,d+2,d+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(t),s=Math.cos(t),o=[],d=[],p=[];for(let m=0;m<this.symbolInstances.length;++m){p.push(m);const g=this.symbolInstances.get(m);o.push(0|Math.round(i*g.anchorX+s*g.anchorY)),d.push(g.featureIndex)}return p.sort((m,g)=>o[m]-o[g]||d[g]-d[m]),p}addToSortKeyRanges(t,i){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===i?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const s=this.symbolInstances.get(i);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((o,d,p)=>{o>=0&&p.indexOf(o)===d&&this.addIndicesForPlacedSymbol(this.text,o)}),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 cd,hd;ze("SymbolBucket",io,{omit:["layers","collisionBoxArray","features","compareText"]}),io.MAX_GLYPHS=65535,io.addDynamicAttributes=Nh;var $h={get paint(){return hd=hd||new Pi({"icon-opacity":new Ne(ne.paint_symbol["icon-opacity"]),"icon-color":new Ne(ne.paint_symbol["icon-color"]),"icon-halo-color":new Ne(ne.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ne(ne.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ne(ne.paint_symbol["icon-halo-blur"]),"icon-translate":new Fe(ne.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fe(ne.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ne(ne.paint_symbol["text-opacity"]),"text-color":new Ne(ne.paint_symbol["text-color"],{runtimeType:hi,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new Ne(ne.paint_symbol["text-halo-color"]),"text-halo-width":new Ne(ne.paint_symbol["text-halo-width"]),"text-halo-blur":new Ne(ne.paint_symbol["text-halo-blur"]),"text-translate":new Fe(ne.paint_symbol["text-translate"]),"text-translate-anchor":new Fe(ne.paint_symbol["text-translate-anchor"])})},get layout(){return cd=cd||new Pi({"symbol-placement":new Fe(ne.layout_symbol["symbol-placement"]),"symbol-spacing":new Fe(ne.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fe(ne.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ne(ne.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fe(ne.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Fe(ne.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Fe(ne.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Fe(ne.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fe(ne.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fe(ne.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ne(ne.layout_symbol["icon-size"]),"icon-text-fit":new Fe(ne.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Fe(ne.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ne(ne.layout_symbol["icon-image"]),"icon-rotate":new Ne(ne.layout_symbol["icon-rotate"]),"icon-padding":new Ne(ne.layout_symbol["icon-padding"]),"icon-keep-upright":new Fe(ne.layout_symbol["icon-keep-upright"]),"icon-offset":new Ne(ne.layout_symbol["icon-offset"]),"icon-anchor":new Ne(ne.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fe(ne.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fe(ne.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fe(ne.layout_symbol["text-rotation-alignment"]),"text-field":new Ne(ne.layout_symbol["text-field"]),"text-font":new Ne(ne.layout_symbol["text-font"]),"text-size":new Ne(ne.layout_symbol["text-size"]),"text-max-width":new Ne(ne.layout_symbol["text-max-width"]),"text-line-height":new Fe(ne.layout_symbol["text-line-height"]),"text-letter-spacing":new Ne(ne.layout_symbol["text-letter-spacing"]),"text-justify":new Ne(ne.layout_symbol["text-justify"]),"text-radial-offset":new Ne(ne.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fe(ne.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ne(ne.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ne(ne.layout_symbol["text-anchor"]),"text-max-angle":new Fe(ne.layout_symbol["text-max-angle"]),"text-writing-mode":new Fe(ne.layout_symbol["text-writing-mode"]),"text-rotate":new Ne(ne.layout_symbol["text-rotate"]),"text-padding":new Fe(ne.layout_symbol["text-padding"]),"text-keep-upright":new Fe(ne.layout_symbol["text-keep-upright"]),"text-transform":new Ne(ne.layout_symbol["text-transform"]),"text-offset":new Ne(ne.layout_symbol["text-offset"]),"text-allow-overlap":new Fe(ne.layout_symbol["text-allow-overlap"]),"text-overlap":new Fe(ne.layout_symbol["text-overlap"]),"text-ignore-placement":new Fe(ne.layout_symbol["text-ignore-placement"]),"text-optional":new Fe(ne.layout_symbol["text-optional"])})}};class ud{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:Gn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(t.formattedSection))return i.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ze("FormatSectionOverride",ud,{omit:["defaultValue"]});class Ec extends Wi{constructor(t){super(t,$h)}recalculate(t,i){if(super.recalculate(t,i),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const o=[];for(const d of s)o.indexOf(d)<0&&o.push(d);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,i,s,o){const d=this.layout.get(t).evaluate(i,{},s,o),p=this._unevaluatedLayout._values[t];return p.isDataDriven()||ka(p.value)||!d?d:function(m,g){return g.replace(/{([^{}]+)}/g,(x,v)=>m&&v in m?String(m[v]):"")}(i.properties,d)}createBucket(t){return new io(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of $h.paint.overridableProperties){if(!Ec.hasPaintOverride(this.layout,t))continue;const i=this.paint.get(t),s=new ud(i),o=new Bo(s,i.property.specification);let d=null;d=i.value.kind==="constant"||i.value.kind==="source"?new Us("source",o):new Oo("composite",o,i.value.zoomStops),this.paint._values[t]=new Pr(i.property,d,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,s){return!(!this.layout||i.isDataDriven()||s.isDataDriven())&&Ec.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,i){const s=t.get("text-field"),o=$h.paint.properties[i];let d=!1;const p=m=>{for(const g of m)if(o.overrides&&o.overrides.hasOverride(g))return void(d=!0)};if(s.value.kind==="constant"&&s.value.value instanceof bi)p(s.value.value.sections);else if(s.value.kind==="source"||s.value.kind==="composite"){const m=x=>{d||(x instanceof Ir&&Ue(x.value)===Hr?p(x.value.sections):x instanceof Tn?p(x.sections):x.eachChild(m))},g=s.value;g._styleExpression&&m(g._styleExpression.expression)}return d}}let dd;var Gf={get paint(){return dd=dd||new Pi({"background-color":new Fe(ne.paint_background["background-color"]),"background-pattern":new en(ne.paint_background["background-pattern"]),"background-opacity":new Fe(ne.paint_background["background-opacity"])})}};class qf extends Wi{constructor(t){super(t,Gf)}}let pd;var Wf={get paint(){return pd=pd||new Pi({"raster-opacity":new Fe(ne.paint_raster["raster-opacity"]),"raster-hue-rotate":new Fe(ne.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Fe(ne.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Fe(ne.paint_raster["raster-brightness-max"]),"raster-saturation":new Fe(ne.paint_raster["raster-saturation"]),"raster-contrast":new Fe(ne.paint_raster["raster-contrast"]),"raster-resampling":new Fe(ne.paint_raster["raster-resampling"]),"raster-fade-duration":new Fe(ne.paint_raster["raster-fade-duration"])})}};class Hf extends Wi{constructor(t){super(t,Wf)}}class Xf extends Wi{constructor(t){super(t,{}),this.onAdd=i=>{this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)},this.onRemove=i=>{this.implementation.onRemove&&this.implementation.onRemove(i,i.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 Yf{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Kf={once:!0},Zh=63710088e-1;class ys{constructor(t,i){if(isNaN(t)||isNaN(i))throw new Error(`Invalid LngLat object: (${t}, ${i})`);if(this.lng=+t,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ys(Nn(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const i=Math.PI/180,s=this.lat*i,o=t.lat*i,d=Math.sin(s)*Math.sin(o)+Math.cos(s)*Math.cos(o)*Math.cos((t.lng-this.lng)*i);return Zh*Math.acos(Math.min(d,1))}static convert(t){if(t instanceof ys)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new ys(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new ys(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>]")}}const fd=2*Math.PI*Zh;function md(r){return fd*Math.cos(r*Math.PI/180)}function gd(r){return(180+r)/360}function _d(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function yd(r,t){return r/md(t)}function Gh(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}function xd(r,t){return r*md(Gh(t))}class yl{constructor(t,i,s=0){this.x=+t,this.y=+i,this.z=+s}static fromLngLat(t,i=0){const s=ys.convert(t);return new yl(gd(s.lng),_d(s.lat),yd(i,s.lat))}toLngLat(){return new ys(360*this.x-180,Gh(this.y))}toAltitude(){return xd(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/fd*(t=Gh(this.y),1/Math.cos(t*Math.PI/180));var t}}function vd(r,t,i){var s=2*Math.PI*6378137/256/Math.pow(2,i);return[r*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class qh{constructor(t,i,s){if(!function(o,d,p){return!(o<0||o>25||p<0||p>=Math.pow(2,o)||d<0||d>=Math.pow(2,o))}(t,i,s))throw new Error(`x=${i}, 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=i,this.y=s,this.key=ro(0,t,t,i,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,i,s){const o=(p=this.y,m=this.z,g=vd(256*(d=this.x),256*(p=Math.pow(2,m)-p-1),m),x=vd(256*(d+1),256*(p+1),m),g[0]+","+g[1]+","+x[0]+","+x[1]);var d,p,m,g,x;const v=function(T,M,E){let A,L="";for(let F=T;F>0;F--)A=1<<F-1,L+=(M&A?1:0)+(E&A?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,i>1?"@2x":"").replace(/{quadkey}/g,v).replace(/{bbox-epsg-3857}/g,o)}isChildOf(t){const i=this.z-t.z;return i>0&&t.x===this.x>>i&&t.y===this.y>>i}getTilePoint(t){const i=Math.pow(2,this.z);return new be((t.x*i-this.x)*gt,(t.y*i-this.y)*gt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class bd{constructor(t,i){this.wrap=t,this.canonical=i,this.key=ro(t,i.z,i.z,i.x,i.y)}}class cr{constructor(t,i,s,o,d){if(this.terrainRttPosMatrix32f=null,t<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=i,this.canonical=new qh(s,+o,+d),this.key=ro(i,t,s,o,d)}clone(){return new cr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?new cr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new cr(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(t,i){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-t;return t>this.canonical.z?ro(this.wrap*+i,t,this.canonical.z,this.canonical.x,this.canonical.y):ro(this.wrap*+i,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const i=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>i&&t.canonical.y===this.canonical.y>>i}children(t){if(this.overscaledZ>=t)return[new cr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,s=2*this.canonical.x,o=2*this.canonical.y;return[new cr(i,this.wrap,i,s,o),new cr(i,this.wrap,i,s+1,o),new cr(i,this.wrap,i,s,o+1),new cr(i,this.wrap,i,s+1,o+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 cr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new cr(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 bd(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new yl(t.x-this.wrap,t.y))}}function ro(r,t,i,s,o){(r*=2)<0&&(r=-1*r-1);const d=1<<i;return(d*d*r+d*o+s).toString(36)+i.toString(36)+t.toString(36)}function xl(r,t){return t?r.properties[t]:r.id}ze("CanonicalTileID",qh),ze("OverscaledTileID",cr,{omit:["terrainRttPosMatrix32f"]});class ta{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(t){return this.expandBy(-t)}map(t){const i=new ta;return i.extend(t(new be(this.minX,this.minY))),i.extend(t(new be(this.maxX,this.minY))),i.extend(t(new be(this.minX,this.maxY))),i.extend(t(new be(this.maxX,this.maxY))),i}static fromPoints(t){const i=new ta;for(const s of t)i.extend(s);return i}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}}class wd{constructor(t){this._stringToNumber={},this._numberToString=[];for(let i=0;i<t.length;i++){const s=t[i];this._stringToNumber[s]=i,this._numberToString[i]=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,i,s,o,d){this.type="Feature",this._vectorTileFeature=t,t._z=i,t._x=s,t._y=o,this.properties=t.properties,this.id=d}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const i in this)i!=="_geometry"&&i!=="_vectorTileFeature"&&(t[i]=this[i]);return t}}class Pd{constructor(t,i){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Xs(gt,16,0),this.grid3D=new Xs(gt,16,0),this.featureIndexArray=new K,this.promoteId=i}insert(t,i,s,o,d,p){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,o,d);const g=p?this.grid3D:this.grid;for(let x=0;x<i.length;x++){const v=i[x],T=[1/0,1/0,-1/0,-1/0];for(let M=0;M<v.length;M++){const E=v[M];T[0]=Math.min(T[0],E.x),T[1]=Math.min(T[1],E.y),T[2]=Math.max(T[2],E.x),T[3]=Math.max(T[3],E.y)}T[0]<gt&&T[1]<gt&&T[2]>=0&&T[3]>=0&&g.insert(m,T[0],T[1],T[2],T[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Nu(new Rh(this.rawTileData)).layers,this.sourceLayerCoder=new wd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,i,s,o){this.loadVTLayers();const d=t.params,p=gt/t.tileSize/t.scale,m=En(d.filter),g=t.queryGeometry,x=t.queryPadding*p,v=ta.fromPoints(g),T=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),M=ta.fromPoints(t.cameraQueryGeometry).expandBy(x),E=this.grid3D.query(M.minX,M.minY,M.maxX,M.maxY,(F,V,Q,W)=>function(X,ce,pe,xe,Ae){for(const Ie of X)if(ce<=Ie.x&&pe<=Ie.y&&xe>=Ie.x&&Ae>=Ie.y)return!0;const Pe=[new be(ce,pe),new be(ce,Ae),new be(xe,Ae),new be(xe,pe)];if(X.length>2){for(const Ie of Pe)if(Xa(X,Ie))return!0}for(let Ie=0;Ie<X.length-1;Ie++)if(Cp(X[Ie],X[Ie+1],Pe))return!0;return!1}(t.cameraQueryGeometry,F-x,V-x,Q+x,W+x));for(const F of E)T.push(F);T.sort(Jf);const A={};let L;for(let F=0;F<T.length;F++){const V=T[F];if(V===L)continue;L=V;const Q=this.featureIndexArray.get(V);let W=null;this.loadMatchingFeature(A,Q.bucketIndex,Q.sourceLayerIndex,Q.featureIndex,m,d.layers,d.availableImages,i,s,o,(X,ce,pe)=>(W||(W=an(X)),ce.queryIntersectsFeature({queryGeometry:g,feature:X,featureState:pe,geometry:W,zoom:this.z,transform:t.transform,pixelsToTileUnits:p,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation})))}return A}loadMatchingFeature(t,i,s,o,d,p,m,g,x,v,T){const M=this.bucketLayerIDs[i];if(p&&!M.some(F=>p.has(F)))return;const E=this.sourceLayerCoder.decode(s),A=this.vtLayers[E].feature(o);if(d.needGeometry){const F=kr(A,!0);if(!d.filter(new wt(this.tileID.overscaledZ),F,this.tileID.canonical))return}else if(!d.filter(new wt(this.tileID.overscaledZ),A))return;const L=this.getId(A,E);for(let F=0;F<M.length;F++){const V=M[F];if(p&&!p.has(V))continue;const Q=g[V];if(!Q)continue;let W={};L&&v&&(W=v.getState(Q.sourceLayer||"_geojsonTileLayer",L));const X=Zi({},x[V]);X.paint=Sd(X.paint,Q.paint,A,W,m),X.layout=Sd(X.layout,Q.layout,A,W,m);const ce=!T||T(A,Q,W);if(!ce)continue;const pe=new Td(A,this.z,this.x,this.y,L);pe.layer=X;let xe=t[V];xe===void 0&&(xe=t[V]=[]),xe.push({featureIndex:o,feature:pe,intersectionZ:ce})}}lookupSymbolFeatures(t,i,s,o,d,p,m,g){const x={};this.loadVTLayers();const v=En(d);for(const T of t)this.loadMatchingFeature(x,s,o,T,v,p,m,g,i);return x}hasLayer(t){for(const i of this.bucketLayerIDs)for(const s of i)if(t===s)return!0;return!1}getId(t,i){var s;let o=t.id;return this.promoteId&&(o=t.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[i]],typeof o=="boolean"&&(o=Number(o)),o===void 0&&(!((s=t.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(o=Number(t.properties.cluster_id))),o}}function Sd(r,t,i,s,o){return Vn(r,(d,p)=>{const m=t instanceof Va?t.get(p):null;return m&&m.evaluate?m.evaluate(i,s,o):m})}function Jf(r,t){return t-r}function Md(r,t,i,s,o){const d=[];for(let p=0;p<r.length;p++){const m=r[p];let g;for(let x=0;x<m.length-1;x++){let v=m[x],T=m[x+1];v.x<t&&T.x<t||(v.x<t?v=new be(t,v.y+(t-v.x)/(T.x-v.x)*(T.y-v.y))._round():T.x<t&&(T=new be(t,v.y+(t-v.x)/(T.x-v.x)*(T.y-v.y))._round()),v.y<i&&T.y<i||(v.y<i?v=new be(v.x+(i-v.y)/(T.y-v.y)*(T.x-v.x),i)._round():T.y<i&&(T=new be(v.x+(i-v.y)/(T.y-v.y)*(T.x-v.x),i)._round()),v.x>=s&&T.x>=s||(v.x>=s?v=new be(s,v.y+(s-v.x)/(T.x-v.x)*(T.y-v.y))._round():T.x>=s&&(T=new be(s,v.y+(s-v.x)/(T.x-v.x)*(T.y-v.y))._round()),v.y>=o&&T.y>=o||(v.y>=o?v=new be(v.x+(o-v.y)/(T.y-v.y)*(T.x-v.x),o)._round():T.y>=o&&(T=new be(v.x+(o-v.y)/(T.y-v.y)*(T.x-v.x),o)._round()),g&&v.equals(g[g.length-1])||(g=[v],d.push(g)),g.push(T)))))}}return d}ze("FeatureIndex",Pd,{omit:["rawTileData","sourceLayerCoder"]});class xs extends be{constructor(t,i,s,o){super(t,i),this.angle=s,o!==void 0&&(this.segment=o)}clone(){return new xs(this.x,this.y,this.angle,this.segment)}}function Id(r,t,i,s,o){if(t.segment===void 0||i===0)return!0;let d=t,p=t.segment+1,m=0;for(;m>-i/2;){if(p--,p<0)return!1;m-=r[p].dist(d),d=r[p]}m+=r[p].dist(r[p+1]),p++;const g=[];let x=0;for(;m<i/2;){const v=r[p],T=r[p+1];if(!T)return!1;let M=r[p-1].angleTo(v)-v.angleTo(T);for(M=Math.abs((M+3*Math.PI)%(2*Math.PI)-Math.PI),g.push({distance:m,angleDelta:M}),x+=M;m-g[0].distance>s;)x-=g.shift().angleDelta;if(x>o)return!1;p++,m+=v.dist(T)}return!0}function Cd(r){let t=0;for(let i=0;i<r.length-1;i++)t+=r[i].dist(r[i+1]);return t}function Ed(r,t,i){return r?.6*t*i:0}function Ad(r,t){return Math.max(r?r.right-r.left:0,t?t.right-t.left:0)}function Qf(r,t,i,s,o,d){const p=Ed(i,o,d),m=Ad(i,s)*d;let g=0;const x=Cd(r)/2;for(let v=0;v<r.length-1;v++){const T=r[v],M=r[v+1],E=T.dist(M);if(g+E>x){const A=(x-g)/E,L=wr.number(T.x,M.x,A),F=wr.number(T.y,M.y,A),V=new xs(L,F,M.angleTo(T),v);return V._round(),!p||Id(r,V,m,p,t)?V:void 0}g+=E}}function em(r,t,i,s,o,d,p,m,g){const x=Ed(s,d,p),v=Ad(s,o),T=v*p,M=r[0].x===0||r[0].x===g||r[0].y===0||r[0].y===g;return t-T<t/4&&(t=T+t/4),kd(r,M?t/2*m%t:(v/2+2*d)*p*m%t,t,x,i,T,M,!1,g)}function kd(r,t,i,s,o,d,p,m,g){const x=d/2,v=Cd(r);let T=0,M=t-i,E=[];for(let A=0;A<r.length-1;A++){const L=r[A],F=r[A+1],V=L.dist(F),Q=F.angleTo(L);for(;M+i<T+V;){M+=i;const W=(M-T)/V,X=wr.number(L.x,F.x,W),ce=wr.number(L.y,F.y,W);if(X>=0&&X<g&&ce>=0&&ce<g&&M-x>=0&&M+x<=v){const pe=new xs(X,ce,Q,A);pe._round(),s&&!Id(r,pe,d,s,o)||E.push(pe)}}T+=V}return m||E.length||p||(E=kd(r,T/2,i,s,o,d,p,!0,g)),E}function zd(r,t,i,s){const o=[],d=r.image,p=d.pixelRatio,m=d.paddedRect.w-2,g=d.paddedRect.h-2;let x={x1:r.left,y1:r.top,x2:r.right,y2:r.bottom};const v=d.stretchX||[[0,m]],T=d.stretchY||[[0,g]],M=(ge,$e)=>ge+$e[1]-$e[0],E=v.reduce(M,0),A=T.reduce(M,0),L=m-E,F=g-A;let V=0,Q=E,W=0,X=A,ce=0,pe=L,xe=0,Ae=F;if(d.content&&s){const ge=d.content,$e=ge[2]-ge[0],Ge=ge[3]-ge[1];(d.textFitWidth||d.textFitHeight)&&(x=ad(r)),V=Ac(v,0,ge[0]),W=Ac(T,0,ge[1]),Q=Ac(v,ge[0],ge[2]),X=Ac(T,ge[1],ge[3]),ce=ge[0]-V,xe=ge[1]-W,pe=$e-Q,Ae=Ge-X}const Pe=x.x1,Ie=x.y1,Be=x.x2-Pe,Me=x.y2-Ie,Ce=(ge,$e,Ge,je)=>{const De=kc(ge.stretch-V,Q,Be,Pe),at=zc(ge.fixed-ce,pe,ge.stretch,E),Lt=kc($e.stretch-W,X,Me,Ie),Jt=zc($e.fixed-xe,Ae,$e.stretch,A),vi=kc(Ge.stretch-V,Q,Be,Pe),hr=zc(Ge.fixed-ce,pe,Ge.stretch,E),Vi=kc(je.stretch-W,X,Me,Ie),di=zc(je.fixed-xe,Ae,je.stretch,A),Et=new be(De,Lt),si=new be(vi,Lt),pi=new be(vi,Vi),fi=new be(De,Vi),Di=new be(at/p,Jt/p),ur=new be(hr/p,di/p),ai=t*Math.PI/180;if(ai){const oi=Math.sin(ai),li=Math.cos(ai),Wt=[li,-oi,oi,li];Et._matMult(Wt),si._matMult(Wt),fi._matMult(Wt),pi._matMult(Wt)}const Ui=ge.stretch+ge.fixed,Qt=$e.stretch+$e.fixed;return{tl:Et,tr:si,bl:fi,br:pi,tex:{x:d.paddedRect.x+1+Ui,y:d.paddedRect.y+1+Qt,w:Ge.stretch+Ge.fixed-Ui,h:je.stretch+je.fixed-Qt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Di,pixelOffsetBR:ur,minFontScaleX:pe/p/Be,minFontScaleY:Ae/p/Me,isSDF:i}};if(s&&(d.stretchX||d.stretchY)){const ge=Ld(v,L,E),$e=Ld(T,F,A);for(let Ge=0;Ge<ge.length-1;Ge++){const je=ge[Ge],De=ge[Ge+1];for(let at=0;at<$e.length-1;at++)o.push(Ce(je,$e[at],De,$e[at+1]))}}else o.push(Ce({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:m+1},{fixed:0,stretch:g+1}));return o}function Ac(r,t,i){let s=0;for(const o of r)s+=Math.max(t,Math.min(i,o[1]))-Math.max(t,Math.min(i,o[0]));return s}function Ld(r,t,i){const s=[{fixed:-1,stretch:0}];for(const[o,d]of r){const p=s[s.length-1];s.push({fixed:o-p.stretch,stretch:p.stretch}),s.push({fixed:o-p.stretch,stretch:p.stretch+(d-o)})}return s.push({fixed:t+1,stretch:i}),s}function kc(r,t,i,s){return r/t*i+s}function zc(r,t,i,s){return r-t*i/s}ze("Anchor",xs);class Lc{constructor(t,i,s,o,d,p,m,g,x,v){var T;if(this.boxStartIndex=t.length,x){let M=p.top,E=p.bottom;const A=p.collisionPadding;A&&(M-=A[1],E+=A[3]);let L=E-M;L>0&&(L=Math.max(10,L),this.circleDiameter=L)}else{const M=!((T=p.image)===null||T===void 0)&&T.content&&(p.image.textFitWidth||p.image.textFitHeight)?ad(p):{x1:p.left,y1:p.top,x2:p.right,y2:p.bottom};M.y1=M.y1*m-g[0],M.y2=M.y2*m+g[2],M.x1=M.x1*m-g[3],M.x2=M.x2*m+g[1];const E=p.collisionPadding;if(E&&(M.x1-=E[0]*m,M.y1-=E[1]*m,M.x2+=E[2]*m,M.y2+=E[3]*m),v){const A=new be(M.x1,M.y1),L=new be(M.x2,M.y1),F=new be(M.x1,M.y2),V=new be(M.x2,M.y2),Q=v*Math.PI/180;A._rotate(Q),L._rotate(Q),F._rotate(Q),V._rotate(Q),M.x1=Math.min(A.x,L.x,F.x,V.x),M.x2=Math.max(A.x,L.x,F.x,V.x),M.y1=Math.min(A.y,L.y,F.y,V.y),M.y2=Math.max(A.y,L.y,F.y,V.y)}t.emplaceBack(i.x,i.y,M.x1,M.y1,M.x2,M.y2,s,o,d)}this.boxEndIndex=t.length}}class tm{constructor(t=[],i=(s,o)=>s<o?-1:s>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=i,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:i,compare:s}=this,o=i[t];for(;t>0;){const d=t-1>>1,p=i[d];if(s(o,p)>=0)break;i[t]=p,t=d}i[t]=o}_down(t){const{data:i,compare:s}=this,o=this.length>>1,d=i[t];for(;t<o;){let p=1+(t<<1);const m=p+1;if(m<this.length&&s(i[m],i[p])<0&&(p=m),s(i[p],d)>=0)break;i[t]=i[p],t=p}i[t]=d}}function im(r,t=1,i=!1){const s=ta.fromPoints(r[0]),o=Math.min(s.width(),s.height());let d=o/2;const p=new tm([],rm),{minX:m,minY:g,maxX:x,maxY:v}=s;if(o===0)return new be(m,g);for(let E=m;E<x;E+=o)for(let A=g;A<v;A+=o)p.push(new no(E+d,A+d,d,r));let T=function(E){let A=0,L=0,F=0;const V=E[0];for(let Q=0,W=V.length,X=W-1;Q<W;X=Q++){const ce=V[Q],pe=V[X],xe=ce.x*pe.y-pe.x*ce.y;L+=(ce.x+pe.x)*xe,F+=(ce.y+pe.y)*xe,A+=3*xe}return new no(L/A,F/A,0,E)}(r),M=p.length;for(;p.length;){const E=p.pop();(E.d>T.d||!T.d)&&(T=E,i&&console.log("found best %d after %d probes",Math.round(1e4*E.d)/1e4,M)),E.max-T.d<=t||(d=E.h/2,p.push(new no(E.p.x-d,E.p.y-d,d,r)),p.push(new no(E.p.x+d,E.p.y-d,d,r)),p.push(new no(E.p.x-d,E.p.y+d,d,r)),p.push(new no(E.p.x+d,E.p.y+d,d,r)),M+=4)}return i&&(console.log(`num probes: ${M}`),console.log(`best distance: ${T.d}`)),T.p}function rm(r,t){return t.max-r.max}function no(r,t,i,s){this.p=new be(r,t),this.h=i,this.d=function(o,d){let p=!1,m=1/0;for(let g=0;g<d.length;g++){const x=d[g];for(let v=0,T=x.length,M=T-1;v<T;M=v++){const E=x[v],A=x[M];E.y>o.y!=A.y>o.y&&o.x<(A.x-E.x)*(o.y-E.y)/(A.y-E.y)+E.x&&(p=!p),m=Math.min(m,_u(o,E,A))}}return(p?1:-1)*Math.sqrt(m)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}var xi;C.aE=void 0,(xi=C.aE||(C.aE={}))[xi.center=1]="center",xi[xi.left=2]="left",xi[xi.right=3]="right",xi[xi.top=4]="top",xi[xi.bottom=5]="bottom",xi[xi["top-left"]=6]="top-left",xi[xi["top-right"]=7]="top-right",xi[xi["bottom-left"]=8]="bottom-left",xi[xi["bottom-right"]=9]="bottom-right";const Wh=Number.POSITIVE_INFINITY;function Dd(r,t){return t[1]!==Wh?function(i,s,o){let d=0,p=0;switch(s=Math.abs(s),o=Math.abs(o),i){case"top-right":case"top-left":case"top":p=o-7;break;case"bottom-right":case"bottom-left":case"bottom":p=7-o}switch(i){case"top-right":case"bottom-right":case"right":d=-s;break;case"top-left":case"bottom-left":case"left":d=s}return[d,p]}(r,t[0],t[1]):function(i,s){let o=0,d=0;s<0&&(s=0);const p=s/Math.SQRT2;switch(i){case"top-right":case"top-left":d=p-7;break;case"bottom-right":case"bottom-left":d=7-p;break;case"bottom":d=7-s;break;case"top":d=s-7}switch(i){case"top-right":case"bottom-right":o=-p;break;case"top-left":case"bottom-left":o=p;break;case"left":o=s;break;case"right":o=-s}return[o,d]}(r,t[0])}function Rd(r,t,i){var s;const o=r.layout,d=(s=o.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},i);if(d){const m=d.values,g=[];for(let x=0;x<m.length;x+=2){const v=g[x]=m[x],T=m[x+1].map(M=>M*ni);v.startsWith("top")?T[1]-=7:v.startsWith("bottom")&&(T[1]+=7),g[x+1]=T}return new Ti(g)}const p=o.get("text-variable-anchor");if(p){let m;m=r._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[o.get("text-radial-offset").evaluate(t,{},i)*ni,Wh]:o.get("text-offset").evaluate(t,{},i).map(x=>x*ni);const g=[];for(const x of p)g.push(x,Dd(x,m));return new Ti(g)}return null}function Hh(r){switch(r){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function nm(r,t,i,s,o,d,p,m,g,x,v,T){let M=d.textMaxSize.evaluate(t,{});M===void 0&&(M=p);const E=r.layers[0].layout,A=E.get("icon-offset").evaluate(t,{},v),L=Bd(i.horizontal),F=p/24,V=r.tilePixelRatio*F,Q=r.tilePixelRatio*M/24,W=r.tilePixelRatio*m,X=r.tilePixelRatio*E.get("symbol-spacing"),ce=E.get("text-padding")*r.tilePixelRatio,pe=function(Ge,je,De,at=1){const Lt=Ge.get("icon-padding").evaluate(je,{},De),Jt=Lt&&Lt.values;return[Jt[0]*at,Jt[1]*at,Jt[2]*at,Jt[3]*at]}(E,t,v,r.tilePixelRatio),xe=E.get("text-max-angle")/180*Math.PI,Ae=E.get("text-rotation-alignment")!=="viewport"&&E.get("symbol-placement")!=="point",Pe=E.get("icon-rotation-alignment")==="map"&&E.get("symbol-placement")!=="point",Ie=E.get("symbol-placement"),Be=X/2,Me=E.get("icon-text-fit");let Ce;s&&Me!=="none"&&(r.allowVerticalPlacement&&i.vertical&&(Ce=od(s,i.vertical,Me,E.get("icon-text-fit-padding"),A,F)),L&&(s=od(s,L,Me,E.get("icon-text-fit-padding"),A,F)));const ge=v?T.line.getGranularityForZoomLevel(v.z):1,$e=(Ge,je)=>{je.x<0||je.x>=gt||je.y<0||je.y>=gt||function(De,at,Lt,Jt,vi,hr,Vi,di,Et,si,pi,fi,Di,ur,ai,Ui,Qt,oi,li,Wt,St,zr,so,Lr,om){const ao=De.addToLineVertexArray(at,Lt);let ia,oo,lo,co,Vd=0,Ud=0,$d=0,Zd=0,iu=-1,ru=-1;const On={};let Gd=fs("");if(De.allowVerticalPlacement&&Jt.vertical){const Ii=di.layout.get("text-rotate").evaluate(St,{},Lr)+90;lo=new Lc(Et,at,si,pi,fi,Jt.vertical,Di,ur,ai,Ii),Vi&&(co=new Lc(Et,at,si,pi,fi,Vi,Qt,oi,ai,Ii))}if(vi){const Ii=di.layout.get("icon-rotate").evaluate(St,{}),dr=di.layout.get("icon-text-fit")!=="none",ra=zd(vi,Ii,so,dr),Rr=Vi?zd(Vi,Ii,so,dr):void 0;oo=new Lc(Et,at,si,pi,fi,vi,Qt,oi,!1,Ii),Vd=4*ra.length;const na=De.iconSizeData;let on=null;na.kind==="source"?(on=[Bn*di.layout.get("icon-size").evaluate(St,{})],on[0]>_s&&jt(`${De.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):na.kind==="composite"&&(on=[Bn*zr.compositeIconSizes[0].evaluate(St,{},Lr),Bn*zr.compositeIconSizes[1].evaluate(St,{},Lr)],(on[0]>_s||on[1]>_s)&&jt(`${De.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),De.addSymbols(De.icon,ra,on,Wt,li,St,C.ao.none,at,ao.lineStartIndex,ao.lineLength,-1,Lr),iu=De.icon.placedSymbolArray.length-1,Rr&&(Ud=4*Rr.length,De.addSymbols(De.icon,Rr,on,Wt,li,St,C.ao.vertical,at,ao.lineStartIndex,ao.lineLength,-1,Lr),ru=De.icon.placedSymbolArray.length-1)}const qd=Object.keys(Jt.horizontal);for(const Ii of qd){const dr=Jt.horizontal[Ii];if(!ia){Gd=fs(dr.text);const Rr=di.layout.get("text-rotate").evaluate(St,{},Lr);ia=new Lc(Et,at,si,pi,fi,dr,Di,ur,ai,Rr)}const ra=dr.positionedLines.length===1;if($d+=Fd(De,at,dr,hr,di,ai,St,Ui,ao,Jt.vertical?C.ao.horizontal:C.ao.horizontalOnly,ra?qd:[Ii],On,iu,zr,Lr),ra)break}Jt.vertical&&(Zd+=Fd(De,at,Jt.vertical,hr,di,ai,St,Ui,ao,C.ao.vertical,["vertical"],On,ru,zr,Lr));const lm=ia?ia.boxStartIndex:De.collisionBoxArray.length,cm=ia?ia.boxEndIndex:De.collisionBoxArray.length,hm=lo?lo.boxStartIndex:De.collisionBoxArray.length,um=lo?lo.boxEndIndex:De.collisionBoxArray.length,dm=oo?oo.boxStartIndex:De.collisionBoxArray.length,pm=oo?oo.boxEndIndex:De.collisionBoxArray.length,fm=co?co.boxStartIndex:De.collisionBoxArray.length,mm=co?co.boxEndIndex:De.collisionBoxArray.length;let Dr=-1;const Rc=(Ii,dr)=>Ii&&Ii.circleDiameter?Math.max(Ii.circleDiameter,dr):dr;Dr=Rc(ia,Dr),Dr=Rc(lo,Dr),Dr=Rc(oo,Dr),Dr=Rc(co,Dr);const Wd=Dr>-1?1:0;Wd&&(Dr*=om/ni),De.glyphOffsetArray.length>=io.MAX_GLYPHS&&jt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),St.sortKey!==void 0&&De.addToSortKeyRanges(De.symbolInstances.length,St.sortKey);const gm=Rd(di,St,Lr),[_m,ym]=function(Ii,dr){const ra=Ii.length,Rr=dr==null?void 0:dr.values;if((Rr==null?void 0:Rr.length)>0)for(let na=0;na<Rr.length;na+=2){const on=Rr[na+1];Ii.emplaceBack(C.aE[Rr[na]],on[0],on[1])}return[ra,Ii.length]}(De.textAnchorOffsets,gm);De.symbolInstances.emplaceBack(at.x,at.y,On.right>=0?On.right:-1,On.center>=0?On.center:-1,On.left>=0?On.left:-1,On.vertical||-1,iu,ru,Gd,lm,cm,hm,um,dm,pm,fm,mm,si,$d,Zd,Vd,Ud,Wd,0,Di,Dr,_m,ym)}(r,je,Ge,i,s,o,Ce,r.layers[0],r.collisionBoxArray,t.index,t.sourceLayerIndex,r.index,V,[ce,ce,ce,ce],Ae,g,W,pe,Pe,A,t,d,x,v,p)};if(Ie==="line")for(const Ge of Md(t.geometry,0,0,gt,gt)){const je=ea(Ge,ge),De=em(je,X,xe,i.vertical||L,s,24,Q,r.overscaling,gt);for(const at of De)L&&sm(r,L.text,Be,at)||$e(je,at)}else if(Ie==="line-center"){for(const Ge of t.geometry)if(Ge.length>1){const je=ea(Ge,ge),De=Qf(je,xe,i.vertical||L,s,24,Q);De&&$e(je,De)}}else if(t.type==="Polygon")for(const Ge of Bs(t.geometry,0)){const je=im(Ge,16);$e(ea(Ge[0],ge,!0),new xs(je.x,je.y,0))}else if(t.type==="LineString")for(const Ge of t.geometry){const je=ea(Ge,ge);$e(je,new xs(je[0].x,je[0].y,0))}else if(t.type==="Point")for(const Ge of t.geometry)for(const je of Ge)$e([je],new xs(je.x,je.y,0))}function Fd(r,t,i,s,o,d,p,m,g,x,v,T,M,E,A){const L=function(Q,W,X,ce,pe,xe,Ae,Pe){const Ie=ce.layout.get("text-rotate").evaluate(xe,{})*Math.PI/180,Be=[];for(const Me of W.positionedLines)for(const Ce of Me.positionedGlyphs){if(!Ce.rect)continue;const ge=Ce.rect||{};let $e=4,Ge=!0,je=1,De=0;const at=(pe||Pe)&&Ce.vertical,Lt=Ce.metrics.advance*Ce.scale/2;if(Pe&&W.verticalizable&&(De=Me.lineOffset/2-(Ce.imageName?-(ni-Ce.metrics.width*Ce.scale)/2:(Ce.scale-1)*ni)),Ce.imageName){const oi=Ae[Ce.imageName];Ge=oi.sdf,je=oi.pixelRatio,$e=1/je}const Jt=pe?[Ce.x+Lt,Ce.y]:[0,0];let vi=pe?[0,0]:[Ce.x+Lt+X[0],Ce.y+X[1]-De],hr=[0,0];at&&(hr=vi,vi=[0,0]);const Vi=Ce.metrics.isDoubleResolution?2:1,di=(Ce.metrics.left-$e)*Ce.scale-Lt+vi[0],Et=(-Ce.metrics.top-$e)*Ce.scale+vi[1],si=di+ge.w/Vi*Ce.scale/je,pi=Et+ge.h/Vi*Ce.scale/je,fi=new be(di,Et),Di=new be(si,Et),ur=new be(di,pi),ai=new be(si,pi);if(at){const oi=new be(-Lt,Lt- -17),li=-Math.PI/2,Wt=12-Lt,St=new be(22-Wt,-(Ce.imageName?Wt:0)),zr=new be(...hr);fi._rotateAround(li,oi)._add(St)._add(zr),Di._rotateAround(li,oi)._add(St)._add(zr),ur._rotateAround(li,oi)._add(St)._add(zr),ai._rotateAround(li,oi)._add(St)._add(zr)}if(Ie){const oi=Math.sin(Ie),li=Math.cos(Ie),Wt=[li,-oi,oi,li];fi._matMult(Wt),Di._matMult(Wt),ur._matMult(Wt),ai._matMult(Wt)}const Ui=new be(0,0),Qt=new be(0,0);Be.push({tl:fi,tr:Di,bl:ur,br:ai,tex:ge,writingMode:W.writingMode,glyphOffset:Jt,sectionIndex:Ce.sectionIndex,isSDF:Ge,pixelOffsetTL:Ui,pixelOffsetBR:Qt,minFontScaleX:0,minFontScaleY:0})}return Be}(0,i,m,o,d,p,s,r.allowVerticalPlacement),F=r.textSizeData;let V=null;F.kind==="source"?(V=[Bn*o.layout.get("text-size").evaluate(p,{})],V[0]>_s&&jt(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):F.kind==="composite"&&(V=[Bn*E.compositeTextSizes[0].evaluate(p,{},A),Bn*E.compositeTextSizes[1].evaluate(p,{},A)],(V[0]>_s||V[1]>_s)&&jt(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),r.addSymbols(r.text,L,V,m,d,p,x,t,g.lineStartIndex,g.lineLength,M,A);for(const Q of v)T[Q]=r.text.placedSymbolArray.length-1;return 4*L.length}function Bd(r){for(const t in r)return r[t];return null}function sm(r,t,i,s){const o=r.compareText;if(t in o){const d=o[t];for(let p=d.length-1;p>=0;p--)if(s.dist(d[p])<i)return!0}else o[t]=[];return o[t].push(s),!1}const Od=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Xh{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,s]=new Uint8Array(t,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const o=s>>4;if(o!==1)throw new Error(`Got v${o} data when expected v1.`);const d=Od[15&s];if(!d)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(t,2,1),[m]=new Uint32Array(t,4,1);return new Xh(m,p,d,t)}constructor(t,i=64,s=Float64Array,o){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const d=Od.indexOf(this.ArrayType),p=2*t*this.ArrayType.BYTES_PER_ELEMENT,m=t*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-m%8)%8;if(d<0)throw new Error(`Unexpected typed array class: ${s}.`);o&&o instanceof ArrayBuffer?(this.data=o,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+m+g,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+p+m+g),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+m+g,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+d]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=t)}add(t,i){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=i,s}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Yh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,s,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:d,coords:p,nodeSize:m}=this,g=[0,d.length-1,0],x=[];for(;g.length;){const v=g.pop()||0,T=g.pop()||0,M=g.pop()||0;if(T-M<=m){for(let F=M;F<=T;F++){const V=p[2*F],Q=p[2*F+1];V>=t&&V<=s&&Q>=i&&Q<=o&&x.push(d[F])}continue}const E=M+T>>1,A=p[2*E],L=p[2*E+1];A>=t&&A<=s&&L>=i&&L<=o&&x.push(d[E]),(v===0?t<=A:i<=L)&&(g.push(M),g.push(E-1),g.push(1-v)),(v===0?s>=A:o>=L)&&(g.push(E+1),g.push(T),g.push(1-v))}return x}within(t,i,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:d,nodeSize:p}=this,m=[0,o.length-1,0],g=[],x=s*s;for(;m.length;){const v=m.pop()||0,T=m.pop()||0,M=m.pop()||0;if(T-M<=p){for(let F=M;F<=T;F++)Nd(d[2*F],d[2*F+1],t,i)<=x&&g.push(o[F]);continue}const E=M+T>>1,A=d[2*E],L=d[2*E+1];Nd(A,L,t,i)<=x&&g.push(o[E]),(v===0?t-s<=A:i-s<=L)&&(m.push(M),m.push(E-1),m.push(1-v)),(v===0?t+s>=A:i+s>=L)&&(m.push(E+1),m.push(T),m.push(1-v))}return g}}function Yh(r,t,i,s,o,d){if(o-s<=i)return;const p=s+o>>1;jd(r,t,p,s,o,d),Yh(r,t,i,s,p-1,1-d),Yh(r,t,i,p+1,o,1-d)}function jd(r,t,i,s,o,d){for(;o>s;){if(o-s>600){const x=o-s+1,v=i-s+1,T=Math.log(x),M=.5*Math.exp(2*T/3),E=.5*Math.sqrt(T*M*(x-M)/x)*(v-x/2<0?-1:1);jd(r,t,i,Math.max(s,Math.floor(i-v*M/x+E)),Math.min(o,Math.floor(i+(x-v)*M/x+E)),d)}const p=t[2*i+d];let m=s,g=o;for(vl(r,t,s,i),t[2*o+d]>p&&vl(r,t,s,o);m<g;){for(vl(r,t,m,g),m++,g--;t[2*m+d]<p;)m++;for(;t[2*g+d]>p;)g--}t[2*s+d]===p?vl(r,t,s,g):(g++,vl(r,t,g,o)),g<=i&&(s=g+1),i<=g&&(o=g-1)}}function vl(r,t,i,s){Kh(r,i,s),Kh(t,2*i,2*s),Kh(t,2*i+1,2*s+1)}function Kh(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}function Nd(r,t,i,s){const o=r-i,d=t-s;return o*o+d*d}var Jh;C.cx=void 0,(Jh=C.cx||(C.cx={})).create="create",Jh.load="load",Jh.fullLoad="fullLoad";let Dc=null,bl=[];const Qh=1e3/60,eu="loadTime",tu="fullLoadTime",am={mark(r){performance.mark(r)},frame(r){const t=r;Dc!=null&&bl.push(t-Dc),Dc=t},clearMetrics(){Dc=null,bl=[],performance.clearMeasures(eu),performance.clearMeasures(tu);for(const r in C.cx)performance.clearMarks(C.cx[r])},getPerformanceMetrics(){performance.measure(eu,C.cx.create,C.cx.load),performance.measure(tu,C.cx.create,C.cx.fullLoad);const r=performance.getEntriesByName(eu)[0].duration,t=performance.getEntriesByName(tu)[0].duration,i=bl.length,s=1/(bl.reduce((d,p)=>d+p,0)/i/1e3),o=bl.filter(d=>d>Qh).reduce((d,p)=>d+(p-Qh)/Qh,0);return{loadTime:r,fullLoadTime:t,fps:s,percentDroppedFrames:o/(i+o)*100,totalFrames:i}}};C.$=gt,C.A=ft,C.B=function([r,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:r*Math.cos(t)*Math.sin(i),y:r*Math.sin(t)*Math.sin(i),z:r*Math.cos(i)}},C.C=wr,C.D=Fe,C.E=Re,C.F=wt,C.G=Ws,C.H=function(r){if(mn==null){const t=r.navigator?r.navigator.userAgent:null;mn=!!r.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return mn},C.I=Fh,C.J=class{constructor(r,t){this.target=r,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Yf(()=>this.process()),this.subscription=Ur(this.target,"message",i=>this.receive(i),!1),this.globalScope=gr(self)?r:window}registerMessageHandler(r,t){this.messageHandlers[r]=t}sendAsync(r,t){return new Promise((i,s)=>{const o=Math.round(1e18*Math.random()).toString(36).substring(0,10),d=t?Ur(t.signal,"abort",()=>{d==null||d.unsubscribe(),delete this.resolveRejects[o];const g={id:o,type:"<cancel>",origin:location.origin,targetMapId:r.targetMapId,sourceMapId:this.mapId};this.target.postMessage(g)},Kf):null;this.resolveRejects[o]={resolve:g=>{d==null||d.unsubscribe(),i(g)},reject:g=>{d==null||d.unsubscribe(),s(g)}};const p=[],m=Object.assign(Object.assign({},r),{id:o,sourceMapId:this.mapId,origin:location.origin,data:ls(r.data,p)});this.target.postMessage(m,{transfer:p})})}receive(r){const t=r.data,i=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[i];const s=this.abortControllers[i];return delete this.abortControllers[i],void(s&&s.abort())}if(gr(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(this.taskQueue.length===0)return;const r=this.taskQueue.shift(),t=this.tasks[r];delete this.tasks[r],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(r,t)}processTask(r,t){return c(this,void 0,void 0,function*(){if(t.type==="<response>"){const o=this.resolveRejects[r];return delete this.resolveRejects[r],o?void(t.error?o.reject(zn(t.error)):o.resolve(zn(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(r,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const i=zn(t.data),s=new AbortController;this.abortControllers[r]=s;try{const o=yield this.messageHandlers[t.type](t.sourceMapId,i,s);this.completeTask(r,null,o)}catch(o){this.completeTask(r,o)}})}completeTask(r,t,i){const s=[];delete this.abortControllers[r];const o={id:r,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?ls(t):null,data:ls(i,s)};this.target.postMessage(o,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},C.K=R,C.L=function(){var r=new ft(16);return ft!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r},C.M=function(r,t,i){var s,o,d,p,m,g,x,v,T,M,E,A,L=i[0],F=i[1],V=i[2];return t===r?(r[12]=t[0]*L+t[4]*F+t[8]*V+t[12],r[13]=t[1]*L+t[5]*F+t[9]*V+t[13],r[14]=t[2]*L+t[6]*F+t[10]*V+t[14],r[15]=t[3]*L+t[7]*F+t[11]*V+t[15]):(o=t[1],d=t[2],p=t[3],m=t[4],g=t[5],x=t[6],v=t[7],T=t[8],M=t[9],E=t[10],A=t[11],r[0]=s=t[0],r[1]=o,r[2]=d,r[3]=p,r[4]=m,r[5]=g,r[6]=x,r[7]=v,r[8]=T,r[9]=M,r[10]=E,r[11]=A,r[12]=s*L+m*F+T*V+t[12],r[13]=o*L+g*F+M*V+t[13],r[14]=d*L+x*F+E*V+t[14],r[15]=p*L+v*F+A*V+t[15]),r},C.N=function(r,t,i){var s=i[0],o=i[1],d=i[2];return r[0]=t[0]*s,r[1]=t[1]*s,r[2]=t[2]*s,r[3]=t[3]*s,r[4]=t[4]*o,r[5]=t[5]*o,r[6]=t[6]*o,r[7]=t[7]*o,r[8]=t[8]*d,r[9]=t[9]*d,r[10]=t[10]*d,r[11]=t[11]*d,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},C.O=function(r,t,i){var s=t[0],o=t[1],d=t[2],p=t[3],m=t[4],g=t[5],x=t[6],v=t[7],T=t[8],M=t[9],E=t[10],A=t[11],L=t[12],F=t[13],V=t[14],Q=t[15],W=i[0],X=i[1],ce=i[2],pe=i[3];return r[0]=W*s+X*m+ce*T+pe*L,r[1]=W*o+X*g+ce*M+pe*F,r[2]=W*d+X*x+ce*E+pe*V,r[3]=W*p+X*v+ce*A+pe*Q,r[4]=(W=i[4])*s+(X=i[5])*m+(ce=i[6])*T+(pe=i[7])*L,r[5]=W*o+X*g+ce*M+pe*F,r[6]=W*d+X*x+ce*E+pe*V,r[7]=W*p+X*v+ce*A+pe*Q,r[8]=(W=i[8])*s+(X=i[9])*m+(ce=i[10])*T+(pe=i[11])*L,r[9]=W*o+X*g+ce*M+pe*F,r[10]=W*d+X*x+ce*E+pe*V,r[11]=W*p+X*v+ce*A+pe*Q,r[12]=(W=i[12])*s+(X=i[13])*m+(ce=i[14])*T+(pe=i[15])*L,r[13]=W*o+X*g+ce*M+pe*F,r[14]=W*d+X*x+ce*E+pe*V,r[15]=W*p+X*v+ce*A+pe*Q,r},C.P=be,C.Q=function(r,t){const i={};for(let s=0;s<t.length;s++){const o=t[s];o in r&&(i[o]=r[o])}return i},C.R=Ni,C.S=ys,C.T=Sh,C.U=_d,C.V=gd,C.W=Ri,C.X=Ci,C.Y=$n,C.Z=cr,C._=c,C.a=z,C.a$=Or,C.a0=function(r,t){var i,s,o,d,p;if(!r)return t??{};if(!t)return r;let m=Object.assign({},r);if(t.removeAll&&(m={removeAll:!0}),t.remove){const g=new Set(t.remove);m.add&&(m.add=m.add.filter(v=>!g.has(v.id))),m.update&&(m.update=m.update.filter(v=>!g.has(v.id)));const x=new Set(((i=r.add)!==null&&i!==void 0?i:[]).map(v=>v.id));t.remove=t.remove.filter(v=>!x.has(v))}if(t.remove){const g=new Set(m.remove?m.remove.concat(t.remove):t.remove);m.remove=Array.from(g.values())}if(t.add){const g=m.add?m.add.concat(t.add):t.add,x=new Map(g.map(v=>[v.id,v]));m.add=Array.from(x.values())}if(t.update){const g=new Map((s=m.update)===null||s===void 0?void 0:s.map(x=>[x.id,x]));for(const x of t.update){const v=(o=g.get(x.id))!==null&&o!==void 0?o:{id:x.id};x.newGeometry&&(v.newGeometry=x.newGeometry),x.addOrUpdateProperties&&(v.addOrUpdateProperties=((d=v.addOrUpdateProperties)!==null&&d!==void 0?d:[]).concat(x.addOrUpdateProperties)),x.removeProperties&&(v.removeProperties=((p=v.removeProperties)!==null&&p!==void 0?p:[]).concat(x.removeProperties)),x.removeAllProperties&&(v.removeAllProperties=!0),g.set(x.id,v)}m.update=Array.from(g.values())}return m.remove&&m.add&&(m.remove=m.remove.filter(g=>m.add.findIndex(x=>x.id===g)===-1)),m},C.a1=yl,C.a2=ta,C.a3=25,C.a4=qh,C.a5=r=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const s of r){const o=window.document.createElement("source");le(s)||(t.crossOrigin="Anonymous"),o.src=s,t.appendChild(o)}})},C.a6=Te,C.a7=function(){return Yi++},C.a8=P,C.a9=io,C.aA=function(r){let t=1/0,i=1/0,s=-1/0,o=-1/0;for(const d of r)t=Math.min(t,d.x),i=Math.min(i,d.y),s=Math.max(s,d.x),o=Math.max(o,d.y);return[t,i,s,o]},C.aB=ni,C.aC=dn,C.aD=function(r,t,i,s,o=!1){if(!i[0]&&!i[1])return[0,0];const d=o?s==="map"?-r.bearingInRadians:0:s==="viewport"?r.bearingInRadians:0;if(d){const p=Math.sin(d),m=Math.cos(d);i=[i[0]*m-i[1]*p,i[0]*p+i[1]*m]}return[o?i[0]:dn(t,i[0],r.zoom),o?i[1]:dn(t,i[1],r.zoom)]},C.aF=jh,C.aG=Hh,C.aH=Oh,C.aI=Xh,C.aJ=Bt,C.aK=Pc,C.aL=G,C.aM=Xe,C.aN=yt,C.aO=Nn,C.aP=$r,C.aQ=xd,C.aR=pr,C.aS=Ts,C.aT=function(r){var t=new ft(3);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t},C.aU=function(r,t,i){return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],r},C.aV=function(r,t){var i=t[0],s=t[1],o=t[2],d=i*i+s*s+o*o;return d>0&&(d=1/Math.sqrt(d)),r[0]=t[0]*d,r[1]=t[1]*d,r[2]=t[2]*d,r},C.aW=Br,C.aX=function(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]},C.aY=function(r,t,i){return r[0]=t[0]*i[0],r[1]=t[1]*i[1],r[2]=t[2]*i[2],r[3]=t[3]*i[3],r},C.aZ=jn,C.a_=function(r,t,i){const s=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return s===0?null:(-(r[0]*i[0]+r[1]*i[1]+r[2]*i[2])-i[3])/s},C.aa=En,C.ab=kr,C.ac=Td,C.ad=function(r){const t={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,s,o,d)=>{const p=o||d;return t[s]=!p||p.toLowerCase(),""}),t["max-age"]){const i=parseInt(t["max-age"],10);isNaN(i)?delete t["max-age"]:t["max-age"]=i}return t},C.ae=gn,C.af=function(r){return Math.pow(2,r)},C.ag=$i,C.ah=Ei,C.ai=85.051129,C.aj=yd,C.ak=function(r){return Math.log(r)/Math.LN2},C.al=function(r){var t=r[0],i=r[1];return t*t+i*i},C.am=function(r,t){const i=[];for(const s in r)s in t||i.push(s);return i},C.an=function(r,t){let i=0,s=0;if(r.kind==="constant")s=r.layoutSize;else if(r.kind!=="source"){const{interpolationType:o,minZoom:d,maxZoom:p}=r,m=o?Ei(ui.interpolationFactor(o,t,d,p),0,1):0;r.kind==="camera"?s=wr.number(r.minSize,r.maxSize,m):i=m}return{uSizeT:i,uSize:s}},C.ap=function(r,{uSize:t,uSizeT:i},{lowerSize:s,upperSize:o}){return r.kind==="source"?s/Bn:r.kind==="composite"?wr.number(s/Bn,o/Bn,i):t},C.aq=function(r,t){var i=t[0],s=t[1],o=t[2],d=t[3],p=t[4],m=t[5],g=t[6],x=t[7],v=t[8],T=t[9],M=t[10],E=t[11],A=t[12],L=t[13],F=t[14],V=t[15],Q=i*m-s*p,W=i*g-o*p,X=i*x-d*p,ce=s*g-o*m,pe=s*x-d*m,xe=o*x-d*g,Ae=v*L-T*A,Pe=v*F-M*A,Ie=v*V-E*A,Be=T*F-M*L,Me=T*V-E*L,Ce=M*V-E*F,ge=Q*Ce-W*Me+X*Be+ce*Ie-pe*Pe+xe*Ae;return ge?(r[0]=(m*Ce-g*Me+x*Be)*(ge=1/ge),r[1]=(o*Me-s*Ce-d*Be)*ge,r[2]=(L*xe-F*pe+V*ce)*ge,r[3]=(M*pe-T*xe-E*ce)*ge,r[4]=(g*Ie-p*Ce-x*Pe)*ge,r[5]=(i*Ce-o*Ie+d*Pe)*ge,r[6]=(F*X-A*xe-V*W)*ge,r[7]=(v*xe-M*X+E*W)*ge,r[8]=(p*Me-m*Ie+x*Ae)*ge,r[9]=(s*Ie-i*Me-d*Ae)*ge,r[10]=(A*pe-L*X+V*Q)*ge,r[11]=(T*X-v*pe-E*Q)*ge,r[12]=(m*Pe-p*Be-g*Ae)*ge,r[13]=(i*Be-s*Pe+o*Ae)*ge,r[14]=(L*W-A*ce-F*Q)*ge,r[15]=(v*ce-T*W+M*Q)*ge,r):null},C.ar=un,C.as=function(r){var t=r[0],i=r[1];return Math.sqrt(t*t+i*i)},C.at=function(r){return r[0]=0,r[1]=0,r},C.au=function(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r},C.av=Nh,C.aw=Ps,C.ax=function(r,t,i,s){const o=t.y-r.y,d=t.x-r.x,p=s.y-i.y,m=s.x-i.x,g=p*d-m*o;if(g===0)return null;const x=(m*(r.y-i.y)-p*(r.x-i.x))/g;return new be(r.x+x*d,r.y+x*o)},C.ay=Md,C.az=mu,C.b=_r,C.b$=class extends h{},C.b0=function(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r[2]=t[2]*i,r[3]=t[3]*i,r},C.b1=function(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]},C.b2=bd,C.b3=ro,C.b4=function(r,t,i,s,o){var d=1/Math.tan(t/2);if(r[0]=d/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=d,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,o!=null&&o!==1/0){var p=1/(s-o);r[10]=(o+s)*p,r[14]=2*o*s*p}else r[10]=-1,r[14]=-2*s;return r},C.b5=function(r){var t=new ft(16);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],t},C.b6=function(r,t,i){var s=Math.sin(i),o=Math.cos(i),d=t[0],p=t[1],m=t[2],g=t[3],x=t[4],v=t[5],T=t[6],M=t[7];return t!==r&&(r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=d*o+x*s,r[1]=p*o+v*s,r[2]=m*o+T*s,r[3]=g*o+M*s,r[4]=x*o-d*s,r[5]=v*o-p*s,r[6]=T*o-m*s,r[7]=M*o-g*s,r},C.b7=function(r,t,i){var s=Math.sin(i),o=Math.cos(i),d=t[4],p=t[5],m=t[6],g=t[7],x=t[8],v=t[9],T=t[10],M=t[11];return t!==r&&(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[4]=d*o+x*s,r[5]=p*o+v*s,r[6]=m*o+T*s,r[7]=g*o+M*s,r[8]=x*o-d*s,r[9]=v*o-p*s,r[10]=T*o-m*s,r[11]=M*o-g*s,r},C.b8=function(){const r=new Float32Array(16);return $i(r),r},C.b9=function(){const r=new Float64Array(16);return $i(r),r},C.bA=function(r,t){const i=mi(r,360),s=mi(t,360),o=s-i,d=s>i?o-360:o+360;return Math.abs(o)<Math.abs(d)?o:d},C.bB=function(r){return r[0]=0,r[1]=0,r[2]=0,r},C.bC=function(r,t,i,s){const o=Math.sqrt(r*r+t*t),d=Math.sqrt(i*i+s*s);r/=o,t/=o,i/=d,s/=d;const p=Math.acos(r*i+t*s);return-t*i+r*s>0?p:-p},C.bD=function(r,t){const i=mi(r,2*Math.PI),s=mi(t,2*Math.PI);return Math.min(Math.abs(i-s),Math.abs(i-s+2*Math.PI),Math.abs(i-s-2*Math.PI))},C.bE=function(){const r={},t=ne.$version;for(const i in ne.$root){const s=ne.$root[i];if(s.required){let o=null;o=i==="version"?t:s.type==="array"?[]:{},o!=null&&(r[i]=o)}}return r},C.bF=Oa,C.bG=Y,C.bH=function r(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let s=0;s<t.length;s++)if(!r(t[s],i[s]))return!1;return!0}if(typeof t=="object"&&t!==null&&i!==null){if(typeof i!="object"||Object.keys(t).length!==Object.keys(i).length)return!1;for(const s in t)if(!r(t[s],i[s]))return!1;return!0}return t===i},C.bI=function(r){r=r.slice();const t=Object.create(null);for(let i=0;i<r.length;i++)t[r[i].id]=r[i];for(let i=0;i<r.length;i++)"ref"in r[i]&&(r[i]=Qe(r[i],t[r[i].ref]));return r},C.bJ=function(r){if(r.type==="custom")return new Xf(r);switch(r.type){case"background":return new qf(r);case"circle":return new Ap(r);case"color-relief":return new Fp(r);case"fill":return new Kp(r);case"fill-extrusion":return new cf(r);case"heatmap":return new zp(r);case"hillshade":return new Dp(r);case"line":return new gf(r);case"raster":return new Hf(r);case"symbol":return new Ec(r)}},C.bK=Fi,C.bL=function(r,t){if(!r)return[{command:"setStyle",args:[t]}];let i=[];try{if(!Oe(r.version,t.version))return[{command:"setStyle",args:[t]}];Oe(r.center,t.center)||i.push({command:"setCenter",args:[t.center]}),Oe(r.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),Oe(r.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Oe(r.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),Oe(r.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),Oe(r.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),Oe(r.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),Oe(r.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),Oe(r.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),Oe(r.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),Oe(r.light,t.light)||i.push({command:"setLight",args:[t.light]}),Oe(r.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),Oe(r.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),Oe(r.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const s={},o=[];(function(p,m,g,x){let v;for(v in m=m||{},p=p||{})Object.prototype.hasOwnProperty.call(p,v)&&(Object.prototype.hasOwnProperty.call(m,v)||Ht(v,g,x));for(v in m)Object.prototype.hasOwnProperty.call(m,v)&&(Object.prototype.hasOwnProperty.call(p,v)?Oe(p[v],m[v])||(p[v].type==="geojson"&&m[v].type==="geojson"&&Nt(p,m,v)?He(g,{command:"setGeoJSONSourceData",args:[v,m[v].data]}):Xt(v,m,g,x)):Tt(v,m,g))})(r.sources,t.sources,o,s);const d=[];r.layers&&r.layers.forEach(p=>{"source"in p&&s[p.source]?i.push({command:"removeLayer",args:[p.id]}):d.push(p)}),i=i.concat(o),function(p,m,g){m=m||[];const x=(p=p||[]).map(ot),v=m.map(ot),T=p.reduce(Ut,{}),M=m.reduce(Ut,{}),E=x.slice(),A=Object.create(null);let L,F,V,Q,W;for(let X=0,ce=0;X<x.length;X++)L=x[X],Object.prototype.hasOwnProperty.call(M,L)?ce++:(He(g,{command:"removeLayer",args:[L]}),E.splice(E.indexOf(L,ce),1));for(let X=0,ce=0;X<v.length;X++)L=v[v.length-1-X],E[E.length-1-X]!==L&&(Object.prototype.hasOwnProperty.call(T,L)?(He(g,{command:"removeLayer",args:[L]}),E.splice(E.lastIndexOf(L,E.length-ce),1)):ce++,Q=E[E.length-X],He(g,{command:"addLayer",args:[M[L],Q]}),E.splice(E.length-X,0,L),A[L]=!0);for(let X=0;X<v.length;X++)if(L=v[X],F=T[L],V=M[L],!A[L]&&!Oe(F,V))if(Oe(F.source,V.source)&&Oe(F["source-layer"],V["source-layer"])&&Oe(F.type,V.type)){for(W in rt(F.layout,V.layout,g,L,null,"setLayoutProperty"),rt(F.paint,V.paint,g,L,null,"setPaintProperty"),Oe(F.filter,V.filter)||He(g,{command:"setFilter",args:[L,V.filter]}),Oe(F.minzoom,V.minzoom)&&Oe(F.maxzoom,V.maxzoom)||He(g,{command:"setLayerZoomRange",args:[L,V.minzoom,V.maxzoom]}),F)Object.prototype.hasOwnProperty.call(F,W)&&W!=="layout"&&W!=="paint"&&W!=="filter"&&W!=="metadata"&&W!=="minzoom"&&W!=="maxzoom"&&(W.indexOf("paint.")===0?rt(F[W],V[W],g,L,W.slice(6),"setPaintProperty"):Oe(F[W],V[W])||He(g,{command:"setLayerProperty",args:[L,W,V[W]]}));for(W in V)Object.prototype.hasOwnProperty.call(V,W)&&!Object.prototype.hasOwnProperty.call(F,W)&&W!=="layout"&&W!=="paint"&&W!=="filter"&&W!=="metadata"&&W!=="minzoom"&&W!=="maxzoom"&&(W.indexOf("paint.")===0?rt(F[W],V[W],g,L,W.slice(6),"setPaintProperty"):Oe(F[W],V[W])||He(g,{command:"setLayerProperty",args:[L,W,V[W]]}))}else He(g,{command:"removeLayer",args:[L]}),Q=E[E.lastIndexOf(L)+1],He(g,{command:"addLayer",args:[V,Q]})}(d,t.layers,i)}catch(s){console.warn("Unable to compute style diff:",s),i=[{command:"setStyle",args:[t]}]}return i},C.bM=function(r){const t=[],i=r.id;return i===void 0&&t.push({message:`layers.${i}: missing required property "id"`}),r.render===void 0&&t.push({message:`layers.${i}: missing required method "render"`}),r.renderingMode&&r.renderingMode!=="2d"&&r.renderingMode!=="3d"&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},C.bN=Vn,C.bO=Un,C.bP=class extends Mi{constructor(r,t){super(r,t),this.current=0}set(r){this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}},C.bQ=Kt,C.bR=class extends Mi{constructor(r,t){super(r,t),this.current=Hi}set(r){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let t=1;t<16;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}},C.bS=Gt,C.bT=class extends Mi{constructor(r,t){super(r,t),this.current=[0,0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2]))}},C.bU=class extends Mi{constructor(r,t){super(r,t),this.current=[0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1]))}},C.bV=Ot,C.bW=function(r,t){var i=Math.sin(t),s=Math.cos(t);return r[0]=s,r[1]=i,r[2]=0,r[3]=-i,r[4]=s,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},C.bX=function(r,t,i){var s=t[0],o=t[1],d=t[2];return r[0]=s*i[0]+o*i[3]+d*i[6],r[1]=s*i[1]+o*i[4]+d*i[7],r[2]=s*i[2]+o*i[5]+d*i[8],r},C.bY=function(r,t,i,s,o,d,p){var m=1/(t-i),g=1/(s-o),x=1/(d-p);return r[0]=-2*m,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*g,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*x,r[11]=0,r[12]=(t+i)*m,r[13]=(o+s)*g,r[14]=(p+d)*x,r[15]=1,r},C.bZ=class extends Mi{constructor(r,t){super(r,t),this.current=new Array}set(r){if(r!=this.current){this.current=r;const t=new Float32Array(4*r.length);for(let i=0;i<r.length;i++)t[4*i]=r[i].r,t[4*i+1]=r[i].g,t[4*i+2]=r[i].b,t[4*i+3]=r[i].a;this.gl.uniform4fv(this.location,t)}}},C.b_=class extends Mi{constructor(r,t){super(r,t),this.current=new Array}set(r){if(r!=this.current){this.current=r;const t=new Float32Array(r);this.gl.uniform1fv(this.location,t)}}},C.ba=function(){return new Float64Array(16)},C.bb=function(r,t,i){const s=new Float64Array(4);return hn(s,r,t-90,i),s},C.bc=function(r,t,i,s){var o,d,p,m,g,x=t[0],v=t[1],T=t[2],M=t[3],E=i[0],A=i[1],L=i[2],F=i[3];return(d=x*E+v*A+T*L+M*F)<0&&(d=-d,E=-E,A=-A,L=-L,F=-F),1-d>It?(o=Math.acos(d),p=Math.sin(o),m=Math.sin((1-s)*o)/p,g=Math.sin(s*o)/p):(m=1-s,g=s),r[0]=m*x+g*E,r[1]=m*v+g*A,r[2]=m*T+g*L,r[3]=m*M+g*F,r},C.bd=function(r){const t=new Float64Array(9);var i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q,W;T=(o=(s=r)[0])*(g=o+o),M=(d=s[1])*g,A=(p=s[2])*g,L=p*(x=d+d),V=(m=s[3])*g,Q=m*x,W=m*(v=p+p),(i=t)[0]=1-(E=d*x)-(F=p*v),i[3]=M-W,i[6]=A+Q,i[1]=M+W,i[4]=1-T-F,i[7]=L-V,i[2]=A-Q,i[5]=L+V,i[8]=1-T-E;const X=$r(-Math.asin(Ei(t[2],-1,1)));let ce,pe;return Math.hypot(t[5],t[8])<.001?(ce=0,pe=-$r(Math.atan2(t[3],t[4]))):(ce=$r(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),pe=$r(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:ce,pitch:X+90,bearing:pe}},C.be=function(r,t){return r.roll==t.roll&&r.pitch==t.pitch&&r.bearing==t.bearing},C.bf=it,C.bg=nn,C.bh=Ja,C.bi=dl,C.bj=Ka,C.bk=pn,C.bl=mr,C.bm=_i,C.bn=function(r,t,i,s,o){return pn(s,o,Ei((r-t)/(i-t),0,1))},C.bo=mi,C.bp=function(){return new Float64Array(3)},C.bq=function(r,t,i,s){return r[0]=t[0]+i[0]*s,r[1]=t[1]+i[1]*s,r[2]=t[2]+i[2]*s,r},C.br=hn,C.bs=function(r,t,i){var s=i[0],o=i[1],d=i[2],p=i[3],m=t[0],g=t[1],x=t[2],v=o*x-d*g,T=d*m-s*x,M=s*g-o*m;return r[0]=m+p*(v+=v)+o*(M+=M)-d*(T+=T),r[1]=g+p*T+d*v-s*M,r[2]=x+p*M+s*T-o*v,r},C.bt=function(r,t,i){const s=(o=[r[0],r[1],r[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((v=o[8])*(p=o[4])-(m=o[5])*(x=o[7]))+o[1]*(-v*(d=o[3])+m*(g=o[6]))+o[2]*(x*d-p*g);var o,d,p,m,g,x,v;if(s===0)return null;const T=Br([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),M=Br([],[i[0],i[1],i[2]],[r[0],r[1],r[2]]),E=Br([],[r[0],r[1],r[2]],[t[0],t[1],t[2]]),A=pr([],T,-r[3]);return Ts(A,A,pr([],M,-t[3])),Ts(A,A,pr([],E,-i[3])),pr(A,A,1/s),A},C.bu=Zh,C.bv=function(){return new Float64Array(4)},C.bw=function(r,t,i,s){var o=[],d=[];return o[0]=t[0]-i[0],o[1]=t[1]-i[1],o[2]=t[2]-i[2],d[0]=o[0]*Math.cos(s)-o[1]*Math.sin(s),d[1]=o[0]*Math.sin(s)+o[1]*Math.cos(s),d[2]=o[2],r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},C.bx=function(r,t,i,s){var o=[],d=[];return o[0]=t[0]-i[0],o[1]=t[1]-i[1],o[2]=t[2]-i[2],d[0]=o[0],d[1]=o[1]*Math.cos(s)-o[2]*Math.sin(s),d[2]=o[1]*Math.sin(s)+o[2]*Math.cos(s),r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},C.by=function(r,t,i,s){var o=[],d=[];return o[0]=t[0]-i[0],o[1]=t[1]-i[1],o[2]=t[2]-i[2],d[0]=o[2]*Math.sin(s)+o[0]*Math.cos(s),d[1]=o[1],d[2]=o[2]*Math.cos(s)-o[0]*Math.sin(s),r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},C.bz=function(r,t,i){var s=Math.sin(i),o=Math.cos(i),d=t[0],p=t[1],m=t[2],g=t[3],x=t[8],v=t[9],T=t[10],M=t[11];return t!==r&&(r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=d*o-x*s,r[1]=p*o-v*s,r[2]=m*o-T*s,r[3]=g*o-M*s,r[8]=d*s+x*o,r[9]=p*s+v*o,r[10]=m*s+T*o,r[11]=g*s+M*o,r},C.c=ee,C.c0=vf,C.c1=class extends n{},C.c2=Ph,C.c3=function(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))},C.c4=Su,C.c5=function(r,t,i){var s=t[0],o=t[1],d=t[2],p=i[3]*s+i[7]*o+i[11]*d+i[15];return r[0]=(i[0]*s+i[4]*o+i[8]*d+i[12])/(p=p||1),r[1]=(i[1]*s+i[5]*o+i[9]*d+i[13])/p,r[2]=(i[2]*s+i[6]*o+i[10]*d+i[14])/p,r},C.c6=class extends tl{},C.c7=class extends b{},C.c8=function(r,t){return r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2]&&r[3]===t[3]&&r[4]===t[4]&&r[5]===t[5]&&r[6]===t[6]&&r[7]===t[7]&&r[8]===t[8]&&r[9]===t[9]&&r[10]===t[10]&&r[11]===t[11]&&r[12]===t[12]&&r[13]===t[13]&&r[14]===t[14]&&r[15]===t[15]},C.c9=function(r,t){var i=r[0],s=r[1],o=r[2],d=r[3],p=r[4],m=r[5],g=r[6],x=r[7],v=r[8],T=r[9],M=r[10],E=r[11],A=r[12],L=r[13],F=r[14],V=r[15],Q=t[0],W=t[1],X=t[2],ce=t[3],pe=t[4],xe=t[5],Ae=t[6],Pe=t[7],Ie=t[8],Be=t[9],Me=t[10],Ce=t[11],ge=t[12],$e=t[13],Ge=t[14],je=t[15];return Math.abs(i-Q)<=It*Math.max(1,Math.abs(i),Math.abs(Q))&&Math.abs(s-W)<=It*Math.max(1,Math.abs(s),Math.abs(W))&&Math.abs(o-X)<=It*Math.max(1,Math.abs(o),Math.abs(X))&&Math.abs(d-ce)<=It*Math.max(1,Math.abs(d),Math.abs(ce))&&Math.abs(p-pe)<=It*Math.max(1,Math.abs(p),Math.abs(pe))&&Math.abs(m-xe)<=It*Math.max(1,Math.abs(m),Math.abs(xe))&&Math.abs(g-Ae)<=It*Math.max(1,Math.abs(g),Math.abs(Ae))&&Math.abs(x-Pe)<=It*Math.max(1,Math.abs(x),Math.abs(Pe))&&Math.abs(v-Ie)<=It*Math.max(1,Math.abs(v),Math.abs(Ie))&&Math.abs(T-Be)<=It*Math.max(1,Math.abs(T),Math.abs(Be))&&Math.abs(M-Me)<=It*Math.max(1,Math.abs(M),Math.abs(Me))&&Math.abs(E-Ce)<=It*Math.max(1,Math.abs(E),Math.abs(Ce))&&Math.abs(A-ge)<=It*Math.max(1,Math.abs(A),Math.abs(ge))&&Math.abs(L-$e)<=It*Math.max(1,Math.abs(L),Math.abs($e))&&Math.abs(F-Ge)<=It*Math.max(1,Math.abs(F),Math.abs(Ge))&&Math.abs(V-je)<=It*Math.max(1,Math.abs(V),Math.abs(je))},C.cA=function(r,t){z.REGISTERED_PROTOCOLS[r]=t},C.cB=function(r){delete z.REGISTERED_PROTOCOLS[r]},C.cC=function(r,t){const i={};for(let o=0;o<r.length;o++){const d=t&&t[r[o].id]||dh(r[o]);t&&(t[r[o].id]=d);let p=i[d];p||(p=i[d]=[]),p.push(r[o])}const s=[];for(const o in i)s.push(i[o]);return s},C.cD=ze,C.cE=wd,C.cF=Pd,C.cG=ed,C.cH=function(r){r.bucket.createArrays(),r.bucket.tilePixelRatio=gt/(512*r.bucket.overscaling),r.bucket.compareText={},r.bucket.iconsNeedLinear=!1;const t=r.bucket.layers[0],i=t.layout,s=t._unevaluatedLayout._values,o={layoutIconSize:s["icon-size"].possiblyEvaluate(new wt(r.bucket.zoom+1),r.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new wt(r.bucket.zoom+1),r.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new wt(18))};if(r.bucket.textSizeData.kind==="composite"){const{minZoom:x,maxZoom:v}=r.bucket.textSizeData;o.compositeTextSizes=[s["text-size"].possiblyEvaluate(new wt(x),r.canonical),s["text-size"].possiblyEvaluate(new wt(v),r.canonical)]}if(r.bucket.iconSizeData.kind==="composite"){const{minZoom:x,maxZoom:v}=r.bucket.iconSizeData;o.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new wt(x),r.canonical),s["icon-size"].possiblyEvaluate(new wt(v),r.canonical)]}const d=i.get("text-line-height")*ni,p=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",m=i.get("text-keep-upright"),g=i.get("text-size");for(const x of r.bucket.features){const v=i.get("text-font").evaluate(x,{},r.canonical).join(","),T=g.evaluate(x,{},r.canonical),M=o.layoutTextSize.evaluate(x,{},r.canonical),E=o.layoutIconSize.evaluate(x,{},r.canonical),A={horizontal:{},vertical:void 0},L=x.text;let F,V=[0,0];if(L){const X=L.toString(),ce=i.get("text-letter-spacing").evaluate(x,{},r.canonical)*ni,pe=gh(X)?ce:0,xe=i.get("text-anchor").evaluate(x,{},r.canonical),Ae=Rd(t,x,r.canonical);if(!Ae){const Me=i.get("text-radial-offset").evaluate(x,{},r.canonical);V=Me?Dd(xe,[Me*ni,Wh]):i.get("text-offset").evaluate(x,{},r.canonical).map(Ce=>Ce*ni)}let Pe=p?"center":i.get("text-justify").evaluate(x,{},r.canonical);const Ie=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(x,{},r.canonical)*ni:1/0,Be=()=>{r.bucket.allowVerticalPlacement&&ja(X)&&(A.vertical=Mc(L,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ie,d,xe,"left",pe,V,C.ao.vertical,!0,M,T))};if(!p&&Ae){const Me=new Set;if(Pe==="auto")for(let ge=0;ge<Ae.values.length;ge+=2)Me.add(Hh(Ae.values[ge]));else Me.add(Pe);let Ce=!1;for(const ge of Me)if(!A.horizontal[ge])if(Ce)A.horizontal[ge]=A.horizontal[0];else{const $e=Mc(L,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ie,d,"center",ge,pe,V,C.ao.horizontal,!1,M,T);$e&&(A.horizontal[ge]=$e,Ce=$e.positionedLines.length===1)}Be()}else{Pe==="auto"&&(Pe=Hh(xe));const Me=Mc(L,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ie,d,xe,Pe,pe,V,C.ao.horizontal,!1,M,T);Me&&(A.horizontal[Pe]=Me),Be(),ja(X)&&p&&m&&(A.vertical=Mc(L,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ie,d,xe,Pe,pe,V,C.ao.vertical,!1,M,T))}}let Q=!1;if(x.icon&&x.icon.name){const X=r.imageMap[x.icon.name];X&&(F=Uf(r.imagePositions[x.icon.name],i.get("icon-offset").evaluate(x,{},r.canonical),i.get("icon-anchor").evaluate(x,{},r.canonical)),Q=!!X.sdf,r.bucket.sdfIcons===void 0?r.bucket.sdfIcons=Q:r.bucket.sdfIcons!==Q&&jt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(X.pixelRatio!==r.bucket.pixelRatio||i.get("icon-rotate").constantOr(1)!==0)&&(r.bucket.iconsNeedLinear=!0))}const W=Bd(A.horizontal)||A.vertical;r.bucket.iconsInText=!!W&&W.iconsInText,(W||F)&&nm(r.bucket,x,A,F,r.imageMap,o,M,E,V,Q,r.canonical,r.subdivisionGranularity)}r.showCollisionBoxes&&r.bucket.generateCollisionDebugBuffers()},C.cI=Lh,C.cJ=Ah,C.cK=zh,C.cL=Nu,C.cM=Rh,C.cN=class{constructor(r){this._marks={start:[r.url,"start"].join("#"),end:[r.url,"end"].join("#"),measure:r.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let r=performance.getEntriesByName(this._marks.measure);return r.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),r=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),r}},C.cO=function(r,t,i,s,o){return c(this,void 0,void 0,function*(){if(Ci())try{return yield $n(r,t,i,s,o)}catch{}return function(d,p,m,g,x){const v=d.width,T=d.height;Nr&&Vr||(Nr=new OffscreenCanvas(v,T),Vr=Nr.getContext("2d",{willReadFrequently:!0})),Nr.width=v,Nr.height=T,Vr.drawImage(d,0,0,v,T);const M=Vr.getImageData(p,m,g,x);return Vr.clearRect(0,0,v,T),M.data}(r,t,i,s,o)})},C.cP=Cu,C.cQ=ct,C.cR=ju,C.cS=Qa,C.cT=Vs,C.cU=function(r,t){const i=new Map;if(r!=null)if(r.type==="Feature")i.set(xl(r,t),r);else for(const s of r.features)i.set(xl(s,t),s);return i},C.cV=function(r,t){if(r==null)return!0;if(r.type==="Feature")return xl(r,t)!=null;if(r.type==="FeatureCollection"){const i=new Set;for(const s of r.features){const o=xl(s,t);if(o==null||i.has(o))return!1;i.add(o)}return!0}return!1},C.cW=function(r,t,i){var s,o,d,p;if(t.removeAll&&r.clear(),t.remove)for(const m of t.remove)r.delete(m);if(t.add)for(const m of t.add){const g=xl(m,i);g!=null&&r.set(g,m)}if(t.update)for(const m of t.update){let g=r.get(m.id);if(g==null)continue;const x=!m.removeAllProperties&&(((s=m.removeProperties)===null||s===void 0?void 0:s.length)>0||((o=m.addOrUpdateProperties)===null||o===void 0?void 0:o.length)>0);if((m.newGeometry||m.removeAllProperties||x)&&(g=Object.assign({},g),r.set(m.id,g),x&&(g.properties=Object.assign({},g.properties))),m.newGeometry&&(g.geometry=m.newGeometry),m.removeAllProperties)g.properties={};else if(((d=m.removeProperties)===null||d===void 0?void 0:d.length)>0)for(const v of m.removeProperties)Object.prototype.hasOwnProperty.call(g.properties,v)&&delete g.properties[v];if(((p=m.addOrUpdateProperties)===null||p===void 0?void 0:p.length)>0)for(const{key:v,value:T}of m.addOrUpdateProperties)g.properties[v]=T}},C.cX=sr,C.ca=function(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},C.cb=r=>r.type==="symbol",C.cc=r=>r.type==="circle",C.cd=r=>r.type==="heatmap",C.ce=r=>r.type==="line",C.cf=r=>r.type==="fill",C.cg=r=>r.type==="fill-extrusion",C.ch=r=>r.type==="hillshade",C.ci=r=>r.type==="color-relief",C.cj=r=>r.type==="raster",C.ck=r=>r.type==="background",C.cl=r=>r.type==="custom",C.cm=jr,C.cn=function(r,t,i){const s=la(t.x-i.x,t.y-i.y),o=la(r.x-i.x,r.y-i.y);var d,p;return $r(Math.atan2(s[0]*o[1]-s[1]*o[0],(d=s)[0]*(p=o)[0]+d[1]*p[1]))},C.co=fn,C.cp=function(r,t){return Gr[t]&&(r instanceof MouseEvent||r instanceof WheelEvent)},C.cq=function(r,t){return Zr[t]&&"touches"in r},C.cr=function(r){return Zr[r]||Gr[r]},C.cs=function(r,t,i){var s=t[0],o=t[1];return r[0]=i[0]*s+i[4]*o+i[12],r[1]=i[1]*s+i[5]*o+i[13],r},C.ct=function(r,t){const{x:i,y:s}=yl.fromLngLat(t);return!(r<0||r>25||s<0||s>=1||i<0||i>=1)},C.cu=function(r,t){return r[0]=t[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=t[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=t[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},C.cv=class extends us{},C.cw=am,C.cy=function(r){return r.message===Zn},C.cz=Z,C.d=le,C.e=Zi,C.f=r=>c(void 0,void 0,void 0,function*(){if(r.byteLength===0)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(r)],{type:"image/png"});try{return createImageBitmap(t)}catch(i){throw new Error(`Could not load image because of ${i.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),C.g=D,C.h=r=>new Promise((t,i)=>{const s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame(()=>{s.src=yr})},s.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new Blob([new Uint8Array(r)],{type:"image/png"});s.src=r.byteLength?URL.createObjectURL(o):yr}),C.i=gr,C.j=(r,t)=>ie(Zi(r,{type:"json"}),t),C.k=_e,C.l=ve,C.m=ie,C.n=(r,t)=>ie(Zi(r,{type:"arrayBuffer"}),t),C.o=function(r){return new Rh(r).readFields(kf,[])},C.p=Qu,C.q=ol,C.r=Pi,C.s=Ur,C.t=mc,C.u=st,C.v=ne,C.w=jt,C.x=ph,C.y=Hs,C.z=os}),Ve("worker",["./shared"],function(C){class c{constructor(z){this.keyCache={},z&&this.replace(z)}replace(z){this._layerConfigs={},this._layers={},this.update(z,[])}update(z,D){for(const Z of z){this._layerConfigs[Z.id]=Z;const Y=this._layers[Z.id]=C.bJ(Z);Y._featureFilter=C.aa(Y.filter),this.keyCache[Z.id]&&delete this.keyCache[Z.id]}for(const Z of D)delete this.keyCache[Z],delete this._layerConfigs[Z],delete this._layers[Z];this.familiesBySource={};const R=C.cC(Object.values(this._layerConfigs),this.keyCache);for(const Z of R){const Y=Z.map(_e=>this._layers[_e.id]),ie=Y[0];if(ie.visibility==="none")continue;const le=ie.source||"";let re=this.familiesBySource[le];re||(re=this.familiesBySource[le]={});const fe=ie.sourceLayer||"_geojsonTileLayer";let ve=re[fe];ve||(ve=re[fe]=[]),ve.push(Y)}}}class be{constructor(z){const D={},R=[];for(const le in z){const re=z[le],fe=D[le]={};for(const ve in re){const _e=re[+ve];if(!_e||_e.bitmap.width===0||_e.bitmap.height===0)continue;const Re={x:0,y:0,w:_e.bitmap.width+2,h:_e.bitmap.height+2};R.push(Re),fe[ve]={rect:Re,metrics:_e.metrics}}}const{w:Z,h:Y}=C.p(R),ie=new C.q({width:Z||1,height:Y||1});for(const le in z){const re=z[le];for(const fe in re){const ve=re[+fe];if(!ve||ve.bitmap.width===0||ve.bitmap.height===0)continue;const _e=D[le][fe].rect;C.q.copy(ve.bitmap,ie,{x:0,y:0},{x:_e.x+1,y:_e.y+1},ve.bitmap)}}this.image=ie,this.positions=D}}C.cD("GlyphAtlas",be);class ct{constructor(z){this.tileID=new C.Z(z.tileID.overscaledZ,z.tileID.wrap,z.tileID.canonical.z,z.tileID.canonical.x,z.tileID.canonical.y),this.uid=z.uid,this.zoom=z.zoom,this.pixelRatio=z.pixelRatio,this.tileSize=z.tileSize,this.source=z.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=z.showCollisionBoxes,this.collectResourceTiming=!!z.collectResourceTiming,this.returnDependencies=!!z.returnDependencies,this.promoteId=z.promoteId,this.inFlightDependencies=[],this.globalState=z.globalState}parse(z,D,R,Z,Y){return C._(this,void 0,void 0,function*(){this.status="parsing",this.data=z,this.collisionBoxArray=new C.a8;const ie=new C.cE(Object.keys(z.layers).sort()),le=new C.cF(this.tileID,this.promoteId);le.bucketLayerIDs=[];const re={},fe={featureIndex:le,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:R,subdivisionGranularity:Y},ve=D.familiesBySource[this.source];for(const rt in ve){const ot=z.layers[rt];if(!ot)continue;ot.version===1&&C.w(`Vector tile source "${this.source}" layer "${rt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Ut=ie.encode(rt),Te=[];for(let gi=0;gi<ot.length;gi++){const At=ot.feature(gi),qr=le.getId(At,rt);Te.push({feature:At,id:qr,index:gi,sourceLayerIndex:Ut})}for(const gi of ve[rt]){const At=gi[0];At.source!==this.source&&C.w(`layer.source = ${At.source} does not equal this.source = ${this.source}`),At.minzoom&&this.zoom<Math.floor(At.minzoom)||At.maxzoom&&this.zoom>=At.maxzoom||At.visibility!=="none"&&(ut(gi,this.zoom,R,this.globalState),(re[At.id]=At.createBucket({index:le.bucketLayerIDs.length,layers:gi,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ut,sourceID:this.source,globalState:this.globalState})).populate(Te,fe,this.tileID.canonical),le.bucketLayerIDs.push(gi.map(qr=>qr.id)))}}const _e=C.bN(fe.glyphDependencies,rt=>Object.keys(rt).map(Number));this.inFlightDependencies.forEach(rt=>rt==null?void 0:rt.abort()),this.inFlightDependencies=[];let Re=Promise.resolve({});if(Object.keys(_e).length){const rt=new AbortController;this.inFlightDependencies.push(rt),Re=Z.sendAsync({type:"GG",data:{stacks:_e,source:this.source,tileID:this.tileID,type:"glyphs"}},rt)}const ne=Object.keys(fe.iconDependencies);let qe=Promise.resolve({});if(ne.length){const rt=new AbortController;this.inFlightDependencies.push(rt),qe=Z.sendAsync({type:"GI",data:{icons:ne,source:this.source,tileID:this.tileID,type:"icons"}},rt)}const Qe=Object.keys(fe.patternDependencies);let Oe=Promise.resolve({});if(Qe.length){const rt=new AbortController;this.inFlightDependencies.push(rt),Oe=Z.sendAsync({type:"GI",data:{icons:Qe,source:this.source,tileID:this.tileID,type:"patterns"}},rt)}const[He,Tt,Ht]=yield Promise.all([Re,qe,Oe]),Xt=new be(He),Nt=new C.cG(Tt,Ht);for(const rt in re){const ot=re[rt];ot instanceof C.a9?(ut(ot.layers,this.zoom,R,this.globalState),C.cH({bucket:ot,glyphMap:He,glyphPositions:Xt.positions,imageMap:Tt,imagePositions:Nt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:fe.subdivisionGranularity})):ot.hasPattern&&(ot instanceof C.cI||ot instanceof C.cJ||ot instanceof C.cK)&&(ut(ot.layers,this.zoom,R,this.globalState),ot.addFeatures(fe,this.tileID.canonical,Nt.patternPositions))}return this.status="done",{buckets:Object.values(re).filter(rt=>!rt.isEmpty()),featureIndex:le,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Xt.image,imageAtlas:Nt,glyphMap:this.returnDependencies?He:null,iconMap:this.returnDependencies?Tt:null,glyphPositions:this.returnDependencies?Xt.positions:null}})}}function ut(ee,z,D,R){const Z=new C.F(z);for(const Y of ee)Y.setGlobalState(R),Y.recalculate(Z,D)}class pt{constructor(z,D,R){this.actor=z,this.layerIndex=D,this.availableImages=R,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(z,D){return C._(this,void 0,void 0,function*(){const R=yield C.n(z.request,D);try{return{vectorTile:new C.cL(new C.cM(R.data)),rawData:R.data,cacheControl:R.cacheControl,expires:R.expires}}catch(Z){const Y=new Uint8Array(R.data);let ie=`Unable to parse the tile at ${z.request.url}, `;throw ie+=Y[0]===31&&Y[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${Z.message}`,new Error(ie)}})}loadTile(z){return C._(this,void 0,void 0,function*(){const D=z.uid,R=!!(z&&z.request&&z.request.collectResourceTiming)&&new C.cN(z.request),Z=new ct(z);this.loading[D]=Z;const Y=new AbortController;Z.abort=Y;try{const ie=yield this.loadVectorTile(z,Y);if(delete this.loading[D],!ie)return null;const le=ie.rawData,re={};ie.expires&&(re.expires=ie.expires),ie.cacheControl&&(re.cacheControl=ie.cacheControl);const fe={};if(R){const _e=R.finish();_e&&(fe.resourceTiming=JSON.parse(JSON.stringify(_e)))}Z.vectorTile=ie.vectorTile;const ve=Z.parse(ie.vectorTile,this.layerIndex,this.availableImages,this.actor,z.subdivisionGranularity);this.loaded[D]=Z,this.fetching[D]={rawTileData:le,cacheControl:re,resourceTiming:fe};try{const _e=yield ve;return C.e({rawTileData:le.slice(0)},_e,re,fe)}finally{delete this.fetching[D]}}catch(ie){throw delete this.loading[D],Z.status="done",this.loaded[D]=Z,ie}})}reloadTile(z){return C._(this,void 0,void 0,function*(){const D=z.uid;if(!this.loaded||!this.loaded[D])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const R=this.loaded[D];if(R.showCollisionBoxes=z.showCollisionBoxes,R.globalState=z.globalState,R.status==="parsing"){const Z=yield R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor,z.subdivisionGranularity);let Y;if(this.fetching[D]){const{rawTileData:ie,cacheControl:le,resourceTiming:re}=this.fetching[D];delete this.fetching[D],Y=C.e({rawTileData:ie.slice(0)},Z,le,re)}else Y=Z;return Y}if(R.status==="done"&&R.vectorTile)return R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor,z.subdivisionGranularity)})}abortTile(z){return C._(this,void 0,void 0,function*(){const D=this.loading,R=z.uid;D&&D[R]&&D[R].abort&&(D[R].abort.abort(),delete D[R])})}removeTile(z){return C._(this,void 0,void 0,function*(){this.loaded&&this.loaded[z.uid]&&delete this.loaded[z.uid]})}}class Ee{constructor(){this.loaded={}}loadTile(z){return C._(this,void 0,void 0,function*(){const{uid:D,encoding:R,rawImageData:Z,redFactor:Y,greenFactor:ie,blueFactor:le,baseShift:re}=z,fe=Z.width+2,ve=Z.height+2,_e=C.b(Z)?new C.R({width:fe,height:ve},yield C.cO(Z,-1,-1,fe,ve)):Z,Re=new C.cP(D,_e,R,Y,ie,le,re);return this.loaded=this.loaded||{},this.loaded[D]=Re,Re})}removeTile(z){const D=this.loaded,R=z.uid;D&&D[R]&&delete D[R]}}var se,Mt,ei=function(){if(Mt)return se;function ee(D,R){if(D.length!==0){z(D[0],R);for(var Z=1;Z<D.length;Z++)z(D[Z],!R)}}function z(D,R){for(var Z=0,Y=0,ie=0,le=D.length,re=le-1;ie<le;re=ie++){var fe=(D[ie][0]-D[re][0])*(D[re][1]+D[ie][1]),ve=Z+fe;Y+=Math.abs(Z)>=Math.abs(fe)?Z-ve+fe:fe-ve+Z,Z=ve}Z+Y>=0!=!!R&&D.reverse()}return Mt=1,se=function D(R,Z){var Y,ie=R&&R.type;if(ie==="FeatureCollection")for(Y=0;Y<R.features.length;Y++)D(R.features[Y],Z);else if(ie==="GeometryCollection")for(Y=0;Y<R.geometries.length;Y++)D(R.geometries[Y],Z);else if(ie==="Feature")D(R.geometry,Z);else if(ie==="Polygon")ee(R.coordinates,Z);else if(ie==="MultiPolygon")for(Y=0;Y<R.coordinates.length;Y++)ee(R.coordinates[Y],Z);return R}}(),Ri=C.cQ(ei);class Ci extends C.cS{constructor(z,D){super(new C.cM,0,D,[],[]),this.feature=z,this.type=z.type,this.properties=z.tags?z.tags:{},"id"in z&&(typeof z.id=="string"?this.id=parseInt(z.id,10):typeof z.id!="number"||isNaN(z.id)||(this.id=z.id))}loadGeometry(){const z=[],D=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(const R of D){const Z=[];for(const Y of R)Z.push(new C.P(Y[0],Y[1]));z.push(Z)}return z}}class It extends C.cR{constructor(z,D){super(new C.cM),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=D?D.version:1,this.extent=D?D.extent:4096,this.length=z.length,this.features=z}feature(z){return new Ci(this.features[z],this.extent)}}function ft(ee,z){z.writeVarintField(15,ee.version||1),z.writeStringField(1,ee.name||""),z.writeVarintField(5,ee.extent||4096);const D={keys:[],values:[],keycache:{},valuecache:{}};for(let Y=0;Y<ee.length;Y++)D.feature=ee.feature(Y),z.writeMessage(2,Ot,D);const R=D.keys;for(const Y of R)z.writeStringField(3,Y);const Z=D.values;for(const Y of Z)z.writeMessage(4,Ts,Y)}function Ot(ee,z){if(!ee.feature)return;const D=ee.feature;D.id!==void 0&&z.writeVarintField(1,D.id),z.writeMessage(2,$i,ee),z.writeVarintField(3,D.type),z.writeMessage(4,oa,D)}function $i(ee,z){var D;for(const R in(D=ee.feature)==null?void 0:D.properties){let Z=ee.feature.properties[R],Y=ee.keycache[R];if(Z===null)continue;Y===void 0&&(ee.keys.push(R),Y=ee.keys.length-1,ee.keycache[R]=Y),z.writeVarint(Y),typeof Z!="string"&&typeof Z!="boolean"&&typeof Z!="number"&&(Z=JSON.stringify(Z));const ie=typeof Z+":"+Z;let le=ee.valuecache[ie];le===void 0&&(ee.values.push(Z),le=ee.values.length-1,ee.valuecache[ie]=le),z.writeVarint(le)}}function Sr(ee,z){return(z<<3)+(7&ee)}function jn(ee){return ee<<1^ee>>31}function oa(ee,z){const D=ee.loadGeometry(),R=ee.type;let Z=0,Y=0;for(const ie of D){let le=1;R===1&&(le=ie.length),z.writeVarint(Sr(1,le));const re=R===3?ie.length-1:ie.length;for(let fe=0;fe<re;fe++){fe===1&&R!==1&&z.writeVarint(Sr(2,re-1));const ve=ie[fe].x-Z,_e=ie[fe].y-Y;z.writeVarint(jn(ve)),z.writeVarint(jn(_e)),Z+=ve,Y+=_e}ee.type===3&&z.writeVarint(Sr(7,1))}}function Ts(ee,z){const D=typeof ee;D==="string"?z.writeStringField(1,ee):D==="boolean"?z.writeBooleanField(7,ee):D==="number"&&(ee%1!=0?z.writeDoubleField(3,ee):ee<0?z.writeSVarintField(6,ee):z.writeVarintField(5,ee))}const pr={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ee=>ee},Br=Math.fround||(fr=new Float32Array(1),ee=>(fr[0]=+ee,fr[0]));var fr;class Or{constructor(z){this.options=Object.assign(Object.create(pr),z),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(z){const{log:D,minZoom:R,maxZoom:Z}=this.options;D&&console.time("total time");const Y=`prepare ${z.length} points`;D&&console.time(Y),this.points=z;const ie=[];for(let re=0;re<z.length;re++){const fe=z[re];if(!fe.geometry)continue;const[ve,_e]=fe.geometry.coordinates,Re=Br(hn(ve)),ne=Br(un(_e));ie.push(Re,ne,1/0,re,-1,1),this.options.reduce&&ie.push(0)}let le=this.trees[Z+1]=this._createTree(ie);D&&console.timeEnd(Y);for(let re=Z;re>=R;re--){const fe=+Date.now();le=this.trees[re]=this._createTree(this._cluster(le,re)),D&&console.log("z%d: %d clusters in %dms",re,le.numItems,+Date.now()-fe)}return D&&console.timeEnd("total time"),this}getClusters(z,D){let R=((z[0]+180)%360+360)%360-180;const Z=Math.max(-90,Math.min(90,z[1]));let Y=z[2]===180?180:((z[2]+180)%360+360)%360-180;const ie=Math.max(-90,Math.min(90,z[3]));if(z[2]-z[0]>=360)R=-180,Y=180;else if(R>Y){const _e=this.getClusters([R,Z,180,ie],D),Re=this.getClusters([-180,Z,Y,ie],D);return _e.concat(Re)}const le=this.trees[this._limitZoom(D)],re=le.range(hn(R),un(ie),hn(Y),un(Z)),fe=le.data,ve=[];for(const _e of re){const Re=this.stride*_e;ve.push(fe[Re+5]>1?Ps(fe,Re,this.clusterProps):this.points[fe[Re+3]])}return ve}getChildren(z){const D=this._getOriginId(z),R=this._getOriginZoom(z),Z="No cluster with the specified id.",Y=this.trees[R];if(!Y)throw new Error(Z);const ie=Y.data;if(D*this.stride>=ie.length)throw new Error(Z);const le=this.options.radius/(this.options.extent*Math.pow(2,R-1)),re=Y.within(ie[D*this.stride],ie[D*this.stride+1],le),fe=[];for(const ve of re){const _e=ve*this.stride;ie[_e+4]===z&&fe.push(ie[_e+5]>1?Ps(ie,_e,this.clusterProps):this.points[ie[_e+3]])}if(fe.length===0)throw new Error(Z);return fe}getLeaves(z,D,R){const Z=[];return this._appendLeaves(Z,z,D=D||10,R=R||0,0),Z}getTile(z,D,R){const Z=this.trees[this._limitZoom(z)],Y=Math.pow(2,z),{extent:ie,radius:le}=this.options,re=le/ie,fe=(R-re)/Y,ve=(R+1+re)/Y,_e={features:[]};return this._addTileFeatures(Z.range((D-re)/Y,fe,(D+1+re)/Y,ve),Z.data,D,R,Y,_e),D===0&&this._addTileFeatures(Z.range(1-re/Y,fe,1,ve),Z.data,Y,R,Y,_e),D===Y-1&&this._addTileFeatures(Z.range(0,fe,re/Y,ve),Z.data,-1,R,Y,_e),_e.features.length?_e:null}getClusterExpansionZoom(z){let D=this._getOriginZoom(z)-1;for(;D<=this.options.maxZoom;){const R=this.getChildren(z);if(D++,R.length!==1)break;z=R[0].properties.cluster_id}return D}_appendLeaves(z,D,R,Z,Y){const ie=this.getChildren(D);for(const le of ie){const re=le.properties;if(re&&re.cluster?Y+re.point_count<=Z?Y+=re.point_count:Y=this._appendLeaves(z,re.cluster_id,R,Z,Y):Y<Z?Y++:z.push(le),z.length===R)break}return Y}_createTree(z){const D=new C.aI(z.length/this.stride|0,this.options.nodeSize,Float32Array);for(let R=0;R<z.length;R+=this.stride)D.add(z[R],z[R+1]);return D.finish(),D.data=z,D}_addTileFeatures(z,D,R,Z,Y,ie){for(const le of z){const re=le*this.stride,fe=D[re+5]>1;let ve,_e,Re;if(fe)ve=cn(D,re,this.clusterProps),_e=D[re],Re=D[re+1];else{const Qe=this.points[D[re+3]];ve=Qe.properties;const[Oe,He]=Qe.geometry.coordinates;_e=hn(Oe),Re=un(He)}const ne={type:1,geometry:[[Math.round(this.options.extent*(_e*Y-R)),Math.round(this.options.extent*(Re*Y-Z))]],tags:ve};let qe;qe=fe||this.options.generateId?D[re+3]:this.points[D[re+3]].id,qe!==void 0&&(ne.id=qe),ie.features.push(ne)}}_limitZoom(z){return Math.max(this.options.minZoom,Math.min(Math.floor(+z),this.options.maxZoom+1))}_cluster(z,D){const{radius:R,extent:Z,reduce:Y,minPoints:ie}=this.options,le=R/(Z*Math.pow(2,D)),re=z.data,fe=[],ve=this.stride;for(let _e=0;_e<re.length;_e+=ve){if(re[_e+2]<=D)continue;re[_e+2]=D;const Re=re[_e],ne=re[_e+1],qe=z.within(re[_e],re[_e+1],le),Qe=re[_e+5];let Oe=Qe;for(const He of qe){const Tt=He*ve;re[Tt+2]>D&&(Oe+=re[Tt+5])}if(Oe>Qe&&Oe>=ie){let He,Tt=Re*Qe,Ht=ne*Qe,Xt=-1;const Nt=(_e/ve<<5)+(D+1)+this.points.length;for(const rt of qe){const ot=rt*ve;if(re[ot+2]<=D)continue;re[ot+2]=D;const Ut=re[ot+5];Tt+=re[ot]*Ut,Ht+=re[ot+1]*Ut,re[ot+4]=Nt,Y&&(He||(He=this._map(re,_e,!0),Xt=this.clusterProps.length,this.clusterProps.push(He)),Y(He,this._map(re,ot)))}re[_e+4]=Nt,fe.push(Tt/Oe,Ht/Oe,1/0,Nt,-1,Oe),Y&&fe.push(Xt)}else{for(let He=0;He<ve;He++)fe.push(re[_e+He]);if(Oe>1)for(const He of qe){const Tt=He*ve;if(!(re[Tt+2]<=D)){re[Tt+2]=D;for(let Ht=0;Ht<ve;Ht++)fe.push(re[Tt+Ht])}}}}return fe}_getOriginId(z){return z-this.points.length>>5}_getOriginZoom(z){return(z-this.points.length)%32}_map(z,D,R){if(z[D+5]>1){const ie=this.clusterProps[z[D+6]];return R?Object.assign({},ie):ie}const Z=this.points[z[D+3]].properties,Y=this.options.map(Z);return R&&Y===Z?Object.assign({},Y):Y}}function Ps(ee,z,D){return{type:"Feature",id:ee[z+3],properties:cn(ee,z,D),geometry:{type:"Point",coordinates:[(R=ee[z],360*(R-.5)),la(ee[z+1])]}};var R}function cn(ee,z,D){const R=ee[z+5],Z=R>=1e4?`${Math.round(R/1e3)}k`:R>=1e3?Math.round(R/100)/10+"k":R,Y=ee[z+6],ie=Y===-1?{}:Object.assign({},D[Y]);return Object.assign(ie,{cluster:!0,cluster_id:ee[z+3],point_count:R,point_count_abbreviated:Z})}function hn(ee){return ee/360+.5}function un(ee){const z=Math.sin(ee*Math.PI/180),D=.5-.25*Math.log((1+z)/(1-z))/Math.PI;return D<0?0:D>1?1:D}function la(ee){const z=(180-360*ee)*Math.PI/180;return 360*Math.atan(Math.exp(z))/Math.PI-90}function gt(ee,z,D,R){let Z=R;const Y=z+(D-z>>1);let ie,le=D-z;const re=ee[z],fe=ee[z+1],ve=ee[D],_e=ee[D+1];for(let Re=z+3;Re<D;Re+=3){const ne=dn(ee[Re],ee[Re+1],re,fe,ve,_e);if(ne>Z)ie=Re,Z=ne;else if(ne===Z){const qe=Math.abs(Re-Y);qe<le&&(ie=Re,le=qe)}}Z>R&&(ie-z>3&&gt(ee,z,ie,R),ee[ie+2]=Z,D-ie>3&&gt(ee,ie,D,R))}function dn(ee,z,D,R,Z,Y){let ie=Z-D,le=Y-R;if(ie!==0||le!==0){const re=((ee-D)*ie+(z-R)*le)/(ie*ie+le*le);re>1?(D=Z,R=Y):re>0&&(D+=ie*re,R+=le*re)}return ie=ee-D,le=z-R,ie*ie+le*le}function mi(ee,z,D,R){const Z={id:ee??null,type:z,geometry:D,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(z==="Point"||z==="MultiPoint"||z==="LineString")pn(Z,D);else if(z==="Polygon")pn(Z,D[0]);else if(z==="MultiLineString")for(const Y of D)pn(Z,Y);else if(z==="MultiPolygon")for(const Y of D)pn(Z,Y[0]);return Z}function pn(ee,z){for(let D=0;D<z.length;D+=3)ee.minX=Math.min(ee.minX,z[D]),ee.minY=Math.min(ee.minY,z[D+1]),ee.maxX=Math.max(ee.maxX,z[D]),ee.maxY=Math.max(ee.maxY,z[D+1])}function mr(ee,z,D,R){if(!z.geometry)return;const Z=z.geometry.coordinates;if(Z&&Z.length===0)return;const Y=z.geometry.type,ie=Math.pow(D.tolerance/((1<<D.maxZoom)*D.extent),2);let le=[],re=z.id;if(D.promoteId?re=z.properties[D.promoteId]:D.generateId&&(re=R||0),Y==="Point")jr(Z,le);else if(Y==="MultiPoint")for(const fe of Z)jr(fe,le);else if(Y==="LineString")fn(Z,le,ie,!1);else if(Y==="MultiLineString"){if(D.lineMetrics){for(const fe of Z)le=[],fn(fe,le,ie,!1),ee.push(mi(re,"LineString",le,z.properties));return}Ei(Z,le,ie,!1)}else if(Y==="Polygon")Ei(Z,le,ie,!0);else{if(Y!=="MultiPolygon"){if(Y==="GeometryCollection"){for(const fe of z.geometry.geometries)mr(ee,{id:re,geometry:fe,properties:z.properties},D,R);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const fe of Z){const ve=[];Ei(fe,ve,ie,!0),le.push(ve)}}ee.push(mi(re,Y,le,z.properties))}function jr(ee,z){z.push(Nn(ee[0]),Zi(ee[1]),0)}function fn(ee,z,D,R){let Z,Y,ie=0;for(let re=0;re<ee.length;re++){const fe=Nn(ee[re][0]),ve=Zi(ee[re][1]);z.push(fe,ve,0),re>0&&(ie+=R?(Z*ve-fe*Y)/2:Math.sqrt(Math.pow(fe-Z,2)+Math.pow(ve-Y,2))),Z=fe,Y=ve}const le=z.length-3;z[2]=1,gt(z,0,le,D),z[le+2]=1,z.size=Math.abs(ie),z.start=0,z.end=z.size}function Ei(ee,z,D,R){for(let Z=0;Z<ee.length;Z++){const Y=[];fn(ee[Z],Y,D,R),z.push(Y)}}function Nn(ee){return ee/360+.5}function Zi(ee){const z=Math.sin(ee*Math.PI/180),D=.5-.25*Math.log((1+z)/(1-z))/Math.PI;return D<0?0:D>1?1:D}function Yi(ee,z,D,R,Z,Y,ie,le){if(R/=z,Y>=(D/=z)&&ie<R)return ee;if(ie<D||Y>=R)return null;const re=[];for(const fe of ee){const ve=fe.geometry;let _e=fe.type;const Re=Z===0?fe.minX:fe.minY,ne=Z===0?fe.maxX:fe.maxY;if(Re>=D&&ne<R){re.push(fe);continue}if(ne<D||Re>=R)continue;let qe=[];if(_e==="Point"||_e==="MultiPoint")Vn(ve,qe,D,R,Z);else if(_e==="LineString")Un(ve,qe,D,R,Z,!1,le.lineMetrics);else if(_e==="MultiLineString")Dt(ve,qe,D,R,Z,!1);else if(_e==="Polygon")Dt(ve,qe,D,R,Z,!0);else if(_e==="MultiPolygon")for(const Qe of ve){const Oe=[];Dt(Qe,Oe,D,R,Z,!0),Oe.length&&qe.push(Oe)}if(qe.length){if(le.lineMetrics&&_e==="LineString"){for(const Qe of qe)re.push(mi(fe.id,_e,Qe,fe.tags));continue}_e!=="LineString"&&_e!=="MultiLineString"||(qe.length===1?(_e="LineString",qe=qe[0]):_e="MultiLineString"),_e!=="Point"&&_e!=="MultiPoint"||(_e=qe.length===3?"Point":"MultiPoint"),re.push(mi(fe.id,_e,qe,fe.tags))}}return re.length?re:null}function Vn(ee,z,D,R,Z){for(let Y=0;Y<ee.length;Y+=3){const ie=ee[Y+Z];ie>=D&&ie<=R&&jt(z,ee[Y],ee[Y+1],ee[Y+2])}}function Un(ee,z,D,R,Z,Y,ie){let le=Fi(ee);const re=Z===0?Ki:gr;let fe,ve,_e=ee.start;for(let Oe=0;Oe<ee.length-3;Oe+=3){const He=ee[Oe],Tt=ee[Oe+1],Ht=ee[Oe+2],Xt=ee[Oe+3],Nt=ee[Oe+4],rt=Z===0?He:Tt,ot=Z===0?Xt:Nt;let Ut=!1;ie&&(fe=Math.sqrt(Math.pow(He-Xt,2)+Math.pow(Tt-Nt,2))),rt<D?ot>D&&(ve=re(le,He,Tt,Xt,Nt,D),ie&&(le.start=_e+fe*ve)):rt>R?ot<R&&(ve=re(le,He,Tt,Xt,Nt,R),ie&&(le.start=_e+fe*ve)):jt(le,He,Tt,Ht),ot<D&&rt>=D&&(ve=re(le,He,Tt,Xt,Nt,D),Ut=!0),ot>R&&rt<=R&&(ve=re(le,He,Tt,Xt,Nt,R),Ut=!0),!Y&&Ut&&(ie&&(le.end=_e+fe*ve),z.push(le),le=Fi(ee)),ie&&(_e+=fe)}let Re=ee.length-3;const ne=ee[Re],qe=ee[Re+1],Qe=Z===0?ne:qe;Qe>=D&&Qe<=R&&jt(le,ne,qe,ee[Re+2]),Re=le.length-3,Y&&Re>=3&&(le[Re]!==le[0]||le[Re+1]!==le[1])&&jt(le,le[0],le[1],le[2]),le.length&&z.push(le)}function Fi(ee){const z=[];return z.size=ee.size,z.start=ee.start,z.end=ee.end,z}function Dt(ee,z,D,R,Z,Y){for(const ie of ee)Un(ie,z,D,R,Z,Y,!1)}function jt(ee,z,D,R){ee.push(z,D,R)}function Ki(ee,z,D,R,Z,Y){const ie=(Y-z)/(R-z);return jt(ee,Y,D+(Z-D)*ie,1),ie}function gr(ee,z,D,R,Z,Y){const ie=(Y-D)/(Z-D);return jt(ee,z+(R-z)*ie,Y,1),ie}function mn(ee,z){const D=[];for(let R=0;R<ee.length;R++){const Z=ee[R],Y=Z.type;let ie;if(Y==="Point"||Y==="MultiPoint"||Y==="LineString")ie=_r(Z.geometry,z);else if(Y==="MultiLineString"||Y==="Polygon"){ie=[];for(const le of Z.geometry)ie.push(_r(le,z))}else if(Y==="MultiPolygon"){ie=[];for(const le of Z.geometry){const re=[];for(const fe of le)re.push(_r(fe,z));ie.push(re)}}D.push(mi(Z.id,Y,ie,Z.tags))}return D}function _r(ee,z){const D=[];D.size=ee.size,ee.start!==void 0&&(D.start=ee.start,D.end=ee.end);for(let R=0;R<ee.length;R+=3)D.push(ee[R]+z,ee[R+1],ee[R+2]);return D}function yr(ee,z){if(ee.transformed)return ee;const D=1<<ee.z,R=ee.x,Z=ee.y;for(const Y of ee.features){const ie=Y.geometry,le=Y.type;if(Y.geometry=[],le===1)for(let re=0;re<ie.length;re+=2)Y.geometry.push($n(ie[re],ie[re+1],z,D,R,Z));else for(let re=0;re<ie.length;re++){const fe=[];for(let ve=0;ve<ie[re].length;ve+=2)fe.push($n(ie[re][ve],ie[re][ve+1],z,D,R,Z));Y.geometry.push(fe)}}return ee.transformed=!0,ee}function $n(ee,z,D,R,Z,Y){return[Math.round(D*(ee*R-Z)),Math.round(D*(z*R-Y))]}function Nr(ee,z,D,R,Z){const Y=z===Z.maxZoom?0:Z.tolerance/((1<<z)*Z.extent),ie={features:[],numPoints:0,numSimplified:0,numFeatures:ee.length,source:null,x:D,y:R,z,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const le of ee)Vr(ie,le,Y,Z);return ie}function Vr(ee,z,D,R){const Z=z.geometry,Y=z.type,ie=[];if(ee.minX=Math.min(ee.minX,z.minX),ee.minY=Math.min(ee.minY,z.minY),ee.maxX=Math.max(ee.maxX,z.maxX),ee.maxY=Math.max(ee.maxY,z.maxY),Y==="Point"||Y==="MultiPoint")for(let le=0;le<Z.length;le+=3)ie.push(Z[le],Z[le+1]),ee.numPoints++,ee.numSimplified++;else if(Y==="LineString")Ur(ie,Z,ee,D,!1,!1);else if(Y==="MultiLineString"||Y==="Polygon")for(let le=0;le<Z.length;le++)Ur(ie,Z[le],ee,D,Y==="Polygon",le===0);else if(Y==="MultiPolygon")for(let le=0;le<Z.length;le++){const re=Z[le];for(let fe=0;fe<re.length;fe++)Ur(ie,re[fe],ee,D,!0,fe===0)}if(ie.length){let le=z.tags||null;if(Y==="LineString"&&R.lineMetrics){le={};for(const fe in z.tags)le[fe]=z.tags[fe];le.mapbox_clip_start=Z.start/Z.size,le.mapbox_clip_end=Z.end/Z.size}const re={geometry:ie,type:Y==="Polygon"||Y==="MultiPolygon"?3:Y==="LineString"||Y==="MultiLineString"?2:1,tags:le};z.id!==null&&(re.id=z.id),ee.features.push(re)}}function Ur(ee,z,D,R,Z,Y){const ie=R*R;if(R>0&&z.size<(Z?ie:R))return void(D.numPoints+=z.length/3);const le=[];for(let re=0;re<z.length;re+=3)(R===0||z[re+2]>ie)&&(D.numSimplified++,le.push(z[re],z[re+1])),D.numPoints++;Z&&function(re,fe){let ve=0;for(let _e=0,Re=re.length,ne=Re-2;_e<Re;ne=_e,_e+=2)ve+=(re[_e]-re[ne])*(re[_e+1]+re[ne+1]);if(ve>0===fe)for(let _e=0,Re=re.length;_e<Re/2;_e+=2){const ne=re[_e],qe=re[_e+1];re[_e]=re[Re-2-_e],re[_e+1]=re[Re-1-_e],re[Re-2-_e]=ne,re[Re-1-_e]=qe}}(le,Y),ee.push(le)}const gn={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class $r{constructor(z,D){const R=(D=this.options=function(Y,ie){for(const le in ie)Y[le]=ie[le];return Y}(Object.create(gn),D)).debug;if(R&&console.time("preprocess data"),D.maxZoom<0||D.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(D.promoteId&&D.generateId)throw new Error("promoteId and generateId cannot be used together.");let Z=function(Y,ie){const le=[];if(Y.type==="FeatureCollection")for(let re=0;re<Y.features.length;re++)mr(le,Y.features[re],ie,re);else mr(le,Y.type==="Feature"?Y:{geometry:Y},ie);return le}(z,D);this.tiles={},this.tileCoords=[],R&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",D.indexMaxZoom,D.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),Z=function(Y,ie){const le=ie.buffer/ie.extent;let re=Y;const fe=Yi(Y,1,-1-le,le,0,-1,2,ie),ve=Yi(Y,1,1-le,2+le,0,-1,2,ie);return(fe||ve)&&(re=Yi(Y,1,-le,1+le,0,-1,2,ie)||[],fe&&(re=mn(fe,1).concat(re)),ve&&(re=re.concat(mn(ve,-1)))),re}(Z,D),Z.length&&this.splitTile(Z,0,0,0),R&&(Z.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(z,D,R,Z,Y,ie,le){const re=[z,D,R,Z],fe=this.options,ve=fe.debug;for(;re.length;){Z=re.pop(),R=re.pop(),D=re.pop(),z=re.pop();const _e=1<<D,Re=Zr(D,R,Z);let ne=this.tiles[Re];if(!ne&&(ve>1&&console.time("creation"),ne=this.tiles[Re]=Nr(z,D,R,Z,fe),this.tileCoords.push({z:D,x:R,y:Z}),ve)){ve>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",D,R,Z,ne.numFeatures,ne.numPoints,ne.numSimplified),console.timeEnd("creation"));const Ut=`z${D}`;this.stats[Ut]=(this.stats[Ut]||0)+1,this.total++}if(ne.source=z,Y==null){if(D===fe.indexMaxZoom||ne.numPoints<=fe.indexMaxPoints)continue}else{if(D===fe.maxZoom||D===Y)continue;if(Y!=null){const Ut=Y-D;if(R!==ie>>Ut||Z!==le>>Ut)continue}}if(ne.source=null,z.length===0)continue;ve>1&&console.time("clipping");const qe=.5*fe.buffer/fe.extent,Qe=.5-qe,Oe=.5+qe,He=1+qe;let Tt=null,Ht=null,Xt=null,Nt=null,rt=Yi(z,_e,R-qe,R+Oe,0,ne.minX,ne.maxX,fe),ot=Yi(z,_e,R+Qe,R+He,0,ne.minX,ne.maxX,fe);z=null,rt&&(Tt=Yi(rt,_e,Z-qe,Z+Oe,1,ne.minY,ne.maxY,fe),Ht=Yi(rt,_e,Z+Qe,Z+He,1,ne.minY,ne.maxY,fe),rt=null),ot&&(Xt=Yi(ot,_e,Z-qe,Z+Oe,1,ne.minY,ne.maxY,fe),Nt=Yi(ot,_e,Z+Qe,Z+He,1,ne.minY,ne.maxY,fe),ot=null),ve>1&&console.timeEnd("clipping"),re.push(Tt||[],D+1,2*R,2*Z),re.push(Ht||[],D+1,2*R,2*Z+1),re.push(Xt||[],D+1,2*R+1,2*Z),re.push(Nt||[],D+1,2*R+1,2*Z+1)}}getTile(z,D,R){z=+z,D=+D,R=+R;const Z=this.options,{extent:Y,debug:ie}=Z;if(z<0||z>24)return null;const le=1<<z,re=Zr(z,D=D+le&le-1,R);if(this.tiles[re])return yr(this.tiles[re],Y);ie>1&&console.log("drilling down to z%d-%d-%d",z,D,R);let fe,ve=z,_e=D,Re=R;for(;!fe&&ve>0;)ve--,_e>>=1,Re>>=1,fe=this.tiles[Zr(ve,_e,Re)];return fe&&fe.source?(ie>1&&(console.log("found parent tile z%d-%d-%d",ve,_e,Re),console.time("drilling down")),this.splitTile(fe.source,ve,_e,Re,z,D,R),ie>1&&console.timeEnd("drilling down"),this.tiles[re]?yr(this.tiles[re],Y):null):null}}function Zr(ee,z,D){return 32*((1<<ee)*D+z)+ee}class Gr extends pt{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(z,D){return C._(this,void 0,void 0,function*(){const R=z.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const Z=this._geoJSONIndex.getTile(R.z,R.x,R.y);if(!Z)return null;const Y=new It(Z.features,{version:2,extent:C.$});let ie=function(le){const re=new C.cM;return function(fe,ve){for(const _e in fe.layers)ve.writeMessage(3,ft,fe.layers[_e])}(le,re),re.finish()}(Y);return ie.byteOffset===0&&ie.byteLength===ie.buffer.byteLength||(ie=new Uint8Array(ie)),{vectorTile:Y,rawData:ie.buffer}})}loadData(z){return C._(this,void 0,void 0,function*(){var D;(D=this._pendingRequest)===null||D===void 0||D.abort();const R=!!(z&&z.request&&z.request.collectResourceTiming)&&new C.cN(z.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(z,this._pendingRequest);const Z=yield this._pendingData;this._geoJSONIndex=z.cluster?new Or(function({superclusterOptions:ie,clusterProperties:le}){if(!le||!ie)return ie;const re={},fe={},ve={accumulated:null,zoom:0},_e={properties:null},Re=Object.keys(le);for(const ne of Re){const[qe,Qe]=le[ne],Oe=C.cT(Qe),He=C.cT(typeof qe=="string"?[qe,["accumulated"],["get",ne]]:qe);re[ne]=Oe.value,fe[ne]=He.value}return ie.map=ne=>{_e.properties=ne;const qe={};for(const Qe of Re)qe[Qe]=re[Qe].evaluate(ve,_e);return qe},ie.reduce=(ne,qe)=>{_e.properties=qe;for(const Qe of Re)ve.accumulated=ne[Qe],ne[Qe]=fe[Qe].evaluate(ve,_e)},ie}(z)).load(Z.features):function(ie,le){return new $r(ie,le)}(Z,z.geojsonVtOptions),this.loaded={};const Y={data:Z};if(R){const ie=R.finish();ie&&(Y.resourceTiming={},Y.resourceTiming[z.source]=JSON.parse(JSON.stringify(ie)))}return Y}catch(Z){if(delete this._pendingRequest,C.cy(Z))return{abandoned:!0};throw Z}})}getData(){return C._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(z){const D=this.loaded;return D&&D[z.uid]?super.reloadTile(z):this.loadTile(z)}loadAndProcessGeoJSON(z,D){return C._(this,void 0,void 0,function*(){let R=yield this.loadGeoJSON(z,D);if(delete this._pendingRequest,typeof R!="object")throw new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`);if(Ri(R,!0),z.filter){const Z=C.cT(z.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Z.result==="error")throw new Error(Z.value.map(ie=>`${ie.key}: ${ie.message}`).join(", "));R={type:"FeatureCollection",features:R.features.filter(ie=>Z.value.evaluate({zoom:0},ie))}}return R})}loadGeoJSON(z,D){return C._(this,void 0,void 0,function*(){const{promoteId:R}=z;if(z.request){const Z=yield C.j(z.request,D);return this._dataUpdateable=C.cV(Z.data,R)?C.cU(Z.data,R):void 0,Z.data}if(typeof z.data=="string")try{const Z=JSON.parse(z.data);return this._dataUpdateable=C.cV(Z,R)?C.cU(Z,R):void 0,Z}catch{throw new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`)}if(!z.dataDiff)throw new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${z.source}`);return C.cW(this._dataUpdateable,z.dataDiff,R),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(z){return C._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(z){return this._geoJSONIndex.getClusterExpansionZoom(z.clusterId)}getClusterChildren(z){return this._geoJSONIndex.getChildren(z.clusterId)}getClusterLeaves(z){return this._geoJSONIndex.getLeaves(z.clusterId,z.limit,z.offset)}}class Zn{constructor(z){this.self=z,this.actor=new C.J(z),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(D,R)=>{if(this.externalWorkerSourceTypes[D])throw new Error(`Worker source with name "${D}" already registered.`);this.externalWorkerSourceTypes[D]=R},this.self.addProtocol=C.cA,this.self.removeProtocol=C.cB,this.self.registerRTLTextPlugin=D=>{C.cX.setMethods(D)},this.actor.registerMessageHandler("LDT",(D,R)=>this._getDEMWorkerSource(D,R.source).loadTile(R)),this.actor.registerMessageHandler("RDT",(D,R)=>C._(this,void 0,void 0,function*(){this._getDEMWorkerSource(D,R.source).removeTile(R)})),this.actor.registerMessageHandler("GCEZ",(D,R)=>C._(this,void 0,void 0,function*(){return this._getWorkerSource(D,R.type,R.source).getClusterExpansionZoom(R)})),this.actor.registerMessageHandler("GCC",(D,R)=>C._(this,void 0,void 0,function*(){return this._getWorkerSource(D,R.type,R.source).getClusterChildren(R)})),this.actor.registerMessageHandler("GCL",(D,R)=>C._(this,void 0,void 0,function*(){return this._getWorkerSource(D,R.type,R.source).getClusterLeaves(R)})),this.actor.registerMessageHandler("LD",(D,R)=>this._getWorkerSource(D,R.type,R.source).loadData(R)),this.actor.registerMessageHandler("GD",(D,R)=>this._getWorkerSource(D,R.type,R.source).getData()),this.actor.registerMessageHandler("LT",(D,R)=>this._getWorkerSource(D,R.type,R.source).loadTile(R)),this.actor.registerMessageHandler("RT",(D,R)=>this._getWorkerSource(D,R.type,R.source).reloadTile(R)),this.actor.registerMessageHandler("AT",(D,R)=>this._getWorkerSource(D,R.type,R.source).abortTile(R)),this.actor.registerMessageHandler("RMT",(D,R)=>this._getWorkerSource(D,R.type,R.source).removeTile(R)),this.actor.registerMessageHandler("RS",(D,R)=>C._(this,void 0,void 0,function*(){if(!this.workerSources[D]||!this.workerSources[D][R.type]||!this.workerSources[D][R.type][R.source])return;const Z=this.workerSources[D][R.type][R.source];delete this.workerSources[D][R.type][R.source],Z.removeSource!==void 0&&Z.removeSource(R)})),this.actor.registerMessageHandler("RM",D=>C._(this,void 0,void 0,function*(){delete this.layerIndexes[D],delete this.availableImages[D],delete this.workerSources[D],delete this.demWorkerSources[D]})),this.actor.registerMessageHandler("SR",(D,R)=>C._(this,void 0,void 0,function*(){this.referrer=R})),this.actor.registerMessageHandler("SRPS",(D,R)=>this._syncRTLPluginState(D,R)),this.actor.registerMessageHandler("IS",(D,R)=>C._(this,void 0,void 0,function*(){this.self.importScripts(R)})),this.actor.registerMessageHandler("SI",(D,R)=>this._setImages(D,R)),this.actor.registerMessageHandler("UL",(D,R)=>C._(this,void 0,void 0,function*(){this._getLayerIndex(D).update(R.layers,R.removedIds)})),this.actor.registerMessageHandler("SL",(D,R)=>C._(this,void 0,void 0,function*(){this._getLayerIndex(D).replace(R)}))}_setImages(z,D){return C._(this,void 0,void 0,function*(){this.availableImages[z]=D;for(const R in this.workerSources[z]){const Z=this.workerSources[z][R];for(const Y in Z)Z[Y].availableImages=D}})}_syncRTLPluginState(z,D){return C._(this,void 0,void 0,function*(){return yield C.cX.syncState(D,this.self.importScripts)})}_getAvailableImages(z){let D=this.availableImages[z];return D||(D=[]),D}_getLayerIndex(z){let D=this.layerIndexes[z];return D||(D=this.layerIndexes[z]=new c),D}_getWorkerSource(z,D,R){if(this.workerSources[z]||(this.workerSources[z]={}),this.workerSources[z][D]||(this.workerSources[z][D]={}),!this.workerSources[z][D][R]){const Z={sendAsync:(Y,ie)=>(Y.targetMapId=z,this.actor.sendAsync(Y,ie))};switch(D){case"vector":this.workerSources[z][D][R]=new pt(Z,this._getLayerIndex(z),this._getAvailableImages(z));break;case"geojson":this.workerSources[z][D][R]=new Gr(Z,this._getLayerIndex(z),this._getAvailableImages(z));break;default:this.workerSources[z][D][R]=new this.externalWorkerSourceTypes[D](Z,this._getLayerIndex(z),this._getAvailableImages(z))}}return this.workerSources[z][D][R]}_getDEMWorkerSource(z,D){return this.demWorkerSources[z]||(this.demWorkerSources[z]={}),this.demWorkerSources[z][D]||(this.demWorkerSources[z][D]=new Ee),this.demWorkerSources[z][D]}}return C.i(self)&&(self.worker=new Zn(self)),Zn}),Ve("index",["exports","./shared"],function(C,c){var be="5.7.1";function ct(){var h=new c.A(4);return c.A!=Float32Array&&(h[1]=0,h[2]=0),h[0]=1,h[3]=1,h}let ut,pt;const Ee={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(h,e,n){const a=requestAnimationFrame(u=>{l(),e(u)}),{unsubscribe:l}=c.s(h.signal,"abort",()=>{l(),cancelAnimationFrame(a),n(c.c())},!1)},frameAsync(h){return new Promise((e,n)=>{this.frame(h,e,n)})},getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){const e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>(ut||(ut=document.createElement("a")),ut.href=h,ut.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(pt==null&&(pt=matchMedia("(prefers-reduced-motion: reduce)")),pt.matches)}};class se{static testProp(e){if(!se.docStyle)return e[0];for(let n=0;n<e.length;n++)if(e[n]in se.docStyle)return e[n];return e[0]}static create(e,n,a){const l=window.document.createElement(e);return n!==void 0&&(l.className=n),a&&a.appendChild(l),l}static createNS(e,n){return window.document.createElementNS(e,n)}static disableDrag(){se.docStyle&&se.selectProp&&(se.userSelect=se.docStyle[se.selectProp],se.docStyle[se.selectProp]="none")}static enableDrag(){se.docStyle&&se.selectProp&&(se.docStyle[se.selectProp]=se.userSelect)}static setTransform(e,n){e.style[se.transformProp]=n}static addEventListener(e,n,a,l={}){e.addEventListener(n,a,"passive"in l?l:l.capture)}static removeEventListener(e,n,a,l={}){e.removeEventListener(n,a,"passive"in l?l:l.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",se.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",se.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",se.suppressClickInternal,!0)},0)}static getScale(e){const n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,a){const l=n.boundingClientRect;return new c.P((a.clientX-l.left)/n.x-e.clientLeft,(a.clientY-l.top)/n.y-e.clientTop)}static mousePos(e,n){const a=se.getScale(e);return se.getPoint(e,a,n)}static touchPos(e,n){const a=[],l=se.getScale(e);for(let u=0;u<n.length;u++)a.push(se.getPoint(e,l,n[u]));return a}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}static sanitize(e){const n=new DOMParser().parseFromString(e,"text/html").body||document.createElement("body"),a=n.querySelectorAll("script");for(const l of a)l.remove();return se.clean(n),n.innerHTML}static isPossiblyDangerous(e,n){const a=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!a.includes("javascript:")&&!a.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const n=e.children;for(const a of n)se.removeAttributes(a),se.clean(a)}static removeAttributes(e){for(const{name:n,value:a}of e.attributes)se.isPossiblyDangerous(n,a)&&e.removeAttribute(n)}}se.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,se.selectProp=se.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),se.transformProp=se.testProp(["transform","WebkitTransform"]);const Mt={supported:!1,testSupport:function(h){!Ci&&Ri&&(It?ft(h):ei=h)}};let ei,Ri,Ci=!1,It=!1;function ft(h){const e=h.createTexture();h.bindTexture(h.TEXTURE_2D,e);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,Ri),h.isContextLost())return;Mt.supported=!0}catch{}h.deleteTexture(e),Ci=!0}var Ot;typeof document<"u"&&(Ri=document.createElement("img"),Ri.onload=()=>{ei&&ft(ei),ei=null,It=!0},Ri.onerror=()=>{Ci=!0,ei=null},Ri.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(h){let e,n,a,l;h.resetRequestQueue=()=>{e=[],n=0,a=0,l={}},h.addThrottleControl=y=>{const b=a++;return l[b]=y,b},h.removeThrottleControl=y=>{delete l[y],f()},h.getImage=(y,b,w=!0)=>new Promise((S,P)=>{Mt.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),c.e(y,{type:"image"}),e.push({abortController:b,requestParameters:y,supportImageRefresh:w,state:"queued",onError:I=>{P(I)},onSuccess:I=>{S(I)}}),f()});const u=y=>c._(this,void 0,void 0,function*(){y.state="running";const{requestParameters:b,supportImageRefresh:w,onError:S,onSuccess:P,abortController:I}=y,k=w===!1&&!c.i(self)&&!c.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce((N,U)=>N&&U==="accept",!0));n++;const O=k?_(b,I):c.m(b,I);try{const N=yield O;delete y.abortController,y.state="completed",N.data instanceof HTMLImageElement||c.b(N.data)?P(N):N.data&&P({data:yield(B=N.data,typeof createImageBitmap=="function"?c.f(B):c.h(B)),cacheControl:N.cacheControl,expires:N.expires})}catch(N){delete y.abortController,S(N)}finally{n--,f()}var B}),f=()=>{const y=(()=>{for(const b of Object.keys(l))if(l[b]())return!0;return!1})()?c.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:c.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b<y&&e.length>0;b++){const w=e.shift();w.abortController.signal.aborted?b--:u(w)}},_=(y,b)=>new Promise((w,S)=>{const P=new Image,I=y.url,k=y.credentials;k&&k==="include"?P.crossOrigin="use-credentials":(k&&k==="same-origin"||!c.d(I))&&(P.crossOrigin="anonymous"),b.signal.addEventListener("abort",()=>{P.src="",S(c.c())}),P.fetchPriority="high",P.onload=()=>{P.onerror=P.onload=null,w({data:P})},P.onerror=()=>{P.onerror=P.onload=null,b.signal.aborted||S(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},P.src=I})}(Ot||(Ot={})),Ot.resetRequestQueue();class $i{constructor(e){this._transformRequestFn=e??null}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function Sr(h){const e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){const n=[];for(const{id:a,url:l}of h){const u=`${a}${l}`;n.indexOf(u)===-1&&(n.push(u),e.push({id:a,url:l}))}}return e}function jn(h,e,n){try{const a=new URL(h);return a.pathname+=`${e}${n}`,a.toString()}catch{throw new Error(`Invalid sprite URL "${h}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function oa(h){const{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class Ts extends c.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new c.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:n,promiseResolve:a}of this.requestors)a(this._getImagesForIds(n));this.requestors=[]}}getImage(e){const n=this.images[e];if(n&&!n.data&&n.spriteData){const a=n.spriteData;n.data=new c.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.height).data),n.spriteData=null}return n}addImage(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let a=!0;const l=n.data||n.spriteData;return this._validateStretch(n.stretchX,l&&l.width)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "stretchX" value`))),a=!1),this._validateStretch(n.stretchY,l&&l.height)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "content" value`))),a=!1),a}_validateStretch(e,n){if(!e)return!0;let a=0;for(const l of e){if(l[0]<a||l[1]<l[0]||n<l[1])return!1;a=l[1]}return!0}_validateContent(e,n){if(!e)return!0;if(e.length!==4)return!1;const a=n.spriteData,l=a&&a.width||n.data.width,u=a&&a.height||n.data.height;return!(e[0]<0||l<e[0]||e[1]<0||u<e[1]||e[2]<0||l<e[2]||e[3]<0||u<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,n,a=!0){const l=this.getImage(e);if(a&&(l.data.width!==n.data.width||l.data.height!==n.data.height))throw new Error(`size mismatch between old image (${l.data.width}x${l.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=l.version+1,this.images[e]=n,this.updatedImages[e]=!0}removeImage(e){const 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,a)=>{let l=!0;if(!this.isLoaded())for(const u of e)this.images[u]||(l=!1);this.isLoaded()||l?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})})}_getImagesForIds(e){const n={};for(const a of e){let l=this.getImage(a);l||(this.fire(new c.l("styleimagemissing",{id:a})),l=this.getImage(a)),l?n[a]={data:l.data.clone(),pixelRatio:l.pixelRatio,sdf:l.sdf,version:l.version,stretchX:l.stretchX,stretchY:l.stretchY,content:l.content,textFitWidth:l.textFitWidth,textFitHeight:l.textFitHeight,hasRenderCallback:!!(l.userImage&&l.userImage.render)}:c.w(`Image "${a}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){const n=this.patterns[e],a=this.getImage(e);if(!a)return null;if(n&&n.position.version===a.version)return n.position;if(n)n.position.version=a.version;else{const l={w:a.data.width+2,h:a.data.height+2,x:0,y:0},u=new c.I(l,a);this.patterns[e]={bin:l,position:u}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new c.T(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const u in this.patterns)e.push(this.patterns[u].bin);const{w:n,h:a}=c.p(e),l=this.atlasImage;l.resize({width:n||1,height:a||1});for(const u in this.patterns){const{bin:f}=this.patterns[u],_=f.x+1,y=f.y+1,b=this.getImage(u).data,w=b.width,S=b.height;c.R.copy(b,l,{x:0,y:0},{x:_,y},{width:w,height:S}),c.R.copy(b,l,{x:0,y:S-1},{x:_,y:y-1},{width:w,height:1}),c.R.copy(b,l,{x:0,y:0},{x:_,y:y+S},{width:w,height:1}),c.R.copy(b,l,{x:w-1,y:0},{x:_-1,y},{width:1,height:S}),c.R.copy(b,l,{x:0,y:0},{x:_+w,y},{width:1,height:S})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const a=this.getImage(n);a||c.w(`Image with ID: "${n}" was not found`),oa(a)&&this.updateImage(n,a)}}}const pr=1e20;function Br(h,e,n,a,l,u,f,_,y){for(let b=e;b<e+a;b++)fr(h,n*u+b,u,l,f,_,y);for(let b=n;b<n+l;b++)fr(h,b*u+e,1,a,f,_,y)}function fr(h,e,n,a,l,u,f){u[0]=0,f[0]=-1e20,f[1]=pr,l[0]=h[e];for(let _=1,y=0,b=0;_<a;_++){l[_]=h[e+_*n];const w=_*_;do{const S=u[y];b=(l[_]-l[S]+w-S*S)/(_-S)/2}while(b<=f[y]&&--y>-1);y++,u[y]=_,f[y]=b,f[y+1]=pr}for(let _=0,y=0;_<a;_++){for(;f[y+1]<_;)y++;const b=u[y],w=_-b;h[e+_*n]=l[b]+w*w}}class Or{constructor(e,n,a){this.requestManager=e,this.localIdeographFontFamily=n,this.entries={},this.lang=a}setURL(e){this.url=e}getGlyphs(e){return c._(this,void 0,void 0,function*(){const n=[];for(const u in e)for(const f of e[u])n.push(this._getAndCacheGlyphsPromise(u,f));const a=yield Promise.all(n),l={};for(const{stack:u,id:f,glyph:_}of a)l[u]||(l[u]={}),l[u][f]=_&&{id:_.id,bitmap:_.bitmap.clone(),metrics:_.metrics};return l})}_getAndCacheGlyphsPromise(e,n){return c._(this,void 0,void 0,function*(){let a=this.entries[e];a||(a=this.entries[e]={glyphs:{},requests:{},ranges:{}});let l=a.glyphs[n];if(l!==void 0)return{stack:e,id:n,glyph:l};if(l=this._tinySDF(a,e,n),l)return a.glyphs[n]=l,{stack:e,id:n,glyph:l};const u=Math.floor(n/256);if(256*u>65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[u])return{stack:e,id:n,glyph:l};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[u]){const _=Or.loadGlyphRange(e,u,this.url,this.requestManager);a.requests[u]=_}const f=yield a.requests[u];for(const _ in f)this._doesCharSupportLocalGlyph(+_)||(a.glyphs[+_]=f[+_]);return a.ranges[u]=!0,{stack:e,id:n,glyph:f[n]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(new RegExp("\\p{Ideo}|\\p{sc=Hang}|\\p{sc=Hira}|\\p{sc=Kana}","u").test(String.fromCodePoint(e))||c.u["CJK Unified Ideographs"](e)||c.u["Hangul Syllables"](e)||c.u.Hiragana(e)||c.u.Katakana(e)||c.u["CJK Symbols and Punctuation"](e)||c.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,n,a){const l=this.localIdeographFontFamily;if(!l||!this._doesCharSupportLocalGlyph(a))return;let u=e.tinySDF;if(!u){let _="400";/bold/i.test(n)?_="900":/medium/i.test(n)?_="500":/light/i.test(n)&&(_="200"),u=e.tinySDF=new Or.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,lang:this.lang,fontFamily:l,fontWeight:_})}const f=u.draw(String.fromCharCode(a));return{id:a,bitmap:new c.q({width:f.width||60,height:f.height||60},f.data),metrics:{width:f.glyphWidth/2||24,height:f.glyphHeight/2||24,left:f.glyphLeft/2+.5||0,top:f.glyphTop/2-27.5||-8,advance:f.glyphAdvance/2||24,isDoubleResolution:!0}}}}Or.loadGlyphRange=function(h,e,n,a){return c._(this,void 0,void 0,function*(){const l=256*e,u=l+255,f=a.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${l}-${u}`),"Glyphs"),_=yield c.n(f,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${e}, ${l}-${u}`);const y={};for(const b of c.o(_.data))y[b.id]=b;return y})},Or.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:n=8,cutoff:a=.25,fontFamily:l="sans-serif",fontWeight:u="normal",fontStyle:f="normal",lang:_=null}={}){this.buffer=e,this.cutoff=a,this.radius=n,this.lang=_;const y=this.size=h+4*e,b=this._createCanvas(y),w=this.ctx=b.getContext("2d",{willReadFrequently:!0});w.font=`${f} ${u} ${h}px ${l}`,w.textBaseline="alphabetic",w.textAlign="left",w.fillStyle="black",this.gridOuter=new Float64Array(y*y),this.gridInner=new Float64Array(y*y),this.f=new Float64Array(y),this.z=new Float64Array(y+1),this.v=new Uint16Array(y)}_createCanvas(h){const e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,actualBoundingBoxLeft:l,actualBoundingBoxRight:u}=this.ctx.measureText(h),f=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(u-l))),y=Math.min(this.size-this.buffer,f+Math.ceil(a)),b=_+2*this.buffer,w=y+2*this.buffer,S=Math.max(b*w,0),P=new Uint8ClampedArray(S),I={data:P,width:b,height:w,glyphWidth:_,glyphHeight:y,glyphTop:f,glyphLeft:0,glyphAdvance:e};if(_===0||y===0)return I;const{ctx:k,buffer:O,gridInner:B,gridOuter:N}=this;this.lang&&(k.lang=this.lang),k.clearRect(O,O,_,y),k.fillText(h,O,O+f);const U=k.getImageData(O,O,_,y);N.fill(pr,0,S),B.fill(0,0,S);for(let q=0;q<y;q++)for(let $=0;$<_;$++){const H=U.data[4*(q*_+$)+3]/255;if(H===0)continue;const K=(q+O)*b+$+O;if(H===1)N[K]=0,B[K]=pr;else{const G=.5-H;N[K]=G>0?G*G:0,B[K]=G<0?G*G:0}}Br(N,0,0,b,w,b,this.f,this.v,this.z),Br(B,O,O,_,y,b,this.f,this.v,this.z);for(let q=0;q<S;q++){const $=Math.sqrt(N[q])-Math.sqrt(B[q]);P[q]=Math.round(255-255*($/this.radius+this.cutoff))}return I}};class Ps{constructor(){this.specification=c.v.light.position}possiblyEvaluate(e,n){return c.B(e.expression.evaluate(n))}interpolate(e,n,a){return{x:c.C.number(e.x,n.x,a),y:c.C.number(e.y,n.y,a),z:c.C.number(e.z,n.z,a)}}}let cn;class hn extends c.E{constructor(e){super(),cn=cn||new c.r({anchor:new c.D(c.v.light.anchor),position:new Ps,color:new c.D(c.v.light.color),intensity:new c.D(c.v.light.intensity)}),this._transitionable=new c.t(cn),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(c.x,e,n))for(const a in e){const l=e[a];a.endsWith("-transition")?this._transitionable.setTransition(a.slice(0,-11),l):this._transitionable.setValue(a,l)}}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,a){return(!a||a.validate!==!1)&&c.y(this,e.call(c.z,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:c.v}))}}const un=new c.r({"sky-color":new c.D(c.v.sky["sky-color"]),"horizon-color":new c.D(c.v.sky["horizon-color"]),"fog-color":new c.D(c.v.sky["fog-color"]),"fog-ground-blend":new c.D(c.v.sky["fog-ground-blend"]),"horizon-fog-blend":new c.D(c.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new c.D(c.v.sky["sky-horizon-blend"]),"atmosphere-blend":new c.D(c.v.sky["atmosphere-blend"])});class la extends c.E{constructor(e){super(),this._transitionable=new c.t(un),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.F(0))}setSky(e,n={}){if(!this._validate(c.G,e,n)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const a in e){const l=e[a];a.endsWith("-transition")?this._transitionable.setTransition(a.slice(0,-11),l):this._transitionable.setValue(a,l)}}}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,a={}){return(a==null?void 0:a.validate)!==!1&&c.y(this,e.call(c.z,c.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:c.v})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class gt{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){const a=e.join(",")+String(n);return this.dashEntry[a]||(this.dashEntry[a]=this.addDash(e,n)),this.dashEntry[a]}getDashRanges(e,n,a){const l=[];let u=e.length%2==1?-e[e.length-1]*a:0,f=e[0]*a,_=!0;l.push({left:u,right:f,isDash:_,zeroLength:e[0]===0});let y=e[0];for(let b=1;b<e.length;b++){_=!_;const w=e[b];u=y*a,y+=w,f=y*a,l.push({left:u,right:f,isDash:_,zeroLength:w===0})}return l}addRoundDash(e,n,a){const l=n/2;for(let u=-a;u<=a;u++){const f=this.width*(this.nextRow+a+u);let _=0,y=e[_];for(let b=0;b<this.width;b++){b/y.right>1&&(y=e[++_]);const w=Math.abs(b-y.left),S=Math.abs(b-y.right),P=Math.min(w,S);let I;const k=u/a*(l+1);if(y.isDash){const O=l-Math.abs(k);I=Math.sqrt(P*P+O*O)}else I=l-Math.sqrt(P*P+k*k);this.data[f+b]=Math.max(0,Math.min(255,I+128))}}}addRegularDash(e){for(let _=e.length-1;_>=0;--_){const y=e[_],b=e[_+1];y.zeroLength?e.splice(_,1):b&&b.isDash===y.isDash&&(b.left=y.left,e.splice(_,1))}const n=e[0],a=e[e.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.right=n.right+this.width);const l=this.width*this.nextRow;let u=0,f=e[u];for(let _=0;_<this.width;_++){_/f.right>1&&(f=e[++u]);const y=Math.abs(_-f.left),b=Math.abs(_-f.right),w=Math.min(y,b);this.data[l+_]=Math.max(0,Math.min(255,(f.isDash?w:-w)+128))}}addDash(e,n){const a=n?7:0,l=2*a+1;if(this.nextRow+l>this.height)return c.w("LineAtlas out of space"),null;let u=0;for(let _=0;_<e.length;_++)u+=e[_];if(u!==0){const _=this.width/u,y=this.getDashRanges(e,this.width,_);n?this.addRoundDash(y,_,a):this.addRegularDash(y)}const f={y:(this.nextRow+a+.5)/this.height,height:2*a/this.height,width:u};return this.nextRow+=l,this.dirty=!0,f}bind(e){const 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))}}const dn="maplibre_preloaded_worker_pool";class mi{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<mi.workerCount;)this.workers.push(new Worker(c.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[dn]}numActive(){return Object.keys(this.active).length}}const pn=Math.floor(Ee.hardwareConcurrency/2);let mr,jr;function fn(){return mr||(mr=new mi),mr}mi.workerCount=c.H(globalThis)?Math.max(Math.min(pn,3),1):1;class Ei{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;const a=this.workerPool.acquire(n);for(let l=0;l<a.length;l++){const u=new c.J(a[l],n);u.name=`Worker ${l}`,this.actors.push(u)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,n){const a=[];for(const l of this.actors)a.push(l.sendAsync({type:e,data:n}));return Promise.all(a)}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(const a of this.actors)a.registerMessageHandler(e,n)}}function Nn(){return jr||(jr=new Ei(fn(),c.K),jr.registerMessageHandler("GR",(h,e,n)=>c.m(e,n))),jr}function Zi(h,e){const n=c.L();return c.M(n,n,[1,1,0]),c.N(n,n,[.5*h.width,.5*h.height,1]),h.calculatePosMatrix?c.O(n,n,h.calculatePosMatrix(e.toUnwrapped())):n}function Yi(h,e,n,a,l,u,f){var _;const y=function(P,I,k){if(P)for(const O of P){const B=I[O];if(B&&B.source===k&&B.type==="fill-extrusion")return!0}else for(const O in I){const B=I[O];if(B.source===k&&B.type==="fill-extrusion")return!0}return!1}((_=l==null?void 0:l.layers)!==null&&_!==void 0?_:null,e,h.id),b=u.maxPitchScaleFactor(),w=h.tilesIn(a,b,y);w.sort(Vn);const S=[];for(const P of w)S.push({wrappedTileID:P.tileID.wrapped().key,queryResults:P.tile.queryRenderedFeatures(e,n,h._state,P.queryGeometry,P.cameraQueryGeometry,P.scale,l,u,b,Zi(h.transform,P.tileID),f?(I,k)=>f(P.tileID,I,k):void 0)});return function(P,I){for(const k in P)for(const O of P[k])Un(O,I);return P}(function(P){const I={},k={};for(const O of P){const B=O.queryResults,N=O.wrappedTileID,U=k[N]=k[N]||{};for(const q in B){const $=B[q],H=U[q]=U[q]||{},K=I[q]=I[q]||[];for(const G of $)H[G.featureIndex]||(H[G.featureIndex]=!0,K.push(G))}}return I}(S),h)}function Vn(h,e){const n=h.tileID,a=e.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}function Un(h,e){const n=h.feature,a=e.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=a}function Fi(h,e,n){return c._(this,void 0,void 0,function*(){let a=h;if(h.url?a=(yield c.j(e.transformRequest(h.url,"Source"),n)).data:yield Ee.frameAsync(n),!a)return null;const l=c.Q(c.e(a,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(l.vectorLayerIds=a.vector_layers.map(u=>u.id)),l})}class Dt{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 c.S?new c.S(e.lng,e.lat):c.S.convert(e),this}setSouthWest(e){return this._sw=e instanceof c.S?new c.S(e.lng,e.lat):c.S.convert(e),this}extend(e){const n=this._sw,a=this._ne;let l,u;if(e instanceof c.S)l=e,u=e;else{if(!(e instanceof Dt))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Dt.convert(e)):this.extend(c.S.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(c.S.convert(e)):this;if(l=e._sw,u=e._ne,!l||!u)return this}return n||a?(n.lng=Math.min(l.lng,n.lng),n.lat=Math.min(l.lat,n.lat),a.lng=Math.max(u.lng,a.lng),a.lat=Math.max(u.lat,a.lat)):(this._sw=new c.S(l.lng,l.lat),this._ne=new c.S(u.lng,u.lat)),this}getCenter(){return new c.S((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new c.S(this.getWest(),this.getNorth())}getSouthEast(){return new c.S(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:n,lat:a}=c.S.convert(e);let l=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(l=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&l}static convert(e){return e instanceof Dt?e:e&&new Dt(e)}static fromLngLat(e,n=0){const a=360*n/40075017,l=a/Math.cos(Math.PI/180*e.lat);return new Dt(new c.S(e.lng-l,e.lat-a),new c.S(e.lng+l,e.lat+a))}adjustAntiMeridian(){const e=new c.S(this._sw.lng,this._sw.lat),n=new c.S(this._ne.lng,this._ne.lat);return new Dt(e,e.lng>n.lng?new c.S(n.lng+360,n.lat):n)}}class jt{constructor(e,n,a){this.bounds=Dt.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=a||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const n=Math.pow(2,e.z),a=Math.floor(c.V(this.bounds.getWest())*n),l=Math.floor(c.U(this.bounds.getNorth())*n),u=Math.ceil(c.V(this.bounds.getEast())*n),f=Math.ceil(c.U(this.bounds.getSouth())*n);return e.x>=a&&e.x<u&&e.y>=l&&e.y<f}}class Ki extends c.E{constructor(e,n,a,l){if(super(),this.id=e,this.dispatcher=a,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,c.e(this,c.Q(n,["url","scheme","tileSize","promoteId"])),this._options=c.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(l)}load(){return c._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const e=yield Fi(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e&&(c.e(this,e),e.bounds&&(this.tileBounds=new jt(e.bounds,this.minzoom,this.maxzoom)),this.fire(new c.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.l("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new c.k(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 c.e({},this._options)}loadTile(e){return c._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(n,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};a.request.collectResourceTiming=this._collectResourceTiming;let l="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise((u,f)=>{e.reloadPromise={resolve:u,reject:f}})}else e.actor=this.dispatcher.getActor(),l="LT";e.abortController=new AbortController;try{const u=yield e.actor.sendAsync({type:l,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,u)}catch(u){if(delete e.abortController,e.aborted)return;if(u&&u.status!==404)throw u;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){const a=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(a.resolve).catch(a.reject)}}abortTile(e){return c._(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 c._(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 gr extends c.E{constructor(e,n,a,l){super(),this.id=e,this.dispatcher=a,this.setEventedParent(l),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=c.e({type:"raster"},n),c.e(this,c.Q(n,["url","scheme","tileSize"]))}load(){return c._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const n=yield Fi(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(c.e(this,n),n.bounds&&(this.tileBounds=new jt(n.bounds,this.minzoom,this.maxzoom)),this.fire(new c.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(n){this._tileJSONRequest=null,this.fire(new c.k(n))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return c.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return c._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const a=yield Ot.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a&&a.data){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});const l=this.map.painter.context,u=l.gl,f=a.data;e.texture=this.map.painter.getTileTexture(f.width),e.texture?e.texture.update(f,{useMipmap:!0}):(e.texture=new c.T(l,f,u.RGBA,{useMipmap:!0}),e.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE,u.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}})}abortTile(e){return c._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return c._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class mn extends gr{constructor(e,n,a,l){super(e,n,a,l),this.type="raster-dem",this.maxzoom=22,this._options=c.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 c._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const l=yield Ot.getImage(a,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(l&&l.data){const u=l.data;this.map._refreshExpiredTiles&&(l.cacheControl||l.expires)&&e.setExpiryData({cacheControl:l.cacheControl,expires:l.expires});const f=c.b(u)&&c.W()?u:yield this.readImageNow(u),_={type:this.type,uid:e.uid,source:this.id,rawImageData:f,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();const y=yield e.actor.sendAsync({type:"LDT",data:_});e.dem=y,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(l){if(delete e.abortController,e.aborted)e.state="unloaded";else if(l)throw e.state="errored",l}})}readImageNow(e){return c._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&c.X()){const n=e.width+2,a=e.height+2;try{return new c.R({width:n,height:a},yield c.Y(e,-1,-1,n,a))}catch{}}return Ee.getImageData(e,1)})}_getNeighboringTiles(e){const n=e.canonical,a=Math.pow(2,n.z),l=(n.x-1+a)%a,u=n.x===0?e.wrap-1:e.wrap,f=(n.x+1+a)%a,_=n.x+1===a?e.wrap+1:e.wrap,y={};return y[new c.Z(e.overscaledZ,u,n.z,l,n.y).key]={backfilled:!1},y[new c.Z(e.overscaledZ,_,n.z,f,n.y).key]={backfilled:!1},n.y>0&&(y[new c.Z(e.overscaledZ,u,n.z,l,n.y-1).key]={backfilled:!1},y[new c.Z(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new c.Z(e.overscaledZ,_,n.z,f,n.y-1).key]={backfilled:!1}),n.y+1<a&&(y[new c.Z(e.overscaledZ,u,n.z,l,n.y+1).key]={backfilled:!1},y[new c.Z(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},y[new c.Z(e.overscaledZ,_,n.z,f,n.y+1).key]={backfilled:!1}),y}unloadTile(e){return c._(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 _r extends c.E{constructor(e,n,a,l){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._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actor=a.getActor(),this.setEventedParent(l),this._data=n.data,this._options=c.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,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&c.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=c.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer!==void 0?n.buffer:128),tolerance:this._pixelsToTileUnits(n.tolerance!==void 0?n.tolerance:.375),extent:c.$,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:c.$,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_pixelsToTileUnits(e){return e*(c.$/this.tileSize)}_getClusterMaxZoom(e){const n=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||c.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${n}"`),n}load(){return c._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(e){this.map=e,this.load()}setData(e){return this._data=e,this._pendingWorkerUpdate={data:e},this._updateWorkerData(),this}updateData(e){return this._pendingWorkerUpdate.diff=c.a0(this._pendingWorkerUpdate.diff,e),this._updateWorkerData(),this}getData(){return c._(this,void 0,void 0,function*(){const e=c.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:e})})}getCoordinatesFromGeometry(e){return e.type==="GeometryCollection"?e.geometries.map(n=>n.coordinates).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return c._(this,void 0,void 0,function*(){const e=new Dt,n=yield this.getData();let a;switch(n.type){case"FeatureCollection":a=n.features.map(l=>this.getCoordinatesFromGeometry(l.geometry)).flat(1/0);break;case"Feature":a=this.getCoordinatesFromGeometry(n.geometry);break;default:a=this.getCoordinatesFromGeometry(n)}if(a.length==0)return e;for(let l=0;l<a.length-1;l+=2)e.extend([a[l],a[l+1]]);return e})}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,e&&(e.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(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,a){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:n,offset:a}})}_updateWorkerData(){return c._(this,void 0,void 0,function*(){if(this._isUpdatingWorker)return;const{data:e,diff:n}=this._pendingWorkerUpdate;if(!e&&!n)return void c.w(`No data or diff provided to GeoJSONSource ${this.id}.`);const a=c.e({type:this.type},this.workerOptions);e?(typeof e=="string"?(a.request=this.map._requestManager.transformRequest(Ee.resolveURL(e),"Source"),a.request.collectResourceTiming=this._collectResourceTiming):a.data=JSON.stringify(e),this._pendingWorkerUpdate.data=void 0):n&&(a.dataDiff=n,this._pendingWorkerUpdate.diff=void 0),this._isUpdatingWorker=!0,this.fire(new c.l("dataloading",{dataType:"source"}));try{const l=yield this.actor.sendAsync({type:"LD",data:a});if(this._isUpdatingWorker=!1,this._removed||l.abandoned)return void this.fire(new c.l("dataabort",{dataType:"source"}));this._data=l.data;let u=null;l.resourceTiming&&l.resourceTiming[this.id]&&(u=l.resourceTiming[this.id].slice(0));const f={dataType:"source"};this._collectResourceTiming&&u&&u.length>0&&c.e(f,{resourceTiming:u}),this.fire(new c.l("data",Object.assign(Object.assign({},f),{sourceDataType:"metadata"}))),this.fire(new c.l("data",Object.assign(Object.assign({},f),{sourceDataType:"content"})))}catch(l){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new c.l("dataabort",{dataType:"source"}));this.fire(new c.k(l))}finally{(this._pendingWorkerUpdate.data||this._pendingWorkerUpdate.diff)&&this._updateWorkerData()}})}loaded(){return!this._isUpdatingWorker&&this._pendingWorkerUpdate.data===void 0&&this._pendingWorkerUpdate.diff===void 0}loadTile(e){return c._(this,void 0,void 0,function*(){const n=e.actor?"RT":"LT";e.actor=this.actor;const a={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};e.abortController=new AbortController;const l=yield this.actor.sendAsync({type:n,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(l,this.map.painter,n==="RT")})}abortTile(e){return c._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return c._(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 c.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class yr extends c.E{constructor(e,n,a,l){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=a,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=n}load(e){return c._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield Ot.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 c.k(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 c.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const n=e.map(c.a1.fromLngLat);var a;return this.tileID=function(l){const u=c.a2.fromPoints(l),f=u.width(),_=u.height(),y=Math.max(f,_),b=Math.max(0,Math.floor(-Math.log(y)/Math.LN2)),w=Math.pow(2,b);return new c.a4(b,Math.floor((u.minX+u.maxX)/2*w),Math.floor((u.minY+u.maxY)/2*w))}(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map(l=>this.tileID.getTilePoint(l)._round()),this.flippedWindingOrder=((a=this.tileCoords)[1].x-a[0].x)*(a[2].y-a[0].y)-(a[1].y-a[0].y)*(a[2].x-a[0].x)<0,this.fire(new c.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const e=this.map.painter.context,n=e.gl;this.texture||(this.texture=new c.T(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const l in this.tiles){const u=this.tiles[l];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,a=!0)}a&&this.fire(new c.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return c._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:n,minY:a,maxX:l,maxY:u}=c.a2.fromPoints(e),f={};for(let _=0;_<=c.a3;_++){const y=Math.pow(2,_),b=Math.floor(n*y),w=Math.floor(a*y),S=Math.floor(l*y),P=Math.floor(u*y);f[_]={minTileX:b,minTileY:w,maxTileX:S,maxTileY:P}}return f}}class $n extends yr{constructor(e,n,a,l){super(e,n,a,l),this.roundZoom=!0,this.type="video",this.options=n}load(){return c._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield c.a5(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 c.k(n))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new c.k(new c.a6(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const e=this.map.painter.context,n=e.gl;this.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 c.T(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const l in this.tiles){const u=this.tiles[l];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,a=!0)}a&&this.fire(new c.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Nr extends yr{constructor(e,n,a,l){super(e,n,a,l),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(u=>!Array.isArray(u)||u.length!==2||u.some(f=>typeof f!="number"))||this.fire(new c.k(new c.a6(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new c.k(new c.a6(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new c.k(new c.a6(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new c.k(new c.a6(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new c.k(new c.a6(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return c._(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 c.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,a=n.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new c.T(n,this.canvas,a.RGBA,{premultiply:!0});let l=!1;for(const u in this.tiles){const f=this.tiles[u];f.state!=="loaded"&&(f.state="loaded",f.texture=this.texture,l=!0)}l&&this.fire(new c.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const Vr={},Ur=h=>{switch(h){case"geojson":return _r;case"image":return yr;case"raster":return gr;case"raster-dem":return mn;case"vector":return Ki;case"video":return $n;case"canvas":return Nr}return Vr[h]},gn="RTLPluginLoaded";class $r extends c.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Nn()}_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 c._(this,arguments,void 0,function*(n,a=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Ee.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!a)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return c._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new c.l(gn))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Zr=null;function Gr(){return Zr||(Zr=new $r),Zr}class Zn{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=c.a7(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const n=e+this.timeAdded;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,a){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(l,u){const f={};if(!u)return f;for(const _ of l){const y=_.layerIds.map(b=>u.getLayer(b)).filter(Boolean);if(y.length!==0){_.layers=y,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map(b=>y.filter(w=>w.id===b)[0]));for(const b of y)f[b.id]=_}}return f}(e.buckets,n==null?void 0:n.style),this.hasSymbolBuckets=!1;for(const l in this.buckets){const u=this.buckets[l];if(u instanceof c.a9){if(this.hasSymbolBuckets=!0,!a)break;u.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const l in this.buckets){const u=this.buckets[l];if(u instanceof c.a9&&u.hasRTLText){this.hasRTLText=!0,Gr().lazyLoad();break}}this.queryPadding=0;for(const l in this.buckets){const u=this.buckets[l];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(l).queryRadius(u))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new c.a8}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const a in this.buckets){const l=this.buckets[a];l.uploadPending()&&l.upload(e)}const n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new c.T(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new c.T(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,a,l,u,f,_,y,b,w,S){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:u,scale:f,tileSize:this.tileSize,pixelPosMatrix:w,transform:y,params:_,queryPadding:this.queryPadding*b,getElevation:S},e,n,a):{}}querySourceFeatures(e,n){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const l=a.loadVTLayers(),u=n&&n.sourceLayer?n.sourceLayer:"",f=l._geojsonTileLayer||l[u];if(!f)return;const _=c.aa(n&&n.filter),{z:y,x:b,y:w}=this.tileID.canonical,S={z:y,x:b,y:w};for(let P=0;P<f.length;P++){const I=f.feature(P);if(_.needGeometry){const B=c.ab(I,!0);if(!_.filter(new c.F(this.tileID.overscaledZ),B,this.tileID.canonical))continue}else if(!_.filter(new c.F(this.tileID.overscaledZ),I))continue;const k=a.getId(I,u),O=new c.ac(I,y,b,w,k);O.tile=S,e.push(O)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const n=this.expirationTime;if(e.cacheControl){const a=c.ad(e.cacheControl);a["max-age"]&&(this.expirationTime=Date.now()+1e3*a["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const a=Date.now();let l=!1;if(this.expirationTime>a)l=!1;else if(n)if(this.expirationTime<n)l=!0;else{const u=this.expirationTime-n;u?this.expirationTime=a+Math.max(u,3e4):l=!0}else l=!0;l?(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;const a=this.latestFeatureIndex.loadVTLayers();for(const l in this.buckets){if(!n.style.hasLayer(l))continue;const u=this.buckets[l],f=u.layers[0].sourceLayer||"_geojsonTileLayer",_=a[f],y=e[f];if(!_||!y||Object.keys(y).length===0)continue;u.update(y,_,this.imageAtlas&&this.imageAtlas.patternPositions||{});const b=n&&n.style&&n.style.getLayer(l);b&&(this.queryPadding=Math.max(this.queryPadding,b.queryRadius(u)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Ee.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=Ee.now()+e}setDependencies(e,n){const a={};for(const l of n)a[l]=!0;this.dependencies[e]=a}hasDependency(e,n){for(const a of e){const l=this.dependencies[a];if(l){for(const u of n)if(l[u])return!0}}return!1}}class ee{constructor(e,n){this.max=e,this.onRemove=n,this.reset()}reset(){for(const e in this.data)for(const n of this.data[e])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(e,n,a){const l=e.wrapped().key;this.data[l]===void 0&&(this.data[l]=[]);const u={value:n,timeout:void 0};if(a!==void 0&&(u.timeout=setTimeout(()=>{this.remove(e,u)},a)),this.data[l].push(u),this.order.push(l),this.order.length>this.max){const f=this._getAndRemoveByKey(this.order[0]);f&&this.onRemove(f)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const n=this.data[e].shift();return n.timeout&&clearTimeout(n.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),n.value}getByKey(e){const n=this.data[e];return n?n[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,n){if(!this.has(e))return this;const a=e.wrapped().key,l=n===void 0?0:this.data[a].indexOf(n),u=this.data[a][l];return this.data[a].splice(l,1),u.timeout&&clearTimeout(u.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(u.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(e){const n=[];for(const a in this.data)for(const l of this.data[a])e(l.value)||n.push(l);for(const a of n)this.remove(a.value.tileID,a)}}class z{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,a){const l=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][l]=this.stateChanges[e][l]||{},c.e(this.stateChanges[e][l],a),this.deletedStates[e]===null){this.deletedStates[e]={};for(const u in this.state[e])u!==l&&(this.deletedStates[e][u]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][l]===null){this.deletedStates[e][l]={};for(const u in this.state[e][l])a[u]||(this.deletedStates[e][l][u]=null)}else for(const u in a)this.deletedStates[e]&&this.deletedStates[e][l]&&this.deletedStates[e][l][u]===null&&delete this.deletedStates[e][l][u]}removeFeatureState(e,n,a){if(this.deletedStates[e]===null)return;const l=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&n!==void 0)this.deletedStates[e][l]!==null&&(this.deletedStates[e][l]=this.deletedStates[e][l]||{},this.deletedStates[e][l][a]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][l])for(a in this.deletedStates[e][l]={},this.stateChanges[e][l])this.deletedStates[e][l][a]=null;else this.deletedStates[e][l]=null;else this.deletedStates[e]=null}getState(e,n){const a=String(n),l=c.e({},(this.state[e]||{})[a],(this.stateChanges[e]||{})[a]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const u=this.deletedStates[e][n];if(u===null)return{};for(const f in u)delete l[f]}return l}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){const a={};for(const l in this.stateChanges){this.state[l]=this.state[l]||{};const u={};for(const f in this.stateChanges[l])this.state[l][f]||(this.state[l][f]={}),c.e(this.state[l][f],this.stateChanges[l][f]),u[f]=this.state[l][f];a[l]=u}for(const l in this.deletedStates){this.state[l]=this.state[l]||{};const u={};if(this.deletedStates[l]===null)for(const f in this.state[l])u[f]={},this.state[l][f]={};else for(const f in this.deletedStates[l]){if(this.deletedStates[l][f]===null)this.state[l][f]={};else for(const _ of Object.keys(this.deletedStates[l][f]))delete this.state[l][f][_];u[f]=this.state[l][f]}a[l]=a[l]||{},c.e(a[l],u)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(const l in e)e[l].setFeatureState(a,n)}}const D=89.25;function R(h,e){const n=c.ah(e.lat,-c.ai,c.ai);return new c.P(c.V(e.lng)*h,c.U(n)*h)}function Z(h,e){return new c.a1(e.x/h,e.y/h).toLngLat()}function Y(h){return h.cameraToCenterDistance*Math.min(.85*Math.tan(c.ae(90-h.pitch)),Math.tan(c.ae(D-h.pitch)))}function ie(h,e){const n=h.canonical,a=e/c.af(n.z),l=n.x+Math.pow(2,n.z)*h.wrap,u=c.ag(new Float64Array(16));return c.M(u,u,[l*a,n.y*a,0]),c.N(u,u,[a/c.$,a/c.$,1]),u}function le(h,e,n,a,l){const u=c.a1.fromLngLat(h,e),f=l*c.aj(1,h.lat),_=f*Math.cos(c.ae(n)),y=Math.sqrt(f*f-_*_),b=y*Math.sin(c.ae(-a)),w=y*Math.cos(c.ae(-a));return new c.a1(u.x+b,u.y+w,u.z+_)}function re(h,e,n){const a=e.intersectsFrustum(h);if(!n||a===0)return a;const l=e.intersectsPlane(n);return l===0?0:a===2&&l===2?2:1}function fe(h,e,n){let a=0;const l=(n-e)/10;for(let u=0;u<10;u++)a+=l*Math.pow(Math.cos(e+(u+.5)/10*(n-e)),h);return a}function ve(h,e){return function(n,a,l,u,f){const _=2*((h-1)/c.ak(Math.cos(c.ae(D-f))/Math.cos(c.ae(D)))-1),y=Math.acos(l/u),b=2*fe(_-1,0,c.ae(f/2)),w=Math.min(c.ae(D),y+c.ae(f/2)),S=fe(_-1,Math.min(w,y-c.ae(f/2)),w),P=Math.atan(a/l),I=Math.hypot(a,l);let k=n;return k+=c.ak(u/I/Math.max(.5,Math.cos(c.ae(f/2)))),k+=_*c.ak(Math.cos(P))/2,k-=c.ak(Math.max(1,S/b/e))/2,k}}const _e=ve(9.314,3);function Re(h,e){const n=(e.roundZoom?Math.round:Math.floor)(h.zoom+c.ak(h.tileSize/e.tileSize));return Math.max(0,n)}function ne(h,e){const n=h.getCameraFrustum(),a=h.getClippingPlane(),l=h.screenPointToMercatorCoordinate(h.getCameraPoint()),u=c.a1.fromLngLat(h.center,h.elevation);l.z=u.z+Math.cos(h.pitchInRadians)*h.cameraToCenterDistance/h.worldSize;const f=h.getCoveringTilesDetailsProvider(),_=f.allowVariableZoom(h,e),y=Re(h,e),b=e.minzoom||0,w=e.maxzoom!==void 0?e.maxzoom:h.maxZoom,S=Math.min(Math.max(0,y),w),P=Math.pow(2,S),I=[P*l.x,P*l.y,0],k=[P*u.x,P*u.y,0],O=Math.hypot(u.x-l.x,u.y-l.y),B=Math.abs(u.z-l.z),N=Math.hypot(O,B),U=H=>({zoom:0,x:0,y:0,wrap:H,fullyVisible:!1}),q=[],$=[];if(h.renderWorldCopies&&f.allowWorldCopies())for(let H=1;H<=3;H++)q.push(U(-H)),q.push(U(H));for(q.push(U(0));q.length>0;){const H=q.pop(),K=H.x,G=H.y;let te=H.fullyVisible;const ue={x:K,y:G,z:H.zoom},ae=f.getTileBoundingVolume(ue,H.wrap,h.elevation,e);if(!te){const Se=re(n,ae,a);if(Se===0)continue;te=Se===2}const oe=f.distanceToTile2d(l.x,l.y,ue,ae);let he=y;_&&(he=(e.calculateTileZoom||_e)(h.zoom+c.ak(h.tileSize/e.tileSize),oe,B,N,h.fov)),he=(e.roundZoom?Math.round:Math.floor)(he),he=Math.max(0,he);const we=Math.min(he,w);if(H.wrap=f.getWrap(u,ue,H.wrap),H.zoom>=we){if(H.zoom<b)continue;const Se=S-H.zoom,ye=I[0]-.5-(K<<Se),Le=I[1]-.5-(G<<Se),Ke=e.reparseOverscaled?Math.max(H.zoom,he):H.zoom;$.push({tileID:new c.Z(H.zoom===w?Ke:H.zoom,H.wrap,H.zoom,K,G),distanceSq:c.al([k[0]-.5-K,k[1]-.5-G]),tileDistanceToCamera:Math.sqrt(ye*ye+Le*Le)})}else for(let Se=0;Se<4;Se++)q.push({zoom:H.zoom+1,x:(K<<1)+Se%2,y:(G<<1)+(Se>>1),wrap:H.wrap,fullyVisible:te})}return $.sort((H,K)=>H.distanceSq-K.distanceSq).map(H=>H.tileID)}const qe=c.a2.fromPoints([new c.P(0,0),new c.P(c.$,c.$)]);class Qe extends c.E{constructor(e,n,a){super(),this.id=e,this.dispatcher=a,this.on("data",l=>this._dataHandler(l)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((l,u,f,_)=>{const y=new(Ur(u.type))(l,u,f,_);if(y.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${y.id}`);return y})(e,n,a,this),this._tiles={},this._cache=new ee(0,l=>this._unloadTile(l)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new z,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,a){return c._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,a)}catch(l){e.state="errored",l.status!==404?this._source.fire(new c.k(l,{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 c.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const a=this._tiles[n];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Oe).map(e=>e.key)}getRenderableIds(e){const n=[];for(const a in this._tiles)this._isIdRenderable(a,e)&&n.push(this._tiles[a]);return e?n.sort((a,l)=>{const u=a.tileID,f=l.tileID,_=new c.P(u.canonical.x,u.canonical.y)._rotate(-this.transform.bearingInRadians),y=new c.P(f.canonical.x,f.canonical.y)._rotate(-this.transform.bearingInRadians);return u.overscaledZ-f.overscaledZ||y.y-_.y||y.x-_.x}).map(a=>a.tileID.key):n.map(a=>a.tileID).sort(Oe).map(a=>a.key)}hasRenderableParent(e){const n=this.findLoadedParent(e,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(e,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(n||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const n in this._tiles)e?this._reloadTile(n,"expired"):this._tiles[n].state!=="errored"&&this._reloadTile(n,"reloading")}}_reloadTile(e,n){return c._(this,void 0,void 0,function*(){const a=this._tiles[e];a&&(a.state!=="loading"&&(a.state=n),yield this._loadTile(a,e,n))})}_tileLoaded(e,n,a){e.timeAdded=Ee.now(),a==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new c.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const n=this.getRenderableIds();for(let l=0;l<n.length;l++){const u=n[l];if(e.neighboringTiles&&e.neighboringTiles[u]){const f=this.getTileByID(u);a(e,f),a(f,e)}}function a(l,u){l.needsHillshadePrepare=!0,l.needsTerrainPrepare=!0;let f=u.tileID.canonical.x-l.tileID.canonical.x;const _=u.tileID.canonical.y-l.tileID.canonical.y,y=Math.pow(2,l.tileID.canonical.z),b=u.tileID.key;f===0&&_===0||Math.abs(_)>1||(Math.abs(f)>1&&(Math.abs(f+y)===1?f+=y:Math.abs(f-y)===1&&(f-=y)),u.dem&&l.dem&&(l.dem.backfillBorder(u.dem,f,_),l.neighboringTiles&&l.neighboringTiles[b]&&(l.neighboringTiles[b].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n,a,l){for(const u in this._tiles){let f=this._tiles[u];if(l[u]||!f.hasData()||f.tileID.overscaledZ<=n||f.tileID.overscaledZ>a)continue;let _=f.tileID;for(;f&&f.tileID.overscaledZ>n+1;){const b=f.tileID.scaledTo(f.tileID.overscaledZ-1);f=this._tiles[b.key],f&&f.hasData()&&(_=b)}let y=_;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),e[y.key]||e[y.canonical.key]){l[_.key]=_;break}}}findLoadedParent(e,n){if(e.key in this._loadedParentTiles){const a=this._loadedParentTiles[e.key];return a&&a.tileID.overscaledZ>=n?a:null}for(let a=e.overscaledZ-1;a>=n;a--){const l=e.scaledTo(a),u=this._getLoadedTile(l);if(u)return u}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const n=this._tiles[e.key];return n&&n.hasData()?n:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const n=Math.ceil(e.width/this._source.tileSize)+1,a=Math.ceil(e.height/this._source.tileSize)+1,l=Math.floor(n*a*(this._maxTileCacheZoomLevels===null?c.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),u=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,l):l;this._cache.setMaxSize(u)}handleWrapJump(e){const n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){const a={};for(const l in this._tiles){const u=this._tiles[l];u.tileID=u.tileID.unwrapTo(u.tileID.wrap+n),a[u.tileID.key]=u}this._tiles=a;for(const l in this._timers)clearTimeout(this._timers[l]),delete this._timers[l];for(const l in this._tiles)this._setTileReloadTimer(l,this._tiles[l])}}_updateCoveredAndRetainedTiles(e,n,a,l,u,f){const _={},y={},b=Object.keys(e),w=Ee.now();for(const S of b){const P=e[S],I=this._tiles[S];if(!I||I.fadeEndTime!==0&&I.fadeEndTime<=w)continue;const k=this.findLoadedParent(P,n),O=this.findLoadedSibling(P),B=k||O||null;B&&(this._addTile(B.tileID),_[B.tileID.key]=B.tileID),y[S]=P}this._retainLoadedChildren(y,l,a,e);for(const S in _)e[S]||(this._coveredTiles[S]=!0,e[S]=_[S]);if(f){const S={},P={};for(const I of u)this._tiles[I.key].hasData()?S[I.key]=I:P[I.key]=I;for(const I in P){const k=P[I].children(this._source.maxzoom);this._tiles[k[0].key]&&this._tiles[k[1].key]&&this._tiles[k[2].key]&&this._tiles[k[3].key]&&(S[k[0].key]=e[k[0].key]=k[0],S[k[1].key]=e[k[1].key]=k[1],S[k[2].key]=e[k[2].key]=k[2],S[k[3].key]=e[k[3].key]=k[3],delete P[I])}for(const I in P){const k=P[I],O=this.findLoadedParent(k,this._source.minzoom),B=this.findLoadedSibling(k),N=O||B||null;if(N){S[N.tileID.key]=e[N.tileID.key]=N.tileID;for(const U in S)S[U].isChildOf(N.tileID)&&delete S[U]}}for(const I in this._tiles)S[I]||(this._coveredTiles[I]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let a;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(w=>new c.Z(w.canonical.z,w.wrap,w.canonical.z,w.canonical.x,w.canonical.y)):(a=ne(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(a=a.filter(w=>this._source.hasTile(w)))):a=[];const l=Re(e,this._source),u=Math.max(l-Qe.maxOverzooming,this._source.minzoom),f=Math.max(l+Qe.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const w={};for(const S of a)if(S.canonical.z>this._source.minzoom){const P=S.scaledTo(S.canonical.z-1);w[P.key]=P;const I=S.scaledTo(Math.max(this._source.minzoom,Math.min(S.canonical.z,5)));w[I.key]=I}a=a.concat(Object.values(w))}const _=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new c.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const y=this._updateRetainedTiles(a,l);He(this._source.type)&&this._updateCoveredAndRetainedTiles(y,u,f,l,a,n);for(const w in y)this._tiles[w].clearFadeHold();const b=c.am(this._tiles,y);for(const w of b){const S=this._tiles[w];S.hasSymbolBuckets&&!S.holdingForFade()?S.setHoldDuration(this.map._fadeDuration):S.hasSymbolBuckets&&!S.symbolFadeFinished()||this._removeTile(w)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var a;const l={},u={},f=Math.max(n-Qe.maxOverzooming,this._source.minzoom),_=Math.max(n+Qe.maxUnderzooming,this._source.minzoom),y={};for(const b of e){const w=this._addTile(b);l[b.key]=b,w.hasData()||n<this._source.maxzoom&&(y[b.key]=b)}this._retainLoadedChildren(y,n,_,l);for(const b of e){let w=this._tiles[b.key];if(w.hasData())continue;if(n+1>this._source.maxzoom){const P=b.children(this._source.maxzoom)[0],I=this.getTile(P);if(I&&I.hasData()){l[P.key]=P;continue}}else{const P=b.children(this._source.maxzoom);if(l[P[0].key]&&l[P[1].key]&&l[P[2].key]&&l[P[3].key])continue}let S=w.wasRequested();for(let P=b.overscaledZ-1;P>=f;--P){const I=b.scaledTo(P);if(u[I.key])break;if(u[I.key]=!0,w=this.getTile(I),!w&&S&&(w=this._addTile(I)),w){const k=w.hasData();if((k||!(!((a=this.map)===null||a===void 0)&&a.cancelPendingTileRequestsWhileZooming)||S)&&(l[I.key]=I),S=w.wasRequested(),k)break}}}return l}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const n=[];let a,l=this._tiles[e].tileID;for(;l.overscaledZ>0;){if(l.key in this._loadedParentTiles){a=this._loadedParentTiles[l.key];break}n.push(l.key);const u=l.scaledTo(l.overscaledZ-1);if(a=this._getLoadedTile(u),a)break;l=u}for(const u of n)this._loadedParentTiles[u]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const n=this._tiles[e].tileID,a=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=a}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));const a=n;return n||(n=new Zn(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,a||this._source.fire(new c.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const a=n.getExpiryTimeout();a&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},a))}refreshTiles(e){for(const n in this._tiles)(this._isIdRenderable(n)||this._tiles[n].state=="errored")&&e.some(a=>a.equals(this._tiles[n].tileID.canonical))&&this._reloadTile(n,"expired")}_removeTile(e){const n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){const n=e.sourceDataType;e.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&n==="content"&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,a){const l=[],u=this.transform;if(!u)return l;const f=u.getCoveringTilesDetailsProvider().allowWorldCopies(),_=a?u.getCameraQueryGeometry(e):e,y=I=>u.screenPointToMercatorCoordinate(I,this.terrain),b=this.transformBbox(e,y,!f),w=this.transformBbox(_,y,!f),S=this.getIds(),P=c.a2.fromPoints(w);for(let I=0;I<S.length;I++){const k=this._tiles[S[I]];if(k.holdingForFade())continue;const O=f?[k.tileID]:[k.tileID.unwrapTo(-1),k.tileID.unwrapTo(0)],B=Math.pow(2,u.zoom-k.tileID.overscaledZ),N=n*k.queryPadding*c.$/k.tileSize/B;for(const U of O){const q=P.map($=>U.getTilePoint(new c.a1($.x,$.y)));if(q.expandBy(N),q.intersects(qe)){const $=b.map(K=>U.getTilePoint(K)),H=w.map(K=>U.getTilePoint(K));l.push({tile:k,tileID:f?U:U.unwrapTo(0),queryGeometry:$,cameraQueryGeometry:H,scale:B})}}}return l}transformBbox(e,n,a){let l=e.map(n);if(a){const u=c.a2.fromPoints(e);u.shrinkBy(.001*Math.min(u.width(),u.height()));const f=u.map(n);c.a2.fromPoints(l).covers(f)||(l=l.map(_=>_.x>.5?new c.a1(_.x-1,_.y,_.z):_))}return l}getVisibleCoordinates(e){const n=this.getRenderableIds(e).map(a=>this._tiles[a].tileID);return this.transform&&this.transform.populateCache(n),n}hasTransition(){if(this._source.hasTransition())return!0;if(He(this._source.type)){const e=Ee.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setFeatureState(e,n,a){this._state.updateState(e=e||"_geojsonTileLayer",n,a)}removeFeatureState(e,n,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",n,a)}getFeatureState(e,n){return this._state.getState(e=e||"_geojsonTileLayer",n)}setDependencies(e,n,a){const l=this._tiles[e];l&&l.setDependencies(n,a)}reloadTilesForDependencies(e,n){for(const a in this._tiles)this._tiles[a].hasDependency(e,n)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(e,n))}}function Oe(h,e){const n=Math.abs(2*h.wrap)-+(h.wrap<0),a=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||a-n||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function He(h){return h==="raster"||h==="image"||h==="video"}Qe.maxOverzooming=10,Qe.maxUnderzooming=3;class Tt{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let a=1;a<this.points.length;a++)this._distances[a]=this._distances[a-1]+this.points[a].dist(this.points[a-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=c.ah(e,0,1);let n=1,a=this._distances[n];const l=e*this.paddedLength+this.padding;for(;a<l&&n<this._distances.length;)a=this._distances[++n];const u=n-1,f=this._distances[u],_=a-f,y=_>0?(l-f)/_:0;return this.points[u].mult(1-y).add(this.points[n].mult(y))}}function Ht(h,e){let n=!0;return h==="always"||h!=="never"&&e!=="never"||(n=!1),n}class Xt{constructor(e,n,a){const l=this.boxCells=[],u=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(n/a);for(let f=0;f<this.xCellCount*this.yCellCount;f++)l.push([]),u.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,a,l,u){this._forEachCell(n,a,l,u,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(n),this.bboxes.push(a),this.bboxes.push(l),this.bboxes.push(u)}insertCircle(e,n,a,l){this._forEachCell(n-l,a-l,n+l,a+l,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(n),this.circles.push(a),this.circles.push(l)}_insertBoxCell(e,n,a,l,u,f){this.boxCells[u].push(f)}_insertCircleCell(e,n,a,l,u,f){this.circleCells[u].push(f)}_query(e,n,a,l,u,f,_){if(a<0||e>this.width||l<0||n>this.height)return[];const y=[];if(e<=0&&n<=0&&this.width<=a&&this.height<=l){if(u)return[{key:null,x1:e,y1:n,x2:a,y2:l}];for(let b=0;b<this.boxKeys.length;b++)y.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let b=0;b<this.circleKeys.length;b++){const w=this.circles[3*b],S=this.circles[3*b+1],P=this.circles[3*b+2];y.push({key:this.circleKeys[b],x1:w-P,y1:S-P,x2:w+P,y2:S+P})}}else this._forEachCell(e,n,a,l,this._queryCell,y,{hitTest:u,overlapMode:f,seenUids:{box:{},circle:{}}},_);return y}query(e,n,a,l){return this._query(e,n,a,l,!1,null)}hitTest(e,n,a,l,u,f){return this._query(e,n,a,l,!0,u,f).length>0}hitTestCircle(e,n,a,l,u){const f=e-a,_=e+a,y=n-a,b=n+a;if(_<0||f>this.width||b<0||y>this.height)return!1;const w=[];return this._forEachCell(f,y,_,b,this._queryCellCircle,w,{hitTest:!0,overlapMode:l,circle:{x:e,y:n,radius:a},seenUids:{box:{},circle:{}}},u),w.length>0}_queryCell(e,n,a,l,u,f,_,y){const{seenUids:b,hitTest:w,overlapMode:S}=_,P=this.boxCells[u];if(P!==null){const k=this.bboxes;for(const O of P)if(!b.box[O]){b.box[O]=!0;const B=4*O,N=this.boxKeys[O];if(e<=k[B+2]&&n<=k[B+3]&&a>=k[B+0]&&l>=k[B+1]&&(!y||y(N))&&(!w||!Ht(S,N.overlapMode))&&(f.push({key:N,x1:k[B],y1:k[B+1],x2:k[B+2],y2:k[B+3]}),w))return!0}}const I=this.circleCells[u];if(I!==null){const k=this.circles;for(const O of I)if(!b.circle[O]){b.circle[O]=!0;const B=3*O,N=this.circleKeys[O];if(this._circleAndRectCollide(k[B],k[B+1],k[B+2],e,n,a,l)&&(!y||y(N))&&(!w||!Ht(S,N.overlapMode))){const U=k[B],q=k[B+1],$=k[B+2];if(f.push({key:N,x1:U-$,y1:q-$,x2:U+$,y2:q+$}),w)return!0}}}return!1}_queryCellCircle(e,n,a,l,u,f,_,y){const{circle:b,seenUids:w,overlapMode:S}=_,P=this.boxCells[u];if(P!==null){const k=this.bboxes;for(const O of P)if(!w.box[O]){w.box[O]=!0;const B=4*O,N=this.boxKeys[O];if(this._circleAndRectCollide(b.x,b.y,b.radius,k[B+0],k[B+1],k[B+2],k[B+3])&&(!y||y(N))&&!Ht(S,N.overlapMode))return f.push(!0),!0}}const I=this.circleCells[u];if(I!==null){const k=this.circles;for(const O of I)if(!w.circle[O]){w.circle[O]=!0;const B=3*O,N=this.circleKeys[O];if(this._circlesCollide(k[B],k[B+1],k[B+2],b.x,b.y,b.radius)&&(!y||y(N))&&!Ht(S,N.overlapMode))return f.push(!0),!0}}}_forEachCell(e,n,a,l,u,f,_,y){const b=this._convertToXCellCoord(e),w=this._convertToYCellCoord(n),S=this._convertToXCellCoord(a),P=this._convertToYCellCoord(l);for(let I=b;I<=S;I++)for(let k=w;k<=P;k++)if(u.call(this,e,n,a,l,this.xCellCount*k+I,f,_,y))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,a,l,u,f){const _=l-e,y=u-n,b=a+f;return b*b>_*_+y*y}_circleAndRectCollide(e,n,a,l,u,f,_){const y=(f-l)/2,b=Math.abs(e-(l+y));if(b>y+a)return!1;const w=(_-u)/2,S=Math.abs(n-(u+w));if(S>w+a)return!1;if(b<=y||S<=w)return!0;const P=b-y,I=S-w;return P*P+I*I<=a*a}}function Nt(h,e,n){const a=c.L();if(!h){const{vecSouth:S,vecEast:P}=ot(e),I=ct();I[0]=P[0],I[1]=P[1],I[2]=S[0],I[3]=S[1],l=I,(w=(f=(u=I)[0])*(b=u[3])-(y=u[2])*(_=u[1]))&&(l[0]=b*(w=1/w),l[1]=-_*w,l[2]=-y*w,l[3]=f*w),a[0]=I[0],a[1]=I[1],a[4]=I[2],a[5]=I[3]}var l,u,f,_,y,b,w;return c.N(a,a,[1/n,1/n,1]),a}function rt(h,e,n,a){if(h){const l=c.L();if(!e){const{vecSouth:u,vecEast:f}=ot(n);l[0]=f[0],l[1]=f[1],l[4]=u[0],l[5]=u[1]}return c.N(l,l,[a,a,1]),l}return n.pixelsToClipSpaceMatrix}function ot(h){const e=Math.cos(h.rollInRadians),n=Math.sin(h.rollInRadians),a=Math.cos(h.pitchInRadians),l=Math.cos(h.bearingInRadians),u=Math.sin(h.bearingInRadians),f=c.ar();f[0]=-l*a*n-u*e,f[1]=-u*a*n+l*e;const _=c.as(f);_<1e-9?c.at(f):c.au(f,f,1/_);const y=c.ar();y[0]=l*a*e-u*n,y[1]=u*a*e+l*n;const b=c.as(y);return b<1e-9?c.at(y):c.au(y,y,1/b),{vecEast:y,vecSouth:f}}function Ut(h,e,n,a){let l;a?(l=[h,e,a(h,e),1],c.aw(l,l,n)):(l=[h,e,0,1],qn(l,l,n));const u=l[3];return{point:new c.P(l[0]/u,l[1]/u),signedDistanceFromCamera:u,isOccluded:!1}}function Te(h,e){return .5+h/e*.5}function gi(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function At(h,e,n,a,l,u,f,_,y,b,w,S,P){const I=n?h.textSizeData:h.iconSizeData,k=c.an(I,e.transform.zoom),O=[256/e.width*2+1,256/e.height*2+1],B=n?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;B.clear();const N=h.lineVertexArray,U=n?h.text.placedSymbolArray:h.icon.placedSymbolArray,q=e.transform.width/e.transform.height;let $=!1;for(let H=0;H<U.length;H++){const K=U.get(H);if(K.hidden||K.writingMode===c.ao.vertical&&!$){xr(K.numGlyphs,B);continue}$=!1;const G=new c.P(K.anchorX,K.anchorY),te={getElevation:P,pitchedLabelPlaneMatrix:a,lineVertexArray:N,pitchWithMap:u,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:e.transform,tileAnchorPoint:G,unwrappedTileID:y,width:b,height:w,translation:S},ue=Wr(K.anchorX,K.anchorY,te);if(!gi(ue.point,O)){xr(K.numGlyphs,B);continue}const ae=Te(e.transform.cameraToCenterDistance,ue.signedDistanceFromCamera),oe=c.ap(I,k,K),he=u?oe*e.transform.getPitchedTextCorrection(K.anchorX,K.anchorY,y)/ae:oe*ae,we=ke({projectionContext:te,pitchedLabelPlaneMatrixInverse:l,symbol:K,fontSize:he,flip:!1,keepUpright:f,glyphOffsetArray:h.glyphOffsetArray,dynamicLayoutVertexArray:B,aspectRatio:q,rotateToLine:_});$=we.useVertical,(we.notEnoughRoom||$||we.needsFlipping&&ke({projectionContext:te,pitchedLabelPlaneMatrixInverse:l,symbol:K,fontSize:he,flip:!0,keepUpright:f,glyphOffsetArray:h.glyphOffsetArray,dynamicLayoutVertexArray:B,aspectRatio:q,rotateToLine:_}).notEnoughRoom)&&xr(K.numGlyphs,B)}n?h.text.dynamicLayoutVertexBuffer.updateData(B):h.icon.dynamicLayoutVertexBuffer.updateData(B)}function qr(h,e,n,a,l,u,f,_){const y=u.glyphStartIndex+u.numGlyphs,b=u.lineStartIndex,w=u.lineStartIndex+u.lineLength,S=e.getoffsetX(u.glyphStartIndex),P=e.getoffsetX(y-1),I=Hr(h*S,n,a,l,u.segment,b,w,_,f);if(!I)return null;const k=Hr(h*P,n,a,l,u.segment,b,w,_,f);return k?_.projectionCache.anyProjectionOccluded?null:{first:I,last:k}:null}function Gn(h,e,n,a){return h===c.ao.horizontal&&Math.abs(n.y-e.y)>Math.abs(n.x-e.x)*a?{useVertical:!0}:(h===c.ao.vertical?e.y<n.y:e.x>n.x)?{needsFlipping:!0}:null}function ke(h){const{projectionContext:e,pitchedLabelPlaneMatrixInverse:n,symbol:a,fontSize:l,flip:u,keepUpright:f,glyphOffsetArray:_,dynamicLayoutVertexArray:y,aspectRatio:b,rotateToLine:w}=h,S=l/24,P=a.lineOffsetX*S,I=a.lineOffsetY*S;let k;if(a.numGlyphs>1){const O=a.glyphStartIndex+a.numGlyphs,B=a.lineStartIndex,N=a.lineStartIndex+a.lineLength,U=qr(S,_,P,I,u,a,w,e);if(!U)return{notEnoughRoom:!0};const q=_n(U.first.point.x,U.first.point.y,e,n),$=_n(U.last.point.x,U.last.point.y,e,n);if(f&&!u){const H=Gn(a.writingMode,q,$,b);if(H)return H}k=[U.first];for(let H=a.glyphStartIndex+1;H<O-1;H++){const K=Hr(S*_.getoffsetX(H),P,I,u,a.segment,B,N,e,w);if(!K)return{notEnoughRoom:!0};k.push(K)}k.push(U.last)}else{if(f&&!u){const B=hi(e.tileAnchorPoint.x,e.tileAnchorPoint.y,e).point,N=a.lineStartIndex+a.segment+1,U=new c.P(e.lineVertexArray.getx(N),e.lineVertexArray.gety(N)),q=hi(U.x,U.y,e),$=q.signedDistanceFromCamera>0?q.point:et(e.tileAnchorPoint,U,B,1,e),H=_n(B.x,B.y,e,n),K=_n($.x,$.y,e,n),G=Gn(a.writingMode,H,K,b);if(G)return G}const O=Hr(S*_.getoffsetX(a.glyphStartIndex),P,I,u,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,e,w);if(!O||e.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};k=[O]}for(const O of k)c.av(y,O.point,O.angle);return{}}function et(h,e,n,a,l){const u=h.add(h.sub(e)._unit()),f=hi(u.x,u.y,l).point,_=n.sub(f);return n.add(_._mult(a/_.mag()))}function Je(h,e,n){const a=e.projectionCache;if(a.projections[h])return a.projections[h];const l=new c.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),u=hi(l.x,l.y,e);if(u.signedDistanceFromCamera>0)return a.projections[h]=u.point,a.anyProjectionOccluded=a.anyProjectionOccluded||u.isOccluded,u.point;const f=h-n.direction;return et(n.distanceFromAnchor===0?e.tileAnchorPoint:new c.P(e.lineVertexArray.getx(f),e.lineVertexArray.gety(f)),l,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function hi(h,e,n){const a=h+n.translation[0],l=e+n.translation[1];let u;return n.pitchWithMap?(u=Ut(a,l,n.pitchedLabelPlaneMatrix,n.getElevation),u.isOccluded=!1):(u=n.transform.projectTileCoordinates(a,l,n.unwrappedTileID,n.getElevation),u.point.x=(.5*u.point.x+.5)*n.width,u.point.y=(.5*-u.point.y+.5)*n.height),u}function _n(h,e,n,a){if(n.pitchWithMap){const l=[h,e,0,1];return c.aw(l,l,a),n.transform.projectTileCoordinates(l[0]/l[3],l[1]/l[3],n.unwrappedTileID,n.getElevation).point}return{x:h/n.width*2-1,y:1-e/n.height*2}}function Wr(h,e,n){return n.transform.projectTileCoordinates(h,e,n.unwrappedTileID,n.getElevation)}function Ye(h,e,n){return h._unit()._perp()._mult(e*n)}function ca(h,e,n,a,l,u,f,_,y){if(_.projectionCache.offsets[h])return _.projectionCache.offsets[h];const b=n.add(e);if(h+y.direction<a||h+y.direction>=l)return _.projectionCache.offsets[h]=b,b;const w=Je(h+y.direction,_,y),S=Ye(w.sub(n),f,y.direction),P=n.add(S),I=w.add(S);return _.projectionCache.offsets[h]=c.ax(u,b,P,I)||b,_.projectionCache.offsets[h]}function Hr(h,e,n,a,l,u,f,_,y){const b=a?h-e:h+e;let w=b>0?1:-1,S=0;a&&(w*=-1,S=Math.PI),w<0&&(S+=Math.PI);let P,I=w>0?u+l:u+l+1;_.projectionCache.cachedAnchorPoint?P=_.projectionCache.cachedAnchorPoint:(P=hi(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=P);let k,O,B=P,N=P,U=0,q=0;const $=Math.abs(b),H=[];let K;for(;U+q<=$;){if(I+=w,I<u||I>=f)return null;U+=q,N=B,O=k;const ue={absOffsetX:$,direction:w,distanceFromAnchor:U,previousVertex:N};if(B=Je(I,_,ue),n===0)H.push(N),K=B.sub(N);else{let ae;const oe=B.sub(N);ae=oe.mag()===0?Ye(Je(I+w,_,ue).sub(B),n,w):Ye(oe,n,w),O||(O=N.add(ae)),k=ca(I,ae,B,u,f,O,n,_,ue),H.push(O),K=k.sub(O)}q=K.mag()}const G=K._mult(($-U)/q)._add(O||N),te=S+Math.atan2(B.y-N.y,B.x-N.x);return H.push(G),{point:G,angle:y?te:0,path:H}}const ha=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function xr(h,e){for(let n=0;n<h;n++){const a=e.length;e.resize(a+4),e.float32.set(ha,3*a)}}function qn(h,e,n){const a=e[0],l=e[1];return h[0]=n[0]*a+n[4]*l+n[12],h[1]=n[1]*a+n[5]*l+n[13],h[3]=n[3]*a+n[7]*l+n[15],h}const Rt=100;class ua{constructor(e,n=new Xt(e.width+200,e.height+200,25),a=new Xt(e.width+200,e.height+200,25)){this.transform=e,this.grid=n,this.ignoredGrid=a,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Rt,this.screenBottomBoundary=e.height+Rt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,n,a,l,u,f,_,y,b,w,S,P){const I=this.projectAndGetPerspectiveRatio(e.anchorPointX+y[0],e.anchorPointY+y[1],u,w,P),k=a*I.perspectiveRatio;let O;if(f||_)O=this._projectCollisionBox(e,k,l,u,f,_,y,I,w,S,P);else{const K=I.x+(S?S.x*k:0),G=I.y+(S?S.y*k:0);O={allPointsOccluded:!1,box:[K+e.x1*k,G+e.y1*k,K+e.x2*k,G+e.y2*k]}}const[B,N,U,q]=O.box,$=f?O.allPointsOccluded:I.isOccluded;let H=$;return H||(H=I.perspectiveRatio<this.perspectiveRatioCutoff),H||(H=!this.isInsideGrid(B,N,U,q)),H||n!=="always"&&this.grid.hitTest(B,N,U,q,n,b)?{box:[B,N,U,q],placeable:!1,offscreen:!1,occluded:$}:{box:[B,N,U,q],placeable:!0,offscreen:this.isOffscreen(B,N,U,q),occluded:$}}placeCollisionCircles(e,n,a,l,u,f,_,y,b,w,S,P,I,k){const O=[],B=new c.P(n.anchorX,n.anchorY),N=this.getPerspectiveRatio(B.x,B.y,f,k),U=(b?u*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,f)/N:u*N)/c.aB,q={getElevation:k,pitchedLabelPlaneMatrix:_,lineVertexArray:a,pitchWithMap:b,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:B,unwrappedTileID:f,width:this.transform.width,height:this.transform.height,translation:I},$=qr(U,l,n.lineOffsetX*U,n.lineOffsetY*U,!1,n,!1,q);let H=!1,K=!1,G=!0;if($){const te=.5*S*N+P,ue=new c.P(-100,-100),ae=new c.P(this.screenRightBoundary,this.screenBottomBoundary),oe=new Tt,he=$.first,we=$.last;let Se=[];for(let Ke=he.path.length-1;Ke>=1;Ke--)Se.push(he.path[Ke]);for(let Ke=1;Ke<we.path.length;Ke++)Se.push(we.path[Ke]);const ye=2.5*te;if(b){const Ke=this.projectPathToScreenSpace(Se,q);Se=Ke.some(dt=>dt.signedDistanceFromCamera<=0)?[]:Ke.map(dt=>dt.point)}let Le=[];if(Se.length>0){const Ke=Se[0].clone(),dt=Se[0].clone();for(let yt=1;yt<Se.length;yt++)Ke.x=Math.min(Ke.x,Se[yt].x),Ke.y=Math.min(Ke.y,Se[yt].y),dt.x=Math.max(dt.x,Se[yt].x),dt.y=Math.max(dt.y,Se[yt].y);Le=Ke.x>=ue.x&&dt.x<=ae.x&&Ke.y>=ue.y&&dt.y<=ae.y?[Se]:dt.x<ue.x||Ke.x>ae.x||dt.y<ue.y||Ke.y>ae.y?[]:c.ay([Se],ue.x,ue.y,ae.x,ae.y)}for(const Ke of Le){oe.reset(Ke,.25*te);let dt=0;dt=oe.length<=.5*te?1:Math.ceil(oe.paddedLength/ye)+1;for(let yt=0;yt<dt;yt++){const mt=yt/Math.max(dt-1,1),Ct=oe.lerp(mt),zt=Ct.x+Rt,Xe=Ct.y+Rt;O.push(zt,Xe,te,0);const xt=zt-te,Zt=Xe-te,Yt=zt+te,ri=Xe+te;if(G=G&&this.isOffscreen(xt,Zt,Yt,ri),K=K||this.isInsideGrid(xt,Zt,Yt,ri),e!=="always"&&this.grid.hitTestCircle(zt,Xe,te,e,w)&&(H=!0,!y))return{circles:[],offscreen:!1,collisionDetected:H}}}}return{circles:!y&&H||!K||N<this.perspectiveRatioCutoff?[]:O,offscreen:G,collisionDetected:H}}projectPathToScreenSpace(e,n){const a=function(l,u){const f=c.L();return c.aq(f,u.pitchedLabelPlaneMatrix),l.map(_=>{const y=Ut(_.x,_.y,f,u.getElevation),b=u.transform.projectTileCoordinates(y.point.x,y.point.y,u.unwrappedTileID,u.getElevation);return b.point.x=(.5*b.point.x+.5)*u.width,b.point.y=(.5*-b.point.y+.5)*u.height,b})}(e,n);return function(l){let u=0,f=0,_=0,y=0;for(let b=0;b<l.length;b++)l[b].isOccluded?(_=b+1,y=0):(y++,y>f&&(f=y,u=_));return l.slice(u,u+f)}(a)}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],a=new c.a2;for(const S of e){const P=new c.P(S.x+Rt,S.y+Rt);a.extend(P),n.push(P)}const{minX:l,minY:u,maxX:f,maxY:_}=a,y=this.grid.query(l,u,f,_).concat(this.ignoredGrid.query(l,u,f,_)),b={},w={};for(const S of y){const P=S.key;if(b[P.bucketInstanceId]===void 0&&(b[P.bucketInstanceId]={}),b[P.bucketInstanceId][P.featureIndex])continue;const I=[new c.P(S.x1,S.y1),new c.P(S.x2,S.y1),new c.P(S.x2,S.y2),new c.P(S.x1,S.y2)];c.az(n,I)&&(b[P.bucketInstanceId][P.featureIndex]=!0,w[P.bucketInstanceId]===void 0&&(w[P.bucketInstanceId]=[]),w[P.bucketInstanceId].push(P.featureIndex))}return w}insertCollisionBox(e,n,a,l,u,f){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:u,collisionGroupID:f,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,a,l,u,f){const _=a?this.ignoredGrid:this.grid,y={bucketInstanceId:l,featureIndex:u,collisionGroupID:f,overlapMode:n};for(let b=0;b<e.length;b+=4)_.insertCircle(y,e[b],e[b+1],e[b+2])}projectAndGetPerspectiveRatio(e,n,a,l,u){if(u){let f;l?(f=[e,n,l(e,n),1],c.aw(f,f,u)):(f=[e,n,0,1],qn(f,f,u));const _=f[3];return{x:(f[0]/_+1)/2*this.transform.width+Rt,y:(-f[1]/_+1)/2*this.transform.height+Rt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/_*.5,isOccluded:!1,signedDistanceFromCamera:_}}{const f=this.transform.projectTileCoordinates(e,n,a,l);return{x:(f.point.x+1)/2*this.transform.width+Rt,y:(1-f.point.y)/2*this.transform.height+Rt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/f.signedDistanceFromCamera*.5,isOccluded:f.isOccluded,signedDistanceFromCamera:f.signedDistanceFromCamera}}}getPerspectiveRatio(e,n,a,l){const u=this.transform.projectTileCoordinates(e,n,a,l);return .5+this.transform.cameraToCenterDistance/u.signedDistanceFromCamera*.5}isOffscreen(e,n,a,l){return a<Rt||e>=this.screenRightBoundary||l<Rt||n>this.screenBottomBoundary}isInsideGrid(e,n,a,l){return a>=0&&e<this.gridRightBoundary&&l>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const e=c.ag([]);return c.M(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,a,l,u,f,_,y,b,w,S){let P=1,I=0,k=0,O=1;const B=e.anchorPointX+_[0],N=e.anchorPointY+_[1];if(f&&!u){const Se=this.projectAndGetPerspectiveRatio(B+1,N,l,b,S),ye=Se.x-y.x,Le=Math.atan((Se.y-y.y)/ye)+(ye<0?Math.PI:0),Ke=Math.sin(Le),dt=Math.cos(Le);P=dt,I=Ke,k=-Ke,O=dt}else if(!f&&u){const Se=ot(this.transform);P=Se.vecEast[0],I=Se.vecEast[1],k=Se.vecSouth[0],O=Se.vecSouth[1]}let U=y.x,q=y.y,$=n;u&&(U=B,q=N,$=Math.pow(2,-(this.transform.zoom-a.overscaledZ)),$*=this.transform.getPitchedTextCorrection(B,N,l),w||($*=c.ah(.5+y.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),w&&(U+=P*w.x*$+k*w.y*$,q+=I*w.x*$+O*w.y*$);const H=e.x1*$,K=e.x2*$,G=(H+K)/2,te=e.y1*$,ue=e.y2*$,ae=(te+ue)/2,oe=[{offsetX:H,offsetY:te},{offsetX:G,offsetY:te},{offsetX:K,offsetY:te},{offsetX:K,offsetY:ae},{offsetX:K,offsetY:ue},{offsetX:G,offsetY:ue},{offsetX:H,offsetY:ue},{offsetX:H,offsetY:ae}];let he=[];for(const{offsetX:Se,offsetY:ye}of oe)he.push(new c.P(U+P*Se+k*ye,q+I*Se+O*ye));let we=!1;if(u){const Se=he.map(ye=>this.projectAndGetPerspectiveRatio(ye.x,ye.y,l,b,S));we=Se.some(ye=>!ye.isOccluded),he=Se.map(ye=>new c.P(ye.x,ye.y))}else we=!0;return{box:c.aA(he),allPointsOccluded:!we}}}class Ai{constructor(e,n,a,l){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):l&&a?1:0,this.placed=a}isHidden(){return this.opacity===0&&!this.placed}}class vt{constructor(e,n,a,l,u){this.text=new Ai(e?e.text:null,n,a,u),this.icon=new Ai(e?e.icon:null,n,l,u)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ml{constructor(e,n,a){this.text=e,this.icon=n,this.skipFade=a}}class Ss{constructor(e,n,a,l,u){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=a,this.bucketIndex=l,this.tileID=u}}class uo{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:a=>a.collisionGroupID===n}}return this.collisionGroups[e]}}function Xr(h,e,n,a,l){const{horizontalAlign:u,verticalAlign:f}=c.aH(h);return new c.P(-(u-.5)*e+a[0]*l,-(f-.5)*n+a[1]*l)}class Yr{constructor(e,n,a,l,u){this.transform=e.clone(),this.terrain=n,this.collisionIndex=new ua(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new uo(l),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=u,u&&(u.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const n=this.terrain;return n?(a,l)=>n.getElevation(e,a,l):null}getBucketParts(e,n,a,l){const u=a.getBucket(n),f=a.latestFeatureIndex;if(!u||!f||n.id!==u.layerIds[0])return;const _=a.collisionBoxArray,y=u.layers[0].layout,b=u.layers[0].paint,w=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),S=a.tileSize/c.$,P=a.tileID.toUnwrapped(),I=y.get("text-rotation-alignment")==="map",k=c.aC(a,1,this.transform.zoom),O=c.aD(this.collisionIndex.transform,a,b.get("text-translate"),b.get("text-translate-anchor")),B=c.aD(this.collisionIndex.transform,a,b.get("icon-translate"),b.get("icon-translate-anchor")),N=Nt(I,this.transform,k);this.retainedQueryData[u.bucketInstanceId]=new Ss(u.bucketInstanceId,f,u.sourceLayerIndex,u.index,a.tileID);const U={bucket:u,layout:y,translationText:O,translationIcon:B,unwrappedTileID:P,pitchedLabelPlaneMatrix:N,scale:w,textPixelRatio:S,holdingForFade:a.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:c.an(u.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(u.sourceID)};if(l)for(const q of u.sortKeyRanges){const{sortKey:$,symbolInstanceStart:H,symbolInstanceEnd:K}=q;e.push({sortKey:$,symbolInstanceStart:H,symbolInstanceEnd:K,parameters:U})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:u.symbolInstances.length,parameters:U})}attemptAnchorPlacement(e,n,a,l,u,f,_,y,b,w,S,P,I,k,O,B,N,U,q,$){const H=c.aE[e.textAnchor],K=[e.textOffset0,e.textOffset1],G=Xr(H,a,l,K,u),te=this.collisionIndex.placeCollisionBox(n,P,y,b,w,_,f,B,S.predicate,q,G,$);if((!U||this.collisionIndex.placeCollisionBox(U,P,y,b,w,_,f,N,S.predicate,q,G,$).placeable)&&te.placeable){let ue;if(this.prevPlacement&&this.prevPlacement.variableOffsets[I.crossTileID]&&this.prevPlacement.placements[I.crossTileID]&&this.prevPlacement.placements[I.crossTileID].text&&(ue=this.prevPlacement.variableOffsets[I.crossTileID].anchor),I.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[I.crossTileID]={textOffset:K,width:a,height:l,anchor:H,textBoxScale:u,prevAnchor:ue},this.markUsedJustification(k,H,I,O),k.allowVerticalPlacement&&(this.markUsedOrientation(k,O,I),this.placedOrientations[I.crossTileID]=O),{shift:G,placedGlyphBoxes:te}}}placeLayerBucketPart(e,n,a){const{bucket:l,layout:u,translationText:f,translationIcon:_,unwrappedTileID:y,pitchedLabelPlaneMatrix:b,textPixelRatio:w,holdingForFade:S,collisionBoxArray:P,partiallyEvaluatedTextSize:I,collisionGroup:k}=e.parameters,O=u.get("text-optional"),B=u.get("icon-optional"),N=c.aF(u,"text-overlap","text-allow-overlap"),U=N==="always",q=c.aF(u,"icon-overlap","icon-allow-overlap"),$=q==="always",H=u.get("text-rotation-alignment")==="map",K=u.get("text-pitch-alignment")==="map",G=u.get("icon-text-fit")!=="none",te=u.get("symbol-z-order")==="viewport-y",ue=U&&($||!l.hasIconData()||B),ae=$&&(U||!l.hasTextData()||O);!l.collisionArrays&&P&&l.deserializeCollisionBoxes(P);const oe=this.retainedQueryData[l.bucketInstanceId].tileID,he=this._getTerrainElevationFunc(oe),we=this.transform.getFastPathSimpleProjectionMatrix(oe),Se=(ye,Le,Ke)=>{var dt,yt;if(n[ye.crossTileID])return;if(S)return void(this.placements[ye.crossTileID]=new Ml(!1,!1,!1));let mt=!1,Ct=!1,zt=!0,Xe=null,xt={box:null,placeable:!1,offscreen:null,occluded:!1},Zt={placeable:!1},Yt=null,ri=null,Si=null,ar=0,tn=0,rn=0;Le.textFeatureIndex?ar=Le.textFeatureIndex:ye.useRuntimeCollisionCircles&&(ar=ye.featureIndex),Le.verticalTextFeatureIndex&&(tn=Le.verticalTextFeatureIndex);const ps=Le.textBox;if(ps){const Li=Gt=>{let Kt=c.ao.horizontal;if(l.allowVerticalPlacement&&!Gt&&this.prevPlacement){const Hi=this.prevPlacement.placedOrientations[ye.crossTileID];Hi&&(this.placedOrientations[ye.crossTileID]=Hi,Kt=Hi,this.markUsedOrientation(l,Kt,ye))}return Kt},or=(Gt,Kt)=>{if(l.allowVerticalPlacement&&ye.numVerticalGlyphVertices>0&&Le.verticalTextBox){for(const Hi of l.writingModes)if(Hi===c.ao.vertical?(xt=Kt(),Zt=xt):xt=Gt(),xt&&xt.placeable)break}else xt=Gt()},Mi=ye.textAnchorOffsetStartIndex,nn=ye.textAnchorOffsetEndIndex;if(nn===Mi){const Gt=(Kt,Hi)=>{const qt=this.collisionIndex.placeCollisionBox(Kt,N,w,oe,y,K,H,f,k.predicate,he,void 0,we);return qt&&qt.placeable&&(this.markUsedOrientation(l,Hi,ye),this.placedOrientations[ye.crossTileID]=Hi),qt};or(()=>Gt(ps,c.ao.horizontal),()=>{const Kt=Le.verticalTextBox;return l.allowVerticalPlacement&&ye.numVerticalGlyphVertices>0&&Kt?Gt(Kt,c.ao.vertical):{box:null,offscreen:null}}),Li(xt&&xt.placeable)}else{let Gt=c.aE[(yt=(dt=this.prevPlacement)===null||dt===void 0?void 0:dt.variableOffsets[ye.crossTileID])===null||yt===void 0?void 0:yt.anchor];const Kt=(qt,Js,ms)=>{const Ar=qt.x2-qt.x1,lr=qt.y2-qt.y1,sn=ye.textBoxScale,yc=G&&q==="never"?Js:null;let ji=null,xc=N==="never"?1:2,sl="never";Gt&&xc++;for(let Wa=0;Wa<xc;Wa++){for(let Ha=Mi;Ha<nn;Ha++){const an=l.textAnchorOffsets.get(Ha);if(Gt&&an.textAnchor!==Gt)continue;const kr=this.attemptAnchorPlacement(an,qt,Ar,lr,sn,H,K,w,oe,y,k,sl,ye,l,ms,f,_,yc,he);if(kr&&(ji=kr.placedGlyphBoxes,ji&&ji.placeable))return mt=!0,Xe=kr.shift,ji}Gt?Gt=null:sl=N}return a&&!ji&&(ji={box:this.collisionIndex.placeCollisionBox(ps,"always",w,oe,y,K,H,f,k.predicate,he,void 0,we).box,offscreen:!1,placeable:!1,occluded:!1}),ji};or(()=>Kt(ps,Le.iconBox,c.ao.horizontal),()=>{const qt=Le.verticalTextBox;return l.allowVerticalPlacement&&(!xt||!xt.placeable)&&ye.numVerticalGlyphVertices>0&&qt?Kt(qt,Le.verticalIconBox,c.ao.vertical):{box:null,occluded:!0,offscreen:null}}),xt&&(mt=xt.placeable,zt=xt.offscreen);const Hi=Li(xt&&xt.placeable);if(!mt&&this.prevPlacement){const qt=this.prevPlacement.variableOffsets[ye.crossTileID];qt&&(this.variableOffsets[ye.crossTileID]=qt,this.markUsedJustification(l,qt.anchor,ye,Hi))}}}if(Yt=xt,mt=Yt&&Yt.placeable,zt=Yt&&Yt.offscreen,ye.useRuntimeCollisionCircles){const Li=l.text.placedSymbolArray.get(ye.centerJustifiedTextSymbolIndex),or=c.ap(l.textSizeData,I,Li),Mi=u.get("text-padding");ri=this.collisionIndex.placeCollisionCircles(N,Li,l.lineVertexArray,l.glyphOffsetArray,or,y,b,a,K,k.predicate,ye.collisionCircleDiameter,Mi,f,he),ri.circles.length&&ri.collisionDetected&&!a&&c.w("Collisions detected, but collision boxes are not shown"),mt=U||ri.circles.length>0&&!ri.collisionDetected,zt=zt&&ri.offscreen}if(Le.iconFeatureIndex&&(rn=Le.iconFeatureIndex),Le.iconBox){const Li=or=>this.collisionIndex.placeCollisionBox(or,q,w,oe,y,K,H,_,k.predicate,he,G&&Xe?Xe:void 0,we);Zt&&Zt.placeable&&Le.verticalIconBox?(Si=Li(Le.verticalIconBox),Ct=Si.placeable):(Si=Li(Le.iconBox),Ct=Si.placeable),zt=zt&&Si.offscreen}const fs=O||ye.numHorizontalGlyphVertices===0&&ye.numVerticalGlyphVertices===0,Rn=B||ye.numIconVertices===0;fs||Rn?Rn?fs||(Ct=Ct&&mt):mt=Ct&&mt:Ct=mt=Ct&&mt;const Fn=Ct&&Si.placeable;if(mt&&Yt.placeable&&this.collisionIndex.insertCollisionBox(Yt.box,N,u.get("text-ignore-placement"),l.bucketInstanceId,Zt&&Zt.placeable&&tn?tn:ar,k.ID),Fn&&this.collisionIndex.insertCollisionBox(Si.box,q,u.get("icon-ignore-placement"),l.bucketInstanceId,rn,k.ID),ri&&mt&&this.collisionIndex.insertCollisionCircles(ri.circles,N,u.get("text-ignore-placement"),l.bucketInstanceId,ar,k.ID),a&&this.storeCollisionData(l.bucketInstanceId,Ke,Le,Yt,Si,ri),ye.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(l.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[ye.crossTileID]=new Ml((mt||ue)&&!(Yt!=null&&Yt.occluded),(Ct||ae)&&!(Si!=null&&Si.occluded),zt||l.justReloaded),n[ye.crossTileID]=!0};if(te){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const ye=l.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let Le=ye.length-1;Le>=0;--Le){const Ke=ye[Le];Se(l.symbolInstances.get(Ke),l.collisionArrays[Ke],Ke)}}else for(let ye=e.symbolInstanceStart;ye<e.symbolInstanceEnd;ye++)Se(l.symbolInstances.get(ye),l.collisionArrays[ye],ye);l.justReloaded=!1}storeCollisionData(e,n,a,l,u,f){if(a.textBox||a.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)),a.textBox&&(y.text=l.box),a.iconBox&&(y.icon=u.box)}if(f){let _=this.collisionCircleArrays[e];_===void 0&&(_=this.collisionCircleArrays[e]=[]);for(let y=0;y<f.circles.length;y+=4)_.push(f.circles[y+0]-Rt),_.push(f.circles[y+1]-Rt),_.push(f.circles[y+2]),_.push(f.collisionDetected?1:0)}}markUsedJustification(e,n,a,l){let u;u=l===c.ao.vertical?a.verticalPlacedTextSymbolIndex:{left:a.leftJustifiedTextSymbolIndex,center:a.centerJustifiedTextSymbolIndex,right:a.rightJustifiedTextSymbolIndex}[c.aG(n)];const f=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex,a.verticalPlacedTextSymbolIndex];for(const _ of f)_>=0&&(e.text.placedSymbolArray.get(_).crossTileID=u>=0&&_!==u?0:a.crossTileID)}markUsedOrientation(e,n,a){const l=n===c.ao.horizontal||n===c.ao.horizontalOnly?n:0,u=n===c.ao.vertical?n:0,f=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const _ of f)e.text.placedSymbolArray.get(_).placedOrientation=l;a.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=u)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let a=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const l=n?n.symbolFadeChange(e):1,u=n?n.opacities:{},f=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(const y in this.placements){const b=this.placements[y],w=u[y];w?(this.opacities[y]=new vt(w,l,b.text,b.icon),a=a||b.text!==w.text.placed||b.icon!==w.icon.placed):(this.opacities[y]=new vt(null,l,b.text,b.icon,b.skipFade),a=a||b.text||b.icon)}for(const y in u){const b=u[y];if(!this.opacities[y]){const w=new vt(b,l,!1,!1);w.isHidden()||(this.opacities[y]=w,a=a||b.text.placed||b.icon.placed)}}for(const y in f)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=f[y]);for(const y in _)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=_[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){const a={};for(const l of n){const u=l.getBucket(e);u&&l.latestFeatureIndex&&e.id===u.layerIds[0]&&this.updateBucketOpacities(u,l.tileID,a,l.collisionBoxArray)}}updateBucketOpacities(e,n,a,l){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const u=e.layers[0],f=u.layout,_=new vt(null,0,!1,!1,!0),y=f.get("text-allow-overlap"),b=f.get("icon-allow-overlap"),w=u._unevaluatedLayout.hasValue("text-variable-anchor")||u._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S=f.get("text-rotation-alignment")==="map",P=f.get("text-pitch-alignment")==="map",I=f.get("icon-text-fit")!=="none",k=new vt(null,0,y&&(b||!e.hasIconData()||f.get("icon-optional")),b&&(y||!e.hasTextData()||f.get("text-optional")),!0);!e.collisionArrays&&l&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(l);const O=(N,U,q)=>{for(let $=0;$<U/4;$++)N.opacityVertexArray.emplaceBack(q);N.hasVisibleVertices=N.hasVisibleVertices||q!==Hn},B=this.collisionBoxArrays.get(e.bucketInstanceId);for(let N=0;N<e.symbolInstances.length;N++){const U=e.symbolInstances.get(N),{numHorizontalGlyphVertices:q,numVerticalGlyphVertices:$,crossTileID:H}=U;let K=this.opacities[H];a[H]?K=_:K||(K=k,this.opacities[H]=K),a[H]=!0;const G=U.numIconVertices>0,te=this.placedOrientations[U.crossTileID],ue=te===c.ao.vertical,ae=te===c.ao.horizontal||te===c.ao.horizontalOnly;if(q>0||$>0){const he=fo(K.text);O(e.text,q,ue?Hn:he),O(e.text,$,ae?Hn:he);const we=K.text.isHidden();[U.rightJustifiedTextSymbolIndex,U.centerJustifiedTextSymbolIndex,U.leftJustifiedTextSymbolIndex].forEach(Le=>{Le>=0&&(e.text.placedSymbolArray.get(Le).hidden=we||ue?1:0)}),U.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(U.verticalPlacedTextSymbolIndex).hidden=we||ae?1:0);const Se=this.variableOffsets[U.crossTileID];Se&&this.markUsedJustification(e,Se.anchor,U,te);const ye=this.placedOrientations[U.crossTileID];ye&&(this.markUsedJustification(e,"left",U,ye),this.markUsedOrientation(e,ye,U))}if(G){const he=fo(K.icon),we=!(I&&U.verticalPlacedIconSymbolIndex&&ue);U.placedIconSymbolIndex>=0&&(O(e.icon,U.numIconVertices,we?he:Hn),e.icon.placedSymbolArray.get(U.placedIconSymbolIndex).hidden=K.icon.isHidden()),U.verticalPlacedIconSymbolIndex>=0&&(O(e.icon,U.numVerticalIconVertices,we?Hn:he),e.icon.placedSymbolArray.get(U.verticalPlacedIconSymbolIndex).hidden=K.icon.isHidden())}const oe=B&&B.has(N)?B.get(N):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const he=e.collisionArrays[N];if(he){let we=new c.P(0,0);if(he.textBox||he.verticalTextBox){let Se=!0;if(w){const ye=this.variableOffsets[H];ye?(we=Xr(ye.anchor,ye.width,ye.height,ye.textOffset,ye.textBoxScale),S&&we._rotate(P?-this.transform.bearingInRadians:this.transform.bearingInRadians)):Se=!1}if(he.textBox||he.verticalTextBox){let ye;he.textBox&&(ye=ue),he.verticalTextBox&&(ye=ae),po(e.textCollisionBox.collisionVertexArray,K.text.placed,!Se||ye,oe.text,we.x,we.y)}}if(he.iconBox||he.verticalIconBox){const Se=!!(!ae&&he.verticalIconBox);let ye;he.iconBox&&(ye=Se),he.verticalIconBox&&(ye=!Se),po(e.iconCollisionBox.collisionVertexArray,K.icon.placed,ye,oe.icon,I?we.x:0,I?we.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 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){const a=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*a>e}setStale(){this.stale=!0}}function po(h,e,n,a,l,u){a&&a.length!==0||(a=[0,0,0,0]);const f=a[0]-Rt,_=a[1]-Rt,y=a[2]-Rt,b=a[3]-Rt;h.emplaceBack(e?1:0,n?1:0,l||0,u||0,f,_),h.emplaceBack(e?1:0,n?1:0,l||0,u||0,y,_),h.emplaceBack(e?1:0,n?1:0,l||0,u||0,y,b),h.emplaceBack(e?1:0,n?1:0,l||0,u||0,f,b)}const Il=Math.pow(2,25),Cl=Math.pow(2,24),Wn=Math.pow(2,17),El=Math.pow(2,16),Zc=Math.pow(2,9),Gc=Math.pow(2,8),qc=Math.pow(2,1);function fo(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const e=h.placed?1:0,n=Math.floor(127*h.opacity);return n*Il+e*Cl+n*Wn+e*El+n*Zc+e*Gc+n*qc+e}const Hn=0;class mo{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,a,l,u){const f=this._bucketParts;for(;this._currentTileIndex<e.length;)if(n.getBucketParts(f,l,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,u())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,f.sort((_,y)=>_.sortKey-y.sortKey));this._currentPartIndex<f.length;)if(n.placeLayerBucketPart(f[this._currentPartIndex],this._seenCrossTileIDs,a),this._currentPartIndex++,u())return!0;return!1}}class go{constructor(e,n,a,l,u,f,_,y){this.placement=new Yr(e,n,f,_,y),this._currentPlacementIndex=a.length-1,this._forceFullPlacement=l,this._showCollisionBoxes=u,this._done=!1}isDone(){return this._done}continuePlacement(e,n,a){const l=Ee.now(),u=()=>!this._forceFullPlacement&&Ee.now()-l>2;for(;this._currentPlacementIndex>=0;){const f=n[e[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(f.type==="symbol"&&(!f.minzoom||f.minzoom<=_)&&(!f.maxzoom||f.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new mo(f)),this._inProgressLayer.continuePlacement(a[f.source],this.placement,this._showCollisionBoxes,f,u))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Xn=512/c.$/2;class _o{constructor(e,n,a){this.tileID=e,this.bucketInstanceId=a,this._symbolsByKey={};const l=new Map;for(let u=0;u<n.length;u++){const f=n.get(u),_=f.key,y=l.get(_);y?y.push(f):l.set(_,[f])}for(const[u,f]of l){const _={positions:f.map(y=>({x:Math.floor(y.anchorX*Xn),y:Math.floor(y.anchorY*Xn)})),crossTileIDs:f.map(y=>y.crossTileID)};if(_.positions.length>128){const y=new c.aI(_.positions.length,16,Uint16Array);for(const{x:b,y:w}of _.positions)y.add(b,w);y.finish(),delete _.positions,_.index=y}this._symbolsByKey[u]=_}}getScaledCoordinates(e,n){const{x:a,y:l,z:u}=this.tileID.canonical,{x:f,y:_,z:y}=n.canonical,b=Xn/Math.pow(2,y-u),w=(_*c.$+e.anchorY)*b,S=l*c.$*Xn;return{x:Math.floor((f*c.$+e.anchorX)*b-a*c.$*Xn),y:Math.floor(w-S)}}findMatches(e,n,a){const l=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let u=0;u<e.length;u++){const f=e.get(u);if(f.crossTileID)continue;const _=this._symbolsByKey[f.key];if(!_)continue;const y=this.getScaledCoordinates(f,n);if(_.index){const b=_.index.range(y.x-l,y.y-l,y.x+l,y.y+l).sort();for(const w of b){const S=_.crossTileIDs[w];if(!a[S]){a[S]=!0,f.crossTileID=S;break}}}else if(_.positions)for(let b=0;b<_.positions.length;b++){const w=_.positions[b],S=_.crossTileIDs[b];if(Math.abs(w.x-y.x)<=l&&Math.abs(w.y-y.y)<=l&&!a[S]){a[S]=!0,f.crossTileID=S;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}}class yo{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Wc{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const n=Math.round((e-this.lng)/360);if(n!==0)for(const a in this.indexes){const l=this.indexes[a],u={};for(const f in l){const _=l[f];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),u[_.tileID.key]=_}this.indexes[a]=u}this.lng=e}addBucket(e,n,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let u=0;u<n.symbolInstances.length;u++)n.symbolInstances.get(u).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const l=this.usedCrossTileIDs[e.overscaledZ];for(const u in this.indexes){const f=this.indexes[u];if(Number(u)>e.overscaledZ)for(const _ in f){const y=f[_];y.tileID.isChildOf(e)&&y.findMatches(n.symbolInstances,e,l)}else{const _=f[e.scaledTo(Number(u)).key];_&&_.findMatches(n.symbolInstances,e,l)}}for(let u=0;u<n.symbolInstances.length;u++){const f=n.symbolInstances.get(u);f.crossTileID||(f.crossTileID=a.generate(),l[f.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new _o(e,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(e,n){for(const a of n.getCrossTileIDsLists())for(const l of a)delete this.usedCrossTileIDs[e][l]}removeStaleBuckets(e){let n=!1;for(const a in this.indexes){const l=this.indexes[a];for(const u in l)e[l[u].bucketInstanceId]||(this.removeBucketCrossTileIDs(a,l[u]),delete l[u],n=!0)}return n}}class Yn{constructor(){this.layerIndexes={},this.crossTileIDs=new yo,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,n,a){let l=this.layerIndexes[e.id];l===void 0&&(l=this.layerIndexes[e.id]=new Wc);let u=!1;const f={};l.handleWrapJump(a);for(const _ of n){const y=_.getBucket(e);y&&e.id===y.layerIds[0]&&(y.bucketInstanceId||(y.bucketInstanceId=++this.maxBucketInstanceId),l.addBucket(_.tileID,y,this.crossTileIDs)&&(u=!0),f[y.bucketInstanceId]=!0)}return l.removeStaleBuckets(f)&&(u=!0),u}pruneUnusedLayers(e){const n={};e.forEach(a=>{n[a]=!0});for(const a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}var Ms="void main() {fragColor=vec4(1.0);}";const Ji={prelude:tt(`#ifdef GL_ES
4
+ */var np=Tl.exports,ou;function sp(){return ou||(ou=1,function(me,j){(function(J,de){me.exports=de()})(np,function(){var J={},de={};function je(C,c,be){if(de[C]=be,C==="index"){var ct="var sharedModule = {}; ("+de.shared+")(sharedModule); ("+de.worker+")(sharedModule);",ut={};return de.shared(ut),de.index(J,ut),typeof window<"u"&&J.setWorkerUrl(window.URL.createObjectURL(new Blob([ct],{type:"text/javascript"}))),J}}je("shared",["exports"],function(C){function c(r,t,i,s){return new(i||(i=Promise))(function(o,d){function p(x){try{g(s.next(x))}catch(v){d(v)}}function m(x){try{g(s.throw(x))}catch(v){d(v)}}function g(x){var v;x.done?o(x.value):(v=x.value,v instanceof i?v:new i(function(T){T(v)})).then(p,m)}g((s=s.apply(r,t||[])).next())})}function be(r,t){this.x=r,this.y=t}function ct(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ut,pt;typeof SuppressedError=="function"&&SuppressedError,be.prototype={clone(){return new be(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,t){return this.clone()._rotateAround(r,t)},matMult(r){return this.clone()._matMult(r)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const t=r.x-this.x,i=r.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,t){return Math.atan2(this.x*t-this.y*r,this.x*r+this.y*t)},_matMult(r){const t=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=t,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const t=Math.cos(r),i=Math.sin(r),s=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=s,this},_rotateAround(r,t){const i=Math.cos(r),s=Math.sin(r),o=t.y+s*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-s*(this.y-t.y),this.y=o,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:be},be.convert=function(r){if(r instanceof be)return r;if(Array.isArray(r))return new be(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new be(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};var Ee=function(){if(pt)return ut;function r(t,i,s,o){this.cx=3*t,this.bx=3*(s-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(o-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=i,this.p2x=s,this.p2y=o}return pt=1,ut=r,r.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,i){if(i===void 0&&(i=1e-6),t<0)return 0;if(t>1)return 1;for(var s=t,o=0;o<8;o++){var d=this.sampleCurveX(s)-t;if(Math.abs(d)<i)return s;var p=this.sampleCurveDerivativeX(s);if(Math.abs(p)<1e-6)break;s-=d/p}var m=0,g=1;for(s=t,o=0;o<20&&(d=this.sampleCurveX(s),!(Math.abs(d-t)<i));o++)t>d?m=s:g=s,s=.5*(g-m)+m;return s},solve:function(t,i){return this.sampleCurveY(this.solveCurveX(t,i))}},ut}(),se=ct(Ee);let Mt,ei;function Ri(){return Mt==null&&(Mt=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Mt}function Ci(){if(ei==null&&(ei=!1,Ri())){const t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<5*5;s++){const o=4*s;t.fillStyle=`rgb(${o},${o+1},${o+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}const i=t.getImageData(0,0,5,5).data;for(let s=0;s<5*5*4;s++)if(s%4!=3&&i[s]!==s){ei=!0;break}}}return ei||!1}var It=1e-6,ft=typeof Float32Array<"u"?Float32Array:Array;function Ot(){var r=new ft(9);return ft!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function $i(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Sr(){var r=new ft(3);return ft!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function jn(r){var t=r[0],i=r[1],s=r[2];return Math.sqrt(t*t+i*i+s*s)}function oa(r,t,i){var s=new ft(3);return s[0]=r,s[1]=t,s[2]=i,s}function Ts(r,t,i){return r[0]=t[0]+i[0],r[1]=t[1]+i[1],r[2]=t[2]+i[2],r}function pr(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r[2]=t[2]*i,r}function Br(r,t,i){var s=t[0],o=t[1],d=t[2],p=i[0],m=i[1],g=i[2];return r[0]=o*g-d*m,r[1]=d*p-s*g,r[2]=s*m-o*p,r}var fr,Or=jn;function Ps(r,t,i){var s=t[0],o=t[1],d=t[2],p=t[3];return r[0]=i[0]*s+i[4]*o+i[8]*d+i[12]*p,r[1]=i[1]*s+i[5]*o+i[9]*d+i[13]*p,r[2]=i[2]*s+i[6]*o+i[10]*d+i[14]*p,r[3]=i[3]*s+i[7]*o+i[11]*d+i[15]*p,r}function cn(){var r=new ft(4);return ft!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function hn(r,t,i,s){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",d=Math.PI/360;t*=d,s*=d,i*=d;var p=Math.sin(t),m=Math.cos(t),g=Math.sin(i),x=Math.cos(i),v=Math.sin(s),T=Math.cos(s);switch(o){case"xyz":r[0]=p*x*T+m*g*v,r[1]=m*g*T-p*x*v,r[2]=m*x*v+p*g*T,r[3]=m*x*T-p*g*v;break;case"xzy":r[0]=p*x*T-m*g*v,r[1]=m*g*T-p*x*v,r[2]=m*x*v+p*g*T,r[3]=m*x*T+p*g*v;break;case"yxz":r[0]=p*x*T+m*g*v,r[1]=m*g*T-p*x*v,r[2]=m*x*v-p*g*T,r[3]=m*x*T+p*g*v;break;case"yzx":r[0]=p*x*T+m*g*v,r[1]=m*g*T+p*x*v,r[2]=m*x*v-p*g*T,r[3]=m*x*T-p*g*v;break;case"zxy":r[0]=p*x*T-m*g*v,r[1]=m*g*T+p*x*v,r[2]=m*x*v+p*g*T,r[3]=m*x*T-p*g*v;break;case"zyx":r[0]=p*x*T-m*g*v,r[1]=m*g*T+p*x*v,r[2]=m*x*v-p*g*T,r[3]=m*x*T+p*g*v;break;default:throw new Error("Unknown angle order "+o)}return r}function un(){var r=new ft(2);return ft!=Float32Array&&(r[0]=0,r[1]=0),r}function la(r,t){var i=new ft(2);return i[0]=r,i[1]=t,i}Sr(),fr=new ft(4),ft!=Float32Array&&(fr[0]=0,fr[1]=0,fr[2]=0,fr[3]=0),Sr(),oa(1,0,0),oa(0,1,0),cn(),cn(),Ot(),un();const gt=8192;function dn(r,t,i){return t*(gt/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function mi(r,t){return(r%t+t)%t}function pn(r,t,i){return r*(1-i)+t*i}function mr(r){if(r<=0)return 0;if(r>=1)return 1;const t=r*r,i=t*r;return 4*(r<.5?i:3*(r-t)+i-.75)}function jr(r,t,i,s){const o=new se(r,t,i,s);return d=>o.solve(d)}const fn=jr(.25,.1,.25,1);function Ei(r,t,i){return Math.min(i,Math.max(t,r))}function Nn(r,t,i){const s=i-t,o=((r-t)%s+s)%s+t;return o===t?i:o}function Zi(r,...t){for(const i of t)for(const s in i)r[s]=i[s];return r}let Yi=1;function Vn(r,t,i){const s={};for(const o in r)s[o]=t.call(this,r[o],o,r);return s}function Un(r,t,i){const s={};for(const o in r)t.call(this,r[o],o,r)&&(s[o]=r[o]);return s}function Fi(r){return Array.isArray(r)?r.map(Fi):typeof r=="object"&&r?Vn(r,Fi):r}const Dt={};function jt(r){Dt[r]||(typeof console<"u"&&console.warn(r),Dt[r]=!0)}function Ki(r,t,i){return(i.y-r.y)*(t.x-r.x)>(t.y-r.y)*(i.x-r.x)}function gr(r){return typeof WorkerGlobalScope<"u"&&r!==void 0&&r instanceof WorkerGlobalScope}let mn=null;function _r(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}const yr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function $n(r,t,i,s,o){return c(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const d=new VideoFrame(r,{timestamp:0});try{const p=d==null?void 0:d.format;if(!p||!p.startsWith("BGR")&&!p.startsWith("RGB"))throw new Error(`Unrecognized format ${p}`);const m=p.startsWith("BGR"),g=new Uint8ClampedArray(s*o*4);if(yield d.copyTo(g,function(x,v,T,M,E){const A=4*Math.max(-v,0),L=(Math.max(0,T)-T)*M*4+A,F=4*M,V=Math.max(0,v),Q=Math.max(0,T);return{rect:{x:V,y:Q,width:Math.min(x.width,v+M)-V,height:Math.min(x.height,T+E)-Q},layout:[{offset:L,stride:F}]}}(r,t,i,s,o)),m)for(let x=0;x<g.length;x+=4){const v=g[x];g[x]=g[x+2],g[x+2]=v}return g}finally{d.close()}})}let Nr,Vr;function Ur(r,t,i,s){return r.addEventListener(t,i,s),{unsubscribe:()=>{r.removeEventListener(t,i,s)}}}function gn(r){return r*Math.PI/180}function $r(r){return r/Math.PI*180}const Zr={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Gr={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},Zn="AbortError";function ee(){return new Error(Zn)}const z={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function D(r){return z.REGISTERED_PROTOCOLS[r.substring(0,r.indexOf("://"))]}const R="global-dispatcher";class Z extends Error{constructor(t,i,s,o){super(`AJAXError: ${i} (${t}): ${s}`),this.status=t,this.statusText=i,this.url=s,this.body=o}}const Y=()=>gr(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,ie=function(r,t){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const s=D(r.url);if(s)return s(r,t);if(gr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:R},t)}if(!(/^file:/.test(i=r.url)||/^file:/.test(Y())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,o){return c(this,void 0,void 0,function*(){const d=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:Y(),signal:o.signal});let p,m;s.type!=="json"||d.headers.has("Accept")||d.headers.set("Accept","application/json");try{p=yield fetch(d)}catch(x){throw new Z(0,x.message,s.url,new Blob)}if(!p.ok){const x=yield p.blob();throw new Z(p.status,p.statusText,s.url,x)}m=s.type==="arrayBuffer"||s.type==="image"?p.arrayBuffer():s.type==="json"?p.json():p.text();const g=yield m;if(o.signal.aborted)throw ee();return{data:g,cacheControl:p.headers.get("Cache-Control"),expires:p.headers.get("Expires")}})}(r,t);if(gr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:R},t)}var i;return function(s,o){return new Promise((d,p)=>{var m;const g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(const x in s.headers)g.setRequestHeader(x,s.headers[x]);s.type==="json"&&(g.responseType="text",!((m=s.headers)===null||m===void 0)&&m.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{p(new Error(g.statusText))},g.onload=()=>{if(!o.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)}d({data:x,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{const x=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});p(new Z(g.status,g.statusText,s.url,x))}},o.signal.addEventListener("abort",()=>{g.abort(),p(ee())}),g.send(s.body)})}(r,t)};function le(r){if(!r||r.indexOf("://")<=0||r.indexOf("data:image/")===0||r.indexOf("blob:")===0)return!0;const t=new URL(r),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function re(r,t,i){i[r]&&i[r].indexOf(t)!==-1||(i[r]=i[r]||[],i[r].push(t))}function fe(r,t,i){if(i&&i[r]){const s=i[r].indexOf(t);s!==-1&&i[r].splice(s,1)}}class ve{constructor(t,i={}){Zi(this,i),this.type=t}}class _e extends ve{constructor(t,i={}){super("error",Zi({error:t},i))}}class Re{on(t,i){return this._listeners=this._listeners||{},re(t,i,this._listeners),{unsubscribe:()=>{this.off(t,i)}}}off(t,i){return fe(t,i,this._listeners),fe(t,i,this._oneTimeListeners),this}once(t,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},re(t,i,this._oneTimeListeners),this):new Promise(s=>this.once(t,s))}fire(t,i){typeof t=="string"&&(t=new ve(t,i||{}));const s=t.type;if(this.listens(s)){t.target=this;const o=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const m of o)m.call(this,t);const d=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const m of d)fe(s,m,this._oneTimeListeners),m.call(this,t);const p=this._eventedParent;p&&(Zi(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(t))}else t instanceof _e&&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,i){return this._eventedParent=t,this._eventedParentData=i,this}}var ne={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const qe=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Qe(r,t){const i={};for(const s in r)s!=="ref"&&(i[s]=r[s]);return qe.forEach(s=>{s in t&&(i[s]=t[s])}),i}function Oe(r,t){if(Array.isArray(r)){if(!Array.isArray(t)||r.length!==t.length)return!1;for(let i=0;i<r.length;i++)if(!Oe(r[i],t[i]))return!1;return!0}if(typeof r=="object"&&r!==null&&t!==null){if(typeof t!="object"||Object.keys(r).length!==Object.keys(t).length)return!1;for(const i in r)if(!Oe(r[i],t[i]))return!1;return!0}return r===t}function He(r,t){r.push(t)}function Tt(r,t,i){He(i,{command:"addSource",args:[r,t[r]]})}function Ht(r,t,i){He(t,{command:"removeSource",args:[r]}),i[r]=!0}function Xt(r,t,i,s){Ht(r,i,s),Tt(r,t,i)}function Nt(r,t,i){let s;for(s in r[i])if(Object.prototype.hasOwnProperty.call(r[i],s)&&s!=="data"&&!Oe(r[i][s],t[i][s]))return!1;for(s in t[i])if(Object.prototype.hasOwnProperty.call(t[i],s)&&s!=="data"&&!Oe(r[i][s],t[i][s]))return!1;return!0}function rt(r,t,i,s,o,d){r=r||{},t=t||{};for(const p in r)Object.prototype.hasOwnProperty.call(r,p)&&(Oe(r[p],t[p])||i.push({command:d,args:[s,p,t[p],o]}));for(const p in t)Object.prototype.hasOwnProperty.call(t,p)&&!Object.prototype.hasOwnProperty.call(r,p)&&(Oe(r[p],t[p])||i.push({command:d,args:[s,p,t[p],o]}))}function ot(r){return r.id}function Ut(r,t){return r[t.id]=t,r}class Te{constructor(t,i,s,o){this.message=(t?`${t}: `:"")+s,o&&(this.identifier=o),i!=null&&i.__line__&&(this.line=i.__line__)}}function gi(r,...t){for(const i of t)for(const s in i)r[s]=i[s];return r}class At extends Error{constructor(t,i){super(i),this.message=i,this.key=t}}class qr{constructor(t,i=[]){this.parent=t,this.bindings={};for(const[s,o]of i)this.bindings[s]=o}concat(t){return new qr(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)}}const Gn={kind:"null"},ke={kind:"number"},et={kind:"string"},Je={kind:"boolean"},hi={kind:"color"},_n={kind:"projectionDefinition"},Wr={kind:"object"},Ye={kind:"value"},ca={kind:"collator"},Hr={kind:"formatted"},ha={kind:"padding"},xr={kind:"colorArray"},qn={kind:"numberArray"},Rt={kind:"resolvedImage"},ua={kind:"variableAnchorOffsetCollection"};function Ai(r,t){return{kind:"array",itemType:r,N:t}}function vt(r){if(r.kind==="array"){const t=vt(r.itemType);return typeof r.N=="number"?`array<${t}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${t}>`}return r.kind}const Il=[Gn,ke,et,Je,hi,_n,Hr,Wr,Ai(Ye),ha,qn,xr,Rt,ua];function Ss(r,t){if(t.kind==="error")return null;if(r.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!Ss(r.itemType,t.itemType))&&(typeof r.N!="number"||r.N===t.N))return null}else{if(r.kind===t.kind)return null;if(r.kind==="value"){for(const i of Il)if(!Ss(i,t))return null}}return`Expected ${vt(r)} but found ${vt(t)} instead.`}function uo(r,t){return t.some(i=>i.kind===r.kind)}function Xr(r,t){return t.some(i=>i==="null"?r===null:i==="array"?Array.isArray(r):i==="object"?r&&!Array.isArray(r)&&typeof r=="object":i===typeof r)}function Yr(r,t){return r.kind==="array"&&t.kind==="array"?r.itemType.kind===t.itemType.kind&&typeof r.N=="number":r.kind===t.kind}const po=.96422,Cl=.82521,El=4/29,Wn=6/29,Al=3*Wn*Wn,Zc=Wn*Wn*Wn,Gc=Math.PI/180,qc=180/Math.PI;function fo(r){return(r%=360)<0&&(r+=360),r}function Hn([r,t,i,s]){let o,d;const p=go((.2225045*(r=mo(r))+.7168786*(t=mo(t))+.0606169*(i=mo(i)))/1);r===t&&t===i?o=d=p:(o=go((.4360747*r+.3850649*t+.1430804*i)/po),d=go((.0139322*r+.0971045*t+.7141733*i)/Cl));const m=116*p-16;return[m<0?0:m,500*(o-p),200*(p-d),s]}function mo(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function go(r){return r>Zc?Math.pow(r,1/3):r/Al+El}function Xn([r,t,i,s]){let o=(r+16)/116,d=isNaN(t)?o:o+t/500,p=isNaN(i)?o:o-i/200;return o=1*yo(o),d=po*yo(d),p=Cl*yo(p),[_o(3.1338561*d-1.6168667*o-.4906146*p),_o(-.9787684*d+1.9161415*o+.033454*p),_o(.0719453*d-.2289914*o+1.4052427*p),s]}function _o(r){return(r=r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055)<0?0:r>1?1:r}function yo(r){return r>Wn?r*r*r:Al*(r-El)}const Wc=Object.hasOwn||function(r,t){return Object.prototype.hasOwnProperty.call(r,t)};function Yn(r,t){return Wc(r,t)?r[t]:void 0}function Ms(r){return parseInt(r.padEnd(2,r),16)/255}function Ji(r,t){return tt(t?r/100:r,0,1)}function tt(r,t,i){return Math.min(Math.max(t,r),i)}function yn(r){return!r.some(Number.isNaN)}const Kr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Mr(r,t,i){return r+i*(t-r)}function xn(r,t,i){return r.map((s,o)=>Mr(s,t[o],i))}class it{constructor(t,i,s,o=1,d=!0){this.r=t,this.g=i,this.b=s,this.a=o,d||(this.r*=o,this.g*=o,this.b*=o,o||this.overwriteGetter("rgb",[t,i,s,o]))}static parse(t){if(t instanceof it)return t;if(typeof t!="string")return;const i=function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const o=Yn(Kr,s);if(o){const[p,m,g]=o;return[p/255,m/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const p=s.length<6?1:2;let m=1;return[Ms(s.slice(m,m+=p)),Ms(s.slice(m,m+=p)),Ms(s.slice(m,m+=p)),Ms(s.slice(m,m+p)||"ff")]}if(s.startsWith("rgb")){const p=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){const[m,g,x,v,T,M,E,A,L,F,V,Q]=p,W=[v||" ",E||" ",F].join("");if(W===" "||W===" /"||W===",,"||W===",,,"){const X=[x,M,L].join(""),ce=X==="%%%"?100:X===""?255:0;if(ce){const pe=[tt(+g/ce,0,1),tt(+T/ce,0,1),tt(+A/ce,0,1),V?Ji(+V,Q):1];if(yn(pe))return pe}}return}}const d=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){const[p,m,g,x,v,T,M,E,A]=d,L=[g||" ",v||" ",M].join("");if(L===" "||L===" /"||L===",,"||L===",,,"){const F=[+m,tt(+x,0,100),tt(+T,0,100),E?Ji(+E,A):1];if(yn(F))return function([V,Q,W,X]){function ce(pe){const xe=(pe+V/30)%12,Ae=Q*Math.min(W,1-W);return W-Ae*Math.max(-1,Math.min(xe-3,9-xe,1))}return V=fo(V),Q/=100,W/=100,[ce(0),ce(8),ce(4),X]}(F)}}}(t);return i?new it(...i,!1):void 0}get rgb(){const{r:t,g:i,b:s,a:o}=this,d=o||1/0;return this.overwriteGetter("rgb",[t/d,i/d,s/d,o])}get hcl(){return this.overwriteGetter("hcl",function(t){const[i,s,o,d]=Hn(t),p=Math.sqrt(s*s+o*o);return[Math.round(1e4*p)?fo(Math.atan2(o,s)*qc):NaN,p,i,d]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Hn(this.rgb))}overwriteGetter(t,i){return Object.defineProperty(this,t,{value:i}),i}toString(){const[t,i,s,o]=this.rgb;return`rgba(${[t,i,s].map(d=>Math.round(255*d)).join(",")},${o})`}static interpolate(t,i,s,o="rgb"){switch(o){case"rgb":{const[d,p,m,g]=xn(t.rgb,i.rgb,s);return new it(d,p,m,g,!1)}case"hcl":{const[d,p,m,g]=t.hcl,[x,v,T,M]=i.hcl;let E,A;if(isNaN(d)||isNaN(x))isNaN(d)?isNaN(x)?E=NaN:(E=x,m!==1&&m!==0||(A=v)):(E=d,T!==1&&T!==0||(A=p));else{let W=x-d;x>d&&W>180?W-=360:x<d&&d-x>180&&(W+=360),E=d+s*W}const[L,F,V,Q]=function([W,X,ce,pe]){return W=isNaN(W)?0:W*Gc,Xn([ce,Math.cos(W)*X,Math.sin(W)*X,pe])}([E,A??Mr(p,v,s),Mr(m,T,s),Mr(g,M,s)]);return new it(L,F,V,Q,!1)}case"lab":{const[d,p,m,g]=Xn(xn(t.lab,i.lab,s));return new it(d,p,m,g,!1)}}}}it.black=new it(0,0,0,1),it.white=new it(1,1,1,1),it.transparent=new it(0,0,0,0),it.red=new it(1,0,0,1);class vn{constructor(t,i,s){this.sensitivity=t?i?"variant":"case":i?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,i){return this.collator.compare(t,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const da=["bottom","center","top"];class pa{constructor(t,i,s,o,d,p){this.text=t,this.image=i,this.scale=s,this.fontStack=o,this.textColor=d,this.verticalAlign=p}}class bi{constructor(t){this.sections=t}static fromString(t){return new bi([new pa(t,null,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 ti{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof ti)return t;if(typeof t=="number")return new ti([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const i of t)if(typeof i!="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 ti(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){return new ti(xn(t.values,i.values,s))}}class wi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof wi)return t;if(typeof t=="number")return new wi([t]);if(Array.isArray(t)){for(const i of t)if(typeof i!="number")return;return new wi(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){return new wi(xn(t.values,i.values,s))}}class $t{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof $t)return t;if(typeof t=="string"){const s=it.parse(t);return s?new $t([s]):void 0}if(!Array.isArray(t))return;const i=[];for(const s of t){if(typeof s!="string")return;const o=it.parse(s);if(!o)return;i.push(o)}return new $t(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s,o="rgb"){const d=[];if(t.values.length!=i.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let p=0;p<t.values.length;p++)d.push(it.interpolate(t.values[p],i.values[p],s,o));return new $t(d)}}class bt extends Error{constructor(t){super(t),this.name="RuntimeError"}toJSON(){return this.message}}const kl=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Ti{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Ti)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let i=0;i<t.length;i+=2){const s=t[i],o=t[i+1];if(typeof s!="string"||!kl.has(s)||!Array.isArray(o)||o.length!==2||typeof o[0]!="number"||typeof o[1]!="number")return}return new Ti(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){const o=t.values,d=i.values;if(o.length!==d.length)throw new bt(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`);const p=[];for(let m=0;m<o.length;m+=2){if(o[m]!==d[m])throw new bt(`Cannot interpolate values containing mismatched anchors. from[${m}]: ${o[m]}, to[${m}]: ${d[m]}`);p.push(o[m]);const[g,x]=o[m+1],[v,T]=d[m+1];p.push([Mr(g,v,s),Mr(x,T,s)])}return new Ti(p)}}class Bi{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Bi({name:t,available:!1}):null}}class _i{constructor(t,i,s){this.from=t,this.to=i,this.transition=s}static interpolate(t,i,s){return new _i(t,i,s)}static parse(t){return t instanceof _i?t:Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number"?new _i(t[0],t[1],t[2]):typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number"?new _i(t.from,t.to,t.transition):typeof t=="string"?new _i(t,t,1):void 0}}function Pt(r,t,i,s){return typeof r=="number"&&r>=0&&r<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof i=="number"&&i>=0&&i<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[r,t,i,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[r,t,i,s]:[r,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function bn(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof _i||r instanceof it||r instanceof vn||r instanceof bi||r instanceof ti||r instanceof wi||r instanceof $t||r instanceof Ti||r instanceof Bi)return!0;if(Array.isArray(r)){for(const t of r)if(!bn(t))return!1;return!0}if(typeof r=="object"){for(const t in r)if(!bn(r[t]))return!1;return!0}return!1}function $e(r){if(r===null)return Gn;if(typeof r=="string")return et;if(typeof r=="boolean")return Je;if(typeof r=="number")return ke;if(r instanceof it)return hi;if(r instanceof _i)return _n;if(r instanceof vn)return ca;if(r instanceof bi)return Hr;if(r instanceof ti)return ha;if(r instanceof wi)return qn;if(r instanceof $t)return xr;if(r instanceof Ti)return ua;if(r instanceof Bi)return Rt;if(Array.isArray(r)){const t=r.length;let i;for(const s of r){const o=$e(s);if(i){if(i===o)continue;i=Ye;break}i=o}return Ai(i||Ye,t)}return Wr}function We(r){const t=typeof r;return r===null?"":t==="string"||t==="number"||t==="boolean"?String(r):r instanceof it||r instanceof _i||r instanceof bi||r instanceof ti||r instanceof wi||r instanceof $t||r instanceof Ti||r instanceof Bi?r.toString():JSON.stringify(r)}class Ir{constructor(t,i){this.type=t,this.value=i}static parse(t,i){if(t.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!bn(t[1]))return i.error("invalid value");const s=t[1];let o=$e(s);const d=i.expectedType;return o.kind!=="array"||o.N!==0||!d||d.kind!=="array"||typeof d.N=="number"&&d.N!==0||(o=d),new Ir(o,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const lt={string:et,number:ke,boolean:Je,object:Wr};class Oi{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let s,o=1;const d=t[0];if(d==="array"){let m,g;if(t.length>2){const x=t[1];if(typeof x!="string"||!(x in lt)||x==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);m=lt[x],o++}else m=Ye;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);g=t[2],o++}s=Ai(m,g)}else{if(!lt[d])throw new Error(`Types doesn't contain name = ${d}`);s=lt[d]}const p=[];for(;o<t.length;o++){const m=i.parse(t[o],o,Ye);if(!m)return null;p.push(m)}return new Oi(s,p)}evaluate(t){for(let i=0;i<this.args.length;i++){const s=this.args[i].evaluate(t);if(!Ss(this.type,$e(s)))return s;if(i===this.args.length-1)throw new bt(`Expected value to be of type ${vt(this.type)}, but found ${vt($e(s))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const vr={"to-boolean":Je,"to-color":hi,"to-number":ke,"to-string":et};class br{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const s=t[0];if(!vr[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 i.error("Expected one argument.");const o=vr[s],d=[];for(let p=1;p<t.length;p++){const m=i.parse(t[p],p,Ye);if(!m)return null;d.push(m)}return new br(o,d)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let i,s;for(const o of this.args){if(i=o.evaluate(t),s=null,i instanceof it)return i;if(typeof i=="string"){const d=t.parseColor(i);if(d)return d}else if(Array.isArray(i)&&(s=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:Pt(i[0],i[1],i[2],i[3]),!s))return new it(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new bt(s||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"padding":{let i;for(const s of this.args){i=s.evaluate(t);const o=ti.parse(i);if(o)return o}throw new bt(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"numberArray":{let i;for(const s of this.args){i=s.evaluate(t);const o=wi.parse(i);if(o)return o}throw new bt(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"colorArray":{let i;for(const s of this.args){i=s.evaluate(t);const o=$t.parse(i);if(o)return o}throw new bt(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"variableAnchorOffsetCollection":{let i;for(const s of this.args){i=s.evaluate(t);const o=Ti.parse(i);if(o)return o}throw new bt(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"number":{let i=null;for(const s of this.args){if(i=s.evaluate(t),i===null)return 0;const o=Number(i);if(!isNaN(o))return o}throw new bt(`Could not convert ${JSON.stringify(i)} to number.`)}case"formatted":return bi.fromString(We(this.args[0].evaluate(t)));case"resolvedImage":return Bi.fromString(We(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return We(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const fa=["Unknown","Point","LineString","Polygon"];class xo{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?fa[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 i=this._parseColorCache.get(t);return i||(i=it.parse(t),this._parseColorCache.set(t,i)),i}}class Kn{constructor(t,i,s=[],o,d=new qr,p=[]){this.registry=t,this.path=s,this.key=s.map(m=>`[${m}]`).join(""),this.scope=d,this.errors=p,this.expectedType=o,this._isConstant=i}parse(t,i,s,o,d={}){return i?this.concat(i,s,o)._parse(t,d):this._parse(t,d)}_parse(t,i){function s(o,d,p){return p==="assert"?new Oi(d,[o]):p==="coerce"?new br(d,[o]):o}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=t[0];if(typeof o!="string")return this.error(`Expression name must be a string, but found ${typeof o} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const d=this.registry[o];if(d){let p=d.parse(t,this);if(!p)return null;if(this.expectedType){const m=this.expectedType,g=p.type;if(m.kind!=="string"&&m.kind!=="number"&&m.kind!=="boolean"&&m.kind!=="object"&&m.kind!=="array"||g.kind!=="value"){if(m.kind==="projectionDefinition"&&["string","array"].includes(g.kind)||["color","formatted","resolvedImage"].includes(m.kind)&&["value","string"].includes(g.kind)||["padding","numberArray"].includes(m.kind)&&["value","number","array"].includes(g.kind)||m.kind==="colorArray"&&["value","string","array"].includes(g.kind)||m.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(g.kind))p=s(p,m,i.typeAnnotation||"coerce");else if(this.checkSubtype(m,g))return null}else p=s(p,m,i.typeAnnotation||"assert")}if(!(p instanceof Ir)&&p.type.kind!=="resolvedImage"&&this._isConstant(p)){const m=new xo;try{p=new Ir(p.type,p.evaluate(m))}catch(g){return this.error(g.message),null}}return p}return this.error(`Unknown expression "${o}". 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,i,s){const o=typeof t=="number"?this.path.concat(t):this.path,d=s?this.scope.concat(s):this.scope;return new Kn(this.registry,this._isConstant,o,i||null,d,this.errors)}error(t,...i){const s=`${this.key}${i.map(o=>`[${o}]`).join("")}`;this.errors.push(new At(s,t))}checkSubtype(t,i){const s=Ss(t,i);return s&&this.error(s),s}}class Is{constructor(t,i){this.type=i.type,this.bindings=[].concat(t),this.result=i}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const i of this.bindings)t(i[1]);t(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const s=[];for(let d=1;d<t.length-1;d+=2){const p=t[d];if(typeof p!="string")return i.error(`Expected string, but found ${typeof p} instead.`,d);if(/[^a-zA-Z0-9_]/.test(p))return i.error("Variable names must contain only alphanumeric characters or '_'.",d);const m=i.parse(t[d+1],d+1);if(!m)return null;s.push([p,m])}const o=i.parse(t[t.length-1],t.length-1,i.expectedType,s);return o?new Is(s,o):null}outputDefined(){return this.result.outputDefined()}}class ma{constructor(t,i){this.type=i.type,this.name=t,this.boundExpression=i}static parse(t,i){if(t.length!==2||typeof t[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const s=t[1];return i.scope.has(s)?new ma(s,i.scope.get(s)):i.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 ga{constructor(t,i,s){this.type=t,this.index=i,this.input=s}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,ke),o=i.parse(t[2],2,Ai(i.expectedType||Ye));return s&&o?new ga(o.type.itemType,s,o):null}evaluate(t){const i=this.index.evaluate(t),s=this.input.evaluate(t);if(i<0)throw new bt(`Array index out of bounds: ${i} < 0.`);if(i>=s.length)throw new bt(`Array index out of bounds: ${i} > ${s.length-1}.`);if(i!==Math.floor(i))throw new bt(`Array index must be an integer, but found ${i} instead.`);return s[i]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class _a{constructor(t,i){this.type=Je,this.needle=t,this.haystack=i}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,Ye),o=i.parse(t[2],2,Ye);return s&&o?uo(s.type,[Je,et,ke,Gn,Ye])?new _a(s,o):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${vt(s.type)} instead`):null}evaluate(t){const i=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!Xr(i,["boolean","string","number","null"]))throw new bt(`Expected first argument to be of type boolean, string, number or null, but found ${vt($e(i))} instead.`);if(!Xr(s,["string","array"]))throw new bt(`Expected second argument to be of type array or string, but found ${vt($e(s))} instead.`);return s.indexOf(i)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class Qi{constructor(t,i,s){this.type=ke,this.needle=t,this.haystack=i,this.fromIndex=s}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,Ye),o=i.parse(t[2],2,Ye);if(!s||!o)return null;if(!uo(s.type,[Je,et,ke,Gn,Ye]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${vt(s.type)} instead`);if(t.length===4){const d=i.parse(t[3],3,ke);return d?new Qi(s,o,d):null}return new Qi(s,o)}evaluate(t){const i=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!Xr(i,["boolean","string","number","null"]))throw new bt(`Expected first argument to be of type boolean, string, number or null, but found ${vt($e(i))} instead.`);let o;if(this.fromIndex&&(o=this.fromIndex.evaluate(t)),Xr(s,["string"])){const d=s.indexOf(i,o);return d===-1?-1:[...s.slice(0,d)].length}if(Xr(s,["array"]))return s.indexOf(i,o);throw new bt(`Expected second argument to be of type array or string, but found ${vt($e(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class ii{constructor(t,i,s,o,d,p){this.inputType=t,this.type=i,this.input=s,this.cases=o,this.outputs=d,this.otherwise=p}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let s,o;i.expectedType&&i.expectedType.kind!=="value"&&(o=i.expectedType);const d={},p=[];for(let x=2;x<t.length-1;x+=2){let v=t[x];const T=t[x+1];Array.isArray(v)||(v=[v]);const M=i.concat(x);if(v.length===0)return M.error("Expected at least one branch label.");for(const A of v){if(typeof A!="number"&&typeof A!="string")return M.error("Branch labels must be numbers or strings.");if(typeof A=="number"&&Math.abs(A)>Number.MAX_SAFE_INTEGER)return M.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof A=="number"&&Math.floor(A)!==A)return M.error("Numeric branch labels must be integer values.");if(s){if(M.checkSubtype(s,$e(A)))return null}else s=$e(A);if(d[String(A)]!==void 0)return M.error("Branch labels must be unique.");d[String(A)]=p.length}const E=i.parse(T,x,o);if(!E)return null;o=o||E.type,p.push(E)}const m=i.parse(t[1],1,Ye);if(!m)return null;const g=i.parse(t[t.length-1],t.length-1,o);return g?m.type.kind!=="value"&&i.concat(1).checkSubtype(s,m.type)?null:new ii(s,o,m,d,p,g):null}evaluate(t){const i=this.input.evaluate(t);return($e(i)===this.inputType&&this.outputs[this.cases[i]]||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 Jn{constructor(t,i,s){this.type=t,this.branches=i,this.otherwise=s}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);const o=[];for(let p=1;p<t.length-1;p+=2){const m=i.parse(t[p],p,Je);if(!m)return null;const g=i.parse(t[p+1],p+1,s);if(!g)return null;o.push([m,g]),s=s||g.type}const d=i.parse(t[t.length-1],t.length-1,s);if(!d)return null;if(!s)throw new Error("Can't infer output type");return new Jn(s,o,d)}evaluate(t){for(const[i,s]of this.branches)if(i.evaluate(t))return s.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[i,s]of this.branches)t(i),t(s);t(this.otherwise)}outputDefined(){return this.branches.every(([t,i])=>i.outputDefined())&&this.otherwise.outputDefined()}}class Cs{constructor(t,i,s,o){this.type=t,this.input=i,this.beginIndex=s,this.endIndex=o}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,Ye),o=i.parse(t[2],2,ke);if(!s||!o)return null;if(!uo(s.type,[Ai(Ye),et,Ye]))return i.error(`Expected first argument to be of type array or string, but found ${vt(s.type)} instead`);if(t.length===4){const d=i.parse(t[3],3,ke);return d?new Cs(s.type,s,o,d):null}return new Cs(s.type,s,o)}evaluate(t){const i=this.input.evaluate(t),s=this.beginIndex.evaluate(t);let o;if(this.endIndex&&(o=this.endIndex.evaluate(t)),Xr(i,["string"]))return[...i].slice(s,o).join("");if(Xr(i,["array"]))return i.slice(s,o);throw new bt(`Expected first argument to be of type array or string, but found ${vt($e(i))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function wn(r,t){const i=r.length-1;let s,o,d=0,p=i,m=0;for(;d<=p;)if(m=Math.floor((d+p)/2),s=r[m],o=r[m+1],s<=t){if(m===i||t<o)return m;d=m+1}else{if(!(s>t))throw new bt("Input is not a number.");p=m-1}return 0}class Ft{constructor(t,i,s){this.type=t,this.input=i,this.labels=[],this.outputs=[];for(const[o,d]of s)this.labels.push(o),this.outputs.push(d)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");const s=i.parse(t[1],1,ke);if(!s)return null;const o=[];let d=null;i.expectedType&&i.expectedType.kind!=="value"&&(d=i.expectedType);for(let p=1;p<t.length;p+=2){const m=p===1?-1/0:t[p],g=t[p+1],x=p,v=p+1;if(typeof m!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',x);if(o.length&&o[o.length-1][0]>=m)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);const T=i.parse(g,v,d);if(!T)return null;d=d||T.type,o.push([m,T])}return new Ft(d,s,o)}evaluate(t){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(t);const o=this.input.evaluate(t);if(o<=i[0])return s[0].evaluate(t);const d=i.length;return o>=i[d-1]?s[d-1].evaluate(t):s[wn(i,o)].evaluate(t)}eachChild(t){t(this.input);for(const i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function zl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Es,vo,Hc=function(){if(vo)return Es;function r(t,i,s,o){this.cx=3*t,this.bx=3*(s-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(o-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=i,this.p2x=s,this.p2y=o}return vo=1,Es=r,r.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,i){if(i===void 0&&(i=1e-6),t<0)return 0;if(t>1)return 1;for(var s=t,o=0;o<8;o++){var d=this.sampleCurveX(s)-t;if(Math.abs(d)<i)return s;var p=this.sampleCurveDerivativeX(s);if(Math.abs(p)<1e-6)break;s-=d/p}var m=0,g=1;for(s=t,o=0;o<20&&(d=this.sampleCurveX(s),!(Math.abs(d-t)<i));o++)t>d?m=s:g=s,s=.5*(g-m)+m;return s},solve:function(t,i){return this.sampleCurveY(this.solveCurveX(t,i))}},Es}(),Qn=zl(Hc);class ui{constructor(t,i,s,o,d){this.type=t,this.operator=i,this.interpolation=s,this.input=o,this.labels=[],this.outputs=[];for(const[p,m]of d)this.labels.push(p),this.outputs.push(m)}static interpolationFactor(t,i,s,o){let d=0;if(t.name==="exponential")d=As(i,t.base,s,o);else if(t.name==="linear")d=As(i,1,s,o);else if(t.name==="cubic-bezier"){const p=t.controlPoints;d=new Qn(p[0],p[1],p[2],p[3]).solve(As(i,1,s,o))}return d}static parse(t,i){let[s,o,d,...p]=t;if(!Array.isArray(o)||o.length===0)return i.error("Expected an interpolation type expression.",1);if(o[0]==="linear")o={name:"linear"};else if(o[0]==="exponential"){const x=o[1];if(typeof x!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:x}}else{if(o[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const x=o.slice(1);if(x.length!==4||x.some(v=>typeof v!="number"||v<0||v>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:x}}}if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(d=i.parse(d,2,ke),!d)return null;const m=[];let g=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||i.expectedType==xr?i.expectedType&&i.expectedType.kind!=="value"&&(g=i.expectedType):g=hi;for(let x=0;x<p.length;x+=2){const v=p[x],T=p[x+1],M=x+3,E=x+4;if(typeof v!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',M);if(m.length&&m[m.length-1][0]>=v)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',M);const A=i.parse(T,E,g);if(!A)return null;g=g||A.type,m.push([v,A])}return Yr(g,ke)||Yr(g,_n)||Yr(g,hi)||Yr(g,ha)||Yr(g,qn)||Yr(g,xr)||Yr(g,ua)||Yr(g,Ai(ke))?new ui(g,s,o,d,m):i.error(`Type ${vt(g)} is not interpolatable.`)}evaluate(t){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(t);const o=this.input.evaluate(t);if(o<=i[0])return s[0].evaluate(t);const d=i.length;if(o>=i[d-1])return s[d-1].evaluate(t);const p=wn(i,o),m=ui.interpolationFactor(this.interpolation,o,i[p],i[p+1]),g=s[p].evaluate(t),x=s[p+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Mr(g,x,m);case"color":return it.interpolate(g,x,m);case"padding":return ti.interpolate(g,x,m);case"colorArray":return $t.interpolate(g,x,m);case"numberArray":return wi.interpolate(g,x,m);case"variableAnchorOffsetCollection":return Ti.interpolate(g,x,m);case"array":return xn(g,x,m);case"projectionDefinition":return _i.interpolate(g,x,m)}case"interpolate-hcl":switch(this.type.kind){case"color":return it.interpolate(g,x,m,"hcl");case"colorArray":return $t.interpolate(g,x,m,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return it.interpolate(g,x,m,"lab");case"colorArray":return $t.interpolate(g,x,m,"lab")}}}eachChild(t){t(this.input);for(const i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function As(r,t,i,s){const o=s-i,d=r-i;return o===0?0:t===1?d/o:(Math.pow(t,d)-1)/(Math.pow(t,o)-1)}const wr={color:it.interpolate,number:Mr,padding:ti.interpolate,numberArray:wi.interpolate,colorArray:$t.interpolate,variableAnchorOffsetCollection:Ti.interpolate,array:xn};class ks{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let s=null;const o=i.expectedType;o&&o.kind!=="value"&&(s=o);const d=[];for(const m of t.slice(1)){const g=i.parse(m,1+d.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,d.push(g)}if(!s)throw new Error("No output type");const p=o&&d.some(m=>Ss(o,m.type));return new ks(p?Ye:s,d)}evaluate(t){let i,s=null,o=0;for(const d of this.args)if(o++,s=d.evaluate(t),s&&s instanceof Bi&&!s.available&&(i||(i=s.name),s=null,o===this.args.length&&(s=i)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function zs(r,t){return r==="=="||r==="!="?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 Ls(r,t,i,s){return s.compare(t,i)===0}function yi(r,t,i){const s=r!=="=="&&r!=="!=";return class Hd{constructor(d,p,m){this.type=Je,this.lhs=d,this.rhs=p,this.collator=m,this.hasUntypedArgument=d.type.kind==="value"||p.type.kind==="value"}static parse(d,p){if(d.length!==3&&d.length!==4)return p.error("Expected two or three arguments.");const m=d[0];let g=p.parse(d[1],1,Ye);if(!g)return null;if(!zs(m,g.type))return p.concat(1).error(`"${m}" comparisons are not supported for type '${vt(g.type)}'.`);let x=p.parse(d[2],2,Ye);if(!x)return null;if(!zs(m,x.type))return p.concat(2).error(`"${m}" comparisons are not supported for type '${vt(x.type)}'.`);if(g.type.kind!==x.type.kind&&g.type.kind!=="value"&&x.type.kind!=="value")return p.error(`Cannot compare types '${vt(g.type)}' and '${vt(x.type)}'.`);s&&(g.type.kind==="value"&&x.type.kind!=="value"?g=new Oi(x.type,[g]):g.type.kind!=="value"&&x.type.kind==="value"&&(x=new Oi(g.type,[x])));let v=null;if(d.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(d[3],3,ca),!v)return null}return new Hd(g,x,v)}evaluate(d){const p=this.lhs.evaluate(d),m=this.rhs.evaluate(d);if(s&&this.hasUntypedArgument){const g=$e(p),x=$e(m);if(g.kind!==x.kind||g.kind!=="string"&&g.kind!=="number")throw new bt(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${g.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const g=$e(p),x=$e(m);if(g.kind!=="string"||x.kind!=="string")return t(d,p,m)}return this.collator?i(d,p,m,this.collator.evaluate(d)):t(d,p,m)}eachChild(d){d(this.lhs),d(this.rhs),this.collator&&d(this.collator)}outputDefined(){return!0}}}const Ll=yi("==",function(r,t,i){return t===i},Ls),ya=yi("!=",function(r,t,i){return t!==i},function(r,t,i,s){return!Ls(0,t,i,s)}),Xc=yi("<",function(r,t,i){return t<i},function(r,t,i,s){return s.compare(t,i)<0}),bo=yi(">",function(r,t,i){return t>i},function(r,t,i,s){return s.compare(t,i)>0}),Yc=yi("<=",function(r,t,i){return t<=i},function(r,t,i,s){return s.compare(t,i)<=0}),Kc=yi(">=",function(r,t,i){return t>=i},function(r,t,i,s){return s.compare(t,i)>=0});class xa{constructor(t,i,s){this.type=ca,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=i}static parse(t,i){if(t.length!==2)return i.error("Expected one argument.");const s=t[1];if(typeof s!="object"||Array.isArray(s))return i.error("Collator options argument must be an object.");const o=i.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Je);if(!o)return null;const d=i.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Je);if(!d)return null;let p=null;return s.locale&&(p=i.parse(s.locale,1,et),!p)?null:new xa(o,d,p)}evaluate(t){return new vn(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 wo{constructor(t,i,s,o,d){this.type=et,this.number=t,this.locale=i,this.currency=s,this.minFractionDigits=o,this.maxFractionDigits=d}static parse(t,i){if(t.length!==3)return i.error("Expected two arguments.");const s=i.parse(t[1],1,ke);if(!s)return null;const o=t[2];if(typeof o!="object"||Array.isArray(o))return i.error("NumberFormat options argument must be an object.");let d=null;if(o.locale&&(d=i.parse(o.locale,1,et),!d))return null;let p=null;if(o.currency&&(p=i.parse(o.currency,1,et),!p))return null;let m=null;if(o["min-fraction-digits"]&&(m=i.parse(o["min-fraction-digits"],1,ke),!m))return null;let g=null;return o["max-fraction-digits"]&&(g=i.parse(o["max-fraction-digits"],1,ke),!g)?null:new wo(s,d,p,m,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 Tn{constructor(t){this.type=Hr,this.sections=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const s=t[1];if(!Array.isArray(s)&&typeof s=="object")return i.error("First argument must be an image or text section.");const o=[];let d=!1;for(let p=1;p<=t.length-1;++p){const m=t[p];if(d&&typeof m=="object"&&!Array.isArray(m)){d=!1;let g=null;if(m["font-scale"]&&(g=i.parse(m["font-scale"],1,ke),!g))return null;let x=null;if(m["text-font"]&&(x=i.parse(m["text-font"],1,Ai(et)),!x))return null;let v=null;if(m["text-color"]&&(v=i.parse(m["text-color"],1,hi),!v))return null;let T=null;if(m["vertical-align"]){if(typeof m["vertical-align"]=="string"&&!da.includes(m["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${m["vertical-align"]}' instead.`);if(T=i.parse(m["vertical-align"],1,et),!T)return null}const M=o[o.length-1];M.scale=g,M.font=x,M.textColor=v,M.verticalAlign=T}else{const g=i.parse(t[p],1,Ye);if(!g)return null;const x=g.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");d=!0,o.push({content:g,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Tn(o)}evaluate(t){return new bi(this.sections.map(i=>{const s=i.content.evaluate(t);return $e(s)===Rt?new pa("",s,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(t):null):new pa(We(s),null,i.scale?i.scale.evaluate(t):null,i.font?i.font.evaluate(t).join(","):null,i.textColor?i.textColor.evaluate(t):null,i.verticalAlign?i.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const i of this.sections)t(i.content),i.scale&&t(i.scale),i.font&&t(i.font),i.textColor&&t(i.textColor),i.verticalAlign&&t(i.verticalAlign)}outputDefined(){return!1}}class To{constructor(t){this.type=Rt,this.input=t}static parse(t,i){if(t.length!==2)return i.error("Expected two arguments.");const s=i.parse(t[1],1,et);return s?new To(s):i.error("No image name provided.")}evaluate(t){const i=this.input.evaluate(t),s=Bi.fromString(i);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(i)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class va{constructor(t){this.type=ke,this.input=t}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=i.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${vt(s.type)} instead.`):new va(s):null}evaluate(t){const i=this.input.evaluate(t);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new bt(`Expected value to be of type string or array, but found ${vt($e(i))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const er=8192;function Jc(r,t){const i=(180+r[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r[1]*Math.PI/360)))/360,o=Math.pow(2,t.z);return[Math.round(i*o*er),Math.round(s*o*er)]}function ba(r,t){const i=Math.pow(2,t.z);return[(o=(r[0]/er+t.x)/i,360*o-180),(s=(r[1]/er+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,o}function Ds(r,t){r[0]=Math.min(r[0],t[0]),r[1]=Math.min(r[1],t[1]),r[2]=Math.max(r[2],t[0]),r[3]=Math.max(r[3],t[1])}function Rs(r,t){return!(r[0]<=t[0]||r[2]>=t[2]||r[1]<=t[1]||r[3]>=t[3])}function Qc(r,t,i){const s=r[0]-t[0],o=r[1]-t[1],d=r[0]-i[0],p=r[1]-i[1];return s*p-d*o==0&&s*d<=0&&o*p<=0}function wa(r,t,i,s){return(o=[s[0]-i[0],s[1]-i[1]])[0]*(d=[t[0]-r[0],t[1]-r[1]])[1]-o[1]*d[0]!=0&&!(!Rl(r,t,i,s)||!Rl(i,s,r,t));var o,d}function eh(r,t,i){for(const s of i)for(let o=0;o<s.length-1;++o)if(wa(r,t,s[o],s[o+1]))return!0;return!1}function Pn(r,t,i=!1){let s=!1;for(const m of t)for(let g=0;g<m.length-1;g++){if(Qc(r,m[g],m[g+1]))return i;(d=m[g])[1]>(o=r)[1]!=(p=m[g+1])[1]>o[1]&&o[0]<(p[0]-d[0])*(o[1]-d[1])/(p[1]-d[1])+d[0]&&(s=!s)}var o,d,p;return s}function Dl(r,t){for(const i of t)if(Pn(r,i))return!0;return!1}function Po(r,t){for(const i of r)if(!Pn(i,t))return!1;for(let i=0;i<r.length-1;++i)if(eh(r[i],r[i+1],t))return!1;return!0}function th(r,t){for(const i of t)if(Po(r,i))return!0;return!1}function Rl(r,t,i,s){const o=s[0]-i[0],d=s[1]-i[1],p=(r[0]-i[0])*d-o*(r[1]-i[1]),m=(t[0]-i[0])*d-o*(t[1]-i[1]);return p>0&&m<0||p<0&&m>0}function So(r,t,i){const s=[];for(let o=0;o<r.length;o++){const d=[];for(let p=0;p<r[o].length;p++){const m=Jc(r[o][p],i);Ds(t,m),d.push(m)}s.push(d)}return s}function Fl(r,t,i){const s=[];for(let o=0;o<r.length;o++){const d=So(r[o],t,i);s.push(d)}return s}function Ta(r,t,i,s){if(r[0]<i[0]||r[0]>i[2]){const o=.5*s;let d=r[0]-i[0]>o?-s:i[0]-r[0]>o?s:0;d===0&&(d=r[0]-i[2]>o?-s:i[2]-r[0]>o?s:0),r[0]+=d}Ds(t,r)}function Bl(r,t,i,s){const o=Math.pow(2,s.z)*er,d=[s.x*er,s.y*er],p=[];for(const m of r)for(const g of m){const x=[g.x+d[0],g.y+d[1]];Ta(x,t,i,o),p.push(x)}return p}function Ol(r,t,i,s){const o=Math.pow(2,s.z)*er,d=[s.x*er,s.y*er],p=[];for(const g of r){const x=[];for(const v of g){const T=[v.x+d[0],v.y+d[1]];Ds(t,T),x.push(T)}p.push(x)}if(t[2]-t[0]<=o/2){(m=t)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const g of p)for(const x of g)Ta(x,t,i,o)}var m;return p}class Sn{constructor(t,i){this.type=Je,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(bn(t[1])){const s=t[1];if(s.type==="FeatureCollection"){const o=[];for(const d of s.features){const{type:p,coordinates:m}=d.geometry;p==="Polygon"&&o.push(m),p==="MultiPolygon"&&o.push(...m)}if(o.length)return new Sn(s,{type:"MultiPolygon",coordinates:o})}else if(s.type==="Feature"){const o=s.geometry.type;if(o==="Polygon"||o==="MultiPolygon")return new Sn(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Sn(s,s)}return i.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(i,s){const o=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],p=i.canonicalID();if(s.type==="Polygon"){const m=So(s.coordinates,d,p),g=Bl(i.geometry(),o,d,p);if(!Rs(o,d))return!1;for(const x of g)if(!Pn(x,m))return!1}if(s.type==="MultiPolygon"){const m=Fl(s.coordinates,d,p),g=Bl(i.geometry(),o,d,p);if(!Rs(o,d))return!1;for(const x of g)if(!Dl(x,m))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(i,s){const o=[1/0,1/0,-1/0,-1/0],d=[1/0,1/0,-1/0,-1/0],p=i.canonicalID();if(s.type==="Polygon"){const m=So(s.coordinates,d,p),g=Ol(i.geometry(),o,d,p);if(!Rs(o,d))return!1;for(const x of g)if(!Po(x,m))return!1}if(s.type==="MultiPolygon"){const m=Fl(s.coordinates,d,p),g=Ol(i.geometry(),o,d,p);if(!Rs(o,d))return!1;for(const x of g)if(!th(x,m))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Mo=class{constructor(r=[],t=(i,s)=>i<s?-1:i>s?1:0){if(this.data=r,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;const r=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),r}peek(){return this.data[0]}_up(r){const{data:t,compare:i}=this,s=t[r];for(;r>0;){const o=r-1>>1,d=t[o];if(i(s,d)>=0)break;t[r]=d,r=o}t[r]=s}_down(r){const{data:t,compare:i}=this,s=this.length>>1,o=t[r];for(;r<s;){let d=1+(r<<1);const p=d+1;if(p<this.length&&i(t[p],t[d])<0&&(d=p),i(t[d],o)>=0)break;t[r]=t[d],r=d}t[r]=o}};function Io(r,t,i=0,s=r.length-1,o=ih){for(;s>i;){if(s-i>600){const g=s-i+1,x=t-i+1,v=Math.log(g),T=.5*Math.exp(2*v/3),M=.5*Math.sqrt(v*T*(g-T)/g)*(x-g/2<0?-1:1);Io(r,t,Math.max(i,Math.floor(t-x*T/g+M)),Math.min(s,Math.floor(t+(g-x)*T/g+M)),o)}const d=r[t];let p=i,m=s;for(Fs(r,i,t),o(r[s],d)>0&&Fs(r,i,s);p<m;){for(Fs(r,p,m),p++,m--;o(r[p],d)<0;)p++;for(;o(r[m],d)>0;)m--}o(r[i],d)===0?Fs(r,i,m):(m++,Fs(r,m,s)),m<=t&&(i=m+1),t<=m&&(s=m-1)}}function Fs(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}function ih(r,t){return r<t?-1:r>t?1:0}function Bs(r,t){if(r.length<=1)return[r];const i=[];let s,o;for(const d of r){const p=rh(d);p!==0&&(d.area=Math.abs(p),o===void 0&&(o=p<0),o===p<0?(s&&i.push(s),s=[d]):s.push(d))}if(s&&i.push(s),t>1)for(let d=0;d<i.length;d++)i[d].length<=t||(Io(i[d],t,1,i[d].length-1,jl),i[d]=i[d].slice(0,t));return i}function jl(r,t){return t.area-r.area}function rh(r){let t=0;for(let i,s,o=0,d=r.length,p=d-1;o<d;p=o++)i=r[o],s=r[p],t+=(s.x-i.x)*(i.y+s.y);return t}const Nl=1/298.257223563,Vl=Nl*(2-Nl),Co=Math.PI/180;class Eo{constructor(t){const i=6378.137*Co*1e3,s=Math.cos(t*Co),o=1/(1-Vl*(1-s*s)),d=Math.sqrt(o);this.kx=i*d*s,this.ky=i*d*o*(1-Vl)}distance(t,i){const s=this.wrap(t[0]-i[0])*this.kx,o=(t[1]-i[1])*this.ky;return Math.sqrt(s*s+o*o)}pointOnLine(t,i){let s,o,d,p,m=1/0;for(let g=0;g<t.length-1;g++){let x=t[g][0],v=t[g][1],T=this.wrap(t[g+1][0]-x)*this.kx,M=(t[g+1][1]-v)*this.ky,E=0;T===0&&M===0||(E=(this.wrap(i[0]-x)*this.kx*T+(i[1]-v)*this.ky*M)/(T*T+M*M),E>1?(x=t[g+1][0],v=t[g+1][1]):E>0&&(x+=T/this.kx*E,v+=M/this.ky*E)),T=this.wrap(i[0]-x)*this.kx,M=(i[1]-v)*this.ky;const A=T*T+M*M;A<m&&(m=A,s=x,o=v,d=g,p=E)}return{point:[s,o],index:d,t:Math.max(0,Math.min(1,p))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function Ul(r,t){return t[0]-r[0]}function Pa(r){return r[1]-r[0]+1}function Cr(r,t){return r[1]>=r[0]&&r[1]<t}function ht(r,t){if(r[0]>r[1])return[null,null];const i=Pa(r);if(t){if(i===2)return[r,null];const o=Math.floor(i/2);return[[r[0],r[0]+o],[r[0]+o,r[1]]]}if(i===1)return[r,null];const s=Math.floor(i/2)-1;return[[r[0],r[0]+s],[r[0]+s+1,r[1]]]}function Ao(r,t){if(!Cr(t,r.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)Ds(i,r[s]);return i}function ko(r){const t=[1/0,1/0,-1/0,-1/0];for(const i of r)for(const s of i)Ds(t,s);return t}function $l(r){return r[0]!==-1/0&&r[1]!==-1/0&&r[2]!==1/0&&r[3]!==1/0}function zo(r,t,i){if(!$l(r)||!$l(t))return NaN;let s=0,o=0;return r[2]<t[0]&&(s=t[0]-r[2]),r[0]>t[2]&&(s=r[0]-t[2]),r[1]>t[3]&&(o=r[1]-t[3]),r[3]<t[1]&&(o=t[1]-r[3]),i.distance([0,0],[s,o])}function Mn(r,t,i){const s=i.pointOnLine(t,r);return i.distance(r,s.point)}function Lo(r,t,i,s,o){const d=Math.min(Mn(r,[i,s],o),Mn(t,[i,s],o)),p=Math.min(Mn(i,[r,t],o),Mn(s,[r,t],o));return Math.min(d,p)}function nh(r,t,i,s,o){if(!Cr(t,r.length)||!Cr(s,i.length))return 1/0;let d=1/0;for(let p=t[0];p<t[1];++p){const m=r[p],g=r[p+1];for(let x=s[0];x<s[1];++x){const v=i[x],T=i[x+1];if(wa(m,g,v,T))return 0;d=Math.min(d,Lo(m,g,v,T,o))}}return d}function sh(r,t,i,s,o){if(!Cr(t,r.length)||!Cr(s,i.length))return NaN;let d=1/0;for(let p=t[0];p<=t[1];++p)for(let m=s[0];m<=s[1];++m)if(d=Math.min(d,o.distance(r[p],i[m])),d===0)return d;return d}function ah(r,t,i){if(Pn(r,t,!0))return 0;let s=1/0;for(const o of t){const d=o[0],p=o[o.length-1];if(d!==p&&(s=Math.min(s,Mn(r,[p,d],i)),s===0))return s;const m=i.pointOnLine(o,r);if(s=Math.min(s,i.distance(r,m.point)),s===0)return s}return s}function oh(r,t,i,s){if(!Cr(t,r.length))return NaN;for(let d=t[0];d<=t[1];++d)if(Pn(r[d],i,!0))return 0;let o=1/0;for(let d=t[0];d<t[1];++d){const p=r[d],m=r[d+1];for(const g of i)for(let x=0,v=g.length,T=v-1;x<v;T=x++){const M=g[T],E=g[x];if(wa(p,m,M,E))return 0;o=Math.min(o,Lo(p,m,M,E,s))}}return o}function Zl(r,t){for(const i of r)for(const s of i)if(Pn(s,t,!0))return!0;return!1}function lh(r,t,i,s=1/0){const o=ko(r),d=ko(t);if(s!==1/0&&zo(o,d,i)>=s)return s;if(Rs(o,d)){if(Zl(r,t))return 0}else if(Zl(t,r))return 0;let p=1/0;for(const m of r)for(let g=0,x=m.length,v=x-1;g<x;v=g++){const T=m[v],M=m[g];for(const E of t)for(let A=0,L=E.length,F=L-1;A<L;F=A++){const V=E[F],Q=E[A];if(wa(T,M,V,Q))return 0;p=Math.min(p,Lo(T,M,V,Q,i))}}return p}function Gl(r,t,i,s,o,d){if(!d)return;const p=zo(Ao(s,d),o,i);p<t&&r.push([p,d,[0,0]])}function Sa(r,t,i,s,o,d,p){if(!d||!p)return;const m=zo(Ao(s,d),Ao(o,p),i);m<t&&r.push([m,d,p])}function Ma(r,t,i,s,o=1/0){let d=Math.min(s.distance(r[0],i[0][0]),o);if(d===0)return d;const p=new Mo([[0,[0,r.length-1],[0,0]]],Ul),m=ko(i);for(;p.length>0;){const g=p.pop();if(g[0]>=d)continue;const x=g[1],v=t?50:100;if(Pa(x)<=v){if(!Cr(x,r.length))return NaN;if(t){const T=oh(r,x,i,s);if(isNaN(T)||T===0)return T;d=Math.min(d,T)}else for(let T=x[0];T<=x[1];++T){const M=ah(r[T],i,s);if(d=Math.min(d,M),d===0)return 0}}else{const T=ht(x,t);Gl(p,d,s,r,m,T[0]),Gl(p,d,s,r,m,T[1])}}return d}function Ia(r,t,i,s,o,d=1/0){let p=Math.min(d,o.distance(r[0],i[0]));if(p===0)return p;const m=new Mo([[0,[0,r.length-1],[0,i.length-1]]],Ul);for(;m.length>0;){const g=m.pop();if(g[0]>=p)continue;const x=g[1],v=g[2],T=t?50:100,M=s?50:100;if(Pa(x)<=T&&Pa(v)<=M){if(!Cr(x,r.length)&&Cr(v,i.length))return NaN;let E;if(t&&s)E=nh(r,x,i,v,o),p=Math.min(p,E);else if(t&&!s){const A=r.slice(x[0],x[1]+1);for(let L=v[0];L<=v[1];++L)if(E=Mn(i[L],A,o),p=Math.min(p,E),p===0)return p}else if(!t&&s){const A=i.slice(v[0],v[1]+1);for(let L=x[0];L<=x[1];++L)if(E=Mn(r[L],A,o),p=Math.min(p,E),p===0)return p}else E=sh(r,x,i,v,o),p=Math.min(p,E)}else{const E=ht(x,t),A=ht(v,s);Sa(m,p,o,r,i,E[0],A[0]),Sa(m,p,o,r,i,E[0],A[1]),Sa(m,p,o,r,i,E[1],A[0]),Sa(m,p,o,r,i,E[1],A[1])}}return p}function Do(r){return r.type==="MultiPolygon"?r.coordinates.map(t=>({type:"Polygon",coordinates:t})):r.type==="MultiLineString"?r.coordinates.map(t=>({type:"LineString",coordinates:t})):r.type==="MultiPoint"?r.coordinates.map(t=>({type:"Point",coordinates:t})):[r]}class In{constructor(t,i){this.type=ke,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(bn(t[1])){const s=t[1];if(s.type==="FeatureCollection")return new In(s,s.features.map(o=>Do(o.geometry)).flat());if(s.type==="Feature")return new In(s,Do(s.geometry));if("type"in s&&"coordinates"in s)return new In(s,Do(s))}return i.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(i,s){const o=i.geometry(),d=o.flat().map(g=>ba([g.x,g.y],i.canonical));if(o.length===0)return NaN;const p=new Eo(d[0][1]);let m=1/0;for(const g of s){switch(g.type){case"Point":m=Math.min(m,Ia(d,!1,[g.coordinates],!1,p,m));break;case"LineString":m=Math.min(m,Ia(d,!1,g.coordinates,!0,p,m));break;case"Polygon":m=Math.min(m,Ma(d,!1,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries);if(t.geometryType()==="LineString")return function(i,s){const o=i.geometry(),d=o.flat().map(g=>ba([g.x,g.y],i.canonical));if(o.length===0)return NaN;const p=new Eo(d[0][1]);let m=1/0;for(const g of s){switch(g.type){case"Point":m=Math.min(m,Ia(d,!0,[g.coordinates],!1,p,m));break;case"LineString":m=Math.min(m,Ia(d,!0,g.coordinates,!0,p,m));break;case"Polygon":m=Math.min(m,Ma(d,!0,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries);if(t.geometryType()==="Polygon")return function(i,s){const o=i.geometry();if(o.length===0||o[0].length===0)return NaN;const d=Bs(o,0).map(g=>g.map(x=>x.map(v=>ba([v.x,v.y],i.canonical)))),p=new Eo(d[0][0][0][1]);let m=1/0;for(const g of s)for(const x of d){switch(g.type){case"Point":m=Math.min(m,Ma([g.coordinates],!1,x,p,m));break;case"LineString":m=Math.min(m,Ma(g.coordinates,!0,x,p,m));break;case"Polygon":m=Math.min(m,lh(x,g.coordinates,p,m))}if(m===0)return m}return m}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Os{constructor(t){this.type=Ye,this.key=t}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=t[1];return s==null?i.error("Global state property must be defined."):typeof s!="string"?i.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new Os(s)}evaluate(t){var i;const s=(i=t.globals)===null||i===void 0?void 0:i.globalState;return s&&Object.keys(s).length!==0?Yn(s,this.key):null}eachChild(){}outputDefined(){return!1}}const es={"==":Ll,"!=":ya,">":bo,"<":Xc,">=":Kc,"<=":Yc,array:Oi,at:ga,boolean:Oi,case:Jn,coalesce:ks,collator:xa,format:Tn,image:To,in:_a,"index-of":Qi,interpolate:ui,"interpolate-hcl":ui,"interpolate-lab":ui,length:va,let:Is,literal:Ir,match:ii,number:Oi,"number-format":wo,object:Oi,slice:Cs,step:Ft,string:Oi,"to-boolean":br,"to-color":br,"to-number":br,"to-string":br,var:ma,within:Sn,distance:In,"global-state":Os};class Gi{constructor(t,i,s,o){this.name=t,this.type=i,this._evaluate=s,this.args=o}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,i){const s=t[0],o=Gi.definitions[s];if(!o)return i.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const d=Array.isArray(o)?o[0]:o.type,p=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,m=p.filter(([x])=>!Array.isArray(x)||x.length===t.length-1);let g=null;for(const[x,v]of m){g=new Kn(i.registry,Ca,i.path,null,i.scope);const T=[];let M=!1;for(let E=1;E<t.length;E++){const A=t[E],L=Array.isArray(x)?x[E-1]:x.type,F=g.parse(A,1+T.length,L);if(!F){M=!0;break}T.push(F)}if(!M)if(Array.isArray(x)&&x.length!==T.length)g.error(`Expected ${x.length} arguments, but found ${T.length} instead.`);else{for(let E=0;E<T.length;E++){const A=Array.isArray(x)?x[E]:x.type,L=T[E];g.concat(E+1).checkSubtype(A,L.type)}if(g.errors.length===0)return new Gi(s,d,v,T)}}if(m.length===1)i.errors.push(...g.errors);else{const x=(m.length?m:p).map(([T])=>{return M=T,Array.isArray(M)?`(${M.map(vt).join(", ")})`:`(${vt(M.type)}...)`;var M}).join(" | "),v=[];for(let T=1;T<t.length;T++){const M=i.parse(t[T],1+v.length);if(!M)return null;v.push(vt(M.type))}i.error(`Expected arguments of type ${x}, but found (${v.join(", ")}) instead.`)}return null}static register(t,i){Gi.definitions=i;for(const s in i)t[s]=Gi}}function ql(r,[t,i,s,o]){t=t.evaluate(r),i=i.evaluate(r),s=s.evaluate(r);const d=o?o.evaluate(r):1,p=Pt(t,i,s,d);if(p)throw new bt(p);return new it(t/255,i/255,s/255,d,!1)}function Wl(r,t){return r in t}function Ro(r,t){const i=t[r];return i===void 0?null:i}function Cn(r){return{type:r}}function Ca(r){if(r instanceof ma)return Ca(r.boundExpression);if(r instanceof Gi&&r.name==="error"||r instanceof xa||r instanceof Sn||r instanceof In||r instanceof Os)return!1;const t=r instanceof br||r instanceof Oi;let i=!0;return r.eachChild(s=>{i=t?i&&Ca(s):i&&s instanceof Ir}),!!i&&Ea(r)&&Aa(r,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Ea(r){if(r instanceof Gi&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||/^filter-/.test(r.name))||r instanceof Sn||r instanceof In)return!1;let t=!0;return r.eachChild(i=>{t&&!Ea(i)&&(t=!1)}),t}function js(r){if(r instanceof Gi&&r.name==="feature-state")return!1;let t=!0;return r.eachChild(i=>{t&&!js(i)&&(t=!1)}),t}function Aa(r,t){if(r instanceof Gi&&t.indexOf(r.name)>=0)return!1;let i=!0;return r.eachChild(s=>{i&&!Aa(s,t)&&(i=!1)}),i}function Hl(r){return{result:"success",value:r}}function ts(r){return{result:"error",value:r}}function Jr(r){return r["property-type"]==="data-driven"||r["property-type"]==="cross-faded-data-driven"}function Xl(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function Fo(r){return!!r.expression&&r.expression.interpolated}function nt(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function Ns(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&$e(r)===Wr}function ch(r){return r}function Yl(r,t){const i=r.stops&&typeof r.stops[0][0]=="object",s=i||!(i||r.property!==void 0),o=r.type||(Fo(t)?"exponential":"interval"),d=function(v){switch(v.type){case"color":return it.parse;case"padding":return ti.parse;case"numberArray":return wi.parse;case"colorArray":return $t.parse;default:return null}}(t);if(d&&((r=gi({},r)).stops&&(r.stops=r.stops.map(v=>[v[0],d(v[1])])),r.default=d(r.default?r.default:t.default)),r.colorSpace&&(p=r.colorSpace)!=="rgb"&&p!=="hcl"&&p!=="lab")throw new Error(`Unknown color space: "${r.colorSpace}"`);var p;const m=function(v){switch(v){case"exponential":return Jl;case"interval":return hh;case"categorical":return Kl;case"identity":return uh;default:throw new Error(`Unknown function type "${v}"`)}}(o);let g,x;if(o==="categorical"){g=Object.create(null);for(const v of r.stops)g[v[0]]=v[1];x=typeof r.stops[0][0]}if(i){const v={},T=[];for(let A=0;A<r.stops.length;A++){const L=r.stops[A],F=L[0].zoom;v[F]===void 0&&(v[F]={zoom:F,type:r.type,property:r.property,default:r.default,stops:[]},T.push(F)),v[F].stops.push([L[0].value,L[1]])}const M=[];for(const A of T)M.push([v[A].zoom,Yl(v[A],t)]);const E={name:"linear"};return{kind:"composite",interpolationType:E,interpolationFactor:ui.interpolationFactor.bind(void 0,E),zoomStops:M.map(A=>A[0]),evaluate:({zoom:A},L)=>Jl({stops:M,base:r.base},t,A).evaluate(A,L)}}if(s){const v=o==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:ui.interpolationFactor.bind(void 0,v),zoomStops:r.stops.map(T=>T[0]),evaluate:({zoom:T})=>m(r,t,T,g,x)}}return{kind:"source",evaluate(v,T){const M=T&&T.properties?T.properties[r.property]:void 0;return M===void 0?Qr(r.default,t.default):m(r,t,M,g,x)}}}function Qr(r,t,i){return r!==void 0?r:t!==void 0?t:i!==void 0?i:void 0}function Kl(r,t,i,s,o){return Qr(typeof i===o?s[i]:void 0,r.default,t.default)}function hh(r,t,i){if(nt(i)!=="number")return Qr(r.default,t.default);const s=r.stops.length;if(s===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[s-1][0])return r.stops[s-1][1];const o=wn(r.stops.map(d=>d[0]),i);return r.stops[o][1]}function Jl(r,t,i){const s=r.base!==void 0?r.base:1;if(nt(i)!=="number")return Qr(r.default,t.default);const o=r.stops.length;if(o===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[o-1][0])return r.stops[o-1][1];const d=wn(r.stops.map(v=>v[0]),i),p=function(v,T,M,E){const A=E-M,L=v-M;return A===0?0:T===1?L/A:(Math.pow(T,L)-1)/(Math.pow(T,A)-1)}(i,s,r.stops[d][0],r.stops[d+1][0]),m=r.stops[d][1],g=r.stops[d+1][1],x=wr[t.type]||ch;return typeof m.evaluate=="function"?{evaluate(...v){const T=m.evaluate.apply(void 0,v),M=g.evaluate.apply(void 0,v);if(T!==void 0&&M!==void 0)return x(T,M,p,r.colorSpace)}}:x(m,g,p,r.colorSpace)}function uh(r,t,i){switch(t.type){case"color":i=it.parse(i);break;case"formatted":i=bi.fromString(i.toString());break;case"resolvedImage":i=Bi.fromString(i.toString());break;case"padding":i=ti.parse(i);break;case"colorArray":i=$t.parse(i);break;case"numberArray":i=wi.parse(i);break;default:nt(i)===t.type||t.type==="enum"&&t.values[i]||(i=void 0)}return Qr(i,r.default,t.default)}Gi.register(es,{error:[{kind:"error"},[et],(r,[t])=>{throw new bt(t.evaluate(r))}],typeof:[et,[Ye],(r,[t])=>vt($e(t.evaluate(r)))],"to-rgba":[Ai(ke,4),[hi],(r,[t])=>{const[i,s,o,d]=t.evaluate(r).rgb;return[255*i,255*s,255*o,d]}],rgb:[hi,[ke,ke,ke],ql],rgba:[hi,[ke,ke,ke,ke],ql],has:{type:Je,overloads:[[[et],(r,[t])=>Wl(t.evaluate(r),r.properties())],[[et,Wr],(r,[t,i])=>Wl(t.evaluate(r),i.evaluate(r))]]},get:{type:Ye,overloads:[[[et],(r,[t])=>Ro(t.evaluate(r),r.properties())],[[et,Wr],(r,[t,i])=>Ro(t.evaluate(r),i.evaluate(r))]]},"feature-state":[Ye,[et],(r,[t])=>Ro(t.evaluate(r),r.featureState||{})],properties:[Wr,[],r=>r.properties()],"geometry-type":[et,[],r=>r.geometryType()],id:[Ye,[],r=>r.id()],zoom:[ke,[],r=>r.globals.zoom],"heatmap-density":[ke,[],r=>r.globals.heatmapDensity||0],elevation:[ke,[],r=>r.globals.elevation||0],"line-progress":[ke,[],r=>r.globals.lineProgress||0],accumulated:[Ye,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[ke,Cn(ke),(r,t)=>{let i=0;for(const s of t)i+=s.evaluate(r);return i}],"*":[ke,Cn(ke),(r,t)=>{let i=1;for(const s of t)i*=s.evaluate(r);return i}],"-":{type:ke,overloads:[[[ke,ke],(r,[t,i])=>t.evaluate(r)-i.evaluate(r)],[[ke],(r,[t])=>-t.evaluate(r)]]},"/":[ke,[ke,ke],(r,[t,i])=>t.evaluate(r)/i.evaluate(r)],"%":[ke,[ke,ke],(r,[t,i])=>t.evaluate(r)%i.evaluate(r)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(r,[t,i])=>Math.pow(t.evaluate(r),i.evaluate(r))],sqrt:[ke,[ke],(r,[t])=>Math.sqrt(t.evaluate(r))],log10:[ke,[ke],(r,[t])=>Math.log(t.evaluate(r))/Math.LN10],ln:[ke,[ke],(r,[t])=>Math.log(t.evaluate(r))],log2:[ke,[ke],(r,[t])=>Math.log(t.evaluate(r))/Math.LN2],sin:[ke,[ke],(r,[t])=>Math.sin(t.evaluate(r))],cos:[ke,[ke],(r,[t])=>Math.cos(t.evaluate(r))],tan:[ke,[ke],(r,[t])=>Math.tan(t.evaluate(r))],asin:[ke,[ke],(r,[t])=>Math.asin(t.evaluate(r))],acos:[ke,[ke],(r,[t])=>Math.acos(t.evaluate(r))],atan:[ke,[ke],(r,[t])=>Math.atan(t.evaluate(r))],min:[ke,Cn(ke),(r,t)=>Math.min(...t.map(i=>i.evaluate(r)))],max:[ke,Cn(ke),(r,t)=>Math.max(...t.map(i=>i.evaluate(r)))],abs:[ke,[ke],(r,[t])=>Math.abs(t.evaluate(r))],round:[ke,[ke],(r,[t])=>{const i=t.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[ke,[ke],(r,[t])=>Math.floor(t.evaluate(r))],ceil:[ke,[ke],(r,[t])=>Math.ceil(t.evaluate(r))],"filter-==":[Je,[et,Ye],(r,[t,i])=>r.properties()[t.value]===i.value],"filter-id-==":[Je,[Ye],(r,[t])=>r.id()===t.value],"filter-type-==":[Je,[et],(r,[t])=>r.geometryType()===t.value],"filter-<":[Je,[et,Ye],(r,[t,i])=>{const s=r.properties()[t.value],o=i.value;return typeof s==typeof o&&s<o}],"filter-id-<":[Je,[Ye],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i<s}],"filter->":[Je,[et,Ye],(r,[t,i])=>{const s=r.properties()[t.value],o=i.value;return typeof s==typeof o&&s>o}],"filter-id->":[Je,[Ye],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i>s}],"filter-<=":[Je,[et,Ye],(r,[t,i])=>{const s=r.properties()[t.value],o=i.value;return typeof s==typeof o&&s<=o}],"filter-id-<=":[Je,[Ye],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i<=s}],"filter->=":[Je,[et,Ye],(r,[t,i])=>{const s=r.properties()[t.value],o=i.value;return typeof s==typeof o&&s>=o}],"filter-id->=":[Je,[Ye],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i>=s}],"filter-has":[Je,[Ye],(r,[t])=>t.value in r.properties()],"filter-has-id":[Je,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[Je,[Ai(et)],(r,[t])=>t.value.indexOf(r.geometryType())>=0],"filter-id-in":[Je,[Ai(Ye)],(r,[t])=>t.value.indexOf(r.id())>=0],"filter-in-small":[Je,[et,Ai(Ye)],(r,[t,i])=>i.value.indexOf(r.properties()[t.value])>=0],"filter-in-large":[Je,[et,Ai(Ye)],(r,[t,i])=>function(s,o,d,p){for(;d<=p;){const m=d+p>>1;if(o[m]===s)return!0;o[m]>s?p=m-1:d=m+1}return!1}(r.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Je,overloads:[[[Je,Je],(r,[t,i])=>t.evaluate(r)&&i.evaluate(r)],[Cn(Je),(r,t)=>{for(const i of t)if(!i.evaluate(r))return!1;return!0}]]},any:{type:Je,overloads:[[[Je,Je],(r,[t,i])=>t.evaluate(r)||i.evaluate(r)],[Cn(Je),(r,t)=>{for(const i of t)if(i.evaluate(r))return!0;return!1}]]},"!":[Je,[Je],(r,[t])=>!t.evaluate(r)],"is-supported-script":[Je,[et],(r,[t])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(t.evaluate(r))}],upcase:[et,[et],(r,[t])=>t.evaluate(r).toUpperCase()],downcase:[et,[et],(r,[t])=>t.evaluate(r).toLowerCase()],concat:[et,Cn(Ye),(r,t)=>t.map(i=>We(i.evaluate(r))).join("")],"resolved-locale":[et,[ca],(r,[t])=>t.evaluate(r).resolvedLocale()]});class Bo{constructor(t,i){this.expression=t,this._warningHistory={},this._evaluator=new xo,this._defaultValue=i?function(s){if(s.type==="color"&&Ns(s.default))return new it(0,0,0,0);switch(s.type){case"color":return it.parse(s.default)||null;case"padding":return ti.parse(s.default)||null;case"numberArray":return wi.parse(s.default)||null;case"colorArray":return $t.parse(s.default)||null;case"variableAnchorOffsetCollection":return Ti.parse(s.default)||null;case"projectionDefinition":return _i.parse(s.default)||null;default:return s.default===void 0?null:s.default}}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null}evaluateWithoutErrorHandling(t,i,s,o,d,p){return this._evaluator.globals=t,this._evaluator.feature=i,this._evaluator.featureState=s,this._evaluator.canonical=o,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(t,i,s,o,d,p){this._evaluator.globals=t,this._evaluator.feature=i||null,this._evaluator.featureState=s||null,this._evaluator.canonical=o,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p||null;try{const m=this.expression.evaluate(this._evaluator);if(m==null||typeof m=="number"&&m!=m)return this._defaultValue;if(this._enumValues&&!(m in this._enumValues))throw new bt(`Expected value to be one of ${Object.keys(this._enumValues).map(g=>JSON.stringify(g)).join(", ")}, but found ${JSON.stringify(m)} instead.`);return m}catch(m){return this._warningHistory[m.message]||(this._warningHistory[m.message]=!0,typeof console<"u"&&console.warn(m.message)),this._defaultValue}}}function ka(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in es}function Vs(r,t){const i=new Kn(es,Ca,[],t?function(o){const d={color:hi,string:et,number:ke,enum:et,boolean:Je,formatted:Hr,padding:ha,numberArray:qn,colorArray:xr,projectionDefinition:_n,resolvedImage:Rt,variableAnchorOffsetCollection:ua};return o.type==="array"?Ai(d[o.value]||Ye,o.length):d[o.type]}(t):void 0),s=i.parse(r,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?Hl(new Bo(s,t)):ts(i.errors)}class Us{constructor(t,i){this.kind=t,this._styleExpression=i,this.isStateDependent=t!=="constant"&&!js(i.expression),this.globalStateRefs=Gs(i.expression)}evaluateWithoutErrorHandling(t,i,s,o,d,p){return this._styleExpression.evaluateWithoutErrorHandling(t,i,s,o,d,p)}evaluate(t,i,s,o,d,p){return this._styleExpression.evaluate(t,i,s,o,d,p)}}class Oo{constructor(t,i,s,o){this.kind=t,this.zoomStops=s,this._styleExpression=i,this.isStateDependent=t!=="camera"&&!js(i.expression),this.globalStateRefs=Gs(i.expression),this.interpolationType=o}evaluateWithoutErrorHandling(t,i,s,o,d,p){return this._styleExpression.evaluateWithoutErrorHandling(t,i,s,o,d,p)}evaluate(t,i,s,o,d,p){return this._styleExpression.evaluate(t,i,s,o,d,p)}interpolationFactor(t,i,s){return this.interpolationType?ui.interpolationFactor(this.interpolationType,t,i,s):0}}function Ql(r,t){const i=Vs(r,t);if(i.result==="error")return i;const s=i.value.expression,o=Ea(s);if(!o&&!Jr(t))return ts([new At("","data expressions not supported")]);const d=Aa(s,["zoom"]);if(!d&&!Xl(t))return ts([new At("","zoom expressions not supported")]);const p=Zs(s);return p||d?p instanceof At?ts([p]):p instanceof ui&&!Fo(t)?ts([new At("",'"interpolate" expressions cannot be used with this property')]):Hl(p?new Oo(o?"camera":"composite",i.value,p.labels,p instanceof ui?p.interpolation:void 0):new Us(o?"constant":"source",i.value)):ts([new At("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class $s{constructor(t,i){this._parameters=t,this._specification=i,gi(this,Yl(this._parameters,this._specification))}static deserialize(t){return new $s(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Zs(r){let t=null;if(r instanceof Is)t=Zs(r.result);else if(r instanceof ks){for(const i of r.args)if(t=Zs(i),t)break}else(r instanceof Ft||r instanceof ui)&&r.input instanceof Gi&&r.input.name==="zoom"&&(t=r);return t instanceof At||r.eachChild(i=>{const s=Zs(i);s instanceof At?t=s:!t&&s?t=new At("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new At("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Gs(r,t=new Set){return r instanceof Os&&t.add(r.key),r.eachChild(i=>{Gs(i,t)}),t}function za(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const t of r.slice(1))if(!za(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}const jo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function En(r){if(r==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};za(r)||(r=An(r));const t=Vs(r,jo);if(t.result==="error")throw new Error(t.value.map(i=>`${i.key}: ${i.message}`).join(", "));return{filter:(i,s,o)=>t.value.evaluate(i,s,{},o),needGeometry:La(r),getGlobalStateRefs:()=>Gs(t.value.expression)}}function No(r,t){return r<t?-1:r>t?1:0}function La(r){if(!Array.isArray(r))return!1;if(r[0]==="within"||r[0]==="distance")return!0;for(let t=1;t<r.length;t++)if(La(r[t]))return!0;return!1}function An(r){if(!r)return!0;const t=r[0];return r.length<=1?t!=="any":t==="=="?Vo(r[1],r[2],"=="):t==="!="?Da(Vo(r[1],r[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Vo(r[1],r[2],t):t==="any"?(i=r.slice(1),["any"].concat(i.map(An))):t==="all"?["all"].concat(r.slice(1).map(An)):t==="none"?["all"].concat(r.slice(1).map(An).map(Da)):t==="in"?ec(r[1],r.slice(2)):t==="!in"?Da(ec(r[1],r.slice(2))):t==="has"?tc(r[1]):t!=="!has"||Da(tc(r[1]));var i}function Vo(r,t,i){switch(r){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,r,t]}}function ec(r,t){if(t.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(i=>typeof i!=typeof t[0])?["filter-in-large",r,["literal",t.sort(No)]]:["filter-in-small",r,["literal",t]]}}function tc(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function Da(r){return["!",r]}function Uo(r){const t=typeof r;if(t==="number"||t==="boolean"||t==="string"||r==null)return JSON.stringify(r);if(Array.isArray(r)){let o="[";for(const d of r)o+=`${Uo(d)},`;return`${o}]`}const i=Object.keys(r).sort();let s="{";for(let o=0;o<i.length;o++)s+=`${JSON.stringify(i[o])}:${Uo(r[i[o]])},`;return`${s}}`}function dh(r){let t="";for(const i of qe)t+=`/${Uo(r[i])}`;return t}function $o(r){const t=r.value;return t?[new Te(r.key,t,"constants have been deprecated as of v8")]:[]}function kt(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function Tr(r){if(Array.isArray(r))return r.map(Tr);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const t={};for(const i in r)t[i]=Tr(r[i]);return t}return kt(r)}function qi(r){const t=r.key,i=r.value,s=r.valueSpec||{},o=r.objectElementValidators||{},d=r.style,p=r.styleSpec,m=r.validateSpec;let g=[];const x=nt(i);if(x!=="object")return[new Te(t,i,`object expected, ${x} found`)];for(const v in i){const T=v.split(".")[0],M=Yn(s,T)||s["*"];let E;if(Yn(o,T))E=o[T];else if(Yn(s,T))E=m;else if(o["*"])E=o["*"];else{if(!s["*"]){g.push(new Te(t,i[v],`unknown property "${v}"`));continue}E=m}g=g.concat(E({key:(t&&`${t}.`)+v,value:i[v],valueSpec:M,style:d,styleSpec:p,object:i,objectKey:v,validateSpec:m},i))}for(const v in s)o[v]||s[v].required&&s[v].default===void 0&&i[v]===void 0&&g.push(new Te(t,i,`missing required property "${v}"`));return g}function Ra(r){const t=r.value,i=r.valueSpec,s=r.style,o=r.styleSpec,d=r.key,p=r.arrayElementValidator||r.validateSpec;if(nt(t)!=="array")return[new Te(d,t,`array expected, ${nt(t)} found`)];if(i.length&&t.length!==i.length)return[new Te(d,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new Te(d,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let m={type:i.value,values:i.values};o.$version<7&&(m.function=i.function),nt(i.value)==="object"&&(m=i.value);let g=[];for(let x=0;x<t.length;x++)g=g.concat(p({array:t,arrayIndex:x,value:t[x],valueSpec:m,validateSpec:r.validateSpec,style:s,styleSpec:o,key:`${d}[${x}]`}));return g}function qs(r){const t=r.key,i=r.value,s=r.valueSpec;let o=nt(i);return o==="number"&&i!=i&&(o="NaN"),o!=="number"?[new Te(t,i,`number expected, ${o} found`)]:"minimum"in s&&i<s.minimum?[new Te(t,i,`${i} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&i>s.maximum?[new Te(t,i,`${i} is greater than the maximum value ${s.maximum}`)]:[]}function ic(r){const t=r.valueSpec,i=kt(r.value.type);let s,o,d,p={};const m=i!=="categorical"&&r.value.property===void 0,g=!m,x=nt(r.value.stops)==="array"&&nt(r.value.stops[0])==="array"&&nt(r.value.stops[0][0])==="object",v=qi({key:r.key,value:r.value,valueSpec:r.styleSpec.function,validateSpec:r.validateSpec,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function(E){if(i==="identity")return[new Te(E.key,E.value,'identity function may not have a "stops" property')];let A=[];const L=E.value;return A=A.concat(Ra({key:E.key,value:L,valueSpec:E.valueSpec,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec,arrayElementValidator:T})),nt(L)==="array"&&L.length===0&&A.push(new Te(E.key,L,"array must have at least one stop")),A},default:function(E){return E.validateSpec({key:E.key,value:E.value,valueSpec:t,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec})}}});return i==="identity"&&m&&v.push(new Te(r.key,r.value,'missing required property "property"')),i==="identity"||r.value.stops||v.push(new Te(r.key,r.value,'missing required property "stops"')),i==="exponential"&&r.valueSpec.expression&&!Fo(r.valueSpec)&&v.push(new Te(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(g&&!Jr(r.valueSpec)?v.push(new Te(r.key,r.value,"property functions not supported")):m&&!Xl(r.valueSpec)&&v.push(new Te(r.key,r.value,"zoom functions not supported"))),i!=="categorical"&&!x||r.value.property!==void 0||v.push(new Te(r.key,r.value,'"property" property is required')),v;function T(E){let A=[];const L=E.value,F=E.key;if(nt(L)!=="array")return[new Te(F,L,`array expected, ${nt(L)} found`)];if(L.length!==2)return[new Te(F,L,`array length 2 expected, length ${L.length} found`)];if(x){if(nt(L[0])!=="object")return[new Te(F,L,`object expected, ${nt(L[0])} found`)];if(L[0].zoom===void 0)return[new Te(F,L,"object stop key must have zoom")];if(L[0].value===void 0)return[new Te(F,L,"object stop key must have value")];if(d&&d>kt(L[0].zoom))return[new Te(F,L[0].zoom,"stop zoom values must appear in ascending order")];kt(L[0].zoom)!==d&&(d=kt(L[0].zoom),o=void 0,p={}),A=A.concat(qi({key:`${F}[0]`,value:L[0],valueSpec:{zoom:{}},validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec,objectElementValidators:{zoom:qs,value:M}}))}else A=A.concat(M({key:`${F}[0]`,value:L[0],validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec},L));return ka(Tr(L[1]))?A.concat([new Te(`${F}[1]`,L[1],"expressions are not allowed in function stops.")]):A.concat(E.validateSpec({key:`${F}[1]`,value:L[1],valueSpec:t,validateSpec:E.validateSpec,style:E.style,styleSpec:E.styleSpec}))}function M(E,A){const L=nt(E.value),F=kt(E.value),V=E.value!==null?E.value:A;if(s){if(L!==s)return[new Te(E.key,V,`${L} stop domain type must match previous stop domain type ${s}`)]}else s=L;if(L!=="number"&&L!=="string"&&L!=="boolean")return[new Te(E.key,V,"stop domain value must be a number, string, or boolean")];if(L!=="number"&&i!=="categorical"){let Q=`number expected, ${L} found`;return Jr(t)&&i===void 0&&(Q+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Te(E.key,V,Q)]}return i!=="categorical"||L!=="number"||isFinite(F)&&Math.floor(F)===F?i!=="categorical"&&L==="number"&&o!==void 0&&F<o?[new Te(E.key,V,"stop domain values must appear in ascending order")]:(o=F,i==="categorical"&&F in p?[new Te(E.key,V,"stop domain values must be unique")]:(p[F]=!0,[])):[new Te(E.key,V,`integer expected, found ${F}`)]}}function kn(r){const t=(r.expressionContext==="property"?Ql:Vs)(Tr(r.value),r.valueSpec);if(t.result==="error")return t.value.map(s=>new Te(`${r.key}${s.key}`,r.value,s.message));const i=t.value.expression||t.value._styleExpression.expression;if(r.expressionContext==="property"&&r.propertyKey==="text-font"&&!i.outputDefined())return[new Te(r.key,r.value,`Invalid data expression for "${r.propertyKey}". Output values must be contained as literals within the expression.`)];if(r.expressionContext==="property"&&r.propertyType==="layout"&&!js(i))return[new Te(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter"&&!js(i))return[new Te(r.key,r.value,'"feature-state" data expressions are not supported with filters.')];if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!Aa(i,["zoom","feature-state"]))return[new Te(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!Ea(i))return[new Te(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Fa(r){const t=r.key,i=r.value,s=nt(i);return s!=="string"?[new Te(t,i,`color expected, ${s} found`)]:it.parse(String(i))?[]:[new Te(t,i,`color expected, "${i}" found`)]}function Er(r){const t=r.key,i=r.value,s=r.valueSpec,o=[];return Array.isArray(s.values)?s.values.indexOf(kt(i))===-1&&o.push(new Te(t,i,`expected one of [${s.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(s.values).indexOf(kt(i))===-1&&o.push(new Te(t,i,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(i)} found`)),o}function Zo(r){return za(Tr(r.value))?kn(gi({},r,{expressionContext:"filter",valueSpec:{value:"boolean"}})):rc(r)}function rc(r){const t=r.value,i=r.key;if(nt(t)!=="array")return[new Te(i,t,`array expected, ${nt(t)} found`)];const s=r.styleSpec;let o,d=[];if(t.length<1)return[new Te(i,t,"filter array must have at least 1 element")];switch(d=d.concat(Er({key:`${i}[0]`,value:t[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),kt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&kt(t[1])==="$type"&&d.push(new Te(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&d.push(new Te(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(o=nt(t[1]),o!=="string"&&d.push(new Te(`${i}[1]`,t[1],`string expected, ${o} found`)));for(let p=2;p<t.length;p++)o=nt(t[p]),kt(t[1])==="$type"?d=d.concat(Er({key:`${i}[${p}]`,value:t[p],valueSpec:s.geometry_type,style:r.style,styleSpec:r.styleSpec})):o!=="string"&&o!=="number"&&o!=="boolean"&&d.push(new Te(`${i}[${p}]`,t[p],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let p=1;p<t.length;p++)d=d.concat(rc({key:`${i}[${p}]`,value:t[p],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":o=nt(t[1]),t.length!==2?d.push(new Te(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):o!=="string"&&d.push(new Te(`${i}[1]`,t[1],`string expected, ${o} found`))}return d}function nc(r,t){const i=r.key,s=r.validateSpec,o=r.style,d=r.styleSpec,p=r.value,m=r.objectKey,g=d[`${t}_${r.layerType}`];if(!g)return[];const x=m.match(/^(.*)-transition$/);if(t==="paint"&&x&&g[x[1]]&&g[x[1]].transition)return s({key:i,value:p,valueSpec:d.transition,style:o,styleSpec:d});const v=r.valueSpec||g[m];if(!v)return[new Te(i,p,`unknown property "${m}"`)];let T;if(nt(p)==="string"&&Jr(v)&&!v.tokens&&(T=/^{([^}]+)}$/.exec(p)))return[new Te(i,p,`"${m}" does not support interpolation syntax
5
+ Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(T[1])} }\`.`)];const M=[];return r.layerType==="symbol"&&(m==="text-field"&&o&&!o.glyphs&&M.push(new Te(i,p,'use of "text-field" requires a style "glyphs" property')),m==="text-font"&&Ns(Tr(p))&&kt(p.type)==="identity"&&M.push(new Te(i,p,'"text-font" does not support identity functions'))),M.concat(s({key:r.key,value:p,valueSpec:v,style:o,styleSpec:d,expressionContext:"property",propertyType:t,propertyKey:m}))}function sc(r){return nc(r,"paint")}function ac(r){return nc(r,"layout")}function oc(r){let t=[];const i=r.value,s=r.key,o=r.style,d=r.styleSpec;if(nt(i)!=="object")return[new Te(s,i,`object expected, ${nt(i)} found`)];i.type||i.ref||t.push(new Te(s,i,'either "type" or "ref" is required'));let p=kt(i.type);const m=kt(i.ref);if(i.id){const g=kt(i.id);for(let x=0;x<r.arrayIndex;x++){const v=o.layers[x];kt(v.id)===g&&t.push(new Te(s,i.id,`duplicate layer id "${i.id}", previously used at line ${v.id.__line__}`))}}if("ref"in i){let g;["type","source","source-layer","filter","layout"].forEach(x=>{x in i&&t.push(new Te(s,i[x],`"${x}" is prohibited for ref layers`))}),o.layers.forEach(x=>{kt(x.id)===m&&(g=x)}),g?g.ref?t.push(new Te(s,i.ref,"ref cannot reference another ref layer")):p=kt(g.type):t.push(new Te(s,i.ref,`ref layer "${m}" not found`))}else if(p!=="background")if(i.source){const g=o.sources&&o.sources[i.source],x=g&&kt(g.type);g?x==="vector"&&p==="raster"?t.push(new Te(s,i.source,`layer "${i.id}" requires a raster source`)):x!=="raster-dem"&&p==="hillshade"||x!=="raster-dem"&&p==="color-relief"?t.push(new Te(s,i.source,`layer "${i.id}" requires a raster-dem source`)):x==="raster"&&p!=="raster"?t.push(new Te(s,i.source,`layer "${i.id}" requires a vector source`)):x!=="vector"||i["source-layer"]?x==="raster-dem"&&p!=="hillshade"&&p!=="color-relief"?t.push(new Te(s,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):p!=="line"||!i.paint||!i.paint["line-gradient"]||x==="geojson"&&g.lineMetrics||t.push(new Te(s,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Te(s,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Te(s,i.source,`source "${i.source}" not found`))}else t.push(new Te(s,i,'missing required property "source"'));return t=t.concat(qi({key:s,value:i,valueSpec:d.layer,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,objectElementValidators:{"*":()=>[],type:()=>r.validateSpec({key:`${s}.type`,value:i.type,valueSpec:d.layer.type,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,object:i,objectKey:"type"}),filter:Zo,layout:g=>qi({layer:i,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>ac(gi({layerType:p},x))}}),paint:g=>qi({layer:i,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":x=>sc(gi({layerType:p},x))}})}})),t}function tr(r){const t=r.value,i=r.key,s=nt(t);return s!=="string"?[new Te(i,t,`string expected, ${s} found`)]:[]}const is={promoteId:function({key:r,value:t}){if(nt(t)==="string")return tr({key:r,value:t});{const i=[];for(const s in t)i.push(...tr({key:`${r}.${s}`,value:t[s]}));return i}}};function ki(r){const t=r.value,i=r.key,s=r.styleSpec,o=r.style,d=r.validateSpec;if(!t.type)return[new Te(i,t,'"type" is required')];const p=kt(t.type);let m;switch(p){case"vector":case"raster":return m=qi({key:i,value:t,valueSpec:s[`source_${p.replace("-","_")}`],style:r.style,styleSpec:s,objectElementValidators:is,validateSpec:d}),m;case"raster-dem":return m=function(g){var x;const v=(x=g.sourceName)!==null&&x!==void 0?x:"",T=g.value,M=g.styleSpec,E=M.source_raster_dem,A=g.style;let L=[];const F=nt(T);if(T===void 0)return L;if(F!=="object")return L.push(new Te("source_raster_dem",T,`object expected, ${F} found`)),L;const V=kt(T.encoding)==="custom",Q=["redFactor","greenFactor","blueFactor","baseShift"],W=g.value.encoding?`"${g.value.encoding}"`:"Default";for(const X in T)!V&&Q.includes(X)?L.push(new Te(X,T[X],`In "${v}": "${X}" is only valid when "encoding" is set to "custom". ${W} encoding found`)):E[X]?L=L.concat(g.validateSpec({key:X,value:T[X],valueSpec:E[X],validateSpec:g.validateSpec,style:A,styleSpec:M})):L.push(new Te(X,T[X],`unknown property "${X}"`));return L}({sourceName:i,value:t,style:r.style,styleSpec:s,validateSpec:d}),m;case"geojson":if(m=qi({key:i,value:t,valueSpec:s.source_geojson,style:o,styleSpec:s,validateSpec:d,objectElementValidators:is}),t.cluster)for(const g in t.clusterProperties){const[x,v]=t.clusterProperties[g],T=typeof x=="string"?[x,["accumulated"],["get",g]]:x;m.push(...kn({key:`${i}.${g}.map`,value:v,expressionContext:"cluster-map"})),m.push(...kn({key:`${i}.${g}.reduce`,value:T,expressionContext:"cluster-reduce"}))}return m;case"video":return qi({key:i,value:t,valueSpec:s.source_video,style:o,validateSpec:d,styleSpec:s});case"image":return qi({key:i,value:t,valueSpec:s.source_image,style:o,validateSpec:d,styleSpec:s});case"canvas":return[new Te(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Er({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function rs(r){const t=r.value,i=r.styleSpec,s=i.light,o=r.style;let d=[];const p=nt(t);if(t===void 0)return d;if(p!=="object")return d=d.concat([new Te("light",t,`object expected, ${p} found`)]),d;for(const m in t){const g=m.match(/^(.*)-transition$/);d=d.concat(g&&s[g[1]]&&s[g[1]].transition?r.validateSpec({key:m,value:t[m],valueSpec:i.transition,validateSpec:r.validateSpec,style:o,styleSpec:i}):s[m]?r.validateSpec({key:m,value:t[m],valueSpec:s[m],validateSpec:r.validateSpec,style:o,styleSpec:i}):[new Te(m,t[m],`unknown property "${m}"`)])}return d}function Go(r){const t=r.value,i=r.styleSpec,s=i.sky,o=r.style,d=nt(t);if(t===void 0)return[];if(d!=="object")return[new Te("sky",t,`object expected, ${d} found`)];let p=[];for(const m in t)p=p.concat(s[m]?r.validateSpec({key:m,value:t[m],valueSpec:s[m],style:o,styleSpec:i}):[new Te(m,t[m],`unknown property "${m}"`)]);return p}function lc(r){const t=r.value,i=r.styleSpec,s=i.terrain,o=r.style;let d=[];const p=nt(t);if(t===void 0)return d;if(p!=="object")return d=d.concat([new Te("terrain",t,`object expected, ${p} found`)]),d;for(const m in t)d=d.concat(s[m]?r.validateSpec({key:m,value:t[m],valueSpec:s[m],validateSpec:r.validateSpec,style:o,styleSpec:i}):[new Te(m,t[m],`unknown property "${m}"`)]);return d}function cc(r){let t=[];const i=r.value,s=r.key;if(Array.isArray(i)){const o=[],d=[];for(const p in i)i[p].id&&o.includes(i[p].id)&&t.push(new Te(s,i,`all the sprites' ids must be unique, but ${i[p].id} is duplicated`)),o.push(i[p].id),i[p].url&&d.includes(i[p].url)&&t.push(new Te(s,i,`all the sprites' URLs must be unique, but ${i[p].url} is duplicated`)),d.push(i[p].url),t=t.concat(qi({key:`${s}[${p}]`,value:i[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:r.validateSpec}));return t}return tr({key:s,value:i})}function ns(r){return t=r.value,t&&t.constructor===Object?[]:[new Te(r.key,r.value,`object expected, ${nt(r.value)} found`)];var t}const qo={"*":()=>[],array:Ra,boolean:function(r){const t=r.value,i=r.key,s=nt(t);return s!=="boolean"?[new Te(i,t,`boolean expected, ${s} found`)]:[]},number:qs,color:Fa,constants:$o,enum:Er,filter:Zo,function:ic,layer:oc,object:qi,source:ki,light:rs,sky:Go,terrain:lc,projection:function(r){const t=r.value,i=r.styleSpec,s=i.projection,o=r.style,d=nt(t);if(t===void 0)return[];if(d!=="object")return[new Te("projection",t,`object expected, ${d} found`)];let p=[];for(const m in t)p=p.concat(s[m]?r.validateSpec({key:m,value:t[m],valueSpec:s[m],style:o,styleSpec:i}):[new Te(m,t[m],`unknown property "${m}"`)]);return p},projectionDefinition:function(r){const t=r.key;let i=r.value;i=i instanceof String?i.valueOf():i;const s=nt(i);return s!=="array"||function(o){return Array.isArray(o)&&o.length===3&&typeof o[0]=="string"&&typeof o[1]=="string"&&typeof o[2]=="number"}(i)||function(o){return!!["interpolate","step","literal"].includes(o[0])}(i)?["array","string"].includes(s)?[]:[new Te(t,i,`projection expected, invalid type "${s}" found`)]:[new Te(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:tr,formatted:function(r){return tr(r).length===0?[]:kn(r)},resolvedImage:function(r){return tr(r).length===0?[]:kn(r)},padding:function(r){const t=r.key,i=r.value;if(nt(i)==="array"){if(i.length<1||i.length>4)return[new Te(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const s={type:"number"};let o=[];for(let d=0;d<i.length;d++)o=o.concat(r.validateSpec({key:`${t}[${d}]`,value:i[d],validateSpec:r.validateSpec,valueSpec:s}));return o}return qs({key:t,value:i,valueSpec:{}})},numberArray:function(r){const t=r.key,i=r.value;if(nt(i)==="array"){const s={type:"number"};if(i.length<1)return[new Te(t,i,"array length at least 1 expected, length 0 found")];let o=[];for(let d=0;d<i.length;d++)o=o.concat(r.validateSpec({key:`${t}[${d}]`,value:i[d],validateSpec:r.validateSpec,valueSpec:s}));return o}return qs({key:t,value:i,valueSpec:{}})},colorArray:function(r){const t=r.key,i=r.value;if(nt(i)==="array"){if(i.length<1)return[new Te(t,i,"array length at least 1 expected, length 0 found")];let s=[];for(let o=0;o<i.length;o++)s=s.concat(Fa({key:`${t}[${o}]`,value:i[o]}));return s}return Fa({key:t,value:i})},variableAnchorOffsetCollection:function(r){const t=r.key,i=r.value,s=nt(i),o=r.styleSpec;if(s!=="array"||i.length<1||i.length%2!=0)return[new Te(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let d=[];for(let p=0;p<i.length;p+=2)d=d.concat(Er({key:`${t}[${p}]`,value:i[p],valueSpec:o.layout_symbol["text-anchor"]})),d=d.concat(Ra({key:`${t}[${p+1}]`,value:i[p+1],valueSpec:{length:2,value:"number"},validateSpec:r.validateSpec,style:r.style,styleSpec:o}));return d},sprite:cc,state:ns};function ss(r){const t=r.value,i=r.valueSpec,s=r.styleSpec;return r.validateSpec=ss,i.expression&&Ns(kt(t))?ic(r):i.expression&&ka(Tr(t))?kn(r):i.type&&qo[i.type]?qo[i.type](r):qi(gi({},r,{valueSpec:i.type?s[i.type]:i}))}function hc(r){const t=r.value,i=r.key,s=tr(r);return s.length||(t.indexOf("{fontstack}")===-1&&s.push(new Te(i,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&s.push(new Te(i,t,'"glyphs" url must include a "{range}" token'))),s}function zi(r,t=ne){let i=[];return i=i.concat(ss({key:"",value:r,valueSpec:t.$root,styleSpec:t,style:r,validateSpec:ss,objectElementValidators:{glyphs:hc,"*":()=>[]}})),r.constants&&(i=i.concat($o({key:"constants",value:r.constants}))),as(i)}function ir(r){return function(t){return r({...t,validateSpec:ss})}}function as(r){return[].concat(r).sort((t,i)=>t.line-i.line)}function rr(r){return function(...t){return as(r.apply(this,t))}}zi.source=rr(ir(ki)),zi.sprite=rr(ir(cc)),zi.glyphs=rr(ir(hc)),zi.light=rr(ir(rs)),zi.sky=rr(ir(Go)),zi.terrain=rr(ir(lc)),zi.state=rr(ir(ns)),zi.layer=rr(ir(oc)),zi.filter=rr(ir(Zo)),zi.paintProperty=rr(ir(sc)),zi.layoutProperty=rr(ir(ac));const os=zi,ph=os.light,Ws=os.sky,fh=os.paintProperty,mh=os.layoutProperty;function Hs(r,t){let i=!1;if(t&&t.length)for(const s of t)r.fire(new _e(new Error(s.message))),i=!0;return i}class Xs{constructor(t,i,s){const o=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const p=new Int32Array(this.arrayBuffer);t=p[0],this.d=(i=p[1])+2*(s=p[2]);for(let g=0;g<this.d*this.d;g++){const x=p[3+g],v=p[3+g+1];o.push(x===v?null:p.subarray(x,v))}const m=p[3+o.length+1];this.keys=p.subarray(p[3+o.length],m),this.bboxes=p.subarray(m),this.insert=this._insertReadonly}else{this.d=i+2*s;for(let p=0;p<this.d*this.d;p++)o.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=s,this.scale=i/t,this.uid=0;const d=s/i*t;this.min=-d,this.max=t+d}insert(t,i,s,o,d){this._forEachCell(i,s,o,d,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(i),this.bboxes.push(s),this.bboxes.push(o),this.bboxes.push(d)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,i,s,o,d,p){this.cells[d].push(p)}query(t,i,s,o,d){const p=this.min,m=this.max;if(t<=p&&i<=p&&m<=s&&m<=o&&!d)return Array.prototype.slice.call(this.keys);{const g=[];return this._forEachCell(t,i,s,o,this._queryCell,g,{},d),g}}_queryCell(t,i,s,o,d,p,m,g){const x=this.cells[d];if(x!==null){const v=this.keys,T=this.bboxes;for(let M=0;M<x.length;M++){const E=x[M];if(m[E]===void 0){const A=4*E;(g?g(T[A+0],T[A+1],T[A+2],T[A+3]):t<=T[A+2]&&i<=T[A+3]&&s>=T[A+0]&&o>=T[A+1])?(m[E]=!0,p.push(v[E])):m[E]=!1}}}}_forEachCell(t,i,s,o,d,p,m,g){const x=this._convertToCellCoord(t),v=this._convertToCellCoord(i),T=this._convertToCellCoord(s),M=this._convertToCellCoord(o);for(let E=x;E<=T;E++)for(let A=v;A<=M;A++){const L=this.d*A+E;if((!g||g(this._convertFromCellCoord(E),this._convertFromCellCoord(A),this._convertFromCellCoord(E+1),this._convertFromCellCoord(A+1)))&&d.call(this,t,i,s,o,L,p,m,g))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,i=3+this.cells.length+1+1;let s=0;for(let p=0;p<this.cells.length;p++)s+=this.cells[p].length;const o=new Int32Array(i+s+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;let d=i;for(let p=0;p<t.length;p++){const m=t[p];o[3+p]=d,o.set(m,d),d+=m.length}return o[3+t.length]=d,o.set(this.keys,d),d+=this.keys.length,o[3+t.length+1]=d,o.set(this.bboxes,d),d+=this.bboxes.length,o.buffer}static serialize(t,i){const s=t.toArrayBuffer();return i&&i.push(s),{buffer:s}}static deserialize(t){return new Xs(t.buffer)}}const nr={};function ze(r,t,i={}){if(nr[r])throw new Error(`${r} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:r,writeable:!1}),nr[r]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}ze("Object",Object),ze("Set",Set),ze("TransferableGridIndex",Xs),ze("Color",it),ze("Error",Error),ze("AJAXError",Z),ze("ResolvedImage",Bi),ze("StylePropertyFunction",$s),ze("StyleExpression",Bo,{omit:["_evaluator"]}),ze("ZoomDependentExpression",Oo),ze("ZoomConstantExpression",Us),ze("CompoundExpression",Gi,{omit:["_evaluate"]});for(const r in es)es[r]._classRegistryKey||ze(`Expression_${r}`,es[r]);function Wo(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}function Ba(r){return r.$name||r.constructor._classRegistryKey}function Ho(r){return!function(t){if(t===null||typeof t!="object")return!1;const i=Ba(t);return!(!i||i==="Object")}(r)&&(r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||r instanceof Boolean||r instanceof Number||r instanceof String||r instanceof Date||r instanceof RegExp||r instanceof Blob||r instanceof Error||Wo(r)||_r(r)||ArrayBuffer.isView(r)||r instanceof ImageData)}function ls(r,t){if(Ho(r))return(Wo(r)||_r(r))&&t&&t.push(r),ArrayBuffer.isView(r)&&t&&t.push(r.buffer),r instanceof ImageData&&t&&t.push(r.data.buffer),r;if(Array.isArray(r)){const d=[];for(const p of r)d.push(ls(p,t));return d}if(typeof r!="object")throw new Error("can't serialize object of type "+typeof r);const i=Ba(r);if(!i)throw new Error(`can't serialize object of unregistered class ${r.constructor.name}`);if(!nr[i])throw new Error(`${i} is not registered.`);const{klass:s}=nr[i],o=s.serialize?s.serialize(r,t):{};if(s.serialize){if(t&&o===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const d in r){if(!r.hasOwnProperty(d)||nr[i].omit.indexOf(d)>=0)continue;const p=r[d];o[d]=nr[i].shallow.indexOf(d)>=0?p:ls(p,t)}r instanceof Error&&(o.message=r.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(o.$name=i),o}function zn(r){if(Ho(r))return r;if(Array.isArray(r))return r.map(zn);if(typeof r!="object")throw new Error("can't deserialize object of type "+typeof r);const t=Ba(r)||"Object";if(!nr[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=nr[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(r);const s=Object.create(i.prototype);for(const o of Object.keys(r)){if(o==="$name")continue;const d=r[o];s[o]=nr[t].shallow.indexOf(o)>=0?d:zn(d)}return s}class Oa{constructor(){this.first=!0}update(t,i){const s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=i):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=i),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=s,!0))}}const st={"Latin-1 Supplement":r=>r>=128&&r<=255,"Hangul Jamo":r=>r>=4352&&r<=4607,Khmer:r=>r>=6016&&r<=6143,"General Punctuation":r=>r>=8192&&r<=8303,"Letterlike Symbols":r=>r>=8448&&r<=8527,"Number Forms":r=>r>=8528&&r<=8591,"Miscellaneous Technical":r=>r>=8960&&r<=9215,"Control Pictures":r=>r>=9216&&r<=9279,"Optical Character Recognition":r=>r>=9280&&r<=9311,"Enclosed Alphanumerics":r=>r>=9312&&r<=9471,"Geometric Shapes":r=>r>=9632&&r<=9727,"Miscellaneous Symbols":r=>r>=9728&&r<=9983,"Miscellaneous Symbols and Arrows":r=>r>=11008&&r<=11263,"Ideographic Description Characters":r=>r>=12272&&r<=12287,"CJK Symbols and Punctuation":r=>r>=12288&&r<=12351,Hiragana:r=>r>=12352&&r<=12447,Katakana:r=>r>=12448&&r<=12543,Kanbun:r=>r>=12688&&r<=12703,"CJK Strokes":r=>r>=12736&&r<=12783,"Enclosed CJK Letters and Months":r=>r>=12800&&r<=13055,"CJK Compatibility":r=>r>=13056&&r<=13311,"Yijing Hexagram Symbols":r=>r>=19904&&r<=19967,"CJK Unified Ideographs":r=>r>=19968&&r<=40959,"Hangul Syllables":r=>r>=44032&&r<=55215,"Private Use Area":r=>r>=57344&&r<=63743,"Vertical Forms":r=>r>=65040&&r<=65055,"CJK Compatibility Forms":r=>r>=65072&&r<=65103,"Small Form Variants":r=>r>=65104&&r<=65135,"Halfwidth and Fullwidth Forms":r=>r>=65280&&r<=65519};function ja(r){for(const t of r)if(Yo(t.charCodeAt(0)))return!0;return!1}function gh(r){for(const t of r)if(!uc(t.charCodeAt(0)))return!1;return!0}function Na(r){const t=r.map(i=>{try{return new RegExp(`\\p{sc=${i}}`,"u").source}catch{return null}}).filter(i=>i);return new RegExp(t.join("|"),"u")}const _h=Na(["Arab","Dupl","Mong","Ougr","Syrc"]);function uc(r){return!_h.test(String.fromCodePoint(r))}const Xo=Na(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Yo(r){return!(r!==746&&r!==747&&(r<4352||!(st["CJK Compatibility Forms"](r)&&!(r>=65097&&r<=65103)||st["CJK Compatibility"](r)||st["CJK Strokes"](r)||!(!st["CJK Symbols and Punctuation"](r)||r>=12296&&r<=12305||r>=12308&&r<=12319||r===12336)||st["Enclosed CJK Letters and Months"](r)||st["Ideographic Description Characters"](r)||st.Kanbun(r)||st.Katakana(r)&&r!==12540||!(!st["Halfwidth and Fullwidth Forms"](r)||r===65288||r===65289||r===65293||r>=65306&&r<=65310||r===65339||r===65341||r===65343||r>=65371&&r<=65503||r===65507||r>=65512&&r<=65519)||!(!st["Small Form Variants"](r)||r>=65112&&r<=65118||r>=65123&&r<=65126)||st["Vertical Forms"](r)||st["Yijing Hexagram Symbols"](r)||new RegExp("\\p{sc=Cans}","u").test(String.fromCodePoint(r))||new RegExp("\\p{sc=Hang}","u").test(String.fromCodePoint(r))||Xo.test(String.fromCodePoint(r)))))}function dc(r){return!(Yo(r)||function(t){return!!(st["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||st["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||st["Letterlike Symbols"](t)||st["Number Forms"](t)||st["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||st["Control Pictures"](t)&&t!==9251||st["Optical Character Recognition"](t)||st["Enclosed Alphanumerics"](t)||st["Geometric Shapes"](t)||st["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||st["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||st["CJK Symbols and Punctuation"](t)||st.Katakana(t)||st["Private Use Area"](t)||st["CJK Compatibility Forms"](t)||st["Small Form Variants"](t)||st["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(r))}const pc=Na(["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 Ko(r){return pc.test(String.fromCodePoint(r))}function fc(r,t){return!(!t&&Ko(r)||r>=2304&&r<=3583||r>=3840&&r<=4255||st.Khmer(r))}function mc(r){for(const t of r)if(Ko(t.charCodeAt(0)))return!0;return!1}const sr=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(r){this.pluginStatus=r.pluginStatus,this.pluginURL=r.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(r){if(sr.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=r.applyArabicShaping,this.processBidirectionalText=r.processBidirectionalText,this.processStyledBidirectionalText=r.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(r,t){return c(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if(r.pluginStatus!=="loading")return this.setState(r),r;const i=r.pluginURL,s=new Promise(d=>{this.loadScriptResolve=d});t(i);const o=new Promise(d=>setTimeout(()=>d(),this.TIMEOUT));if(yield Promise.race([s,o]),this.isParsed()){const d={pluginStatus:"loaded",pluginURL:i};return this.setState(d),d}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${i}`)})}};class wt{constructor(t,i){this.zoom=t,i?(this.now=i.now||0,this.fadeDuration=i.fadeDuration||0,this.zoomHistory=i.zoomHistory||new Oa,this.transition=i.transition||{},this.globalState=i.globalState||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Oa,this.transition={},this.globalState={})}isSupportedScript(t){return function(i,s){for(const o of i)if(!fc(o.charCodeAt(0),s))return!1;return!0}(t,sr.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,i=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:i+(1-i)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*i}}}class cs{constructor(t,i){this.property=t,this.value=i,this.expression=function(s,o){if(Ns(s))return new $s(s,o);if(ka(s)){const d=Ql(s,o);if(d.result==="error")throw new Error(d.value.map(p=>`${p.key}: ${p.message}`).join(", "));return d.value}{let d=s;return o.type==="color"&&typeof s=="string"?d=it.parse(s):o.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?o.type!=="numberArray"||typeof s!="number"&&!Array.isArray(s)?o.type!=="colorArray"||typeof s!="string"&&!Array.isArray(s)?o.type==="variableAnchorOffsetCollection"&&Array.isArray(s)?d=Ti.parse(s):o.type==="projectionDefinition"&&typeof s=="string"&&(d=_i.parse(s)):d=$t.parse(s):d=wi.parse(s):d=ti.parse(s),{globalStateRefs:new Set,kind:"constant",evaluate:()=>d}}}(i===void 0?t.specification.default:i,t.specification),this._evaluate=this.expression.evaluate}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,i,s){return this.property.possiblyEvaluate(this,t,i,s)}setGlobalState(t){this.expression.evaluate=(i,s,o,d,p,m)=>(i.globalState=t,this._evaluate.call(this.expression,i,s,o,d,p,m))}}class Jo{constructor(t){this.property=t,this.value=new cs(t,void 0)}transitioned(t,i){return new Qo(this.property,this.value,i,Zi({},t.transition,this.transition),t.now)}untransitioned(){return new Qo(this.property,this.value,null,{},0)}}class gc{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return Fi(this._values[t].value.value)}setValue(t,i){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Jo(this._values[t].property)),this._values[t].value=new cs(this._values[t].property,i===null?void 0:Fi(i))}getTransition(t){return Fi(this._values[t].transition)}setTransition(t,i){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Jo(this._values[t].property)),this._values[t].transition=Fi(i)||void 0}serialize(){const t={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(t[i]=s);const o=this.getTransition(i);o!==void 0&&(t[`${i}-transition`]=o)}return t}transitioned(t,i){const s=new el(this._properties);for(const o of Object.keys(this._values))s._values[o]=this._values[o].transitioned(t,i._values[o]);return s}untransitioned(){const t=new el(this._properties);for(const i of Object.keys(this._values))t._values[i]=this._values[i].untransitioned();return t}}class Qo{constructor(t,i,s,o,d){this.property=t,this.value=i,this.begin=d+o.delay||0,this.end=this.begin+o.duration||0,t.specification.transition&&(o.delay||o.duration)&&(this.prior=s)}possiblyEvaluate(t,i,s){const o=t.now||0,d=this.value.possiblyEvaluate(t,i,s),p=this.prior;if(p){if(o>this.end)return this.prior=null,d;if(this.value.isDataDriven())return this.prior=null,d;if(o<this.begin)return p.possiblyEvaluate(t,i,s);{const m=(o-this.begin)/(this.end-this.begin);return this.property.interpolate(p.possiblyEvaluate(t,i,s),d,mr(m))}}return d}}class el{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,i,s){const o=new Va(this._properties);for(const d of Object.keys(this._values))o._values[d]=this._values[d].possiblyEvaluate(t,i,s);return o}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class _c{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState={}}hasValue(t){return this._values[t].value!==void 0}getValue(t){return Fi(this._values[t].value)}setValue(t,i){this._values[t]=new cs(this._values[t].property,i===null?void 0:Fi(i)),this._values[t].setGlobalState(this._globalState)}serialize(){const t={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(t[i]=s)}return t}possiblyEvaluate(t,i,s){const o=new Va(this._properties);for(const d of Object.keys(this._values))o._values[d]=this._values[d].possiblyEvaluate(t,i,s);return o}setGlobalState(t){this._globalState=t;for(const i of Object.values(this._values))i.setGlobalState(t)}}class Pr{constructor(t,i,s){this.property=t,this.value=i,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,i,s,o){return this.property.evaluate(this.value,this.parameters,t,i,s,o)}}class Va{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Fe{constructor(t){this.specification=t}possiblyEvaluate(t,i){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(i)}interpolate(t,i,s){const o=wr[this.specification.type];return o?o(t,i,s):t}}class Ve{constructor(t,i){this.specification=t,this.overrides=i}possiblyEvaluate(t,i,s,o){return new Pr(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(i,null,{},s,o)}:t.expression,i)}interpolate(t,i,s){if(t.value.kind!=="constant"||i.value.kind!=="constant")return t;if(t.value.value===void 0||i.value.value===void 0)return new Pr(this,{kind:"constant",value:void 0},t.parameters);const o=wr[this.specification.type];if(o){const d=o(t.value.value,i.value.value,s);return new Pr(this,{kind:"constant",value:d},t.parameters)}return t}evaluate(t,i,s,o,d,p){return t.kind==="constant"?t.value:t.evaluate(i,s,o,d,p)}}class Ua extends Ve{possiblyEvaluate(t,i,s,o){if(t.value===void 0)return new Pr(this,{kind:"constant",value:void 0},i);if(t.expression.kind==="constant"){const d=t.expression.evaluate(i,null,{},s,o),p=t.property.specification.type==="resolvedImage"&&typeof d!="string"?d.name:d,m=this._calculate(p,p,p,i);return new Pr(this,{kind:"constant",value:m},i)}if(t.expression.kind==="camera"){const d=this._calculate(t.expression.evaluate({zoom:i.zoom-1}),t.expression.evaluate({zoom:i.zoom}),t.expression.evaluate({zoom:i.zoom+1}),i);return new Pr(this,{kind:"constant",value:d},i)}return new Pr(this,t.expression,i)}evaluate(t,i,s,o,d,p){if(t.kind==="source"){const m=t.evaluate(i,s,o,d,p);return this._calculate(m,m,m,i)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(i.zoom)-1},s,o),t.evaluate({zoom:Math.floor(i.zoom)},s,o),t.evaluate({zoom:Math.floor(i.zoom)+1},s,o),i):t.value}_calculate(t,i,s,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:s,to:i}}interpolate(t){return t}}class en{constructor(t){this.specification=t}possiblyEvaluate(t,i,s,o){if(t.value!==void 0){if(t.expression.kind==="constant"){const d=t.expression.evaluate(i,null,{},s,o);return this._calculate(d,d,d,i)}return this._calculate(t.expression.evaluate(new wt(Math.floor(i.zoom-1),i)),t.expression.evaluate(new wt(Math.floor(i.zoom),i)),t.expression.evaluate(new wt(Math.floor(i.zoom+1),i)),i)}}_calculate(t,i,s,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:s,to:i}}interpolate(t){return t}}class $a{constructor(t){this.specification=t}possiblyEvaluate(t,i,s,o){return!!t.expression.evaluate(i,null,{},s,o)}interpolate(){return!1}}class Pi{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const i in t){const s=t[i];s.specification.overridable&&this.overridableProperties.push(i);const o=this.defaultPropertyValues[i]=new cs(s,void 0),d=this.defaultTransitionablePropertyValues[i]=new Jo(s);this.defaultTransitioningPropertyValues[i]=d.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=o.possiblyEvaluate({})}}}ze("DataDrivenProperty",Ve),ze("DataConstantProperty",Fe),ze("CrossFadedDataDrivenProperty",Ua),ze("CrossFadedProperty",en),ze("ColorRampProperty",$a);const yc="-transition";class Wi extends Re{constructor(t,i){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,this._globalState={},t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=En(t.filter)),i.layout&&(this._unevaluatedLayout=new _c(i.layout)),i.paint)){this._transitionablePaint=new gc(i.paint);for(const s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(const s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Va(i.paint)}}setFilter(t){this.filter=t,this._featureFilter=En(t)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){const t=new Set;if(this._unevaluatedLayout)for(const i in this._unevaluatedLayout._values){const s=this._unevaluatedLayout._values[i];for(const o of s.getGlobalStateRefs())t.add(o)}for(const i of this._featureFilter.getGlobalStateRefs())t.add(i);return t}getPaintAffectingGlobalStateRefs(){var t;const i=new globalThis.Map;if(this._transitionablePaint)for(const s in this._transitionablePaint._values){const o=this._transitionablePaint._values[s].value;for(const d of o.getGlobalStateRefs()){const p=(t=i.get(d))!==null&&t!==void 0?t:[];p.push({name:s,value:o.value}),i.set(d,p)}}return i}setLayoutProperty(t,i,s={}){i!=null&&this._validate(mh,`layers.${this.id}.layout.${t}`,t,i,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,i):this.visibility=i)}getPaintProperty(t){return t.endsWith(yc)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,i,s={}){if(i!=null&&this._validate(fh,`layers.${this.id}.paint.${t}`,t,i,s))return!1;if(t.endsWith(yc))return this._transitionablePaint.setTransition(t.slice(0,-11),i||void 0),!1;{const o=this._transitionablePaint._values[t],d=o.property.specification["property-type"]==="cross-faded-data-driven",p=o.value.isDataDriven(),m=o.value;this._transitionablePaint.setValue(t,i),this._handleSpecialPaintPropertyUpdate(t);const g=this._transitionablePaint._values[t].value;return g.isDataDriven()||p||d||this._handleOverridablePaintPropertyUpdate(t,m,g)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,i,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,i){t.globalState=this._globalState,t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,i)}setGlobalState(t){this._globalState=t,this._unevaluatedLayout&&this._unevaluatedLayout.setGlobalState(t)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),Un(t,(i,s)=>!(i===void 0||s==="layout"&&!Object.keys(i).length||s==="paint"&&!Object.keys(i).length))}_validate(t,i,s,o,d={}){return(!d||d.validate!==!1)&&Hs(this,t.call(os,{key:i,layerType:this.type,objectKey:s,value:o,styleSpec:ne,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const i=this.paint.get(t);if(i instanceof Pr&&Jr(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}}const yh={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ys{constructor(t,i){this._structArray=t,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class _t{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,i){return t._trim(),i&&(t.isTransferred=!0,i.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const i=Object.create(this.prototype);return i.arrayBuffer=t.arrayBuffer,i.length=t.length,i.capacity=t.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Bt(r,t=1){let i=0,s=0;return{members:r.map(o=>{const d=yh[o.type].BYTES_PER_ELEMENT,p=i=Za(i,Math.max(t,d)),m=o.components||1;return s=Math.max(s,d),i+=d*m,{name:o.name,type:o.type,components:m,offset:p}}),size:Za(i,Math.max(s,t)),alignment:t}}function Za(r,t){return Math.ceil(r/t)*t}class hs extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const o=2*t;return this.int16[o+0]=i,this.int16[o+1]=s,t}}hs.prototype.bytesPerElement=4,ze("StructArrayLayout2i4",hs);class us extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=3*t;return this.int16[d+0]=i,this.int16[d+1]=s,this.int16[d+2]=o,t}}us.prototype.bytesPerElement=6,ze("StructArrayLayout3i6",us);class tl extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o){const d=this.length;return this.resize(d+1),this.emplace(d,t,i,s,o)}emplace(t,i,s,o,d){const p=4*t;return this.int16[p+0]=i,this.int16[p+1]=s,this.int16[p+2]=o,this.int16[p+3]=d,t}}tl.prototype.bytesPerElement=8,ze("StructArrayLayout4i8",tl);class ds extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,i,s,o,d,p)}emplace(t,i,s,o,d,p,m){const g=6*t;return this.int16[g+0]=i,this.int16[g+1]=s,this.int16[g+2]=o,this.int16[g+3]=d,this.int16[g+4]=p,this.int16[g+5]=m,t}}ds.prototype.bytesPerElement=12,ze("StructArrayLayout2i4i12",ds);class Ln extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,i,s,o,d,p)}emplace(t,i,s,o,d,p,m){const g=4*t,x=8*t;return this.int16[g+0]=i,this.int16[g+1]=s,this.uint8[x+4]=o,this.uint8[x+5]=d,this.uint8[x+6]=p,this.uint8[x+7]=m,t}}Ln.prototype.bytesPerElement=8,ze("StructArrayLayout2i4ub8",Ln);class Ks extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const o=2*t;return this.float32[o+0]=i,this.float32[o+1]=s,t}}Ks.prototype.bytesPerElement=8,ze("StructArrayLayout2f8",Ks);class Ga extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p,m,g,x,v){const T=this.length;return this.resize(T+1),this.emplace(T,t,i,s,o,d,p,m,g,x,v)}emplace(t,i,s,o,d,p,m,g,x,v,T){const M=10*t;return this.uint16[M+0]=i,this.uint16[M+1]=s,this.uint16[M+2]=o,this.uint16[M+3]=d,this.uint16[M+4]=p,this.uint16[M+5]=m,this.uint16[M+6]=g,this.uint16[M+7]=x,this.uint16[M+8]=v,this.uint16[M+9]=T,t}}Ga.prototype.bytesPerElement=20,ze("StructArrayLayout10ui20",Ga);class Dn extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p,m,g,x,v,T,M){const E=this.length;return this.resize(E+1),this.emplace(E,t,i,s,o,d,p,m,g,x,v,T,M)}emplace(t,i,s,o,d,p,m,g,x,v,T,M,E){const A=12*t;return this.int16[A+0]=i,this.int16[A+1]=s,this.int16[A+2]=o,this.int16[A+3]=d,this.uint16[A+4]=p,this.uint16[A+5]=m,this.uint16[A+6]=g,this.uint16[A+7]=x,this.int16[A+8]=v,this.int16[A+9]=T,this.int16[A+10]=M,this.int16[A+11]=E,t}}Dn.prototype.bytesPerElement=24,ze("StructArrayLayout4i4ui4i24",Dn);class il extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=3*t;return this.float32[d+0]=i,this.float32[d+1]=s,this.float32[d+2]=o,t}}il.prototype.bytesPerElement=12,ze("StructArrayLayout3f12",il);class rl extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint32[1*t+0]=i,t}}rl.prototype.bytesPerElement=4,ze("StructArrayLayout1ul4",rl);class qa extends _t{_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,i,s,o,d,p,m,g,x){const v=this.length;return this.resize(v+1),this.emplace(v,t,i,s,o,d,p,m,g,x)}emplace(t,i,s,o,d,p,m,g,x,v){const T=10*t,M=5*t;return this.int16[T+0]=i,this.int16[T+1]=s,this.int16[T+2]=o,this.int16[T+3]=d,this.int16[T+4]=p,this.int16[T+5]=m,this.uint32[M+3]=g,this.uint16[T+8]=x,this.uint16[T+9]=v,t}}qa.prototype.bytesPerElement=20,ze("StructArrayLayout6i1ul2ui20",qa);class nl extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,i,s,o,d,p)}emplace(t,i,s,o,d,p,m){const g=6*t;return this.int16[g+0]=i,this.int16[g+1]=s,this.int16[g+2]=o,this.int16[g+3]=d,this.int16[g+4]=p,this.int16[g+5]=m,t}}nl.prototype.bytesPerElement=12,ze("StructArrayLayout2i2i2i12",nl);class h extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d){const p=this.length;return this.resize(p+1),this.emplace(p,t,i,s,o,d)}emplace(t,i,s,o,d,p){const m=4*t,g=8*t;return this.float32[m+0]=i,this.float32[m+1]=s,this.float32[m+2]=o,this.int16[g+6]=d,this.int16[g+7]=p,t}}h.prototype.bytesPerElement=16,ze("StructArrayLayout2f1f2i16",h);class e extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,o,d,p){const m=this.length;return this.resize(m+1),this.emplace(m,t,i,s,o,d,p)}emplace(t,i,s,o,d,p,m){const g=16*t,x=4*t,v=8*t;return this.uint8[g+0]=i,this.uint8[g+1]=s,this.float32[x+1]=o,this.float32[x+2]=d,this.int16[v+6]=p,this.int16[v+7]=m,t}}e.prototype.bytesPerElement=16,ze("StructArrayLayout2ub2f2i16",e);class n extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=3*t;return this.uint16[d+0]=i,this.uint16[d+1]=s,this.uint16[d+2]=o,t}}n.prototype.bytesPerElement=6,ze("StructArrayLayout3ui6",n);class a extends _t{_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,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V){const Q=this.length;return this.resize(Q+1),this.emplace(Q,t,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V)}emplace(t,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q){const W=24*t,X=12*t,ce=48*t;return this.int16[W+0]=i,this.int16[W+1]=s,this.uint16[W+2]=o,this.uint16[W+3]=d,this.uint32[X+2]=p,this.uint32[X+3]=m,this.uint32[X+4]=g,this.uint16[W+10]=x,this.uint16[W+11]=v,this.uint16[W+12]=T,this.float32[X+7]=M,this.float32[X+8]=E,this.uint8[ce+36]=A,this.uint8[ce+37]=L,this.uint8[ce+38]=F,this.uint32[X+10]=V,this.int16[W+22]=Q,t}}a.prototype.bytesPerElement=48,ze("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",a);class l extends _t{_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,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q,W,X,ce,pe,xe,Ae,Pe,Ie,Be,Me){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,t,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q,W,X,ce,pe,xe,Ae,Pe,Ie,Be,Me)}emplace(t,i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q,W,X,ce,pe,xe,Ae,Pe,Ie,Be,Me,Ce){const ge=32*t,Ze=16*t;return this.int16[ge+0]=i,this.int16[ge+1]=s,this.int16[ge+2]=o,this.int16[ge+3]=d,this.int16[ge+4]=p,this.int16[ge+5]=m,this.int16[ge+6]=g,this.int16[ge+7]=x,this.uint16[ge+8]=v,this.uint16[ge+9]=T,this.uint16[ge+10]=M,this.uint16[ge+11]=E,this.uint16[ge+12]=A,this.uint16[ge+13]=L,this.uint16[ge+14]=F,this.uint16[ge+15]=V,this.uint16[ge+16]=Q,this.uint16[ge+17]=W,this.uint16[ge+18]=X,this.uint16[ge+19]=ce,this.uint16[ge+20]=pe,this.uint16[ge+21]=xe,this.uint16[ge+22]=Ae,this.uint32[Ze+12]=Pe,this.float32[Ze+13]=Ie,this.float32[Ze+14]=Be,this.uint16[ge+30]=Me,this.uint16[ge+31]=Ce,t}}l.prototype.bytesPerElement=64,ze("StructArrayLayout8i15ui1ul2f2ui64",l);class u extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.float32[1*t+0]=i,t}}u.prototype.bytesPerElement=4,ze("StructArrayLayout1f4",u);class f extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=3*t;return this.uint16[6*t+0]=i,this.float32[d+1]=s,this.float32[d+2]=o,t}}f.prototype.bytesPerElement=12,ze("StructArrayLayout1ui2f12",f);class _ extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,i,s)}emplace(t,i,s,o){const d=4*t;return this.uint32[2*t+0]=i,this.uint16[d+2]=s,this.uint16[d+3]=o,t}}_.prototype.bytesPerElement=8,ze("StructArrayLayout1ul2ui8",_);class y extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const o=2*t;return this.uint16[o+0]=i,this.uint16[o+1]=s,t}}y.prototype.bytesPerElement=4,ze("StructArrayLayout2ui4",y);class b extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint16[1*t+0]=i,t}}b.prototype.bytesPerElement=2,ze("StructArrayLayout1ui2",b);class w extends _t{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s,o){const d=this.length;return this.resize(d+1),this.emplace(d,t,i,s,o)}emplace(t,i,s,o,d){const p=4*t;return this.float32[p+0]=i,this.float32[p+1]=s,this.float32[p+2]=o,this.float32[p+3]=d,t}}w.prototype.bytesPerElement=16,ze("StructArrayLayout4f16",w);class S extends Ys{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new be(this.anchorPointX,this.anchorPointY)}}S.prototype.size=20;class P extends qa{get(t){return new S(this,t)}}ze("CollisionBoxArray",P);class I extends Ys{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(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]}}I.prototype.size=48;class k extends a{get(t){return new I(this,t)}}ze("PlacedSymbolArray",k);class O extends Ys{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(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]}}O.prototype.size=64;class B extends l{get(t){return new O(this,t)}}ze("SymbolInstanceArray",B);class N extends u{getoffsetX(t){return this.float32[1*t+0]}}ze("GlyphOffsetArray",N);class U extends us{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}ze("SymbolLineVertexArray",U);class q extends Ys{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}q.prototype.size=12;class $ extends f{get(t){return new q(this,t)}}ze("TextAnchorOffsetArray",$);class H extends Ys{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}H.prototype.size=8;class K extends _{get(t){return new H(this,t)}}ze("FeatureIndexArray",K);class G extends hs{}class te extends hs{}class ue extends hs{}class ae extends ds{}class oe extends Ln{}class he extends Ks{}class we extends Ga{}class Se extends Dn{}class ye extends il{}class Le extends rl{}class Ke extends nl{}class dt extends e{}class yt extends n{}class mt extends y{}const Ct=Bt([{name:"a_pos",components:2,type:"Int16"}],4),{members:zt}=Ct;class Xe{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,i,s,o){const d=this.segments[this.segments.length-1];return t>Xe.MAX_VERTEX_ARRAY_LENGTH&&jt(`Max vertices per segment is ${Xe.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Xe.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!d||d.vertexLength+t>Xe.MAX_VERTEX_ARRAY_LENGTH||d.sortKey!==o?this.createNewSegment(i,s,o):d}createNewSegment(t,i,s){const o={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(o.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(o),o}getOrCreateLatestSegment(t,i,s){return this.prepareSegment(0,t,i,s)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const t of this.segments)for(const i in t.vaos)t.vaos[i].destroy()}static simpleSegment(t,i,s,o){return new Xe([{vertexOffset:t,primitiveOffset:i,vertexLength:s,primitiveLength:o,vaos:{},sortKey:0}])}}function xt(r,t){return 256*(r=Ei(Math.floor(r),0,255))+Ei(Math.floor(t),0,255)}Xe.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ze("SegmentVector",Xe);const Zt=Bt([{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 Yt,ri,Si,ar={exports:{}},tn={exports:{}},rn={exports:{}},ps=function(){if(Si)return ar.exports;Si=1;var r=(Yt||(Yt=1,tn.exports=function(i,s){var o,d,p,m,g,x,v,T;for(d=i.length-(o=3&i.length),p=s,g=3432918353,x=461845907,T=0;T<d;)v=255&i.charCodeAt(T)|(255&i.charCodeAt(++T))<<8|(255&i.charCodeAt(++T))<<16|(255&i.charCodeAt(++T))<<24,++T,p=27492+(65535&(m=5*(65535&(p=(p^=v=(65535&(v=(v=(65535&v)*g+(((v>>>16)*g&65535)<<16)&4294967295)<<15|v>>>17))*x+(((v>>>16)*x&65535)<<16)&4294967295)<<13|p>>>19))+((5*(p>>>16)&65535)<<16)&4294967295))+((58964+(m>>>16)&65535)<<16);switch(v=0,o){case 3:v^=(255&i.charCodeAt(T+2))<<16;case 2:v^=(255&i.charCodeAt(T+1))<<8;case 1:p^=v=(65535&(v=(v=(65535&(v^=255&i.charCodeAt(T)))*g+(((v>>>16)*g&65535)<<16)&4294967295)<<15|v>>>17))*x+(((v>>>16)*x&65535)<<16)&4294967295}return p^=i.length,p=2246822507*(65535&(p^=p>>>16))+((2246822507*(p>>>16)&65535)<<16)&4294967295,p=3266489909*(65535&(p^=p>>>13))+((3266489909*(p>>>16)&65535)<<16)&4294967295,(p^=p>>>16)>>>0}),tn.exports),t=(ri||(ri=1,rn.exports=function(i,s){for(var o,d=i.length,p=s^d,m=0;d>=4;)o=1540483477*(65535&(o=255&i.charCodeAt(m)|(255&i.charCodeAt(++m))<<8|(255&i.charCodeAt(++m))<<16|(255&i.charCodeAt(++m))<<24))+((1540483477*(o>>>16)&65535)<<16),p=1540483477*(65535&p)+((1540483477*(p>>>16)&65535)<<16)^(o=1540483477*(65535&(o^=o>>>24))+((1540483477*(o>>>16)&65535)<<16)),d-=4,++m;switch(d){case 3:p^=(255&i.charCodeAt(m+2))<<16;case 2:p^=(255&i.charCodeAt(m+1))<<8;case 1:p=1540483477*(65535&(p^=255&i.charCodeAt(m)))+((1540483477*(p>>>16)&65535)<<16)}return p=1540483477*(65535&(p^=p>>>13))+((1540483477*(p>>>16)&65535)<<16),(p^=p>>>15)>>>0}),rn.exports);return ar.exports=r,ar.exports.murmur3=r,ar.exports.murmur2=t,ar.exports}(),fs=ct(ps);class Rn{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,i,s,o){this.ids.push(Fn(t)),this.positions.push(i,s,o)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const i=Fn(t);let s=0,o=this.ids.length-1;for(;s<o;){const p=s+o>>1;this.ids[p]>=i?o=p:s=p+1}const d=[];for(;this.ids[s]===i;)d.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return d}static serialize(t,i){const s=new Float64Array(t.ids),o=new Uint32Array(t.positions);return Li(s,o,0,s.length-1),i&&i.push(s.buffer,o.buffer),{ids:s,positions:o}}static deserialize(t){const i=new Rn;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}}function Fn(r){const t=+r;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:fs(String(r))}function Li(r,t,i,s){for(;i<s;){const o=r[i+s>>1];let d=i-1,p=s+1;for(;;){do d++;while(r[d]<o);do p--;while(r[p]>o);if(d>=p)break;or(r,d,p),or(t,3*d,3*p),or(t,3*d+1,3*p+1),or(t,3*d+2,3*p+2)}p-i<s-p?(Li(r,t,i,p),i=p+1):(Li(r,t,p+1,s),s=p)}}function or(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}ze("FeaturePositionMap",Rn);class Mi{constructor(t,i){this.gl=t.gl,this.location=i}}class nn extends Mi{constructor(t,i){super(t,i),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Gt extends Mi{constructor(t,i){super(t,i),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 Kt extends Mi{constructor(t,i){super(t,i),this.current=it.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))}}const Hi=new Float32Array(16);function qt(r){return[xt(255*r.r,255*r.g),xt(255*r.b,255*r.a)]}class Js{constructor(t,i,s){this.value=t,this.uniformNames=i.map(o=>`u_${o}`),this.type=s}setUniform(t,i,s){t.set(s.constantOr(this.value))}getBinding(t,i,s){return this.type==="color"?new Kt(t,i):new nn(t,i)}}class ms{constructor(t,i){this.uniformNames=i.map(s=>`u_${s}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,i){this.pixelRatioFrom=i.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=i.tlbr,this.patternTo=t.tlbr}setUniform(t,i,s,o){const d=o==="u_pattern_to"?this.patternTo:o==="u_pattern_from"?this.patternFrom:o==="u_pixel_ratio_to"?this.pixelRatioTo:o==="u_pixel_ratio_from"?this.pixelRatioFrom:null;d&&t.set(d)}getBinding(t,i,s){return s.substr(0,9)==="u_pattern"?new Gt(t,i):new nn(t,i)}}class Ar{constructor(t,i,s,o){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=i.map(d=>({name:`a_${d}`,type:"Float32",components:s==="color"?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(t,i,s){const o=this.paintVertexArray.length,d=this.expression.evaluate(new wt(0,s),i,{},s.canonical,[],s.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(o,t,d)}updatePaintArray(t,i,s,o,d){const p=this.expression.evaluate(new wt(0,d),s,o);this._setPaintValue(t,i,p)}_setPaintValue(t,i,s){if(this.type==="color"){const o=qt(s);for(let d=t;d<i;d++)this.paintVertexArray.emplace(d,o[0],o[1])}else{for(let o=t;o<i;o++)this.paintVertexArray.emplace(o,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 lr{constructor(t,i,s,o,d,p){this.expression=t,this.uniformNames=i.map(m=>`u_${m}_t`),this.type=s,this.useIntegerZoom=o,this.zoom=d,this.maxValue=0,this.paintVertexAttributes=i.map(m=>({name:`a_${m}`,type:"Float32",components:s==="color"?4:2,offset:0})),this.paintVertexArray=new p}populatePaintArray(t,i,s){const o=this.expression.evaluate(new wt(this.zoom,s),i,{},s.canonical,[],s.formattedSection),d=this.expression.evaluate(new wt(this.zoom+1,s),i,{},s.canonical,[],s.formattedSection),p=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(p,t,o,d)}updatePaintArray(t,i,s,o,d){const p=this.expression.evaluate(new wt(this.zoom,d),s,o),m=this.expression.evaluate(new wt(this.zoom+1,d),s,o);this._setPaintValue(t,i,p,m)}_setPaintValue(t,i,s,o){if(this.type==="color"){const d=qt(s),p=qt(o);for(let m=t;m<i;m++)this.paintVertexArray.emplace(m,d[0],d[1],p[0],p[1])}else{for(let d=t;d<i;d++)this.paintVertexArray.emplace(d,s,o);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(o))}}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,i){const s=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,o=Ei(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);t.set(o)}getBinding(t,i,s){return new nn(t,i)}}class sn{constructor(t,i,s,o,d,p){this.expression=t,this.type=i,this.useIntegerZoom=s,this.zoom=o,this.layerId=p,this.zoomInPaintVertexArray=new d,this.zoomOutPaintVertexArray=new d}populatePaintArray(t,i,s){const o=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(o,t,i.patterns&&i.patterns[this.layerId],s.imagePositions)}updatePaintArray(t,i,s,o,d){this._setPaintValues(t,i,s.patterns&&s.patterns[this.layerId],d.imagePositions)}_setPaintValues(t,i,s,o){if(!o||!s)return;const{min:d,mid:p,max:m}=s,g=o[d],x=o[p],v=o[m];if(g&&x&&v)for(let T=t;T<i;T++)this.zoomInPaintVertexArray.emplace(T,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(T,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,Zt.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Zt.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class xc{constructor(t,i,s){this.binders={},this._buffers=[];const o=[];for(const d in t.paint._values){if(!s(d))continue;const p=t.paint.get(d);if(!(p instanceof Pr&&Jr(p.property.specification)))continue;const m=vc(d,t.type),g=p.value,x=p.property.specification.type,v=p.property.useIntegerZoom,T=p.property.specification["property-type"],M=T==="cross-faded"||T==="cross-faded-data-driven";if(g.kind==="constant")this.binders[d]=M?new ms(g.value,m):new Js(g.value,m,x),o.push(`/u_${d}`);else if(g.kind==="source"||M){const E=sl(d,x,"source");this.binders[d]=M?new sn(g,x,v,i,E,t.id):new Ar(g,m,x,E),o.push(`/a_${d}`)}else{const E=sl(d,x,"composite");this.binders[d]=new lr(g,m,x,v,i,E),o.push(`/z_${d}`)}}this.cacheKey=o.sort().join("")}getMaxValue(t){const i=this.binders[t];return i instanceof Ar||i instanceof lr?i.maxValue:0}populatePaintArrays(t,i,s){for(const o in this.binders){const d=this.binders[o];(d instanceof Ar||d instanceof lr||d instanceof sn)&&d.populatePaintArray(t,i,s)}}setConstantPatternPositions(t,i){for(const s in this.binders){const o=this.binders[s];o instanceof ms&&o.setConstantPatternPositions(t,i)}}updatePaintArrays(t,i,s,o,d){let p=!1;for(const m in t){const g=i.getPositions(m);for(const x of g){const v=s.feature(x.index);for(const T in this.binders){const M=this.binders[T];if((M instanceof Ar||M instanceof lr||M instanceof sn)&&M.expression.isStateDependent===!0){const E=o.paint.get(T);M.expression=E.value,M.updatePaintArray(x.start,x.end,v,t[m],d),p=!0}}}}return p}defines(){const t=[];for(const i in this.binders){const s=this.binders[i];(s instanceof Js||s instanceof ms)&&t.push(...s.uniformNames.map(o=>`#define HAS_UNIFORM_${o}`))}return t}getBinderAttributes(){const t=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof Ar||s instanceof lr)for(let o=0;o<s.paintVertexAttributes.length;o++)t.push(s.paintVertexAttributes[o].name);else if(s instanceof sn)for(let o=0;o<Zt.members.length;o++)t.push(Zt.members[o].name)}return t}getBinderUniforms(){const t=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof Js||s instanceof ms||s instanceof lr)for(const o of s.uniformNames)t.push(o)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,i){const s=[];for(const o in this.binders){const d=this.binders[o];if(d instanceof Js||d instanceof ms||d instanceof lr){for(const p of d.uniformNames)if(i[p]){const m=d.getBinding(t,i[p],p);s.push({name:p,property:o,binding:m})}}}return s}setUniforms(t,i,s,o){for(const{name:d,property:p,binding:m}of i)this.binders[p].setUniform(m,o,s.get(p),d)}updatePaintBuffers(t){this._buffers=[];for(const i in this.binders){const s=this.binders[i];if(t&&s instanceof sn){const o=t.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;o&&this._buffers.push(o)}else(s instanceof Ar||s instanceof lr)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(t){for(const i in this.binders){const s=this.binders[i];(s instanceof Ar||s instanceof lr||s instanceof sn)&&s.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const i=this.binders[t];(i instanceof Ar||i instanceof lr||i instanceof sn)&&i.destroy()}}}class ji{constructor(t,i,s=()=>!0){this.programConfigurations={};for(const o of t)this.programConfigurations[o.id]=new xc(o,i,s);this.needsUpload=!1,this._featureMap=new Rn,this._bufferOffset=0}populatePaintArrays(t,i,s,o){for(const d in this.programConfigurations)this.programConfigurations[d].populatePaintArrays(t,i,o);i.id!==void 0&&this._featureMap.add(i.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,i,s,o){for(const d of s)this.needsUpload=this.programConfigurations[d.id].updatePaintArrays(t,this._featureMap,i,d,o)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function vc(r,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"]}[r]||[r.replace(`${t}-`,"").replace(/-/g,"_")]}function sl(r,t,i){const s={color:{source:Ks,composite:w},number:{source:u,composite:Ks}},o=function(d){return{"line-pattern":{source:we,composite:we},"fill-pattern":{source:we,composite:we},"fill-extrusion-pattern":{source:we,composite:we}}[d]}(r);return o&&o[i]||s[t][i]}ze("ConstantBinder",Js),ze("CrossFadedConstantBinder",ms),ze("SourceExpressionBinder",Ar),ze("CrossFadedCompositeBinder",sn),ze("CompositeExpressionBinder",lr),ze("ProgramConfiguration",xc,{omit:["_buffers"]}),ze("ProgramConfigurationSet",ji);const Wa=Math.pow(2,14)-1,Ha=-Wa-1;function an(r){const t=gt/r.extent,i=r.loadGeometry();for(let s=0;s<i.length;s++){const o=i[s];for(let d=0;d<o.length;d++){const p=o[d],m=Math.round(p.x*t),g=Math.round(p.y*t);p.x=Ei(m,Ha,Wa),p.y=Ei(g,Ha,Wa),(m<p.x||m>p.x+1||g<p.y||g>p.y+1)&&jt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function kr(r,t){return{type:r.type,id:r.id,properties:r.properties,geometry:t?an(r):[]}}const fu=-32768;function Pp(r,t,i,s,o){r.emplaceBack(fu+8*t+s,fu+8*i+o)}class xh{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new te,this.indexArray=new yt,this.segments=new Xe,this.programConfigurations=new ji(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){const o=this.layers[0],d=[];let p=null,m=!1,g=o.type==="heatmap";if(o.type==="circle"){const v=o;p=v.layout.get("circle-sort-key"),m=!p.isConstant(),g=g||v.paint.get("circle-pitch-alignment")==="map"}const x=g?i.subdivisionGranularity.circle:1;for(const{feature:v,id:T,index:M,sourceLayerIndex:E}of t){const A=this.layers[0]._featureFilter.needGeometry,L=kr(v,A);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom,{globalState:this.globalState}),L,s))continue;const F=m?p.evaluate(L,{},s):void 0,V={id:T,properties:v.properties,type:v.type,sourceLayerIndex:E,index:M,geometry:A?L.geometry:an(v),patterns:{},sortKey:F};d.push(V)}m&&d.sort((v,T)=>v.sortKey-T.sortKey);for(const v of d){const{geometry:T,index:M,sourceLayerIndex:E}=v,A=t[M].feature;this.addFeature(v,T,M,s,x),i.featureIndex.insert(A,T,M,E,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,zt),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,i,s,o,d=1){let p;switch(d){case 1:p=[0,7];break;case 3:p=[0,2,5,7];break;case 5:p=[0,1,3,4,6,7];break;case 7:p=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${d}; valid values are 1, 3, 5, 7.`)}const m=p.length;for(const g of i)for(const x of g){const v=x.x,T=x.y;if(v<0||v>=gt||T<0||T>=gt)continue;const M=this.segments.prepareSegment(m*m,this.layoutVertexArray,this.indexArray,t.sortKey),E=M.vertexLength;for(let A=0;A<m;A++)for(let L=0;L<m;L++)Pp(this.layoutVertexArray,v,T,p[L],p[A]);for(let A=0;A<m-1;A++)for(let L=0;L<m-1;L++){const F=E+A*m+L,V=E+(A+1)*m+L;this.indexArray.emplaceBack(F,V+1,F+1),this.indexArray.emplaceBack(F,V,V+1)}M.vertexLength+=m*m,M.primitiveLength+=(m-1)*(m-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:{},canonical:o,globalState:this.globalState})}}function mu(r,t){for(let i=0;i<r.length;i++)if(Xa(t,r[i]))return!0;for(let i=0;i<t.length;i++)if(Xa(r,t[i]))return!0;return!!vh(r,t)}function Sp(r,t,i){return!!Xa(r,t)||!!bh(t,r,i)}function gu(r,t){if(r.length===1)return yu(t,r[0]);for(let i=0;i<t.length;i++){const s=t[i];for(let o=0;o<s.length;o++)if(Xa(r,s[o]))return!0}for(let i=0;i<r.length;i++)if(yu(t,r[i]))return!0;for(let i=0;i<t.length;i++)if(vh(r,t[i]))return!0;return!1}function Mp(r,t,i){if(r.length>1){if(vh(r,t))return!0;for(let s=0;s<t.length;s++)if(bh(t[s],r,i))return!0}for(let s=0;s<r.length;s++)if(bh(r[s],t,i))return!0;return!1}function vh(r,t){if(r.length===0||t.length===0)return!1;for(let i=0;i<r.length-1;i++){const s=r[i],o=r[i+1];for(let d=0;d<t.length-1;d++)if(Ip(s,o,t[d],t[d+1]))return!0}return!1}function Ip(r,t,i,s){return Ki(r,i,s)!==Ki(t,i,s)&&Ki(r,t,i)!==Ki(r,t,s)}function bh(r,t,i){const s=i*i;if(t.length===1)return r.distSqr(t[0])<s;for(let o=1;o<t.length;o++)if(_u(r,t[o-1],t[o])<s)return!0;return!1}function _u(r,t,i){const s=t.distSqr(i);if(s===0)return r.distSqr(t);const o=((r.x-t.x)*(i.x-t.x)+(r.y-t.y)*(i.y-t.y))/s;return r.distSqr(o<0?t:o>1?i:i.sub(t)._mult(o)._add(t))}function yu(r,t){let i,s,o,d=!1;for(let p=0;p<r.length;p++){i=r[p];for(let m=0,g=i.length-1;m<i.length;g=m++)s=i[m],o=i[g],s.y>t.y!=o.y>t.y&&t.x<(o.x-s.x)*(t.y-s.y)/(o.y-s.y)+s.x&&(d=!d)}return d}function Xa(r,t){let i=!1;for(let s=0,o=r.length-1;s<r.length;o=s++){const d=r[s],p=r[o];d.y>t.y!=p.y>t.y&&t.x<(p.x-d.x)*(t.y-d.y)/(p.y-d.y)+d.x&&(i=!i)}return i}function Cp(r,t,i){const s=i[0],o=i[2];if(r.x<s.x&&t.x<s.x||r.x>o.x&&t.x>o.x||r.y<s.y&&t.y<s.y||r.y>o.y&&t.y>o.y)return!1;const d=Ki(r,t,i[0]);return d!==Ki(r,t,i[1])||d!==Ki(r,t,i[2])||d!==Ki(r,t,i[3])}function al(r,t,i){const s=t.paint.get(r).value;return s.kind==="constant"?s.value:i.programConfigurations.get(t.id).getMaxValue(r)}function bc(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function wc(r,t,i,s,o){if(!t[0]&&!t[1])return r;const d=be.convert(t)._mult(o);i==="viewport"&&d._rotate(-s);const p=[];for(let m=0;m<r.length;m++)p.push(r[m].sub(d));return p}let xu,vu;ze("CircleBucket",xh,{omit:["layers"]});var Ep={get paint(){return vu=vu||new Pi({"circle-radius":new Ve(ne.paint_circle["circle-radius"]),"circle-color":new Ve(ne.paint_circle["circle-color"]),"circle-blur":new Ve(ne.paint_circle["circle-blur"]),"circle-opacity":new Ve(ne.paint_circle["circle-opacity"]),"circle-translate":new Fe(ne.paint_circle["circle-translate"]),"circle-translate-anchor":new Fe(ne.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Fe(ne.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Fe(ne.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ve(ne.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ve(ne.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ve(ne.paint_circle["circle-stroke-opacity"])})},get layout(){return xu=xu||new Pi({"circle-sort-key":new Ve(ne.layout_circle["circle-sort-key"])})}};class Ap extends Wi{constructor(t){super(t,Ep)}createBucket(t){return new xh(t)}queryRadius(t){const i=t;return al("circle-radius",this,i)+al("circle-stroke-width",this,i)+bc(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:o,transform:d,pixelsToTileUnits:p,unwrappedTileID:m,getElevation:g}){const x=wc(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-d.bearingInRadians,p),v=this.paint.get("circle-radius").evaluate(i,s)+this.paint.get("circle-stroke-width").evaluate(i,s),T=this.paint.get("circle-pitch-alignment")==="map",M=T?x:function(A,L,F,V){return A.map(Q=>bu(Q,L,F,V))}(x,d,m,g),E=T?v*p:v;for(const A of o)for(const L of A){const F=T?L:bu(L,d,m,g);let V=E;const Q=d.projectTileCoordinates(L.x,L.y,m,g).signedDistanceFromCamera;if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?V*=Q/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(V*=d.cameraToCenterDistance/Q),Sp(M,F,V))return!0}return!1}}function bu(r,t,i,s){const o=t.projectTileCoordinates(r.x,r.y,i,s).point;return new be((.5*o.x+.5)*t.width,(.5*-o.y+.5)*t.height)}class wu extends xh{}let Tu;ze("HeatmapBucket",wu,{omit:["layers"]});var kp={get paint(){return Tu=Tu||new Pi({"heatmap-radius":new Ve(ne.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ve(ne.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Fe(ne.paint_heatmap["heatmap-intensity"]),"heatmap-color":new $a(ne.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Fe(ne.paint_heatmap["heatmap-opacity"])})}};function wh(r,{width:t,height:i},s,o){if(o){if(o instanceof Uint8ClampedArray)o=new Uint8Array(o.buffer);else if(o.length!==t*i*s)throw new RangeError(`mismatched image size. expected: ${o.length} but got: ${t*i*s}`)}else o=new Uint8Array(t*i*s);return r.width=t,r.height=i,r.data=o,r}function Pu(r,{width:t,height:i},s){if(t===r.width&&i===r.height)return;const o=wh({},{width:t,height:i},s);Th(r,o,{x:0,y:0},{x:0,y:0},{width:Math.min(r.width,t),height:Math.min(r.height,i)},s),r.width=t,r.height=i,r.data=o.data}function Th(r,t,i,s,o,d){if(o.width===0||o.height===0)return t;if(o.width>r.width||o.height>r.height||i.x>r.width-o.width||i.y>r.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>t.width||o.height>t.height||s.x>t.width-o.width||s.y>t.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const p=r.data,m=t.data;if(p===m)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g<o.height;g++){const x=((i.y+g)*r.width+i.x)*d,v=((s.y+g)*t.width+s.x)*d;for(let T=0;T<o.width*d;T++)m[v+T]=p[x+T]}return t}class ol{constructor(t,i){wh(this,t,1,i)}resize(t){Pu(this,t,1)}clone(){return new ol({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,s,o,d){Th(t,i,s,o,d,1)}}class Ni{constructor(t,i){wh(this,t,4,i)}resize(t){Pu(this,t,4)}replace(t,i){i?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Ni({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,s,o,d){Th(t,i,s,o,d,4)}setPixel(t,i,s){const o=4*(t*this.width+i);this.data[o+0]=Math.round(255*s.r/s.a),this.data[o+1]=Math.round(255*s.g/s.a),this.data[o+2]=Math.round(255*s.b/s.a),this.data[o+3]=Math.round(255*s.a)}}function Su(r){const t={},i=r.resolution||256,s=r.clips?r.clips.length:1,o=r.image||new Ni({width:i,height:s});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const d=(p,m,g)=>{t[r.evaluationKey]=g;const x=r.expression.evaluate(t);o.setPixel(p/4/i,m/4,x)};if(r.clips)for(let p=0,m=0;p<s;++p,m+=4*i)for(let g=0,x=0;g<i;g++,x+=4){const v=g/(i-1),{start:T,end:M}=r.clips[p];d(m,x,T*(1-v)+M*v)}else for(let p=0,m=0;p<i;p++,m+=4)d(0,m,p/(i-1));return o}ze("AlphaImage",ol),ze("RGBAImage",Ni);const Ph="big-fb";class zp extends Wi{createBucket(t){return new wu(t)}constructor(t){super(t,kp),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Su({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Ph)&&this.heatmapFbos.delete(Ph)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let Mu;var Lp={get paint(){return Mu=Mu||new Pi({"hillshade-illumination-direction":new Fe(ne.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Fe(ne.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Fe(ne.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Fe(ne.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Fe(ne.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Fe(ne.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Fe(ne.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Fe(ne.paint_hillshade["hillshade-method"])})}};class Dp extends Wi{constructor(t){super(t,Lp),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,i=this.paint.get("hillshade-illumination-altitude").values,s=this.paint.get("hillshade-highlight-color").values,o=this.paint.get("hillshade-shadow-color").values;const d=Math.max(t.length,i.length,s.length,o.length);t=t.concat(Array(d-t.length).fill(t.at(-1))),i=i.concat(Array(d-i.length).fill(i.at(-1))),s=s.concat(Array(d-s.length).fill(s.at(-1))),o=o.concat(Array(d-o.length).fill(o.at(-1)));const p=i.map(gn);return{directionRadians:t.map(gn),altitudeRadians:p,shadowColor:o,highlightColor:s}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}let Iu;var Rp={get paint(){return Iu=Iu||new Pi({"color-relief-opacity":new Fe(ne["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new $a(ne["paint_color-relief"]["color-relief-color"])})}};class Sh{constructor(t,i,s,o){this.context=t,this.format=s,this.texture=t.gl.createTexture(),this.update(i,o)}update(t,i,s){const{width:o,height:d}=t,p=!(this.size&&this.size[0]===o&&this.size[1]===d||s),{context:m}=this,{gl:g}=m;if(this.useMipmap=!!(i&&i.useMipmap),g.bindTexture(g.TEXTURE_2D,this.texture),m.pixelStoreUnpackFlipY.set(!1),m.pixelStoreUnpack.set(1),m.pixelStoreUnpackPremultiplyAlpha.set(this.format===g.RGBA&&(!i||i.premultiply!==!1)),p)this.size=[o,d],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||_r(t)?g.texImage2D(g.TEXTURE_2D,0,this.format,this.format,g.UNSIGNED_BYTE,t):g.texImage2D(g.TEXTURE_2D,0,this.format,o,d,0,this.format,g.UNSIGNED_BYTE,t.data);else{const{x,y:v}=s||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||_r(t)?g.texSubImage2D(g.TEXTURE_2D,0,x,v,g.RGBA,g.UNSIGNED_BYTE,t):g.texSubImage2D(g.TEXTURE_2D,0,x,v,o,d,g.RGBA,g.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&g.generateMipmap(g.TEXTURE_2D),m.pixelStoreUnpackFlipY.setDefault(),m.pixelStoreUnpack.setDefault(),m.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(t,i,s){const{context:o}=this,{gl:d}=o;d.bindTexture(d.TEXTURE_2D,this.texture),s!==d.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=d.LINEAR),t!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,s||t),this.filter=t),i!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,i),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,i),this.wrap=i)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Cu{constructor(t,i,s,o=1,d=1,p=1,m=0){if(this.uid=t,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void jt(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;const g=this.dim=i.height-2;switch(this.data=new Uint32Array(i.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=o,this.greenFactor=d,this.blueFactor=p,this.baseShift=m;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++){const T=this.get(x,v);T>this.max&&(this.max=T),T<this.min&&(this.min=T)}}get(t,i){const s=new Uint8Array(this.data.buffer),o=4*this._idx(t,i);return this.unpack(s[o],s[o+1],s[o+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,i){if(t<-1||t>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(t+1)}unpack(t,i,s){return t*this.redFactor+i*this.greenFactor+s*this.blueFactor-this.baseShift}pack(t){return Eu(t,this.getUnpackVector())}getPixels(){return new Ni({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,i,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let o=i*this.dim,d=i*this.dim+this.dim,p=s*this.dim,m=s*this.dim+this.dim;switch(i){case-1:o=d-1;break;case 1:d=o+1}switch(s){case-1:p=m-1;break;case 1:m=p+1}const g=-i*this.dim,x=-s*this.dim;for(let v=p;v<m;v++)for(let T=o;T<d;T++)this.data[this._idx(T,v)]=t.data[this._idx(T+g,v+x)]}}function Eu(r,t){const i=t[0],s=t[1],o=t[2],d=t[3],p=Math.min(i,s,o),m=Math.round((r+d)/p);return{r:Math.floor(m*p/i)%256,g:Math.floor(m*p/s)%256,b:Math.floor(m*p/o)%256}}ze("DEMData",Cu);class Fp extends Wi{constructor(t){super(t,Rp)}_createColorRamp(t){const i={elevationStops:[],colorStops:[]},s=this._transitionablePaint._values["color-relief-color"].value.expression;if(s instanceof Us&&s._styleExpression.expression instanceof ui){this.colorRampExpression=s;const p=s._styleExpression.expression;i.elevationStops=p.labels,i.colorStops=[];for(const m of i.elevationStops)i.colorStops.push(p.evaluate({globals:{elevation:m}}))}if(i.elevationStops.length<1&&(i.elevationStops=[0],i.colorStops=[it.transparent]),i.elevationStops.length<2&&(i.elevationStops.push(i.elevationStops[0]+1),i.colorStops.push(i.colorStops[0])),i.elevationStops.length<=t)return i;const o={elevationStops:[],colorStops:[]},d=(i.elevationStops.length-1)/(t-1);for(let p=0;p<i.elevationStops.length-.5;p+=d)o.elevationStops.push(i.elevationStops[Math.round(p)]),o.colorStops.push(i.colorStops[Math.round(p)]);return jt(`Too many colors in specification of ${this.id} color-relief layer, may not render properly.`),o}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,i,s){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const o=this._createColorRamp(i),d=new Ni({width:o.colorStops.length,height:1}),p=new Ni({width:o.colorStops.length,height:1});for(let m=0;m<o.elevationStops.length;m++){const g=Eu(o.elevationStops[m],s);p.setPixel(0,m,new it(g.r/255,g.g/255,g.b/255,1)),d.setPixel(0,m,o.colorStops[m])}return this.colorRampTextures={elevationTexture:new Sh(t,p,t.gl.RGBA),colorTexture:new Sh(t,d,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return this.visibility!=="none"&&!!this.colorRampTextures}}const Bp=Bt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Op}=Bp;function Mh(r,t,i){const s=i.patternDependencies;let o=!1;for(const d of t){const p=d.paint.get(`${r}-pattern`);p.isConstant()||(o=!0);const m=p.constantOr(null);m&&(o=!0,s[m.to]=!0,s[m.from]=!0)}return o}function Ih(r,t,i,s,o){const{zoom:d,globalState:p}=s,m=o.patternDependencies;for(const g of t){const x=g.paint.get(`${r}-pattern`).value;if(x.kind!=="constant"){let v=x.evaluate({zoom:d-1,globalState:p},i,{},o.availableImages),T=x.evaluate({zoom:d,globalState:p},i,{},o.availableImages),M=x.evaluate({zoom:d+1,globalState:p},i,{},o.availableImages);v=v&&v.name?v.name:v,T=T&&T.name?T.name:T,M=M&&M.name?M.name:M,m[v]=!0,m[T]=!0,m[M]=!0,i.patterns[g.id]={min:v,mid:T,max:M}}}return i}function Au(r,t,i,s,o){let d;if(o===function(p,m,g,x){let v=0;for(let T=m,M=g-x;T<g;T+=x)v+=(p[M]-p[T])*(p[T+1]+p[M+1]),M=T;return v}(r,t,i,s)>0)for(let p=t;p<i;p+=s)d=Du(p/s|0,r[p],r[p+1],d);else for(let p=i-s;p>=t;p-=s)d=Du(p/s|0,r[p],r[p+1],d);return d&&Ya(d,d.next)&&(ul(d),d=d.next),d}function Qs(r,t){if(!r)return r;t||(t=r);let i,s=r;do if(i=!1,s.steiner||!Ya(s,s.next)&&Vt(s.prev,s,s.next)!==0)s=s.next;else{if(ul(s),s=t=s.prev,s===s.next)break;i=!0}while(i||s!==t);return t}function ll(r,t,i,s,o,d,p){if(!r)return;!p&&d&&function(g,x,v,T){let M=g;do M.z===0&&(M.z=Ch(M.x,M.y,x,v,T)),M.prevZ=M.prev,M.nextZ=M.next,M=M.next;while(M!==g);M.prevZ.nextZ=null,M.prevZ=null,function(E){let A,L=1;do{let F,V=E;E=null;let Q=null;for(A=0;V;){A++;let W=V,X=0;for(let pe=0;pe<L&&(X++,W=W.nextZ,W);pe++);let ce=L;for(;X>0||ce>0&&W;)X!==0&&(ce===0||!W||V.z<=W.z)?(F=V,V=V.nextZ,X--):(F=W,W=W.nextZ,ce--),Q?Q.nextZ=F:E=F,F.prevZ=Q,Q=F;V=W}Q.nextZ=null,L*=2}while(A>1)}(M)}(r,s,o,d);let m=r;for(;r.prev!==r.next;){const g=r.prev,x=r.next;if(d?Np(r,s,o,d):jp(r))t.push(g.i,r.i,x.i),ul(r),r=x.next,m=x.next;else if((r=x)===m){p?p===1?ll(r=Vp(Qs(r),t),t,i,s,o,d,2):p===2&&Up(r,t,i,s,o,d):ll(Qs(r),t,i,s,o,d,1);break}}}function jp(r){const t=r.prev,i=r,s=r.next;if(Vt(t,i,s)>=0)return!1;const o=t.x,d=i.x,p=s.x,m=t.y,g=i.y,x=s.y,v=Math.min(o,d,p),T=Math.min(m,g,x),M=Math.max(o,d,p),E=Math.max(m,g,x);let A=s.next;for(;A!==t;){if(A.x>=v&&A.x<=M&&A.y>=T&&A.y<=E&&cl(o,m,d,g,p,x,A.x,A.y)&&Vt(A.prev,A,A.next)>=0)return!1;A=A.next}return!0}function Np(r,t,i,s){const o=r.prev,d=r,p=r.next;if(Vt(o,d,p)>=0)return!1;const m=o.x,g=d.x,x=p.x,v=o.y,T=d.y,M=p.y,E=Math.min(m,g,x),A=Math.min(v,T,M),L=Math.max(m,g,x),F=Math.max(v,T,M),V=Ch(E,A,t,i,s),Q=Ch(L,F,t,i,s);let W=r.prevZ,X=r.nextZ;for(;W&&W.z>=V&&X&&X.z<=Q;){if(W.x>=E&&W.x<=L&&W.y>=A&&W.y<=F&&W!==o&&W!==p&&cl(m,v,g,T,x,M,W.x,W.y)&&Vt(W.prev,W,W.next)>=0||(W=W.prevZ,X.x>=E&&X.x<=L&&X.y>=A&&X.y<=F&&X!==o&&X!==p&&cl(m,v,g,T,x,M,X.x,X.y)&&Vt(X.prev,X,X.next)>=0))return!1;X=X.nextZ}for(;W&&W.z>=V;){if(W.x>=E&&W.x<=L&&W.y>=A&&W.y<=F&&W!==o&&W!==p&&cl(m,v,g,T,x,M,W.x,W.y)&&Vt(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;X&&X.z<=Q;){if(X.x>=E&&X.x<=L&&X.y>=A&&X.y<=F&&X!==o&&X!==p&&cl(m,v,g,T,x,M,X.x,X.y)&&Vt(X.prev,X,X.next)>=0)return!1;X=X.nextZ}return!0}function Vp(r,t){let i=r;do{const s=i.prev,o=i.next.next;!Ya(s,o)&&zu(s,i,i.next,o)&&hl(s,o)&&hl(o,s)&&(t.push(s.i,i.i,o.i),ul(i),ul(i.next),i=r=o),i=i.next}while(i!==r);return Qs(i)}function Up(r,t,i,s,o,d){let p=r;do{let m=p.next.next;for(;m!==p.prev;){if(p.i!==m.i&&Wp(p,m)){let g=Lu(p,m);return p=Qs(p,p.next),g=Qs(g,g.next),ll(p,t,i,s,o,d,0),void ll(g,t,i,s,o,d,0)}m=m.next}p=p.next}while(p!==r)}function $p(r,t){let i=r.x-t.x;return i===0&&(i=r.y-t.y,i===0)&&(i=(r.next.y-r.y)/(r.next.x-r.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Zp(r,t){const i=function(o,d){let p=d;const m=o.x,g=o.y;let x,v=-1/0;if(Ya(o,p))return p;do{if(Ya(o,p.next))return p.next;if(g<=p.y&&g>=p.next.y&&p.next.y!==p.y){const L=p.x+(g-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(L<=m&&L>v&&(v=L,x=p.x<p.next.x?p:p.next,L===m))return x}p=p.next}while(p!==d);if(!x)return null;const T=x,M=x.x,E=x.y;let A=1/0;p=x;do{if(m>=p.x&&p.x>=M&&m!==p.x&&ku(g<E?m:v,g,M,E,g<E?v:m,g,p.x,p.y)){const L=Math.abs(g-p.y)/(m-p.x);hl(p,o)&&(L<A||L===A&&(p.x>x.x||p.x===x.x&&Gp(x,p)))&&(x=p,A=L)}p=p.next}while(p!==T);return x}(r,t);if(!i)return t;const s=Lu(i,r);return Qs(s,s.next),Qs(i,i.next)}function Gp(r,t){return Vt(r.prev,r,t.prev)<0&&Vt(t.next,r,r.next)<0}function Ch(r,t,i,s,o){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-i)*o|0)|r<<8))|r<<4))|r<<2))|r<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function qp(r){let t=r,i=r;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==r);return i}function ku(r,t,i,s,o,d,p,m){return(o-p)*(t-m)>=(r-p)*(d-m)&&(r-p)*(s-m)>=(i-p)*(t-m)&&(i-p)*(d-m)>=(o-p)*(s-m)}function cl(r,t,i,s,o,d,p,m){return!(r===p&&t===m)&&ku(r,t,i,s,o,d,p,m)}function Wp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!function(i,s){let o=i;do{if(o.i!==i.i&&o.next.i!==i.i&&o.i!==s.i&&o.next.i!==s.i&&zu(o,o.next,i,s))return!0;o=o.next}while(o!==i);return!1}(r,t)&&(hl(r,t)&&hl(t,r)&&function(i,s){let o=i,d=!1;const p=(i.x+s.x)/2,m=(i.y+s.y)/2;do o.y>m!=o.next.y>m&&o.next.y!==o.y&&p<(o.next.x-o.x)*(m-o.y)/(o.next.y-o.y)+o.x&&(d=!d),o=o.next;while(o!==i);return d}(r,t)&&(Vt(r.prev,r,t.prev)||Vt(r,t.prev,t))||Ya(r,t)&&Vt(r.prev,r,r.next)>0&&Vt(t.prev,t,t.next)>0)}function Vt(r,t,i){return(t.y-r.y)*(i.x-t.x)-(t.x-r.x)*(i.y-t.y)}function Ya(r,t){return r.x===t.x&&r.y===t.y}function zu(r,t,i,s){const o=Pc(Vt(r,t,i)),d=Pc(Vt(r,t,s)),p=Pc(Vt(i,s,r)),m=Pc(Vt(i,s,t));return o!==d&&p!==m||!(o!==0||!Tc(r,i,t))||!(d!==0||!Tc(r,s,t))||!(p!==0||!Tc(i,r,s))||!(m!==0||!Tc(i,t,s))}function Tc(r,t,i){return t.x<=Math.max(r.x,i.x)&&t.x>=Math.min(r.x,i.x)&&t.y<=Math.max(r.y,i.y)&&t.y>=Math.min(r.y,i.y)}function Pc(r){return r>0?1:r<0?-1:0}function hl(r,t){return Vt(r.prev,r,r.next)<0?Vt(r,t,r.next)>=0&&Vt(r,r.prev,t)>=0:Vt(r,t,r.prev)<0||Vt(r,r.next,t)<0}function Lu(r,t){const i=Eh(r.i,r.x,r.y),s=Eh(t.i,t.x,t.y),o=r.next,d=t.prev;return r.next=t,t.prev=r,i.next=o,o.prev=i,s.next=i,i.prev=s,d.next=s,s.prev=d,s}function Du(r,t,i,s){const o=Eh(r,t,i);return s?(o.next=s.next,o.prev=s,s.next.prev=o,s.next=o):(o.prev=o,o.next=o),o}function ul(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Eh(r,t,i){return{i:r,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Ka{constructor(t,i){if(i>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=i}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class Sc{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}Sc.noSubdivision=new Sc({fill:new Ka(0,0),line:new Ka(0,0),tile:new Ka(0,0),stencil:new Ka(0,0),circle:1}),ze("SubdivisionGranularityExpression",Ka),ze("SubdivisionGranularitySetting",Sc);const Ja=-32768,dl=32767;class Hp{constructor(t,i){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=gt/t,this._canonical=i}_getKey(t,i){return(t+=32768)<<16|i+32768}_vertexToIndex(t,i){if(t<-32768||i<-32768||t>32767||i>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const s=0|Math.round(t),o=0|Math.round(i),d=this._getKey(s,o);if(this._vertexDictionary.has(d))return this._vertexDictionary.get(d);const p=this._vertexBuffer.length/2;return this._vertexDictionary.set(d,p),this._vertexBuffer.push(s,o),p}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(o,d){const p=[];for(let m=0;m<d.length;m+=3){const g=d[m],x=d[m+1],v=d[m+2],T=o[2*g],M=o[2*g+1];(o[2*x]-T)*(o[2*v+1]-M)-(o[2*x+1]-M)*(o[2*v]-T)>0?(p.push(g),p.push(v),p.push(x)):(p.push(g),p.push(x),p.push(v))}return p}(this._vertexBuffer,t);const i=[],s=t.length;for(let o=0;o<s;o+=3){const d=[t[o+0],t[o+1],t[o+2]],p=[this._vertexBuffer[2*t[o+0]+0],this._vertexBuffer[2*t[o+0]+1],this._vertexBuffer[2*t[o+1]+0],this._vertexBuffer[2*t[o+1]+1],this._vertexBuffer[2*t[o+2]+0],this._vertexBuffer[2*t[o+2]+1]];let m=1/0,g=1/0,x=-1/0,v=-1/0;for(let L=0;L<3;L++){const F=p[2*L],V=p[2*L+1];m=Math.min(m,F),x=Math.max(x,F),g=Math.min(g,V),v=Math.max(v,V)}if(m===x||g===v)continue;const T=Math.floor(m/this._granularityCellSize),M=Math.ceil(x/this._granularityCellSize),E=Math.floor(g/this._granularityCellSize),A=Math.ceil(v/this._granularityCellSize);if(T!==M||E!==A)for(let L=E;L<A;L++){const F=this._scanlineGenerateVertexRingForCellRow(L,p,d);Xp(this._vertexBuffer,F,i)}else i.push(...d)}return i}_scanlineGenerateVertexRingForCellRow(t,i,s){const o=t*this._granularityCellSize,d=o+this._granularityCellSize,p=[];for(let m=0;m<3;m++){const g=i[2*m],x=i[2*m+1],v=i[2*(m+1)%6],T=i[(2*(m+1)+1)%6],M=i[2*(m+2)%6],E=i[(2*(m+2)+1)%6],A=v-g,L=T-x,F=A===0,V=L===0,Q=(o-x)/L,W=(d-x)/L,X=Math.min(Q,W),ce=Math.max(Q,W);if(!V&&(X>=1||ce<=0)||V&&(x<o||x>d)){T>=o&&T<=d&&p.push(s[(m+1)%3]);continue}!V&&X>0&&p.push(this._vertexToIndex(g+A*X,x+L*X));const pe=g+A*Math.max(X,0),xe=g+A*Math.min(ce,1);F||this._generateIntraEdgeVertices(p,g,x,v,T,pe,xe),!V&&ce<1&&p.push(this._vertexToIndex(g+A*ce,x+L*ce)),(V||T>=o&&T<=d)&&p.push(s[(m+1)%3]),!V&&(T<=o||T>=d)&&this._generateInterEdgeVertices(p,g,x,v,T,M,E,xe,o,d)}return p}_generateIntraEdgeVertices(t,i,s,o,d,p,m){const g=o-i,x=d-s,v=x===0,T=v?Math.min(i,o):Math.min(p,m),M=v?Math.max(i,o):Math.max(p,m),E=Math.floor(T/this._granularityCellSize)+1,A=Math.ceil(M/this._granularityCellSize)-1;if(v?i<o:p<m)for(let L=E;L<=A;L++){const F=L*this._granularityCellSize;t.push(this._vertexToIndex(F,s+x*(F-i)/g))}else for(let L=A;L>=E;L--){const F=L*this._granularityCellSize;t.push(this._vertexToIndex(F,s+x*(F-i)/g))}}_generateInterEdgeVertices(t,i,s,o,d,p,m,g,x,v){const T=d-s,M=p-o,E=m-d,A=(x-d)/E,L=(v-d)/E,F=Math.min(A,L),V=Math.max(A,L),Q=o+M*F;let W=Math.floor(Math.min(Q,g)/this._granularityCellSize)+1,X=Math.ceil(Math.max(Q,g)/this._granularityCellSize)-1,ce=g<Q;const pe=E===0;if(pe&&(m===x||m===v))return;if(pe||F>=1||V<=0){const Ae=s-m,Pe=p+(i-p)*Math.min((x-m)/Ae,(v-m)/Ae);W=Math.floor(Math.min(Pe,g)/this._granularityCellSize)+1,X=Math.ceil(Math.max(Pe,g)/this._granularityCellSize)-1,ce=g<Pe}const xe=T>0?v:x;if(ce)for(let Ae=W;Ae<=X;Ae++)t.push(this._vertexToIndex(Ae*this._granularityCellSize,xe));else for(let Ae=X;Ae>=W;Ae--)t.push(this._vertexToIndex(Ae*this._granularityCellSize,xe))}_generateOutline(t){const i=[];for(const s of t){const o=ea(s,this._granularity,!0),d=this._pointArrayToIndices(o),p=[];for(let m=1;m<d.length;m++)p.push(d[m-1]),p.push(d[m]);i.push(p)}return i}_handlePoles(t){let i=!1,s=!1;this._canonical&&(this._canonical.y===0&&(i=!0),this._canonical.y===(1<<this._canonical.z)-1&&(s=!0)),(i||s)&&this._fillPoles(t,i,s)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let i=0;i<t.length;i+=2){const s=t[i+1];s===Ja&&(t[i+1]=-32767),s===dl&&(t[i+1]=32766)}}_generatePoleQuad(t,i,s,o,d,p){o>d!=(p===Ja)?(t.push(i),t.push(s),t.push(this._vertexToIndex(o,p)),t.push(s),t.push(this._vertexToIndex(d,p)),t.push(this._vertexToIndex(o,p))):(t.push(s),t.push(i),t.push(this._vertexToIndex(o,p)),t.push(this._vertexToIndex(d,p)),t.push(s),t.push(this._vertexToIndex(o,p)))}_fillPoles(t,i,s){const o=this._vertexBuffer,d=gt,p=t.length;for(let m=2;m<p;m+=3){const g=t[m-2],x=t[m-1],v=t[m],T=o[2*g],M=o[2*g+1],E=o[2*x],A=o[2*x+1],L=o[2*v],F=o[2*v+1];i&&(M===0&&A===0&&this._generatePoleQuad(t,g,x,T,E,Ja),A===0&&F===0&&this._generatePoleQuad(t,x,v,E,L,Ja),F===0&&M===0&&this._generatePoleQuad(t,v,g,L,T,Ja)),s&&(M===d&&A===d&&this._generatePoleQuad(t,g,x,T,E,dl),A===d&&F===d&&this._generatePoleQuad(t,x,v,E,L,dl),F===d&&M===d&&this._generatePoleQuad(t,v,g,L,T,dl))}}_initializeVertices(t){for(let i=0;i<t.length;i+=2)this._vertexToIndex(t[i],t[i+1])}subdividePolygonInternal(t,i){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:s,holeIndices:o}=function(m){const g=[],x=[];for(const v of m)if(v.length!==0){v!==m[0]&&g.push(x.length/2);for(let T=0;T<v.length;T++)x.push(v[T].x),x.push(v[T].y)}return{flattened:x,holeIndices:g}}(t);let d;this._initializeVertices(s);try{const m=function(x,v,T=2){const M=v&&v.length,E=M?v[0]*T:x.length;let A=Au(x,0,E,T,!0);const L=[];if(!A||A.next===A.prev)return L;let F,V,Q;if(M&&(A=function(W,X,ce,pe){const xe=[];for(let Ae=0,Pe=X.length;Ae<Pe;Ae++){const Ie=Au(W,X[Ae]*pe,Ae<Pe-1?X[Ae+1]*pe:W.length,pe,!1);Ie===Ie.next&&(Ie.steiner=!0),xe.push(qp(Ie))}xe.sort($p);for(let Ae=0;Ae<xe.length;Ae++)ce=Zp(xe[Ae],ce);return ce}(x,v,A,T)),x.length>80*T){F=x[0],V=x[1];let W=F,X=V;for(let ce=T;ce<E;ce+=T){const pe=x[ce],xe=x[ce+1];pe<F&&(F=pe),xe<V&&(V=xe),pe>W&&(W=pe),xe>X&&(X=xe)}Q=Math.max(W-F,X-V),Q=Q!==0?32767/Q:0}return ll(A,L,T,F,V,Q,0),L}(s,o),g=this._convertIndices(s,m);d=this._subdivideTrianglesScanline(g)}catch(m){console.error(m)}let p=[];return i&&(p=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(d),{verticesFlattened:this._vertexBuffer,indicesTriangles:d,indicesLineList:p}}_convertIndices(t,i){const s=[];for(let o=0;o<i.length;o++)s.push(this._vertexToIndex(t[2*i[o]],t[2*i[o]+1]));return s}_pointArrayToIndices(t){const i=[];for(let s=0;s<t.length;s++){const o=t[s];i.push(this._vertexToIndex(o.x,o.y))}return i}}function Ru(r,t,i,s=!0){return new Hp(i,t).subdividePolygonInternal(r,s)}function ea(r,t,i=!1){if(!r||r.length<1)return[];if(r.length<2)return[];const s=r[0],o=r[r.length-1],d=i&&(s.x!==o.x||s.y!==o.y);if(t<2)return d?[...r,r[0]]:[...r];const p=Math.floor(gt/t),m=[];m.push(new be(r[0].x,r[0].y));const g=r.length,x=d?g:g-1;for(let v=0;v<x;v++){const T=r[v],M=v<g-1?r[v+1]:r[0],E=T.x,A=T.y,L=M.x,F=M.y,V=E!==L,Q=A!==F;if(!V&&!Q)continue;const W=L-E,X=F-A,ce=Math.abs(W),pe=Math.abs(X);let xe=E,Ae=A;for(;;){const Ie=W>0?(Math.floor(xe/p)+1)*p:(Math.ceil(xe/p)-1)*p,Be=X>0?(Math.floor(Ae/p)+1)*p:(Math.ceil(Ae/p)-1)*p,Me=Math.abs(xe-Ie),Ce=Math.abs(Ae-Be),ge=Math.abs(xe-L),Ze=Math.abs(Ae-F),Ge=V?Me/ce:Number.POSITIVE_INFINITY,Ne=Q?Ce/pe:Number.POSITIVE_INFINITY;if((ge<=Me||!V)&&(Ze<=Ce||!Q))break;if(Ge<Ne&&V||!Q){xe=Ie,Ae+=X*Ge;const De=new be(xe,Math.round(Ae));m[m.length-1].x===De.x&&m[m.length-1].y===De.y||m.push(De)}else{xe+=W*Ne,Ae=Be;const De=new be(Math.round(xe),Ae);m[m.length-1].x===De.x&&m[m.length-1].y===De.y||m.push(De)}}const Pe=new be(L,F);m[m.length-1].x===Pe.x&&m[m.length-1].y===Pe.y||m.push(Pe)}return m}function Xp(r,t,i){if(t.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,o=r[2*t[0]];for(let g=1;g<t.length;g++){const x=r[2*t[g]];x<o&&(o=x,s=g)}const d=t.length;let p=s,m=(p+1)%d;for(;;){const g=p-1>=0?p-1:d-1,x=(m+1)%d,v=r[2*t[g]],T=r[2*t[x]],M=r[2*t[p]],E=r[2*t[p]+1],A=r[2*t[m]+1];let L=!1;if(v<T)L=!0;else if(v>T)L=!1;else{const F=A-E,V=-(r[2*t[m]]-M),Q=E<A?1:-1;((v-M)*F+(r[2*t[g]+1]-E)*V)*Q>((T-M)*F+(r[2*t[x]+1]-E)*V)*Q&&(L=!0)}if(L){const F=t[g],V=t[p],Q=t[m];F!==V&&F!==Q&&V!==Q&&i.push(Q,V,F),p--,p<0&&(p=d-1)}else{const F=t[x],V=t[p],Q=t[m];F!==V&&F!==Q&&V!==Q&&i.push(Q,V,F),m++,m>=d&&(m=0)}if(g===x)break}}function Fu(r,t,i,s,o,d,p,m,g){const x=o.length/2,v=p&&m&&g;if(x<Xe.MAX_VERTEX_ARRAY_LENGTH){const T=t.prepareSegment(x,i,s),M=T.vertexLength;for(let L=0;L<d.length;L+=3)s.emplaceBack(M+d[L],M+d[L+1],M+d[L+2]);let E,A;T.vertexLength+=x,T.primitiveLength+=d.length/3,v&&(A=p.prepareSegment(x,i,m),E=A.vertexLength,A.vertexLength+=x);for(let L=0;L<o.length;L+=2)r(o[L],o[L+1]);if(v)for(let L=0;L<g.length;L++){const F=g[L];for(let V=1;V<F.length;V+=2)m.emplaceBack(E+F[V-1],E+F[V]);A.primitiveLength+=F.length/2}}else(function(T,M,E,A,L,F){const V=[];for(let pe=0;pe<A.length/2;pe++)V.push(-1);const Q={count:0};let W=0,X=T.getOrCreateLatestSegment(M,E),ce=X.vertexLength;for(let pe=2;pe<L.length;pe+=3){const xe=L[pe-2],Ae=L[pe-1],Pe=L[pe];let Ie=V[xe]<W,Be=V[Ae]<W,Me=V[Pe]<W;X.vertexLength+((Ie?1:0)+(Be?1:0)+(Me?1:0))>Xe.MAX_VERTEX_ARRAY_LENGTH&&(X=T.createNewSegment(M,E),W=Q.count,Ie=!0,Be=!0,Me=!0,ce=0);const Ce=pl(V,A,F,Q,xe,Ie,X),ge=pl(V,A,F,Q,Ae,Be,X),Ze=pl(V,A,F,Q,Pe,Me,X);E.emplaceBack(ce+Ce-W,ce+ge-W,ce+Ze-W),X.primitiveLength++}})(t,i,s,o,d,r),v&&function(T,M,E,A,L,F){const V=[];for(let pe=0;pe<A.length/2;pe++)V.push(-1);const Q={count:0};let W=0,X=T.getOrCreateLatestSegment(M,E),ce=X.vertexLength;for(let pe=0;pe<L.length;pe++){const xe=L[pe];for(let Ae=1;Ae<L[pe].length;Ae+=2){const Pe=xe[Ae-1],Ie=xe[Ae];let Be=V[Pe]<W,Me=V[Ie]<W;X.vertexLength+((Be?1:0)+(Me?1:0))>Xe.MAX_VERTEX_ARRAY_LENGTH&&(X=T.createNewSegment(M,E),W=Q.count,Be=!0,Me=!0,ce=0);const Ce=pl(V,A,F,Q,Pe,Be,X),ge=pl(V,A,F,Q,Ie,Me,X);E.emplaceBack(ce+Ce-W,ce+ge-W),X.primitiveLength++}}}(p,i,m,o,g,r),t.forceNewSegmentOnNextPrepare(),p==null||p.forceNewSegmentOnNextPrepare()}function pl(r,t,i,s,o,d,p){if(d){const m=s.count;return i(t[2*o],t[2*o+1]),r[o]=s.count,s.count++,p.vertexLength++,m}return r[o]}class Ah{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ue,this.indexArray=new yt,this.indexArray2=new mt,this.programConfigurations=new ji(t.layers,t.zoom),this.segments=new Xe,this.segments2=new Xe,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.hasPattern=Mh("fill",this.layers,i);const o=this.layers[0].layout.get("fill-sort-key"),d=!o.isConstant(),p=[];for(const{feature:m,id:g,index:x,sourceLayerIndex:v}of t){const T=this.layers[0]._featureFilter.needGeometry,M=kr(m,T);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom,{globalState:this.globalState}),M,s))continue;const E=d?o.evaluate(M,{},s,i.availableImages):void 0,A={id:g,properties:m.properties,type:m.type,sourceLayerIndex:v,index:x,geometry:T?M.geometry:an(m),patterns:{},sortKey:E};p.push(A)}d&&p.sort((m,g)=>m.sortKey-g.sortKey);for(const m of p){const{geometry:g,index:x,sourceLayerIndex:v}=m;if(this.hasPattern){const T=Ih("fill",this.layers,m,{zoom:this.zoom,globalState:this.globalState},i);this.patternFeatures.push(T)}else this.addFeature(m,g,x,s,{},i.subdivisionGranularity);i.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}addFeatures(t,i,s){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,i,s,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Op),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,i,s,o,d,p){for(const m of Bs(i,500)){const g=Ru(m,o,p.fill.getGranularityForZoomLevel(o.z)),x=this.layoutVertexArray;Fu((v,T)=>{x.emplaceBack(v,T)},this.segments,this.layoutVertexArray,this.indexArray,g.verticesFlattened,g.indicesTriangles,this.segments2,this.indexArray2,g.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:d,canonical:o,globalState:this.globalState})}}let Bu,Ou;ze("FillBucket",Ah,{omit:["layers","patternFeatures"]});var Yp={get paint(){return Ou=Ou||new Pi({"fill-antialias":new Fe(ne.paint_fill["fill-antialias"]),"fill-opacity":new Ve(ne.paint_fill["fill-opacity"]),"fill-color":new Ve(ne.paint_fill["fill-color"]),"fill-outline-color":new Ve(ne.paint_fill["fill-outline-color"]),"fill-translate":new Fe(ne.paint_fill["fill-translate"]),"fill-translate-anchor":new Fe(ne.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ua(ne.paint_fill["fill-pattern"])})},get layout(){return Bu=Bu||new Pi({"fill-sort-key":new Ve(ne.layout_fill["fill-sort-key"])})}};class Kp extends Wi{constructor(t){super(t,Yp)}recalculate(t,i){super.recalculate(t,i);const 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 Ah(t)}queryRadius(){return bc(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:i,transform:s,pixelsToTileUnits:o}){return gu(wc(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,o),i)}isTileClipped(){return!0}}const Jp=Bt([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Qp=Bt([{name:"a_centroid",components:2,type:"Int16"}],4),{members:ef}=Jp;class Qa{constructor(t,i,s,o,d){this.properties={},this.extent=s,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=o,this._values=d,t.readFields(tf,this,i)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const i=t.readVarint()+t.pos,s=[];let o,d=1,p=0,m=0,g=0;for(;t.pos<i;){if(p<=0){const x=t.readVarint();d=7&x,p=x>>3}if(p--,d===1||d===2)m+=t.readSVarint(),g+=t.readSVarint(),d===1&&(o&&s.push(o),o=[]),o&&o.push(new be(m,g));else{if(d!==7)throw new Error(`unknown command ${d}`);o&&o.push(o[0].clone())}}return o&&s.push(o),s}bbox(){const t=this._pbf;t.pos=this._geometry;const i=t.readVarint()+t.pos;let s=1,o=0,d=0,p=0,m=1/0,g=-1/0,x=1/0,v=-1/0;for(;t.pos<i;){if(o<=0){const T=t.readVarint();s=7&T,o=T>>3}if(o--,s===1||s===2)d+=t.readSVarint(),p+=t.readSVarint(),d<m&&(m=d),d>g&&(g=d),p<x&&(x=p),p>v&&(v=p);else if(s!==7)throw new Error(`unknown command ${s}`)}return[m,x,g,v]}toGeoJSON(t,i,s){const o=this.extent*Math.pow(2,s),d=this.extent*t,p=this.extent*i,m=this.loadGeometry();function g(M){return[360*(M.x+d)/o-180,360/Math.PI*Math.atan(Math.exp((1-2*(M.y+p)/o)*Math.PI))-90]}function x(M){return M.map(g)}let v;if(this.type===1){const M=[];for(const A of m)M.push(A[0]);const E=x(M);v=M.length===1?{type:"Point",coordinates:E[0]}:{type:"MultiPoint",coordinates:E}}else if(this.type===2){const M=m.map(x);v=M.length===1?{type:"LineString",coordinates:M[0]}:{type:"MultiLineString",coordinates:M}}else{if(this.type!==3)throw new Error("unknown feature type");{const M=function(A){const L=A.length;if(L<=1)return[A];const F=[];let V,Q;for(let W=0;W<L;W++){const X=rf(A[W]);X!==0&&(Q===void 0&&(Q=X<0),Q===X<0?(V&&F.push(V),V=[A[W]]):V&&V.push(A[W]))}return V&&F.push(V),F}(m),E=[];for(const A of M)E.push(A.map(x));v=E.length===1?{type:"Polygon",coordinates:E[0]}:{type:"MultiPolygon",coordinates:E}}}const T={type:"Feature",geometry:v,properties:this.properties};return this.id!=null&&(T.id=this.id),T}}function tf(r,t,i){r===1?t.id=i.readVarint():r===2?function(s,o){const d=s.readVarint()+s.pos;for(;s.pos<d;){const p=o._keys[s.readVarint()],m=o._values[s.readVarint()];o.properties[p]=m}}(i,t):r===3?t.type=i.readVarint():r===4&&(t._geometry=i.pos)}function rf(r){let t=0;for(let i,s,o=0,d=r.length,p=d-1;o<d;p=o++)i=r[o],s=r[p],t+=(s.x-i.x)*(i.y+s.y);return t}Qa.types=["Unknown","Point","LineString","Polygon"];class ju{constructor(t,i){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(nf,this,i),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const i=this._pbf.readVarint()+this._pbf.pos;return new Qa(this._pbf,i,this.extent,this._keys,this._values)}}function nf(r,t,i){r===15?t.version=i.readVarint():r===1?t.name=i.readString():r===5?t.extent=i.readVarint():r===2?t._features.push(i.pos):r===3?t._keys.push(i.readString()):r===4&&t._values.push(function(s){let o=null;const d=s.readVarint()+s.pos;for(;s.pos<d;){const p=s.readVarint()>>3;o=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}if(o==null)throw new Error("unknown feature value");return o}(i))}class Nu{constructor(t,i){this.layers=t.readFields(sf,{},i)}}function sf(r,t,i){if(r===3){const s=new ju(i,i.readVarint()+i.pos);s.length&&(t[s.name]=s)}}const kh=Math.pow(2,13);function fl(r,t,i,s,o,d,p,m){r.emplaceBack(t,i,2*Math.floor(s*kh)+p,o*kh*2,d*kh*2,Math.round(m))}class zh{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ae,this.centroidVertexArray=new G,this.indexArray=new yt,this.programConfigurations=new ji(t.layers,t.zoom),this.segments=new Xe,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.features=[],this.hasPattern=Mh("fill-extrusion",this.layers,i);for(const{feature:o,id:d,index:p,sourceLayerIndex:m}of t){const g=this.layers[0]._featureFilter.needGeometry,x=kr(o,g);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom,{globalState:this.globalState}),x,s))continue;const v={id:d,sourceLayerIndex:m,index:p,geometry:g?x.geometry:an(o),properties:o.properties,type:o.type,patterns:{}};this.hasPattern?this.features.push(Ih("fill-extrusion",this.layers,v,{zoom:this.zoom,globalState:this.globalState},i)):this.addFeature(v,v.geometry,p,s,{},i.subdivisionGranularity),i.featureIndex.insert(o,v.geometry,p,m,this.index,!0)}}addFeatures(t,i,s){for(const o of this.features){const{geometry:d}=o;this.addFeature(o,d,o.index,i,s,t.subdivisionGranularity)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}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,ef),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Qp.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,i,s,o,d,p){for(const m of Bs(i,500)){const g={x:0,y:0,sampleCount:0},x=this.layoutVertexArray.length;this.processPolygon(g,o,t,m,p);const v=this.layoutVertexArray.length-x,T=Math.floor(g.x/g.sampleCount),M=Math.floor(g.y/g.sampleCount);for(let E=0;E<v;E++)this.centroidVertexArray.emplaceBack(T,M)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:d,canonical:o,globalState:this.globalState})}processPolygon(t,i,s,o,d){if(o.length<1||Vu(o[0]))return;for(const T of o)T.length!==0&&af(t,T);const p={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},m=d.fill.getGranularityForZoomLevel(i.z),g=Qa.types[s.type]==="Polygon";for(const T of o){if(T.length===0||Vu(T))continue;const M=ea(T,m,g);this._generateSideFaces(M,p)}if(!g)return;const x=Ru(o,i,m,!1),v=this.layoutVertexArray;Fu((T,M)=>{fl(v,T,M,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,x.verticesFlattened,x.indicesTriangles)}_generateSideFaces(t,i){let s=0;for(let o=1;o<t.length;o++){const d=t[o],p=t[o-1];if(of(d,p))continue;i.segment.vertexLength+4>Xe.MAX_VERTEX_ARRAY_LENGTH&&(i.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const m=d.sub(p)._perp()._unit(),g=p.dist(d);s+g>32768&&(s=0),fl(this.layoutVertexArray,d.x,d.y,m.x,m.y,0,0,s),fl(this.layoutVertexArray,d.x,d.y,m.x,m.y,0,1,s),s+=g,fl(this.layoutVertexArray,p.x,p.y,m.x,m.y,0,0,s),fl(this.layoutVertexArray,p.x,p.y,m.x,m.y,0,1,s);const x=i.segment.vertexLength;this.indexArray.emplaceBack(x,x+2,x+1),this.indexArray.emplaceBack(x+1,x+2,x+3),i.segment.vertexLength+=4,i.segment.primitiveLength+=2}}}function af(r,t){for(let i=0;i<t.length;i++){const s=t[i];i===t.length-1&&t[0].x===s.x&&t[0].y===s.y||(r.x+=s.x,r.y+=s.y,r.sampleCount++)}}function of(r,t){return r.x===t.x&&(r.x<0||r.x>gt)||r.y===t.y&&(r.y<0||r.y>gt)}function Vu(r){return r.every(t=>t.x<0)||r.every(t=>t.x>gt)||r.every(t=>t.y<0)||r.every(t=>t.y>gt)}let Uu;ze("FillExtrusionBucket",zh,{omit:["layers","features"]});var lf={get paint(){return Uu=Uu||new Pi({"fill-extrusion-opacity":new Fe(ne["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ve(ne["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Fe(ne["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Fe(ne["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ua(ne["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ve(ne["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ve(ne["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Fe(ne["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class cf extends Wi{constructor(t){super(t,lf)}createBucket(t){return new zh(t)}queryRadius(){return bc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:o,transform:d,pixelsToTileUnits:p,pixelPosMatrix:m}){const g=wc(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-d.bearingInRadians,p),x=this.paint.get("fill-extrusion-height").evaluate(i,s),v=this.paint.get("fill-extrusion-base").evaluate(i,s),T=function(E,A){const L=[];for(const F of E){const V=[F.x,F.y,0,1];Ps(V,V,A),L.push(new be(V[0]/V[3],V[1]/V[3]))}return L}(g,m),M=function(E,A,L,F){const V=[],Q=[],W=F[8]*A,X=F[9]*A,ce=F[10]*A,pe=F[11]*A,xe=F[8]*L,Ae=F[9]*L,Pe=F[10]*L,Ie=F[11]*L;for(const Be of E){const Me=[],Ce=[];for(const ge of Be){const Ze=ge.x,Ge=ge.y,Ne=F[0]*Ze+F[4]*Ge+F[12],De=F[1]*Ze+F[5]*Ge+F[13],at=F[2]*Ze+F[6]*Ge+F[14],Lt=F[3]*Ze+F[7]*Ge+F[15],Jt=at+ce,vi=Lt+pe,hr=Ne+xe,Vi=De+Ae,di=at+Pe,Et=Lt+Ie,si=new be((Ne+W)/vi,(De+X)/vi);si.z=Jt/vi,Me.push(si);const pi=new be(hr/Et,Vi/Et);pi.z=di/Et,Ce.push(pi)}V.push(Me),Q.push(Ce)}return[V,Q]}(o,v,x,m);return function(E,A,L){let F=1/0;gu(L,A)&&(F=$u(L,A[0]));for(let V=0;V<A.length;V++){const Q=A[V],W=E[V];for(let X=0;X<Q.length-1;X++){const ce=Q[X],pe=[ce,Q[X+1],W[X+1],W[X],ce];mu(L,pe)&&(F=Math.min(F,$u(L,pe)))}}return F!==1/0&&F}(M[0],M[1],T)}}function ml(r,t){return r.x*t.x+r.y*t.y}function $u(r,t){if(r.length===1){let i=0;const s=t[i++];let o;for(;!o||s.equals(o);)if(o=t[i++],!o)return 1/0;for(;i<t.length;i++){const d=t[i],p=r[0],m=o.sub(s),g=d.sub(s),x=p.sub(s),v=ml(m,m),T=ml(m,g),M=ml(g,g),E=ml(x,m),A=ml(x,g),L=v*M-T*T,F=(M*E-T*A)/L,V=(v*A-T*E)/L,Q=s.z*(1-F-V)+o.z*F+d.z*V;if(isFinite(Q))return Q}return 1/0}{let i=1/0;for(const s of t)i=Math.min(i,s.z);return i}}const hf=Bt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:uf}=hf,df=Bt([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:pf}=df,ff=Math.cos(Math.PI/180*37.5),Zu=Math.pow(2,14)/.5;class Lh{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new oe,this.layoutVertexArray2=new he,this.indexArray=new yt,this.programConfigurations=new ji(t.layers,t.zoom),this.segments=new Xe,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.hasPattern=Mh("line",this.layers,i);const o=this.layers[0].layout.get("line-sort-key"),d=!o.isConstant(),p=[];for(const{feature:m,id:g,index:x,sourceLayerIndex:v}of t){const T=this.layers[0]._featureFilter.needGeometry,M=kr(m,T);if(!this.layers[0]._featureFilter.filter(new wt(this.zoom,{globalState:this.globalState}),M,s))continue;const E=d?o.evaluate(M,{},s):void 0,A={id:g,properties:m.properties,type:m.type,sourceLayerIndex:v,index:x,geometry:T?M.geometry:an(m),patterns:{},sortKey:E};p.push(A)}d&&p.sort((m,g)=>m.sortKey-g.sortKey);for(const m of p){const{geometry:g,index:x,sourceLayerIndex:v}=m;if(this.hasPattern){const T=Ih("line",this.layers,m,{zoom:this.zoom,globalState:this.globalState},i);this.patternFeatures.push(T)}else this.addFeature(m,g,x,s,{},i.subdivisionGranularity);i.featureIndex.insert(t[x].feature,g,x,v,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}addFeatures(t,i,s){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.index,i,s,t.subdivisionGranularity)}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,pf)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,uf),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,i,s,o,d,p){const m=this.layers[0].layout,g=m.get("line-join").evaluate(t,{}),x=m.get("line-cap"),v=m.get("line-miter-limit"),T=m.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const M of i)this.addLine(M,t,g,x,v,T,o,p);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:d,canonical:o,globalState:this.globalState})}addLine(t,i,s,o,d,p,m,g){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=ea(t,m?g.line.getGranularityForZoomLevel(m.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let W=0;W<t.length-1;W++)this.totalDistance+=t[W].dist(t[W+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const x=Qa.types[i.type]==="Polygon";let v=t.length;for(;v>=2&&t[v-1].equals(t[v-2]);)v--;let T=0;for(;T<v-1&&t[T].equals(t[T+1]);)T++;if(v<(x?3:2))return;s==="bevel"&&(d=1.05);const M=this.overscaling<=16?122880/(512*this.overscaling):0,E=this.segments.prepareSegment(10*v,this.layoutVertexArray,this.indexArray);let A,L,F,V,Q;this.e1=this.e2=-1,x&&(A=t[v-2],Q=t[T].sub(A)._unit()._perp());for(let W=T;W<v;W++){if(F=W===v-1?x?t[T+1]:void 0:t[W+1],F&&t[W].equals(F))continue;Q&&(V=Q),A&&(L=A),A=t[W],Q=F?F.sub(A)._unit()._perp():V,V=V||Q;let X=V.add(Q);X.x===0&&X.y===0||X._unit();const ce=V.x*Q.x+V.y*Q.y,pe=X.x*Q.x+X.y*Q.y,xe=pe!==0?1/pe:1/0,Ae=2*Math.sqrt(2-2*pe),Pe=pe<ff&&L&&F,Ie=V.x*Q.y-V.y*Q.x>0;if(Pe&&W>T){const Ce=A.dist(L);if(Ce>2*M){const ge=A.sub(A.sub(L)._mult(M/Ce)._round());this.updateDistance(L,ge),this.addCurrentVertex(ge,V,0,0,E),L=ge}}const Be=L&&F;let Me=Be?s:x?"butt":o;if(Be&&Me==="round"&&(xe<p?Me="miter":xe<=2&&(Me="fakeround")),Me==="miter"&&xe>d&&(Me="bevel"),Me==="bevel"&&(xe>2&&(Me="flipbevel"),xe<d&&(Me="miter")),L&&this.updateDistance(L,A),Me==="miter")X._mult(xe),this.addCurrentVertex(A,X,0,0,E);else if(Me==="flipbevel"){if(xe>100)X=Q.mult(-1);else{const Ce=xe*V.add(Q).mag()/V.sub(Q).mag();X._perp()._mult(Ce*(Ie?-1:1))}this.addCurrentVertex(A,X,0,0,E),this.addCurrentVertex(A,X.mult(-1),0,0,E)}else if(Me==="bevel"||Me==="fakeround"){const Ce=-Math.sqrt(xe*xe-1),ge=Ie?Ce:0,Ze=Ie?0:Ce;if(L&&this.addCurrentVertex(A,V,ge,Ze,E),Me==="fakeround"){const Ge=Math.round(180*Ae/Math.PI/20);for(let Ne=1;Ne<Ge;Ne++){let De=Ne/Ge;if(De!==.5){const Lt=De-.5;De+=De*Lt*(De-1)*((1.0904+ce*(ce*(3.55645-1.43519*ce)-3.2452))*Lt*Lt+(.848013+ce*(.215638*ce-1.06021)))}const at=Q.sub(V)._mult(De)._add(V)._unit()._mult(Ie?-1:1);this.addHalfVertex(A,at.x,at.y,!1,Ie,0,E)}}F&&this.addCurrentVertex(A,Q,-ge,-Ze,E)}else if(Me==="butt")this.addCurrentVertex(A,X,0,0,E);else if(Me==="square"){const Ce=L?1:-1;this.addCurrentVertex(A,X,Ce,Ce,E)}else Me==="round"&&(L&&(this.addCurrentVertex(A,V,0,0,E),this.addCurrentVertex(A,V,1,1,E,!0)),F&&(this.addCurrentVertex(A,Q,-1,-1,E,!0),this.addCurrentVertex(A,Q,0,0,E)));if(Pe&&W<v-1){const Ce=A.dist(F);if(Ce>2*M){const ge=A.add(F.sub(A)._mult(M/Ce)._round());this.updateDistance(A,ge),this.addCurrentVertex(ge,Q,0,0,E),A=ge}}}}addCurrentVertex(t,i,s,o,d,p=!1){const m=i.y*o-i.x,g=-i.y-i.x*o;this.addHalfVertex(t,i.x+i.y*s,i.y-i.x*s,p,!1,s,d),this.addHalfVertex(t,m,g,p,!0,-o,d),this.distance>Zu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,i,s,o,d,p))}addHalfVertex({x:t,y:i},s,o,d,p,m,g){const x=.5*(this.lineClips?this.scaledDistance*(Zu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(d?1:0),(i<<1)+(p?1:0),Math.round(63*s)+128,Math.round(63*o)+128,1+(m===0?0:m<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const v=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,v,this.e2),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,i){this.distance+=t.dist(i),this.updateScaledDistance()}}let Gu,qu;ze("LineBucket",Lh,{omit:["layers","patternFeatures"]});var Wu={get paint(){return qu=qu||new Pi({"line-opacity":new Ve(ne.paint_line["line-opacity"]),"line-color":new Ve(ne.paint_line["line-color"]),"line-translate":new Fe(ne.paint_line["line-translate"]),"line-translate-anchor":new Fe(ne.paint_line["line-translate-anchor"]),"line-width":new Ve(ne.paint_line["line-width"]),"line-gap-width":new Ve(ne.paint_line["line-gap-width"]),"line-offset":new Ve(ne.paint_line["line-offset"]),"line-blur":new Ve(ne.paint_line["line-blur"]),"line-dasharray":new en(ne.paint_line["line-dasharray"]),"line-pattern":new Ua(ne.paint_line["line-pattern"]),"line-gradient":new $a(ne.paint_line["line-gradient"])})},get layout(){return Gu=Gu||new Pi({"line-cap":new Fe(ne.layout_line["line-cap"]),"line-join":new Ve(ne.layout_line["line-join"]),"line-miter-limit":new Fe(ne.layout_line["line-miter-limit"]),"line-round-limit":new Fe(ne.layout_line["line-round-limit"]),"line-sort-key":new Ve(ne.layout_line["line-sort-key"])})}};class mf extends Ve{possiblyEvaluate(t,i){return i=new wt(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,zoomHistory:i.zoomHistory,transition:i.transition}),super.possiblyEvaluate(t,i)}evaluate(t,i,s,o){return i=Zi({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(t,i,s,o)}}let Mc;class gf extends Wi{constructor(t){super(t,Wu),this.gradientVersion=0,Mc||(Mc=new mf(Wu.paint.properties["line-width"].specification),Mc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const i=this.gradientExpression();this.stepInterpolant=!!function(s){return s._styleExpression!==void 0}(i)&&i._styleExpression.expression instanceof Ft,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,i){super.recalculate(t,i),this.paint._values["line-floorwidth"]=Mc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Lh(t)}queryRadius(t){const i=t,s=Hu(al("line-width",this,i),al("line-gap-width",this,i)),o=al("line-offset",this,i);return s/2+Math.abs(o)+bc(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:o,transform:d,pixelsToTileUnits:p}){const m=wc(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-d.bearingInRadians,p),g=p/2*Hu(this.paint.get("line-width").evaluate(i,s),this.paint.get("line-gap-width").evaluate(i,s)),x=this.paint.get("line-offset").evaluate(i,s);return x&&(o=function(v,T){const M=[];for(let E=0;E<v.length;E++){const A=v[E],L=[];for(let F=0;F<A.length;F++){const V=A[F-1],Q=A[F],W=A[F+1],X=F===0?new be(0,0):Q.sub(V)._unit()._perp(),ce=F===A.length-1?new be(0,0):W.sub(Q)._unit()._perp(),pe=X._add(ce)._unit(),xe=pe.x*ce.x+pe.y*ce.y;xe!==0&&pe._mult(1/xe),L.push(pe._mult(T)._add(Q))}M.push(L)}return M}(o,x*p)),function(v,T,M){for(let E=0;E<T.length;E++){const A=T[E];if(v.length>=3){for(let L=0;L<A.length;L++)if(Xa(v,A[L]))return!0}if(Mp(v,A,M))return!0}return!1}(m,o,g)}isTileClipped(){return!0}}function Hu(r,t){return t>0?t+2*r:r}const _f=Bt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),yf=Bt([{name:"a_projected_pos",components:3,type:"Float32"}],4);Bt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const xf=Bt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Bt([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Xu=Bt([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),vf=Bt([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function bf(r,t,i){return r.sections.forEach(s=>{s.text=function(o,d,p){const m=d.layout.get("text-transform").evaluate(p,{});return m==="uppercase"?o=o.toLocaleUpperCase():m==="lowercase"&&(o=o.toLocaleLowerCase()),sr.applyArabicShaping&&(o=sr.applyArabicShaping(o)),o}(s.text,t,i)}),r}Bt([{name:"triangle",components:3,type:"Uint16"}]),Bt([{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"}]),Bt([{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"}]),Bt([{type:"Float32",name:"offsetX"}]),Bt([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Bt([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const gl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var ni=24;const Dh=4294967296,Yu=1/Dh,Ku=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class Rh{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,i,s=this.length){for(;this.pos<s;){const o=this.readVarint(),d=o>>3,p=this.pos;this.type=7&o,t(d,i,this),this.pos===p&&this.skip(o)}return i}readMessage(t,i){return this.readFields(t,i,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Dh;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Dh;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const i=this.buf;let s,o;return o=i[this.pos++],s=127&o,o<128?s:(o=i[this.pos++],s|=(127&o)<<7,o<128?s:(o=i[this.pos++],s|=(127&o)<<14,o<128?s:(o=i[this.pos++],s|=(127&o)<<21,o<128?s:(o=i[this.pos],s|=(15&o)<<28,function(d,p,m){const g=m.buf;let x,v;if(v=g[m.pos++],x=(112&v)>>4,v<128||(v=g[m.pos++],x|=(127&v)<<3,v<128)||(v=g[m.pos++],x|=(127&v)<<10,v<128)||(v=g[m.pos++],x|=(127&v)<<17,v<128)||(v=g[m.pos++],x|=(127&v)<<24,v<128)||(v=g[m.pos++],x|=(1&v)<<31,v<128))return eo(d,x,p);throw new Error("Expected varint not more than 10 bytes")}(s,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){const t=this.readVarint()+this.pos,i=this.pos;return this.pos=t,t-i>=12&&Ku?Ku.decode(this.buf.subarray(i,t)):function(s,o,d){let p="",m=o;for(;m<d;){const g=s[m];let x,v,T,M=null,E=g>239?4:g>223?3:g>191?2:1;if(m+E>d)break;E===1?g<128&&(M=g):E===2?(x=s[m+1],(192&x)==128&&(M=(31&g)<<6|63&x,M<=127&&(M=null))):E===3?(x=s[m+1],v=s[m+2],(192&x)==128&&(192&v)==128&&(M=(15&g)<<12|(63&x)<<6|63&v,(M<=2047||M>=55296&&M<=57343)&&(M=null))):E===4&&(x=s[m+1],v=s[m+2],T=s[m+3],(192&x)==128&&(192&v)==128&&(192&T)==128&&(M=(15&g)<<18|(63&x)<<12|(63&v)<<6|63&T,(M<=65535||M>=1114112)&&(M=null))),M===null?(M=65533,E=1):M>65535&&(M-=65536,p+=String.fromCharCode(M>>>10&1023|55296),M=56320|1023&M),p+=String.fromCharCode(M),m+=E}return p}(this.buf,i,t)}readBytes(){const t=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,t);return this.pos=t,i}readPackedVarint(t=[],i){const s=this.readPackedEnd();for(;this.pos<s;)t.push(this.readVarint(i));return t}readPackedSVarint(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(t){const i=7&t;if(i===0)for(;this.buf[this.pos++]>127;);else if(i===2)this.pos=this.readVarint()+this.pos;else if(i===5)this.pos+=4;else{if(i!==1)throw new Error(`Unimplemented type: ${i}`);this.pos+=8}}writeTag(t,i){this.writeVarint(t<<3|i)}realloc(t){let i=this.length||16;for(;i<this.pos+t;)i*=2;if(i!==this.length){const s=new Uint8Array(i);s.set(this.buf),this.buf=s,this.dataView=new DataView(s.buffer),this.length=i}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Yu),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Yu),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(i,s){let o,d;if(i>=0?(o=i%4294967296|0,d=i/4294967296|0):(o=~(-i%4294967296),d=~(-i/4294967296),4294967295^o?o=o+1|0:(o=0,d=d+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(p,m,g){g.buf[g.pos++]=127&p|128,p>>>=7,g.buf[g.pos++]=127&p|128,p>>>=7,g.buf[g.pos++]=127&p|128,p>>>=7,g.buf[g.pos++]=127&p|128,g.buf[g.pos]=127&(p>>>=7)}(o,0,s),function(p,m){const g=(7&p)<<4;m.buf[m.pos++]|=g|((p>>>=3)?128:0),p&&(m.buf[m.pos++]=127&p|((p>>>=7)?128:0),p&&(m.buf[m.pos++]=127&p|((p>>>=7)?128:0),p&&(m.buf[m.pos++]=127&p|((p>>>=7)?128:0),p&&(m.buf[m.pos++]=127&p|((p>>>=7)?128:0),p&&(m.buf[m.pos++]=127&p)))))}(d,s)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const i=this.pos;this.pos=function(o,d,p){for(let m,g,x=0;x<d.length;x++){if(m=d.charCodeAt(x),m>55295&&m<57344){if(!g){m>56319||x+1===d.length?(o[p++]=239,o[p++]=191,o[p++]=189):g=m;continue}if(m<56320){o[p++]=239,o[p++]=191,o[p++]=189,g=m;continue}m=g-55296<<10|m-56320|65536,g=null}else g&&(o[p++]=239,o[p++]=191,o[p++]=189,g=null);m<128?o[p++]=m:(m<2048?o[p++]=m>>6|192:(m<65536?o[p++]=m>>12|224:(o[p++]=m>>18|240,o[p++]=m>>12&63|128),o[p++]=m>>6&63|128),o[p++]=63&m|128)}return p}(this.buf,t,this.pos);const s=this.pos-i;s>=128&&Ju(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const i=t.length;this.writeVarint(i),this.realloc(i);for(let s=0;s<i;s++)this.buf[this.pos++]=t[s]}writeRawMessage(t,i){this.pos++;const s=this.pos;t(i,this);const o=this.pos-s;o>=128&&Ju(s,o,this),this.pos=s-1,this.writeVarint(o),this.pos+=o}writeMessage(t,i,s){this.writeTag(t,2),this.writeRawMessage(i,s)}writePackedVarint(t,i){i.length&&this.writeMessage(t,wf,i)}writePackedSVarint(t,i){i.length&&this.writeMessage(t,Tf,i)}writePackedBoolean(t,i){i.length&&this.writeMessage(t,Mf,i)}writePackedFloat(t,i){i.length&&this.writeMessage(t,Pf,i)}writePackedDouble(t,i){i.length&&this.writeMessage(t,Sf,i)}writePackedFixed32(t,i){i.length&&this.writeMessage(t,If,i)}writePackedSFixed32(t,i){i.length&&this.writeMessage(t,Cf,i)}writePackedFixed64(t,i){i.length&&this.writeMessage(t,Ef,i)}writePackedSFixed64(t,i){i.length&&this.writeMessage(t,Af,i)}writeBytesField(t,i){this.writeTag(t,2),this.writeBytes(i)}writeFixed32Field(t,i){this.writeTag(t,5),this.writeFixed32(i)}writeSFixed32Field(t,i){this.writeTag(t,5),this.writeSFixed32(i)}writeFixed64Field(t,i){this.writeTag(t,1),this.writeFixed64(i)}writeSFixed64Field(t,i){this.writeTag(t,1),this.writeSFixed64(i)}writeVarintField(t,i){this.writeTag(t,0),this.writeVarint(i)}writeSVarintField(t,i){this.writeTag(t,0),this.writeSVarint(i)}writeStringField(t,i){this.writeTag(t,2),this.writeString(i)}writeFloatField(t,i){this.writeTag(t,5),this.writeFloat(i)}writeDoubleField(t,i){this.writeTag(t,1),this.writeDouble(i)}writeBooleanField(t,i){this.writeVarintField(t,+i)}}function eo(r,t,i){return i?4294967296*t+(r>>>0):4294967296*(t>>>0)+(r>>>0)}function Ju(r,t,i){const s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(s);for(let o=i.pos-1;o>=r;o--)i.buf[o+s]=i.buf[o]}function wf(r,t){for(let i=0;i<r.length;i++)t.writeVarint(r[i])}function Tf(r,t){for(let i=0;i<r.length;i++)t.writeSVarint(r[i])}function Pf(r,t){for(let i=0;i<r.length;i++)t.writeFloat(r[i])}function Sf(r,t){for(let i=0;i<r.length;i++)t.writeDouble(r[i])}function Mf(r,t){for(let i=0;i<r.length;i++)t.writeBoolean(r[i])}function If(r,t){for(let i=0;i<r.length;i++)t.writeFixed32(r[i])}function Cf(r,t){for(let i=0;i<r.length;i++)t.writeSFixed32(r[i])}function Ef(r,t){for(let i=0;i<r.length;i++)t.writeFixed64(r[i])}function Af(r,t){for(let i=0;i<r.length;i++)t.writeSFixed64(r[i])}function kf(r,t,i){r===1&&i.readMessage(zf,t)}function zf(r,t,i){if(r===3){const{id:s,bitmap:o,width:d,height:p,left:m,top:g,advance:x}=i.readMessage(Lf,{});t.push({id:s,bitmap:new ol({width:d+6,height:p+6},o),metrics:{width:d,height:p,left:m,top:g,advance:x}})}}function Lf(r,t,i){r===1?t.id=i.readVarint():r===2?t.bitmap=i.readBytes():r===3?t.width=i.readVarint():r===4?t.height=i.readVarint():r===5?t.left=i.readSVarint():r===6?t.top=i.readSVarint():r===7&&(t.advance=i.readVarint())}function Qu(r){let t=0,i=0;for(const p of r)t+=p.w*p.h,i=Math.max(i,p.w);r.sort((p,m)=>m.h-p.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let o=0,d=0;for(const p of r)for(let m=s.length-1;m>=0;m--){const g=s[m];if(!(p.w>g.w||p.h>g.h)){if(p.x=g.x,p.y=g.y,d=Math.max(d,p.y+p.h),o=Math.max(o,p.x+p.w),p.w===g.w&&p.h===g.h){const x=s.pop();x&&m<s.length&&(s[m]=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:o,h:d,fill:t/(o*d)||0}}class Fh{constructor(t,{pixelRatio:i,version:s,stretchX:o,stretchY:d,content:p,textFitWidth:m,textFitHeight:g}){this.paddedRect=t,this.pixelRatio=i,this.stretchX=o,this.stretchY=d,this.content=p,this.version=s,this.textFitWidth=m,this.textFitHeight=g}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class ed{constructor(t,i){const s={},o={};this.haveRenderCallbacks=[];const d=[];this.addImages(t,s,d),this.addImages(i,o,d);const{w:p,h:m}=Qu(d),g=new Ni({width:p||1,height:m||1});for(const x in t){const v=t[x],T=s[x].paddedRect;Ni.copy(v.data,g,{x:0,y:0},{x:T.x+1,y:T.y+1},v.data)}for(const x in i){const v=i[x],T=o[x].paddedRect,M=T.x+1,E=T.y+1,A=v.data.width,L=v.data.height;Ni.copy(v.data,g,{x:0,y:0},{x:M,y:E},v.data),Ni.copy(v.data,g,{x:0,y:L-1},{x:M,y:E-1},{width:A,height:1}),Ni.copy(v.data,g,{x:0,y:0},{x:M,y:E+L},{width:A,height:1}),Ni.copy(v.data,g,{x:A-1,y:0},{x:M-1,y:E},{width:1,height:L}),Ni.copy(v.data,g,{x:0,y:0},{x:M+A,y:E},{width:1,height:L})}this.image=g,this.iconPositions=s,this.patternPositions=o}addImages(t,i,s){for(const o in t){const d=t[o],p={x:0,y:0,w:d.data.width+2,h:d.data.height+2};s.push(p),i[o]=new Fh(p,d),d.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(t,i){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in t.updatedImages)this.patchUpdatedImage(this.iconPositions[s],t.getImage(s),i),this.patchUpdatedImage(this.patternPositions[s],t.getImage(s),i)}patchUpdatedImage(t,i,s){if(!t||!i||t.version===i.version)return;t.version=i.version;const[o,d]=t.tl;s.update(i.data,void 0,{x:o,y:d})}}var gs;ze("ImagePosition",Fh),ze("ImageAtlas",ed),C.ao=void 0,(gs=C.ao||(C.ao={}))[gs.none=0]="none",gs[gs.horizontal=1]="horizontal",gs[gs.vertical=2]="vertical",gs[gs.horizontalOnly=3]="horizontalOnly";class _l{constructor(){this.scale=1,this.fontStack="",this.imageName=null,this.verticalAlign="bottom"}static forText(t,i,s){const o=new _l;return o.scale=t||1,o.fontStack=i,o.verticalAlign=s||"bottom",o}static forImage(t,i){const s=new _l;return s.imageName=t,s.verticalAlign=i||"bottom",s}}class to{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,i){const s=new to;for(let o=0;o<t.sections.length;o++){const d=t.sections[o];d.image?s.addImageSection(d):s.addTextSection(d,i)}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 i="";for(let s=0;s<t.length;s++){const o=t.charCodeAt(s+1)||null,d=t.charCodeAt(s-1)||null;i+=o&&dc(o)&&!gl[t[s+1]]||d&&dc(d)&&!gl[t[s-1]]||!gl[t[s]]?t[s]:gl[t[s]]}return i}(this.text)}trim(){let t=0;for(let s=0;s<this.text.length&&Cc[this.text.charCodeAt(s)];s++)t++;let i=this.text.length;for(let s=this.text.length-1;s>=0&&s>=t&&Cc[this.text.charCodeAt(s)];s--)i--;this.text=this.text.substring(t,i),this.sectionIndex=this.sectionIndex.slice(t,i)}substring(t,i){const s=new to;return s.text=this.text.substring(t,i),s.sectionIndex=this.sectionIndex.slice(t,i),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,i)=>Math.max(t,this.sections[i].scale),0)}getMaxImageSize(t){let i=0,s=0;for(let o=0;o<this.length();o++){const d=this.getSection(o);if(d.imageName){const p=t[d.imageName];if(!p)continue;const m=p.displaySize;i=Math.max(i,m[0]),s=Math.max(s,m[1])}}return{maxImageWidth:i,maxImageHeight:s}}addTextSection(t,i){this.text+=t.text,this.sections.push(_l.forText(t.scale,t.fontStack||i,t.verticalAlign));const s=this.sections.length-1;for(let o=0;o<t.text.length;++o)this.sectionIndex.push(s)}addImageSection(t){const i=t.image?t.image.name:"";if(i.length===0)return void jt("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push(_l.forImage(i,t.verticalAlign)),this.sectionIndex.push(this.sections.length-1)):jt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ic(r,t,i,s,o,d,p,m,g,x,v,T,M,E,A){const L=to.fromFeature(r,o);let F;T===C.ao.vertical&&L.verticalizePunctuation();const{processBidirectionalText:V,processStyledBidirectionalText:Q}=sr;if(V&&L.sections.length===1){F=[];const ce=V(L.toString(),Bh(L,x,d,t,s,E));for(const pe of ce){const xe=new to;xe.text=pe,xe.sections=L.sections;for(let Ae=0;Ae<pe.length;Ae++)xe.sectionIndex.push(0);F.push(xe)}}else if(Q){F=[];const ce=Q(L.text,L.sectionIndex,Bh(L,x,d,t,s,E));for(const pe of ce){const xe=new to;xe.text=pe[0],xe.sectionIndex=pe[1],xe.sections=L.sections,F.push(xe)}}else F=function(ce,pe){const xe=[],Ae=ce.text;let Pe=0;for(const Ie of pe)xe.push(ce.substring(Pe,Ie)),Pe=Ie;return Pe<Ae.length&&xe.push(ce.substring(Pe,Ae.length)),xe}(L,Bh(L,x,d,t,s,E));const W=[],X={positionedLines:W,text:L.toString(),top:v[1],bottom:v[1],left:v[0],right:v[0],writingMode:T,iconsInText:!1,verticalizable:!1};return function(ce,pe,xe,Ae,Pe,Ie,Be,Me,Ce,ge,Ze,Ge){let Ne=0,De=0,at=0,Lt=0;const Jt=Me==="right"?1:Me==="left"?0:.5,vi=ni/Ge;let hr=0;for(const Et of Pe){Et.trim();const si=Et.getMaxScale(),pi={positionedGlyphs:[],lineOffset:0};ce.positionedLines[hr]=pi;const fi=pi.positionedGlyphs;let Di=0;if(!Et.length()){De+=Ie,++hr;continue}const ur=Bf(Ae,Et,vi);for(let Ui=0;Ui<Et.length();Ui++){const Qt=Et.getSection(Ui),oi=Et.getSectionIndex(Ui),li=Et.getCharCode(Ui),Wt=Of(Ce,Ze,li);let St;if(Qt.imageName){if(ce.iconsInText=!0,Qt.scale=Qt.scale*vi,St=Nf(Qt,Wt,si,ur,Ae),!St)continue;Di=Math.max(Di,St.imageOffset)}else if(St=jf(Qt,li,Wt,ur,pe,xe),!St)continue;const{rect:zr,metrics:so,baselineOffset:Lr}=St;fi.push({glyph:li,imageName:Qt.imageName,x:Ne,y:De+Lr+-17,vertical:Wt,scale:Qt.scale,fontStack:Qt.fontStack,sectionIndex:oi,metrics:so,rect:zr}),Wt?(ce.verticalizable=!0,Ne+=(Qt.imageName?so.advance:ni)*Qt.scale+ge):Ne+=so.advance*Qt.scale+ge}fi.length!==0&&(at=Math.max(Ne-ge,at),Vf(fi,0,fi.length-1,Jt)),Ne=0,pi.lineOffset=Math.max(Di,(si-1)*ni);const ai=Ie*si+Di;De+=ai,Lt=Math.max(ai,Lt),++hr}const{horizontalAlign:Vi,verticalAlign:di}=Oh(Be);(function(Et,si,pi,fi,Di,ur,ai,Ui,Qt){const oi=(si-pi)*Di;let li=0;li=ur!==ai?-Ui*fi- -17:-fi*Qt*ai+.5*ai;for(const Wt of Et)for(const St of Wt.positionedGlyphs)St.x+=oi,St.y+=li})(ce.positionedLines,Jt,Vi,di,at,Lt,Ie,De,Pe.length),ce.top+=-di*De,ce.bottom=ce.top+De,ce.left+=-Vi*at,ce.right=ce.left+at}(X,t,i,s,F,p,m,g,T,x,M,A),!function(ce){for(const pe of ce)if(pe.positionedGlyphs.length!==0)return!1;return!0}(W)&&X}const Cc={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Df={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},Rf={40:!0};function td(r,t,i,s,o,d){if(t.imageName){const p=s[t.imageName];return p?p.displaySize[0]*t.scale*ni/d+o:0}{const p=i[t.fontStack],m=p&&p[r];return m?m.metrics.advance*t.scale+o:0}}function id(r,t,i,s){const o=Math.pow(r-t,2);return s?r<t?o/2:2*o:o+Math.abs(i)*i}function Ff(r,t,i){let s=0;return r===10&&(s-=1e4),i&&(s+=150),r!==40&&r!==65288||(s+=50),t!==41&&t!==65289||(s+=50),s}function rd(r,t,i,s,o,d){let p=null,m=id(t,i,o,d);for(const g of s){const x=id(t-g.x,i,o,d)+g.badness;x<=m&&(p=g,m=x)}return{index:r,x:t,priorBreak:p,badness:m}}function nd(r){return r?nd(r.priorBreak).concat(r.index):[]}function Bh(r,t,i,s,o,d){if(!r)return[];const p=[],m=function(T,M,E,A,L,F){let V=0;for(let Q=0;Q<T.length();Q++){const W=T.getSection(Q);V+=td(T.getCharCode(Q),W,A,L,M,F)}return V/Math.max(1,Math.ceil(V/E))}(r,t,i,s,o,d),g=r.text.indexOf("​")>=0;let x=0;for(let T=0;T<r.length();T++){const M=r.getSection(T),E=r.getCharCode(T);if(Cc[E]||(x+=td(E,M,s,o,t,d)),T<r.length()-1){const A=!((v=E)<11904)&&(!!st["CJK Compatibility Forms"](v)||!!st["CJK Compatibility"](v)||!!st["CJK Strokes"](v)||!!st["CJK Symbols and Punctuation"](v)||!!st["Enclosed CJK Letters and Months"](v)||!!st["Halfwidth and Fullwidth Forms"](v)||!!st["Ideographic Description Characters"](v)||!!st["Vertical Forms"](v)||Xo.test(String.fromCodePoint(v)));(Df[E]||A||M.imageName||T!==r.length()-2&&Rf[r.getCharCode(T+1)])&&p.push(rd(T+1,x,m,p,Ff(E,r.getCharCode(T+1),A&&g),!1))}}var v;return nd(rd(r.length(),x,m,p,0,!0))}function Oh(r){let t=.5,i=.5;switch(r){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(r){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function Bf(r,t,i){const s=t.getMaxScale()*ni,{maxImageWidth:o,maxImageHeight:d}=t.getMaxImageSize(r),p=Math.max(s,d*i);return{verticalLineContentWidth:Math.max(s,o*i),horizontalLineContentHeight:p}}function sd(r){switch(r){case"top":return 0;case"center":return .5;default:return 1}}function Of(r,t,i){return!(r===C.ao.horizontal||!t&&!Yo(i)||t&&(Cc[i]||(s=i,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(s)))));var s}function jf(r,t,i,s,o,d){const p=d[r.fontStack],m=function(x,v,T,M){if(x&&x.rect)return x;const E=v[T.fontStack],A=E&&E[M];return A?{rect:null,metrics:A.metrics}:null}(p&&p[t],o,r,t);if(m===null)return null;let g;if(i)g=s.verticalLineContentWidth-r.scale*ni;else{const x=sd(r.verticalAlign);g=(s.horizontalLineContentHeight-r.scale*ni)*x}return{rect:m.rect,metrics:m.metrics,baselineOffset:g}}function Nf(r,t,i,s,o){const d=o[r.imageName];if(!d)return null;const p=d.paddedRect,m=d.displaySize,g={width:m[0],height:m[1],left:1,top:-3,advance:t?m[1]:m[0]};let x;if(t)x=s.verticalLineContentWidth-m[1]*r.scale;else{const v=sd(r.verticalAlign);x=(s.horizontalLineContentHeight-m[1]*r.scale)*v}return{rect:p,metrics:g,baselineOffset:x,imageOffset:(t?m[0]:m[1])*r.scale-ni*i}}function Vf(r,t,i,s){if(s===0)return;const o=r[i],d=(r[i].x+o.metrics.advance*o.scale)*s;for(let p=t;p<=i;p++)r[p].x-=d}function Uf(r,t,i){const{horizontalAlign:s,verticalAlign:o}=Oh(i),d=t[0]-r.displaySize[0]*s,p=t[1]-r.displaySize[1]*o;return{image:r,top:p,bottom:p+r.displaySize[1],left:d,right:d+r.displaySize[0]}}function ad(r){var t,i;let s=r.left,o=r.top,d=r.right-s,p=r.bottom-o;const m=(t=r.image.textFitWidth)!==null&&t!==void 0?t:"stretchOrShrink",g=(i=r.image.textFitHeight)!==null&&i!==void 0?i:"stretchOrShrink",x=(r.image.content[2]-r.image.content[0])/(r.image.content[3]-r.image.content[1]);if(g==="proportional"){if(m==="stretchOnly"&&d/p<x||m==="proportional"){const v=Math.ceil(p*x);s*=v/d,d=v}}else if(m==="proportional"&&g==="stretchOnly"&&x!==0&&d/p>x){const v=Math.ceil(d/x);o*=v/p,p=v}return{x1:s,y1:o,x2:s+d,y2:o+p}}function od(r,t,i,s,o,d){const p=r.image;let m;if(p.content){const F=p.content,V=p.pixelRatio||1;m=[F[0]/V,F[1]/V,p.displaySize[0]-F[2]/V,p.displaySize[1]-F[3]/V]}const g=t.left*d,x=t.right*d;let v,T,M,E;i==="width"||i==="both"?(E=o[0]+g-s[3],T=o[0]+x+s[1]):(E=o[0]+(g+x-p.displaySize[0])/2,T=E+p.displaySize[0]);const A=t.top*d,L=t.bottom*d;return i==="height"||i==="both"?(v=o[1]+A-s[0],M=o[1]+L+s[2]):(v=o[1]+(A+L-p.displaySize[1])/2,M=v+p.displaySize[1]),{image:p,top:v,right:T,bottom:M,left:E,collisionPadding:m}}const Bn=128,_s=32640;function ld(r,t){const{expression:i}=t;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new wt(r+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:o}=i;let d=0;for(;d<s.length&&s[d]<=r;)d++;d=Math.max(0,d-1);let p=d;for(;p<s.length&&s[p]<r+1;)p++;p=Math.min(s.length-1,p);const m=s[d],g=s[p];return i.kind==="composite"?{kind:"composite",minZoom:m,maxZoom:g,interpolationType:o}:{kind:"camera",minZoom:m,maxZoom:g,minSize:i.evaluate(new wt(m)),maxSize:i.evaluate(new wt(g)),interpolationType:o}}}function jh(r,t,i){let s="never";const o=r.get(t);return o?s=o:r.get(i)&&(s="always"),s}const $f=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Ec(r,t,i,s,o,d,p,m,g,x,v,T,M){const E=m?Math.min(_s,Math.round(m[0])):0,A=m?Math.min(_s,Math.round(m[1])):0;r.emplaceBack(t,i,Math.round(32*s),Math.round(32*o),d,p,(E<<1)+(g?1:0),A,16*x,16*v,256*T,256*M)}function Nh(r,t,i){r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i)}function Zf(r){for(const t of r.sections)if(mc(t.text))return!0;return!1}class Vh{constructor(t){this.layoutVertexArray=new Se,this.indexArray=new yt,this.programConfigurations=t,this.segments=new Xe,this.dynamicLayoutVertexArray=new ye,this.opacityVertexArray=new Le,this.hasVisibleVertices=!1,this.placedSymbolArray=new k}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,i,s,o){this.isEmpty()||(s&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,_f.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,yf.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,$f,!0),this.opacityVertexBuffer.itemSize=1),(s||o)&&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())}}ze("SymbolBuffers",Vh);class Uh{constructor(t,i,s){this.layoutVertexArray=new t,this.layoutAttributes=i,this.indexArray=new s,this.segments=new Xe,this.collisionVertexArray=new dt}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,xf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ze("CollisionBuffers",Uh);class io{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.globalState=t.globalState,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=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ld(this.zoom,i["text-size"]),this.iconSizeData=ld(this.zoom,i["icon-size"]);const s=this.layers[0].layout,o=s.get("symbol-sort-key"),d=s.get("symbol-z-order");this.canOverlap=jh(s,"text-overlap","text-allow-overlap")!=="never"||jh(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=d!=="viewport-y"&&!o.isConstant(),this.sortFeaturesByY=(d==="viewport-y"||d==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map(p=>C.ao[p])),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.sourceID=t.sourceID}createArrays(){this.text=new Vh(new ji(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new Vh(new ji(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new N,this.lineVertexArray=new U,this.symbolInstances=new B,this.textAnchorOffsets=new $}calculateGlyphDependencies(t,i,s,o,d){for(let p=0;p<t.length;p++)if(i[t.charCodeAt(p)]=!0,(s||o)&&d){const m=gl[t.charAt(p)];m&&(i[m.charCodeAt(0)]=!0)}}populate(t,i,s){const o=this.layers[0],d=o.layout,p=d.get("text-font"),m=d.get("text-field"),g=d.get("icon-image"),x=(m.value.kind!=="constant"||m.value.value instanceof bi&&!m.value.value.isEmpty()||m.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,T=d.get("symbol-sort-key");if(this.features=[],!x&&!v)return;const M=i.iconDependencies,E=i.glyphDependencies,A=i.availableImages,L=new wt(this.zoom,{globalState:this.globalState});for(const{feature:F,id:V,index:Q,sourceLayerIndex:W}of t){const X=o._featureFilter.needGeometry,ce=kr(F,X);if(!o._featureFilter.filter(L,ce,s))continue;let pe,xe;if(X||(ce.geometry=an(F)),x){const Pe=o.getValueAndResolveTokens("text-field",ce,s,A),Ie=bi.factory(Pe),Be=this.hasRTLText=this.hasRTLText||Zf(Ie);(!Be||sr.getRTLTextPluginStatus()==="unavailable"||Be&&sr.isParsed())&&(pe=bf(Ie,o,ce))}if(v){const Pe=o.getValueAndResolveTokens("icon-image",ce,s,A);xe=Pe instanceof Bi?Pe:Bi.fromString(Pe)}if(!pe&&!xe)continue;const Ae=this.sortFeaturesByKey?T.evaluate(ce,{},s):void 0;if(this.features.push({id:V,text:pe,icon:xe,index:Q,sourceLayerIndex:W,geometry:ce.geometry,properties:F.properties,type:Qa.types[F.type],sortKey:Ae}),xe&&(M[xe.name]=!0),pe){const Pe=p.evaluate(ce,{},s).join(","),Ie=d.get("text-rotation-alignment")!=="viewport"&&d.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(C.ao.vertical)>=0;for(const Be of pe.sections)if(Be.image)M[Be.image.name]=!0;else{const Me=ja(pe.toString()),Ce=Be.fontStack||Pe,ge=E[Ce]=E[Ce]||{};this.calculateGlyphDependencies(Be.text,ge,Ie,this.allowVerticalPlacement,Me)}}}d.get("symbol-placement")==="line"&&(this.features=function(F){const V={},Q={},W=[];let X=0;function ce(Pe){W.push(F[Pe]),X++}function pe(Pe,Ie,Be){const Me=Q[Pe];return delete Q[Pe],Q[Ie]=Me,W[Me].geometry[0].pop(),W[Me].geometry[0]=W[Me].geometry[0].concat(Be[0]),Me}function xe(Pe,Ie,Be){const Me=V[Ie];return delete V[Ie],V[Pe]=Me,W[Me].geometry[0].shift(),W[Me].geometry[0]=Be[0].concat(W[Me].geometry[0]),Me}function Ae(Pe,Ie,Be){const Me=Be?Ie[0][Ie[0].length-1]:Ie[0][0];return`${Pe}:${Me.x}:${Me.y}`}for(let Pe=0;Pe<F.length;Pe++){const Ie=F[Pe],Be=Ie.geometry,Me=Ie.text?Ie.text.toString():null;if(!Me){ce(Pe);continue}const Ce=Ae(Me,Be),ge=Ae(Me,Be,!0);if(Ce in Q&&ge in V&&Q[Ce]!==V[ge]){const Ze=xe(Ce,ge,Be),Ge=pe(Ce,ge,W[Ze].geometry);delete V[Ce],delete Q[ge],Q[Ae(Me,W[Ge].geometry,!0)]=Ge,W[Ze].geometry=null}else Ce in Q?pe(Ce,ge,Be):ge in V?xe(Ce,ge,Be):(ce(Pe),V[Ce]=X-1,Q[ge]=X-1)}return W.filter(Pe=>Pe.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((F,V)=>F.sortKey-V.sortKey)}update(t,i,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,i,this.layers,{imagePositions:s,globalState:this.globalState}),this.icon.programConfigurations.updatePaintArrays(t,i,this.layers,{imagePositions:s,globalState:this.globalState}))}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,i){const s=this.lineVertexArray.length;if(t.segment!==void 0){let o=t.dist(i[t.segment+1]),d=t.dist(i[t.segment]);const p={};for(let m=t.segment+1;m<i.length;m++)p[m]={x:i[m].x,y:i[m].y,tileUnitDistanceFromAnchor:o},m<i.length-1&&(o+=i[m+1].dist(i[m]));for(let m=t.segment||0;m>=0;m--)p[m]={x:i[m].x,y:i[m].y,tileUnitDistanceFromAnchor:d},m>0&&(d+=i[m-1].dist(i[m]));for(let m=0;m<i.length;m++){const g=p[m];this.lineVertexArray.emplaceBack(g.x,g.y,g.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(t,i,s,o,d,p,m,g,x,v,T,M){const E=t.indexArray,A=t.layoutVertexArray,L=t.segments.prepareSegment(4*i.length,A,E,this.canOverlap?p.sortKey:void 0),F=this.glyphOffsetArray.length,V=L.vertexLength,Q=this.allowVerticalPlacement&&m===C.ao.vertical?Math.PI/2:0,W=p.text&&p.text.sections;for(let X=0;X<i.length;X++){const{tl:ce,tr:pe,bl:xe,br:Ae,tex:Pe,pixelOffsetTL:Ie,pixelOffsetBR:Be,minFontScaleX:Me,minFontScaleY:Ce,glyphOffset:ge,isSDF:Ze,sectionIndex:Ge}=i[X],Ne=L.vertexLength,De=ge[1];Ec(A,g.x,g.y,ce.x,De+ce.y,Pe.x,Pe.y,s,Ze,Ie.x,Ie.y,Me,Ce),Ec(A,g.x,g.y,pe.x,De+pe.y,Pe.x+Pe.w,Pe.y,s,Ze,Be.x,Ie.y,Me,Ce),Ec(A,g.x,g.y,xe.x,De+xe.y,Pe.x,Pe.y+Pe.h,s,Ze,Ie.x,Be.y,Me,Ce),Ec(A,g.x,g.y,Ae.x,De+Ae.y,Pe.x+Pe.w,Pe.y+Pe.h,s,Ze,Be.x,Be.y,Me,Ce),Nh(t.dynamicLayoutVertexArray,g,Q),E.emplaceBack(Ne,Ne+2,Ne+1),E.emplaceBack(Ne+1,Ne+2,Ne+3),L.vertexLength+=4,L.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(ge[0]),X!==i.length-1&&Ge===i[X+1].sectionIndex||t.programConfigurations.populatePaintArrays(A.length,p,p.index,{imagePositions:{},canonical:M,formattedSection:W&&W[Ge],globalState:this.globalState})}t.placedSymbolArray.emplaceBack(g.x,g.y,F,this.glyphOffsetArray.length-F,V,x,v,g.segment,s?s[0]:0,s?s[1]:0,o[0],o[1],m,0,!1,0,T)}_addCollisionDebugVertex(t,i,s,o,d,p){return i.emplaceBack(0,0),t.emplaceBack(s.x,s.y,o,d,Math.round(p.x),Math.round(p.y))}addCollisionDebugVertices(t,i,s,o,d,p,m){const g=d.segments.prepareSegment(4,d.layoutVertexArray,d.indexArray),x=g.vertexLength,v=d.layoutVertexArray,T=d.collisionVertexArray,M=m.anchorX,E=m.anchorY;this._addCollisionDebugVertex(v,T,p,M,E,new be(t,i)),this._addCollisionDebugVertex(v,T,p,M,E,new be(s,i)),this._addCollisionDebugVertex(v,T,p,M,E,new be(s,o)),this._addCollisionDebugVertex(v,T,p,M,E,new be(t,o)),g.vertexLength+=4;const A=d.indexArray;A.emplaceBack(x,x+1),A.emplaceBack(x+1,x+2),A.emplaceBack(x+2,x+3),A.emplaceBack(x+3,x),g.primitiveLength+=4}addDebugCollisionBoxes(t,i,s,o){for(let d=t;d<i;d++){const p=this.collisionBoxArray.get(d);this.addCollisionDebugVertices(p.x1,p.y1,p.x2,p.y2,o?this.textCollisionBox:this.iconCollisionBox,p.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Uh(Ke,Xu.members,mt),this.iconCollisionBox=new Uh(Ke,Xu.members,mt);for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.addDebugCollisionBoxes(i.textBoxStartIndex,i.textBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.iconBoxStartIndex,i.iconBoxEndIndex,i,!1),this.addDebugCollisionBoxes(i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex,i,!1)}}_deserializeCollisionBoxesForSymbol(t,i,s,o,d,p,m,g,x){const v={};for(let T=i;T<s;T++){const M=t.get(T);v.textBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},v.textFeatureIndex=M.featureIndex;break}for(let T=o;T<d;T++){const M=t.get(T);v.verticalTextBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},v.verticalTextFeatureIndex=M.featureIndex;break}for(let T=p;T<m;T++){const M=t.get(T);v.iconBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},v.iconFeatureIndex=M.featureIndex;break}for(let T=g;T<x;T++){const M=t.get(T);v.verticalIconBox={x1:M.x1,y1:M.y1,x2:M.x2,y2:M.y2,anchorPointX:M.anchorPointX,anchorPointY:M.anchorPointY},v.verticalIconFeatureIndex=M.featureIndex;break}return v}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const s=this.symbolInstances.get(i);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,i){const s=t.placedSymbolArray.get(i),o=s.vertexStartIndex+4*s.numGlyphs;for(let d=s.vertexStartIndex;d<o;d+=4)t.indexArray.emplaceBack(d,d+2,d+1),t.indexArray.emplaceBack(d+1,d+2,d+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(t),s=Math.cos(t),o=[],d=[],p=[];for(let m=0;m<this.symbolInstances.length;++m){p.push(m);const g=this.symbolInstances.get(m);o.push(0|Math.round(i*g.anchorX+s*g.anchorY)),d.push(g.featureIndex)}return p.sort((m,g)=>o[m]-o[g]||d[g]-d[m]),p}addToSortKeyRanges(t,i){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===i?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const s=this.symbolInstances.get(i);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((o,d,p)=>{o>=0&&p.indexOf(o)===d&&this.addIndicesForPlacedSymbol(this.text,o)}),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 cd,hd;ze("SymbolBucket",io,{omit:["layers","collisionBoxArray","features","compareText"]}),io.MAX_GLYPHS=65535,io.addDynamicAttributes=Nh;var $h={get paint(){return hd=hd||new Pi({"icon-opacity":new Ve(ne.paint_symbol["icon-opacity"]),"icon-color":new Ve(ne.paint_symbol["icon-color"]),"icon-halo-color":new Ve(ne.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ve(ne.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ve(ne.paint_symbol["icon-halo-blur"]),"icon-translate":new Fe(ne.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fe(ne.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ve(ne.paint_symbol["text-opacity"]),"text-color":new Ve(ne.paint_symbol["text-color"],{runtimeType:hi,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new Ve(ne.paint_symbol["text-halo-color"]),"text-halo-width":new Ve(ne.paint_symbol["text-halo-width"]),"text-halo-blur":new Ve(ne.paint_symbol["text-halo-blur"]),"text-translate":new Fe(ne.paint_symbol["text-translate"]),"text-translate-anchor":new Fe(ne.paint_symbol["text-translate-anchor"])})},get layout(){return cd=cd||new Pi({"symbol-placement":new Fe(ne.layout_symbol["symbol-placement"]),"symbol-spacing":new Fe(ne.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fe(ne.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ve(ne.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fe(ne.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Fe(ne.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Fe(ne.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Fe(ne.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fe(ne.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fe(ne.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ve(ne.layout_symbol["icon-size"]),"icon-text-fit":new Fe(ne.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Fe(ne.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ve(ne.layout_symbol["icon-image"]),"icon-rotate":new Ve(ne.layout_symbol["icon-rotate"]),"icon-padding":new Ve(ne.layout_symbol["icon-padding"]),"icon-keep-upright":new Fe(ne.layout_symbol["icon-keep-upright"]),"icon-offset":new Ve(ne.layout_symbol["icon-offset"]),"icon-anchor":new Ve(ne.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fe(ne.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fe(ne.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fe(ne.layout_symbol["text-rotation-alignment"]),"text-field":new Ve(ne.layout_symbol["text-field"]),"text-font":new Ve(ne.layout_symbol["text-font"]),"text-size":new Ve(ne.layout_symbol["text-size"]),"text-max-width":new Ve(ne.layout_symbol["text-max-width"]),"text-line-height":new Fe(ne.layout_symbol["text-line-height"]),"text-letter-spacing":new Ve(ne.layout_symbol["text-letter-spacing"]),"text-justify":new Ve(ne.layout_symbol["text-justify"]),"text-radial-offset":new Ve(ne.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fe(ne.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ve(ne.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ve(ne.layout_symbol["text-anchor"]),"text-max-angle":new Fe(ne.layout_symbol["text-max-angle"]),"text-writing-mode":new Fe(ne.layout_symbol["text-writing-mode"]),"text-rotate":new Ve(ne.layout_symbol["text-rotate"]),"text-padding":new Fe(ne.layout_symbol["text-padding"]),"text-keep-upright":new Fe(ne.layout_symbol["text-keep-upright"]),"text-transform":new Ve(ne.layout_symbol["text-transform"]),"text-offset":new Ve(ne.layout_symbol["text-offset"]),"text-allow-overlap":new Fe(ne.layout_symbol["text-allow-overlap"]),"text-overlap":new Fe(ne.layout_symbol["text-overlap"]),"text-ignore-placement":new Fe(ne.layout_symbol["text-ignore-placement"]),"text-optional":new Fe(ne.layout_symbol["text-optional"])})}};class ud{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:Gn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(t.formattedSection))return i.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ze("FormatSectionOverride",ud,{omit:["defaultValue"]});class Ac extends Wi{constructor(t){super(t,$h)}recalculate(t,i){if(super.recalculate(t,i),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const o=[];for(const d of s)o.indexOf(d)<0&&o.push(d);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,i,s,o){const d=this.layout.get(t).evaluate(i,{},s,o),p=this._unevaluatedLayout._values[t];return p.isDataDriven()||ka(p.value)||!d?d:function(m,g){return g.replace(/{([^{}]+)}/g,(x,v)=>m&&v in m?String(m[v]):"")}(i.properties,d)}createBucket(t){return new io(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of $h.paint.overridableProperties){if(!Ac.hasPaintOverride(this.layout,t))continue;const i=this.paint.get(t),s=new ud(i),o=new Bo(s,i.property.specification);let d=null;d=i.value.kind==="constant"||i.value.kind==="source"?new Us("source",o):new Oo("composite",o,i.value.zoomStops),this.paint._values[t]=new Pr(i.property,d,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,s){return!(!this.layout||i.isDataDriven()||s.isDataDriven())&&Ac.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,i){const s=t.get("text-field"),o=$h.paint.properties[i];let d=!1;const p=m=>{for(const g of m)if(o.overrides&&o.overrides.hasOverride(g))return void(d=!0)};if(s.value.kind==="constant"&&s.value.value instanceof bi)p(s.value.value.sections);else if(s.value.kind==="source"||s.value.kind==="composite"){const m=x=>{d||(x instanceof Ir&&$e(x.value)===Hr?p(x.value.sections):x instanceof Tn?p(x.sections):x.eachChild(m))},g=s.value;g._styleExpression&&m(g._styleExpression.expression)}return d}}let dd;var Gf={get paint(){return dd=dd||new Pi({"background-color":new Fe(ne.paint_background["background-color"]),"background-pattern":new en(ne.paint_background["background-pattern"]),"background-opacity":new Fe(ne.paint_background["background-opacity"])})}};class qf extends Wi{constructor(t){super(t,Gf)}}let pd;var Wf={get paint(){return pd=pd||new Pi({"raster-opacity":new Fe(ne.paint_raster["raster-opacity"]),"raster-hue-rotate":new Fe(ne.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Fe(ne.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Fe(ne.paint_raster["raster-brightness-max"]),"raster-saturation":new Fe(ne.paint_raster["raster-saturation"]),"raster-contrast":new Fe(ne.paint_raster["raster-contrast"]),"raster-resampling":new Fe(ne.paint_raster["raster-resampling"]),"raster-fade-duration":new Fe(ne.paint_raster["raster-fade-duration"])})}};class Hf extends Wi{constructor(t){super(t,Wf)}}class Xf extends Wi{constructor(t){super(t,{}),this.onAdd=i=>{this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)},this.onRemove=i=>{this.implementation.onRemove&&this.implementation.onRemove(i,i.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 Yf{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Kf={once:!0},Zh=63710088e-1;class ys{constructor(t,i){if(isNaN(t)||isNaN(i))throw new Error(`Invalid LngLat object: (${t}, ${i})`);if(this.lng=+t,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ys(Nn(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const i=Math.PI/180,s=this.lat*i,o=t.lat*i,d=Math.sin(s)*Math.sin(o)+Math.cos(s)*Math.cos(o)*Math.cos((t.lng-this.lng)*i);return Zh*Math.acos(Math.min(d,1))}static convert(t){if(t instanceof ys)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new ys(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new ys(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>]")}}const fd=2*Math.PI*Zh;function md(r){return fd*Math.cos(r*Math.PI/180)}function gd(r){return(180+r)/360}function _d(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function yd(r,t){return r/md(t)}function Gh(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}function xd(r,t){return r*md(Gh(t))}class yl{constructor(t,i,s=0){this.x=+t,this.y=+i,this.z=+s}static fromLngLat(t,i=0){const s=ys.convert(t);return new yl(gd(s.lng),_d(s.lat),yd(i,s.lat))}toLngLat(){return new ys(360*this.x-180,Gh(this.y))}toAltitude(){return xd(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/fd*(t=Gh(this.y),1/Math.cos(t*Math.PI/180));var t}}function vd(r,t,i){var s=2*Math.PI*6378137/256/Math.pow(2,i);return[r*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class qh{constructor(t,i,s){if(!function(o,d,p){return!(o<0||o>25||p<0||p>=Math.pow(2,o)||d<0||d>=Math.pow(2,o))}(t,i,s))throw new Error(`x=${i}, 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=i,this.y=s,this.key=ro(0,t,t,i,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,i,s){const o=(p=this.y,m=this.z,g=vd(256*(d=this.x),256*(p=Math.pow(2,m)-p-1),m),x=vd(256*(d+1),256*(p+1),m),g[0]+","+g[1]+","+x[0]+","+x[1]);var d,p,m,g,x;const v=function(T,M,E){let A,L="";for(let F=T;F>0;F--)A=1<<F-1,L+=(M&A?1:0)+(E&A?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,i>1?"@2x":"").replace(/{quadkey}/g,v).replace(/{bbox-epsg-3857}/g,o)}isChildOf(t){const i=this.z-t.z;return i>0&&t.x===this.x>>i&&t.y===this.y>>i}getTilePoint(t){const i=Math.pow(2,this.z);return new be((t.x*i-this.x)*gt,(t.y*i-this.y)*gt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class bd{constructor(t,i){this.wrap=t,this.canonical=i,this.key=ro(t,i.z,i.z,i.x,i.y)}}class cr{constructor(t,i,s,o,d){if(this.terrainRttPosMatrix32f=null,t<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=i,this.canonical=new qh(s,+o,+d),this.key=ro(i,t,s,o,d)}clone(){return new cr(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?new cr(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new cr(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(t,i){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-t;return t>this.canonical.z?ro(this.wrap*+i,t,this.canonical.z,this.canonical.x,this.canonical.y):ro(this.wrap*+i,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const i=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>i&&t.canonical.y===this.canonical.y>>i}children(t){if(this.overscaledZ>=t)return[new cr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,s=2*this.canonical.x,o=2*this.canonical.y;return[new cr(i,this.wrap,i,s,o),new cr(i,this.wrap,i,s+1,o),new cr(i,this.wrap,i,s,o+1),new cr(i,this.wrap,i,s+1,o+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 cr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new cr(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 bd(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new yl(t.x-this.wrap,t.y))}}function ro(r,t,i,s,o){(r*=2)<0&&(r=-1*r-1);const d=1<<i;return(d*d*r+d*o+s).toString(36)+i.toString(36)+t.toString(36)}function xl(r,t){return t?r.properties[t]:r.id}ze("CanonicalTileID",qh),ze("OverscaledTileID",cr,{omit:["terrainRttPosMatrix32f"]});class ta{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(t){return this.expandBy(-t)}map(t){const i=new ta;return i.extend(t(new be(this.minX,this.minY))),i.extend(t(new be(this.maxX,this.minY))),i.extend(t(new be(this.minX,this.maxY))),i.extend(t(new be(this.maxX,this.maxY))),i}static fromPoints(t){const i=new ta;for(const s of t)i.extend(s);return i}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}}class wd{constructor(t){this._stringToNumber={},this._numberToString=[];for(let i=0;i<t.length;i++){const s=t[i];this._stringToNumber[s]=i,this._numberToString[i]=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,i,s,o,d){this.type="Feature",this._vectorTileFeature=t,t._z=i,t._x=s,t._y=o,this.properties=t.properties,this.id=d}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const i in this)i!=="_geometry"&&i!=="_vectorTileFeature"&&(t[i]=this[i]);return t}}class Pd{constructor(t,i){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Xs(gt,16,0),this.grid3D=new Xs(gt,16,0),this.featureIndexArray=new K,this.promoteId=i}insert(t,i,s,o,d,p){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,o,d);const g=p?this.grid3D:this.grid;for(let x=0;x<i.length;x++){const v=i[x],T=[1/0,1/0,-1/0,-1/0];for(let M=0;M<v.length;M++){const E=v[M];T[0]=Math.min(T[0],E.x),T[1]=Math.min(T[1],E.y),T[2]=Math.max(T[2],E.x),T[3]=Math.max(T[3],E.y)}T[0]<gt&&T[1]<gt&&T[2]>=0&&T[3]>=0&&g.insert(m,T[0],T[1],T[2],T[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Nu(new Rh(this.rawTileData)).layers,this.sourceLayerCoder=new wd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,i,s,o){this.loadVTLayers();const d=t.params,p=gt/t.tileSize/t.scale,m=En(d.filter),g=t.queryGeometry,x=t.queryPadding*p,v=ta.fromPoints(g),T=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),M=ta.fromPoints(t.cameraQueryGeometry).expandBy(x),E=this.grid3D.query(M.minX,M.minY,M.maxX,M.maxY,(F,V,Q,W)=>function(X,ce,pe,xe,Ae){for(const Ie of X)if(ce<=Ie.x&&pe<=Ie.y&&xe>=Ie.x&&Ae>=Ie.y)return!0;const Pe=[new be(ce,pe),new be(ce,Ae),new be(xe,Ae),new be(xe,pe)];if(X.length>2){for(const Ie of Pe)if(Xa(X,Ie))return!0}for(let Ie=0;Ie<X.length-1;Ie++)if(Cp(X[Ie],X[Ie+1],Pe))return!0;return!1}(t.cameraQueryGeometry,F-x,V-x,Q+x,W+x));for(const F of E)T.push(F);T.sort(Jf);const A={};let L;for(let F=0;F<T.length;F++){const V=T[F];if(V===L)continue;L=V;const Q=this.featureIndexArray.get(V);let W=null;this.loadMatchingFeature(A,Q.bucketIndex,Q.sourceLayerIndex,Q.featureIndex,m,d.layers,d.availableImages,i,s,o,(X,ce,pe)=>(W||(W=an(X)),ce.queryIntersectsFeature({queryGeometry:g,feature:X,featureState:pe,geometry:W,zoom:this.z,transform:t.transform,pixelsToTileUnits:p,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation})))}return A}loadMatchingFeature(t,i,s,o,d,p,m,g,x,v,T){const M=this.bucketLayerIDs[i];if(p&&!M.some(F=>p.has(F)))return;const E=this.sourceLayerCoder.decode(s),A=this.vtLayers[E].feature(o);if(d.needGeometry){const F=kr(A,!0);if(!d.filter(new wt(this.tileID.overscaledZ),F,this.tileID.canonical))return}else if(!d.filter(new wt(this.tileID.overscaledZ),A))return;const L=this.getId(A,E);for(let F=0;F<M.length;F++){const V=M[F];if(p&&!p.has(V))continue;const Q=g[V];if(!Q)continue;let W={};L&&v&&(W=v.getState(Q.sourceLayer||"_geojsonTileLayer",L));const X=Zi({},x[V]);X.paint=Sd(X.paint,Q.paint,A,W,m),X.layout=Sd(X.layout,Q.layout,A,W,m);const ce=!T||T(A,Q,W);if(!ce)continue;const pe=new Td(A,this.z,this.x,this.y,L);pe.layer=X;let xe=t[V];xe===void 0&&(xe=t[V]=[]),xe.push({featureIndex:o,feature:pe,intersectionZ:ce})}}lookupSymbolFeatures(t,i,s,o,d,p,m,g){const x={};this.loadVTLayers();const v=En(d);for(const T of t)this.loadMatchingFeature(x,s,o,T,v,p,m,g,i);return x}hasLayer(t){for(const i of this.bucketLayerIDs)for(const s of i)if(t===s)return!0;return!1}getId(t,i){var s;let o=t.id;return this.promoteId&&(o=t.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[i]],typeof o=="boolean"&&(o=Number(o)),o===void 0&&(!((s=t.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(o=Number(t.properties.cluster_id))),o}}function Sd(r,t,i,s,o){return Vn(r,(d,p)=>{const m=t instanceof Va?t.get(p):null;return m&&m.evaluate?m.evaluate(i,s,o):m})}function Jf(r,t){return t-r}function Md(r,t,i,s,o){const d=[];for(let p=0;p<r.length;p++){const m=r[p];let g;for(let x=0;x<m.length-1;x++){let v=m[x],T=m[x+1];v.x<t&&T.x<t||(v.x<t?v=new be(t,v.y+(t-v.x)/(T.x-v.x)*(T.y-v.y))._round():T.x<t&&(T=new be(t,v.y+(t-v.x)/(T.x-v.x)*(T.y-v.y))._round()),v.y<i&&T.y<i||(v.y<i?v=new be(v.x+(i-v.y)/(T.y-v.y)*(T.x-v.x),i)._round():T.y<i&&(T=new be(v.x+(i-v.y)/(T.y-v.y)*(T.x-v.x),i)._round()),v.x>=s&&T.x>=s||(v.x>=s?v=new be(s,v.y+(s-v.x)/(T.x-v.x)*(T.y-v.y))._round():T.x>=s&&(T=new be(s,v.y+(s-v.x)/(T.x-v.x)*(T.y-v.y))._round()),v.y>=o&&T.y>=o||(v.y>=o?v=new be(v.x+(o-v.y)/(T.y-v.y)*(T.x-v.x),o)._round():T.y>=o&&(T=new be(v.x+(o-v.y)/(T.y-v.y)*(T.x-v.x),o)._round()),g&&v.equals(g[g.length-1])||(g=[v],d.push(g)),g.push(T)))))}}return d}ze("FeatureIndex",Pd,{omit:["rawTileData","sourceLayerCoder"]});class xs extends be{constructor(t,i,s,o){super(t,i),this.angle=s,o!==void 0&&(this.segment=o)}clone(){return new xs(this.x,this.y,this.angle,this.segment)}}function Id(r,t,i,s,o){if(t.segment===void 0||i===0)return!0;let d=t,p=t.segment+1,m=0;for(;m>-i/2;){if(p--,p<0)return!1;m-=r[p].dist(d),d=r[p]}m+=r[p].dist(r[p+1]),p++;const g=[];let x=0;for(;m<i/2;){const v=r[p],T=r[p+1];if(!T)return!1;let M=r[p-1].angleTo(v)-v.angleTo(T);for(M=Math.abs((M+3*Math.PI)%(2*Math.PI)-Math.PI),g.push({distance:m,angleDelta:M}),x+=M;m-g[0].distance>s;)x-=g.shift().angleDelta;if(x>o)return!1;p++,m+=v.dist(T)}return!0}function Cd(r){let t=0;for(let i=0;i<r.length-1;i++)t+=r[i].dist(r[i+1]);return t}function Ed(r,t,i){return r?.6*t*i:0}function Ad(r,t){return Math.max(r?r.right-r.left:0,t?t.right-t.left:0)}function Qf(r,t,i,s,o,d){const p=Ed(i,o,d),m=Ad(i,s)*d;let g=0;const x=Cd(r)/2;for(let v=0;v<r.length-1;v++){const T=r[v],M=r[v+1],E=T.dist(M);if(g+E>x){const A=(x-g)/E,L=wr.number(T.x,M.x,A),F=wr.number(T.y,M.y,A),V=new xs(L,F,M.angleTo(T),v);return V._round(),!p||Id(r,V,m,p,t)?V:void 0}g+=E}}function em(r,t,i,s,o,d,p,m,g){const x=Ed(s,d,p),v=Ad(s,o),T=v*p,M=r[0].x===0||r[0].x===g||r[0].y===0||r[0].y===g;return t-T<t/4&&(t=T+t/4),kd(r,M?t/2*m%t:(v/2+2*d)*p*m%t,t,x,i,T,M,!1,g)}function kd(r,t,i,s,o,d,p,m,g){const x=d/2,v=Cd(r);let T=0,M=t-i,E=[];for(let A=0;A<r.length-1;A++){const L=r[A],F=r[A+1],V=L.dist(F),Q=F.angleTo(L);for(;M+i<T+V;){M+=i;const W=(M-T)/V,X=wr.number(L.x,F.x,W),ce=wr.number(L.y,F.y,W);if(X>=0&&X<g&&ce>=0&&ce<g&&M-x>=0&&M+x<=v){const pe=new xs(X,ce,Q,A);pe._round(),s&&!Id(r,pe,d,s,o)||E.push(pe)}}T+=V}return m||E.length||p||(E=kd(r,T/2,i,s,o,d,p,!0,g)),E}function zd(r,t,i,s){const o=[],d=r.image,p=d.pixelRatio,m=d.paddedRect.w-2,g=d.paddedRect.h-2;let x={x1:r.left,y1:r.top,x2:r.right,y2:r.bottom};const v=d.stretchX||[[0,m]],T=d.stretchY||[[0,g]],M=(ge,Ze)=>ge+Ze[1]-Ze[0],E=v.reduce(M,0),A=T.reduce(M,0),L=m-E,F=g-A;let V=0,Q=E,W=0,X=A,ce=0,pe=L,xe=0,Ae=F;if(d.content&&s){const ge=d.content,Ze=ge[2]-ge[0],Ge=ge[3]-ge[1];(d.textFitWidth||d.textFitHeight)&&(x=ad(r)),V=kc(v,0,ge[0]),W=kc(T,0,ge[1]),Q=kc(v,ge[0],ge[2]),X=kc(T,ge[1],ge[3]),ce=ge[0]-V,xe=ge[1]-W,pe=Ze-Q,Ae=Ge-X}const Pe=x.x1,Ie=x.y1,Be=x.x2-Pe,Me=x.y2-Ie,Ce=(ge,Ze,Ge,Ne)=>{const De=zc(ge.stretch-V,Q,Be,Pe),at=Lc(ge.fixed-ce,pe,ge.stretch,E),Lt=zc(Ze.stretch-W,X,Me,Ie),Jt=Lc(Ze.fixed-xe,Ae,Ze.stretch,A),vi=zc(Ge.stretch-V,Q,Be,Pe),hr=Lc(Ge.fixed-ce,pe,Ge.stretch,E),Vi=zc(Ne.stretch-W,X,Me,Ie),di=Lc(Ne.fixed-xe,Ae,Ne.stretch,A),Et=new be(De,Lt),si=new be(vi,Lt),pi=new be(vi,Vi),fi=new be(De,Vi),Di=new be(at/p,Jt/p),ur=new be(hr/p,di/p),ai=t*Math.PI/180;if(ai){const oi=Math.sin(ai),li=Math.cos(ai),Wt=[li,-oi,oi,li];Et._matMult(Wt),si._matMult(Wt),fi._matMult(Wt),pi._matMult(Wt)}const Ui=ge.stretch+ge.fixed,Qt=Ze.stretch+Ze.fixed;return{tl:Et,tr:si,bl:fi,br:pi,tex:{x:d.paddedRect.x+1+Ui,y:d.paddedRect.y+1+Qt,w:Ge.stretch+Ge.fixed-Ui,h:Ne.stretch+Ne.fixed-Qt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Di,pixelOffsetBR:ur,minFontScaleX:pe/p/Be,minFontScaleY:Ae/p/Me,isSDF:i}};if(s&&(d.stretchX||d.stretchY)){const ge=Ld(v,L,E),Ze=Ld(T,F,A);for(let Ge=0;Ge<ge.length-1;Ge++){const Ne=ge[Ge],De=ge[Ge+1];for(let at=0;at<Ze.length-1;at++)o.push(Ce(Ne,Ze[at],De,Ze[at+1]))}}else o.push(Ce({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:m+1},{fixed:0,stretch:g+1}));return o}function kc(r,t,i){let s=0;for(const o of r)s+=Math.max(t,Math.min(i,o[1]))-Math.max(t,Math.min(i,o[0]));return s}function Ld(r,t,i){const s=[{fixed:-1,stretch:0}];for(const[o,d]of r){const p=s[s.length-1];s.push({fixed:o-p.stretch,stretch:p.stretch}),s.push({fixed:o-p.stretch,stretch:p.stretch+(d-o)})}return s.push({fixed:t+1,stretch:i}),s}function zc(r,t,i,s){return r/t*i+s}function Lc(r,t,i,s){return r-t*i/s}ze("Anchor",xs);class Dc{constructor(t,i,s,o,d,p,m,g,x,v){var T;if(this.boxStartIndex=t.length,x){let M=p.top,E=p.bottom;const A=p.collisionPadding;A&&(M-=A[1],E+=A[3]);let L=E-M;L>0&&(L=Math.max(10,L),this.circleDiameter=L)}else{const M=!((T=p.image)===null||T===void 0)&&T.content&&(p.image.textFitWidth||p.image.textFitHeight)?ad(p):{x1:p.left,y1:p.top,x2:p.right,y2:p.bottom};M.y1=M.y1*m-g[0],M.y2=M.y2*m+g[2],M.x1=M.x1*m-g[3],M.x2=M.x2*m+g[1];const E=p.collisionPadding;if(E&&(M.x1-=E[0]*m,M.y1-=E[1]*m,M.x2+=E[2]*m,M.y2+=E[3]*m),v){const A=new be(M.x1,M.y1),L=new be(M.x2,M.y1),F=new be(M.x1,M.y2),V=new be(M.x2,M.y2),Q=v*Math.PI/180;A._rotate(Q),L._rotate(Q),F._rotate(Q),V._rotate(Q),M.x1=Math.min(A.x,L.x,F.x,V.x),M.x2=Math.max(A.x,L.x,F.x,V.x),M.y1=Math.min(A.y,L.y,F.y,V.y),M.y2=Math.max(A.y,L.y,F.y,V.y)}t.emplaceBack(i.x,i.y,M.x1,M.y1,M.x2,M.y2,s,o,d)}this.boxEndIndex=t.length}}class tm{constructor(t=[],i=(s,o)=>s<o?-1:s>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=i,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:i,compare:s}=this,o=i[t];for(;t>0;){const d=t-1>>1,p=i[d];if(s(o,p)>=0)break;i[t]=p,t=d}i[t]=o}_down(t){const{data:i,compare:s}=this,o=this.length>>1,d=i[t];for(;t<o;){let p=1+(t<<1);const m=p+1;if(m<this.length&&s(i[m],i[p])<0&&(p=m),s(i[p],d)>=0)break;i[t]=i[p],t=p}i[t]=d}}function im(r,t=1,i=!1){const s=ta.fromPoints(r[0]),o=Math.min(s.width(),s.height());let d=o/2;const p=new tm([],rm),{minX:m,minY:g,maxX:x,maxY:v}=s;if(o===0)return new be(m,g);for(let E=m;E<x;E+=o)for(let A=g;A<v;A+=o)p.push(new no(E+d,A+d,d,r));let T=function(E){let A=0,L=0,F=0;const V=E[0];for(let Q=0,W=V.length,X=W-1;Q<W;X=Q++){const ce=V[Q],pe=V[X],xe=ce.x*pe.y-pe.x*ce.y;L+=(ce.x+pe.x)*xe,F+=(ce.y+pe.y)*xe,A+=3*xe}return new no(L/A,F/A,0,E)}(r),M=p.length;for(;p.length;){const E=p.pop();(E.d>T.d||!T.d)&&(T=E,i&&console.log("found best %d after %d probes",Math.round(1e4*E.d)/1e4,M)),E.max-T.d<=t||(d=E.h/2,p.push(new no(E.p.x-d,E.p.y-d,d,r)),p.push(new no(E.p.x+d,E.p.y-d,d,r)),p.push(new no(E.p.x-d,E.p.y+d,d,r)),p.push(new no(E.p.x+d,E.p.y+d,d,r)),M+=4)}return i&&(console.log(`num probes: ${M}`),console.log(`best distance: ${T.d}`)),T.p}function rm(r,t){return t.max-r.max}function no(r,t,i,s){this.p=new be(r,t),this.h=i,this.d=function(o,d){let p=!1,m=1/0;for(let g=0;g<d.length;g++){const x=d[g];for(let v=0,T=x.length,M=T-1;v<T;M=v++){const E=x[v],A=x[M];E.y>o.y!=A.y>o.y&&o.x<(A.x-E.x)*(o.y-E.y)/(A.y-E.y)+E.x&&(p=!p),m=Math.min(m,_u(o,E,A))}}return(p?1:-1)*Math.sqrt(m)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}var xi;C.aE=void 0,(xi=C.aE||(C.aE={}))[xi.center=1]="center",xi[xi.left=2]="left",xi[xi.right=3]="right",xi[xi.top=4]="top",xi[xi.bottom=5]="bottom",xi[xi["top-left"]=6]="top-left",xi[xi["top-right"]=7]="top-right",xi[xi["bottom-left"]=8]="bottom-left",xi[xi["bottom-right"]=9]="bottom-right";const Wh=Number.POSITIVE_INFINITY;function Dd(r,t){return t[1]!==Wh?function(i,s,o){let d=0,p=0;switch(s=Math.abs(s),o=Math.abs(o),i){case"top-right":case"top-left":case"top":p=o-7;break;case"bottom-right":case"bottom-left":case"bottom":p=7-o}switch(i){case"top-right":case"bottom-right":case"right":d=-s;break;case"top-left":case"bottom-left":case"left":d=s}return[d,p]}(r,t[0],t[1]):function(i,s){let o=0,d=0;s<0&&(s=0);const p=s/Math.SQRT2;switch(i){case"top-right":case"top-left":d=p-7;break;case"bottom-right":case"bottom-left":d=7-p;break;case"bottom":d=7-s;break;case"top":d=s-7}switch(i){case"top-right":case"bottom-right":o=-p;break;case"top-left":case"bottom-left":o=p;break;case"left":o=s;break;case"right":o=-s}return[o,d]}(r,t[0])}function Rd(r,t,i){var s;const o=r.layout,d=(s=o.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},i);if(d){const m=d.values,g=[];for(let x=0;x<m.length;x+=2){const v=g[x]=m[x],T=m[x+1].map(M=>M*ni);v.startsWith("top")?T[1]-=7:v.startsWith("bottom")&&(T[1]+=7),g[x+1]=T}return new Ti(g)}const p=o.get("text-variable-anchor");if(p){let m;m=r._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[o.get("text-radial-offset").evaluate(t,{},i)*ni,Wh]:o.get("text-offset").evaluate(t,{},i).map(x=>x*ni);const g=[];for(const x of p)g.push(x,Dd(x,m));return new Ti(g)}return null}function Hh(r){switch(r){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function nm(r,t,i,s,o,d,p,m,g,x,v,T){let M=d.textMaxSize.evaluate(t,{});M===void 0&&(M=p);const E=r.layers[0].layout,A=E.get("icon-offset").evaluate(t,{},v),L=Bd(i.horizontal),F=p/24,V=r.tilePixelRatio*F,Q=r.tilePixelRatio*M/24,W=r.tilePixelRatio*m,X=r.tilePixelRatio*E.get("symbol-spacing"),ce=E.get("text-padding")*r.tilePixelRatio,pe=function(Ge,Ne,De,at=1){const Lt=Ge.get("icon-padding").evaluate(Ne,{},De),Jt=Lt&&Lt.values;return[Jt[0]*at,Jt[1]*at,Jt[2]*at,Jt[3]*at]}(E,t,v,r.tilePixelRatio),xe=E.get("text-max-angle")/180*Math.PI,Ae=E.get("text-rotation-alignment")!=="viewport"&&E.get("symbol-placement")!=="point",Pe=E.get("icon-rotation-alignment")==="map"&&E.get("symbol-placement")!=="point",Ie=E.get("symbol-placement"),Be=X/2,Me=E.get("icon-text-fit");let Ce;s&&Me!=="none"&&(r.allowVerticalPlacement&&i.vertical&&(Ce=od(s,i.vertical,Me,E.get("icon-text-fit-padding"),A,F)),L&&(s=od(s,L,Me,E.get("icon-text-fit-padding"),A,F)));const ge=v?T.line.getGranularityForZoomLevel(v.z):1,Ze=(Ge,Ne)=>{Ne.x<0||Ne.x>=gt||Ne.y<0||Ne.y>=gt||function(De,at,Lt,Jt,vi,hr,Vi,di,Et,si,pi,fi,Di,ur,ai,Ui,Qt,oi,li,Wt,St,zr,so,Lr,om){const ao=De.addToLineVertexArray(at,Lt);let ia,oo,lo,co,Vd=0,Ud=0,$d=0,Zd=0,iu=-1,ru=-1;const On={};let Gd=fs("");if(De.allowVerticalPlacement&&Jt.vertical){const Ii=di.layout.get("text-rotate").evaluate(St,{},Lr)+90;lo=new Dc(Et,at,si,pi,fi,Jt.vertical,Di,ur,ai,Ii),Vi&&(co=new Dc(Et,at,si,pi,fi,Vi,Qt,oi,ai,Ii))}if(vi){const Ii=di.layout.get("icon-rotate").evaluate(St,{}),dr=di.layout.get("icon-text-fit")!=="none",ra=zd(vi,Ii,so,dr),Rr=Vi?zd(Vi,Ii,so,dr):void 0;oo=new Dc(Et,at,si,pi,fi,vi,Qt,oi,!1,Ii),Vd=4*ra.length;const na=De.iconSizeData;let on=null;na.kind==="source"?(on=[Bn*di.layout.get("icon-size").evaluate(St,{})],on[0]>_s&&jt(`${De.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):na.kind==="composite"&&(on=[Bn*zr.compositeIconSizes[0].evaluate(St,{},Lr),Bn*zr.compositeIconSizes[1].evaluate(St,{},Lr)],(on[0]>_s||on[1]>_s)&&jt(`${De.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),De.addSymbols(De.icon,ra,on,Wt,li,St,C.ao.none,at,ao.lineStartIndex,ao.lineLength,-1,Lr),iu=De.icon.placedSymbolArray.length-1,Rr&&(Ud=4*Rr.length,De.addSymbols(De.icon,Rr,on,Wt,li,St,C.ao.vertical,at,ao.lineStartIndex,ao.lineLength,-1,Lr),ru=De.icon.placedSymbolArray.length-1)}const qd=Object.keys(Jt.horizontal);for(const Ii of qd){const dr=Jt.horizontal[Ii];if(!ia){Gd=fs(dr.text);const Rr=di.layout.get("text-rotate").evaluate(St,{},Lr);ia=new Dc(Et,at,si,pi,fi,dr,Di,ur,ai,Rr)}const ra=dr.positionedLines.length===1;if($d+=Fd(De,at,dr,hr,di,ai,St,Ui,ao,Jt.vertical?C.ao.horizontal:C.ao.horizontalOnly,ra?qd:[Ii],On,iu,zr,Lr),ra)break}Jt.vertical&&(Zd+=Fd(De,at,Jt.vertical,hr,di,ai,St,Ui,ao,C.ao.vertical,["vertical"],On,ru,zr,Lr));const lm=ia?ia.boxStartIndex:De.collisionBoxArray.length,cm=ia?ia.boxEndIndex:De.collisionBoxArray.length,hm=lo?lo.boxStartIndex:De.collisionBoxArray.length,um=lo?lo.boxEndIndex:De.collisionBoxArray.length,dm=oo?oo.boxStartIndex:De.collisionBoxArray.length,pm=oo?oo.boxEndIndex:De.collisionBoxArray.length,fm=co?co.boxStartIndex:De.collisionBoxArray.length,mm=co?co.boxEndIndex:De.collisionBoxArray.length;let Dr=-1;const Fc=(Ii,dr)=>Ii&&Ii.circleDiameter?Math.max(Ii.circleDiameter,dr):dr;Dr=Fc(ia,Dr),Dr=Fc(lo,Dr),Dr=Fc(oo,Dr),Dr=Fc(co,Dr);const Wd=Dr>-1?1:0;Wd&&(Dr*=om/ni),De.glyphOffsetArray.length>=io.MAX_GLYPHS&&jt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),St.sortKey!==void 0&&De.addToSortKeyRanges(De.symbolInstances.length,St.sortKey);const gm=Rd(di,St,Lr),[_m,ym]=function(Ii,dr){const ra=Ii.length,Rr=dr==null?void 0:dr.values;if((Rr==null?void 0:Rr.length)>0)for(let na=0;na<Rr.length;na+=2){const on=Rr[na+1];Ii.emplaceBack(C.aE[Rr[na]],on[0],on[1])}return[ra,Ii.length]}(De.textAnchorOffsets,gm);De.symbolInstances.emplaceBack(at.x,at.y,On.right>=0?On.right:-1,On.center>=0?On.center:-1,On.left>=0?On.left:-1,On.vertical||-1,iu,ru,Gd,lm,cm,hm,um,dm,pm,fm,mm,si,$d,Zd,Vd,Ud,Wd,0,Di,Dr,_m,ym)}(r,Ne,Ge,i,s,o,Ce,r.layers[0],r.collisionBoxArray,t.index,t.sourceLayerIndex,r.index,V,[ce,ce,ce,ce],Ae,g,W,pe,Pe,A,t,d,x,v,p)};if(Ie==="line")for(const Ge of Md(t.geometry,0,0,gt,gt)){const Ne=ea(Ge,ge),De=em(Ne,X,xe,i.vertical||L,s,24,Q,r.overscaling,gt);for(const at of De)L&&sm(r,L.text,Be,at)||Ze(Ne,at)}else if(Ie==="line-center"){for(const Ge of t.geometry)if(Ge.length>1){const Ne=ea(Ge,ge),De=Qf(Ne,xe,i.vertical||L,s,24,Q);De&&Ze(Ne,De)}}else if(t.type==="Polygon")for(const Ge of Bs(t.geometry,0)){const Ne=im(Ge,16);Ze(ea(Ge[0],ge,!0),new xs(Ne.x,Ne.y,0))}else if(t.type==="LineString")for(const Ge of t.geometry){const Ne=ea(Ge,ge);Ze(Ne,new xs(Ne[0].x,Ne[0].y,0))}else if(t.type==="Point")for(const Ge of t.geometry)for(const Ne of Ge)Ze([Ne],new xs(Ne.x,Ne.y,0))}function Fd(r,t,i,s,o,d,p,m,g,x,v,T,M,E,A){const L=function(Q,W,X,ce,pe,xe,Ae,Pe){const Ie=ce.layout.get("text-rotate").evaluate(xe,{})*Math.PI/180,Be=[];for(const Me of W.positionedLines)for(const Ce of Me.positionedGlyphs){if(!Ce.rect)continue;const ge=Ce.rect||{};let Ze=4,Ge=!0,Ne=1,De=0;const at=(pe||Pe)&&Ce.vertical,Lt=Ce.metrics.advance*Ce.scale/2;if(Pe&&W.verticalizable&&(De=Me.lineOffset/2-(Ce.imageName?-(ni-Ce.metrics.width*Ce.scale)/2:(Ce.scale-1)*ni)),Ce.imageName){const oi=Ae[Ce.imageName];Ge=oi.sdf,Ne=oi.pixelRatio,Ze=1/Ne}const Jt=pe?[Ce.x+Lt,Ce.y]:[0,0];let vi=pe?[0,0]:[Ce.x+Lt+X[0],Ce.y+X[1]-De],hr=[0,0];at&&(hr=vi,vi=[0,0]);const Vi=Ce.metrics.isDoubleResolution?2:1,di=(Ce.metrics.left-Ze)*Ce.scale-Lt+vi[0],Et=(-Ce.metrics.top-Ze)*Ce.scale+vi[1],si=di+ge.w/Vi*Ce.scale/Ne,pi=Et+ge.h/Vi*Ce.scale/Ne,fi=new be(di,Et),Di=new be(si,Et),ur=new be(di,pi),ai=new be(si,pi);if(at){const oi=new be(-Lt,Lt- -17),li=-Math.PI/2,Wt=12-Lt,St=new be(22-Wt,-(Ce.imageName?Wt:0)),zr=new be(...hr);fi._rotateAround(li,oi)._add(St)._add(zr),Di._rotateAround(li,oi)._add(St)._add(zr),ur._rotateAround(li,oi)._add(St)._add(zr),ai._rotateAround(li,oi)._add(St)._add(zr)}if(Ie){const oi=Math.sin(Ie),li=Math.cos(Ie),Wt=[li,-oi,oi,li];fi._matMult(Wt),Di._matMult(Wt),ur._matMult(Wt),ai._matMult(Wt)}const Ui=new be(0,0),Qt=new be(0,0);Be.push({tl:fi,tr:Di,bl:ur,br:ai,tex:ge,writingMode:W.writingMode,glyphOffset:Jt,sectionIndex:Ce.sectionIndex,isSDF:Ge,pixelOffsetTL:Ui,pixelOffsetBR:Qt,minFontScaleX:0,minFontScaleY:0})}return Be}(0,i,m,o,d,p,s,r.allowVerticalPlacement),F=r.textSizeData;let V=null;F.kind==="source"?(V=[Bn*o.layout.get("text-size").evaluate(p,{})],V[0]>_s&&jt(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):F.kind==="composite"&&(V=[Bn*E.compositeTextSizes[0].evaluate(p,{},A),Bn*E.compositeTextSizes[1].evaluate(p,{},A)],(V[0]>_s||V[1]>_s)&&jt(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),r.addSymbols(r.text,L,V,m,d,p,x,t,g.lineStartIndex,g.lineLength,M,A);for(const Q of v)T[Q]=r.text.placedSymbolArray.length-1;return 4*L.length}function Bd(r){for(const t in r)return r[t];return null}function sm(r,t,i,s){const o=r.compareText;if(t in o){const d=o[t];for(let p=d.length-1;p>=0;p--)if(s.dist(d[p])<i)return!0}else o[t]=[];return o[t].push(s),!1}const Od=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Xh{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,s]=new Uint8Array(t,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const o=s>>4;if(o!==1)throw new Error(`Got v${o} data when expected v1.`);const d=Od[15&s];if(!d)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(t,2,1),[m]=new Uint32Array(t,4,1);return new Xh(m,p,d,t)}constructor(t,i=64,s=Float64Array,o){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const d=Od.indexOf(this.ArrayType),p=2*t*this.ArrayType.BYTES_PER_ELEMENT,m=t*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-m%8)%8;if(d<0)throw new Error(`Unexpected typed array class: ${s}.`);o&&o instanceof ArrayBuffer?(this.data=o,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+m+g,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+p+m+g),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+m+g,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+d]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=t)}add(t,i){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=i,s}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Yh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,s,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:d,coords:p,nodeSize:m}=this,g=[0,d.length-1,0],x=[];for(;g.length;){const v=g.pop()||0,T=g.pop()||0,M=g.pop()||0;if(T-M<=m){for(let F=M;F<=T;F++){const V=p[2*F],Q=p[2*F+1];V>=t&&V<=s&&Q>=i&&Q<=o&&x.push(d[F])}continue}const E=M+T>>1,A=p[2*E],L=p[2*E+1];A>=t&&A<=s&&L>=i&&L<=o&&x.push(d[E]),(v===0?t<=A:i<=L)&&(g.push(M),g.push(E-1),g.push(1-v)),(v===0?s>=A:o>=L)&&(g.push(E+1),g.push(T),g.push(1-v))}return x}within(t,i,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:d,nodeSize:p}=this,m=[0,o.length-1,0],g=[],x=s*s;for(;m.length;){const v=m.pop()||0,T=m.pop()||0,M=m.pop()||0;if(T-M<=p){for(let F=M;F<=T;F++)Nd(d[2*F],d[2*F+1],t,i)<=x&&g.push(o[F]);continue}const E=M+T>>1,A=d[2*E],L=d[2*E+1];Nd(A,L,t,i)<=x&&g.push(o[E]),(v===0?t-s<=A:i-s<=L)&&(m.push(M),m.push(E-1),m.push(1-v)),(v===0?t+s>=A:i+s>=L)&&(m.push(E+1),m.push(T),m.push(1-v))}return g}}function Yh(r,t,i,s,o,d){if(o-s<=i)return;const p=s+o>>1;jd(r,t,p,s,o,d),Yh(r,t,i,s,p-1,1-d),Yh(r,t,i,p+1,o,1-d)}function jd(r,t,i,s,o,d){for(;o>s;){if(o-s>600){const x=o-s+1,v=i-s+1,T=Math.log(x),M=.5*Math.exp(2*T/3),E=.5*Math.sqrt(T*M*(x-M)/x)*(v-x/2<0?-1:1);jd(r,t,i,Math.max(s,Math.floor(i-v*M/x+E)),Math.min(o,Math.floor(i+(x-v)*M/x+E)),d)}const p=t[2*i+d];let m=s,g=o;for(vl(r,t,s,i),t[2*o+d]>p&&vl(r,t,s,o);m<g;){for(vl(r,t,m,g),m++,g--;t[2*m+d]<p;)m++;for(;t[2*g+d]>p;)g--}t[2*s+d]===p?vl(r,t,s,g):(g++,vl(r,t,g,o)),g<=i&&(s=g+1),i<=g&&(o=g-1)}}function vl(r,t,i,s){Kh(r,i,s),Kh(t,2*i,2*s),Kh(t,2*i+1,2*s+1)}function Kh(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}function Nd(r,t,i,s){const o=r-i,d=t-s;return o*o+d*d}var Jh;C.cx=void 0,(Jh=C.cx||(C.cx={})).create="create",Jh.load="load",Jh.fullLoad="fullLoad";let Rc=null,bl=[];const Qh=1e3/60,eu="loadTime",tu="fullLoadTime",am={mark(r){performance.mark(r)},frame(r){const t=r;Rc!=null&&bl.push(t-Rc),Rc=t},clearMetrics(){Rc=null,bl=[],performance.clearMeasures(eu),performance.clearMeasures(tu);for(const r in C.cx)performance.clearMarks(C.cx[r])},getPerformanceMetrics(){performance.measure(eu,C.cx.create,C.cx.load),performance.measure(tu,C.cx.create,C.cx.fullLoad);const r=performance.getEntriesByName(eu)[0].duration,t=performance.getEntriesByName(tu)[0].duration,i=bl.length,s=1/(bl.reduce((d,p)=>d+p,0)/i/1e3),o=bl.filter(d=>d>Qh).reduce((d,p)=>d+(p-Qh)/Qh,0);return{loadTime:r,fullLoadTime:t,fps:s,percentDroppedFrames:o/(i+o)*100,totalFrames:i}}};C.$=gt,C.A=ft,C.B=function([r,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:r*Math.cos(t)*Math.sin(i),y:r*Math.sin(t)*Math.sin(i),z:r*Math.cos(i)}},C.C=wr,C.D=Fe,C.E=Re,C.F=wt,C.G=Ws,C.H=function(r){if(mn==null){const t=r.navigator?r.navigator.userAgent:null;mn=!!r.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return mn},C.I=Fh,C.J=class{constructor(r,t){this.target=r,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Yf(()=>this.process()),this.subscription=Ur(this.target,"message",i=>this.receive(i),!1),this.globalScope=gr(self)?r:window}registerMessageHandler(r,t){this.messageHandlers[r]=t}sendAsync(r,t){return new Promise((i,s)=>{const o=Math.round(1e18*Math.random()).toString(36).substring(0,10),d=t?Ur(t.signal,"abort",()=>{d==null||d.unsubscribe(),delete this.resolveRejects[o];const g={id:o,type:"<cancel>",origin:location.origin,targetMapId:r.targetMapId,sourceMapId:this.mapId};this.target.postMessage(g)},Kf):null;this.resolveRejects[o]={resolve:g=>{d==null||d.unsubscribe(),i(g)},reject:g=>{d==null||d.unsubscribe(),s(g)}};const p=[],m=Object.assign(Object.assign({},r),{id:o,sourceMapId:this.mapId,origin:location.origin,data:ls(r.data,p)});this.target.postMessage(m,{transfer:p})})}receive(r){const t=r.data,i=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[i];const s=this.abortControllers[i];return delete this.abortControllers[i],void(s&&s.abort())}if(gr(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(this.taskQueue.length===0)return;const r=this.taskQueue.shift(),t=this.tasks[r];delete this.tasks[r],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(r,t)}processTask(r,t){return c(this,void 0,void 0,function*(){if(t.type==="<response>"){const o=this.resolveRejects[r];return delete this.resolveRejects[r],o?void(t.error?o.reject(zn(t.error)):o.resolve(zn(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(r,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const i=zn(t.data),s=new AbortController;this.abortControllers[r]=s;try{const o=yield this.messageHandlers[t.type](t.sourceMapId,i,s);this.completeTask(r,null,o)}catch(o){this.completeTask(r,o)}})}completeTask(r,t,i){const s=[];delete this.abortControllers[r];const o={id:r,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?ls(t):null,data:ls(i,s)};this.target.postMessage(o,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},C.K=R,C.L=function(){var r=new ft(16);return ft!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r},C.M=function(r,t,i){var s,o,d,p,m,g,x,v,T,M,E,A,L=i[0],F=i[1],V=i[2];return t===r?(r[12]=t[0]*L+t[4]*F+t[8]*V+t[12],r[13]=t[1]*L+t[5]*F+t[9]*V+t[13],r[14]=t[2]*L+t[6]*F+t[10]*V+t[14],r[15]=t[3]*L+t[7]*F+t[11]*V+t[15]):(o=t[1],d=t[2],p=t[3],m=t[4],g=t[5],x=t[6],v=t[7],T=t[8],M=t[9],E=t[10],A=t[11],r[0]=s=t[0],r[1]=o,r[2]=d,r[3]=p,r[4]=m,r[5]=g,r[6]=x,r[7]=v,r[8]=T,r[9]=M,r[10]=E,r[11]=A,r[12]=s*L+m*F+T*V+t[12],r[13]=o*L+g*F+M*V+t[13],r[14]=d*L+x*F+E*V+t[14],r[15]=p*L+v*F+A*V+t[15]),r},C.N=function(r,t,i){var s=i[0],o=i[1],d=i[2];return r[0]=t[0]*s,r[1]=t[1]*s,r[2]=t[2]*s,r[3]=t[3]*s,r[4]=t[4]*o,r[5]=t[5]*o,r[6]=t[6]*o,r[7]=t[7]*o,r[8]=t[8]*d,r[9]=t[9]*d,r[10]=t[10]*d,r[11]=t[11]*d,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},C.O=function(r,t,i){var s=t[0],o=t[1],d=t[2],p=t[3],m=t[4],g=t[5],x=t[6],v=t[7],T=t[8],M=t[9],E=t[10],A=t[11],L=t[12],F=t[13],V=t[14],Q=t[15],W=i[0],X=i[1],ce=i[2],pe=i[3];return r[0]=W*s+X*m+ce*T+pe*L,r[1]=W*o+X*g+ce*M+pe*F,r[2]=W*d+X*x+ce*E+pe*V,r[3]=W*p+X*v+ce*A+pe*Q,r[4]=(W=i[4])*s+(X=i[5])*m+(ce=i[6])*T+(pe=i[7])*L,r[5]=W*o+X*g+ce*M+pe*F,r[6]=W*d+X*x+ce*E+pe*V,r[7]=W*p+X*v+ce*A+pe*Q,r[8]=(W=i[8])*s+(X=i[9])*m+(ce=i[10])*T+(pe=i[11])*L,r[9]=W*o+X*g+ce*M+pe*F,r[10]=W*d+X*x+ce*E+pe*V,r[11]=W*p+X*v+ce*A+pe*Q,r[12]=(W=i[12])*s+(X=i[13])*m+(ce=i[14])*T+(pe=i[15])*L,r[13]=W*o+X*g+ce*M+pe*F,r[14]=W*d+X*x+ce*E+pe*V,r[15]=W*p+X*v+ce*A+pe*Q,r},C.P=be,C.Q=function(r,t){const i={};for(let s=0;s<t.length;s++){const o=t[s];o in r&&(i[o]=r[o])}return i},C.R=Ni,C.S=ys,C.T=Sh,C.U=_d,C.V=gd,C.W=Ri,C.X=Ci,C.Y=$n,C.Z=cr,C._=c,C.a=z,C.a$=Or,C.a0=function(r,t){var i,s,o,d,p;if(!r)return t??{};if(!t)return r;let m=Object.assign({},r);if(t.removeAll&&(m={removeAll:!0}),t.remove){const g=new Set(t.remove);m.add&&(m.add=m.add.filter(v=>!g.has(v.id))),m.update&&(m.update=m.update.filter(v=>!g.has(v.id)));const x=new Set(((i=r.add)!==null&&i!==void 0?i:[]).map(v=>v.id));t.remove=t.remove.filter(v=>!x.has(v))}if(t.remove){const g=new Set(m.remove?m.remove.concat(t.remove):t.remove);m.remove=Array.from(g.values())}if(t.add){const g=m.add?m.add.concat(t.add):t.add,x=new Map(g.map(v=>[v.id,v]));m.add=Array.from(x.values())}if(t.update){const g=new Map((s=m.update)===null||s===void 0?void 0:s.map(x=>[x.id,x]));for(const x of t.update){const v=(o=g.get(x.id))!==null&&o!==void 0?o:{id:x.id};x.newGeometry&&(v.newGeometry=x.newGeometry),x.addOrUpdateProperties&&(v.addOrUpdateProperties=((d=v.addOrUpdateProperties)!==null&&d!==void 0?d:[]).concat(x.addOrUpdateProperties)),x.removeProperties&&(v.removeProperties=((p=v.removeProperties)!==null&&p!==void 0?p:[]).concat(x.removeProperties)),x.removeAllProperties&&(v.removeAllProperties=!0),g.set(x.id,v)}m.update=Array.from(g.values())}return m.remove&&m.add&&(m.remove=m.remove.filter(g=>m.add.findIndex(x=>x.id===g)===-1)),m},C.a1=yl,C.a2=ta,C.a3=25,C.a4=qh,C.a5=r=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const s of r){const o=window.document.createElement("source");le(s)||(t.crossOrigin="Anonymous"),o.src=s,t.appendChild(o)}})},C.a6=Te,C.a7=function(){return Yi++},C.a8=P,C.a9=io,C.aA=function(r){let t=1/0,i=1/0,s=-1/0,o=-1/0;for(const d of r)t=Math.min(t,d.x),i=Math.min(i,d.y),s=Math.max(s,d.x),o=Math.max(o,d.y);return[t,i,s,o]},C.aB=ni,C.aC=dn,C.aD=function(r,t,i,s,o=!1){if(!i[0]&&!i[1])return[0,0];const d=o?s==="map"?-r.bearingInRadians:0:s==="viewport"?r.bearingInRadians:0;if(d){const p=Math.sin(d),m=Math.cos(d);i=[i[0]*m-i[1]*p,i[0]*p+i[1]*m]}return[o?i[0]:dn(t,i[0],r.zoom),o?i[1]:dn(t,i[1],r.zoom)]},C.aF=jh,C.aG=Hh,C.aH=Oh,C.aI=Xh,C.aJ=Bt,C.aK=Sc,C.aL=G,C.aM=Xe,C.aN=yt,C.aO=Nn,C.aP=$r,C.aQ=xd,C.aR=pr,C.aS=Ts,C.aT=function(r){var t=new ft(3);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t},C.aU=function(r,t,i){return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],r},C.aV=function(r,t){var i=t[0],s=t[1],o=t[2],d=i*i+s*s+o*o;return d>0&&(d=1/Math.sqrt(d)),r[0]=t[0]*d,r[1]=t[1]*d,r[2]=t[2]*d,r},C.aW=Br,C.aX=function(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]},C.aY=function(r,t,i){return r[0]=t[0]*i[0],r[1]=t[1]*i[1],r[2]=t[2]*i[2],r[3]=t[3]*i[3],r},C.aZ=jn,C.a_=function(r,t,i){const s=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return s===0?null:(-(r[0]*i[0]+r[1]*i[1]+r[2]*i[2])-i[3])/s},C.aa=En,C.ab=kr,C.ac=Td,C.ad=function(r){const t={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,s,o,d)=>{const p=o||d;return t[s]=!p||p.toLowerCase(),""}),t["max-age"]){const i=parseInt(t["max-age"],10);isNaN(i)?delete t["max-age"]:t["max-age"]=i}return t},C.ae=gn,C.af=function(r){return Math.pow(2,r)},C.ag=$i,C.ah=Ei,C.ai=85.051129,C.aj=yd,C.ak=function(r){return Math.log(r)/Math.LN2},C.al=function(r){var t=r[0],i=r[1];return t*t+i*i},C.am=function(r,t){const i=[];for(const s in r)s in t||i.push(s);return i},C.an=function(r,t){let i=0,s=0;if(r.kind==="constant")s=r.layoutSize;else if(r.kind!=="source"){const{interpolationType:o,minZoom:d,maxZoom:p}=r,m=o?Ei(ui.interpolationFactor(o,t,d,p),0,1):0;r.kind==="camera"?s=wr.number(r.minSize,r.maxSize,m):i=m}return{uSizeT:i,uSize:s}},C.ap=function(r,{uSize:t,uSizeT:i},{lowerSize:s,upperSize:o}){return r.kind==="source"?s/Bn:r.kind==="composite"?wr.number(s/Bn,o/Bn,i):t},C.aq=function(r,t){var i=t[0],s=t[1],o=t[2],d=t[3],p=t[4],m=t[5],g=t[6],x=t[7],v=t[8],T=t[9],M=t[10],E=t[11],A=t[12],L=t[13],F=t[14],V=t[15],Q=i*m-s*p,W=i*g-o*p,X=i*x-d*p,ce=s*g-o*m,pe=s*x-d*m,xe=o*x-d*g,Ae=v*L-T*A,Pe=v*F-M*A,Ie=v*V-E*A,Be=T*F-M*L,Me=T*V-E*L,Ce=M*V-E*F,ge=Q*Ce-W*Me+X*Be+ce*Ie-pe*Pe+xe*Ae;return ge?(r[0]=(m*Ce-g*Me+x*Be)*(ge=1/ge),r[1]=(o*Me-s*Ce-d*Be)*ge,r[2]=(L*xe-F*pe+V*ce)*ge,r[3]=(M*pe-T*xe-E*ce)*ge,r[4]=(g*Ie-p*Ce-x*Pe)*ge,r[5]=(i*Ce-o*Ie+d*Pe)*ge,r[6]=(F*X-A*xe-V*W)*ge,r[7]=(v*xe-M*X+E*W)*ge,r[8]=(p*Me-m*Ie+x*Ae)*ge,r[9]=(s*Ie-i*Me-d*Ae)*ge,r[10]=(A*pe-L*X+V*Q)*ge,r[11]=(T*X-v*pe-E*Q)*ge,r[12]=(m*Pe-p*Be-g*Ae)*ge,r[13]=(i*Be-s*Pe+o*Ae)*ge,r[14]=(L*W-A*ce-F*Q)*ge,r[15]=(v*ce-T*W+M*Q)*ge,r):null},C.ar=un,C.as=function(r){var t=r[0],i=r[1];return Math.sqrt(t*t+i*i)},C.at=function(r){return r[0]=0,r[1]=0,r},C.au=function(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r},C.av=Nh,C.aw=Ps,C.ax=function(r,t,i,s){const o=t.y-r.y,d=t.x-r.x,p=s.y-i.y,m=s.x-i.x,g=p*d-m*o;if(g===0)return null;const x=(m*(r.y-i.y)-p*(r.x-i.x))/g;return new be(r.x+x*d,r.y+x*o)},C.ay=Md,C.az=mu,C.b=_r,C.b$=class extends h{},C.b0=function(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r[2]=t[2]*i,r[3]=t[3]*i,r},C.b1=function(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]},C.b2=bd,C.b3=ro,C.b4=function(r,t,i,s,o){var d=1/Math.tan(t/2);if(r[0]=d/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=d,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,o!=null&&o!==1/0){var p=1/(s-o);r[10]=(o+s)*p,r[14]=2*o*s*p}else r[10]=-1,r[14]=-2*s;return r},C.b5=function(r){var t=new ft(16);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],t},C.b6=function(r,t,i){var s=Math.sin(i),o=Math.cos(i),d=t[0],p=t[1],m=t[2],g=t[3],x=t[4],v=t[5],T=t[6],M=t[7];return t!==r&&(r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=d*o+x*s,r[1]=p*o+v*s,r[2]=m*o+T*s,r[3]=g*o+M*s,r[4]=x*o-d*s,r[5]=v*o-p*s,r[6]=T*o-m*s,r[7]=M*o-g*s,r},C.b7=function(r,t,i){var s=Math.sin(i),o=Math.cos(i),d=t[4],p=t[5],m=t[6],g=t[7],x=t[8],v=t[9],T=t[10],M=t[11];return t!==r&&(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[4]=d*o+x*s,r[5]=p*o+v*s,r[6]=m*o+T*s,r[7]=g*o+M*s,r[8]=x*o-d*s,r[9]=v*o-p*s,r[10]=T*o-m*s,r[11]=M*o-g*s,r},C.b8=function(){const r=new Float32Array(16);return $i(r),r},C.b9=function(){const r=new Float64Array(16);return $i(r),r},C.bA=function(r,t){const i=mi(r,360),s=mi(t,360),o=s-i,d=s>i?o-360:o+360;return Math.abs(o)<Math.abs(d)?o:d},C.bB=function(r){return r[0]=0,r[1]=0,r[2]=0,r},C.bC=function(r,t,i,s){const o=Math.sqrt(r*r+t*t),d=Math.sqrt(i*i+s*s);r/=o,t/=o,i/=d,s/=d;const p=Math.acos(r*i+t*s);return-t*i+r*s>0?p:-p},C.bD=function(r,t){const i=mi(r,2*Math.PI),s=mi(t,2*Math.PI);return Math.min(Math.abs(i-s),Math.abs(i-s+2*Math.PI),Math.abs(i-s-2*Math.PI))},C.bE=function(){const r={},t=ne.$version;for(const i in ne.$root){const s=ne.$root[i];if(s.required){let o=null;o=i==="version"?t:s.type==="array"?[]:{},o!=null&&(r[i]=o)}}return r},C.bF=Oa,C.bG=Y,C.bH=function r(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let s=0;s<t.length;s++)if(!r(t[s],i[s]))return!1;return!0}if(typeof t=="object"&&t!==null&&i!==null){if(typeof i!="object"||Object.keys(t).length!==Object.keys(i).length)return!1;for(const s in t)if(!r(t[s],i[s]))return!1;return!0}return t===i},C.bI=function(r){r=r.slice();const t=Object.create(null);for(let i=0;i<r.length;i++)t[r[i].id]=r[i];for(let i=0;i<r.length;i++)"ref"in r[i]&&(r[i]=Qe(r[i],t[r[i].ref]));return r},C.bJ=function(r){if(r.type==="custom")return new Xf(r);switch(r.type){case"background":return new qf(r);case"circle":return new Ap(r);case"color-relief":return new Fp(r);case"fill":return new Kp(r);case"fill-extrusion":return new cf(r);case"heatmap":return new zp(r);case"hillshade":return new Dp(r);case"line":return new gf(r);case"raster":return new Hf(r);case"symbol":return new Ac(r)}},C.bK=Fi,C.bL=function(r,t){if(!r)return[{command:"setStyle",args:[t]}];let i=[];try{if(!Oe(r.version,t.version))return[{command:"setStyle",args:[t]}];Oe(r.center,t.center)||i.push({command:"setCenter",args:[t.center]}),Oe(r.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),Oe(r.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Oe(r.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),Oe(r.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),Oe(r.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),Oe(r.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),Oe(r.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),Oe(r.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),Oe(r.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),Oe(r.light,t.light)||i.push({command:"setLight",args:[t.light]}),Oe(r.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),Oe(r.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),Oe(r.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const s={},o=[];(function(p,m,g,x){let v;for(v in m=m||{},p=p||{})Object.prototype.hasOwnProperty.call(p,v)&&(Object.prototype.hasOwnProperty.call(m,v)||Ht(v,g,x));for(v in m)Object.prototype.hasOwnProperty.call(m,v)&&(Object.prototype.hasOwnProperty.call(p,v)?Oe(p[v],m[v])||(p[v].type==="geojson"&&m[v].type==="geojson"&&Nt(p,m,v)?He(g,{command:"setGeoJSONSourceData",args:[v,m[v].data]}):Xt(v,m,g,x)):Tt(v,m,g))})(r.sources,t.sources,o,s);const d=[];r.layers&&r.layers.forEach(p=>{"source"in p&&s[p.source]?i.push({command:"removeLayer",args:[p.id]}):d.push(p)}),i=i.concat(o),function(p,m,g){m=m||[];const x=(p=p||[]).map(ot),v=m.map(ot),T=p.reduce(Ut,{}),M=m.reduce(Ut,{}),E=x.slice(),A=Object.create(null);let L,F,V,Q,W;for(let X=0,ce=0;X<x.length;X++)L=x[X],Object.prototype.hasOwnProperty.call(M,L)?ce++:(He(g,{command:"removeLayer",args:[L]}),E.splice(E.indexOf(L,ce),1));for(let X=0,ce=0;X<v.length;X++)L=v[v.length-1-X],E[E.length-1-X]!==L&&(Object.prototype.hasOwnProperty.call(T,L)?(He(g,{command:"removeLayer",args:[L]}),E.splice(E.lastIndexOf(L,E.length-ce),1)):ce++,Q=E[E.length-X],He(g,{command:"addLayer",args:[M[L],Q]}),E.splice(E.length-X,0,L),A[L]=!0);for(let X=0;X<v.length;X++)if(L=v[X],F=T[L],V=M[L],!A[L]&&!Oe(F,V))if(Oe(F.source,V.source)&&Oe(F["source-layer"],V["source-layer"])&&Oe(F.type,V.type)){for(W in rt(F.layout,V.layout,g,L,null,"setLayoutProperty"),rt(F.paint,V.paint,g,L,null,"setPaintProperty"),Oe(F.filter,V.filter)||He(g,{command:"setFilter",args:[L,V.filter]}),Oe(F.minzoom,V.minzoom)&&Oe(F.maxzoom,V.maxzoom)||He(g,{command:"setLayerZoomRange",args:[L,V.minzoom,V.maxzoom]}),F)Object.prototype.hasOwnProperty.call(F,W)&&W!=="layout"&&W!=="paint"&&W!=="filter"&&W!=="metadata"&&W!=="minzoom"&&W!=="maxzoom"&&(W.indexOf("paint.")===0?rt(F[W],V[W],g,L,W.slice(6),"setPaintProperty"):Oe(F[W],V[W])||He(g,{command:"setLayerProperty",args:[L,W,V[W]]}));for(W in V)Object.prototype.hasOwnProperty.call(V,W)&&!Object.prototype.hasOwnProperty.call(F,W)&&W!=="layout"&&W!=="paint"&&W!=="filter"&&W!=="metadata"&&W!=="minzoom"&&W!=="maxzoom"&&(W.indexOf("paint.")===0?rt(F[W],V[W],g,L,W.slice(6),"setPaintProperty"):Oe(F[W],V[W])||He(g,{command:"setLayerProperty",args:[L,W,V[W]]}))}else He(g,{command:"removeLayer",args:[L]}),Q=E[E.lastIndexOf(L)+1],He(g,{command:"addLayer",args:[V,Q]})}(d,t.layers,i)}catch(s){console.warn("Unable to compute style diff:",s),i=[{command:"setStyle",args:[t]}]}return i},C.bM=function(r){const t=[],i=r.id;return i===void 0&&t.push({message:`layers.${i}: missing required property "id"`}),r.render===void 0&&t.push({message:`layers.${i}: missing required method "render"`}),r.renderingMode&&r.renderingMode!=="2d"&&r.renderingMode!=="3d"&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},C.bN=Vn,C.bO=Un,C.bP=class extends Mi{constructor(r,t){super(r,t),this.current=0}set(r){this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}},C.bQ=Kt,C.bR=class extends Mi{constructor(r,t){super(r,t),this.current=Hi}set(r){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let t=1;t<16;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}},C.bS=Gt,C.bT=class extends Mi{constructor(r,t){super(r,t),this.current=[0,0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2]))}},C.bU=class extends Mi{constructor(r,t){super(r,t),this.current=[0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1]))}},C.bV=Ot,C.bW=function(r,t){var i=Math.sin(t),s=Math.cos(t);return r[0]=s,r[1]=i,r[2]=0,r[3]=-i,r[4]=s,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},C.bX=function(r,t,i){var s=t[0],o=t[1],d=t[2];return r[0]=s*i[0]+o*i[3]+d*i[6],r[1]=s*i[1]+o*i[4]+d*i[7],r[2]=s*i[2]+o*i[5]+d*i[8],r},C.bY=function(r,t,i,s,o,d,p){var m=1/(t-i),g=1/(s-o),x=1/(d-p);return r[0]=-2*m,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*g,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*x,r[11]=0,r[12]=(t+i)*m,r[13]=(o+s)*g,r[14]=(p+d)*x,r[15]=1,r},C.bZ=class extends Mi{constructor(r,t){super(r,t),this.current=new Array}set(r){if(r!=this.current){this.current=r;const t=new Float32Array(4*r.length);for(let i=0;i<r.length;i++)t[4*i]=r[i].r,t[4*i+1]=r[i].g,t[4*i+2]=r[i].b,t[4*i+3]=r[i].a;this.gl.uniform4fv(this.location,t)}}},C.b_=class extends Mi{constructor(r,t){super(r,t),this.current=new Array}set(r){if(r!=this.current){this.current=r;const t=new Float32Array(r);this.gl.uniform1fv(this.location,t)}}},C.ba=function(){return new Float64Array(16)},C.bb=function(r,t,i){const s=new Float64Array(4);return hn(s,r,t-90,i),s},C.bc=function(r,t,i,s){var o,d,p,m,g,x=t[0],v=t[1],T=t[2],M=t[3],E=i[0],A=i[1],L=i[2],F=i[3];return(d=x*E+v*A+T*L+M*F)<0&&(d=-d,E=-E,A=-A,L=-L,F=-F),1-d>It?(o=Math.acos(d),p=Math.sin(o),m=Math.sin((1-s)*o)/p,g=Math.sin(s*o)/p):(m=1-s,g=s),r[0]=m*x+g*E,r[1]=m*v+g*A,r[2]=m*T+g*L,r[3]=m*M+g*F,r},C.bd=function(r){const t=new Float64Array(9);var i,s,o,d,p,m,g,x,v,T,M,E,A,L,F,V,Q,W;T=(o=(s=r)[0])*(g=o+o),M=(d=s[1])*g,A=(p=s[2])*g,L=p*(x=d+d),V=(m=s[3])*g,Q=m*x,W=m*(v=p+p),(i=t)[0]=1-(E=d*x)-(F=p*v),i[3]=M-W,i[6]=A+Q,i[1]=M+W,i[4]=1-T-F,i[7]=L-V,i[2]=A-Q,i[5]=L+V,i[8]=1-T-E;const X=$r(-Math.asin(Ei(t[2],-1,1)));let ce,pe;return Math.hypot(t[5],t[8])<.001?(ce=0,pe=-$r(Math.atan2(t[3],t[4]))):(ce=$r(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),pe=$r(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:ce,pitch:X+90,bearing:pe}},C.be=function(r,t){return r.roll==t.roll&&r.pitch==t.pitch&&r.bearing==t.bearing},C.bf=it,C.bg=nn,C.bh=Ja,C.bi=dl,C.bj=Ka,C.bk=pn,C.bl=mr,C.bm=_i,C.bn=function(r,t,i,s,o){return pn(s,o,Ei((r-t)/(i-t),0,1))},C.bo=mi,C.bp=function(){return new Float64Array(3)},C.bq=function(r,t,i,s){return r[0]=t[0]+i[0]*s,r[1]=t[1]+i[1]*s,r[2]=t[2]+i[2]*s,r},C.br=hn,C.bs=function(r,t,i){var s=i[0],o=i[1],d=i[2],p=i[3],m=t[0],g=t[1],x=t[2],v=o*x-d*g,T=d*m-s*x,M=s*g-o*m;return r[0]=m+p*(v+=v)+o*(M+=M)-d*(T+=T),r[1]=g+p*T+d*v-s*M,r[2]=x+p*M+s*T-o*v,r},C.bt=function(r,t,i){const s=(o=[r[0],r[1],r[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((v=o[8])*(p=o[4])-(m=o[5])*(x=o[7]))+o[1]*(-v*(d=o[3])+m*(g=o[6]))+o[2]*(x*d-p*g);var o,d,p,m,g,x,v;if(s===0)return null;const T=Br([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),M=Br([],[i[0],i[1],i[2]],[r[0],r[1],r[2]]),E=Br([],[r[0],r[1],r[2]],[t[0],t[1],t[2]]),A=pr([],T,-r[3]);return Ts(A,A,pr([],M,-t[3])),Ts(A,A,pr([],E,-i[3])),pr(A,A,1/s),A},C.bu=Zh,C.bv=function(){return new Float64Array(4)},C.bw=function(r,t,i,s){var o=[],d=[];return o[0]=t[0]-i[0],o[1]=t[1]-i[1],o[2]=t[2]-i[2],d[0]=o[0]*Math.cos(s)-o[1]*Math.sin(s),d[1]=o[0]*Math.sin(s)+o[1]*Math.cos(s),d[2]=o[2],r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},C.bx=function(r,t,i,s){var o=[],d=[];return o[0]=t[0]-i[0],o[1]=t[1]-i[1],o[2]=t[2]-i[2],d[0]=o[0],d[1]=o[1]*Math.cos(s)-o[2]*Math.sin(s),d[2]=o[1]*Math.sin(s)+o[2]*Math.cos(s),r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},C.by=function(r,t,i,s){var o=[],d=[];return o[0]=t[0]-i[0],o[1]=t[1]-i[1],o[2]=t[2]-i[2],d[0]=o[2]*Math.sin(s)+o[0]*Math.cos(s),d[1]=o[1],d[2]=o[2]*Math.cos(s)-o[0]*Math.sin(s),r[0]=d[0]+i[0],r[1]=d[1]+i[1],r[2]=d[2]+i[2],r},C.bz=function(r,t,i){var s=Math.sin(i),o=Math.cos(i),d=t[0],p=t[1],m=t[2],g=t[3],x=t[8],v=t[9],T=t[10],M=t[11];return t!==r&&(r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=d*o-x*s,r[1]=p*o-v*s,r[2]=m*o-T*s,r[3]=g*o-M*s,r[8]=d*s+x*o,r[9]=p*s+v*o,r[10]=m*s+T*o,r[11]=g*s+M*o,r},C.c=ee,C.c0=vf,C.c1=class extends n{},C.c2=Ph,C.c3=function(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))},C.c4=Su,C.c5=function(r,t,i){var s=t[0],o=t[1],d=t[2],p=i[3]*s+i[7]*o+i[11]*d+i[15];return r[0]=(i[0]*s+i[4]*o+i[8]*d+i[12])/(p=p||1),r[1]=(i[1]*s+i[5]*o+i[9]*d+i[13])/p,r[2]=(i[2]*s+i[6]*o+i[10]*d+i[14])/p,r},C.c6=class extends tl{},C.c7=class extends b{},C.c8=function(r,t){return r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2]&&r[3]===t[3]&&r[4]===t[4]&&r[5]===t[5]&&r[6]===t[6]&&r[7]===t[7]&&r[8]===t[8]&&r[9]===t[9]&&r[10]===t[10]&&r[11]===t[11]&&r[12]===t[12]&&r[13]===t[13]&&r[14]===t[14]&&r[15]===t[15]},C.c9=function(r,t){var i=r[0],s=r[1],o=r[2],d=r[3],p=r[4],m=r[5],g=r[6],x=r[7],v=r[8],T=r[9],M=r[10],E=r[11],A=r[12],L=r[13],F=r[14],V=r[15],Q=t[0],W=t[1],X=t[2],ce=t[3],pe=t[4],xe=t[5],Ae=t[6],Pe=t[7],Ie=t[8],Be=t[9],Me=t[10],Ce=t[11],ge=t[12],Ze=t[13],Ge=t[14],Ne=t[15];return Math.abs(i-Q)<=It*Math.max(1,Math.abs(i),Math.abs(Q))&&Math.abs(s-W)<=It*Math.max(1,Math.abs(s),Math.abs(W))&&Math.abs(o-X)<=It*Math.max(1,Math.abs(o),Math.abs(X))&&Math.abs(d-ce)<=It*Math.max(1,Math.abs(d),Math.abs(ce))&&Math.abs(p-pe)<=It*Math.max(1,Math.abs(p),Math.abs(pe))&&Math.abs(m-xe)<=It*Math.max(1,Math.abs(m),Math.abs(xe))&&Math.abs(g-Ae)<=It*Math.max(1,Math.abs(g),Math.abs(Ae))&&Math.abs(x-Pe)<=It*Math.max(1,Math.abs(x),Math.abs(Pe))&&Math.abs(v-Ie)<=It*Math.max(1,Math.abs(v),Math.abs(Ie))&&Math.abs(T-Be)<=It*Math.max(1,Math.abs(T),Math.abs(Be))&&Math.abs(M-Me)<=It*Math.max(1,Math.abs(M),Math.abs(Me))&&Math.abs(E-Ce)<=It*Math.max(1,Math.abs(E),Math.abs(Ce))&&Math.abs(A-ge)<=It*Math.max(1,Math.abs(A),Math.abs(ge))&&Math.abs(L-Ze)<=It*Math.max(1,Math.abs(L),Math.abs(Ze))&&Math.abs(F-Ge)<=It*Math.max(1,Math.abs(F),Math.abs(Ge))&&Math.abs(V-Ne)<=It*Math.max(1,Math.abs(V),Math.abs(Ne))},C.cA=function(r,t){z.REGISTERED_PROTOCOLS[r]=t},C.cB=function(r){delete z.REGISTERED_PROTOCOLS[r]},C.cC=function(r,t){const i={};for(let o=0;o<r.length;o++){const d=t&&t[r[o].id]||dh(r[o]);t&&(t[r[o].id]=d);let p=i[d];p||(p=i[d]=[]),p.push(r[o])}const s=[];for(const o in i)s.push(i[o]);return s},C.cD=ze,C.cE=wd,C.cF=Pd,C.cG=ed,C.cH=function(r){r.bucket.createArrays(),r.bucket.tilePixelRatio=gt/(512*r.bucket.overscaling),r.bucket.compareText={},r.bucket.iconsNeedLinear=!1;const t=r.bucket.layers[0],i=t.layout,s=t._unevaluatedLayout._values,o={layoutIconSize:s["icon-size"].possiblyEvaluate(new wt(r.bucket.zoom+1),r.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new wt(r.bucket.zoom+1),r.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new wt(18))};if(r.bucket.textSizeData.kind==="composite"){const{minZoom:x,maxZoom:v}=r.bucket.textSizeData;o.compositeTextSizes=[s["text-size"].possiblyEvaluate(new wt(x),r.canonical),s["text-size"].possiblyEvaluate(new wt(v),r.canonical)]}if(r.bucket.iconSizeData.kind==="composite"){const{minZoom:x,maxZoom:v}=r.bucket.iconSizeData;o.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new wt(x),r.canonical),s["icon-size"].possiblyEvaluate(new wt(v),r.canonical)]}const d=i.get("text-line-height")*ni,p=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",m=i.get("text-keep-upright"),g=i.get("text-size");for(const x of r.bucket.features){const v=i.get("text-font").evaluate(x,{},r.canonical).join(","),T=g.evaluate(x,{},r.canonical),M=o.layoutTextSize.evaluate(x,{},r.canonical),E=o.layoutIconSize.evaluate(x,{},r.canonical),A={horizontal:{},vertical:void 0},L=x.text;let F,V=[0,0];if(L){const X=L.toString(),ce=i.get("text-letter-spacing").evaluate(x,{},r.canonical)*ni,pe=gh(X)?ce:0,xe=i.get("text-anchor").evaluate(x,{},r.canonical),Ae=Rd(t,x,r.canonical);if(!Ae){const Me=i.get("text-radial-offset").evaluate(x,{},r.canonical);V=Me?Dd(xe,[Me*ni,Wh]):i.get("text-offset").evaluate(x,{},r.canonical).map(Ce=>Ce*ni)}let Pe=p?"center":i.get("text-justify").evaluate(x,{},r.canonical);const Ie=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(x,{},r.canonical)*ni:1/0,Be=()=>{r.bucket.allowVerticalPlacement&&ja(X)&&(A.vertical=Ic(L,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ie,d,xe,"left",pe,V,C.ao.vertical,!0,M,T))};if(!p&&Ae){const Me=new Set;if(Pe==="auto")for(let ge=0;ge<Ae.values.length;ge+=2)Me.add(Hh(Ae.values[ge]));else Me.add(Pe);let Ce=!1;for(const ge of Me)if(!A.horizontal[ge])if(Ce)A.horizontal[ge]=A.horizontal[0];else{const Ze=Ic(L,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ie,d,"center",ge,pe,V,C.ao.horizontal,!1,M,T);Ze&&(A.horizontal[ge]=Ze,Ce=Ze.positionedLines.length===1)}Be()}else{Pe==="auto"&&(Pe=Hh(xe));const Me=Ic(L,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ie,d,xe,Pe,pe,V,C.ao.horizontal,!1,M,T);Me&&(A.horizontal[Pe]=Me),Be(),ja(X)&&p&&m&&(A.vertical=Ic(L,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ie,d,xe,Pe,pe,V,C.ao.vertical,!1,M,T))}}let Q=!1;if(x.icon&&x.icon.name){const X=r.imageMap[x.icon.name];X&&(F=Uf(r.imagePositions[x.icon.name],i.get("icon-offset").evaluate(x,{},r.canonical),i.get("icon-anchor").evaluate(x,{},r.canonical)),Q=!!X.sdf,r.bucket.sdfIcons===void 0?r.bucket.sdfIcons=Q:r.bucket.sdfIcons!==Q&&jt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(X.pixelRatio!==r.bucket.pixelRatio||i.get("icon-rotate").constantOr(1)!==0)&&(r.bucket.iconsNeedLinear=!0))}const W=Bd(A.horizontal)||A.vertical;r.bucket.iconsInText=!!W&&W.iconsInText,(W||F)&&nm(r.bucket,x,A,F,r.imageMap,o,M,E,V,Q,r.canonical,r.subdivisionGranularity)}r.showCollisionBoxes&&r.bucket.generateCollisionDebugBuffers()},C.cI=Lh,C.cJ=Ah,C.cK=zh,C.cL=Nu,C.cM=Rh,C.cN=class{constructor(r){this._marks={start:[r.url,"start"].join("#"),end:[r.url,"end"].join("#"),measure:r.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let r=performance.getEntriesByName(this._marks.measure);return r.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),r=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),r}},C.cO=function(r,t,i,s,o){return c(this,void 0,void 0,function*(){if(Ci())try{return yield $n(r,t,i,s,o)}catch{}return function(d,p,m,g,x){const v=d.width,T=d.height;Nr&&Vr||(Nr=new OffscreenCanvas(v,T),Vr=Nr.getContext("2d",{willReadFrequently:!0})),Nr.width=v,Nr.height=T,Vr.drawImage(d,0,0,v,T);const M=Vr.getImageData(p,m,g,x);return Vr.clearRect(0,0,v,T),M.data}(r,t,i,s,o)})},C.cP=Cu,C.cQ=ct,C.cR=ju,C.cS=Qa,C.cT=Vs,C.cU=function(r,t){const i=new Map;if(r!=null)if(r.type==="Feature")i.set(xl(r,t),r);else for(const s of r.features)i.set(xl(s,t),s);return i},C.cV=function(r,t){if(r==null)return!0;if(r.type==="Feature")return xl(r,t)!=null;if(r.type==="FeatureCollection"){const i=new Set;for(const s of r.features){const o=xl(s,t);if(o==null||i.has(o))return!1;i.add(o)}return!0}return!1},C.cW=function(r,t,i){var s,o,d,p;if(t.removeAll&&r.clear(),t.remove)for(const m of t.remove)r.delete(m);if(t.add)for(const m of t.add){const g=xl(m,i);g!=null&&r.set(g,m)}if(t.update)for(const m of t.update){let g=r.get(m.id);if(g==null)continue;const x=!m.removeAllProperties&&(((s=m.removeProperties)===null||s===void 0?void 0:s.length)>0||((o=m.addOrUpdateProperties)===null||o===void 0?void 0:o.length)>0);if((m.newGeometry||m.removeAllProperties||x)&&(g=Object.assign({},g),r.set(m.id,g),x&&(g.properties=Object.assign({},g.properties))),m.newGeometry&&(g.geometry=m.newGeometry),m.removeAllProperties)g.properties={};else if(((d=m.removeProperties)===null||d===void 0?void 0:d.length)>0)for(const v of m.removeProperties)Object.prototype.hasOwnProperty.call(g.properties,v)&&delete g.properties[v];if(((p=m.addOrUpdateProperties)===null||p===void 0?void 0:p.length)>0)for(const{key:v,value:T}of m.addOrUpdateProperties)g.properties[v]=T}},C.cX=sr,C.ca=function(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},C.cb=r=>r.type==="symbol",C.cc=r=>r.type==="circle",C.cd=r=>r.type==="heatmap",C.ce=r=>r.type==="line",C.cf=r=>r.type==="fill",C.cg=r=>r.type==="fill-extrusion",C.ch=r=>r.type==="hillshade",C.ci=r=>r.type==="color-relief",C.cj=r=>r.type==="raster",C.ck=r=>r.type==="background",C.cl=r=>r.type==="custom",C.cm=jr,C.cn=function(r,t,i){const s=la(t.x-i.x,t.y-i.y),o=la(r.x-i.x,r.y-i.y);var d,p;return $r(Math.atan2(s[0]*o[1]-s[1]*o[0],(d=s)[0]*(p=o)[0]+d[1]*p[1]))},C.co=fn,C.cp=function(r,t){return Gr[t]&&(r instanceof MouseEvent||r instanceof WheelEvent)},C.cq=function(r,t){return Zr[t]&&"touches"in r},C.cr=function(r){return Zr[r]||Gr[r]},C.cs=function(r,t,i){var s=t[0],o=t[1];return r[0]=i[0]*s+i[4]*o+i[12],r[1]=i[1]*s+i[5]*o+i[13],r},C.ct=function(r,t){const{x:i,y:s}=yl.fromLngLat(t);return!(r<0||r>25||s<0||s>=1||i<0||i>=1)},C.cu=function(r,t){return r[0]=t[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=t[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=t[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},C.cv=class extends us{},C.cw=am,C.cy=function(r){return r.message===Zn},C.cz=Z,C.d=le,C.e=Zi,C.f=r=>c(void 0,void 0,void 0,function*(){if(r.byteLength===0)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(r)],{type:"image/png"});try{return createImageBitmap(t)}catch(i){throw new Error(`Could not load image because of ${i.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),C.g=D,C.h=r=>new Promise((t,i)=>{const s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame(()=>{s.src=yr})},s.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new Blob([new Uint8Array(r)],{type:"image/png"});s.src=r.byteLength?URL.createObjectURL(o):yr}),C.i=gr,C.j=(r,t)=>ie(Zi(r,{type:"json"}),t),C.k=_e,C.l=ve,C.m=ie,C.n=(r,t)=>ie(Zi(r,{type:"arrayBuffer"}),t),C.o=function(r){return new Rh(r).readFields(kf,[])},C.p=Qu,C.q=ol,C.r=Pi,C.s=Ur,C.t=gc,C.u=st,C.v=ne,C.w=jt,C.x=ph,C.y=Hs,C.z=os}),je("worker",["./shared"],function(C){class c{constructor(z){this.keyCache={},z&&this.replace(z)}replace(z){this._layerConfigs={},this._layers={},this.update(z,[])}update(z,D){for(const Z of z){this._layerConfigs[Z.id]=Z;const Y=this._layers[Z.id]=C.bJ(Z);Y._featureFilter=C.aa(Y.filter),this.keyCache[Z.id]&&delete this.keyCache[Z.id]}for(const Z of D)delete this.keyCache[Z],delete this._layerConfigs[Z],delete this._layers[Z];this.familiesBySource={};const R=C.cC(Object.values(this._layerConfigs),this.keyCache);for(const Z of R){const Y=Z.map(_e=>this._layers[_e.id]),ie=Y[0];if(ie.visibility==="none")continue;const le=ie.source||"";let re=this.familiesBySource[le];re||(re=this.familiesBySource[le]={});const fe=ie.sourceLayer||"_geojsonTileLayer";let ve=re[fe];ve||(ve=re[fe]=[]),ve.push(Y)}}}class be{constructor(z){const D={},R=[];for(const le in z){const re=z[le],fe=D[le]={};for(const ve in re){const _e=re[+ve];if(!_e||_e.bitmap.width===0||_e.bitmap.height===0)continue;const Re={x:0,y:0,w:_e.bitmap.width+2,h:_e.bitmap.height+2};R.push(Re),fe[ve]={rect:Re,metrics:_e.metrics}}}const{w:Z,h:Y}=C.p(R),ie=new C.q({width:Z||1,height:Y||1});for(const le in z){const re=z[le];for(const fe in re){const ve=re[+fe];if(!ve||ve.bitmap.width===0||ve.bitmap.height===0)continue;const _e=D[le][fe].rect;C.q.copy(ve.bitmap,ie,{x:0,y:0},{x:_e.x+1,y:_e.y+1},ve.bitmap)}}this.image=ie,this.positions=D}}C.cD("GlyphAtlas",be);class ct{constructor(z){this.tileID=new C.Z(z.tileID.overscaledZ,z.tileID.wrap,z.tileID.canonical.z,z.tileID.canonical.x,z.tileID.canonical.y),this.uid=z.uid,this.zoom=z.zoom,this.pixelRatio=z.pixelRatio,this.tileSize=z.tileSize,this.source=z.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=z.showCollisionBoxes,this.collectResourceTiming=!!z.collectResourceTiming,this.returnDependencies=!!z.returnDependencies,this.promoteId=z.promoteId,this.inFlightDependencies=[],this.globalState=z.globalState}parse(z,D,R,Z,Y){return C._(this,void 0,void 0,function*(){this.status="parsing",this.data=z,this.collisionBoxArray=new C.a8;const ie=new C.cE(Object.keys(z.layers).sort()),le=new C.cF(this.tileID,this.promoteId);le.bucketLayerIDs=[];const re={},fe={featureIndex:le,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:R,subdivisionGranularity:Y},ve=D.familiesBySource[this.source];for(const rt in ve){const ot=z.layers[rt];if(!ot)continue;ot.version===1&&C.w(`Vector tile source "${this.source}" layer "${rt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Ut=ie.encode(rt),Te=[];for(let gi=0;gi<ot.length;gi++){const At=ot.feature(gi),qr=le.getId(At,rt);Te.push({feature:At,id:qr,index:gi,sourceLayerIndex:Ut})}for(const gi of ve[rt]){const At=gi[0];At.source!==this.source&&C.w(`layer.source = ${At.source} does not equal this.source = ${this.source}`),At.minzoom&&this.zoom<Math.floor(At.minzoom)||At.maxzoom&&this.zoom>=At.maxzoom||At.visibility!=="none"&&(ut(gi,this.zoom,R,this.globalState),(re[At.id]=At.createBucket({index:le.bucketLayerIDs.length,layers:gi,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ut,sourceID:this.source,globalState:this.globalState})).populate(Te,fe,this.tileID.canonical),le.bucketLayerIDs.push(gi.map(qr=>qr.id)))}}const _e=C.bN(fe.glyphDependencies,rt=>Object.keys(rt).map(Number));this.inFlightDependencies.forEach(rt=>rt==null?void 0:rt.abort()),this.inFlightDependencies=[];let Re=Promise.resolve({});if(Object.keys(_e).length){const rt=new AbortController;this.inFlightDependencies.push(rt),Re=Z.sendAsync({type:"GG",data:{stacks:_e,source:this.source,tileID:this.tileID,type:"glyphs"}},rt)}const ne=Object.keys(fe.iconDependencies);let qe=Promise.resolve({});if(ne.length){const rt=new AbortController;this.inFlightDependencies.push(rt),qe=Z.sendAsync({type:"GI",data:{icons:ne,source:this.source,tileID:this.tileID,type:"icons"}},rt)}const Qe=Object.keys(fe.patternDependencies);let Oe=Promise.resolve({});if(Qe.length){const rt=new AbortController;this.inFlightDependencies.push(rt),Oe=Z.sendAsync({type:"GI",data:{icons:Qe,source:this.source,tileID:this.tileID,type:"patterns"}},rt)}const[He,Tt,Ht]=yield Promise.all([Re,qe,Oe]),Xt=new be(He),Nt=new C.cG(Tt,Ht);for(const rt in re){const ot=re[rt];ot instanceof C.a9?(ut(ot.layers,this.zoom,R,this.globalState),C.cH({bucket:ot,glyphMap:He,glyphPositions:Xt.positions,imageMap:Tt,imagePositions:Nt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:fe.subdivisionGranularity})):ot.hasPattern&&(ot instanceof C.cI||ot instanceof C.cJ||ot instanceof C.cK)&&(ut(ot.layers,this.zoom,R,this.globalState),ot.addFeatures(fe,this.tileID.canonical,Nt.patternPositions))}return this.status="done",{buckets:Object.values(re).filter(rt=>!rt.isEmpty()),featureIndex:le,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Xt.image,imageAtlas:Nt,glyphMap:this.returnDependencies?He:null,iconMap:this.returnDependencies?Tt:null,glyphPositions:this.returnDependencies?Xt.positions:null}})}}function ut(ee,z,D,R){const Z=new C.F(z);for(const Y of ee)Y.setGlobalState(R),Y.recalculate(Z,D)}class pt{constructor(z,D,R){this.actor=z,this.layerIndex=D,this.availableImages=R,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(z,D){return C._(this,void 0,void 0,function*(){const R=yield C.n(z.request,D);try{return{vectorTile:new C.cL(new C.cM(R.data)),rawData:R.data,cacheControl:R.cacheControl,expires:R.expires}}catch(Z){const Y=new Uint8Array(R.data);let ie=`Unable to parse the tile at ${z.request.url}, `;throw ie+=Y[0]===31&&Y[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${Z.message}`,new Error(ie)}})}loadTile(z){return C._(this,void 0,void 0,function*(){const D=z.uid,R=!!(z&&z.request&&z.request.collectResourceTiming)&&new C.cN(z.request),Z=new ct(z);this.loading[D]=Z;const Y=new AbortController;Z.abort=Y;try{const ie=yield this.loadVectorTile(z,Y);if(delete this.loading[D],!ie)return null;const le=ie.rawData,re={};ie.expires&&(re.expires=ie.expires),ie.cacheControl&&(re.cacheControl=ie.cacheControl);const fe={};if(R){const _e=R.finish();_e&&(fe.resourceTiming=JSON.parse(JSON.stringify(_e)))}Z.vectorTile=ie.vectorTile;const ve=Z.parse(ie.vectorTile,this.layerIndex,this.availableImages,this.actor,z.subdivisionGranularity);this.loaded[D]=Z,this.fetching[D]={rawTileData:le,cacheControl:re,resourceTiming:fe};try{const _e=yield ve;return C.e({rawTileData:le.slice(0)},_e,re,fe)}finally{delete this.fetching[D]}}catch(ie){throw delete this.loading[D],Z.status="done",this.loaded[D]=Z,ie}})}reloadTile(z){return C._(this,void 0,void 0,function*(){const D=z.uid;if(!this.loaded||!this.loaded[D])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const R=this.loaded[D];if(R.showCollisionBoxes=z.showCollisionBoxes,R.globalState=z.globalState,R.status==="parsing"){const Z=yield R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor,z.subdivisionGranularity);let Y;if(this.fetching[D]){const{rawTileData:ie,cacheControl:le,resourceTiming:re}=this.fetching[D];delete this.fetching[D],Y=C.e({rawTileData:ie.slice(0)},Z,le,re)}else Y=Z;return Y}if(R.status==="done"&&R.vectorTile)return R.parse(R.vectorTile,this.layerIndex,this.availableImages,this.actor,z.subdivisionGranularity)})}abortTile(z){return C._(this,void 0,void 0,function*(){const D=this.loading,R=z.uid;D&&D[R]&&D[R].abort&&(D[R].abort.abort(),delete D[R])})}removeTile(z){return C._(this,void 0,void 0,function*(){this.loaded&&this.loaded[z.uid]&&delete this.loaded[z.uid]})}}class Ee{constructor(){this.loaded={}}loadTile(z){return C._(this,void 0,void 0,function*(){const{uid:D,encoding:R,rawImageData:Z,redFactor:Y,greenFactor:ie,blueFactor:le,baseShift:re}=z,fe=Z.width+2,ve=Z.height+2,_e=C.b(Z)?new C.R({width:fe,height:ve},yield C.cO(Z,-1,-1,fe,ve)):Z,Re=new C.cP(D,_e,R,Y,ie,le,re);return this.loaded=this.loaded||{},this.loaded[D]=Re,Re})}removeTile(z){const D=this.loaded,R=z.uid;D&&D[R]&&delete D[R]}}var se,Mt,ei=function(){if(Mt)return se;function ee(D,R){if(D.length!==0){z(D[0],R);for(var Z=1;Z<D.length;Z++)z(D[Z],!R)}}function z(D,R){for(var Z=0,Y=0,ie=0,le=D.length,re=le-1;ie<le;re=ie++){var fe=(D[ie][0]-D[re][0])*(D[re][1]+D[ie][1]),ve=Z+fe;Y+=Math.abs(Z)>=Math.abs(fe)?Z-ve+fe:fe-ve+Z,Z=ve}Z+Y>=0!=!!R&&D.reverse()}return Mt=1,se=function D(R,Z){var Y,ie=R&&R.type;if(ie==="FeatureCollection")for(Y=0;Y<R.features.length;Y++)D(R.features[Y],Z);else if(ie==="GeometryCollection")for(Y=0;Y<R.geometries.length;Y++)D(R.geometries[Y],Z);else if(ie==="Feature")D(R.geometry,Z);else if(ie==="Polygon")ee(R.coordinates,Z);else if(ie==="MultiPolygon")for(Y=0;Y<R.coordinates.length;Y++)ee(R.coordinates[Y],Z);return R}}(),Ri=C.cQ(ei);class Ci extends C.cS{constructor(z,D){super(new C.cM,0,D,[],[]),this.feature=z,this.type=z.type,this.properties=z.tags?z.tags:{},"id"in z&&(typeof z.id=="string"?this.id=parseInt(z.id,10):typeof z.id!="number"||isNaN(z.id)||(this.id=z.id))}loadGeometry(){const z=[],D=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(const R of D){const Z=[];for(const Y of R)Z.push(new C.P(Y[0],Y[1]));z.push(Z)}return z}}class It extends C.cR{constructor(z,D){super(new C.cM),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=D?D.version:1,this.extent=D?D.extent:4096,this.length=z.length,this.features=z}feature(z){return new Ci(this.features[z],this.extent)}}function ft(ee,z){z.writeVarintField(15,ee.version||1),z.writeStringField(1,ee.name||""),z.writeVarintField(5,ee.extent||4096);const D={keys:[],values:[],keycache:{},valuecache:{}};for(let Y=0;Y<ee.length;Y++)D.feature=ee.feature(Y),z.writeMessage(2,Ot,D);const R=D.keys;for(const Y of R)z.writeStringField(3,Y);const Z=D.values;for(const Y of Z)z.writeMessage(4,Ts,Y)}function Ot(ee,z){if(!ee.feature)return;const D=ee.feature;D.id!==void 0&&z.writeVarintField(1,D.id),z.writeMessage(2,$i,ee),z.writeVarintField(3,D.type),z.writeMessage(4,oa,D)}function $i(ee,z){var D;for(const R in(D=ee.feature)==null?void 0:D.properties){let Z=ee.feature.properties[R],Y=ee.keycache[R];if(Z===null)continue;Y===void 0&&(ee.keys.push(R),Y=ee.keys.length-1,ee.keycache[R]=Y),z.writeVarint(Y),typeof Z!="string"&&typeof Z!="boolean"&&typeof Z!="number"&&(Z=JSON.stringify(Z));const ie=typeof Z+":"+Z;let le=ee.valuecache[ie];le===void 0&&(ee.values.push(Z),le=ee.values.length-1,ee.valuecache[ie]=le),z.writeVarint(le)}}function Sr(ee,z){return(z<<3)+(7&ee)}function jn(ee){return ee<<1^ee>>31}function oa(ee,z){const D=ee.loadGeometry(),R=ee.type;let Z=0,Y=0;for(const ie of D){let le=1;R===1&&(le=ie.length),z.writeVarint(Sr(1,le));const re=R===3?ie.length-1:ie.length;for(let fe=0;fe<re;fe++){fe===1&&R!==1&&z.writeVarint(Sr(2,re-1));const ve=ie[fe].x-Z,_e=ie[fe].y-Y;z.writeVarint(jn(ve)),z.writeVarint(jn(_e)),Z+=ve,Y+=_e}ee.type===3&&z.writeVarint(Sr(7,1))}}function Ts(ee,z){const D=typeof ee;D==="string"?z.writeStringField(1,ee):D==="boolean"?z.writeBooleanField(7,ee):D==="number"&&(ee%1!=0?z.writeDoubleField(3,ee):ee<0?z.writeSVarintField(6,ee):z.writeVarintField(5,ee))}const pr={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ee=>ee},Br=Math.fround||(fr=new Float32Array(1),ee=>(fr[0]=+ee,fr[0]));var fr;class Or{constructor(z){this.options=Object.assign(Object.create(pr),z),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(z){const{log:D,minZoom:R,maxZoom:Z}=this.options;D&&console.time("total time");const Y=`prepare ${z.length} points`;D&&console.time(Y),this.points=z;const ie=[];for(let re=0;re<z.length;re++){const fe=z[re];if(!fe.geometry)continue;const[ve,_e]=fe.geometry.coordinates,Re=Br(hn(ve)),ne=Br(un(_e));ie.push(Re,ne,1/0,re,-1,1),this.options.reduce&&ie.push(0)}let le=this.trees[Z+1]=this._createTree(ie);D&&console.timeEnd(Y);for(let re=Z;re>=R;re--){const fe=+Date.now();le=this.trees[re]=this._createTree(this._cluster(le,re)),D&&console.log("z%d: %d clusters in %dms",re,le.numItems,+Date.now()-fe)}return D&&console.timeEnd("total time"),this}getClusters(z,D){let R=((z[0]+180)%360+360)%360-180;const Z=Math.max(-90,Math.min(90,z[1]));let Y=z[2]===180?180:((z[2]+180)%360+360)%360-180;const ie=Math.max(-90,Math.min(90,z[3]));if(z[2]-z[0]>=360)R=-180,Y=180;else if(R>Y){const _e=this.getClusters([R,Z,180,ie],D),Re=this.getClusters([-180,Z,Y,ie],D);return _e.concat(Re)}const le=this.trees[this._limitZoom(D)],re=le.range(hn(R),un(ie),hn(Y),un(Z)),fe=le.data,ve=[];for(const _e of re){const Re=this.stride*_e;ve.push(fe[Re+5]>1?Ps(fe,Re,this.clusterProps):this.points[fe[Re+3]])}return ve}getChildren(z){const D=this._getOriginId(z),R=this._getOriginZoom(z),Z="No cluster with the specified id.",Y=this.trees[R];if(!Y)throw new Error(Z);const ie=Y.data;if(D*this.stride>=ie.length)throw new Error(Z);const le=this.options.radius/(this.options.extent*Math.pow(2,R-1)),re=Y.within(ie[D*this.stride],ie[D*this.stride+1],le),fe=[];for(const ve of re){const _e=ve*this.stride;ie[_e+4]===z&&fe.push(ie[_e+5]>1?Ps(ie,_e,this.clusterProps):this.points[ie[_e+3]])}if(fe.length===0)throw new Error(Z);return fe}getLeaves(z,D,R){const Z=[];return this._appendLeaves(Z,z,D=D||10,R=R||0,0),Z}getTile(z,D,R){const Z=this.trees[this._limitZoom(z)],Y=Math.pow(2,z),{extent:ie,radius:le}=this.options,re=le/ie,fe=(R-re)/Y,ve=(R+1+re)/Y,_e={features:[]};return this._addTileFeatures(Z.range((D-re)/Y,fe,(D+1+re)/Y,ve),Z.data,D,R,Y,_e),D===0&&this._addTileFeatures(Z.range(1-re/Y,fe,1,ve),Z.data,Y,R,Y,_e),D===Y-1&&this._addTileFeatures(Z.range(0,fe,re/Y,ve),Z.data,-1,R,Y,_e),_e.features.length?_e:null}getClusterExpansionZoom(z){let D=this._getOriginZoom(z)-1;for(;D<=this.options.maxZoom;){const R=this.getChildren(z);if(D++,R.length!==1)break;z=R[0].properties.cluster_id}return D}_appendLeaves(z,D,R,Z,Y){const ie=this.getChildren(D);for(const le of ie){const re=le.properties;if(re&&re.cluster?Y+re.point_count<=Z?Y+=re.point_count:Y=this._appendLeaves(z,re.cluster_id,R,Z,Y):Y<Z?Y++:z.push(le),z.length===R)break}return Y}_createTree(z){const D=new C.aI(z.length/this.stride|0,this.options.nodeSize,Float32Array);for(let R=0;R<z.length;R+=this.stride)D.add(z[R],z[R+1]);return D.finish(),D.data=z,D}_addTileFeatures(z,D,R,Z,Y,ie){for(const le of z){const re=le*this.stride,fe=D[re+5]>1;let ve,_e,Re;if(fe)ve=cn(D,re,this.clusterProps),_e=D[re],Re=D[re+1];else{const Qe=this.points[D[re+3]];ve=Qe.properties;const[Oe,He]=Qe.geometry.coordinates;_e=hn(Oe),Re=un(He)}const ne={type:1,geometry:[[Math.round(this.options.extent*(_e*Y-R)),Math.round(this.options.extent*(Re*Y-Z))]],tags:ve};let qe;qe=fe||this.options.generateId?D[re+3]:this.points[D[re+3]].id,qe!==void 0&&(ne.id=qe),ie.features.push(ne)}}_limitZoom(z){return Math.max(this.options.minZoom,Math.min(Math.floor(+z),this.options.maxZoom+1))}_cluster(z,D){const{radius:R,extent:Z,reduce:Y,minPoints:ie}=this.options,le=R/(Z*Math.pow(2,D)),re=z.data,fe=[],ve=this.stride;for(let _e=0;_e<re.length;_e+=ve){if(re[_e+2]<=D)continue;re[_e+2]=D;const Re=re[_e],ne=re[_e+1],qe=z.within(re[_e],re[_e+1],le),Qe=re[_e+5];let Oe=Qe;for(const He of qe){const Tt=He*ve;re[Tt+2]>D&&(Oe+=re[Tt+5])}if(Oe>Qe&&Oe>=ie){let He,Tt=Re*Qe,Ht=ne*Qe,Xt=-1;const Nt=(_e/ve<<5)+(D+1)+this.points.length;for(const rt of qe){const ot=rt*ve;if(re[ot+2]<=D)continue;re[ot+2]=D;const Ut=re[ot+5];Tt+=re[ot]*Ut,Ht+=re[ot+1]*Ut,re[ot+4]=Nt,Y&&(He||(He=this._map(re,_e,!0),Xt=this.clusterProps.length,this.clusterProps.push(He)),Y(He,this._map(re,ot)))}re[_e+4]=Nt,fe.push(Tt/Oe,Ht/Oe,1/0,Nt,-1,Oe),Y&&fe.push(Xt)}else{for(let He=0;He<ve;He++)fe.push(re[_e+He]);if(Oe>1)for(const He of qe){const Tt=He*ve;if(!(re[Tt+2]<=D)){re[Tt+2]=D;for(let Ht=0;Ht<ve;Ht++)fe.push(re[Tt+Ht])}}}}return fe}_getOriginId(z){return z-this.points.length>>5}_getOriginZoom(z){return(z-this.points.length)%32}_map(z,D,R){if(z[D+5]>1){const ie=this.clusterProps[z[D+6]];return R?Object.assign({},ie):ie}const Z=this.points[z[D+3]].properties,Y=this.options.map(Z);return R&&Y===Z?Object.assign({},Y):Y}}function Ps(ee,z,D){return{type:"Feature",id:ee[z+3],properties:cn(ee,z,D),geometry:{type:"Point",coordinates:[(R=ee[z],360*(R-.5)),la(ee[z+1])]}};var R}function cn(ee,z,D){const R=ee[z+5],Z=R>=1e4?`${Math.round(R/1e3)}k`:R>=1e3?Math.round(R/100)/10+"k":R,Y=ee[z+6],ie=Y===-1?{}:Object.assign({},D[Y]);return Object.assign(ie,{cluster:!0,cluster_id:ee[z+3],point_count:R,point_count_abbreviated:Z})}function hn(ee){return ee/360+.5}function un(ee){const z=Math.sin(ee*Math.PI/180),D=.5-.25*Math.log((1+z)/(1-z))/Math.PI;return D<0?0:D>1?1:D}function la(ee){const z=(180-360*ee)*Math.PI/180;return 360*Math.atan(Math.exp(z))/Math.PI-90}function gt(ee,z,D,R){let Z=R;const Y=z+(D-z>>1);let ie,le=D-z;const re=ee[z],fe=ee[z+1],ve=ee[D],_e=ee[D+1];for(let Re=z+3;Re<D;Re+=3){const ne=dn(ee[Re],ee[Re+1],re,fe,ve,_e);if(ne>Z)ie=Re,Z=ne;else if(ne===Z){const qe=Math.abs(Re-Y);qe<le&&(ie=Re,le=qe)}}Z>R&&(ie-z>3&&gt(ee,z,ie,R),ee[ie+2]=Z,D-ie>3&&gt(ee,ie,D,R))}function dn(ee,z,D,R,Z,Y){let ie=Z-D,le=Y-R;if(ie!==0||le!==0){const re=((ee-D)*ie+(z-R)*le)/(ie*ie+le*le);re>1?(D=Z,R=Y):re>0&&(D+=ie*re,R+=le*re)}return ie=ee-D,le=z-R,ie*ie+le*le}function mi(ee,z,D,R){const Z={id:ee??null,type:z,geometry:D,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(z==="Point"||z==="MultiPoint"||z==="LineString")pn(Z,D);else if(z==="Polygon")pn(Z,D[0]);else if(z==="MultiLineString")for(const Y of D)pn(Z,Y);else if(z==="MultiPolygon")for(const Y of D)pn(Z,Y[0]);return Z}function pn(ee,z){for(let D=0;D<z.length;D+=3)ee.minX=Math.min(ee.minX,z[D]),ee.minY=Math.min(ee.minY,z[D+1]),ee.maxX=Math.max(ee.maxX,z[D]),ee.maxY=Math.max(ee.maxY,z[D+1])}function mr(ee,z,D,R){if(!z.geometry)return;const Z=z.geometry.coordinates;if(Z&&Z.length===0)return;const Y=z.geometry.type,ie=Math.pow(D.tolerance/((1<<D.maxZoom)*D.extent),2);let le=[],re=z.id;if(D.promoteId?re=z.properties[D.promoteId]:D.generateId&&(re=R||0),Y==="Point")jr(Z,le);else if(Y==="MultiPoint")for(const fe of Z)jr(fe,le);else if(Y==="LineString")fn(Z,le,ie,!1);else if(Y==="MultiLineString"){if(D.lineMetrics){for(const fe of Z)le=[],fn(fe,le,ie,!1),ee.push(mi(re,"LineString",le,z.properties));return}Ei(Z,le,ie,!1)}else if(Y==="Polygon")Ei(Z,le,ie,!0);else{if(Y!=="MultiPolygon"){if(Y==="GeometryCollection"){for(const fe of z.geometry.geometries)mr(ee,{id:re,geometry:fe,properties:z.properties},D,R);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const fe of Z){const ve=[];Ei(fe,ve,ie,!0),le.push(ve)}}ee.push(mi(re,Y,le,z.properties))}function jr(ee,z){z.push(Nn(ee[0]),Zi(ee[1]),0)}function fn(ee,z,D,R){let Z,Y,ie=0;for(let re=0;re<ee.length;re++){const fe=Nn(ee[re][0]),ve=Zi(ee[re][1]);z.push(fe,ve,0),re>0&&(ie+=R?(Z*ve-fe*Y)/2:Math.sqrt(Math.pow(fe-Z,2)+Math.pow(ve-Y,2))),Z=fe,Y=ve}const le=z.length-3;z[2]=1,gt(z,0,le,D),z[le+2]=1,z.size=Math.abs(ie),z.start=0,z.end=z.size}function Ei(ee,z,D,R){for(let Z=0;Z<ee.length;Z++){const Y=[];fn(ee[Z],Y,D,R),z.push(Y)}}function Nn(ee){return ee/360+.5}function Zi(ee){const z=Math.sin(ee*Math.PI/180),D=.5-.25*Math.log((1+z)/(1-z))/Math.PI;return D<0?0:D>1?1:D}function Yi(ee,z,D,R,Z,Y,ie,le){if(R/=z,Y>=(D/=z)&&ie<R)return ee;if(ie<D||Y>=R)return null;const re=[];for(const fe of ee){const ve=fe.geometry;let _e=fe.type;const Re=Z===0?fe.minX:fe.minY,ne=Z===0?fe.maxX:fe.maxY;if(Re>=D&&ne<R){re.push(fe);continue}if(ne<D||Re>=R)continue;let qe=[];if(_e==="Point"||_e==="MultiPoint")Vn(ve,qe,D,R,Z);else if(_e==="LineString")Un(ve,qe,D,R,Z,!1,le.lineMetrics);else if(_e==="MultiLineString")Dt(ve,qe,D,R,Z,!1);else if(_e==="Polygon")Dt(ve,qe,D,R,Z,!0);else if(_e==="MultiPolygon")for(const Qe of ve){const Oe=[];Dt(Qe,Oe,D,R,Z,!0),Oe.length&&qe.push(Oe)}if(qe.length){if(le.lineMetrics&&_e==="LineString"){for(const Qe of qe)re.push(mi(fe.id,_e,Qe,fe.tags));continue}_e!=="LineString"&&_e!=="MultiLineString"||(qe.length===1?(_e="LineString",qe=qe[0]):_e="MultiLineString"),_e!=="Point"&&_e!=="MultiPoint"||(_e=qe.length===3?"Point":"MultiPoint"),re.push(mi(fe.id,_e,qe,fe.tags))}}return re.length?re:null}function Vn(ee,z,D,R,Z){for(let Y=0;Y<ee.length;Y+=3){const ie=ee[Y+Z];ie>=D&&ie<=R&&jt(z,ee[Y],ee[Y+1],ee[Y+2])}}function Un(ee,z,D,R,Z,Y,ie){let le=Fi(ee);const re=Z===0?Ki:gr;let fe,ve,_e=ee.start;for(let Oe=0;Oe<ee.length-3;Oe+=3){const He=ee[Oe],Tt=ee[Oe+1],Ht=ee[Oe+2],Xt=ee[Oe+3],Nt=ee[Oe+4],rt=Z===0?He:Tt,ot=Z===0?Xt:Nt;let Ut=!1;ie&&(fe=Math.sqrt(Math.pow(He-Xt,2)+Math.pow(Tt-Nt,2))),rt<D?ot>D&&(ve=re(le,He,Tt,Xt,Nt,D),ie&&(le.start=_e+fe*ve)):rt>R?ot<R&&(ve=re(le,He,Tt,Xt,Nt,R),ie&&(le.start=_e+fe*ve)):jt(le,He,Tt,Ht),ot<D&&rt>=D&&(ve=re(le,He,Tt,Xt,Nt,D),Ut=!0),ot>R&&rt<=R&&(ve=re(le,He,Tt,Xt,Nt,R),Ut=!0),!Y&&Ut&&(ie&&(le.end=_e+fe*ve),z.push(le),le=Fi(ee)),ie&&(_e+=fe)}let Re=ee.length-3;const ne=ee[Re],qe=ee[Re+1],Qe=Z===0?ne:qe;Qe>=D&&Qe<=R&&jt(le,ne,qe,ee[Re+2]),Re=le.length-3,Y&&Re>=3&&(le[Re]!==le[0]||le[Re+1]!==le[1])&&jt(le,le[0],le[1],le[2]),le.length&&z.push(le)}function Fi(ee){const z=[];return z.size=ee.size,z.start=ee.start,z.end=ee.end,z}function Dt(ee,z,D,R,Z,Y){for(const ie of ee)Un(ie,z,D,R,Z,Y,!1)}function jt(ee,z,D,R){ee.push(z,D,R)}function Ki(ee,z,D,R,Z,Y){const ie=(Y-z)/(R-z);return jt(ee,Y,D+(Z-D)*ie,1),ie}function gr(ee,z,D,R,Z,Y){const ie=(Y-D)/(Z-D);return jt(ee,z+(R-z)*ie,Y,1),ie}function mn(ee,z){const D=[];for(let R=0;R<ee.length;R++){const Z=ee[R],Y=Z.type;let ie;if(Y==="Point"||Y==="MultiPoint"||Y==="LineString")ie=_r(Z.geometry,z);else if(Y==="MultiLineString"||Y==="Polygon"){ie=[];for(const le of Z.geometry)ie.push(_r(le,z))}else if(Y==="MultiPolygon"){ie=[];for(const le of Z.geometry){const re=[];for(const fe of le)re.push(_r(fe,z));ie.push(re)}}D.push(mi(Z.id,Y,ie,Z.tags))}return D}function _r(ee,z){const D=[];D.size=ee.size,ee.start!==void 0&&(D.start=ee.start,D.end=ee.end);for(let R=0;R<ee.length;R+=3)D.push(ee[R]+z,ee[R+1],ee[R+2]);return D}function yr(ee,z){if(ee.transformed)return ee;const D=1<<ee.z,R=ee.x,Z=ee.y;for(const Y of ee.features){const ie=Y.geometry,le=Y.type;if(Y.geometry=[],le===1)for(let re=0;re<ie.length;re+=2)Y.geometry.push($n(ie[re],ie[re+1],z,D,R,Z));else for(let re=0;re<ie.length;re++){const fe=[];for(let ve=0;ve<ie[re].length;ve+=2)fe.push($n(ie[re][ve],ie[re][ve+1],z,D,R,Z));Y.geometry.push(fe)}}return ee.transformed=!0,ee}function $n(ee,z,D,R,Z,Y){return[Math.round(D*(ee*R-Z)),Math.round(D*(z*R-Y))]}function Nr(ee,z,D,R,Z){const Y=z===Z.maxZoom?0:Z.tolerance/((1<<z)*Z.extent),ie={features:[],numPoints:0,numSimplified:0,numFeatures:ee.length,source:null,x:D,y:R,z,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const le of ee)Vr(ie,le,Y,Z);return ie}function Vr(ee,z,D,R){const Z=z.geometry,Y=z.type,ie=[];if(ee.minX=Math.min(ee.minX,z.minX),ee.minY=Math.min(ee.minY,z.minY),ee.maxX=Math.max(ee.maxX,z.maxX),ee.maxY=Math.max(ee.maxY,z.maxY),Y==="Point"||Y==="MultiPoint")for(let le=0;le<Z.length;le+=3)ie.push(Z[le],Z[le+1]),ee.numPoints++,ee.numSimplified++;else if(Y==="LineString")Ur(ie,Z,ee,D,!1,!1);else if(Y==="MultiLineString"||Y==="Polygon")for(let le=0;le<Z.length;le++)Ur(ie,Z[le],ee,D,Y==="Polygon",le===0);else if(Y==="MultiPolygon")for(let le=0;le<Z.length;le++){const re=Z[le];for(let fe=0;fe<re.length;fe++)Ur(ie,re[fe],ee,D,!0,fe===0)}if(ie.length){let le=z.tags||null;if(Y==="LineString"&&R.lineMetrics){le={};for(const fe in z.tags)le[fe]=z.tags[fe];le.mapbox_clip_start=Z.start/Z.size,le.mapbox_clip_end=Z.end/Z.size}const re={geometry:ie,type:Y==="Polygon"||Y==="MultiPolygon"?3:Y==="LineString"||Y==="MultiLineString"?2:1,tags:le};z.id!==null&&(re.id=z.id),ee.features.push(re)}}function Ur(ee,z,D,R,Z,Y){const ie=R*R;if(R>0&&z.size<(Z?ie:R))return void(D.numPoints+=z.length/3);const le=[];for(let re=0;re<z.length;re+=3)(R===0||z[re+2]>ie)&&(D.numSimplified++,le.push(z[re],z[re+1])),D.numPoints++;Z&&function(re,fe){let ve=0;for(let _e=0,Re=re.length,ne=Re-2;_e<Re;ne=_e,_e+=2)ve+=(re[_e]-re[ne])*(re[_e+1]+re[ne+1]);if(ve>0===fe)for(let _e=0,Re=re.length;_e<Re/2;_e+=2){const ne=re[_e],qe=re[_e+1];re[_e]=re[Re-2-_e],re[_e+1]=re[Re-1-_e],re[Re-2-_e]=ne,re[Re-1-_e]=qe}}(le,Y),ee.push(le)}const gn={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class $r{constructor(z,D){const R=(D=this.options=function(Y,ie){for(const le in ie)Y[le]=ie[le];return Y}(Object.create(gn),D)).debug;if(R&&console.time("preprocess data"),D.maxZoom<0||D.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(D.promoteId&&D.generateId)throw new Error("promoteId and generateId cannot be used together.");let Z=function(Y,ie){const le=[];if(Y.type==="FeatureCollection")for(let re=0;re<Y.features.length;re++)mr(le,Y.features[re],ie,re);else mr(le,Y.type==="Feature"?Y:{geometry:Y},ie);return le}(z,D);this.tiles={},this.tileCoords=[],R&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",D.indexMaxZoom,D.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),Z=function(Y,ie){const le=ie.buffer/ie.extent;let re=Y;const fe=Yi(Y,1,-1-le,le,0,-1,2,ie),ve=Yi(Y,1,1-le,2+le,0,-1,2,ie);return(fe||ve)&&(re=Yi(Y,1,-le,1+le,0,-1,2,ie)||[],fe&&(re=mn(fe,1).concat(re)),ve&&(re=re.concat(mn(ve,-1)))),re}(Z,D),Z.length&&this.splitTile(Z,0,0,0),R&&(Z.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(z,D,R,Z,Y,ie,le){const re=[z,D,R,Z],fe=this.options,ve=fe.debug;for(;re.length;){Z=re.pop(),R=re.pop(),D=re.pop(),z=re.pop();const _e=1<<D,Re=Zr(D,R,Z);let ne=this.tiles[Re];if(!ne&&(ve>1&&console.time("creation"),ne=this.tiles[Re]=Nr(z,D,R,Z,fe),this.tileCoords.push({z:D,x:R,y:Z}),ve)){ve>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",D,R,Z,ne.numFeatures,ne.numPoints,ne.numSimplified),console.timeEnd("creation"));const Ut=`z${D}`;this.stats[Ut]=(this.stats[Ut]||0)+1,this.total++}if(ne.source=z,Y==null){if(D===fe.indexMaxZoom||ne.numPoints<=fe.indexMaxPoints)continue}else{if(D===fe.maxZoom||D===Y)continue;if(Y!=null){const Ut=Y-D;if(R!==ie>>Ut||Z!==le>>Ut)continue}}if(ne.source=null,z.length===0)continue;ve>1&&console.time("clipping");const qe=.5*fe.buffer/fe.extent,Qe=.5-qe,Oe=.5+qe,He=1+qe;let Tt=null,Ht=null,Xt=null,Nt=null,rt=Yi(z,_e,R-qe,R+Oe,0,ne.minX,ne.maxX,fe),ot=Yi(z,_e,R+Qe,R+He,0,ne.minX,ne.maxX,fe);z=null,rt&&(Tt=Yi(rt,_e,Z-qe,Z+Oe,1,ne.minY,ne.maxY,fe),Ht=Yi(rt,_e,Z+Qe,Z+He,1,ne.minY,ne.maxY,fe),rt=null),ot&&(Xt=Yi(ot,_e,Z-qe,Z+Oe,1,ne.minY,ne.maxY,fe),Nt=Yi(ot,_e,Z+Qe,Z+He,1,ne.minY,ne.maxY,fe),ot=null),ve>1&&console.timeEnd("clipping"),re.push(Tt||[],D+1,2*R,2*Z),re.push(Ht||[],D+1,2*R,2*Z+1),re.push(Xt||[],D+1,2*R+1,2*Z),re.push(Nt||[],D+1,2*R+1,2*Z+1)}}getTile(z,D,R){z=+z,D=+D,R=+R;const Z=this.options,{extent:Y,debug:ie}=Z;if(z<0||z>24)return null;const le=1<<z,re=Zr(z,D=D+le&le-1,R);if(this.tiles[re])return yr(this.tiles[re],Y);ie>1&&console.log("drilling down to z%d-%d-%d",z,D,R);let fe,ve=z,_e=D,Re=R;for(;!fe&&ve>0;)ve--,_e>>=1,Re>>=1,fe=this.tiles[Zr(ve,_e,Re)];return fe&&fe.source?(ie>1&&(console.log("found parent tile z%d-%d-%d",ve,_e,Re),console.time("drilling down")),this.splitTile(fe.source,ve,_e,Re,z,D,R),ie>1&&console.timeEnd("drilling down"),this.tiles[re]?yr(this.tiles[re],Y):null):null}}function Zr(ee,z,D){return 32*((1<<ee)*D+z)+ee}class Gr extends pt{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(z,D){return C._(this,void 0,void 0,function*(){const R=z.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const Z=this._geoJSONIndex.getTile(R.z,R.x,R.y);if(!Z)return null;const Y=new It(Z.features,{version:2,extent:C.$});let ie=function(le){const re=new C.cM;return function(fe,ve){for(const _e in fe.layers)ve.writeMessage(3,ft,fe.layers[_e])}(le,re),re.finish()}(Y);return ie.byteOffset===0&&ie.byteLength===ie.buffer.byteLength||(ie=new Uint8Array(ie)),{vectorTile:Y,rawData:ie.buffer}})}loadData(z){return C._(this,void 0,void 0,function*(){var D;(D=this._pendingRequest)===null||D===void 0||D.abort();const R=!!(z&&z.request&&z.request.collectResourceTiming)&&new C.cN(z.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(z,this._pendingRequest);const Z=yield this._pendingData;this._geoJSONIndex=z.cluster?new Or(function({superclusterOptions:ie,clusterProperties:le}){if(!le||!ie)return ie;const re={},fe={},ve={accumulated:null,zoom:0},_e={properties:null},Re=Object.keys(le);for(const ne of Re){const[qe,Qe]=le[ne],Oe=C.cT(Qe),He=C.cT(typeof qe=="string"?[qe,["accumulated"],["get",ne]]:qe);re[ne]=Oe.value,fe[ne]=He.value}return ie.map=ne=>{_e.properties=ne;const qe={};for(const Qe of Re)qe[Qe]=re[Qe].evaluate(ve,_e);return qe},ie.reduce=(ne,qe)=>{_e.properties=qe;for(const Qe of Re)ve.accumulated=ne[Qe],ne[Qe]=fe[Qe].evaluate(ve,_e)},ie}(z)).load(Z.features):function(ie,le){return new $r(ie,le)}(Z,z.geojsonVtOptions),this.loaded={};const Y={data:Z};if(R){const ie=R.finish();ie&&(Y.resourceTiming={},Y.resourceTiming[z.source]=JSON.parse(JSON.stringify(ie)))}return Y}catch(Z){if(delete this._pendingRequest,C.cy(Z))return{abandoned:!0};throw Z}})}getData(){return C._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(z){const D=this.loaded;return D&&D[z.uid]?super.reloadTile(z):this.loadTile(z)}loadAndProcessGeoJSON(z,D){return C._(this,void 0,void 0,function*(){let R=yield this.loadGeoJSON(z,D);if(delete this._pendingRequest,typeof R!="object")throw new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`);if(Ri(R,!0),z.filter){const Z=C.cT(z.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Z.result==="error")throw new Error(Z.value.map(ie=>`${ie.key}: ${ie.message}`).join(", "));R={type:"FeatureCollection",features:R.features.filter(ie=>Z.value.evaluate({zoom:0},ie))}}return R})}loadGeoJSON(z,D){return C._(this,void 0,void 0,function*(){const{promoteId:R}=z;if(z.request){const Z=yield C.j(z.request,D);return this._dataUpdateable=C.cV(Z.data,R)?C.cU(Z.data,R):void 0,Z.data}if(typeof z.data=="string")try{const Z=JSON.parse(z.data);return this._dataUpdateable=C.cV(Z,R)?C.cU(Z,R):void 0,Z}catch{throw new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`)}if(!z.dataDiff)throw new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${z.source}`);return C.cW(this._dataUpdateable,z.dataDiff,R),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(z){return C._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(z){return this._geoJSONIndex.getClusterExpansionZoom(z.clusterId)}getClusterChildren(z){return this._geoJSONIndex.getChildren(z.clusterId)}getClusterLeaves(z){return this._geoJSONIndex.getLeaves(z.clusterId,z.limit,z.offset)}}class Zn{constructor(z){this.self=z,this.actor=new C.J(z),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(D,R)=>{if(this.externalWorkerSourceTypes[D])throw new Error(`Worker source with name "${D}" already registered.`);this.externalWorkerSourceTypes[D]=R},this.self.addProtocol=C.cA,this.self.removeProtocol=C.cB,this.self.registerRTLTextPlugin=D=>{C.cX.setMethods(D)},this.actor.registerMessageHandler("LDT",(D,R)=>this._getDEMWorkerSource(D,R.source).loadTile(R)),this.actor.registerMessageHandler("RDT",(D,R)=>C._(this,void 0,void 0,function*(){this._getDEMWorkerSource(D,R.source).removeTile(R)})),this.actor.registerMessageHandler("GCEZ",(D,R)=>C._(this,void 0,void 0,function*(){return this._getWorkerSource(D,R.type,R.source).getClusterExpansionZoom(R)})),this.actor.registerMessageHandler("GCC",(D,R)=>C._(this,void 0,void 0,function*(){return this._getWorkerSource(D,R.type,R.source).getClusterChildren(R)})),this.actor.registerMessageHandler("GCL",(D,R)=>C._(this,void 0,void 0,function*(){return this._getWorkerSource(D,R.type,R.source).getClusterLeaves(R)})),this.actor.registerMessageHandler("LD",(D,R)=>this._getWorkerSource(D,R.type,R.source).loadData(R)),this.actor.registerMessageHandler("GD",(D,R)=>this._getWorkerSource(D,R.type,R.source).getData()),this.actor.registerMessageHandler("LT",(D,R)=>this._getWorkerSource(D,R.type,R.source).loadTile(R)),this.actor.registerMessageHandler("RT",(D,R)=>this._getWorkerSource(D,R.type,R.source).reloadTile(R)),this.actor.registerMessageHandler("AT",(D,R)=>this._getWorkerSource(D,R.type,R.source).abortTile(R)),this.actor.registerMessageHandler("RMT",(D,R)=>this._getWorkerSource(D,R.type,R.source).removeTile(R)),this.actor.registerMessageHandler("RS",(D,R)=>C._(this,void 0,void 0,function*(){if(!this.workerSources[D]||!this.workerSources[D][R.type]||!this.workerSources[D][R.type][R.source])return;const Z=this.workerSources[D][R.type][R.source];delete this.workerSources[D][R.type][R.source],Z.removeSource!==void 0&&Z.removeSource(R)})),this.actor.registerMessageHandler("RM",D=>C._(this,void 0,void 0,function*(){delete this.layerIndexes[D],delete this.availableImages[D],delete this.workerSources[D],delete this.demWorkerSources[D]})),this.actor.registerMessageHandler("SR",(D,R)=>C._(this,void 0,void 0,function*(){this.referrer=R})),this.actor.registerMessageHandler("SRPS",(D,R)=>this._syncRTLPluginState(D,R)),this.actor.registerMessageHandler("IS",(D,R)=>C._(this,void 0,void 0,function*(){this.self.importScripts(R)})),this.actor.registerMessageHandler("SI",(D,R)=>this._setImages(D,R)),this.actor.registerMessageHandler("UL",(D,R)=>C._(this,void 0,void 0,function*(){this._getLayerIndex(D).update(R.layers,R.removedIds)})),this.actor.registerMessageHandler("SL",(D,R)=>C._(this,void 0,void 0,function*(){this._getLayerIndex(D).replace(R)}))}_setImages(z,D){return C._(this,void 0,void 0,function*(){this.availableImages[z]=D;for(const R in this.workerSources[z]){const Z=this.workerSources[z][R];for(const Y in Z)Z[Y].availableImages=D}})}_syncRTLPluginState(z,D){return C._(this,void 0,void 0,function*(){return yield C.cX.syncState(D,this.self.importScripts)})}_getAvailableImages(z){let D=this.availableImages[z];return D||(D=[]),D}_getLayerIndex(z){let D=this.layerIndexes[z];return D||(D=this.layerIndexes[z]=new c),D}_getWorkerSource(z,D,R){if(this.workerSources[z]||(this.workerSources[z]={}),this.workerSources[z][D]||(this.workerSources[z][D]={}),!this.workerSources[z][D][R]){const Z={sendAsync:(Y,ie)=>(Y.targetMapId=z,this.actor.sendAsync(Y,ie))};switch(D){case"vector":this.workerSources[z][D][R]=new pt(Z,this._getLayerIndex(z),this._getAvailableImages(z));break;case"geojson":this.workerSources[z][D][R]=new Gr(Z,this._getLayerIndex(z),this._getAvailableImages(z));break;default:this.workerSources[z][D][R]=new this.externalWorkerSourceTypes[D](Z,this._getLayerIndex(z),this._getAvailableImages(z))}}return this.workerSources[z][D][R]}_getDEMWorkerSource(z,D){return this.demWorkerSources[z]||(this.demWorkerSources[z]={}),this.demWorkerSources[z][D]||(this.demWorkerSources[z][D]=new Ee),this.demWorkerSources[z][D]}}return C.i(self)&&(self.worker=new Zn(self)),Zn}),je("index",["exports","./shared"],function(C,c){var be="5.7.1";function ct(){var h=new c.A(4);return c.A!=Float32Array&&(h[1]=0,h[2]=0),h[0]=1,h[3]=1,h}let ut,pt;const Ee={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(h,e,n){const a=requestAnimationFrame(u=>{l(),e(u)}),{unsubscribe:l}=c.s(h.signal,"abort",()=>{l(),cancelAnimationFrame(a),n(c.c())},!1)},frameAsync(h){return new Promise((e,n)=>{this.frame(h,e,n)})},getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){const e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>(ut||(ut=document.createElement("a")),ut.href=h,ut.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(pt==null&&(pt=matchMedia("(prefers-reduced-motion: reduce)")),pt.matches)}};class se{static testProp(e){if(!se.docStyle)return e[0];for(let n=0;n<e.length;n++)if(e[n]in se.docStyle)return e[n];return e[0]}static create(e,n,a){const l=window.document.createElement(e);return n!==void 0&&(l.className=n),a&&a.appendChild(l),l}static createNS(e,n){return window.document.createElementNS(e,n)}static disableDrag(){se.docStyle&&se.selectProp&&(se.userSelect=se.docStyle[se.selectProp],se.docStyle[se.selectProp]="none")}static enableDrag(){se.docStyle&&se.selectProp&&(se.docStyle[se.selectProp]=se.userSelect)}static setTransform(e,n){e.style[se.transformProp]=n}static addEventListener(e,n,a,l={}){e.addEventListener(n,a,"passive"in l?l:l.capture)}static removeEventListener(e,n,a,l={}){e.removeEventListener(n,a,"passive"in l?l:l.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",se.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",se.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",se.suppressClickInternal,!0)},0)}static getScale(e){const n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,a){const l=n.boundingClientRect;return new c.P((a.clientX-l.left)/n.x-e.clientLeft,(a.clientY-l.top)/n.y-e.clientTop)}static mousePos(e,n){const a=se.getScale(e);return se.getPoint(e,a,n)}static touchPos(e,n){const a=[],l=se.getScale(e);for(let u=0;u<n.length;u++)a.push(se.getPoint(e,l,n[u]));return a}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}static sanitize(e){const n=new DOMParser().parseFromString(e,"text/html").body||document.createElement("body"),a=n.querySelectorAll("script");for(const l of a)l.remove();return se.clean(n),n.innerHTML}static isPossiblyDangerous(e,n){const a=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!a.includes("javascript:")&&!a.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const n=e.children;for(const a of n)se.removeAttributes(a),se.clean(a)}static removeAttributes(e){for(const{name:n,value:a}of e.attributes)se.isPossiblyDangerous(n,a)&&e.removeAttribute(n)}}se.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,se.selectProp=se.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),se.transformProp=se.testProp(["transform","WebkitTransform"]);const Mt={supported:!1,testSupport:function(h){!Ci&&Ri&&(It?ft(h):ei=h)}};let ei,Ri,Ci=!1,It=!1;function ft(h){const e=h.createTexture();h.bindTexture(h.TEXTURE_2D,e);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,Ri),h.isContextLost())return;Mt.supported=!0}catch{}h.deleteTexture(e),Ci=!0}var Ot;typeof document<"u"&&(Ri=document.createElement("img"),Ri.onload=()=>{ei&&ft(ei),ei=null,It=!0},Ri.onerror=()=>{Ci=!0,ei=null},Ri.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(h){let e,n,a,l;h.resetRequestQueue=()=>{e=[],n=0,a=0,l={}},h.addThrottleControl=y=>{const b=a++;return l[b]=y,b},h.removeThrottleControl=y=>{delete l[y],f()},h.getImage=(y,b,w=!0)=>new Promise((S,P)=>{Mt.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),c.e(y,{type:"image"}),e.push({abortController:b,requestParameters:y,supportImageRefresh:w,state:"queued",onError:I=>{P(I)},onSuccess:I=>{S(I)}}),f()});const u=y=>c._(this,void 0,void 0,function*(){y.state="running";const{requestParameters:b,supportImageRefresh:w,onError:S,onSuccess:P,abortController:I}=y,k=w===!1&&!c.i(self)&&!c.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce((N,U)=>N&&U==="accept",!0));n++;const O=k?_(b,I):c.m(b,I);try{const N=yield O;delete y.abortController,y.state="completed",N.data instanceof HTMLImageElement||c.b(N.data)?P(N):N.data&&P({data:yield(B=N.data,typeof createImageBitmap=="function"?c.f(B):c.h(B)),cacheControl:N.cacheControl,expires:N.expires})}catch(N){delete y.abortController,S(N)}finally{n--,f()}var B}),f=()=>{const y=(()=>{for(const b of Object.keys(l))if(l[b]())return!0;return!1})()?c.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:c.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b<y&&e.length>0;b++){const w=e.shift();w.abortController.signal.aborted?b--:u(w)}},_=(y,b)=>new Promise((w,S)=>{const P=new Image,I=y.url,k=y.credentials;k&&k==="include"?P.crossOrigin="use-credentials":(k&&k==="same-origin"||!c.d(I))&&(P.crossOrigin="anonymous"),b.signal.addEventListener("abort",()=>{P.src="",S(c.c())}),P.fetchPriority="high",P.onload=()=>{P.onerror=P.onload=null,w({data:P})},P.onerror=()=>{P.onerror=P.onload=null,b.signal.aborted||S(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},P.src=I})}(Ot||(Ot={})),Ot.resetRequestQueue();class $i{constructor(e){this._transformRequestFn=e??null}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function Sr(h){const e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){const n=[];for(const{id:a,url:l}of h){const u=`${a}${l}`;n.indexOf(u)===-1&&(n.push(u),e.push({id:a,url:l}))}}return e}function jn(h,e,n){try{const a=new URL(h);return a.pathname+=`${e}${n}`,a.toString()}catch{throw new Error(`Invalid sprite URL "${h}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function oa(h){const{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class Ts extends c.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new c.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:n,promiseResolve:a}of this.requestors)a(this._getImagesForIds(n));this.requestors=[]}}getImage(e){const n=this.images[e];if(n&&!n.data&&n.spriteData){const a=n.spriteData;n.data=new c.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.height).data),n.spriteData=null}return n}addImage(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let a=!0;const l=n.data||n.spriteData;return this._validateStretch(n.stretchX,l&&l.width)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "stretchX" value`))),a=!1),this._validateStretch(n.stretchY,l&&l.height)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new c.k(new Error(`Image "${e}" has invalid "content" value`))),a=!1),a}_validateStretch(e,n){if(!e)return!0;let a=0;for(const l of e){if(l[0]<a||l[1]<l[0]||n<l[1])return!1;a=l[1]}return!0}_validateContent(e,n){if(!e)return!0;if(e.length!==4)return!1;const a=n.spriteData,l=a&&a.width||n.data.width,u=a&&a.height||n.data.height;return!(e[0]<0||l<e[0]||e[1]<0||u<e[1]||e[2]<0||l<e[2]||e[3]<0||u<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,n,a=!0){const l=this.getImage(e);if(a&&(l.data.width!==n.data.width||l.data.height!==n.data.height))throw new Error(`size mismatch between old image (${l.data.width}x${l.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=l.version+1,this.images[e]=n,this.updatedImages[e]=!0}removeImage(e){const 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,a)=>{let l=!0;if(!this.isLoaded())for(const u of e)this.images[u]||(l=!1);this.isLoaded()||l?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})})}_getImagesForIds(e){const n={};for(const a of e){let l=this.getImage(a);l||(this.fire(new c.l("styleimagemissing",{id:a})),l=this.getImage(a)),l?n[a]={data:l.data.clone(),pixelRatio:l.pixelRatio,sdf:l.sdf,version:l.version,stretchX:l.stretchX,stretchY:l.stretchY,content:l.content,textFitWidth:l.textFitWidth,textFitHeight:l.textFitHeight,hasRenderCallback:!!(l.userImage&&l.userImage.render)}:c.w(`Image "${a}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){const n=this.patterns[e],a=this.getImage(e);if(!a)return null;if(n&&n.position.version===a.version)return n.position;if(n)n.position.version=a.version;else{const l={w:a.data.width+2,h:a.data.height+2,x:0,y:0},u=new c.I(l,a);this.patterns[e]={bin:l,position:u}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new c.T(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const u in this.patterns)e.push(this.patterns[u].bin);const{w:n,h:a}=c.p(e),l=this.atlasImage;l.resize({width:n||1,height:a||1});for(const u in this.patterns){const{bin:f}=this.patterns[u],_=f.x+1,y=f.y+1,b=this.getImage(u).data,w=b.width,S=b.height;c.R.copy(b,l,{x:0,y:0},{x:_,y},{width:w,height:S}),c.R.copy(b,l,{x:0,y:S-1},{x:_,y:y-1},{width:w,height:1}),c.R.copy(b,l,{x:0,y:0},{x:_,y:y+S},{width:w,height:1}),c.R.copy(b,l,{x:w-1,y:0},{x:_-1,y},{width:1,height:S}),c.R.copy(b,l,{x:0,y:0},{x:_+w,y},{width:1,height:S})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const a=this.getImage(n);a||c.w(`Image with ID: "${n}" was not found`),oa(a)&&this.updateImage(n,a)}}}const pr=1e20;function Br(h,e,n,a,l,u,f,_,y){for(let b=e;b<e+a;b++)fr(h,n*u+b,u,l,f,_,y);for(let b=n;b<n+l;b++)fr(h,b*u+e,1,a,f,_,y)}function fr(h,e,n,a,l,u,f){u[0]=0,f[0]=-1e20,f[1]=pr,l[0]=h[e];for(let _=1,y=0,b=0;_<a;_++){l[_]=h[e+_*n];const w=_*_;do{const S=u[y];b=(l[_]-l[S]+w-S*S)/(_-S)/2}while(b<=f[y]&&--y>-1);y++,u[y]=_,f[y]=b,f[y+1]=pr}for(let _=0,y=0;_<a;_++){for(;f[y+1]<_;)y++;const b=u[y],w=_-b;h[e+_*n]=l[b]+w*w}}class Or{constructor(e,n,a){this.requestManager=e,this.localIdeographFontFamily=n,this.entries={},this.lang=a}setURL(e){this.url=e}getGlyphs(e){return c._(this,void 0,void 0,function*(){const n=[];for(const u in e)for(const f of e[u])n.push(this._getAndCacheGlyphsPromise(u,f));const a=yield Promise.all(n),l={};for(const{stack:u,id:f,glyph:_}of a)l[u]||(l[u]={}),l[u][f]=_&&{id:_.id,bitmap:_.bitmap.clone(),metrics:_.metrics};return l})}_getAndCacheGlyphsPromise(e,n){return c._(this,void 0,void 0,function*(){let a=this.entries[e];a||(a=this.entries[e]={glyphs:{},requests:{},ranges:{}});let l=a.glyphs[n];if(l!==void 0)return{stack:e,id:n,glyph:l};if(l=this._tinySDF(a,e,n),l)return a.glyphs[n]=l,{stack:e,id:n,glyph:l};const u=Math.floor(n/256);if(256*u>65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[u])return{stack:e,id:n,glyph:l};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[u]){const _=Or.loadGlyphRange(e,u,this.url,this.requestManager);a.requests[u]=_}const f=yield a.requests[u];for(const _ in f)this._doesCharSupportLocalGlyph(+_)||(a.glyphs[+_]=f[+_]);return a.ranges[u]=!0,{stack:e,id:n,glyph:f[n]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(new RegExp("\\p{Ideo}|\\p{sc=Hang}|\\p{sc=Hira}|\\p{sc=Kana}","u").test(String.fromCodePoint(e))||c.u["CJK Unified Ideographs"](e)||c.u["Hangul Syllables"](e)||c.u.Hiragana(e)||c.u.Katakana(e)||c.u["CJK Symbols and Punctuation"](e)||c.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,n,a){const l=this.localIdeographFontFamily;if(!l||!this._doesCharSupportLocalGlyph(a))return;let u=e.tinySDF;if(!u){let _="400";/bold/i.test(n)?_="900":/medium/i.test(n)?_="500":/light/i.test(n)&&(_="200"),u=e.tinySDF=new Or.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,lang:this.lang,fontFamily:l,fontWeight:_})}const f=u.draw(String.fromCharCode(a));return{id:a,bitmap:new c.q({width:f.width||60,height:f.height||60},f.data),metrics:{width:f.glyphWidth/2||24,height:f.glyphHeight/2||24,left:f.glyphLeft/2+.5||0,top:f.glyphTop/2-27.5||-8,advance:f.glyphAdvance/2||24,isDoubleResolution:!0}}}}Or.loadGlyphRange=function(h,e,n,a){return c._(this,void 0,void 0,function*(){const l=256*e,u=l+255,f=a.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${l}-${u}`),"Glyphs"),_=yield c.n(f,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${e}, ${l}-${u}`);const y={};for(const b of c.o(_.data))y[b.id]=b;return y})},Or.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:n=8,cutoff:a=.25,fontFamily:l="sans-serif",fontWeight:u="normal",fontStyle:f="normal",lang:_=null}={}){this.buffer=e,this.cutoff=a,this.radius=n,this.lang=_;const y=this.size=h+4*e,b=this._createCanvas(y),w=this.ctx=b.getContext("2d",{willReadFrequently:!0});w.font=`${f} ${u} ${h}px ${l}`,w.textBaseline="alphabetic",w.textAlign="left",w.fillStyle="black",this.gridOuter=new Float64Array(y*y),this.gridInner=new Float64Array(y*y),this.f=new Float64Array(y),this.z=new Float64Array(y+1),this.v=new Uint16Array(y)}_createCanvas(h){const e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,actualBoundingBoxLeft:l,actualBoundingBoxRight:u}=this.ctx.measureText(h),f=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(u-l))),y=Math.min(this.size-this.buffer,f+Math.ceil(a)),b=_+2*this.buffer,w=y+2*this.buffer,S=Math.max(b*w,0),P=new Uint8ClampedArray(S),I={data:P,width:b,height:w,glyphWidth:_,glyphHeight:y,glyphTop:f,glyphLeft:0,glyphAdvance:e};if(_===0||y===0)return I;const{ctx:k,buffer:O,gridInner:B,gridOuter:N}=this;this.lang&&(k.lang=this.lang),k.clearRect(O,O,_,y),k.fillText(h,O,O+f);const U=k.getImageData(O,O,_,y);N.fill(pr,0,S),B.fill(0,0,S);for(let q=0;q<y;q++)for(let $=0;$<_;$++){const H=U.data[4*(q*_+$)+3]/255;if(H===0)continue;const K=(q+O)*b+$+O;if(H===1)N[K]=0,B[K]=pr;else{const G=.5-H;N[K]=G>0?G*G:0,B[K]=G<0?G*G:0}}Br(N,0,0,b,w,b,this.f,this.v,this.z),Br(B,O,O,_,y,b,this.f,this.v,this.z);for(let q=0;q<S;q++){const $=Math.sqrt(N[q])-Math.sqrt(B[q]);P[q]=Math.round(255-255*($/this.radius+this.cutoff))}return I}};class Ps{constructor(){this.specification=c.v.light.position}possiblyEvaluate(e,n){return c.B(e.expression.evaluate(n))}interpolate(e,n,a){return{x:c.C.number(e.x,n.x,a),y:c.C.number(e.y,n.y,a),z:c.C.number(e.z,n.z,a)}}}let cn;class hn extends c.E{constructor(e){super(),cn=cn||new c.r({anchor:new c.D(c.v.light.anchor),position:new Ps,color:new c.D(c.v.light.color),intensity:new c.D(c.v.light.intensity)}),this._transitionable=new c.t(cn),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(c.x,e,n))for(const a in e){const l=e[a];a.endsWith("-transition")?this._transitionable.setTransition(a.slice(0,-11),l):this._transitionable.setValue(a,l)}}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,a){return(!a||a.validate!==!1)&&c.y(this,e.call(c.z,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:c.v}))}}const un=new c.r({"sky-color":new c.D(c.v.sky["sky-color"]),"horizon-color":new c.D(c.v.sky["horizon-color"]),"fog-color":new c.D(c.v.sky["fog-color"]),"fog-ground-blend":new c.D(c.v.sky["fog-ground-blend"]),"horizon-fog-blend":new c.D(c.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new c.D(c.v.sky["sky-horizon-blend"]),"atmosphere-blend":new c.D(c.v.sky["atmosphere-blend"])});class la extends c.E{constructor(e){super(),this._transitionable=new c.t(un),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.F(0))}setSky(e,n={}){if(!this._validate(c.G,e,n)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const a in e){const l=e[a];a.endsWith("-transition")?this._transitionable.setTransition(a.slice(0,-11),l):this._transitionable.setValue(a,l)}}}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,a={}){return(a==null?void 0:a.validate)!==!1&&c.y(this,e.call(c.z,c.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:c.v})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class gt{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){const a=e.join(",")+String(n);return this.dashEntry[a]||(this.dashEntry[a]=this.addDash(e,n)),this.dashEntry[a]}getDashRanges(e,n,a){const l=[];let u=e.length%2==1?-e[e.length-1]*a:0,f=e[0]*a,_=!0;l.push({left:u,right:f,isDash:_,zeroLength:e[0]===0});let y=e[0];for(let b=1;b<e.length;b++){_=!_;const w=e[b];u=y*a,y+=w,f=y*a,l.push({left:u,right:f,isDash:_,zeroLength:w===0})}return l}addRoundDash(e,n,a){const l=n/2;for(let u=-a;u<=a;u++){const f=this.width*(this.nextRow+a+u);let _=0,y=e[_];for(let b=0;b<this.width;b++){b/y.right>1&&(y=e[++_]);const w=Math.abs(b-y.left),S=Math.abs(b-y.right),P=Math.min(w,S);let I;const k=u/a*(l+1);if(y.isDash){const O=l-Math.abs(k);I=Math.sqrt(P*P+O*O)}else I=l-Math.sqrt(P*P+k*k);this.data[f+b]=Math.max(0,Math.min(255,I+128))}}}addRegularDash(e){for(let _=e.length-1;_>=0;--_){const y=e[_],b=e[_+1];y.zeroLength?e.splice(_,1):b&&b.isDash===y.isDash&&(b.left=y.left,e.splice(_,1))}const n=e[0],a=e[e.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.right=n.right+this.width);const l=this.width*this.nextRow;let u=0,f=e[u];for(let _=0;_<this.width;_++){_/f.right>1&&(f=e[++u]);const y=Math.abs(_-f.left),b=Math.abs(_-f.right),w=Math.min(y,b);this.data[l+_]=Math.max(0,Math.min(255,(f.isDash?w:-w)+128))}}addDash(e,n){const a=n?7:0,l=2*a+1;if(this.nextRow+l>this.height)return c.w("LineAtlas out of space"),null;let u=0;for(let _=0;_<e.length;_++)u+=e[_];if(u!==0){const _=this.width/u,y=this.getDashRanges(e,this.width,_);n?this.addRoundDash(y,_,a):this.addRegularDash(y)}const f={y:(this.nextRow+a+.5)/this.height,height:2*a/this.height,width:u};return this.nextRow+=l,this.dirty=!0,f}bind(e){const 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))}}const dn="maplibre_preloaded_worker_pool";class mi{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<mi.workerCount;)this.workers.push(new Worker(c.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[dn]}numActive(){return Object.keys(this.active).length}}const pn=Math.floor(Ee.hardwareConcurrency/2);let mr,jr;function fn(){return mr||(mr=new mi),mr}mi.workerCount=c.H(globalThis)?Math.max(Math.min(pn,3),1):1;class Ei{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;const a=this.workerPool.acquire(n);for(let l=0;l<a.length;l++){const u=new c.J(a[l],n);u.name=`Worker ${l}`,this.actors.push(u)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,n){const a=[];for(const l of this.actors)a.push(l.sendAsync({type:e,data:n}));return Promise.all(a)}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(const a of this.actors)a.registerMessageHandler(e,n)}}function Nn(){return jr||(jr=new Ei(fn(),c.K),jr.registerMessageHandler("GR",(h,e,n)=>c.m(e,n))),jr}function Zi(h,e){const n=c.L();return c.M(n,n,[1,1,0]),c.N(n,n,[.5*h.width,.5*h.height,1]),h.calculatePosMatrix?c.O(n,n,h.calculatePosMatrix(e.toUnwrapped())):n}function Yi(h,e,n,a,l,u,f){var _;const y=function(P,I,k){if(P)for(const O of P){const B=I[O];if(B&&B.source===k&&B.type==="fill-extrusion")return!0}else for(const O in I){const B=I[O];if(B.source===k&&B.type==="fill-extrusion")return!0}return!1}((_=l==null?void 0:l.layers)!==null&&_!==void 0?_:null,e,h.id),b=u.maxPitchScaleFactor(),w=h.tilesIn(a,b,y);w.sort(Vn);const S=[];for(const P of w)S.push({wrappedTileID:P.tileID.wrapped().key,queryResults:P.tile.queryRenderedFeatures(e,n,h._state,P.queryGeometry,P.cameraQueryGeometry,P.scale,l,u,b,Zi(h.transform,P.tileID),f?(I,k)=>f(P.tileID,I,k):void 0)});return function(P,I){for(const k in P)for(const O of P[k])Un(O,I);return P}(function(P){const I={},k={};for(const O of P){const B=O.queryResults,N=O.wrappedTileID,U=k[N]=k[N]||{};for(const q in B){const $=B[q],H=U[q]=U[q]||{},K=I[q]=I[q]||[];for(const G of $)H[G.featureIndex]||(H[G.featureIndex]=!0,K.push(G))}}return I}(S),h)}function Vn(h,e){const n=h.tileID,a=e.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}function Un(h,e){const n=h.feature,a=e.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=a}function Fi(h,e,n){return c._(this,void 0,void 0,function*(){let a=h;if(h.url?a=(yield c.j(e.transformRequest(h.url,"Source"),n)).data:yield Ee.frameAsync(n),!a)return null;const l=c.Q(c.e(a,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(l.vectorLayerIds=a.vector_layers.map(u=>u.id)),l})}class Dt{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 c.S?new c.S(e.lng,e.lat):c.S.convert(e),this}setSouthWest(e){return this._sw=e instanceof c.S?new c.S(e.lng,e.lat):c.S.convert(e),this}extend(e){const n=this._sw,a=this._ne;let l,u;if(e instanceof c.S)l=e,u=e;else{if(!(e instanceof Dt))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Dt.convert(e)):this.extend(c.S.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(c.S.convert(e)):this;if(l=e._sw,u=e._ne,!l||!u)return this}return n||a?(n.lng=Math.min(l.lng,n.lng),n.lat=Math.min(l.lat,n.lat),a.lng=Math.max(u.lng,a.lng),a.lat=Math.max(u.lat,a.lat)):(this._sw=new c.S(l.lng,l.lat),this._ne=new c.S(u.lng,u.lat)),this}getCenter(){return new c.S((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new c.S(this.getWest(),this.getNorth())}getSouthEast(){return new c.S(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:n,lat:a}=c.S.convert(e);let l=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(l=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&l}static convert(e){return e instanceof Dt?e:e&&new Dt(e)}static fromLngLat(e,n=0){const a=360*n/40075017,l=a/Math.cos(Math.PI/180*e.lat);return new Dt(new c.S(e.lng-l,e.lat-a),new c.S(e.lng+l,e.lat+a))}adjustAntiMeridian(){const e=new c.S(this._sw.lng,this._sw.lat),n=new c.S(this._ne.lng,this._ne.lat);return new Dt(e,e.lng>n.lng?new c.S(n.lng+360,n.lat):n)}}class jt{constructor(e,n,a){this.bounds=Dt.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=a||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const n=Math.pow(2,e.z),a=Math.floor(c.V(this.bounds.getWest())*n),l=Math.floor(c.U(this.bounds.getNorth())*n),u=Math.ceil(c.V(this.bounds.getEast())*n),f=Math.ceil(c.U(this.bounds.getSouth())*n);return e.x>=a&&e.x<u&&e.y>=l&&e.y<f}}class Ki extends c.E{constructor(e,n,a,l){if(super(),this.id=e,this.dispatcher=a,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,c.e(this,c.Q(n,["url","scheme","tileSize","promoteId"])),this._options=c.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(l)}load(){return c._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const e=yield Fi(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e&&(c.e(this,e),e.bounds&&(this.tileBounds=new jt(e.bounds,this.minzoom,this.maxzoom)),this.fire(new c.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.l("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new c.k(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 c.e({},this._options)}loadTile(e){return c._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(n,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};a.request.collectResourceTiming=this._collectResourceTiming;let l="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise((u,f)=>{e.reloadPromise={resolve:u,reject:f}})}else e.actor=this.dispatcher.getActor(),l="LT";e.abortController=new AbortController;try{const u=yield e.actor.sendAsync({type:l,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,u)}catch(u){if(delete e.abortController,e.aborted)return;if(u&&u.status!==404)throw u;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){const a=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(a.resolve).catch(a.reject)}}abortTile(e){return c._(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 c._(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 gr extends c.E{constructor(e,n,a,l){super(),this.id=e,this.dispatcher=a,this.setEventedParent(l),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=c.e({type:"raster"},n),c.e(this,c.Q(n,["url","scheme","tileSize"]))}load(){return c._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const n=yield Fi(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(c.e(this,n),n.bounds&&(this.tileBounds=new jt(n.bounds,this.minzoom,this.maxzoom)),this.fire(new c.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(n){this._tileJSONRequest=null,this.fire(new c.k(n))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return c.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return c._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const a=yield Ot.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a&&a.data){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});const l=this.map.painter.context,u=l.gl,f=a.data;e.texture=this.map.painter.getTileTexture(f.width),e.texture?e.texture.update(f,{useMipmap:!0}):(e.texture=new c.T(l,f,u.RGBA,{useMipmap:!0}),e.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE,u.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}})}abortTile(e){return c._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return c._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class mn extends gr{constructor(e,n,a,l){super(e,n,a,l),this.type="raster-dem",this.maxzoom=22,this._options=c.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 c._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const l=yield Ot.getImage(a,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(l&&l.data){const u=l.data;this.map._refreshExpiredTiles&&(l.cacheControl||l.expires)&&e.setExpiryData({cacheControl:l.cacheControl,expires:l.expires});const f=c.b(u)&&c.W()?u:yield this.readImageNow(u),_={type:this.type,uid:e.uid,source:this.id,rawImageData:f,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();const y=yield e.actor.sendAsync({type:"LDT",data:_});e.dem=y,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(l){if(delete e.abortController,e.aborted)e.state="unloaded";else if(l)throw e.state="errored",l}})}readImageNow(e){return c._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&c.X()){const n=e.width+2,a=e.height+2;try{return new c.R({width:n,height:a},yield c.Y(e,-1,-1,n,a))}catch{}}return Ee.getImageData(e,1)})}_getNeighboringTiles(e){const n=e.canonical,a=Math.pow(2,n.z),l=(n.x-1+a)%a,u=n.x===0?e.wrap-1:e.wrap,f=(n.x+1+a)%a,_=n.x+1===a?e.wrap+1:e.wrap,y={};return y[new c.Z(e.overscaledZ,u,n.z,l,n.y).key]={backfilled:!1},y[new c.Z(e.overscaledZ,_,n.z,f,n.y).key]={backfilled:!1},n.y>0&&(y[new c.Z(e.overscaledZ,u,n.z,l,n.y-1).key]={backfilled:!1},y[new c.Z(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new c.Z(e.overscaledZ,_,n.z,f,n.y-1).key]={backfilled:!1}),n.y+1<a&&(y[new c.Z(e.overscaledZ,u,n.z,l,n.y+1).key]={backfilled:!1},y[new c.Z(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},y[new c.Z(e.overscaledZ,_,n.z,f,n.y+1).key]={backfilled:!1}),y}unloadTile(e){return c._(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 _r extends c.E{constructor(e,n,a,l){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._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actor=a.getActor(),this.setEventedParent(l),this._data=n.data,this._options=c.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,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&c.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=c.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer!==void 0?n.buffer:128),tolerance:this._pixelsToTileUnits(n.tolerance!==void 0?n.tolerance:.375),extent:c.$,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:c.$,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_pixelsToTileUnits(e){return e*(c.$/this.tileSize)}_getClusterMaxZoom(e){const n=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||c.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${n}"`),n}load(){return c._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(e){this.map=e,this.load()}setData(e){return this._data=e,this._pendingWorkerUpdate={data:e},this._updateWorkerData(),this}updateData(e){return this._pendingWorkerUpdate.diff=c.a0(this._pendingWorkerUpdate.diff,e),this._updateWorkerData(),this}getData(){return c._(this,void 0,void 0,function*(){const e=c.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:e})})}getCoordinatesFromGeometry(e){return e.type==="GeometryCollection"?e.geometries.map(n=>n.coordinates).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return c._(this,void 0,void 0,function*(){const e=new Dt,n=yield this.getData();let a;switch(n.type){case"FeatureCollection":a=n.features.map(l=>this.getCoordinatesFromGeometry(l.geometry)).flat(1/0);break;case"Feature":a=this.getCoordinatesFromGeometry(n.geometry);break;default:a=this.getCoordinatesFromGeometry(n)}if(a.length==0)return e;for(let l=0;l<a.length-1;l+=2)e.extend([a[l],a[l+1]]);return e})}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,e&&(e.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(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,a){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:n,offset:a}})}_updateWorkerData(){return c._(this,void 0,void 0,function*(){if(this._isUpdatingWorker)return;const{data:e,diff:n}=this._pendingWorkerUpdate;if(!e&&!n)return void c.w(`No data or diff provided to GeoJSONSource ${this.id}.`);const a=c.e({type:this.type},this.workerOptions);e?(typeof e=="string"?(a.request=this.map._requestManager.transformRequest(Ee.resolveURL(e),"Source"),a.request.collectResourceTiming=this._collectResourceTiming):a.data=JSON.stringify(e),this._pendingWorkerUpdate.data=void 0):n&&(a.dataDiff=n,this._pendingWorkerUpdate.diff=void 0),this._isUpdatingWorker=!0,this.fire(new c.l("dataloading",{dataType:"source"}));try{const l=yield this.actor.sendAsync({type:"LD",data:a});if(this._isUpdatingWorker=!1,this._removed||l.abandoned)return void this.fire(new c.l("dataabort",{dataType:"source"}));this._data=l.data;let u=null;l.resourceTiming&&l.resourceTiming[this.id]&&(u=l.resourceTiming[this.id].slice(0));const f={dataType:"source"};this._collectResourceTiming&&u&&u.length>0&&c.e(f,{resourceTiming:u}),this.fire(new c.l("data",Object.assign(Object.assign({},f),{sourceDataType:"metadata"}))),this.fire(new c.l("data",Object.assign(Object.assign({},f),{sourceDataType:"content"})))}catch(l){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new c.l("dataabort",{dataType:"source"}));this.fire(new c.k(l))}finally{(this._pendingWorkerUpdate.data||this._pendingWorkerUpdate.diff)&&this._updateWorkerData()}})}loaded(){return!this._isUpdatingWorker&&this._pendingWorkerUpdate.data===void 0&&this._pendingWorkerUpdate.diff===void 0}loadTile(e){return c._(this,void 0,void 0,function*(){const n=e.actor?"RT":"LT";e.actor=this.actor;const a={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};e.abortController=new AbortController;const l=yield this.actor.sendAsync({type:n,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(l,this.map.painter,n==="RT")})}abortTile(e){return c._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return c._(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 c.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class yr extends c.E{constructor(e,n,a,l){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=a,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=n}load(e){return c._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield Ot.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 c.k(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 c.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const n=e.map(c.a1.fromLngLat);var a;return this.tileID=function(l){const u=c.a2.fromPoints(l),f=u.width(),_=u.height(),y=Math.max(f,_),b=Math.max(0,Math.floor(-Math.log(y)/Math.LN2)),w=Math.pow(2,b);return new c.a4(b,Math.floor((u.minX+u.maxX)/2*w),Math.floor((u.minY+u.maxY)/2*w))}(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map(l=>this.tileID.getTilePoint(l)._round()),this.flippedWindingOrder=((a=this.tileCoords)[1].x-a[0].x)*(a[2].y-a[0].y)-(a[1].y-a[0].y)*(a[2].x-a[0].x)<0,this.fire(new c.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const e=this.map.painter.context,n=e.gl;this.texture||(this.texture=new c.T(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const l in this.tiles){const u=this.tiles[l];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,a=!0)}a&&this.fire(new c.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return c._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:n,minY:a,maxX:l,maxY:u}=c.a2.fromPoints(e),f={};for(let _=0;_<=c.a3;_++){const y=Math.pow(2,_),b=Math.floor(n*y),w=Math.floor(a*y),S=Math.floor(l*y),P=Math.floor(u*y);f[_]={minTileX:b,minTileY:w,maxTileX:S,maxTileY:P}}return f}}class $n extends yr{constructor(e,n,a,l){super(e,n,a,l),this.roundZoom=!0,this.type="video",this.options=n}load(){return c._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield c.a5(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 c.k(n))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new c.k(new c.a6(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const e=this.map.painter.context,n=e.gl;this.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 c.T(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(const l in this.tiles){const u=this.tiles[l];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,a=!0)}a&&this.fire(new c.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Nr extends yr{constructor(e,n,a,l){super(e,n,a,l),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(u=>!Array.isArray(u)||u.length!==2||u.some(f=>typeof f!="number"))||this.fire(new c.k(new c.a6(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new c.k(new c.a6(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new c.k(new c.a6(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new c.k(new c.a6(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new c.k(new c.a6(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return c._(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 c.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,a=n.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new c.T(n,this.canvas,a.RGBA,{premultiply:!0});let l=!1;for(const u in this.tiles){const f=this.tiles[u];f.state!=="loaded"&&(f.state="loaded",f.texture=this.texture,l=!0)}l&&this.fire(new c.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const Vr={},Ur=h=>{switch(h){case"geojson":return _r;case"image":return yr;case"raster":return gr;case"raster-dem":return mn;case"vector":return Ki;case"video":return $n;case"canvas":return Nr}return Vr[h]},gn="RTLPluginLoaded";class $r extends c.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Nn()}_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 c._(this,arguments,void 0,function*(n,a=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Ee.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!a)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return c._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new c.l(gn))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Zr=null;function Gr(){return Zr||(Zr=new $r),Zr}class Zn{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=c.a7(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const n=e+this.timeAdded;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,a){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(l,u){const f={};if(!u)return f;for(const _ of l){const y=_.layerIds.map(b=>u.getLayer(b)).filter(Boolean);if(y.length!==0){_.layers=y,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map(b=>y.filter(w=>w.id===b)[0]));for(const b of y)f[b.id]=_}}return f}(e.buckets,n==null?void 0:n.style),this.hasSymbolBuckets=!1;for(const l in this.buckets){const u=this.buckets[l];if(u instanceof c.a9){if(this.hasSymbolBuckets=!0,!a)break;u.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const l in this.buckets){const u=this.buckets[l];if(u instanceof c.a9&&u.hasRTLText){this.hasRTLText=!0,Gr().lazyLoad();break}}this.queryPadding=0;for(const l in this.buckets){const u=this.buckets[l];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(l).queryRadius(u))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new c.a8}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const a in this.buckets){const l=this.buckets[a];l.uploadPending()&&l.upload(e)}const n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new c.T(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new c.T(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,a,l,u,f,_,y,b,w,S){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:u,scale:f,tileSize:this.tileSize,pixelPosMatrix:w,transform:y,params:_,queryPadding:this.queryPadding*b,getElevation:S},e,n,a):{}}querySourceFeatures(e,n){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const l=a.loadVTLayers(),u=n&&n.sourceLayer?n.sourceLayer:"",f=l._geojsonTileLayer||l[u];if(!f)return;const _=c.aa(n&&n.filter),{z:y,x:b,y:w}=this.tileID.canonical,S={z:y,x:b,y:w};for(let P=0;P<f.length;P++){const I=f.feature(P);if(_.needGeometry){const B=c.ab(I,!0);if(!_.filter(new c.F(this.tileID.overscaledZ),B,this.tileID.canonical))continue}else if(!_.filter(new c.F(this.tileID.overscaledZ),I))continue;const k=a.getId(I,u),O=new c.ac(I,y,b,w,k);O.tile=S,e.push(O)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const n=this.expirationTime;if(e.cacheControl){const a=c.ad(e.cacheControl);a["max-age"]&&(this.expirationTime=Date.now()+1e3*a["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const a=Date.now();let l=!1;if(this.expirationTime>a)l=!1;else if(n)if(this.expirationTime<n)l=!0;else{const u=this.expirationTime-n;u?this.expirationTime=a+Math.max(u,3e4):l=!0}else l=!0;l?(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;const a=this.latestFeatureIndex.loadVTLayers();for(const l in this.buckets){if(!n.style.hasLayer(l))continue;const u=this.buckets[l],f=u.layers[0].sourceLayer||"_geojsonTileLayer",_=a[f],y=e[f];if(!_||!y||Object.keys(y).length===0)continue;u.update(y,_,this.imageAtlas&&this.imageAtlas.patternPositions||{});const b=n&&n.style&&n.style.getLayer(l);b&&(this.queryPadding=Math.max(this.queryPadding,b.queryRadius(u)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Ee.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=Ee.now()+e}setDependencies(e,n){const a={};for(const l of n)a[l]=!0;this.dependencies[e]=a}hasDependency(e,n){for(const a of e){const l=this.dependencies[a];if(l){for(const u of n)if(l[u])return!0}}return!1}}class ee{constructor(e,n){this.max=e,this.onRemove=n,this.reset()}reset(){for(const e in this.data)for(const n of this.data[e])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(e,n,a){const l=e.wrapped().key;this.data[l]===void 0&&(this.data[l]=[]);const u={value:n,timeout:void 0};if(a!==void 0&&(u.timeout=setTimeout(()=>{this.remove(e,u)},a)),this.data[l].push(u),this.order.push(l),this.order.length>this.max){const f=this._getAndRemoveByKey(this.order[0]);f&&this.onRemove(f)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const n=this.data[e].shift();return n.timeout&&clearTimeout(n.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),n.value}getByKey(e){const n=this.data[e];return n?n[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,n){if(!this.has(e))return this;const a=e.wrapped().key,l=n===void 0?0:this.data[a].indexOf(n),u=this.data[a][l];return this.data[a].splice(l,1),u.timeout&&clearTimeout(u.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(u.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(e){const n=[];for(const a in this.data)for(const l of this.data[a])e(l.value)||n.push(l);for(const a of n)this.remove(a.value.tileID,a)}}class z{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,a){const l=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][l]=this.stateChanges[e][l]||{},c.e(this.stateChanges[e][l],a),this.deletedStates[e]===null){this.deletedStates[e]={};for(const u in this.state[e])u!==l&&(this.deletedStates[e][u]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][l]===null){this.deletedStates[e][l]={};for(const u in this.state[e][l])a[u]||(this.deletedStates[e][l][u]=null)}else for(const u in a)this.deletedStates[e]&&this.deletedStates[e][l]&&this.deletedStates[e][l][u]===null&&delete this.deletedStates[e][l][u]}removeFeatureState(e,n,a){if(this.deletedStates[e]===null)return;const l=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&n!==void 0)this.deletedStates[e][l]!==null&&(this.deletedStates[e][l]=this.deletedStates[e][l]||{},this.deletedStates[e][l][a]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][l])for(a in this.deletedStates[e][l]={},this.stateChanges[e][l])this.deletedStates[e][l][a]=null;else this.deletedStates[e][l]=null;else this.deletedStates[e]=null}getState(e,n){const a=String(n),l=c.e({},(this.state[e]||{})[a],(this.stateChanges[e]||{})[a]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const u=this.deletedStates[e][n];if(u===null)return{};for(const f in u)delete l[f]}return l}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){const a={};for(const l in this.stateChanges){this.state[l]=this.state[l]||{};const u={};for(const f in this.stateChanges[l])this.state[l][f]||(this.state[l][f]={}),c.e(this.state[l][f],this.stateChanges[l][f]),u[f]=this.state[l][f];a[l]=u}for(const l in this.deletedStates){this.state[l]=this.state[l]||{};const u={};if(this.deletedStates[l]===null)for(const f in this.state[l])u[f]={},this.state[l][f]={};else for(const f in this.deletedStates[l]){if(this.deletedStates[l][f]===null)this.state[l][f]={};else for(const _ of Object.keys(this.deletedStates[l][f]))delete this.state[l][f][_];u[f]=this.state[l][f]}a[l]=a[l]||{},c.e(a[l],u)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(const l in e)e[l].setFeatureState(a,n)}}const D=89.25;function R(h,e){const n=c.ah(e.lat,-c.ai,c.ai);return new c.P(c.V(e.lng)*h,c.U(n)*h)}function Z(h,e){return new c.a1(e.x/h,e.y/h).toLngLat()}function Y(h){return h.cameraToCenterDistance*Math.min(.85*Math.tan(c.ae(90-h.pitch)),Math.tan(c.ae(D-h.pitch)))}function ie(h,e){const n=h.canonical,a=e/c.af(n.z),l=n.x+Math.pow(2,n.z)*h.wrap,u=c.ag(new Float64Array(16));return c.M(u,u,[l*a,n.y*a,0]),c.N(u,u,[a/c.$,a/c.$,1]),u}function le(h,e,n,a,l){const u=c.a1.fromLngLat(h,e),f=l*c.aj(1,h.lat),_=f*Math.cos(c.ae(n)),y=Math.sqrt(f*f-_*_),b=y*Math.sin(c.ae(-a)),w=y*Math.cos(c.ae(-a));return new c.a1(u.x+b,u.y+w,u.z+_)}function re(h,e,n){const a=e.intersectsFrustum(h);if(!n||a===0)return a;const l=e.intersectsPlane(n);return l===0?0:a===2&&l===2?2:1}function fe(h,e,n){let a=0;const l=(n-e)/10;for(let u=0;u<10;u++)a+=l*Math.pow(Math.cos(e+(u+.5)/10*(n-e)),h);return a}function ve(h,e){return function(n,a,l,u,f){const _=2*((h-1)/c.ak(Math.cos(c.ae(D-f))/Math.cos(c.ae(D)))-1),y=Math.acos(l/u),b=2*fe(_-1,0,c.ae(f/2)),w=Math.min(c.ae(D),y+c.ae(f/2)),S=fe(_-1,Math.min(w,y-c.ae(f/2)),w),P=Math.atan(a/l),I=Math.hypot(a,l);let k=n;return k+=c.ak(u/I/Math.max(.5,Math.cos(c.ae(f/2)))),k+=_*c.ak(Math.cos(P))/2,k-=c.ak(Math.max(1,S/b/e))/2,k}}const _e=ve(9.314,3);function Re(h,e){const n=(e.roundZoom?Math.round:Math.floor)(h.zoom+c.ak(h.tileSize/e.tileSize));return Math.max(0,n)}function ne(h,e){const n=h.getCameraFrustum(),a=h.getClippingPlane(),l=h.screenPointToMercatorCoordinate(h.getCameraPoint()),u=c.a1.fromLngLat(h.center,h.elevation);l.z=u.z+Math.cos(h.pitchInRadians)*h.cameraToCenterDistance/h.worldSize;const f=h.getCoveringTilesDetailsProvider(),_=f.allowVariableZoom(h,e),y=Re(h,e),b=e.minzoom||0,w=e.maxzoom!==void 0?e.maxzoom:h.maxZoom,S=Math.min(Math.max(0,y),w),P=Math.pow(2,S),I=[P*l.x,P*l.y,0],k=[P*u.x,P*u.y,0],O=Math.hypot(u.x-l.x,u.y-l.y),B=Math.abs(u.z-l.z),N=Math.hypot(O,B),U=H=>({zoom:0,x:0,y:0,wrap:H,fullyVisible:!1}),q=[],$=[];if(h.renderWorldCopies&&f.allowWorldCopies())for(let H=1;H<=3;H++)q.push(U(-H)),q.push(U(H));for(q.push(U(0));q.length>0;){const H=q.pop(),K=H.x,G=H.y;let te=H.fullyVisible;const ue={x:K,y:G,z:H.zoom},ae=f.getTileBoundingVolume(ue,H.wrap,h.elevation,e);if(!te){const Se=re(n,ae,a);if(Se===0)continue;te=Se===2}const oe=f.distanceToTile2d(l.x,l.y,ue,ae);let he=y;_&&(he=(e.calculateTileZoom||_e)(h.zoom+c.ak(h.tileSize/e.tileSize),oe,B,N,h.fov)),he=(e.roundZoom?Math.round:Math.floor)(he),he=Math.max(0,he);const we=Math.min(he,w);if(H.wrap=f.getWrap(u,ue,H.wrap),H.zoom>=we){if(H.zoom<b)continue;const Se=S-H.zoom,ye=I[0]-.5-(K<<Se),Le=I[1]-.5-(G<<Se),Ke=e.reparseOverscaled?Math.max(H.zoom,he):H.zoom;$.push({tileID:new c.Z(H.zoom===w?Ke:H.zoom,H.wrap,H.zoom,K,G),distanceSq:c.al([k[0]-.5-K,k[1]-.5-G]),tileDistanceToCamera:Math.sqrt(ye*ye+Le*Le)})}else for(let Se=0;Se<4;Se++)q.push({zoom:H.zoom+1,x:(K<<1)+Se%2,y:(G<<1)+(Se>>1),wrap:H.wrap,fullyVisible:te})}return $.sort((H,K)=>H.distanceSq-K.distanceSq).map(H=>H.tileID)}const qe=c.a2.fromPoints([new c.P(0,0),new c.P(c.$,c.$)]);class Qe extends c.E{constructor(e,n,a){super(),this.id=e,this.dispatcher=a,this.on("data",l=>this._dataHandler(l)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((l,u,f,_)=>{const y=new(Ur(u.type))(l,u,f,_);if(y.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${y.id}`);return y})(e,n,a,this),this._tiles={},this._cache=new ee(0,l=>this._unloadTile(l)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new z,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,a){return c._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,a)}catch(l){e.state="errored",l.status!==404?this._source.fire(new c.k(l,{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 c.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const a=this._tiles[n];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Oe).map(e=>e.key)}getRenderableIds(e){const n=[];for(const a in this._tiles)this._isIdRenderable(a,e)&&n.push(this._tiles[a]);return e?n.sort((a,l)=>{const u=a.tileID,f=l.tileID,_=new c.P(u.canonical.x,u.canonical.y)._rotate(-this.transform.bearingInRadians),y=new c.P(f.canonical.x,f.canonical.y)._rotate(-this.transform.bearingInRadians);return u.overscaledZ-f.overscaledZ||y.y-_.y||y.x-_.x}).map(a=>a.tileID.key):n.map(a=>a.tileID).sort(Oe).map(a=>a.key)}hasRenderableParent(e){const n=this.findLoadedParent(e,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(e,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(n||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const n in this._tiles)e?this._reloadTile(n,"expired"):this._tiles[n].state!=="errored"&&this._reloadTile(n,"reloading")}}_reloadTile(e,n){return c._(this,void 0,void 0,function*(){const a=this._tiles[e];a&&(a.state!=="loading"&&(a.state=n),yield this._loadTile(a,e,n))})}_tileLoaded(e,n,a){e.timeAdded=Ee.now(),a==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new c.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const n=this.getRenderableIds();for(let l=0;l<n.length;l++){const u=n[l];if(e.neighboringTiles&&e.neighboringTiles[u]){const f=this.getTileByID(u);a(e,f),a(f,e)}}function a(l,u){l.needsHillshadePrepare=!0,l.needsTerrainPrepare=!0;let f=u.tileID.canonical.x-l.tileID.canonical.x;const _=u.tileID.canonical.y-l.tileID.canonical.y,y=Math.pow(2,l.tileID.canonical.z),b=u.tileID.key;f===0&&_===0||Math.abs(_)>1||(Math.abs(f)>1&&(Math.abs(f+y)===1?f+=y:Math.abs(f-y)===1&&(f-=y)),u.dem&&l.dem&&(l.dem.backfillBorder(u.dem,f,_),l.neighboringTiles&&l.neighboringTiles[b]&&(l.neighboringTiles[b].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n,a,l){for(const u in this._tiles){let f=this._tiles[u];if(l[u]||!f.hasData()||f.tileID.overscaledZ<=n||f.tileID.overscaledZ>a)continue;let _=f.tileID;for(;f&&f.tileID.overscaledZ>n+1;){const b=f.tileID.scaledTo(f.tileID.overscaledZ-1);f=this._tiles[b.key],f&&f.hasData()&&(_=b)}let y=_;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),e[y.key]||e[y.canonical.key]){l[_.key]=_;break}}}findLoadedParent(e,n){if(e.key in this._loadedParentTiles){const a=this._loadedParentTiles[e.key];return a&&a.tileID.overscaledZ>=n?a:null}for(let a=e.overscaledZ-1;a>=n;a--){const l=e.scaledTo(a),u=this._getLoadedTile(l);if(u)return u}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const n=this._tiles[e.key];return n&&n.hasData()?n:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const n=Math.ceil(e.width/this._source.tileSize)+1,a=Math.ceil(e.height/this._source.tileSize)+1,l=Math.floor(n*a*(this._maxTileCacheZoomLevels===null?c.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),u=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,l):l;this._cache.setMaxSize(u)}handleWrapJump(e){const n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){const a={};for(const l in this._tiles){const u=this._tiles[l];u.tileID=u.tileID.unwrapTo(u.tileID.wrap+n),a[u.tileID.key]=u}this._tiles=a;for(const l in this._timers)clearTimeout(this._timers[l]),delete this._timers[l];for(const l in this._tiles)this._setTileReloadTimer(l,this._tiles[l])}}_updateCoveredAndRetainedTiles(e,n,a,l,u,f){const _={},y={},b=Object.keys(e),w=Ee.now();for(const S of b){const P=e[S],I=this._tiles[S];if(!I||I.fadeEndTime!==0&&I.fadeEndTime<=w)continue;const k=this.findLoadedParent(P,n),O=this.findLoadedSibling(P),B=k||O||null;B&&(this._addTile(B.tileID),_[B.tileID.key]=B.tileID),y[S]=P}this._retainLoadedChildren(y,l,a,e);for(const S in _)e[S]||(this._coveredTiles[S]=!0,e[S]=_[S]);if(f){const S={},P={};for(const I of u)this._tiles[I.key].hasData()?S[I.key]=I:P[I.key]=I;for(const I in P){const k=P[I].children(this._source.maxzoom);this._tiles[k[0].key]&&this._tiles[k[1].key]&&this._tiles[k[2].key]&&this._tiles[k[3].key]&&(S[k[0].key]=e[k[0].key]=k[0],S[k[1].key]=e[k[1].key]=k[1],S[k[2].key]=e[k[2].key]=k[2],S[k[3].key]=e[k[3].key]=k[3],delete P[I])}for(const I in P){const k=P[I],O=this.findLoadedParent(k,this._source.minzoom),B=this.findLoadedSibling(k),N=O||B||null;if(N){S[N.tileID.key]=e[N.tileID.key]=N.tileID;for(const U in S)S[U].isChildOf(N.tileID)&&delete S[U]}}for(const I in this._tiles)S[I]||(this._coveredTiles[I]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let a;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(w=>new c.Z(w.canonical.z,w.wrap,w.canonical.z,w.canonical.x,w.canonical.y)):(a=ne(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(a=a.filter(w=>this._source.hasTile(w)))):a=[];const l=Re(e,this._source),u=Math.max(l-Qe.maxOverzooming,this._source.minzoom),f=Math.max(l+Qe.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const w={};for(const S of a)if(S.canonical.z>this._source.minzoom){const P=S.scaledTo(S.canonical.z-1);w[P.key]=P;const I=S.scaledTo(Math.max(this._source.minzoom,Math.min(S.canonical.z,5)));w[I.key]=I}a=a.concat(Object.values(w))}const _=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,_&&this.fire(new c.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const y=this._updateRetainedTiles(a,l);He(this._source.type)&&this._updateCoveredAndRetainedTiles(y,u,f,l,a,n);for(const w in y)this._tiles[w].clearFadeHold();const b=c.am(this._tiles,y);for(const w of b){const S=this._tiles[w];S.hasSymbolBuckets&&!S.holdingForFade()?S.setHoldDuration(this.map._fadeDuration):S.hasSymbolBuckets&&!S.symbolFadeFinished()||this._removeTile(w)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var a;const l={},u={},f=Math.max(n-Qe.maxOverzooming,this._source.minzoom),_=Math.max(n+Qe.maxUnderzooming,this._source.minzoom),y={};for(const b of e){const w=this._addTile(b);l[b.key]=b,w.hasData()||n<this._source.maxzoom&&(y[b.key]=b)}this._retainLoadedChildren(y,n,_,l);for(const b of e){let w=this._tiles[b.key];if(w.hasData())continue;if(n+1>this._source.maxzoom){const P=b.children(this._source.maxzoom)[0],I=this.getTile(P);if(I&&I.hasData()){l[P.key]=P;continue}}else{const P=b.children(this._source.maxzoom);if(l[P[0].key]&&l[P[1].key]&&l[P[2].key]&&l[P[3].key])continue}let S=w.wasRequested();for(let P=b.overscaledZ-1;P>=f;--P){const I=b.scaledTo(P);if(u[I.key])break;if(u[I.key]=!0,w=this.getTile(I),!w&&S&&(w=this._addTile(I)),w){const k=w.hasData();if((k||!(!((a=this.map)===null||a===void 0)&&a.cancelPendingTileRequestsWhileZooming)||S)&&(l[I.key]=I),S=w.wasRequested(),k)break}}}return l}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const n=[];let a,l=this._tiles[e].tileID;for(;l.overscaledZ>0;){if(l.key in this._loadedParentTiles){a=this._loadedParentTiles[l.key];break}n.push(l.key);const u=l.scaledTo(l.overscaledZ-1);if(a=this._getLoadedTile(u),a)break;l=u}for(const u of n)this._loadedParentTiles[u]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const n=this._tiles[e].tileID,a=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=a}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));const a=n;return n||(n=new Zn(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,a||this._source.fire(new c.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const a=n.getExpiryTimeout();a&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},a))}refreshTiles(e){for(const n in this._tiles)(this._isIdRenderable(n)||this._tiles[n].state=="errored")&&e.some(a=>a.equals(this._tiles[n].tileID.canonical))&&this._reloadTile(n,"expired")}_removeTile(e){const n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){const n=e.sourceDataType;e.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&n==="content"&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,a){const l=[],u=this.transform;if(!u)return l;const f=u.getCoveringTilesDetailsProvider().allowWorldCopies(),_=a?u.getCameraQueryGeometry(e):e,y=I=>u.screenPointToMercatorCoordinate(I,this.terrain),b=this.transformBbox(e,y,!f),w=this.transformBbox(_,y,!f),S=this.getIds(),P=c.a2.fromPoints(w);for(let I=0;I<S.length;I++){const k=this._tiles[S[I]];if(k.holdingForFade())continue;const O=f?[k.tileID]:[k.tileID.unwrapTo(-1),k.tileID.unwrapTo(0)],B=Math.pow(2,u.zoom-k.tileID.overscaledZ),N=n*k.queryPadding*c.$/k.tileSize/B;for(const U of O){const q=P.map($=>U.getTilePoint(new c.a1($.x,$.y)));if(q.expandBy(N),q.intersects(qe)){const $=b.map(K=>U.getTilePoint(K)),H=w.map(K=>U.getTilePoint(K));l.push({tile:k,tileID:f?U:U.unwrapTo(0),queryGeometry:$,cameraQueryGeometry:H,scale:B})}}}return l}transformBbox(e,n,a){let l=e.map(n);if(a){const u=c.a2.fromPoints(e);u.shrinkBy(.001*Math.min(u.width(),u.height()));const f=u.map(n);c.a2.fromPoints(l).covers(f)||(l=l.map(_=>_.x>.5?new c.a1(_.x-1,_.y,_.z):_))}return l}getVisibleCoordinates(e){const n=this.getRenderableIds(e).map(a=>this._tiles[a].tileID);return this.transform&&this.transform.populateCache(n),n}hasTransition(){if(this._source.hasTransition())return!0;if(He(this._source.type)){const e=Ee.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setFeatureState(e,n,a){this._state.updateState(e=e||"_geojsonTileLayer",n,a)}removeFeatureState(e,n,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",n,a)}getFeatureState(e,n){return this._state.getState(e=e||"_geojsonTileLayer",n)}setDependencies(e,n,a){const l=this._tiles[e];l&&l.setDependencies(n,a)}reloadTilesForDependencies(e,n){for(const a in this._tiles)this._tiles[a].hasDependency(e,n)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(e,n))}}function Oe(h,e){const n=Math.abs(2*h.wrap)-+(h.wrap<0),a=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||a-n||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function He(h){return h==="raster"||h==="image"||h==="video"}Qe.maxOverzooming=10,Qe.maxUnderzooming=3;class Tt{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let a=1;a<this.points.length;a++)this._distances[a]=this._distances[a-1]+this.points[a].dist(this.points[a-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=c.ah(e,0,1);let n=1,a=this._distances[n];const l=e*this.paddedLength+this.padding;for(;a<l&&n<this._distances.length;)a=this._distances[++n];const u=n-1,f=this._distances[u],_=a-f,y=_>0?(l-f)/_:0;return this.points[u].mult(1-y).add(this.points[n].mult(y))}}function Ht(h,e){let n=!0;return h==="always"||h!=="never"&&e!=="never"||(n=!1),n}class Xt{constructor(e,n,a){const l=this.boxCells=[],u=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(n/a);for(let f=0;f<this.xCellCount*this.yCellCount;f++)l.push([]),u.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,a,l,u){this._forEachCell(n,a,l,u,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(n),this.bboxes.push(a),this.bboxes.push(l),this.bboxes.push(u)}insertCircle(e,n,a,l){this._forEachCell(n-l,a-l,n+l,a+l,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(n),this.circles.push(a),this.circles.push(l)}_insertBoxCell(e,n,a,l,u,f){this.boxCells[u].push(f)}_insertCircleCell(e,n,a,l,u,f){this.circleCells[u].push(f)}_query(e,n,a,l,u,f,_){if(a<0||e>this.width||l<0||n>this.height)return[];const y=[];if(e<=0&&n<=0&&this.width<=a&&this.height<=l){if(u)return[{key:null,x1:e,y1:n,x2:a,y2:l}];for(let b=0;b<this.boxKeys.length;b++)y.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let b=0;b<this.circleKeys.length;b++){const w=this.circles[3*b],S=this.circles[3*b+1],P=this.circles[3*b+2];y.push({key:this.circleKeys[b],x1:w-P,y1:S-P,x2:w+P,y2:S+P})}}else this._forEachCell(e,n,a,l,this._queryCell,y,{hitTest:u,overlapMode:f,seenUids:{box:{},circle:{}}},_);return y}query(e,n,a,l){return this._query(e,n,a,l,!1,null)}hitTest(e,n,a,l,u,f){return this._query(e,n,a,l,!0,u,f).length>0}hitTestCircle(e,n,a,l,u){const f=e-a,_=e+a,y=n-a,b=n+a;if(_<0||f>this.width||b<0||y>this.height)return!1;const w=[];return this._forEachCell(f,y,_,b,this._queryCellCircle,w,{hitTest:!0,overlapMode:l,circle:{x:e,y:n,radius:a},seenUids:{box:{},circle:{}}},u),w.length>0}_queryCell(e,n,a,l,u,f,_,y){const{seenUids:b,hitTest:w,overlapMode:S}=_,P=this.boxCells[u];if(P!==null){const k=this.bboxes;for(const O of P)if(!b.box[O]){b.box[O]=!0;const B=4*O,N=this.boxKeys[O];if(e<=k[B+2]&&n<=k[B+3]&&a>=k[B+0]&&l>=k[B+1]&&(!y||y(N))&&(!w||!Ht(S,N.overlapMode))&&(f.push({key:N,x1:k[B],y1:k[B+1],x2:k[B+2],y2:k[B+3]}),w))return!0}}const I=this.circleCells[u];if(I!==null){const k=this.circles;for(const O of I)if(!b.circle[O]){b.circle[O]=!0;const B=3*O,N=this.circleKeys[O];if(this._circleAndRectCollide(k[B],k[B+1],k[B+2],e,n,a,l)&&(!y||y(N))&&(!w||!Ht(S,N.overlapMode))){const U=k[B],q=k[B+1],$=k[B+2];if(f.push({key:N,x1:U-$,y1:q-$,x2:U+$,y2:q+$}),w)return!0}}}return!1}_queryCellCircle(e,n,a,l,u,f,_,y){const{circle:b,seenUids:w,overlapMode:S}=_,P=this.boxCells[u];if(P!==null){const k=this.bboxes;for(const O of P)if(!w.box[O]){w.box[O]=!0;const B=4*O,N=this.boxKeys[O];if(this._circleAndRectCollide(b.x,b.y,b.radius,k[B+0],k[B+1],k[B+2],k[B+3])&&(!y||y(N))&&!Ht(S,N.overlapMode))return f.push(!0),!0}}const I=this.circleCells[u];if(I!==null){const k=this.circles;for(const O of I)if(!w.circle[O]){w.circle[O]=!0;const B=3*O,N=this.circleKeys[O];if(this._circlesCollide(k[B],k[B+1],k[B+2],b.x,b.y,b.radius)&&(!y||y(N))&&!Ht(S,N.overlapMode))return f.push(!0),!0}}}_forEachCell(e,n,a,l,u,f,_,y){const b=this._convertToXCellCoord(e),w=this._convertToYCellCoord(n),S=this._convertToXCellCoord(a),P=this._convertToYCellCoord(l);for(let I=b;I<=S;I++)for(let k=w;k<=P;k++)if(u.call(this,e,n,a,l,this.xCellCount*k+I,f,_,y))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,a,l,u,f){const _=l-e,y=u-n,b=a+f;return b*b>_*_+y*y}_circleAndRectCollide(e,n,a,l,u,f,_){const y=(f-l)/2,b=Math.abs(e-(l+y));if(b>y+a)return!1;const w=(_-u)/2,S=Math.abs(n-(u+w));if(S>w+a)return!1;if(b<=y||S<=w)return!0;const P=b-y,I=S-w;return P*P+I*I<=a*a}}function Nt(h,e,n){const a=c.L();if(!h){const{vecSouth:S,vecEast:P}=ot(e),I=ct();I[0]=P[0],I[1]=P[1],I[2]=S[0],I[3]=S[1],l=I,(w=(f=(u=I)[0])*(b=u[3])-(y=u[2])*(_=u[1]))&&(l[0]=b*(w=1/w),l[1]=-_*w,l[2]=-y*w,l[3]=f*w),a[0]=I[0],a[1]=I[1],a[4]=I[2],a[5]=I[3]}var l,u,f,_,y,b,w;return c.N(a,a,[1/n,1/n,1]),a}function rt(h,e,n,a){if(h){const l=c.L();if(!e){const{vecSouth:u,vecEast:f}=ot(n);l[0]=f[0],l[1]=f[1],l[4]=u[0],l[5]=u[1]}return c.N(l,l,[a,a,1]),l}return n.pixelsToClipSpaceMatrix}function ot(h){const e=Math.cos(h.rollInRadians),n=Math.sin(h.rollInRadians),a=Math.cos(h.pitchInRadians),l=Math.cos(h.bearingInRadians),u=Math.sin(h.bearingInRadians),f=c.ar();f[0]=-l*a*n-u*e,f[1]=-u*a*n+l*e;const _=c.as(f);_<1e-9?c.at(f):c.au(f,f,1/_);const y=c.ar();y[0]=l*a*e-u*n,y[1]=u*a*e+l*n;const b=c.as(y);return b<1e-9?c.at(y):c.au(y,y,1/b),{vecEast:y,vecSouth:f}}function Ut(h,e,n,a){let l;a?(l=[h,e,a(h,e),1],c.aw(l,l,n)):(l=[h,e,0,1],qn(l,l,n));const u=l[3];return{point:new c.P(l[0]/u,l[1]/u),signedDistanceFromCamera:u,isOccluded:!1}}function Te(h,e){return .5+h/e*.5}function gi(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function At(h,e,n,a,l,u,f,_,y,b,w,S,P){const I=n?h.textSizeData:h.iconSizeData,k=c.an(I,e.transform.zoom),O=[256/e.width*2+1,256/e.height*2+1],B=n?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;B.clear();const N=h.lineVertexArray,U=n?h.text.placedSymbolArray:h.icon.placedSymbolArray,q=e.transform.width/e.transform.height;let $=!1;for(let H=0;H<U.length;H++){const K=U.get(H);if(K.hidden||K.writingMode===c.ao.vertical&&!$){xr(K.numGlyphs,B);continue}$=!1;const G=new c.P(K.anchorX,K.anchorY),te={getElevation:P,pitchedLabelPlaneMatrix:a,lineVertexArray:N,pitchWithMap:u,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:e.transform,tileAnchorPoint:G,unwrappedTileID:y,width:b,height:w,translation:S},ue=Wr(K.anchorX,K.anchorY,te);if(!gi(ue.point,O)){xr(K.numGlyphs,B);continue}const ae=Te(e.transform.cameraToCenterDistance,ue.signedDistanceFromCamera),oe=c.ap(I,k,K),he=u?oe*e.transform.getPitchedTextCorrection(K.anchorX,K.anchorY,y)/ae:oe*ae,we=ke({projectionContext:te,pitchedLabelPlaneMatrixInverse:l,symbol:K,fontSize:he,flip:!1,keepUpright:f,glyphOffsetArray:h.glyphOffsetArray,dynamicLayoutVertexArray:B,aspectRatio:q,rotateToLine:_});$=we.useVertical,(we.notEnoughRoom||$||we.needsFlipping&&ke({projectionContext:te,pitchedLabelPlaneMatrixInverse:l,symbol:K,fontSize:he,flip:!0,keepUpright:f,glyphOffsetArray:h.glyphOffsetArray,dynamicLayoutVertexArray:B,aspectRatio:q,rotateToLine:_}).notEnoughRoom)&&xr(K.numGlyphs,B)}n?h.text.dynamicLayoutVertexBuffer.updateData(B):h.icon.dynamicLayoutVertexBuffer.updateData(B)}function qr(h,e,n,a,l,u,f,_){const y=u.glyphStartIndex+u.numGlyphs,b=u.lineStartIndex,w=u.lineStartIndex+u.lineLength,S=e.getoffsetX(u.glyphStartIndex),P=e.getoffsetX(y-1),I=Hr(h*S,n,a,l,u.segment,b,w,_,f);if(!I)return null;const k=Hr(h*P,n,a,l,u.segment,b,w,_,f);return k?_.projectionCache.anyProjectionOccluded?null:{first:I,last:k}:null}function Gn(h,e,n,a){return h===c.ao.horizontal&&Math.abs(n.y-e.y)>Math.abs(n.x-e.x)*a?{useVertical:!0}:(h===c.ao.vertical?e.y<n.y:e.x>n.x)?{needsFlipping:!0}:null}function ke(h){const{projectionContext:e,pitchedLabelPlaneMatrixInverse:n,symbol:a,fontSize:l,flip:u,keepUpright:f,glyphOffsetArray:_,dynamicLayoutVertexArray:y,aspectRatio:b,rotateToLine:w}=h,S=l/24,P=a.lineOffsetX*S,I=a.lineOffsetY*S;let k;if(a.numGlyphs>1){const O=a.glyphStartIndex+a.numGlyphs,B=a.lineStartIndex,N=a.lineStartIndex+a.lineLength,U=qr(S,_,P,I,u,a,w,e);if(!U)return{notEnoughRoom:!0};const q=_n(U.first.point.x,U.first.point.y,e,n),$=_n(U.last.point.x,U.last.point.y,e,n);if(f&&!u){const H=Gn(a.writingMode,q,$,b);if(H)return H}k=[U.first];for(let H=a.glyphStartIndex+1;H<O-1;H++){const K=Hr(S*_.getoffsetX(H),P,I,u,a.segment,B,N,e,w);if(!K)return{notEnoughRoom:!0};k.push(K)}k.push(U.last)}else{if(f&&!u){const B=hi(e.tileAnchorPoint.x,e.tileAnchorPoint.y,e).point,N=a.lineStartIndex+a.segment+1,U=new c.P(e.lineVertexArray.getx(N),e.lineVertexArray.gety(N)),q=hi(U.x,U.y,e),$=q.signedDistanceFromCamera>0?q.point:et(e.tileAnchorPoint,U,B,1,e),H=_n(B.x,B.y,e,n),K=_n($.x,$.y,e,n),G=Gn(a.writingMode,H,K,b);if(G)return G}const O=Hr(S*_.getoffsetX(a.glyphStartIndex),P,I,u,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,e,w);if(!O||e.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};k=[O]}for(const O of k)c.av(y,O.point,O.angle);return{}}function et(h,e,n,a,l){const u=h.add(h.sub(e)._unit()),f=hi(u.x,u.y,l).point,_=n.sub(f);return n.add(_._mult(a/_.mag()))}function Je(h,e,n){const a=e.projectionCache;if(a.projections[h])return a.projections[h];const l=new c.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),u=hi(l.x,l.y,e);if(u.signedDistanceFromCamera>0)return a.projections[h]=u.point,a.anyProjectionOccluded=a.anyProjectionOccluded||u.isOccluded,u.point;const f=h-n.direction;return et(n.distanceFromAnchor===0?e.tileAnchorPoint:new c.P(e.lineVertexArray.getx(f),e.lineVertexArray.gety(f)),l,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function hi(h,e,n){const a=h+n.translation[0],l=e+n.translation[1];let u;return n.pitchWithMap?(u=Ut(a,l,n.pitchedLabelPlaneMatrix,n.getElevation),u.isOccluded=!1):(u=n.transform.projectTileCoordinates(a,l,n.unwrappedTileID,n.getElevation),u.point.x=(.5*u.point.x+.5)*n.width,u.point.y=(.5*-u.point.y+.5)*n.height),u}function _n(h,e,n,a){if(n.pitchWithMap){const l=[h,e,0,1];return c.aw(l,l,a),n.transform.projectTileCoordinates(l[0]/l[3],l[1]/l[3],n.unwrappedTileID,n.getElevation).point}return{x:h/n.width*2-1,y:1-e/n.height*2}}function Wr(h,e,n){return n.transform.projectTileCoordinates(h,e,n.unwrappedTileID,n.getElevation)}function Ye(h,e,n){return h._unit()._perp()._mult(e*n)}function ca(h,e,n,a,l,u,f,_,y){if(_.projectionCache.offsets[h])return _.projectionCache.offsets[h];const b=n.add(e);if(h+y.direction<a||h+y.direction>=l)return _.projectionCache.offsets[h]=b,b;const w=Je(h+y.direction,_,y),S=Ye(w.sub(n),f,y.direction),P=n.add(S),I=w.add(S);return _.projectionCache.offsets[h]=c.ax(u,b,P,I)||b,_.projectionCache.offsets[h]}function Hr(h,e,n,a,l,u,f,_,y){const b=a?h-e:h+e;let w=b>0?1:-1,S=0;a&&(w*=-1,S=Math.PI),w<0&&(S+=Math.PI);let P,I=w>0?u+l:u+l+1;_.projectionCache.cachedAnchorPoint?P=_.projectionCache.cachedAnchorPoint:(P=hi(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=P);let k,O,B=P,N=P,U=0,q=0;const $=Math.abs(b),H=[];let K;for(;U+q<=$;){if(I+=w,I<u||I>=f)return null;U+=q,N=B,O=k;const ue={absOffsetX:$,direction:w,distanceFromAnchor:U,previousVertex:N};if(B=Je(I,_,ue),n===0)H.push(N),K=B.sub(N);else{let ae;const oe=B.sub(N);ae=oe.mag()===0?Ye(Je(I+w,_,ue).sub(B),n,w):Ye(oe,n,w),O||(O=N.add(ae)),k=ca(I,ae,B,u,f,O,n,_,ue),H.push(O),K=k.sub(O)}q=K.mag()}const G=K._mult(($-U)/q)._add(O||N),te=S+Math.atan2(B.y-N.y,B.x-N.x);return H.push(G),{point:G,angle:y?te:0,path:H}}const ha=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function xr(h,e){for(let n=0;n<h;n++){const a=e.length;e.resize(a+4),e.float32.set(ha,3*a)}}function qn(h,e,n){const a=e[0],l=e[1];return h[0]=n[0]*a+n[4]*l+n[12],h[1]=n[1]*a+n[5]*l+n[13],h[3]=n[3]*a+n[7]*l+n[15],h}const Rt=100;class ua{constructor(e,n=new Xt(e.width+200,e.height+200,25),a=new Xt(e.width+200,e.height+200,25)){this.transform=e,this.grid=n,this.ignoredGrid=a,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Rt,this.screenBottomBoundary=e.height+Rt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,n,a,l,u,f,_,y,b,w,S,P){const I=this.projectAndGetPerspectiveRatio(e.anchorPointX+y[0],e.anchorPointY+y[1],u,w,P),k=a*I.perspectiveRatio;let O;if(f||_)O=this._projectCollisionBox(e,k,l,u,f,_,y,I,w,S,P);else{const K=I.x+(S?S.x*k:0),G=I.y+(S?S.y*k:0);O={allPointsOccluded:!1,box:[K+e.x1*k,G+e.y1*k,K+e.x2*k,G+e.y2*k]}}const[B,N,U,q]=O.box,$=f?O.allPointsOccluded:I.isOccluded;let H=$;return H||(H=I.perspectiveRatio<this.perspectiveRatioCutoff),H||(H=!this.isInsideGrid(B,N,U,q)),H||n!=="always"&&this.grid.hitTest(B,N,U,q,n,b)?{box:[B,N,U,q],placeable:!1,offscreen:!1,occluded:$}:{box:[B,N,U,q],placeable:!0,offscreen:this.isOffscreen(B,N,U,q),occluded:$}}placeCollisionCircles(e,n,a,l,u,f,_,y,b,w,S,P,I,k){const O=[],B=new c.P(n.anchorX,n.anchorY),N=this.getPerspectiveRatio(B.x,B.y,f,k),U=(b?u*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,f)/N:u*N)/c.aB,q={getElevation:k,pitchedLabelPlaneMatrix:_,lineVertexArray:a,pitchWithMap:b,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:B,unwrappedTileID:f,width:this.transform.width,height:this.transform.height,translation:I},$=qr(U,l,n.lineOffsetX*U,n.lineOffsetY*U,!1,n,!1,q);let H=!1,K=!1,G=!0;if($){const te=.5*S*N+P,ue=new c.P(-100,-100),ae=new c.P(this.screenRightBoundary,this.screenBottomBoundary),oe=new Tt,he=$.first,we=$.last;let Se=[];for(let Ke=he.path.length-1;Ke>=1;Ke--)Se.push(he.path[Ke]);for(let Ke=1;Ke<we.path.length;Ke++)Se.push(we.path[Ke]);const ye=2.5*te;if(b){const Ke=this.projectPathToScreenSpace(Se,q);Se=Ke.some(dt=>dt.signedDistanceFromCamera<=0)?[]:Ke.map(dt=>dt.point)}let Le=[];if(Se.length>0){const Ke=Se[0].clone(),dt=Se[0].clone();for(let yt=1;yt<Se.length;yt++)Ke.x=Math.min(Ke.x,Se[yt].x),Ke.y=Math.min(Ke.y,Se[yt].y),dt.x=Math.max(dt.x,Se[yt].x),dt.y=Math.max(dt.y,Se[yt].y);Le=Ke.x>=ue.x&&dt.x<=ae.x&&Ke.y>=ue.y&&dt.y<=ae.y?[Se]:dt.x<ue.x||Ke.x>ae.x||dt.y<ue.y||Ke.y>ae.y?[]:c.ay([Se],ue.x,ue.y,ae.x,ae.y)}for(const Ke of Le){oe.reset(Ke,.25*te);let dt=0;dt=oe.length<=.5*te?1:Math.ceil(oe.paddedLength/ye)+1;for(let yt=0;yt<dt;yt++){const mt=yt/Math.max(dt-1,1),Ct=oe.lerp(mt),zt=Ct.x+Rt,Xe=Ct.y+Rt;O.push(zt,Xe,te,0);const xt=zt-te,Zt=Xe-te,Yt=zt+te,ri=Xe+te;if(G=G&&this.isOffscreen(xt,Zt,Yt,ri),K=K||this.isInsideGrid(xt,Zt,Yt,ri),e!=="always"&&this.grid.hitTestCircle(zt,Xe,te,e,w)&&(H=!0,!y))return{circles:[],offscreen:!1,collisionDetected:H}}}}return{circles:!y&&H||!K||N<this.perspectiveRatioCutoff?[]:O,offscreen:G,collisionDetected:H}}projectPathToScreenSpace(e,n){const a=function(l,u){const f=c.L();return c.aq(f,u.pitchedLabelPlaneMatrix),l.map(_=>{const y=Ut(_.x,_.y,f,u.getElevation),b=u.transform.projectTileCoordinates(y.point.x,y.point.y,u.unwrappedTileID,u.getElevation);return b.point.x=(.5*b.point.x+.5)*u.width,b.point.y=(.5*-b.point.y+.5)*u.height,b})}(e,n);return function(l){let u=0,f=0,_=0,y=0;for(let b=0;b<l.length;b++)l[b].isOccluded?(_=b+1,y=0):(y++,y>f&&(f=y,u=_));return l.slice(u,u+f)}(a)}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],a=new c.a2;for(const S of e){const P=new c.P(S.x+Rt,S.y+Rt);a.extend(P),n.push(P)}const{minX:l,minY:u,maxX:f,maxY:_}=a,y=this.grid.query(l,u,f,_).concat(this.ignoredGrid.query(l,u,f,_)),b={},w={};for(const S of y){const P=S.key;if(b[P.bucketInstanceId]===void 0&&(b[P.bucketInstanceId]={}),b[P.bucketInstanceId][P.featureIndex])continue;const I=[new c.P(S.x1,S.y1),new c.P(S.x2,S.y1),new c.P(S.x2,S.y2),new c.P(S.x1,S.y2)];c.az(n,I)&&(b[P.bucketInstanceId][P.featureIndex]=!0,w[P.bucketInstanceId]===void 0&&(w[P.bucketInstanceId]=[]),w[P.bucketInstanceId].push(P.featureIndex))}return w}insertCollisionBox(e,n,a,l,u,f){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:u,collisionGroupID:f,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,a,l,u,f){const _=a?this.ignoredGrid:this.grid,y={bucketInstanceId:l,featureIndex:u,collisionGroupID:f,overlapMode:n};for(let b=0;b<e.length;b+=4)_.insertCircle(y,e[b],e[b+1],e[b+2])}projectAndGetPerspectiveRatio(e,n,a,l,u){if(u){let f;l?(f=[e,n,l(e,n),1],c.aw(f,f,u)):(f=[e,n,0,1],qn(f,f,u));const _=f[3];return{x:(f[0]/_+1)/2*this.transform.width+Rt,y:(-f[1]/_+1)/2*this.transform.height+Rt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/_*.5,isOccluded:!1,signedDistanceFromCamera:_}}{const f=this.transform.projectTileCoordinates(e,n,a,l);return{x:(f.point.x+1)/2*this.transform.width+Rt,y:(1-f.point.y)/2*this.transform.height+Rt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/f.signedDistanceFromCamera*.5,isOccluded:f.isOccluded,signedDistanceFromCamera:f.signedDistanceFromCamera}}}getPerspectiveRatio(e,n,a,l){const u=this.transform.projectTileCoordinates(e,n,a,l);return .5+this.transform.cameraToCenterDistance/u.signedDistanceFromCamera*.5}isOffscreen(e,n,a,l){return a<Rt||e>=this.screenRightBoundary||l<Rt||n>this.screenBottomBoundary}isInsideGrid(e,n,a,l){return a>=0&&e<this.gridRightBoundary&&l>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const e=c.ag([]);return c.M(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,a,l,u,f,_,y,b,w,S){let P=1,I=0,k=0,O=1;const B=e.anchorPointX+_[0],N=e.anchorPointY+_[1];if(f&&!u){const Se=this.projectAndGetPerspectiveRatio(B+1,N,l,b,S),ye=Se.x-y.x,Le=Math.atan((Se.y-y.y)/ye)+(ye<0?Math.PI:0),Ke=Math.sin(Le),dt=Math.cos(Le);P=dt,I=Ke,k=-Ke,O=dt}else if(!f&&u){const Se=ot(this.transform);P=Se.vecEast[0],I=Se.vecEast[1],k=Se.vecSouth[0],O=Se.vecSouth[1]}let U=y.x,q=y.y,$=n;u&&(U=B,q=N,$=Math.pow(2,-(this.transform.zoom-a.overscaledZ)),$*=this.transform.getPitchedTextCorrection(B,N,l),w||($*=c.ah(.5+y.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),w&&(U+=P*w.x*$+k*w.y*$,q+=I*w.x*$+O*w.y*$);const H=e.x1*$,K=e.x2*$,G=(H+K)/2,te=e.y1*$,ue=e.y2*$,ae=(te+ue)/2,oe=[{offsetX:H,offsetY:te},{offsetX:G,offsetY:te},{offsetX:K,offsetY:te},{offsetX:K,offsetY:ae},{offsetX:K,offsetY:ue},{offsetX:G,offsetY:ue},{offsetX:H,offsetY:ue},{offsetX:H,offsetY:ae}];let he=[];for(const{offsetX:Se,offsetY:ye}of oe)he.push(new c.P(U+P*Se+k*ye,q+I*Se+O*ye));let we=!1;if(u){const Se=he.map(ye=>this.projectAndGetPerspectiveRatio(ye.x,ye.y,l,b,S));we=Se.some(ye=>!ye.isOccluded),he=Se.map(ye=>new c.P(ye.x,ye.y))}else we=!0;return{box:c.aA(he),allPointsOccluded:!we}}}class Ai{constructor(e,n,a,l){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):l&&a?1:0,this.placed=a}isHidden(){return this.opacity===0&&!this.placed}}class vt{constructor(e,n,a,l,u){this.text=new Ai(e?e.text:null,n,a,u),this.icon=new Ai(e?e.icon:null,n,l,u)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Il{constructor(e,n,a){this.text=e,this.icon=n,this.skipFade=a}}class Ss{constructor(e,n,a,l,u){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=a,this.bucketIndex=l,this.tileID=u}}class uo{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:a=>a.collisionGroupID===n}}return this.collisionGroups[e]}}function Xr(h,e,n,a,l){const{horizontalAlign:u,verticalAlign:f}=c.aH(h);return new c.P(-(u-.5)*e+a[0]*l,-(f-.5)*n+a[1]*l)}class Yr{constructor(e,n,a,l,u){this.transform=e.clone(),this.terrain=n,this.collisionIndex=new ua(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new uo(l),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=u,u&&(u.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const n=this.terrain;return n?(a,l)=>n.getElevation(e,a,l):null}getBucketParts(e,n,a,l){const u=a.getBucket(n),f=a.latestFeatureIndex;if(!u||!f||n.id!==u.layerIds[0])return;const _=a.collisionBoxArray,y=u.layers[0].layout,b=u.layers[0].paint,w=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),S=a.tileSize/c.$,P=a.tileID.toUnwrapped(),I=y.get("text-rotation-alignment")==="map",k=c.aC(a,1,this.transform.zoom),O=c.aD(this.collisionIndex.transform,a,b.get("text-translate"),b.get("text-translate-anchor")),B=c.aD(this.collisionIndex.transform,a,b.get("icon-translate"),b.get("icon-translate-anchor")),N=Nt(I,this.transform,k);this.retainedQueryData[u.bucketInstanceId]=new Ss(u.bucketInstanceId,f,u.sourceLayerIndex,u.index,a.tileID);const U={bucket:u,layout:y,translationText:O,translationIcon:B,unwrappedTileID:P,pitchedLabelPlaneMatrix:N,scale:w,textPixelRatio:S,holdingForFade:a.holdingForFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:c.an(u.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(u.sourceID)};if(l)for(const q of u.sortKeyRanges){const{sortKey:$,symbolInstanceStart:H,symbolInstanceEnd:K}=q;e.push({sortKey:$,symbolInstanceStart:H,symbolInstanceEnd:K,parameters:U})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:u.symbolInstances.length,parameters:U})}attemptAnchorPlacement(e,n,a,l,u,f,_,y,b,w,S,P,I,k,O,B,N,U,q,$){const H=c.aE[e.textAnchor],K=[e.textOffset0,e.textOffset1],G=Xr(H,a,l,K,u),te=this.collisionIndex.placeCollisionBox(n,P,y,b,w,_,f,B,S.predicate,q,G,$);if((!U||this.collisionIndex.placeCollisionBox(U,P,y,b,w,_,f,N,S.predicate,q,G,$).placeable)&&te.placeable){let ue;if(this.prevPlacement&&this.prevPlacement.variableOffsets[I.crossTileID]&&this.prevPlacement.placements[I.crossTileID]&&this.prevPlacement.placements[I.crossTileID].text&&(ue=this.prevPlacement.variableOffsets[I.crossTileID].anchor),I.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[I.crossTileID]={textOffset:K,width:a,height:l,anchor:H,textBoxScale:u,prevAnchor:ue},this.markUsedJustification(k,H,I,O),k.allowVerticalPlacement&&(this.markUsedOrientation(k,O,I),this.placedOrientations[I.crossTileID]=O),{shift:G,placedGlyphBoxes:te}}}placeLayerBucketPart(e,n,a){const{bucket:l,layout:u,translationText:f,translationIcon:_,unwrappedTileID:y,pitchedLabelPlaneMatrix:b,textPixelRatio:w,holdingForFade:S,collisionBoxArray:P,partiallyEvaluatedTextSize:I,collisionGroup:k}=e.parameters,O=u.get("text-optional"),B=u.get("icon-optional"),N=c.aF(u,"text-overlap","text-allow-overlap"),U=N==="always",q=c.aF(u,"icon-overlap","icon-allow-overlap"),$=q==="always",H=u.get("text-rotation-alignment")==="map",K=u.get("text-pitch-alignment")==="map",G=u.get("icon-text-fit")!=="none",te=u.get("symbol-z-order")==="viewport-y",ue=U&&($||!l.hasIconData()||B),ae=$&&(U||!l.hasTextData()||O);!l.collisionArrays&&P&&l.deserializeCollisionBoxes(P);const oe=this.retainedQueryData[l.bucketInstanceId].tileID,he=this._getTerrainElevationFunc(oe),we=this.transform.getFastPathSimpleProjectionMatrix(oe),Se=(ye,Le,Ke)=>{var dt,yt;if(n[ye.crossTileID])return;if(S)return void(this.placements[ye.crossTileID]=new Il(!1,!1,!1));let mt=!1,Ct=!1,zt=!0,Xe=null,xt={box:null,placeable:!1,offscreen:null,occluded:!1},Zt={placeable:!1},Yt=null,ri=null,Si=null,ar=0,tn=0,rn=0;Le.textFeatureIndex?ar=Le.textFeatureIndex:ye.useRuntimeCollisionCircles&&(ar=ye.featureIndex),Le.verticalTextFeatureIndex&&(tn=Le.verticalTextFeatureIndex);const ps=Le.textBox;if(ps){const Li=Gt=>{let Kt=c.ao.horizontal;if(l.allowVerticalPlacement&&!Gt&&this.prevPlacement){const Hi=this.prevPlacement.placedOrientations[ye.crossTileID];Hi&&(this.placedOrientations[ye.crossTileID]=Hi,Kt=Hi,this.markUsedOrientation(l,Kt,ye))}return Kt},or=(Gt,Kt)=>{if(l.allowVerticalPlacement&&ye.numVerticalGlyphVertices>0&&Le.verticalTextBox){for(const Hi of l.writingModes)if(Hi===c.ao.vertical?(xt=Kt(),Zt=xt):xt=Gt(),xt&&xt.placeable)break}else xt=Gt()},Mi=ye.textAnchorOffsetStartIndex,nn=ye.textAnchorOffsetEndIndex;if(nn===Mi){const Gt=(Kt,Hi)=>{const qt=this.collisionIndex.placeCollisionBox(Kt,N,w,oe,y,K,H,f,k.predicate,he,void 0,we);return qt&&qt.placeable&&(this.markUsedOrientation(l,Hi,ye),this.placedOrientations[ye.crossTileID]=Hi),qt};or(()=>Gt(ps,c.ao.horizontal),()=>{const Kt=Le.verticalTextBox;return l.allowVerticalPlacement&&ye.numVerticalGlyphVertices>0&&Kt?Gt(Kt,c.ao.vertical):{box:null,offscreen:null}}),Li(xt&&xt.placeable)}else{let Gt=c.aE[(yt=(dt=this.prevPlacement)===null||dt===void 0?void 0:dt.variableOffsets[ye.crossTileID])===null||yt===void 0?void 0:yt.anchor];const Kt=(qt,Js,ms)=>{const Ar=qt.x2-qt.x1,lr=qt.y2-qt.y1,sn=ye.textBoxScale,xc=G&&q==="never"?Js:null;let ji=null,vc=N==="never"?1:2,sl="never";Gt&&vc++;for(let Wa=0;Wa<vc;Wa++){for(let Ha=Mi;Ha<nn;Ha++){const an=l.textAnchorOffsets.get(Ha);if(Gt&&an.textAnchor!==Gt)continue;const kr=this.attemptAnchorPlacement(an,qt,Ar,lr,sn,H,K,w,oe,y,k,sl,ye,l,ms,f,_,xc,he);if(kr&&(ji=kr.placedGlyphBoxes,ji&&ji.placeable))return mt=!0,Xe=kr.shift,ji}Gt?Gt=null:sl=N}return a&&!ji&&(ji={box:this.collisionIndex.placeCollisionBox(ps,"always",w,oe,y,K,H,f,k.predicate,he,void 0,we).box,offscreen:!1,placeable:!1,occluded:!1}),ji};or(()=>Kt(ps,Le.iconBox,c.ao.horizontal),()=>{const qt=Le.verticalTextBox;return l.allowVerticalPlacement&&(!xt||!xt.placeable)&&ye.numVerticalGlyphVertices>0&&qt?Kt(qt,Le.verticalIconBox,c.ao.vertical):{box:null,occluded:!0,offscreen:null}}),xt&&(mt=xt.placeable,zt=xt.offscreen);const Hi=Li(xt&&xt.placeable);if(!mt&&this.prevPlacement){const qt=this.prevPlacement.variableOffsets[ye.crossTileID];qt&&(this.variableOffsets[ye.crossTileID]=qt,this.markUsedJustification(l,qt.anchor,ye,Hi))}}}if(Yt=xt,mt=Yt&&Yt.placeable,zt=Yt&&Yt.offscreen,ye.useRuntimeCollisionCircles){const Li=l.text.placedSymbolArray.get(ye.centerJustifiedTextSymbolIndex),or=c.ap(l.textSizeData,I,Li),Mi=u.get("text-padding");ri=this.collisionIndex.placeCollisionCircles(N,Li,l.lineVertexArray,l.glyphOffsetArray,or,y,b,a,K,k.predicate,ye.collisionCircleDiameter,Mi,f,he),ri.circles.length&&ri.collisionDetected&&!a&&c.w("Collisions detected, but collision boxes are not shown"),mt=U||ri.circles.length>0&&!ri.collisionDetected,zt=zt&&ri.offscreen}if(Le.iconFeatureIndex&&(rn=Le.iconFeatureIndex),Le.iconBox){const Li=or=>this.collisionIndex.placeCollisionBox(or,q,w,oe,y,K,H,_,k.predicate,he,G&&Xe?Xe:void 0,we);Zt&&Zt.placeable&&Le.verticalIconBox?(Si=Li(Le.verticalIconBox),Ct=Si.placeable):(Si=Li(Le.iconBox),Ct=Si.placeable),zt=zt&&Si.offscreen}const fs=O||ye.numHorizontalGlyphVertices===0&&ye.numVerticalGlyphVertices===0,Rn=B||ye.numIconVertices===0;fs||Rn?Rn?fs||(Ct=Ct&&mt):mt=Ct&&mt:Ct=mt=Ct&&mt;const Fn=Ct&&Si.placeable;if(mt&&Yt.placeable&&this.collisionIndex.insertCollisionBox(Yt.box,N,u.get("text-ignore-placement"),l.bucketInstanceId,Zt&&Zt.placeable&&tn?tn:ar,k.ID),Fn&&this.collisionIndex.insertCollisionBox(Si.box,q,u.get("icon-ignore-placement"),l.bucketInstanceId,rn,k.ID),ri&&mt&&this.collisionIndex.insertCollisionCircles(ri.circles,N,u.get("text-ignore-placement"),l.bucketInstanceId,ar,k.ID),a&&this.storeCollisionData(l.bucketInstanceId,Ke,Le,Yt,Si,ri),ye.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(l.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[ye.crossTileID]=new Il((mt||ue)&&!(Yt!=null&&Yt.occluded),(Ct||ae)&&!(Si!=null&&Si.occluded),zt||l.justReloaded),n[ye.crossTileID]=!0};if(te){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const ye=l.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let Le=ye.length-1;Le>=0;--Le){const Ke=ye[Le];Se(l.symbolInstances.get(Ke),l.collisionArrays[Ke],Ke)}}else for(let ye=e.symbolInstanceStart;ye<e.symbolInstanceEnd;ye++)Se(l.symbolInstances.get(ye),l.collisionArrays[ye],ye);l.justReloaded=!1}storeCollisionData(e,n,a,l,u,f){if(a.textBox||a.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)),a.textBox&&(y.text=l.box),a.iconBox&&(y.icon=u.box)}if(f){let _=this.collisionCircleArrays[e];_===void 0&&(_=this.collisionCircleArrays[e]=[]);for(let y=0;y<f.circles.length;y+=4)_.push(f.circles[y+0]-Rt),_.push(f.circles[y+1]-Rt),_.push(f.circles[y+2]),_.push(f.collisionDetected?1:0)}}markUsedJustification(e,n,a,l){let u;u=l===c.ao.vertical?a.verticalPlacedTextSymbolIndex:{left:a.leftJustifiedTextSymbolIndex,center:a.centerJustifiedTextSymbolIndex,right:a.rightJustifiedTextSymbolIndex}[c.aG(n)];const f=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex,a.verticalPlacedTextSymbolIndex];for(const _ of f)_>=0&&(e.text.placedSymbolArray.get(_).crossTileID=u>=0&&_!==u?0:a.crossTileID)}markUsedOrientation(e,n,a){const l=n===c.ao.horizontal||n===c.ao.horizontalOnly?n:0,u=n===c.ao.vertical?n:0,f=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const _ of f)e.text.placedSymbolArray.get(_).placedOrientation=l;a.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=u)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let a=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const l=n?n.symbolFadeChange(e):1,u=n?n.opacities:{},f=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(const y in this.placements){const b=this.placements[y],w=u[y];w?(this.opacities[y]=new vt(w,l,b.text,b.icon),a=a||b.text!==w.text.placed||b.icon!==w.icon.placed):(this.opacities[y]=new vt(null,l,b.text,b.icon,b.skipFade),a=a||b.text||b.icon)}for(const y in u){const b=u[y];if(!this.opacities[y]){const w=new vt(b,l,!1,!1);w.isHidden()||(this.opacities[y]=w,a=a||b.text.placed||b.icon.placed)}}for(const y in f)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=f[y]);for(const y in _)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=_[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){const a={};for(const l of n){const u=l.getBucket(e);u&&l.latestFeatureIndex&&e.id===u.layerIds[0]&&this.updateBucketOpacities(u,l.tileID,a,l.collisionBoxArray)}}updateBucketOpacities(e,n,a,l){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const u=e.layers[0],f=u.layout,_=new vt(null,0,!1,!1,!0),y=f.get("text-allow-overlap"),b=f.get("icon-allow-overlap"),w=u._unevaluatedLayout.hasValue("text-variable-anchor")||u._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S=f.get("text-rotation-alignment")==="map",P=f.get("text-pitch-alignment")==="map",I=f.get("icon-text-fit")!=="none",k=new vt(null,0,y&&(b||!e.hasIconData()||f.get("icon-optional")),b&&(y||!e.hasTextData()||f.get("text-optional")),!0);!e.collisionArrays&&l&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(l);const O=(N,U,q)=>{for(let $=0;$<U/4;$++)N.opacityVertexArray.emplaceBack(q);N.hasVisibleVertices=N.hasVisibleVertices||q!==Hn},B=this.collisionBoxArrays.get(e.bucketInstanceId);for(let N=0;N<e.symbolInstances.length;N++){const U=e.symbolInstances.get(N),{numHorizontalGlyphVertices:q,numVerticalGlyphVertices:$,crossTileID:H}=U;let K=this.opacities[H];a[H]?K=_:K||(K=k,this.opacities[H]=K),a[H]=!0;const G=U.numIconVertices>0,te=this.placedOrientations[U.crossTileID],ue=te===c.ao.vertical,ae=te===c.ao.horizontal||te===c.ao.horizontalOnly;if(q>0||$>0){const he=fo(K.text);O(e.text,q,ue?Hn:he),O(e.text,$,ae?Hn:he);const we=K.text.isHidden();[U.rightJustifiedTextSymbolIndex,U.centerJustifiedTextSymbolIndex,U.leftJustifiedTextSymbolIndex].forEach(Le=>{Le>=0&&(e.text.placedSymbolArray.get(Le).hidden=we||ue?1:0)}),U.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(U.verticalPlacedTextSymbolIndex).hidden=we||ae?1:0);const Se=this.variableOffsets[U.crossTileID];Se&&this.markUsedJustification(e,Se.anchor,U,te);const ye=this.placedOrientations[U.crossTileID];ye&&(this.markUsedJustification(e,"left",U,ye),this.markUsedOrientation(e,ye,U))}if(G){const he=fo(K.icon),we=!(I&&U.verticalPlacedIconSymbolIndex&&ue);U.placedIconSymbolIndex>=0&&(O(e.icon,U.numIconVertices,we?he:Hn),e.icon.placedSymbolArray.get(U.placedIconSymbolIndex).hidden=K.icon.isHidden()),U.verticalPlacedIconSymbolIndex>=0&&(O(e.icon,U.numVerticalIconVertices,we?Hn:he),e.icon.placedSymbolArray.get(U.verticalPlacedIconSymbolIndex).hidden=K.icon.isHidden())}const oe=B&&B.has(N)?B.get(N):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const he=e.collisionArrays[N];if(he){let we=new c.P(0,0);if(he.textBox||he.verticalTextBox){let Se=!0;if(w){const ye=this.variableOffsets[H];ye?(we=Xr(ye.anchor,ye.width,ye.height,ye.textOffset,ye.textBoxScale),S&&we._rotate(P?-this.transform.bearingInRadians:this.transform.bearingInRadians)):Se=!1}if(he.textBox||he.verticalTextBox){let ye;he.textBox&&(ye=ue),he.verticalTextBox&&(ye=ae),po(e.textCollisionBox.collisionVertexArray,K.text.placed,!Se||ye,oe.text,we.x,we.y)}}if(he.iconBox||he.verticalIconBox){const Se=!!(!ae&&he.verticalIconBox);let ye;he.iconBox&&(ye=Se),he.verticalIconBox&&(ye=!Se),po(e.iconCollisionBox.collisionVertexArray,K.icon.placed,ye,oe.icon,I?we.x:0,I?we.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 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){const a=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*a>e}setStale(){this.stale=!0}}function po(h,e,n,a,l,u){a&&a.length!==0||(a=[0,0,0,0]);const f=a[0]-Rt,_=a[1]-Rt,y=a[2]-Rt,b=a[3]-Rt;h.emplaceBack(e?1:0,n?1:0,l||0,u||0,f,_),h.emplaceBack(e?1:0,n?1:0,l||0,u||0,y,_),h.emplaceBack(e?1:0,n?1:0,l||0,u||0,y,b),h.emplaceBack(e?1:0,n?1:0,l||0,u||0,f,b)}const Cl=Math.pow(2,25),El=Math.pow(2,24),Wn=Math.pow(2,17),Al=Math.pow(2,16),Zc=Math.pow(2,9),Gc=Math.pow(2,8),qc=Math.pow(2,1);function fo(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const e=h.placed?1:0,n=Math.floor(127*h.opacity);return n*Cl+e*El+n*Wn+e*Al+n*Zc+e*Gc+n*qc+e}const Hn=0;class mo{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,a,l,u){const f=this._bucketParts;for(;this._currentTileIndex<e.length;)if(n.getBucketParts(f,l,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,u())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,f.sort((_,y)=>_.sortKey-y.sortKey));this._currentPartIndex<f.length;)if(n.placeLayerBucketPart(f[this._currentPartIndex],this._seenCrossTileIDs,a),this._currentPartIndex++,u())return!0;return!1}}class go{constructor(e,n,a,l,u,f,_,y){this.placement=new Yr(e,n,f,_,y),this._currentPlacementIndex=a.length-1,this._forceFullPlacement=l,this._showCollisionBoxes=u,this._done=!1}isDone(){return this._done}continuePlacement(e,n,a){const l=Ee.now(),u=()=>!this._forceFullPlacement&&Ee.now()-l>2;for(;this._currentPlacementIndex>=0;){const f=n[e[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(f.type==="symbol"&&(!f.minzoom||f.minzoom<=_)&&(!f.maxzoom||f.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new mo(f)),this._inProgressLayer.continuePlacement(a[f.source],this.placement,this._showCollisionBoxes,f,u))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Xn=512/c.$/2;class _o{constructor(e,n,a){this.tileID=e,this.bucketInstanceId=a,this._symbolsByKey={};const l=new Map;for(let u=0;u<n.length;u++){const f=n.get(u),_=f.key,y=l.get(_);y?y.push(f):l.set(_,[f])}for(const[u,f]of l){const _={positions:f.map(y=>({x:Math.floor(y.anchorX*Xn),y:Math.floor(y.anchorY*Xn)})),crossTileIDs:f.map(y=>y.crossTileID)};if(_.positions.length>128){const y=new c.aI(_.positions.length,16,Uint16Array);for(const{x:b,y:w}of _.positions)y.add(b,w);y.finish(),delete _.positions,_.index=y}this._symbolsByKey[u]=_}}getScaledCoordinates(e,n){const{x:a,y:l,z:u}=this.tileID.canonical,{x:f,y:_,z:y}=n.canonical,b=Xn/Math.pow(2,y-u),w=(_*c.$+e.anchorY)*b,S=l*c.$*Xn;return{x:Math.floor((f*c.$+e.anchorX)*b-a*c.$*Xn),y:Math.floor(w-S)}}findMatches(e,n,a){const l=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let u=0;u<e.length;u++){const f=e.get(u);if(f.crossTileID)continue;const _=this._symbolsByKey[f.key];if(!_)continue;const y=this.getScaledCoordinates(f,n);if(_.index){const b=_.index.range(y.x-l,y.y-l,y.x+l,y.y+l).sort();for(const w of b){const S=_.crossTileIDs[w];if(!a[S]){a[S]=!0,f.crossTileID=S;break}}}else if(_.positions)for(let b=0;b<_.positions.length;b++){const w=_.positions[b],S=_.crossTileIDs[b];if(Math.abs(w.x-y.x)<=l&&Math.abs(w.y-y.y)<=l&&!a[S]){a[S]=!0,f.crossTileID=S;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}}class yo{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Wc{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const n=Math.round((e-this.lng)/360);if(n!==0)for(const a in this.indexes){const l=this.indexes[a],u={};for(const f in l){const _=l[f];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),u[_.tileID.key]=_}this.indexes[a]=u}this.lng=e}addBucket(e,n,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let u=0;u<n.symbolInstances.length;u++)n.symbolInstances.get(u).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const l=this.usedCrossTileIDs[e.overscaledZ];for(const u in this.indexes){const f=this.indexes[u];if(Number(u)>e.overscaledZ)for(const _ in f){const y=f[_];y.tileID.isChildOf(e)&&y.findMatches(n.symbolInstances,e,l)}else{const _=f[e.scaledTo(Number(u)).key];_&&_.findMatches(n.symbolInstances,e,l)}}for(let u=0;u<n.symbolInstances.length;u++){const f=n.symbolInstances.get(u);f.crossTileID||(f.crossTileID=a.generate(),l[f.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new _o(e,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(e,n){for(const a of n.getCrossTileIDsLists())for(const l of a)delete this.usedCrossTileIDs[e][l]}removeStaleBuckets(e){let n=!1;for(const a in this.indexes){const l=this.indexes[a];for(const u in l)e[l[u].bucketInstanceId]||(this.removeBucketCrossTileIDs(a,l[u]),delete l[u],n=!0)}return n}}class Yn{constructor(){this.layerIndexes={},this.crossTileIDs=new yo,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,n,a){let l=this.layerIndexes[e.id];l===void 0&&(l=this.layerIndexes[e.id]=new Wc);let u=!1;const f={};l.handleWrapJump(a);for(const _ of n){const y=_.getBucket(e);y&&e.id===y.layerIds[0]&&(y.bucketInstanceId||(y.bucketInstanceId=++this.maxBucketInstanceId),l.addBucket(_.tileID,y,this.crossTileIDs)&&(u=!0),f[y.bucketInstanceId]=!0)}return l.removeStaleBuckets(f)&&(u=!0),u}pruneUnusedLayers(e){const n={};e.forEach(a=>{n[a]=!0});for(const a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}var Ms="void main() {fragColor=vec4(1.0);}";const Ji={prelude:tt(`#ifdef GL_ES
6
6
  precision mediump float;
7
7
  #else
8
8
  #if !defined(lowp)
@@ -736,8 +736,8 @@ uniform ${w} ${S} u_${P};
736
736
  #else
737
737
  ${w} ${S} ${P} = u_${P};
738
738
  #endif
739
- `}),staticAttributes:a,staticUniforms:f}}class yn{constructor(e,n,a){this.vertexBuffer=e,this.indexBuffer=n,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Kr=c.aJ([{name:"a_pos",type:"Int16",components:2}]);const Mr="#define PROJECTION_MERCATOR",xn="mercator";class it{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return xn}get shaderDefine(){return Mr}get shaderPreludeCode(){return Ji.projectionMercator}get vertexShaderPreludeCode(){return Ji.projectionMercator.vertexSource}get subdivisionGranularity(){return c.aK.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,n,a,l,u){if(this._cachedMesh)return this._cachedMesh;const f=new c.aL;f.emplaceBack(0,0),f.emplaceBack(c.$,0),f.emplaceBack(0,c.$),f.emplaceBack(c.$,c.$);const _=e.createVertexBuffer(f,Kr.members),y=c.aM.simpleSegment(0,0,4,2),b=new c.aN;b.emplaceBack(1,0,2),b.emplaceBack(1,2,3);const w=e.createIndexBuffer(b);return this._cachedMesh=new yn(_,w,y),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class vn{constructor(e=0,n=0,a=0,l=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=a,this.right=l}interpolate(e,n,a){return n.top!=null&&e.top!=null&&(this.top=c.C.number(e.top,n.top,a)),n.bottom!=null&&e.bottom!=null&&(this.bottom=c.C.number(e.bottom,n.bottom,a)),n.left!=null&&e.left!=null&&(this.left=c.C.number(e.left,n.left,a)),n.right!=null&&e.right!=null&&(this.right=c.C.number(e.right,n.right,a)),this}getCenter(e,n){const a=c.ah((this.left+e-this.right)/2,0,e),l=c.ah((this.top+n-this.bottom)/2,0,n);return new c.P(a,l)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new vn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function da(h,e){if(!h.renderWorldCopies||h.lngRange)return;const n=e.lng-h.center.lng;e.lng+=n>180?-360:n<-180?360:0}function pa(h){return Math.max(0,Math.floor(h))}class bi{constructor(e,n,a,l,u,f){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=f===void 0||!!f,this._minZoom=n||0,this._maxZoom=a||22,this._minPitch=l??0,this._maxPitch=u??60,this.setMaxBounds(),this._width=0,this._height=0,this._center=new c.S(0,0),this._elevation=0,this._zoom=0,this._tileZoom=pa(this._zoom),this._scale=c.af(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new vn,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,n,a){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=pa(this._zoom),this._scale=c.af(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new vn(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!a&&e.autoCalculateNearFarZ,n&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){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 c.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const n=c.aO(e,-180,180)*Math.PI/180;var a,l,u,f,_,y,b,w,S;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=ct(),a=this._rotationMatrix,u=-this._bearingInRadians,f=(l=this._rotationMatrix)[0],_=l[1],y=l[2],b=l[3],w=Math.sin(u),S=Math.cos(u),a[0]=f*S+y*w,a[1]=_*S+b*w,a[2]=f*-w+y*S,a[3]=_*-w+b*S)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const n=c.ah(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const n=e/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return c.aP(this._fovInRadians)}setFov(e){e=c.ah(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=c.ae(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const n=this.getConstrained(this._center,e).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=c.af(n),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,n){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,a){this._unmodified=!1,this._edgeInsets.interpolate(e,n,a),this._constrain(),this._calcMatrices()}resize(e,n,a=!0){this._width=e,this._height=n,a&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new Dt([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-c.ai,c.ai])}getConstrained(e,n){return this._callbacks.getConstrained(e,n)}getCameraQueryGeometry(e,n){if(n.length===1)return[n[0],e];{const{minX:a,minY:l,maxX:u,maxY:f}=c.a2.fromPoints(n).extend(e);return[new c.P(a,l),new c.P(u,l),new c.P(u,f),new c.P(a,f),new c.P(a,l)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:n,zoom:a}=this.getConstrained(this.center,this.zoom);this.setCenter(n),this.setZoom(a),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=c.ag(new Float64Array(16));c.N(e,e,[this._width/2,-this._height/2,1]),c.M(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=c.ag(new Float64Array(16)),c.N(e,e,[1,-1,1]),c.M(e,e,[-1,-1,0]),c.N(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,n,a,l){const u=a!==void 0?a:this.bearing,f=l=l!==void 0?l:this.pitch,_=c.a1.fromLngLat(e,n),y=-Math.cos(c.ae(f)),b=Math.sin(c.ae(f)),w=b*Math.sin(c.ae(u)),S=-b*Math.cos(c.ae(u));let P=this.elevation;const I=n-P;let k;y*I>=0||Math.abs(y)<.1?(k=1e4,P=n+k*y):k=-I/y;let O,B,N=c.aQ(1,_.y),U=0;do{if(U+=1,U>10)break;B=k/N,O=new c.a1(_.x+w*B,_.y+S*B),N=1/O.meterInMercatorCoordinateUnits()}while(Math.abs(k-B*N)>1e-12);return{center:O.toLngLat(),elevation:P,zoom:c.ak(this.height/2/Math.tan(this.fovInRadians/2)/B/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const n=c.aj(1,this.center.lat)*this.worldSize,a=this.cameraToCenterDistance/n,l=c.a1.fromLngLat(this.center,this.elevation),u=le(this.center,this.elevation,this.pitch,this.bearing,a);this._elevation=e;const f=this.calculateCenterFromCameraLngLatAlt(u.toLngLat(),c.aQ(u.z,l.y),this.bearing,this.pitch);this._elevation=f.elevation,this._center=f.center,this.setZoom(f.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new c.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=c.aj(1,this.center.lat)*this.worldSize;return le(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const n=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/n,e.canonical.y/n,1/n/c.$,1/n/c.$]}}class ti{constructor(e,n){this.min=e,this.max=n,this.center=c.aR([],c.aS([],this.min,this.max),.5)}quadrant(e){const n=[e%2==0,e<2],a=c.aT(this.min),l=c.aT(this.max);for(let u=0;u<n.length;u++)a[u]=n[u]?this.min[u]:this.center[u],l[u]=n[u]?this.center[u]:this.max[u];return l[2]=this.max[2],new ti(a,l)}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]}intersectsFrustum(e){let n=!0;for(let a=0;a<e.planes.length;a++){const l=this.intersectsPlane(e.planes[a]);if(l===0)return 0;l===1&&(n=!1)}return n?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let n=e[3],a=e[3];for(let l=0;l<3;l++)e[l]>0?(n+=e[l]*this.min[l],a+=e[l]*this.max[l]):(a+=e[l]*this.min[l],n+=e[l]*this.max[l]);return n>=0?2:a<0?0:1}}class wi{distanceToTile2d(e,n,a,l){const u=l.distanceX([e,n]),f=l.distanceY([e,n]);return Math.hypot(u,f)}getWrap(e,n,a){return a}getTileBoundingVolume(e,n,a,l){var u,f;let _=0,y=0;if(l!=null&&l.terrain){const w=new c.Z(e.z,n,e.z,e.x,e.y),S=l.terrain.getMinMaxElevation(w);_=(u=S.minElevation)!==null&&u!==void 0?u:Math.min(0,a),y=(f=S.maxElevation)!==null&&f!==void 0?f:Math.max(0,a)}const b=1<<e.z;return new ti([n+e.x/b,e.y/b,_],[n+(e.x+1)/b,(e.y+1)/b,y])}allowVariableZoom(e,n){const a=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,l=c.ah(78.5-a/2,0,60);return!!n.terrain||e.pitch>l}allowWorldCopies(){return!0}prepareNextFrame(){}}class $t{constructor(e,n,a){this.points=e,this.planes=n,this.aabb=a}static fromInvProjectionMatrix(e,n=1,a=0,l,u){const f=u?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],_=Math.pow(2,a),y=[[-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(P=>function(I,k,O,B){const N=c.aw([],I,k),U=1/N[3]/O*B;return c.aY(N,N,[U,U,1/N[3],U])}(P,e,n,_));l&&function(P,I,k,O){const B=O?4:0,N=O?0:4;let U=0;const q=[],$=[];for(let G=0;G<4;G++){const te=c.aU([],P[G+N],P[G+B]),ue=c.aZ(te);c.aR(te,te,1/ue),q.push(ue),$.push(te)}for(let G=0;G<4;G++){const te=c.a_(P[G+B],$[G],k);U=te!==null&&te>=0?Math.max(U,te):Math.max(U,q[G])}const H=function(G,te){const ue=c.aU([],G[te[0]],G[te[1]]),ae=c.aU([],G[te[2]],G[te[1]]),oe=[0,0,0,0];return c.aV(oe,c.aW([],ue,ae)),oe[3]=-c.aX(oe,G[te[0]]),oe}(P,I),K=function(G,te){const ue=c.a$(G),ae=c.b0([],G,1/ue),oe=c.aU([],te,c.aR([],ae,c.aX(te,ae))),he=c.a$(oe);if(he>0){const we=Math.sqrt(1-ae[3]*ae[3]),Se=c.aR([],ae,-ae[3]),ye=c.aS([],Se,c.aR([],oe,we/he));return c.b1(te,ye)}return null}(k,H);if(K!==null){const G=K/c.aX($[0],H);U=Math.min(U,G)}for(let G=0;G<4;G++){const te=Math.min(U,q[G]);P[G+N]=[P[G+B][0]+$[G][0]*te,P[G+B][1]+$[G][1]*te,P[G+B][2]+$[G][2]*te,1]}}(y,f[0],l,u);const b=f.map(P=>{const I=c.aU([],y[P[0]],y[P[1]]),k=c.aU([],y[P[2]],y[P[1]]),O=c.aV([],c.aW([],I,k)),B=-c.aX(O,y[P[1]]);return O.concat(B)}),w=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],S=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const P of y)for(let I=0;I<3;I++)w[I]=Math.min(w[I],P[I]),S[I]=Math.max(S[I],P[I]);return new $t(y,b,new ti(w,S))}}class bt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,a){return this._helper.interpolatePadding(e,n,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n,a=!0){this._helper.resize(e,n,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,n){}constructor(e,n,a,l,u){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new bi({calcMatrices:()=>{this._calcMatrices()},getConstrained:(f,_)=>this.getConstrained(f,_)},e,n,a,l,u),this._coveringTilesDetailsProvider=new wi}clone(){const e=new bt;return e.apply(this),e}apply(e,n,a){this._helper.apply(e,n,a)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const n=[new c.b2(0,e)];if(this._helper._renderWorldCopies){const a=this.screenPointToMercatorCoordinate(new c.P(0,0)),l=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,0)),u=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,this._helper._height)),f=this.screenPointToMercatorCoordinate(new c.P(0,this._helper._height)),_=Math.floor(Math.min(a.x,l.x,u.x,f.x)),y=Math.floor(Math.max(a.x,l.x,u.x,f.x)),b=1;for(let w=_-b;w<=y+b;w++)w!==0&&n.push(new c.b2(w,e))}return n}getCameraFrustum(){return $t.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const n=this.screenPointToLocation(this.centerPoint,e),a=e?e.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(a)}setLocationAtPoint(e,n){const a=c.aj(this.elevation,this.center.lat),l=this.screenPointToMercatorCoordinateAtZ(n,a),u=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,a),f=c.a1.fromLngLat(e),_=new c.a1(f.x-(l.x-u.x),f.y-(l.y-u.y));this.setCenter(_==null?void 0:_.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,n){return n?this.coordinatePoint(c.a1.fromLngLat(e),n.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(c.a1.fromLngLat(e))}screenPointToLocation(e,n){var a;return(a=this.screenPointToMercatorCoordinate(e,n))===null||a===void 0?void 0:a.toLngLat()}screenPointToMercatorCoordinate(e,n){if(n){const a=n.pointCoordinate(e);if(a!=null)return a}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,n){const a=n||0,l=[e.x,e.y,0,1],u=[e.x,e.y,1,1];c.aw(l,l,this._pixelMatrixInverse),c.aw(u,u,this._pixelMatrixInverse);const f=l[3],_=u[3],y=l[1]/f,b=u[1]/_,w=l[2]/f,S=u[2]/_,P=w===S?0:(a-w)/(S-w);return new c.a1(c.C.number(l[0]/f,u[0]/_,P)/this.worldSize,c.C.number(y,b,P)/this.worldSize,a)}coordinatePoint(e,n=0,a=this._pixelMatrix){const l=[e.x*this.worldSize,e.y*this.worldSize,n,1];return c.aw(l,l,a),new c.P(l[0]/l[3],l[1]/l[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Y(this));return new Dt().extend(this.screenPointToLocation(new c.P(0,e))).extend(this.screenPointToLocation(new c.P(this._helper._width,e))).extend(this.screenPointToLocation(new c.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new c.P(0,this._helper._height)))}isPointOnMapSurface(e,n){return n?n.pointCoordinate(e)!=null:e.y>this.height/2-Y(this)}calculatePosMatrix(e,n=!1,a){var l;const u=(l=e.key)!==null&&l!==void 0?l:c.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),f=n?this._alignedPosMatrixCache:this._posMatrixCache;if(f.has(u)){const b=f.get(u);return a?b.f32:b.f64}const _=ie(e,this.worldSize);c.O(_,n?this._alignedProjMatrix:this._viewProjMatrix,_);const y={f64:_,f32:new Float32Array(_)};return f.set(u,y),a?y.f32:y.f64}calculateFogMatrix(e){const n=e.key,a=this._fogMatrixCacheF32;if(a.has(n))return a.get(n);const l=ie(e,this.worldSize);return c.O(l,this._fogMatrix,l),a.set(n,new Float32Array(l)),a.get(n)}getConstrained(e,n){n=c.ah(+n,this.minZoom,this.maxZoom);const a={center:new c.S(e.lng,e.lat),zoom:n};let l=this._helper._lngRange;!this._helper._renderWorldCopies&&l===null&&(l=[-179.9999999999,179.9999999999]);const u=this.tileSize*c.af(a.zoom);let f=0,_=u,y=0,b=u,w=0,S=0;const{x:P,y:I}=this.size;if(this._helper._latRange){const q=this._helper._latRange;f=c.U(q[1])*u,_=c.U(q[0])*u,_-f<I&&(w=I/(_-f))}l&&(y=c.aO(c.V(l[0])*u,0,u),b=c.aO(c.V(l[1])*u,0,u),b<y&&(b+=u),b-y<P&&(S=P/(b-y)));const{x:k,y:O}=R(u,e);let B,N;const U=Math.max(S||0,w||0);if(U){const q=new c.P(S?(b+y)/2:k,w?(_+f)/2:O);return a.center=Z(u,q).wrap(),a.zoom+=c.ak(U),a}if(this._helper._latRange){const q=I/2;O-q<f&&(N=f+q),O+q>_&&(N=_-q)}if(l){const q=(y+b)/2;let $=k;this._helper._renderWorldCopies&&($=c.aO(k,q-u/2,q+u/2));const H=P/2;$-H<y&&(B=y+H),$+H>b&&(B=b-H)}if(B!==void 0||N!==void 0){const q=new c.P(B??k,N??O);a.center=Z(u,q).wrap()}return a}calculateCenterFromCameraLngLatAlt(e,n,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,a,l)}_calculateNearFarZIfNeeded(e,n,a){if(!this._helper.autoCalculateNearFarZ)return;const l=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),u=e-l*this._helper._pixelPerMeter/Math.cos(n),f=l<0?u:e,_=Math.PI/2+this.pitchInRadians,y=c.ae(this.fov)*(Math.abs(Math.cos(c.ae(this.roll)))*this.height+Math.abs(Math.sin(c.ae(this.roll)))*this.width)/this.height*(.5+a.y/this.height),b=Math.sin(y)*f/Math.sin(c.ah(Math.PI-_-y,.01,Math.PI-.01)),w=Y(this),S=Math.atan(w/this._helper.cameraToCenterDistance),P=c.ae(.75),I=S>P?2*S*(.5+a.y/(2*w)):P,k=Math.sin(I)*f/Math.sin(c.ah(Math.PI-_-I,.01,Math.PI-.01)),O=Math.min(b,k);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*O+f),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,n=R(this.worldSize,this.center),a=n.x,l=n.y;this._helper._pixelPerMeter=c.aj(1,this.center.lat)*this.worldSize;const u=c.ae(Math.min(this.pitch,D)),f=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(u));let _;this._calculateNearFarZIfNeeded(f,u,e),_=new Float64Array(16),c.b4(_,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),c.aq(this._invProjMatrix,_),_[8]=2*-e.x/this._helper._width,_[9]=2*e.y/this._helper._height,this._projectionMatrix=c.b5(_),c.N(_,_,[1,-1,1]),c.M(_,_,[0,0,-this._helper.cameraToCenterDistance]),c.b6(_,_,-this.rollInRadians),c.b7(_,_,this.pitchInRadians),c.b6(_,_,-this.bearingInRadians),c.M(_,_,[-a,-l,0]),this._mercatorMatrix=c.N([],_,[this.worldSize,this.worldSize,this.worldSize]),c.N(_,_,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=c.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,_),c.M(_,_,[0,0,-this.elevation]),this._viewProjMatrix=_,this._invViewProjMatrix=c.aq([],_);const y=[0,0,-1,1];c.aw(y,y,this._invViewProjMatrix),this._cameraPosition=[y[0]/y[3],y[1]/y[3],y[2]/y[3]],this._fogMatrix=new Float64Array(16),c.b4(this._fogMatrix,this.fovInRadians,this.width/this.height,f,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,c.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),c.M(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),c.b6(this._fogMatrix,this._fogMatrix,-this.rollInRadians),c.b7(this._fogMatrix,this._fogMatrix,this.pitchInRadians),c.b6(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),c.M(this._fogMatrix,this._fogMatrix,[-a,-l,0]),c.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),c.M(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=c.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,_);const b=this._helper._width%2/2,w=this._helper._height%2/2,S=Math.cos(this.bearingInRadians),P=Math.sin(-this.bearingInRadians),I=a-Math.round(a)+S*b+P*w,k=l-Math.round(l)+S*w+P*b,O=new Float64Array(_);if(c.M(O,O,[I>.5?I-1:I,k>.5?k-1:k,0]),this._alignedProjMatrix=O,_=c.aq(new Float64Array(16),this._pixelMatrix),!_)throw new Error("failed to invert matrix");this._pixelMatrixInverse=_,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new c.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return c.aw(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=c.aj(1,this.center.lat)*this.worldSize;return le(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,n){const a=c.a1.fromLngLat(e),l=[a.x*this.worldSize,a.y*this.worldSize,n,1];return c.aw(l,l,this._viewProjMatrix),l[2]/l[3]}getProjectionData(e){const{overscaledTileID:n,aligned:a,applyTerrainMatrix:l}=e,u=this._helper.getMercatorTileCoordinates(n),f=n?this.calculatePosMatrix(n,a,!0):null;let _;return _=n&&n.terrainRttPosMatrix32f&&l?n.terrainRttPosMatrix32f:f||c.b8(),{mainMatrix:_,tileMercatorCoords:u,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:_}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,n,a){return 1}transformLightDirection(e){return c.aT(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,n,a,l){const u=this.calculatePosMatrix(a);let f;l?(f=[e,n,l(e,n),1],c.aw(f,f,u)):(f=[e,n,0,1],qn(f,f,u));const _=f[3];return{point:new c.P(f[0]/_,f[1]/_),signedDistanceFromCamera:_,isOccluded:!1}}populateCache(e){for(const n of e)this.calculatePosMatrix(n)}getMatrixForModel(e,n){const a=c.a1.fromLngLat(e,n),l=a.meterInMercatorCoordinateUnits(),u=c.b9();return c.M(u,u,[a.x,a.y,a.z]),c.b6(u,u,Math.PI),c.b7(u,u,Math.PI/2),c.N(u,u,[-l,l,l]),u}getProjectionDataForCustomLayer(e=!0){const n=new c.Z(0,0,0,0,0),a=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:e}),l=ie(n,this.worldSize);c.O(l,this._viewProjMatrix,l),a.tileMercatorCoords=[0,0,1,1];const u=[c.$,c.$,this.worldSize/this._helper.pixelsPerMeter],f=c.ba();return c.N(f,l,u),a.fallbackMatrix=f,a.mainMatrix=f,a}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Al(){c.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Ti(h){if(h.useSlerp)if(h.k<1){const e=c.bb(h.startEulerAngles.roll,h.startEulerAngles.pitch,h.startEulerAngles.bearing),n=c.bb(h.endEulerAngles.roll,h.endEulerAngles.pitch,h.endEulerAngles.bearing),a=new Float64Array(4);c.bc(a,e,n,h.k);const l=c.bd(a);h.tr.setRoll(l.roll),h.tr.setPitch(l.pitch),h.tr.setBearing(l.bearing)}else h.tr.setRoll(h.endEulerAngles.roll),h.tr.setPitch(h.endEulerAngles.pitch),h.tr.setBearing(h.endEulerAngles.bearing);else h.tr.setRoll(c.C.number(h.startEulerAngles.roll,h.endEulerAngles.roll,h.k)),h.tr.setPitch(c.C.number(h.startEulerAngles.pitch,h.endEulerAngles.pitch,h.k)),h.tr.setBearing(c.C.number(h.startEulerAngles.bearing,h.endEulerAngles.bearing,h.k))}function Bi(h,e,n,a,l){const u=l.padding,f=R(l.worldSize,n.getNorthWest()),_=R(l.worldSize,n.getNorthEast()),y=R(l.worldSize,n.getSouthEast()),b=R(l.worldSize,n.getSouthWest()),w=c.ae(-a),S=f.rotate(w),P=_.rotate(w),I=y.rotate(w),k=b.rotate(w),O=new c.P(Math.max(S.x,P.x,k.x,I.x),Math.max(S.y,P.y,k.y,I.y)),B=new c.P(Math.min(S.x,P.x,k.x,I.x),Math.min(S.y,P.y,k.y,I.y)),N=O.sub(B),U=(l.width-(u.left+u.right+e.left+e.right))/N.x,q=(l.height-(u.top+u.bottom+e.top+e.bottom))/N.y;if(q<0||U<0)return void Al();const $=Math.min(c.ak(l.scale*Math.min(U,q)),h.maxZoom),H=c.P.convert(h.offset),K=new c.P((e.left-e.right)/2,(e.top-e.bottom)/2).rotate(c.ae(a)),G=H.add(K).mult(l.scale/c.af($));return{center:Z(l.worldSize,f.add(y).div(2).sub(G)),zoom:$,bearing:a}}class _i{get useGlobeControls(){return!1}handlePanInertia(e,n){const a=e.mag(),l=Math.abs(Y(n));return{easingOffset:e.mult(Math.min(.75*l/a,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(e,n){e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta),e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta)}handleMapControlsPan(e,n,a){e.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(a,e.around)}cameraForBoxAndBearing(e,n,a,l,u){return Bi(e,n,a,l,u)}handleJumpToCenterZoom(e,n){e.zoom!==(n.zoom!==void 0?+n.zoom:e.zoom)&&e.setZoom(+n.zoom),n.center!==void 0&&e.setCenter(c.S.convert(n.center))}handleEaseTo(e,n){const a=e.zoom,l=e.padding,u={roll:e.roll,pitch:e.pitch,bearing:e.bearing},f={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},_=n.zoom!==void 0,y=!e.isPaddingEqual(n.padding);let b=!1;const w=_?+n.zoom:e.zoom;let S=e.centerPoint.add(n.offsetAsPoint);const P=e.screenPointToLocation(S),{center:I,zoom:k}=e.getConstrained(c.S.convert(n.center||P),w??a);da(e,I);const O=R(e.worldSize,P),B=R(e.worldSize,I).sub(O),N=c.af(k-a);return b=k!==a,{easeFunc:U=>{if(b&&e.setZoom(c.C.number(a,k,U)),c.be(u,f)||Ti({startEulerAngles:u,endEulerAngles:f,tr:e,k:U,useSlerp:u.roll!=f.roll}),y&&(e.interpolatePadding(l,n.padding,U),S=e.centerPoint.add(n.offsetAsPoint)),n.around)e.setLocationAtPoint(n.around,n.aroundPoint);else{const q=c.af(e.zoom-a),$=k>a?Math.min(2,N):Math.max(.5,N),H=Math.pow($,1-U),K=Z(e.worldSize,O.add(B.mult(U*H)).mult(q));e.setLocationAtPoint(e.renderWorldCopies?K.wrap():K,S)}},isZooming:b,elevationCenter:I}}handleFlyTo(e,n){const a=n.zoom!==void 0,l=e.zoom,u=e.getConstrained(c.S.convert(n.center||n.locationAtOffset),a?+n.zoom:l),f=u.center,_=u.zoom;da(e,f);const y=R(e.worldSize,n.locationAtOffset),b=R(e.worldSize,f).sub(y),w=b.mag(),S=c.af(_-l);let P;if(n.minZoom!==void 0){const I=Math.min(+n.minZoom,l,_),k=e.getConstrained(f,I).zoom;P=c.af(k-l)}return{easeFunc:(I,k,O,B)=>{e.setZoom(I===1?_:l+c.ak(k));const N=I===1?f:Z(e.worldSize,y.add(b.mult(O)).mult(k));e.setLocationAtPoint(e.renderWorldCopies?N.wrap():N,B)},scaleOfZoom:S,targetCenter:f,scaleOfMinZoom:P,pixelPathLength:w}}}class Pt{constructor(e,n,a){this.blendFunction=e,this.blendColor=n,this.mask=a}}Pt.Replace=[1,0],Pt.disabled=new Pt(Pt.Replace,c.bf.transparent,[!1,!1,!1,!1]),Pt.unblended=new Pt(Pt.Replace,c.bf.transparent,[!0,!0,!0,!0]),Pt.alphaBlended=new Pt([1,771],c.bf.transparent,[!0,!0,!0,!0]);const bn=2305;class Ue{constructor(e,n,a){this.enable=e,this.mode=n,this.frontFace=a}}Ue.disabled=new Ue(!1,1029,bn),Ue.backCCW=new Ue(!0,1029,bn),Ue.frontCCW=new Ue(!0,1028,bn);class We{constructor(e,n,a){this.func=e,this.mask=n,this.range=a}}We.ReadOnly=!1,We.ReadWrite=!0,We.disabled=new We(519,We.ReadOnly,[0,1]);const Ir=7680;class lt{constructor(e,n,a,l,u,f){this.test=e,this.ref=n,this.mask=a,this.fail=l,this.depthFail=u,this.pass=f}}lt.disabled=new lt({func:519,mask:0},0,0,Ir,Ir,Ir);const Oi=new WeakMap;function vr(h){var e;if(Oi.has(h))return Oi.get(h);{const n=(e=h.getParameter(h.VERSION))===null||e===void 0?void 0:e.startsWith("WebGL 2.0");return Oi.set(h,n),n}}class br{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const n=e.context,a=n.gl;this._texFormat=a.RGBA,this._texType=a.UNSIGNED_BYTE;const l=new c.aL;l.emplaceBack(-1,-1),l.emplaceBack(2,-1),l.emplaceBack(-1,2);const u=new c.aN;u.emplaceBack(0,1,2),this._fullscreenTriangle=new yn(n.createVertexBuffer(l,Kr.members),n.createIndexBuffer(u),c.aM.simpleSegment(0,0,l.length,u.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(a.TEXTURE1);const f=a.createTexture();a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texImage2D(a.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(f),vr(a)&&(this._pbo=a.createBuffer(),a.bindBuffer(a.PIXEL_PACK_BUFFER,this._pbo),a.bufferData(a.PIXEL_PACK_BUFFER,4,a.STREAM_READ),a.bindBuffer(a.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,n){const a=this._updateCount;return this._readbackQueue?a>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():a>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,n),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,n=e.gl;e.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,n){const a=this._cachedRenderContext.context,l=a.gl;if(this._bindFramebuffer(),a.viewport.set([0,0,this._texWidth,this._texHeight]),a.clear({color:c.bf.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(a,l.TRIANGLES,We.disabled,lt.disabled,Pt.unblended,Ue.disabled,((u,f)=>({u_input:u,u_output_expected:f}))(e,n),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&vr(l)){l.bindBuffer(l.PIXEL_PACK_BUFFER,this._pbo),l.readBuffer(l.COLOR_ATTACHMENT0),l.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null);const u=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);l.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:u}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&vr(e)){const n=e.clientWaitSync(this._readbackQueue.sync,0,0);if(n===e.WAIT_FAILED)return c.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=br._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let n=0;return n+=e[0]/256,n+=e[1]/65536,n+=e[2]/16777216,e[3]<127&&(n=-n),n/128}}const fa=c.$/128;function xo(h,e){const n=h.granularity!==void 0?Math.max(h.granularity,1):1,a=n+(h.generateBorders?2:0),l=n+(h.extendToNorthPole||h.generateBorders?1:0)+(h.extendToSouthPole||h.generateBorders?1:0),u=a+1,f=l+1,_=h.generateBorders?-1:0,y=h.generateBorders||h.extendToNorthPole?-1:0,b=n+(h.generateBorders?1:0),w=n+(h.generateBorders||h.extendToSouthPole?1:0),S=u*f,P=a*l*6,I=u*f>65536;if(I&&e==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const k=I||e==="32bit",O=new Int16Array(2*S);let B=0;for(let q=y;q<=w;q++)for(let $=_;$<=b;$++){let H=$/n*c.$;$===-1&&(H=-fa),$===n+1&&(H=c.$+fa);let K=q/n*c.$;q===-1&&(K=h.extendToNorthPole?c.bh:-fa),q===n+1&&(K=h.extendToSouthPole?c.bi:c.$+fa),O[B++]=H,O[B++]=K}const N=k?new Uint32Array(P):new Uint16Array(P);let U=0;for(let q=0;q<l;q++)for(let $=0;$<a;$++){const H=$+1+q*u,K=$+(q+1)*u,G=$+1+(q+1)*u;N[U++]=$+q*u,N[U++]=K,N[U++]=H,N[U++]=H,N[U++]=K,N[U++]=G}return{vertices:O.buffer.slice(0),indices:N.buffer.slice(0),uses32bitIndices:k}}const Kn=new c.aK({fill:new c.bj(128,2),line:new c.bj(512,0),tile:new c.bj(128,32),stencil:new c.bj(128,1),circle:3});class Is{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Ji.projectionGlobe}get vertexShaderPreludeCode(){return Ji.projectionMercator.vertexSource}get subdivisionGranularity(){return Kn}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new br(e));const n=c.U(this._errorQueryLatitudeDegrees),a=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,l=this._errorMeasurement.updateErrorLoop(n,a),u=Ee.now();l!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=l,this._errorMeasurementLastChangeTime=u);const f=Math.min(Math.max((u-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=c.bk(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,c.bl(f))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,n,a,l,u){const f=(u==="stencil"?Kn.stencil:Kn.tile).getGranularityForZoomLevel(n.z);return this._getMesh(e,{granularity:f,generateBorders:a,extendToNorthPole:n.y===0&&l,extendToSouthPole:n.y===(1<<n.z)-1&&l})}_getMesh(e,n){const a=this._getMeshKey(n);if(a in this._tileMeshCache)return this._tileMeshCache[a];const l=function(u,f){const _=xo(f,"16bit"),y=c.aL.deserialize({arrayBuffer:_.vertices,length:_.vertices.byteLength/2/2}),b=c.aN.deserialize({arrayBuffer:_.indices,length:_.indices.byteLength/2/3});return new yn(u.createVertexBuffer(y,Kr.members),u.createIndexBuffer(b),c.aM.simpleSegment(0,0,y.length,b.length))}(e,n);return this._tileMeshCache[a]=l,l}recalculate(e){}hasTransition(){const e=Ee.now();let n=!1;return n=n||(e-this._errorMeasurementLastChangeTime)/1e3<.7,n=n||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,n}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const ma=new c.r({type:new c.D(c.v.projection.type)});class ga extends c.E{constructor(e){super(),this._transitionable=new c.t(ma),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.F(0)),this._mercatorProjection=new it,this._verticalPerspectiveProjection=new Is}get transitionState(){const e=this.properties.get("type");if(typeof e=="string"&&e==="mercator")return 0;if(typeof e=="string"&&e==="vertical-perspective")return 1;if(e instanceof c.bm){if(e.from==="vertical-perspective"&&e.to==="mercator")return 1-e.transition;if(e.from==="mercator"&&e.to==="vertical-perspective")return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,n,a,l,u){return this.currentProjection.getMeshFromTileID(e,n,a,l,u)}setProjection(e){this._transitionable.setValue("type",(e==null?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function _a(h){const e=Jn(h.worldSize,h.center.lat);return 2*Math.PI*e}function Qi(h,e,n,a,l){const u=1/(1<<l),f=e/c.$*u+a*u,_=c.bo((h/c.$*u+n*u)*Math.PI*2+Math.PI,2*Math.PI),y=2*Math.atan(Math.exp(Math.PI-f*Math.PI*2))-.5*Math.PI,b=Math.cos(y),w=new Float64Array(3);return w[0]=Math.sin(_)*b,w[1]=Math.sin(y),w[2]=Math.cos(_)*b,w}function ii(h){return function(e,n){const a=Math.cos(n),l=new Float64Array(3);return l[0]=Math.sin(e)*a,l[1]=Math.sin(n),l[2]=Math.cos(e)*a,l}(h.lng*Math.PI/180,h.lat*Math.PI/180)}function Jn(h,e){return h/(2*Math.PI)/Math.cos(e*Math.PI/180)}function Cs(h){const e=Math.asin(h[1])/Math.PI*180,n=Math.sqrt(h[0]*h[0]+h[2]*h[2]);if(n>1e-6){const a=h[0]/n,l=Math.acos(h[2]/n),u=(a>0?l:-l)/Math.PI*180;return new c.S(c.aO(u,-180,180),e)}return new c.S(0,e)}function wn(h){return Math.cos(h*Math.PI/180)}function Ft(h,e){const n=wn(h),a=wn(e);return c.ak(a/n)}function kl(h,e){const n=h.rotate(e.bearingInRadians),a=e.zoom+Ft(e.center.lat,0),l=c.bk(1/wn(e.center.lat),1/wn(Math.min(Math.abs(e.center.lat),60)),c.bn(a,7,3,0,1)),u=360/_a({worldSize:e.worldSize,center:{lat:e.center.lat}});return new c.S(e.center.lng-n.x*u*l,c.ah(e.center.lat+n.y*u,-c.ai,c.ai))}function Es(h){const e=.5*h,n=Math.sin(e),a=Math.cos(e);return Math.log(n+a)-Math.log(a-n)}function vo(h,e,n,a){const l=h.lat+n*a;if(Math.abs(n)>1){const u=(Math.sign(h.lat+n)!==Math.sign(h.lat)?-Math.abs(h.lat):Math.abs(h.lat))*Math.PI/180,f=Math.abs(h.lat+n)*Math.PI/180,_=Es(u+a*(f-u)),y=Es(u),b=Es(f);return new c.S(h.lng+e*((_-y)/(b-y)),l)}return new c.S(h.lng+e*a,l)}class Hc{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,n,a,l){const u=`${e.z}_${e.x}_${e.y}_${l!=null&&l.terrain?"t":""}`,f=this._cache.get(u);if(f)return f;const _=this._cachePrevious.get(u);if(_)return this._cache.set(u,_),_;const y=this._boundingVolumeFactory(e,n,a,l);return this._cache.set(u,y),this._hadAnyChanges=!0,y}}class Qn{constructor(e,n,a,l){this.min=a,this.max=l,this.points=e,this.planes=n}static fromAabb(e,n){const a=[];for(let l=0;l<8;l++)a.push([1&~l?e[0]:n[0],(l>>1&1)==1?n[1]:e[1],(l>>2&1)==1?n[2]:e[2]]);return new Qn(a,[[-1,0,0,n[0]],[1,0,0,-e[0]],[0,-1,0,n[1]],[0,1,0,-e[1]],[0,0,-1,n[2]],[0,0,1,-e[2]]],e,n)}static fromCenterSizeAngles(e,n,a){const l=c.br([],a[0],a[1],a[2]),u=c.bs([],[n[0],0,0],l),f=c.bs([],[0,n[1],0],l),_=c.bs([],[0,0,n[2]],l),y=[...e],b=[...e];for(let S=0;S<8;S++)for(let P=0;P<3;P++){const I=e[P]+u[P]*(1&~S?-1:1)+f[P]*((S>>1&1)==1?1:-1)+_[P]*((S>>2&1)==1?1:-1);y[P]=Math.min(y[P],I),b[P]=Math.max(b[P],I)}const w=[];for(let S=0;S<8;S++){const P=[...e];c.aS(P,P,c.aR([],u,1&~S?-1:1)),c.aS(P,P,c.aR([],f,(S>>1&1)==1?1:-1)),c.aS(P,P,c.aR([],_,(S>>2&1)==1?1:-1)),w.push(P)}return new Qn(w,[[...u,-c.aX(u,w[0])],[...f,-c.aX(f,w[0])],[..._,-c.aX(_,w[0])],[-u[0],-u[1],-u[2],-c.aX(u,w[7])],[-f[0],-f[1],-f[2],-c.aX(f,w[7])],[-_[0],-_[1],-_[2],-c.aX(_,w[7])]],y,b)}intersectsFrustum(e){let n=!0;const a=this.points.length,l=this.planes.length,u=e.planes.length,f=e.points.length;for(let _=0;_<u;_++){const y=e.planes[_];let b=0;for(let w=0;w<a;w++){const S=this.points[w];y[0]*S[0]+y[1]*S[1]+y[2]*S[2]+y[3]>=0&&b++}if(b===0)return 0;b<a&&(n=!1)}if(n)return 2;for(let _=0;_<l;_++){const y=this.planes[_];let b=0;for(let w=0;w<f;w++){const S=e.points[w];y[0]*S[0]+y[1]*S[1]+y[2]*S[2]+y[3]>=0&&b++}if(b===0)return 0}return 1}intersectsPlane(e){const n=this.points.length;let a=0;for(let l=0;l<n;l++){const u=this.points[l];e[0]*u[0]+e[1]*u[1]+e[2]*u[2]+e[3]>=0&&a++}return a===n?2:a===0?0:1}}function ui(h,e,n){const a=h-e;return a<0?-a:Math.max(0,a-n)}function As(h,e,n,a,l){const u=h-n;let f;return f=u<0?Math.min(-u,1+u-l):u>1?Math.min(Math.max(u-l,0),1-u):0,Math.max(f,ui(e,a,l))}class wr{constructor(){this._boundingVolumeCache=new Hc(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,n,a,l){const u=1<<a.z,f=1/u,_=a.x/u,y=a.y/u;let b=2;return b=Math.min(b,As(e,n,_,y,f)),b=Math.min(b,As(e,n,_+.5,-y-f,f)),b=Math.min(b,As(e,n,_+.5,2-y-f,f)),b}getWrap(e,n,a){const l=1<<n.z,u=1/l,f=n.x/l,_=ui(e.x,f,u),y=ui(e.x,f-1,u),b=ui(e.x,f+1,u),w=Math.min(_,y,b);return w===b?1:w===y?-1:0}allowVariableZoom(e,n){return Re(e,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,n,a,l){return this._boundingVolumeCache.getTileBoundingVolume(e,n,a,l)}_computeTileBoundingVolume(e,n,a,l){var u,f;let _=0,y=0;if(l!=null&&l.terrain){const b=new c.Z(e.z,n,e.z,e.x,e.y),w=l.terrain.getMinMaxElevation(b);_=(u=w.minElevation)!==null&&u!==void 0?u:Math.min(0,a),y=(f=w.maxElevation)!==null&&f!==void 0?f:Math.max(0,a)}if(_/=c.bu,y/=c.bu,_+=1,y+=1,e.z<=0)return Qn.fromAabb([-y,-y,-y],[y,y,y]);if(e.z===1)return Qn.fromAabb([e.x===0?-y:0,e.y===0?0:-y,-y],[e.x===0?0:y,e.y===0?y:0,y]);{const b=[Qi(0,0,e.x,e.y,e.z),Qi(c.$,0,e.x,e.y,e.z),Qi(c.$,c.$,e.x,e.y,e.z),Qi(0,c.$,e.x,e.y,e.z)],w=[];for(const oe of b)w.push(c.aR([],oe,y));if(y!==_)for(const oe of b)w.push(c.aR([],oe,_));e.y===0&&w.push([0,1,0]),e.y===(1<<e.z)-1&&w.push([0,-1,0]);const S=[1,1,1],P=[-1,-1,-1];for(const oe of w)for(let he=0;he<3;he++)S[he]=Math.min(S[he],oe[he]),P[he]=Math.max(P[he],oe[he]);const I=Qi(c.$/2,c.$/2,e.x,e.y,e.z),k=c.aW([],[0,1,0],I);c.aV(k,k);const O=c.aW([],I,k);c.aV(O,O);const B=c.aW([],b[2],b[1]);c.aV(B,B);const N=c.aW([],b[0],b[3]);c.aV(N,N),w.push(c.aR([],I,y)),e.y>=(1<<e.z)/2&&w.push(c.aR([],Qi(c.$/2,0,e.x,e.y,e.z),y)),e.y<(1<<e.z)/2&&w.push(c.aR([],Qi(c.$/2,c.$,e.x,e.y,e.z),y));const U=ks(I,w),q=ks(O,w),$=[-I[0],-I[1],-I[2],U.max],H=[I[0],I[1],I[2],-U.min],K=[-O[0],-O[1],-O[2],q.max],G=[O[0],O[1],O[2],-q.min],te=[...B,0],ue=[...N,0],ae=[];return e.y===0?ae.push(c.bt(ue,te,$),c.bt(ue,te,H)):ae.push(c.bt(K,te,$),c.bt(K,te,H),c.bt(K,ue,$),c.bt(K,ue,H)),e.y===(1<<e.z)-1?ae.push(c.bt(ue,te,$),c.bt(ue,te,H)):ae.push(c.bt(G,te,$),c.bt(G,te,H),c.bt(G,ue,$),c.bt(G,ue,H)),new Qn(ae,[$,H,K,G,te,ue],S,P)}}}function ks(h,e){let n=1/0,a=-1/0;for(const l of e){const u=c.aX(h,l);n=Math.min(n,u),a=Math.max(a,u)}return{min:n,max:a}}class zs{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,a){return this._helper.interpolatePadding(e,n,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n){this._helper.resize(e,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(){this._cachedClippingPlane=c.bv(),this._projectionMatrix=c.b9(),this._globeViewProjMatrix32f=c.b8(),this._globeViewProjMatrixNoCorrection=c.b9(),this._globeViewProjMatrixNoCorrectionInverted=c.b9(),this._globeProjMatrixInverted=c.b9(),this._cameraPosition=c.bp(),this._globeLatitudeErrorCorrectionRadians=0,this._helper=new bi({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,n)=>this.getConstrained(e,n)}),this._coveringTilesDetailsProvider=new wr}clone(){const e=new zs;return e.apply(this),e}apply(e,n){this._globeLatitudeErrorCorrectionRadians=n||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=c.bp();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:n,applyGlobeMatrix:a}=e,l=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:l,clippingPlane:this._cachedClippingPlane,projectionTransition:a?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const n=this.pitchInRadians,a=this.cameraToCenterDistance/e,l=Math.sin(n)*a,u=Math.cos(n)*a+1,f=1/Math.sqrt(l*l+u*u)*1;let _=-l,y=u;const b=Math.sqrt(_*_+y*y);_/=b,y/=b;const w=[0,_,y];c.bw(w,w,[0,0,0],-this.bearingInRadians),c.bx(w,w,[0,0,0],-1*this.center.lat*Math.PI/180),c.by(w,w,[0,0,0],this.center.lng*Math.PI/180);const S=1/c.aZ(w);return c.aR(w,w,S),[...w,-f*S]}isLocationOccluded(e){return!this.isSurfacePointVisible(ii(e))}transformLightDirection(e){const n=this._helper._center.lng*Math.PI/180,a=this._helper._center.lat*Math.PI/180,l=Math.cos(a),u=[Math.sin(n)*l,Math.sin(a),Math.cos(n)*l],f=[u[2],0,-u[0]],_=[0,0,0];c.aW(_,f,u),c.aV(f,f),c.aV(_,_);const y=[0,0,0];return c.aV(y,[f[0]*e[0]+_[0]*e[1]+u[0]*e[2],f[1]*e[0]+_[1]*e[1]+u[1]*e[2],f[2]*e[0]+_[2]*e[1]+u[2]*e[2]]),y}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,n,a){const l=function(_,y,b){const w=1/(1<<b.z);return new c.a1(_/c.$*w+b.x*w,y/c.$*w+b.y*w)}(e,n,a.canonical),u=(f=l.y,[c.bo(l.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-f*Math.PI*2))-.5*Math.PI]);var f;return this.getCircleRadiusCorrection()/Math.cos(u[1])}projectTileCoordinates(e,n,a,l){const u=a.canonical,f=Qi(e,n,u.x,u.y,u.z),_=1+(l?l(e,n):0)/c.bu,y=[f[0]*_,f[1]*_,f[2]*_,1];c.aw(y,y,this._globeViewProjMatrixNoCorrection);const b=this._cachedClippingPlane,w=b[0]*f[0]+b[1]*f[1]+b[2]*f[2]+b[3]<0;return{point:new c.P(y[0]/y[3],y[1]/y[3]),signedDistanceFromCamera:y[3],isOccluded:w}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=Jn(this.worldSize,this.center.lat),n=c.ba(),a=c.ba();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),c.b4(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const l=this.centerOffset;n[8]=2*-l.x/this._helper._width,n[9]=2*l.y/this._helper._height,this._projectionMatrix=c.b5(n),this._globeProjMatrixInverted=c.ba(),c.aq(this._globeProjMatrixInverted,n),c.M(n,n,[0,0,-this.cameraToCenterDistance]),c.b6(n,n,this.rollInRadians),c.b7(n,n,-this.pitchInRadians),c.b6(n,n,this.bearingInRadians),c.M(n,n,[0,0,-e]);const u=c.bp();u[0]=e,u[1]=e,u[2]=e,c.b7(a,n,this.center.lat*Math.PI/180),c.bz(a,a,-this.center.lng*Math.PI/180),c.N(a,a,u),this._globeViewProjMatrixNoCorrection=a,c.b7(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),c.bz(n,n,-this.center.lng*Math.PI/180),c.N(n,n,u),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=c.ba(),c.aq(this._globeViewProjMatrixNoCorrectionInverted,a);const f=c.bp();this._cameraPosition=c.bp(),this._cameraPosition[2]=this.cameraToCenterDistance/e,c.bw(this._cameraPosition,this._cameraPosition,f,-this.rollInRadians),c.bx(this._cameraPosition,this._cameraPosition,f,this.pitchInRadians),c.bw(this._cameraPosition,this._cameraPosition,f,-this.bearingInRadians),c.aS(this._cameraPosition,this._cameraPosition,[0,0,1]),c.bx(this._cameraPosition,this._cameraPosition,f,-this.center.lat*Math.PI/180),c.by(this._cameraPosition,this._cameraPosition,f,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const _=c.b5(this._globeViewProjMatrixNoCorrectionInverted);c.N(_,_,[1,1,-1]),this._cachedFrustum=$t.fromInvProjectionMatrix(_,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){c.w("calculateFogMatrix is not supported on globe projection.");const n=c.ba();return c.ag(n),n}getVisibleUnwrappedCoordinates(e){return[new c.b2(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&c.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){if(!this._globeViewProjMatrixNoCorrection)return 1;const a=ii(e);c.aR(a,a,1+n/c.bu);const l=c.bv();return c.aw(l,[a[0],a[1],a[2],1],this._globeViewProjMatrixNoCorrection),l[2]/l[3]}populateCache(e){}getBounds(){const e=.5*this.width,n=.5*this.height,a=[new c.P(0,0),new c.P(e,0),new c.P(this.width,0),new c.P(this.width,n),new c.P(this.width,this.height),new c.P(e,this.height),new c.P(0,this.height),new c.P(0,n)],l=[];for(const S of a)l.push(this.unprojectScreenPoint(S));let u=0,f=0,_=0,y=0;const b=this.center;for(const S of l){const P=c.bA(b.lng,S.lng),I=c.bA(b.lat,S.lat);P<f&&(f=P),P>u&&(u=P),I<y&&(y=I),I>_&&(_=I)}const w=[b.lng+f,b.lat+y,b.lng+u,b.lat+_];return this.isSurfacePointOnScreen([0,1,0])&&(w[3]=90,w[0]=-180,w[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(w[1]=-90,w[0]=-180,w[2]=180),new Dt(w)}getConstrained(e,n){const a=c.ah(e.lat,-c.ai,c.ai),l=c.ah(+n,this.minZoom+Ft(0,a),this.maxZoom);return{center:new c.S(e.lng,a),zoom:l}}calculateCenterFromCameraLngLatAlt(e,n,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,a,l)}setLocationAtPoint(e,n){const a=ii(this.unprojectScreenPoint(n)),l=ii(e),u=c.bp();c.bB(u);const f=c.bp();c.by(f,a,u,-this.center.lng*Math.PI/180),c.bx(f,f,u,this.center.lat*Math.PI/180);const _=l[0]*l[0]+l[2]*l[2],y=f[0]*f[0];if(_<y)return;const b=Math.sqrt(_-y),w=-b,S=c.bC(l[0],l[2],f[0],b),P=c.bC(l[0],l[2],f[0],w),I=c.bp();c.by(I,l,u,-S);const k=c.bC(I[1],I[2],f[1],f[2]),O=c.bp();c.by(O,l,u,-P);const B=c.bC(O[1],O[2],f[1],f[2]),N=.5*Math.PI,U=k>=-N&&k<=N,q=B>=-N&&B<=N;let $,H;if(U&&q){const ue=this.center.lng*Math.PI/180,ae=this.center.lat*Math.PI/180;c.bD(S,ue)+c.bD(k,ae)<c.bD(P,ue)+c.bD(B,ae)?($=S,H=k):($=P,H=B)}else if(U)$=S,H=k;else{if(!q)return;$=P,H=B}const K=$/Math.PI*180,G=H/Math.PI*180,te=this.center.lat;this.setCenter(new c.S(K,c.ah(G,-90,90))),this.setZoom(this.zoom+Ft(te,this.center.lat))}locationToScreenPoint(e,n){const a=ii(e);if(n){const l=n.getElevationForLngLatZoom(e,this._helper._tileZoom);c.aR(a,a,1+l/c.bu)}return this._projectSurfacePointToScreen(a)}_projectSurfacePointToScreen(e){const n=c.bv();return c.aw(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new c.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,n){if(n){const a=n.pointCoordinate(e);if(a)return a}return c.a1.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,n){var a;return(a=this.screenPointToMercatorCoordinate(e,n))===null||a===void 0?void 0:a.toLngLat()}isPointOnMapSurface(e,n){const a=this._cameraPosition,l=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(a,l)}getRayDirectionFromPixel(e){const n=c.bv();n[0]=e.x/this.width*2-1,n[1]=-1*(e.y/this.height*2-1),n[2]=1,n[3]=1,c.aw(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];const a=c.bp();a[0]=n[0]-this._cameraPosition[0],a[1]=n[1]-this._cameraPosition[1],a[2]=n[2]-this._cameraPosition[2];const l=c.bp();return c.aV(l,a),l}isSurfacePointVisible(e){const n=this._cachedClippingPlane;return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const n=c.bv();return c.aw(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(e,n){const a=c.aX(e,n),l=c.bp(),u=c.bp();c.aR(u,n,a),c.aU(l,e,u);const f=1-c.aX(l,l);if(f<0)return null;const _=c.aX(e,e)-1,y=-a+(a<0?1:-1)*Math.sqrt(f),b=_/y,w=y;return{tMin:Math.min(b,w),tMax:Math.max(b,w)}}unprojectScreenPoint(e){const n=this._cameraPosition,a=this.getRayDirectionFromPixel(e),l=this.rayPlanetIntersection(n,a);if(l){const w=c.bp();c.aS(w,n,[a[0]*l.tMin,a[1]*l.tMin,a[2]*l.tMin]);const S=c.bp();return c.aV(S,w),Cs(S)}const u=this._cachedClippingPlane,f=u[0]*a[0]+u[1]*a[1]+u[2]*a[2],_=-c.b1(u,n)/f,y=c.bp();if(_>0)c.aS(y,n,[a[0]*_,a[1]*_,a[2]*_]);else{const w=c.bp();c.aS(w,n,[2*a[0],2*a[1],2*a[2]]);const S=c.b1(this._cachedClippingPlane,w);c.aU(y,w,[this._cachedClippingPlane[0]*S,this._cachedClippingPlane[1]*S,this._cachedClippingPlane[2]*S])}const b=function(w){const S=c.bp();return S[0]=w[0]*-w[3],S[1]=w[1]*-w[3],S[2]=w[2]*-w[3],{center:S,radius:Math.sqrt(1-w[3]*w[3])}}(u);return Cs(function(w,S,P){const I=c.bp();c.aU(I,P,w);const k=c.bp();return c.bq(k,w,I,S/c.a$(I)),k}(b.center,b.radius,y))}getMatrixForModel(e,n){const a=c.S.convert(e),l=1/c.bu,u=c.b9();return c.bz(u,u,a.lng/180*Math.PI),c.b7(u,u,-a.lat/180*Math.PI),c.M(u,u,[0,0,1+n/c.bu]),c.b7(u,u,.5*Math.PI),c.N(u,u,[l,l,l]),u}getProjectionDataForCustomLayer(e=!0){const n=this.getProjectionData({overscaledTileID:new c.Z(0,0,0,0,0),applyGlobeMatrix:e});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(e){}}class Ls{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,a){return this._helper.interpolatePadding(e,n,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n,a=!0){this._helper.resize(e,n,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,n){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new bi({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,n)=>this.getConstrained(e,n)}),this._globeness=1,this._mercatorTransform=new bt,this._verticalPerspectiveTransform=new zs}clone(){const e=new Ls;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const n=this._mercatorTransform.getProjectionData(e),a=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?a.mainMatrix:n.mainMatrix,clippingPlane:a.clippingPlane,tileMercatorCoords:a.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return c.bk(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return c.bk(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,n,a){const l=this._mercatorTransform.getPitchedTextCorrection(e,n,a),u=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,n,a);return c.bk(l,u,this._globeness)}projectTileCoordinates(e,n,a,l){return this.currentTransform.projectTileCoordinates(e,n,a,l)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){return this.currentTransform.lngLatToCameraDepth(e,n)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,n){return this.currentTransform.getConstrained(e,n)}calculateCenterFromCameraLngLatAlt(e,n,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,a,l)}setLocationAtPoint(e,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,n),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,n),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,n){return this.currentTransform.locationToScreenPoint(e,n)}screenPointToMercatorCoordinate(e,n){return this.currentTransform.screenPointToMercatorCoordinate(e,n)}screenPointToLocation(e,n){return this.currentTransform.screenPointToLocation(e,n)}isPointOnMapSurface(e,n){return this.currentTransform.isPointOnMapSurface(e,n)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,n){return this.currentTransform.getMatrixForModel(e,n)}getProjectionDataForCustomLayer(e=!0){const n=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return n;const a=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return a.fallbackMatrix=n.mainMatrix,a}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class yi{get useGlobeControls(){return!0}handlePanInertia(e,n){const a=kl(e,n);return Math.abs(a.lng-n.center.lng)>180&&(a.lng=n.center.lng+179.5*Math.sign(a.lng-n.center.lng)),{easingCenter:a,easingOffset:new c.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,n){const a=e.around,l=n.screenPointToLocation(a);e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta);const u=n.zoom;e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta);const f=n.zoom-u;if(f===0)return;const _=c.bA(n.center.lng,l.lng),y=_/(Math.abs(_/180)+1),b=c.bA(n.center.lat,l.lat),w=n.getRayDirectionFromPixel(a),S=n.cameraPosition,P=-1*c.aX(S,w),I=c.bp();c.aS(I,S,[w[0]*P,w[1]*P,w[2]*P]);const k=c.aZ(I)-1,O=Math.exp(.5*-Math.max(k-.3,0)),B=Jn(n.worldSize,n.center.lat)/Math.min(n.width,n.height),N=c.bn(B,.9,.5,1,.25),U=(1-c.af(-f))*Math.min(O,N),q=n.center.lat,$=n.zoom,H=new c.S(n.center.lng+y*U,c.ah(n.center.lat+b*U,-c.ai,c.ai));n.setLocationAtPoint(l,a);const K=n.center,G=c.bn(Math.abs(_),45,85,0,1),te=c.bn(B,.75,.35,0,1),ue=Math.pow(Math.max(G,te),.25),ae=c.bA(K.lng,H.lng),oe=c.bA(K.lat,H.lat);n.setCenter(new c.S(K.lng+ae*ue,K.lat+oe*ue).wrap()),n.setZoom($+Ft(q,n.center.lat))}handleMapControlsPan(e,n,a){if(!e.panDelta)return;const l=n.center.lat,u=n.zoom;n.setCenter(kl(e.panDelta,n).wrap()),n.setZoom(u+Ft(l,n.center.lat))}cameraForBoxAndBearing(e,n,a,l,u){const f=Bi(e,n,a,l,u),_=n.left/u.width*2-1,y=(u.width-n.right)/u.width*2-1,b=n.top/u.height*-2+1,w=(u.height-n.bottom)/u.height*-2+1,S=c.bA(a.getWest(),a.getEast())<0,P=S?a.getEast():a.getWest(),I=S?a.getWest():a.getEast(),k=Math.max(a.getNorth(),a.getSouth()),O=Math.min(a.getNorth(),a.getSouth()),B=P+.5*c.bA(P,I),N=k+.5*c.bA(k,O),U=u.clone();U.setCenter(f.center),U.setBearing(f.bearing),U.setPitch(0),U.setRoll(0),U.setZoom(f.zoom);const q=U.modelViewProjectionMatrix,$=[ii(a.getNorthWest()),ii(a.getNorthEast()),ii(a.getSouthWest()),ii(a.getSouthEast()),ii(new c.S(I,N)),ii(new c.S(P,N)),ii(new c.S(B,k)),ii(new c.S(B,O))],H=ii(f.center);let K=Number.POSITIVE_INFINITY;for(const G of $)_<0&&(K=yi.getLesserNonNegativeNonNull(K,yi.solveVectorScale(G,H,q,"x",_))),y>0&&(K=yi.getLesserNonNegativeNonNull(K,yi.solveVectorScale(G,H,q,"x",y))),b>0&&(K=yi.getLesserNonNegativeNonNull(K,yi.solveVectorScale(G,H,q,"y",b))),w<0&&(K=yi.getLesserNonNegativeNonNull(K,yi.solveVectorScale(G,H,q,"y",w)));if(Number.isFinite(K)&&K!==0)return f.zoom=U.zoom+c.ak(K),f;Al()}handleJumpToCenterZoom(e,n){const a=e.center.lat,l=e.getConstrained(n.center?c.S.convert(n.center):e.center,e.zoom).center;e.setCenter(l.wrap());const u=n.zoom!==void 0?+n.zoom:e.zoom+Ft(a,l.lat);e.zoom!==u&&e.setZoom(u)}handleEaseTo(e,n){const a=e.zoom,l=e.center,u=e.padding,f={roll:e.roll,pitch:e.pitch,bearing:e.bearing},_={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},y=n.zoom!==void 0,b=!e.isPaddingEqual(n.padding);let w=!1;const S=n.center?c.S.convert(n.center):l,P=e.getConstrained(S,a).center;da(e,P);const I=e.clone();I.setCenter(P),I.setZoom(y?+n.zoom:a+Ft(l.lat,S.lat)),I.setBearing(n.bearing);const k=new c.P(c.ah(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),c.ah(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));I.setLocationAtPoint(P,k);const O=(n.offset&&n.offsetAsPoint.mag())>0?I.center:P,B=y?+n.zoom:a+Ft(l.lat,O.lat),N=a+Ft(l.lat,0),U=B+Ft(O.lat,0),q=c.bA(l.lng,O.lng),$=c.bA(l.lat,O.lat),H=c.af(U-N);return w=B!==a,{easeFunc:K=>{if(c.be(f,_)||Ti({startEulerAngles:f,endEulerAngles:_,tr:e,k:K,useSlerp:f.roll!=_.roll}),b&&e.interpolatePadding(u,n.padding,K),n.around)c.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(n.around,n.aroundPoint);else{const G=U>N?Math.min(2,H):Math.max(.5,H),te=Math.pow(G,1-K),ue=vo(l,q,$,K*te);e.setCenter(ue.wrap())}if(w){const G=c.C.number(N,U,K)+Ft(0,e.center.lat);e.setZoom(G)}},isZooming:w,elevationCenter:O}}handleFlyTo(e,n){const a=n.zoom!==void 0,l=e.center,u=e.zoom,f=e.padding,_=!e.isPaddingEqual(n.padding),y=e.getConstrained(c.S.convert(n.center||n.locationAtOffset),u).center,b=a?+n.zoom:e.zoom+Ft(e.center.lat,y.lat),w=e.clone();w.setCenter(y),w.setZoom(b),w.setBearing(n.bearing);const S=new c.P(c.ah(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),c.ah(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));w.setLocationAtPoint(y,S);const P=w.center;da(e,P);const I=function($,H,K){const G=ii(H),te=ii(K),ue=c.aX(G,te),ae=Math.acos(ue),oe=_a($);return ae/(2*Math.PI)*oe}(e,l,P),k=u+Ft(l.lat,0),O=b+Ft(P.lat,0),B=c.af(O-k);let N;if(typeof n.minZoom=="number"){const $=+n.minZoom+Ft(P.lat,0),H=Math.min($,k,O)+Ft(0,P.lat),K=e.getConstrained(P,H).zoom+Ft(P.lat,0);N=c.af(K-k)}const U=c.bA(l.lng,P.lng),q=c.bA(l.lat,P.lat);return{easeFunc:($,H,K,G)=>{const te=vo(l,U,q,K);_&&e.interpolatePadding(f,n.padding,$);const ue=$===1?P:te;e.setCenter(ue.wrap());const ae=k+c.ak(H);e.setZoom($===1?b:ae+Ft(0,ue.lat))},scaleOfZoom:B,targetCenter:P,scaleOfMinZoom:N,pixelPathLength:I}}static solveVectorScale(e,n,a,l,u){const f=l==="x"?[a[0],a[4],a[8],a[12]]:[a[1],a[5],a[9],a[13]],_=[a[3],a[7],a[11],a[15]],y=e[0]*f[0]+e[1]*f[1]+e[2]*f[2],b=e[0]*_[0]+e[1]*_[1]+e[2]*_[2],w=n[0]*f[0]+n[1]*f[1]+n[2]*f[2],S=n[0]*_[0]+n[1]*_[1]+n[2]*_[2];return w+u*b===y+u*S||_[3]*(y-w)+f[3]*(S-b)+y*S==w*b?null:(w+f[3]-u*S-u*_[3])/(w-y-u*S+u*b)}static getLesserNonNegativeNonNull(e,n){return n!==null&&n>=0&&n<e?n:e}}class zl{constructor(e){this._globe=e,this._mercatorCameraHelper=new _i,this._verticalPerspectiveCameraHelper=new yi}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,n){return this.currentHelper.handlePanInertia(e,n)}handleMapControlsRollPitchBearingZoom(e,n){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,n)}handleMapControlsPan(e,n,a){this.currentHelper.handleMapControlsPan(e,n,a)}cameraForBoxAndBearing(e,n,a,l,u){return this.currentHelper.cameraForBoxAndBearing(e,n,a,l,u)}handleJumpToCenterZoom(e,n){this.currentHelper.handleJumpToCenterZoom(e,n)}handleEaseTo(e,n){return this.currentHelper.handleEaseTo(e,n)}handleFlyTo(e,n){return this.currentHelper.handleFlyTo(e,n)}}const ya=(h,e)=>c.y(h,e&&e.filter(n=>n.identifier!=="source.canvas")),Xc=c.bE();class bo extends c.E{constructor(e,n={}){var a,l;super(),this._rtlPluginLoaded=()=>{for(const f in this.sourceCaches){const _=this.sourceCaches[f].getSource().type;_!=="vector"&&_!=="geojson"||this.sourceCaches[f].reload()}},this.map=e,this.dispatcher=new Ei(fn(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(f,_)=>this.getGlyphs(f,_)),this.dispatcher.registerMessageHandler("GI",(f,_)=>this.getImages(f,_)),this.imageManager=new Ts,this.imageManager.setEventedParent(this);const u=((a=e._container)===null||a===void 0?void 0:a.lang)||typeof document<"u"&&((l=document.documentElement)===null||l===void 0?void 0:l.lang)||void 0;this.glyphManager=new Or(e._requestManager,n.localIdeographFontFamily,u),this.lineAtlas=new gt(256,512),this.crossTileSymbolIndex=new Yn,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new c.bF,this._loaded=!1,this._availableImages=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast("SR",c.bG()),Gr().on(gn,this._rtlPluginLoaded),this.on("data",f=>{if(f.dataType!=="source"||f.sourceDataType!=="metadata")return;const _=this.sourceCaches[f.sourceId];if(!_)return;const y=_.getSource();if(y&&y.vectorLayerIds)for(const b in this._layers){const w=this._layers[b];w.source===y.id&&this._validateLayer(w)}})}setGlobalStateProperty(e,n){var a,l,u;this._checkLoaded();const f=n===null?(u=(l=(a=this.stylesheet.state)===null||a===void 0?void 0:a[e])===null||l===void 0?void 0:l.default)!==null&&u!==void 0?u:null:n;if(c.bH(f,this._globalState[e]))return this;this._globalState[e]=f,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const n=[];for(const a in e)!c.bH(this._globalState[a],e[a].default)&&(n.push(a),this._globalState[a]=e[a].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(e){if(e.length===0)return;const n=new Set;for(const a in this._layers){const l=this._layers[a],u=l.getLayoutAffectingGlobalStateRefs(),f=l.getPaintAffectingGlobalStateRefs();for(const _ of e)if(u.has(_)&&n.add(l.source),f.has(_))for(const{name:y,value:b}of f.get(_))this._updatePaintProperty(l,y,b)}for(const a in this.sourceCaches)n.has(a)&&(this._reloadSource(a),this._changed=!0)}loadURL(e,n={},a){this.fire(new c.l("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const l=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const u=this._loadStyleRequest;c.j(l,this._loadStyleRequest).then(f=>{this._loadStyleRequest=null,this._load(f.data,n,a)}).catch(f=>{this._loadStyleRequest=null,f&&!u.signal.aborted&&this.fire(new c.k(f))})}loadJSON(e,n={},a){this.fire(new c.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,Ee.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,a)}).catch(()=>{})}loadEmpty(){this.fire(new c.l("dataloading",{dataType:"style"})),this._load(Xc,{validate:!1})}_load(e,n,a){var l,u;let f=n.transformStyle?n.transformStyle(a,e):e;if(!n.validate||!ya(this,c.z(f))){f=Object.assign({},f),this._loaded=!0,this.stylesheet=f;for(const _ in f.sources)this.addSource(_,f.sources[_],{validate:!1});f.sprite?this._loadSprite(f.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(f.glyphs),this._createLayers(),this.light=new hn(this.stylesheet.light),this._setProjectionInternal(((l=this.stylesheet.projection)===null||l===void 0?void 0:l.type)||"mercator"),this.sky=new la(this.stylesheet.sky),this.map.setTerrain((u=this.stylesheet.terrain)!==null&&u!==void 0?u:null),this.fire(new c.l("data",{dataType:"style"})),this.fire(new c.l("style.load"))}}_createLayers(){var e;const n=c.bI(this.stylesheet.layers);this.dispatcher.broadcast("SL",n),this._order=n.map(a=>a.id),this._layers={},this.setGlobalState((e=this.stylesheet.state)!==null&&e!==void 0?e:null),this._serializedLayers=null;for(const a of n){const l=c.bJ(a);l.setEventedParent(this,{layer:{id:a.id}}),l.setGlobalState(this._globalState),this._layers[a.id]=l}}_loadSprite(e,n=!1,a=void 0){let l;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(u,f,_,y){return c._(this,void 0,void 0,function*(){const b=Sr(u),w=_>1?"@2x":"",S={},P={};for(const{id:I,url:k}of b){const O=f.transformRequest(jn(k,w,".json"),"SpriteJSON");S[I]=c.j(O,y);const B=f.transformRequest(jn(k,w,".png"),"SpriteImage");P[I]=Ot.getImage(B,y)}return yield Promise.all([...Object.values(S),...Object.values(P)]),function(I,k){return c._(this,void 0,void 0,function*(){const O={};for(const B in I){O[B]={};const N=Ee.getImageCanvasContext((yield k[B]).data),U=(yield I[B]).data;for(const q in U){const{width:$,height:H,x:K,y:G,sdf:te,pixelRatio:ue,stretchX:ae,stretchY:oe,content:he,textFitWidth:we,textFitHeight:Se}=U[q];O[B][q]={data:null,pixelRatio:ue,sdf:te,stretchX:ae,stretchY:oe,content:he,textFitWidth:we,textFitHeight:Se,spriteData:{width:$,height:H,x:K,y:G,context:N}}}}return O})}(S,P)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(u=>{if(this._spriteRequest=null,u)for(const f in u){this._spritesImagesIds[f]=[];const _=this._spritesImagesIds[f]?this._spritesImagesIds[f].filter(y=>!(y in u)):[];for(const y of _)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(const y in u[f]){const b=f==="default"?y:`${f}:${y}`;this._spritesImagesIds[f].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,u[f][y],!1):this.imageManager.addImage(b,u[f][y]),n&&(this._changedImages[b]=!0)}}}).catch(u=>{this._spriteRequest=null,l=u,this.fire(new c.k(l))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"})),a&&a(l)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}_validateLayer(e){const n=this.sourceCaches[e.source];if(!n)return;const a=e.sourceLayer;if(!a)return;const l=n.getSource();(l.type==="geojson"||l.vectorLayerIds&&l.vectorLayerIds.indexOf(a)===-1)&&this.fire(new c.k(new Error(`Source layer "${a}" does not exist on source "${l.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){const a=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?c.bK(a):a);const l=[];for(const u of e)if(a[u]){const f=n?c.bK(a[u]):a[u];l.push(f)}return l}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const n=Object.keys(this._layers);for(const a of n){const l=this._layers[a];l.type!=="custom"&&(e[a]=l.serialize())}return e}hasTransitions(){var e,n,a;if(!((e=this.light)===null||e===void 0)&&e.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((a=this.projection)===null||a===void 0)&&a.hasTransition())return!0;for(const l in this.sourceCaches)if(this.sourceCaches[l].hasTransition())return!0;for(const l in this._layers)if(this._layers[l].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const n=this._changed;if(n){const l=Object.keys(this._updatedLayers),u=Object.keys(this._removedLayers);(l.length||u.length)&&this._updateWorkerLayers(l,u);for(const f in this._updatedSources){const _=this._updatedSources[f];if(_==="reload")this._reloadSource(f);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(f)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const f in this._updatedPaintProps)this._layers[f].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const a={};for(const l in this.sourceCaches){const u=this.sourceCaches[l];a[l]=u.used,u.used=!1}for(const l of this._order){const u=this._layers[l];u.recalculate(e,this._availableImages),!u.isHidden(e.zoom)&&u.source&&(this.sourceCaches[u.source].used=!0)}for(const l in a){const u=this.sourceCaches[l];!!a[l]!=!!u.used&&u.fire(new c.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:l}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,n&&this.fire(new c.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var a;this._checkLoaded();const l=this.serialize();if(e=n.transformStyle?n.transformStyle(l,e):e,((a=n.validate)===null||a===void 0||a)&&ya(this,c.z(e)))return!1;(e=c.bK(e)).layers=c.bI(e.layers);const u=c.bL(l,e),f=this._getOperationsToPerform(u);if(f.unimplemented.length>0)throw new Error(`Unimplemented: ${f.unimplemented.join(", ")}.`);if(f.operations.length===0)return!1;for(const _ of f.operations)_();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const n=[],a=[];for(const l of e)switch(l.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,l.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,l.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,l.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,l.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,l.args));break;case"addSource":n.push(()=>this.addSource.apply(this,l.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,l.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,l.args));break;case"setLight":n.push(()=>this.setLight.apply(this,l.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,l.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,l.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,l.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,l.args));break;case"setSky":n.push(()=>this.setSky.apply(this,l.args));break;case"setProjection":this.setProjection.apply(this,l.args);break;case"setGlobalState":n.push(()=>this.setGlobalState.apply(this,l.args));break;case"setTransition":n.push(()=>{});break;default:a.push(l.command)}return{operations:n,unimplemented:a}}addImage(e,n){if(this.getImage(e))return this.fire(new c.k(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 c.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,a={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(c.z.source,`sources.${e}`,n,null,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const l=this.sourceCaches[e]=new Qe(e,n,this.dispatcher);l.style=this,l.setEventedParent(this,()=>({isSourceLoaded:l.loaded(),source:l.serialize(),sourceId:e})),l.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(const a in this._layers)if(this._layers[a].source===e)return this.fire(new c.k(new Error(`Source "${e}" cannot be removed while layer "${a}" is using it.`)));const n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new c.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);const a=this.sourceCaches[e].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,a={}){this._checkLoaded();const l=e.id;if(this.getLayer(l))return void this.fire(new c.k(new Error(`Layer "${l}" already exists on this map.`)));let u;if(e.type==="custom"){if(ya(this,c.bM(e)))return;u=c.bJ(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(l,e.source),e=c.bK(e),e=c.e(e,{source:l})),this._validate(c.z.layer,`layers.${l}`,e,{arrayIndex:-1},a))return;u=c.bJ(e),this._validateLayer(u),u.setEventedParent(this,{layer:{id:l}})}const f=n?this._order.indexOf(n):this._order.length;if(n&&f===-1)this.fire(new c.k(new Error(`Cannot add layer "${l}" before non-existing layer "${n}".`)));else{if(this._order.splice(f,0,l),this._layerOrderChanged=!0,this._layers[l]=u,this._removedLayers[l]&&u.source&&u.type!=="custom"){const _=this._removedLayers[l];delete this._removedLayers[l],_.type!==u.type?this._updatedSources[u.source]="clear":(this._updatedSources[u.source]="reload",this.sourceCaches[u.source].pause())}this._updateLayer(u),u.onAdd&&u.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new c.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;const a=this._order.indexOf(e);this._order.splice(a,1);const l=n?this._order.indexOf(n):this._order.length;n&&l===-1?this.fire(new c.k(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(l,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const n=this._layers[e];if(!n)return void this.fire(new c.k(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);const a=this._order.indexOf(e);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,a){this._checkLoaded();const l=this.getLayer(e);l?l.minzoom===n&&l.maxzoom===a||(n!=null&&(l.minzoom=n),a!=null&&(l.maxzoom=a),this._updateLayer(l)):this.fire(new c.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,a={}){this._checkLoaded();const l=this.getLayer(e);if(l){if(!c.bH(l.filter,n))return n==null?(l.setFilter(void 0),void this._updateLayer(l)):void(this._validate(c.z.filter,`layers.${l.id}.filter`,n,null,a)||(l.setFilter(c.bK(n)),this._updateLayer(l)))}else this.fire(new c.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return c.bK(this.getLayer(e).filter)}setLayoutProperty(e,n,a,l={}){this._checkLoaded();const u=this.getLayer(e);u?c.bH(u.getLayoutProperty(n),a)||(u.setLayoutProperty(n,a,l),this._updateLayer(u)):this.fire(new c.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){const a=this.getLayer(e);if(a)return a.getLayoutProperty(n);this.fire(new c.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,a,l={}){this._checkLoaded();const u=this.getLayer(e);u?c.bH(u.getPaintProperty(n),a)||this._updatePaintProperty(u,n,a,l):this.fire(new c.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,n,a,l={}){e.setPaintProperty(n,a,l)&&this._updateLayer(e),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();const a=e.source,l=e.sourceLayer,u=this.sourceCaches[a];if(u===void 0)return void this.fire(new c.k(new Error(`The source '${a}' does not exist in the map's style.`)));const f=u.getSource().type;f==="geojson"&&l?this.fire(new c.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):f!=="vector"||l?(e.id===void 0&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),u.setFeatureState(l,e.id,n)):this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();const a=e.source,l=this.sourceCaches[a];if(l===void 0)return void this.fire(new c.k(new Error(`The source '${a}' does not exist in the map's style.`)));const u=l.getSource().type,f=u==="vector"?e.sourceLayer:void 0;u!=="vector"||f?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new c.k(new Error("A feature id is required to remove its specific state property."))):l.removeFeatureState(f,e.id,n):this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const n=e.source,a=e.sourceLayer,l=this.sourceCaches[n];if(l!==void 0)return l.getSource().type!=="vector"||a?(e.id===void 0&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),l.getFeatureState(a,e.id)):void this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new c.k(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return c.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=c.bN(this.sourceCaches,u=>u.serialize()),n=this._serializeByIds(this._order,!0),a=this.map.getTerrain()||void 0,l=this.stylesheet;return c.bO({version:l.version,name:l.name,metadata:l.metadata,light:l.light,sky:l.sky,center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch,sprite:l.sprite,glyphs:l.glyphs,transition:l.transition,projection:l.projection,sources:e,layers:n,terrain:a},u=>u!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const n=f=>this._layers[f].type==="fill-extrusion",a={},l=[];for(let f=this._order.length-1;f>=0;f--){const _=this._order[f];if(n(_)){a[_]=f;for(const y of e){const b=y[_];if(b)for(const w of b)l.push(w)}}}l.sort((f,_)=>_.intersectionZ-f.intersectionZ);const u=[];for(let f=this._order.length-1;f>=0;f--){const _=this._order[f];if(n(_))for(let y=l.length-1;y>=0;y--){const b=l[y].feature;if(a[b.layer.id]<f)break;u.push(b),l.pop()}else for(const y of e){const b=y[_];if(b)for(const w of b)u.push(w.feature)}}return u}queryRenderedFeatures(e,n,a){n&&n.filter&&this._validate(c.z.filter,"queryRenderedFeatures.filter",n.filter,null,n);const l={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new c.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const b of n.layers){const w=this._layers[b];if(!w)return this.fire(new c.k(new Error(`The layer '${b}' does not exist in the map's style and cannot be queried for features.`))),[];l[w.source]=!0}}const u=[];n.availableImages=this._availableImages;const f=this._serializedAllLayers(),_=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,y=Object.assign(Object.assign({},n),{layers:_});for(const b in this.sourceCaches)n.layers&&!l[b]||u.push(Yi(this.sourceCaches[b],this._layers,f,e,y,a,this.map.terrain?(w,S,P)=>this.map.terrain.getElevation(w,S,P):void 0));return this.placement&&u.push(function(b,w,S,P,I,k,O){const B={},N=k.queryRenderedSymbols(P),U=[];for(const q of Object.keys(N).map(Number))U.push(O[q]);U.sort(Vn);for(const q of U){const $=q.featureIndex.lookupSymbolFeatures(N[q.bucketInstanceId],w,q.bucketIndex,q.sourceLayerIndex,I.filter,I.layers,I.availableImages,b);for(const H in $){const K=B[H]=B[H]||[],G=$[H];G.sort((te,ue)=>{const ae=q.featureSortOrder;if(ae){const oe=ae.indexOf(te.featureIndex);return ae.indexOf(ue.featureIndex)-oe}return ue.featureIndex-te.featureIndex});for(const te of G)K.push(te)}}return function(q,$,H){for(const K in q)for(const G of q[K])Un(G,H[$[K].source]);return q}(B,b,S)}(this._layers,f,this.sourceCaches,e,y,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(u)}querySourceFeatures(e,n){n&&n.filter&&this._validate(c.z.filter,"querySourceFeatures.filter",n.filter,null,n);const a=this.sourceCaches[e];return a?function(l,u){const f=l.getRenderableIds().map(b=>l.getTileByID(b)),_=[],y={};for(let b=0;b<f.length;b++){const w=f[b],S=w.tileID.canonical.key;y[S]||(y[S]=!0,w.querySourceFeatures(_,u))}return _}(a,n):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();const a=this.light.getLight();let l=!1;for(const f in e)if(!c.bH(e[f],a[f])){l=!0;break}if(!l)return;const u={now:Ee.now(),transition:c.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(u)}getProjection(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.projection}setProjection(e){if(this._checkLoaded(),this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=e,this._setProjectionInternal(e.type)}getSky(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.sky}setSky(e,n={}){this._checkLoaded();const a=this.getSky();let l=!1;if(!e&&!a)return;if(e&&!a)l=!0;else if(!e&&a)l=!0;else for(const f in e)if(!c.bH(e[f],a[f])){l=!0;break}if(!l)return;const u={now:Ee.now(),transition:c.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(u)}_setProjectionInternal(e){const n=function(a){if(Array.isArray(a)){const l=new ga({type:a});return{projection:l,transform:new Ls,cameraHelper:new zl(l)}}switch(a){case"mercator":return{projection:new it,transform:new bt,cameraHelper:new _i};case"globe":{const l=new ga({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:l,transform:new Ls,cameraHelper:new zl(l)}}case"vertical-perspective":return{projection:new Is,transform:new zs,cameraHelper:new yi};default:return c.w(`Unknown projection name: ${a}. Falling back to mercator projection.`),{projection:new it,transform:new bt,cameraHelper:new _i}}}(e);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const a in this.sourceCaches)this.sourceCaches[a].reload()}_validate(e,n,a,l,u={}){return(!u||u.validate!==!1)&&ya(this,e.call(c.z,c.e({key:n,style:this.serialize(),value:a,styleSpec:c.v},l)))}_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),Gr().off(gn,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const a=this.sourceCaches[n];a.setEventedParent(null),a.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(const n in this.sourceCaches)this.sourceCaches[n].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.sourceCaches)this._reloadSource(e)}_updatePlacement(e,n,a,l,u=!1){let f=!1,_=!1;const y={};for(const b of this._order){const w=this._layers[b];if(w.type!=="symbol")continue;if(!y[w.source]){const P=this.sourceCaches[w.source];y[w.source]=P.getRenderableIds(!0).map(I=>P.getTileByID(I)).sort((I,k)=>k.tileID.overscaledZ-I.tileID.overscaledZ||(I.tileID.isLessThan(k.tileID)?-1:1))}const S=this.crossTileSymbolIndex.addLayer(w,y[w.source],e.center.lng);f=f||S}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((u=u||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Ee.now(),e.zoom))&&(this.pauseablePlacement=new go(e,this.map.terrain,this._order,u,n,a,l,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(Ee.now()),_=!0),f&&this.pauseablePlacement.placement.setStale()),_||f)for(const b of this._order){const w=this._layers[b];w.type==="symbol"&&this.placement.updateLayerOpacities(w,y[w.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Ee.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return c._(this,void 0,void 0,function*(){const a=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const l=this.sourceCaches[n.source];return l&&l.setDependencies(n.tileID.key,n.type,n.icons),a})}getGlyphs(e,n){return c._(this,void 0,void 0,function*(){const a=yield this.glyphManager.getGlyphs(n.stacks),l=this.sourceCaches[n.source];return l&&l.setDependencies(n.tileID.key,n.type,[""]),a})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(c.z.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,a={},l){this._checkLoaded();const u=[{id:e,url:n}],f=[...Sr(this.stylesheet.sprite),...u];this._validate(c.z.sprite,"sprite",f,null,a)||(this.stylesheet.sprite=f,this._loadSprite(u,!0,l))}removeSprite(e){this._checkLoaded();const n=Sr(this.stylesheet.sprite);if(n.find(a=>a.id===e)){if(this._spritesImagesIds[e])for(const a of this._spritesImagesIds[e])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex(a=>a.id===e),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}else this.fire(new c.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return Sr(this.stylesheet.sprite)}setSprite(e,n={},a){this._checkLoaded(),e&&this._validate(c.z.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,a):(this._unloadSprite(),a&&a(null)))}}var Yc=c.aJ([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Kc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,a,l,u,f,_,y,b){this.context=e;let w=this.boundPaintVertexBuffers.length!==l.length;for(let S=0;!w&&S<l.length;S++)this.boundPaintVertexBuffers[S]!==l[S]&&(w=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==a||w||this.boundIndexBuffer!==u||this.boundVertexOffset!==f||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==y||this.boundDynamicVertexBuffer3!==b?this.freshBind(n,a,l,u,f,_,y,b):(e.bindVertexArray.set(this.vao),_&&_.bind(),u&&u.dynamicDraw&&u.bind(),y&&y.bind(),b&&b.bind())}freshBind(e,n,a,l,u,f,_,y){const b=e.numAttributes,w=this.context,S=w.gl;this.vao&&this.destroy(),this.vao=w.createVertexArray(),w.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=a,this.boundIndexBuffer=l,this.boundVertexOffset=u,this.boundDynamicVertexBuffer=f,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=y,n.enableAttributes(S,e);for(const P of a)P.enableAttributes(S,e);f&&f.enableAttributes(S,e),_&&_.enableAttributes(S,e),y&&y.enableAttributes(S,e),n.bind(),n.setVertexAttribPointers(S,e,u);for(const P of a)P.bind(),P.setVertexAttribPointers(S,e,u);f&&(f.bind(),f.setVertexAttribPointers(S,e,u)),l&&l.bind(),_&&(_.bind(),_.setVertexAttribPointers(S,e,u)),y&&(y.bind(),y.setVertexAttribPointers(S,e,u)),w.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const xa=(h,e,n,a,l)=>({u_texture:0,u_ele_delta:h,u_fog_matrix:e,u_fog_color:n?n.properties.get("fog-color"):c.bf.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:l?0:n?n.calculateFogBlendOpacity(a):0,u_horizon_color:n?n.properties.get("horizon-color"):c.bf.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:l?1:0}),wo={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Tn(h){const e=[];for(let n=0;n<h.length;n++){if(h[n]===null)continue;const a=h[n].split(" ");e.push(a.pop())}return e}class To{constructor(e,n,a,l,u,f,_,y,b=[]){const w=e.gl;this.program=w.createProgram();const S=Tn(n.staticAttributes),P=a?a.getBinderAttributes():[],I=S.concat(P),k=Ji.prelude.staticUniforms?Tn(Ji.prelude.staticUniforms):[],O=_.staticUniforms?Tn(_.staticUniforms):[],B=n.staticUniforms?Tn(n.staticUniforms):[],N=a?a.getBinderUniforms():[],U=k.concat(O).concat(B).concat(N),q=[];for(const ae of U)q.indexOf(ae)<0&&q.push(ae);const $=a?a.defines():[];vr(w)&&$.unshift("#version 300 es"),u&&$.push("#define OVERDRAW_INSPECTOR;"),f&&$.push("#define TERRAIN3D;"),y&&$.push(y),b&&$.push(...b);let H=$.concat(Ji.prelude.fragmentSource,_.fragmentSource,n.fragmentSource).join(`
739
+ `}),staticAttributes:a,staticUniforms:f}}class yn{constructor(e,n,a){this.vertexBuffer=e,this.indexBuffer=n,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Kr=c.aJ([{name:"a_pos",type:"Int16",components:2}]);const Mr="#define PROJECTION_MERCATOR",xn="mercator";class it{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return xn}get shaderDefine(){return Mr}get shaderPreludeCode(){return Ji.projectionMercator}get vertexShaderPreludeCode(){return Ji.projectionMercator.vertexSource}get subdivisionGranularity(){return c.aK.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,n,a,l,u){if(this._cachedMesh)return this._cachedMesh;const f=new c.aL;f.emplaceBack(0,0),f.emplaceBack(c.$,0),f.emplaceBack(0,c.$),f.emplaceBack(c.$,c.$);const _=e.createVertexBuffer(f,Kr.members),y=c.aM.simpleSegment(0,0,4,2),b=new c.aN;b.emplaceBack(1,0,2),b.emplaceBack(1,2,3);const w=e.createIndexBuffer(b);return this._cachedMesh=new yn(_,w,y),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class vn{constructor(e=0,n=0,a=0,l=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=a,this.right=l}interpolate(e,n,a){return n.top!=null&&e.top!=null&&(this.top=c.C.number(e.top,n.top,a)),n.bottom!=null&&e.bottom!=null&&(this.bottom=c.C.number(e.bottom,n.bottom,a)),n.left!=null&&e.left!=null&&(this.left=c.C.number(e.left,n.left,a)),n.right!=null&&e.right!=null&&(this.right=c.C.number(e.right,n.right,a)),this}getCenter(e,n){const a=c.ah((this.left+e-this.right)/2,0,e),l=c.ah((this.top+n-this.bottom)/2,0,n);return new c.P(a,l)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new vn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function da(h,e){if(!h.renderWorldCopies||h.lngRange)return;const n=e.lng-h.center.lng;e.lng+=n>180?-360:n<-180?360:0}function pa(h){return Math.max(0,Math.floor(h))}class bi{constructor(e,n,a,l,u,f){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=f===void 0||!!f,this._minZoom=n||0,this._maxZoom=a||22,this._minPitch=l??0,this._maxPitch=u??60,this.setMaxBounds(),this._width=0,this._height=0,this._center=new c.S(0,0),this._elevation=0,this._zoom=0,this._tileZoom=pa(this._zoom),this._scale=c.af(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new vn,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,n,a){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=pa(this._zoom),this._scale=c.af(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new vn(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!a&&e.autoCalculateNearFarZ,n&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){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 c.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const n=c.aO(e,-180,180)*Math.PI/180;var a,l,u,f,_,y,b,w,S;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=ct(),a=this._rotationMatrix,u=-this._bearingInRadians,f=(l=this._rotationMatrix)[0],_=l[1],y=l[2],b=l[3],w=Math.sin(u),S=Math.cos(u),a[0]=f*S+y*w,a[1]=_*S+b*w,a[2]=f*-w+y*S,a[3]=_*-w+b*S)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const n=c.ah(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const n=e/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return c.aP(this._fovInRadians)}setFov(e){e=c.ah(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=c.ae(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const n=this.getConstrained(this._center,e).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=c.af(n),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,n){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,a){this._unmodified=!1,this._edgeInsets.interpolate(e,n,a),this._constrain(),this._calcMatrices()}resize(e,n,a=!0){this._width=e,this._height=n,a&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new Dt([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-c.ai,c.ai])}getConstrained(e,n){return this._callbacks.getConstrained(e,n)}getCameraQueryGeometry(e,n){if(n.length===1)return[n[0],e];{const{minX:a,minY:l,maxX:u,maxY:f}=c.a2.fromPoints(n).extend(e);return[new c.P(a,l),new c.P(u,l),new c.P(u,f),new c.P(a,f),new c.P(a,l)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:n,zoom:a}=this.getConstrained(this.center,this.zoom);this.setCenter(n),this.setZoom(a),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=c.ag(new Float64Array(16));c.N(e,e,[this._width/2,-this._height/2,1]),c.M(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=c.ag(new Float64Array(16)),c.N(e,e,[1,-1,1]),c.M(e,e,[-1,-1,0]),c.N(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,n,a,l){const u=a!==void 0?a:this.bearing,f=l=l!==void 0?l:this.pitch,_=c.a1.fromLngLat(e,n),y=-Math.cos(c.ae(f)),b=Math.sin(c.ae(f)),w=b*Math.sin(c.ae(u)),S=-b*Math.cos(c.ae(u));let P=this.elevation;const I=n-P;let k;y*I>=0||Math.abs(y)<.1?(k=1e4,P=n+k*y):k=-I/y;let O,B,N=c.aQ(1,_.y),U=0;do{if(U+=1,U>10)break;B=k/N,O=new c.a1(_.x+w*B,_.y+S*B),N=1/O.meterInMercatorCoordinateUnits()}while(Math.abs(k-B*N)>1e-12);return{center:O.toLngLat(),elevation:P,zoom:c.ak(this.height/2/Math.tan(this.fovInRadians/2)/B/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const n=c.aj(1,this.center.lat)*this.worldSize,a=this.cameraToCenterDistance/n,l=c.a1.fromLngLat(this.center,this.elevation),u=le(this.center,this.elevation,this.pitch,this.bearing,a);this._elevation=e;const f=this.calculateCenterFromCameraLngLatAlt(u.toLngLat(),c.aQ(u.z,l.y),this.bearing,this.pitch);this._elevation=f.elevation,this._center=f.center,this.setZoom(f.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new c.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=c.aj(1,this.center.lat)*this.worldSize;return le(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const n=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/n,e.canonical.y/n,1/n/c.$,1/n/c.$]}}class ti{constructor(e,n){this.min=e,this.max=n,this.center=c.aR([],c.aS([],this.min,this.max),.5)}quadrant(e){const n=[e%2==0,e<2],a=c.aT(this.min),l=c.aT(this.max);for(let u=0;u<n.length;u++)a[u]=n[u]?this.min[u]:this.center[u],l[u]=n[u]?this.center[u]:this.max[u];return l[2]=this.max[2],new ti(a,l)}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]}intersectsFrustum(e){let n=!0;for(let a=0;a<e.planes.length;a++){const l=this.intersectsPlane(e.planes[a]);if(l===0)return 0;l===1&&(n=!1)}return n?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let n=e[3],a=e[3];for(let l=0;l<3;l++)e[l]>0?(n+=e[l]*this.min[l],a+=e[l]*this.max[l]):(a+=e[l]*this.min[l],n+=e[l]*this.max[l]);return n>=0?2:a<0?0:1}}class wi{distanceToTile2d(e,n,a,l){const u=l.distanceX([e,n]),f=l.distanceY([e,n]);return Math.hypot(u,f)}getWrap(e,n,a){return a}getTileBoundingVolume(e,n,a,l){var u,f;let _=0,y=0;if(l!=null&&l.terrain){const w=new c.Z(e.z,n,e.z,e.x,e.y),S=l.terrain.getMinMaxElevation(w);_=(u=S.minElevation)!==null&&u!==void 0?u:Math.min(0,a),y=(f=S.maxElevation)!==null&&f!==void 0?f:Math.max(0,a)}const b=1<<e.z;return new ti([n+e.x/b,e.y/b,_],[n+(e.x+1)/b,(e.y+1)/b,y])}allowVariableZoom(e,n){const a=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,l=c.ah(78.5-a/2,0,60);return!!n.terrain||e.pitch>l}allowWorldCopies(){return!0}prepareNextFrame(){}}class $t{constructor(e,n,a){this.points=e,this.planes=n,this.aabb=a}static fromInvProjectionMatrix(e,n=1,a=0,l,u){const f=u?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],_=Math.pow(2,a),y=[[-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(P=>function(I,k,O,B){const N=c.aw([],I,k),U=1/N[3]/O*B;return c.aY(N,N,[U,U,1/N[3],U])}(P,e,n,_));l&&function(P,I,k,O){const B=O?4:0,N=O?0:4;let U=0;const q=[],$=[];for(let G=0;G<4;G++){const te=c.aU([],P[G+N],P[G+B]),ue=c.aZ(te);c.aR(te,te,1/ue),q.push(ue),$.push(te)}for(let G=0;G<4;G++){const te=c.a_(P[G+B],$[G],k);U=te!==null&&te>=0?Math.max(U,te):Math.max(U,q[G])}const H=function(G,te){const ue=c.aU([],G[te[0]],G[te[1]]),ae=c.aU([],G[te[2]],G[te[1]]),oe=[0,0,0,0];return c.aV(oe,c.aW([],ue,ae)),oe[3]=-c.aX(oe,G[te[0]]),oe}(P,I),K=function(G,te){const ue=c.a$(G),ae=c.b0([],G,1/ue),oe=c.aU([],te,c.aR([],ae,c.aX(te,ae))),he=c.a$(oe);if(he>0){const we=Math.sqrt(1-ae[3]*ae[3]),Se=c.aR([],ae,-ae[3]),ye=c.aS([],Se,c.aR([],oe,we/he));return c.b1(te,ye)}return null}(k,H);if(K!==null){const G=K/c.aX($[0],H);U=Math.min(U,G)}for(let G=0;G<4;G++){const te=Math.min(U,q[G]);P[G+N]=[P[G+B][0]+$[G][0]*te,P[G+B][1]+$[G][1]*te,P[G+B][2]+$[G][2]*te,1]}}(y,f[0],l,u);const b=f.map(P=>{const I=c.aU([],y[P[0]],y[P[1]]),k=c.aU([],y[P[2]],y[P[1]]),O=c.aV([],c.aW([],I,k)),B=-c.aX(O,y[P[1]]);return O.concat(B)}),w=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],S=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const P of y)for(let I=0;I<3;I++)w[I]=Math.min(w[I],P[I]),S[I]=Math.max(S[I],P[I]);return new $t(y,b,new ti(w,S))}}class bt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,a){return this._helper.interpolatePadding(e,n,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n,a=!0){this._helper.resize(e,n,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,n){}constructor(e,n,a,l,u){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new bi({calcMatrices:()=>{this._calcMatrices()},getConstrained:(f,_)=>this.getConstrained(f,_)},e,n,a,l,u),this._coveringTilesDetailsProvider=new wi}clone(){const e=new bt;return e.apply(this),e}apply(e,n,a){this._helper.apply(e,n,a)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const n=[new c.b2(0,e)];if(this._helper._renderWorldCopies){const a=this.screenPointToMercatorCoordinate(new c.P(0,0)),l=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,0)),u=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,this._helper._height)),f=this.screenPointToMercatorCoordinate(new c.P(0,this._helper._height)),_=Math.floor(Math.min(a.x,l.x,u.x,f.x)),y=Math.floor(Math.max(a.x,l.x,u.x,f.x)),b=1;for(let w=_-b;w<=y+b;w++)w!==0&&n.push(new c.b2(w,e))}return n}getCameraFrustum(){return $t.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const n=this.screenPointToLocation(this.centerPoint,e),a=e?e.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(a)}setLocationAtPoint(e,n){const a=c.aj(this.elevation,this.center.lat),l=this.screenPointToMercatorCoordinateAtZ(n,a),u=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,a),f=c.a1.fromLngLat(e),_=new c.a1(f.x-(l.x-u.x),f.y-(l.y-u.y));this.setCenter(_==null?void 0:_.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,n){return n?this.coordinatePoint(c.a1.fromLngLat(e),n.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(c.a1.fromLngLat(e))}screenPointToLocation(e,n){var a;return(a=this.screenPointToMercatorCoordinate(e,n))===null||a===void 0?void 0:a.toLngLat()}screenPointToMercatorCoordinate(e,n){if(n){const a=n.pointCoordinate(e);if(a!=null)return a}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,n){const a=n||0,l=[e.x,e.y,0,1],u=[e.x,e.y,1,1];c.aw(l,l,this._pixelMatrixInverse),c.aw(u,u,this._pixelMatrixInverse);const f=l[3],_=u[3],y=l[1]/f,b=u[1]/_,w=l[2]/f,S=u[2]/_,P=w===S?0:(a-w)/(S-w);return new c.a1(c.C.number(l[0]/f,u[0]/_,P)/this.worldSize,c.C.number(y,b,P)/this.worldSize,a)}coordinatePoint(e,n=0,a=this._pixelMatrix){const l=[e.x*this.worldSize,e.y*this.worldSize,n,1];return c.aw(l,l,a),new c.P(l[0]/l[3],l[1]/l[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Y(this));return new Dt().extend(this.screenPointToLocation(new c.P(0,e))).extend(this.screenPointToLocation(new c.P(this._helper._width,e))).extend(this.screenPointToLocation(new c.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new c.P(0,this._helper._height)))}isPointOnMapSurface(e,n){return n?n.pointCoordinate(e)!=null:e.y>this.height/2-Y(this)}calculatePosMatrix(e,n=!1,a){var l;const u=(l=e.key)!==null&&l!==void 0?l:c.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),f=n?this._alignedPosMatrixCache:this._posMatrixCache;if(f.has(u)){const b=f.get(u);return a?b.f32:b.f64}const _=ie(e,this.worldSize);c.O(_,n?this._alignedProjMatrix:this._viewProjMatrix,_);const y={f64:_,f32:new Float32Array(_)};return f.set(u,y),a?y.f32:y.f64}calculateFogMatrix(e){const n=e.key,a=this._fogMatrixCacheF32;if(a.has(n))return a.get(n);const l=ie(e,this.worldSize);return c.O(l,this._fogMatrix,l),a.set(n,new Float32Array(l)),a.get(n)}getConstrained(e,n){n=c.ah(+n,this.minZoom,this.maxZoom);const a={center:new c.S(e.lng,e.lat),zoom:n};let l=this._helper._lngRange;!this._helper._renderWorldCopies&&l===null&&(l=[-179.9999999999,179.9999999999]);const u=this.tileSize*c.af(a.zoom);let f=0,_=u,y=0,b=u,w=0,S=0;const{x:P,y:I}=this.size;if(this._helper._latRange){const q=this._helper._latRange;f=c.U(q[1])*u,_=c.U(q[0])*u,_-f<I&&(w=I/(_-f))}l&&(y=c.aO(c.V(l[0])*u,0,u),b=c.aO(c.V(l[1])*u,0,u),b<y&&(b+=u),b-y<P&&(S=P/(b-y)));const{x:k,y:O}=R(u,e);let B,N;const U=Math.max(S||0,w||0);if(U){const q=new c.P(S?(b+y)/2:k,w?(_+f)/2:O);return a.center=Z(u,q).wrap(),a.zoom+=c.ak(U),a}if(this._helper._latRange){const q=I/2;O-q<f&&(N=f+q),O+q>_&&(N=_-q)}if(l){const q=(y+b)/2;let $=k;this._helper._renderWorldCopies&&($=c.aO(k,q-u/2,q+u/2));const H=P/2;$-H<y&&(B=y+H),$+H>b&&(B=b-H)}if(B!==void 0||N!==void 0){const q=new c.P(B??k,N??O);a.center=Z(u,q).wrap()}return a}calculateCenterFromCameraLngLatAlt(e,n,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,a,l)}_calculateNearFarZIfNeeded(e,n,a){if(!this._helper.autoCalculateNearFarZ)return;const l=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),u=e-l*this._helper._pixelPerMeter/Math.cos(n),f=l<0?u:e,_=Math.PI/2+this.pitchInRadians,y=c.ae(this.fov)*(Math.abs(Math.cos(c.ae(this.roll)))*this.height+Math.abs(Math.sin(c.ae(this.roll)))*this.width)/this.height*(.5+a.y/this.height),b=Math.sin(y)*f/Math.sin(c.ah(Math.PI-_-y,.01,Math.PI-.01)),w=Y(this),S=Math.atan(w/this._helper.cameraToCenterDistance),P=c.ae(.75),I=S>P?2*S*(.5+a.y/(2*w)):P,k=Math.sin(I)*f/Math.sin(c.ah(Math.PI-_-I,.01,Math.PI-.01)),O=Math.min(b,k);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*O+f),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,n=R(this.worldSize,this.center),a=n.x,l=n.y;this._helper._pixelPerMeter=c.aj(1,this.center.lat)*this.worldSize;const u=c.ae(Math.min(this.pitch,D)),f=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(u));let _;this._calculateNearFarZIfNeeded(f,u,e),_=new Float64Array(16),c.b4(_,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),c.aq(this._invProjMatrix,_),_[8]=2*-e.x/this._helper._width,_[9]=2*e.y/this._helper._height,this._projectionMatrix=c.b5(_),c.N(_,_,[1,-1,1]),c.M(_,_,[0,0,-this._helper.cameraToCenterDistance]),c.b6(_,_,-this.rollInRadians),c.b7(_,_,this.pitchInRadians),c.b6(_,_,-this.bearingInRadians),c.M(_,_,[-a,-l,0]),this._mercatorMatrix=c.N([],_,[this.worldSize,this.worldSize,this.worldSize]),c.N(_,_,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=c.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,_),c.M(_,_,[0,0,-this.elevation]),this._viewProjMatrix=_,this._invViewProjMatrix=c.aq([],_);const y=[0,0,-1,1];c.aw(y,y,this._invViewProjMatrix),this._cameraPosition=[y[0]/y[3],y[1]/y[3],y[2]/y[3]],this._fogMatrix=new Float64Array(16),c.b4(this._fogMatrix,this.fovInRadians,this.width/this.height,f,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,c.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),c.M(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),c.b6(this._fogMatrix,this._fogMatrix,-this.rollInRadians),c.b7(this._fogMatrix,this._fogMatrix,this.pitchInRadians),c.b6(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),c.M(this._fogMatrix,this._fogMatrix,[-a,-l,0]),c.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),c.M(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=c.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,_);const b=this._helper._width%2/2,w=this._helper._height%2/2,S=Math.cos(this.bearingInRadians),P=Math.sin(-this.bearingInRadians),I=a-Math.round(a)+S*b+P*w,k=l-Math.round(l)+S*w+P*b,O=new Float64Array(_);if(c.M(O,O,[I>.5?I-1:I,k>.5?k-1:k,0]),this._alignedProjMatrix=O,_=c.aq(new Float64Array(16),this._pixelMatrix),!_)throw new Error("failed to invert matrix");this._pixelMatrixInverse=_,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new c.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return c.aw(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=c.aj(1,this.center.lat)*this.worldSize;return le(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,n){const a=c.a1.fromLngLat(e),l=[a.x*this.worldSize,a.y*this.worldSize,n,1];return c.aw(l,l,this._viewProjMatrix),l[2]/l[3]}getProjectionData(e){const{overscaledTileID:n,aligned:a,applyTerrainMatrix:l}=e,u=this._helper.getMercatorTileCoordinates(n),f=n?this.calculatePosMatrix(n,a,!0):null;let _;return _=n&&n.terrainRttPosMatrix32f&&l?n.terrainRttPosMatrix32f:f||c.b8(),{mainMatrix:_,tileMercatorCoords:u,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:_}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,n,a){return 1}transformLightDirection(e){return c.aT(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,n,a,l){const u=this.calculatePosMatrix(a);let f;l?(f=[e,n,l(e,n),1],c.aw(f,f,u)):(f=[e,n,0,1],qn(f,f,u));const _=f[3];return{point:new c.P(f[0]/_,f[1]/_),signedDistanceFromCamera:_,isOccluded:!1}}populateCache(e){for(const n of e)this.calculatePosMatrix(n)}getMatrixForModel(e,n){const a=c.a1.fromLngLat(e,n),l=a.meterInMercatorCoordinateUnits(),u=c.b9();return c.M(u,u,[a.x,a.y,a.z]),c.b6(u,u,Math.PI),c.b7(u,u,Math.PI/2),c.N(u,u,[-l,l,l]),u}getProjectionDataForCustomLayer(e=!0){const n=new c.Z(0,0,0,0,0),a=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:e}),l=ie(n,this.worldSize);c.O(l,this._viewProjMatrix,l),a.tileMercatorCoords=[0,0,1,1];const u=[c.$,c.$,this.worldSize/this._helper.pixelsPerMeter],f=c.ba();return c.N(f,l,u),a.fallbackMatrix=f,a.mainMatrix=f,a}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function kl(){c.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Ti(h){if(h.useSlerp)if(h.k<1){const e=c.bb(h.startEulerAngles.roll,h.startEulerAngles.pitch,h.startEulerAngles.bearing),n=c.bb(h.endEulerAngles.roll,h.endEulerAngles.pitch,h.endEulerAngles.bearing),a=new Float64Array(4);c.bc(a,e,n,h.k);const l=c.bd(a);h.tr.setRoll(l.roll),h.tr.setPitch(l.pitch),h.tr.setBearing(l.bearing)}else h.tr.setRoll(h.endEulerAngles.roll),h.tr.setPitch(h.endEulerAngles.pitch),h.tr.setBearing(h.endEulerAngles.bearing);else h.tr.setRoll(c.C.number(h.startEulerAngles.roll,h.endEulerAngles.roll,h.k)),h.tr.setPitch(c.C.number(h.startEulerAngles.pitch,h.endEulerAngles.pitch,h.k)),h.tr.setBearing(c.C.number(h.startEulerAngles.bearing,h.endEulerAngles.bearing,h.k))}function Bi(h,e,n,a,l){const u=l.padding,f=R(l.worldSize,n.getNorthWest()),_=R(l.worldSize,n.getNorthEast()),y=R(l.worldSize,n.getSouthEast()),b=R(l.worldSize,n.getSouthWest()),w=c.ae(-a),S=f.rotate(w),P=_.rotate(w),I=y.rotate(w),k=b.rotate(w),O=new c.P(Math.max(S.x,P.x,k.x,I.x),Math.max(S.y,P.y,k.y,I.y)),B=new c.P(Math.min(S.x,P.x,k.x,I.x),Math.min(S.y,P.y,k.y,I.y)),N=O.sub(B),U=(l.width-(u.left+u.right+e.left+e.right))/N.x,q=(l.height-(u.top+u.bottom+e.top+e.bottom))/N.y;if(q<0||U<0)return void kl();const $=Math.min(c.ak(l.scale*Math.min(U,q)),h.maxZoom),H=c.P.convert(h.offset),K=new c.P((e.left-e.right)/2,(e.top-e.bottom)/2).rotate(c.ae(a)),G=H.add(K).mult(l.scale/c.af($));return{center:Z(l.worldSize,f.add(y).div(2).sub(G)),zoom:$,bearing:a}}class _i{get useGlobeControls(){return!1}handlePanInertia(e,n){const a=e.mag(),l=Math.abs(Y(n));return{easingOffset:e.mult(Math.min(.75*l/a,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(e,n){e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta),e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta)}handleMapControlsPan(e,n,a){e.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(a,e.around)}cameraForBoxAndBearing(e,n,a,l,u){return Bi(e,n,a,l,u)}handleJumpToCenterZoom(e,n){e.zoom!==(n.zoom!==void 0?+n.zoom:e.zoom)&&e.setZoom(+n.zoom),n.center!==void 0&&e.setCenter(c.S.convert(n.center))}handleEaseTo(e,n){const a=e.zoom,l=e.padding,u={roll:e.roll,pitch:e.pitch,bearing:e.bearing},f={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},_=n.zoom!==void 0,y=!e.isPaddingEqual(n.padding);let b=!1;const w=_?+n.zoom:e.zoom;let S=e.centerPoint.add(n.offsetAsPoint);const P=e.screenPointToLocation(S),{center:I,zoom:k}=e.getConstrained(c.S.convert(n.center||P),w??a);da(e,I);const O=R(e.worldSize,P),B=R(e.worldSize,I).sub(O),N=c.af(k-a);return b=k!==a,{easeFunc:U=>{if(b&&e.setZoom(c.C.number(a,k,U)),c.be(u,f)||Ti({startEulerAngles:u,endEulerAngles:f,tr:e,k:U,useSlerp:u.roll!=f.roll}),y&&(e.interpolatePadding(l,n.padding,U),S=e.centerPoint.add(n.offsetAsPoint)),n.around)e.setLocationAtPoint(n.around,n.aroundPoint);else{const q=c.af(e.zoom-a),$=k>a?Math.min(2,N):Math.max(.5,N),H=Math.pow($,1-U),K=Z(e.worldSize,O.add(B.mult(U*H)).mult(q));e.setLocationAtPoint(e.renderWorldCopies?K.wrap():K,S)}},isZooming:b,elevationCenter:I}}handleFlyTo(e,n){const a=n.zoom!==void 0,l=e.zoom,u=e.getConstrained(c.S.convert(n.center||n.locationAtOffset),a?+n.zoom:l),f=u.center,_=u.zoom;da(e,f);const y=R(e.worldSize,n.locationAtOffset),b=R(e.worldSize,f).sub(y),w=b.mag(),S=c.af(_-l);let P;if(n.minZoom!==void 0){const I=Math.min(+n.minZoom,l,_),k=e.getConstrained(f,I).zoom;P=c.af(k-l)}return{easeFunc:(I,k,O,B)=>{e.setZoom(I===1?_:l+c.ak(k));const N=I===1?f:Z(e.worldSize,y.add(b.mult(O)).mult(k));e.setLocationAtPoint(e.renderWorldCopies?N.wrap():N,B)},scaleOfZoom:S,targetCenter:f,scaleOfMinZoom:P,pixelPathLength:w}}}class Pt{constructor(e,n,a){this.blendFunction=e,this.blendColor=n,this.mask=a}}Pt.Replace=[1,0],Pt.disabled=new Pt(Pt.Replace,c.bf.transparent,[!1,!1,!1,!1]),Pt.unblended=new Pt(Pt.Replace,c.bf.transparent,[!0,!0,!0,!0]),Pt.alphaBlended=new Pt([1,771],c.bf.transparent,[!0,!0,!0,!0]);const bn=2305;class $e{constructor(e,n,a){this.enable=e,this.mode=n,this.frontFace=a}}$e.disabled=new $e(!1,1029,bn),$e.backCCW=new $e(!0,1029,bn),$e.frontCCW=new $e(!0,1028,bn);class We{constructor(e,n,a){this.func=e,this.mask=n,this.range=a}}We.ReadOnly=!1,We.ReadWrite=!0,We.disabled=new We(519,We.ReadOnly,[0,1]);const Ir=7680;class lt{constructor(e,n,a,l,u,f){this.test=e,this.ref=n,this.mask=a,this.fail=l,this.depthFail=u,this.pass=f}}lt.disabled=new lt({func:519,mask:0},0,0,Ir,Ir,Ir);const Oi=new WeakMap;function vr(h){var e;if(Oi.has(h))return Oi.get(h);{const n=(e=h.getParameter(h.VERSION))===null||e===void 0?void 0:e.startsWith("WebGL 2.0");return Oi.set(h,n),n}}class br{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const n=e.context,a=n.gl;this._texFormat=a.RGBA,this._texType=a.UNSIGNED_BYTE;const l=new c.aL;l.emplaceBack(-1,-1),l.emplaceBack(2,-1),l.emplaceBack(-1,2);const u=new c.aN;u.emplaceBack(0,1,2),this._fullscreenTriangle=new yn(n.createVertexBuffer(l,Kr.members),n.createIndexBuffer(u),c.aM.simpleSegment(0,0,l.length,u.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(a.TEXTURE1);const f=a.createTexture();a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texImage2D(a.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(f),vr(a)&&(this._pbo=a.createBuffer(),a.bindBuffer(a.PIXEL_PACK_BUFFER,this._pbo),a.bufferData(a.PIXEL_PACK_BUFFER,4,a.STREAM_READ),a.bindBuffer(a.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,n){const a=this._updateCount;return this._readbackQueue?a>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():a>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,n),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,n=e.gl;e.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,n){const a=this._cachedRenderContext.context,l=a.gl;if(this._bindFramebuffer(),a.viewport.set([0,0,this._texWidth,this._texHeight]),a.clear({color:c.bf.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(a,l.TRIANGLES,We.disabled,lt.disabled,Pt.unblended,$e.disabled,((u,f)=>({u_input:u,u_output_expected:f}))(e,n),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&vr(l)){l.bindBuffer(l.PIXEL_PACK_BUFFER,this._pbo),l.readBuffer(l.COLOR_ATTACHMENT0),l.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null);const u=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);l.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:u}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&vr(e)){const n=e.clientWaitSync(this._readbackQueue.sync,0,0);if(n===e.WAIT_FAILED)return c.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=br._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let n=0;return n+=e[0]/256,n+=e[1]/65536,n+=e[2]/16777216,e[3]<127&&(n=-n),n/128}}const fa=c.$/128;function xo(h,e){const n=h.granularity!==void 0?Math.max(h.granularity,1):1,a=n+(h.generateBorders?2:0),l=n+(h.extendToNorthPole||h.generateBorders?1:0)+(h.extendToSouthPole||h.generateBorders?1:0),u=a+1,f=l+1,_=h.generateBorders?-1:0,y=h.generateBorders||h.extendToNorthPole?-1:0,b=n+(h.generateBorders?1:0),w=n+(h.generateBorders||h.extendToSouthPole?1:0),S=u*f,P=a*l*6,I=u*f>65536;if(I&&e==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const k=I||e==="32bit",O=new Int16Array(2*S);let B=0;for(let q=y;q<=w;q++)for(let $=_;$<=b;$++){let H=$/n*c.$;$===-1&&(H=-fa),$===n+1&&(H=c.$+fa);let K=q/n*c.$;q===-1&&(K=h.extendToNorthPole?c.bh:-fa),q===n+1&&(K=h.extendToSouthPole?c.bi:c.$+fa),O[B++]=H,O[B++]=K}const N=k?new Uint32Array(P):new Uint16Array(P);let U=0;for(let q=0;q<l;q++)for(let $=0;$<a;$++){const H=$+1+q*u,K=$+(q+1)*u,G=$+1+(q+1)*u;N[U++]=$+q*u,N[U++]=K,N[U++]=H,N[U++]=H,N[U++]=K,N[U++]=G}return{vertices:O.buffer.slice(0),indices:N.buffer.slice(0),uses32bitIndices:k}}const Kn=new c.aK({fill:new c.bj(128,2),line:new c.bj(512,0),tile:new c.bj(128,32),stencil:new c.bj(128,1),circle:3});class Is{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Ji.projectionGlobe}get vertexShaderPreludeCode(){return Ji.projectionMercator.vertexSource}get subdivisionGranularity(){return Kn}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new br(e));const n=c.U(this._errorQueryLatitudeDegrees),a=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,l=this._errorMeasurement.updateErrorLoop(n,a),u=Ee.now();l!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=l,this._errorMeasurementLastChangeTime=u);const f=Math.min(Math.max((u-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=c.bk(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,c.bl(f))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,n,a,l,u){const f=(u==="stencil"?Kn.stencil:Kn.tile).getGranularityForZoomLevel(n.z);return this._getMesh(e,{granularity:f,generateBorders:a,extendToNorthPole:n.y===0&&l,extendToSouthPole:n.y===(1<<n.z)-1&&l})}_getMesh(e,n){const a=this._getMeshKey(n);if(a in this._tileMeshCache)return this._tileMeshCache[a];const l=function(u,f){const _=xo(f,"16bit"),y=c.aL.deserialize({arrayBuffer:_.vertices,length:_.vertices.byteLength/2/2}),b=c.aN.deserialize({arrayBuffer:_.indices,length:_.indices.byteLength/2/3});return new yn(u.createVertexBuffer(y,Kr.members),u.createIndexBuffer(b),c.aM.simpleSegment(0,0,y.length,b.length))}(e,n);return this._tileMeshCache[a]=l,l}recalculate(e){}hasTransition(){const e=Ee.now();let n=!1;return n=n||(e-this._errorMeasurementLastChangeTime)/1e3<.7,n=n||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,n}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const ma=new c.r({type:new c.D(c.v.projection.type)});class ga extends c.E{constructor(e){super(),this._transitionable=new c.t(ma),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.F(0)),this._mercatorProjection=new it,this._verticalPerspectiveProjection=new Is}get transitionState(){const e=this.properties.get("type");if(typeof e=="string"&&e==="mercator")return 0;if(typeof e=="string"&&e==="vertical-perspective")return 1;if(e instanceof c.bm){if(e.from==="vertical-perspective"&&e.to==="mercator")return 1-e.transition;if(e.from==="mercator"&&e.to==="vertical-perspective")return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,n,a,l,u){return this.currentProjection.getMeshFromTileID(e,n,a,l,u)}setProjection(e){this._transitionable.setValue("type",(e==null?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function _a(h){const e=Jn(h.worldSize,h.center.lat);return 2*Math.PI*e}function Qi(h,e,n,a,l){const u=1/(1<<l),f=e/c.$*u+a*u,_=c.bo((h/c.$*u+n*u)*Math.PI*2+Math.PI,2*Math.PI),y=2*Math.atan(Math.exp(Math.PI-f*Math.PI*2))-.5*Math.PI,b=Math.cos(y),w=new Float64Array(3);return w[0]=Math.sin(_)*b,w[1]=Math.sin(y),w[2]=Math.cos(_)*b,w}function ii(h){return function(e,n){const a=Math.cos(n),l=new Float64Array(3);return l[0]=Math.sin(e)*a,l[1]=Math.sin(n),l[2]=Math.cos(e)*a,l}(h.lng*Math.PI/180,h.lat*Math.PI/180)}function Jn(h,e){return h/(2*Math.PI)/Math.cos(e*Math.PI/180)}function Cs(h){const e=Math.asin(h[1])/Math.PI*180,n=Math.sqrt(h[0]*h[0]+h[2]*h[2]);if(n>1e-6){const a=h[0]/n,l=Math.acos(h[2]/n),u=(a>0?l:-l)/Math.PI*180;return new c.S(c.aO(u,-180,180),e)}return new c.S(0,e)}function wn(h){return Math.cos(h*Math.PI/180)}function Ft(h,e){const n=wn(h),a=wn(e);return c.ak(a/n)}function zl(h,e){const n=h.rotate(e.bearingInRadians),a=e.zoom+Ft(e.center.lat,0),l=c.bk(1/wn(e.center.lat),1/wn(Math.min(Math.abs(e.center.lat),60)),c.bn(a,7,3,0,1)),u=360/_a({worldSize:e.worldSize,center:{lat:e.center.lat}});return new c.S(e.center.lng-n.x*u*l,c.ah(e.center.lat+n.y*u,-c.ai,c.ai))}function Es(h){const e=.5*h,n=Math.sin(e),a=Math.cos(e);return Math.log(n+a)-Math.log(a-n)}function vo(h,e,n,a){const l=h.lat+n*a;if(Math.abs(n)>1){const u=(Math.sign(h.lat+n)!==Math.sign(h.lat)?-Math.abs(h.lat):Math.abs(h.lat))*Math.PI/180,f=Math.abs(h.lat+n)*Math.PI/180,_=Es(u+a*(f-u)),y=Es(u),b=Es(f);return new c.S(h.lng+e*((_-y)/(b-y)),l)}return new c.S(h.lng+e*a,l)}class Hc{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,n,a,l){const u=`${e.z}_${e.x}_${e.y}_${l!=null&&l.terrain?"t":""}`,f=this._cache.get(u);if(f)return f;const _=this._cachePrevious.get(u);if(_)return this._cache.set(u,_),_;const y=this._boundingVolumeFactory(e,n,a,l);return this._cache.set(u,y),this._hadAnyChanges=!0,y}}class Qn{constructor(e,n,a,l){this.min=a,this.max=l,this.points=e,this.planes=n}static fromAabb(e,n){const a=[];for(let l=0;l<8;l++)a.push([1&~l?e[0]:n[0],(l>>1&1)==1?n[1]:e[1],(l>>2&1)==1?n[2]:e[2]]);return new Qn(a,[[-1,0,0,n[0]],[1,0,0,-e[0]],[0,-1,0,n[1]],[0,1,0,-e[1]],[0,0,-1,n[2]],[0,0,1,-e[2]]],e,n)}static fromCenterSizeAngles(e,n,a){const l=c.br([],a[0],a[1],a[2]),u=c.bs([],[n[0],0,0],l),f=c.bs([],[0,n[1],0],l),_=c.bs([],[0,0,n[2]],l),y=[...e],b=[...e];for(let S=0;S<8;S++)for(let P=0;P<3;P++){const I=e[P]+u[P]*(1&~S?-1:1)+f[P]*((S>>1&1)==1?1:-1)+_[P]*((S>>2&1)==1?1:-1);y[P]=Math.min(y[P],I),b[P]=Math.max(b[P],I)}const w=[];for(let S=0;S<8;S++){const P=[...e];c.aS(P,P,c.aR([],u,1&~S?-1:1)),c.aS(P,P,c.aR([],f,(S>>1&1)==1?1:-1)),c.aS(P,P,c.aR([],_,(S>>2&1)==1?1:-1)),w.push(P)}return new Qn(w,[[...u,-c.aX(u,w[0])],[...f,-c.aX(f,w[0])],[..._,-c.aX(_,w[0])],[-u[0],-u[1],-u[2],-c.aX(u,w[7])],[-f[0],-f[1],-f[2],-c.aX(f,w[7])],[-_[0],-_[1],-_[2],-c.aX(_,w[7])]],y,b)}intersectsFrustum(e){let n=!0;const a=this.points.length,l=this.planes.length,u=e.planes.length,f=e.points.length;for(let _=0;_<u;_++){const y=e.planes[_];let b=0;for(let w=0;w<a;w++){const S=this.points[w];y[0]*S[0]+y[1]*S[1]+y[2]*S[2]+y[3]>=0&&b++}if(b===0)return 0;b<a&&(n=!1)}if(n)return 2;for(let _=0;_<l;_++){const y=this.planes[_];let b=0;for(let w=0;w<f;w++){const S=e.points[w];y[0]*S[0]+y[1]*S[1]+y[2]*S[2]+y[3]>=0&&b++}if(b===0)return 0}return 1}intersectsPlane(e){const n=this.points.length;let a=0;for(let l=0;l<n;l++){const u=this.points[l];e[0]*u[0]+e[1]*u[1]+e[2]*u[2]+e[3]>=0&&a++}return a===n?2:a===0?0:1}}function ui(h,e,n){const a=h-e;return a<0?-a:Math.max(0,a-n)}function As(h,e,n,a,l){const u=h-n;let f;return f=u<0?Math.min(-u,1+u-l):u>1?Math.min(Math.max(u-l,0),1-u):0,Math.max(f,ui(e,a,l))}class wr{constructor(){this._boundingVolumeCache=new Hc(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,n,a,l){const u=1<<a.z,f=1/u,_=a.x/u,y=a.y/u;let b=2;return b=Math.min(b,As(e,n,_,y,f)),b=Math.min(b,As(e,n,_+.5,-y-f,f)),b=Math.min(b,As(e,n,_+.5,2-y-f,f)),b}getWrap(e,n,a){const l=1<<n.z,u=1/l,f=n.x/l,_=ui(e.x,f,u),y=ui(e.x,f-1,u),b=ui(e.x,f+1,u),w=Math.min(_,y,b);return w===b?1:w===y?-1:0}allowVariableZoom(e,n){return Re(e,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,n,a,l){return this._boundingVolumeCache.getTileBoundingVolume(e,n,a,l)}_computeTileBoundingVolume(e,n,a,l){var u,f;let _=0,y=0;if(l!=null&&l.terrain){const b=new c.Z(e.z,n,e.z,e.x,e.y),w=l.terrain.getMinMaxElevation(b);_=(u=w.minElevation)!==null&&u!==void 0?u:Math.min(0,a),y=(f=w.maxElevation)!==null&&f!==void 0?f:Math.max(0,a)}if(_/=c.bu,y/=c.bu,_+=1,y+=1,e.z<=0)return Qn.fromAabb([-y,-y,-y],[y,y,y]);if(e.z===1)return Qn.fromAabb([e.x===0?-y:0,e.y===0?0:-y,-y],[e.x===0?0:y,e.y===0?y:0,y]);{const b=[Qi(0,0,e.x,e.y,e.z),Qi(c.$,0,e.x,e.y,e.z),Qi(c.$,c.$,e.x,e.y,e.z),Qi(0,c.$,e.x,e.y,e.z)],w=[];for(const oe of b)w.push(c.aR([],oe,y));if(y!==_)for(const oe of b)w.push(c.aR([],oe,_));e.y===0&&w.push([0,1,0]),e.y===(1<<e.z)-1&&w.push([0,-1,0]);const S=[1,1,1],P=[-1,-1,-1];for(const oe of w)for(let he=0;he<3;he++)S[he]=Math.min(S[he],oe[he]),P[he]=Math.max(P[he],oe[he]);const I=Qi(c.$/2,c.$/2,e.x,e.y,e.z),k=c.aW([],[0,1,0],I);c.aV(k,k);const O=c.aW([],I,k);c.aV(O,O);const B=c.aW([],b[2],b[1]);c.aV(B,B);const N=c.aW([],b[0],b[3]);c.aV(N,N),w.push(c.aR([],I,y)),e.y>=(1<<e.z)/2&&w.push(c.aR([],Qi(c.$/2,0,e.x,e.y,e.z),y)),e.y<(1<<e.z)/2&&w.push(c.aR([],Qi(c.$/2,c.$,e.x,e.y,e.z),y));const U=ks(I,w),q=ks(O,w),$=[-I[0],-I[1],-I[2],U.max],H=[I[0],I[1],I[2],-U.min],K=[-O[0],-O[1],-O[2],q.max],G=[O[0],O[1],O[2],-q.min],te=[...B,0],ue=[...N,0],ae=[];return e.y===0?ae.push(c.bt(ue,te,$),c.bt(ue,te,H)):ae.push(c.bt(K,te,$),c.bt(K,te,H),c.bt(K,ue,$),c.bt(K,ue,H)),e.y===(1<<e.z)-1?ae.push(c.bt(ue,te,$),c.bt(ue,te,H)):ae.push(c.bt(G,te,$),c.bt(G,te,H),c.bt(G,ue,$),c.bt(G,ue,H)),new Qn(ae,[$,H,K,G,te,ue],S,P)}}}function ks(h,e){let n=1/0,a=-1/0;for(const l of e){const u=c.aX(h,l);n=Math.min(n,u),a=Math.max(a,u)}return{min:n,max:a}}class zs{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,a){return this._helper.interpolatePadding(e,n,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n){this._helper.resize(e,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(){this._cachedClippingPlane=c.bv(),this._projectionMatrix=c.b9(),this._globeViewProjMatrix32f=c.b8(),this._globeViewProjMatrixNoCorrection=c.b9(),this._globeViewProjMatrixNoCorrectionInverted=c.b9(),this._globeProjMatrixInverted=c.b9(),this._cameraPosition=c.bp(),this._globeLatitudeErrorCorrectionRadians=0,this._helper=new bi({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,n)=>this.getConstrained(e,n)}),this._coveringTilesDetailsProvider=new wr}clone(){const e=new zs;return e.apply(this),e}apply(e,n){this._globeLatitudeErrorCorrectionRadians=n||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=c.bp();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:n,applyGlobeMatrix:a}=e,l=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:l,clippingPlane:this._cachedClippingPlane,projectionTransition:a?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const n=this.pitchInRadians,a=this.cameraToCenterDistance/e,l=Math.sin(n)*a,u=Math.cos(n)*a+1,f=1/Math.sqrt(l*l+u*u)*1;let _=-l,y=u;const b=Math.sqrt(_*_+y*y);_/=b,y/=b;const w=[0,_,y];c.bw(w,w,[0,0,0],-this.bearingInRadians),c.bx(w,w,[0,0,0],-1*this.center.lat*Math.PI/180),c.by(w,w,[0,0,0],this.center.lng*Math.PI/180);const S=1/c.aZ(w);return c.aR(w,w,S),[...w,-f*S]}isLocationOccluded(e){return!this.isSurfacePointVisible(ii(e))}transformLightDirection(e){const n=this._helper._center.lng*Math.PI/180,a=this._helper._center.lat*Math.PI/180,l=Math.cos(a),u=[Math.sin(n)*l,Math.sin(a),Math.cos(n)*l],f=[u[2],0,-u[0]],_=[0,0,0];c.aW(_,f,u),c.aV(f,f),c.aV(_,_);const y=[0,0,0];return c.aV(y,[f[0]*e[0]+_[0]*e[1]+u[0]*e[2],f[1]*e[0]+_[1]*e[1]+u[1]*e[2],f[2]*e[0]+_[2]*e[1]+u[2]*e[2]]),y}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,n,a){const l=function(_,y,b){const w=1/(1<<b.z);return new c.a1(_/c.$*w+b.x*w,y/c.$*w+b.y*w)}(e,n,a.canonical),u=(f=l.y,[c.bo(l.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-f*Math.PI*2))-.5*Math.PI]);var f;return this.getCircleRadiusCorrection()/Math.cos(u[1])}projectTileCoordinates(e,n,a,l){const u=a.canonical,f=Qi(e,n,u.x,u.y,u.z),_=1+(l?l(e,n):0)/c.bu,y=[f[0]*_,f[1]*_,f[2]*_,1];c.aw(y,y,this._globeViewProjMatrixNoCorrection);const b=this._cachedClippingPlane,w=b[0]*f[0]+b[1]*f[1]+b[2]*f[2]+b[3]<0;return{point:new c.P(y[0]/y[3],y[1]/y[3]),signedDistanceFromCamera:y[3],isOccluded:w}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=Jn(this.worldSize,this.center.lat),n=c.ba(),a=c.ba();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),c.b4(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const l=this.centerOffset;n[8]=2*-l.x/this._helper._width,n[9]=2*l.y/this._helper._height,this._projectionMatrix=c.b5(n),this._globeProjMatrixInverted=c.ba(),c.aq(this._globeProjMatrixInverted,n),c.M(n,n,[0,0,-this.cameraToCenterDistance]),c.b6(n,n,this.rollInRadians),c.b7(n,n,-this.pitchInRadians),c.b6(n,n,this.bearingInRadians),c.M(n,n,[0,0,-e]);const u=c.bp();u[0]=e,u[1]=e,u[2]=e,c.b7(a,n,this.center.lat*Math.PI/180),c.bz(a,a,-this.center.lng*Math.PI/180),c.N(a,a,u),this._globeViewProjMatrixNoCorrection=a,c.b7(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),c.bz(n,n,-this.center.lng*Math.PI/180),c.N(n,n,u),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=c.ba(),c.aq(this._globeViewProjMatrixNoCorrectionInverted,a);const f=c.bp();this._cameraPosition=c.bp(),this._cameraPosition[2]=this.cameraToCenterDistance/e,c.bw(this._cameraPosition,this._cameraPosition,f,-this.rollInRadians),c.bx(this._cameraPosition,this._cameraPosition,f,this.pitchInRadians),c.bw(this._cameraPosition,this._cameraPosition,f,-this.bearingInRadians),c.aS(this._cameraPosition,this._cameraPosition,[0,0,1]),c.bx(this._cameraPosition,this._cameraPosition,f,-this.center.lat*Math.PI/180),c.by(this._cameraPosition,this._cameraPosition,f,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const _=c.b5(this._globeViewProjMatrixNoCorrectionInverted);c.N(_,_,[1,1,-1]),this._cachedFrustum=$t.fromInvProjectionMatrix(_,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){c.w("calculateFogMatrix is not supported on globe projection.");const n=c.ba();return c.ag(n),n}getVisibleUnwrappedCoordinates(e){return[new c.b2(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&c.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){if(!this._globeViewProjMatrixNoCorrection)return 1;const a=ii(e);c.aR(a,a,1+n/c.bu);const l=c.bv();return c.aw(l,[a[0],a[1],a[2],1],this._globeViewProjMatrixNoCorrection),l[2]/l[3]}populateCache(e){}getBounds(){const e=.5*this.width,n=.5*this.height,a=[new c.P(0,0),new c.P(e,0),new c.P(this.width,0),new c.P(this.width,n),new c.P(this.width,this.height),new c.P(e,this.height),new c.P(0,this.height),new c.P(0,n)],l=[];for(const S of a)l.push(this.unprojectScreenPoint(S));let u=0,f=0,_=0,y=0;const b=this.center;for(const S of l){const P=c.bA(b.lng,S.lng),I=c.bA(b.lat,S.lat);P<f&&(f=P),P>u&&(u=P),I<y&&(y=I),I>_&&(_=I)}const w=[b.lng+f,b.lat+y,b.lng+u,b.lat+_];return this.isSurfacePointOnScreen([0,1,0])&&(w[3]=90,w[0]=-180,w[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(w[1]=-90,w[0]=-180,w[2]=180),new Dt(w)}getConstrained(e,n){const a=c.ah(e.lat,-c.ai,c.ai),l=c.ah(+n,this.minZoom+Ft(0,a),this.maxZoom);return{center:new c.S(e.lng,a),zoom:l}}calculateCenterFromCameraLngLatAlt(e,n,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,a,l)}setLocationAtPoint(e,n){const a=ii(this.unprojectScreenPoint(n)),l=ii(e),u=c.bp();c.bB(u);const f=c.bp();c.by(f,a,u,-this.center.lng*Math.PI/180),c.bx(f,f,u,this.center.lat*Math.PI/180);const _=l[0]*l[0]+l[2]*l[2],y=f[0]*f[0];if(_<y)return;const b=Math.sqrt(_-y),w=-b,S=c.bC(l[0],l[2],f[0],b),P=c.bC(l[0],l[2],f[0],w),I=c.bp();c.by(I,l,u,-S);const k=c.bC(I[1],I[2],f[1],f[2]),O=c.bp();c.by(O,l,u,-P);const B=c.bC(O[1],O[2],f[1],f[2]),N=.5*Math.PI,U=k>=-N&&k<=N,q=B>=-N&&B<=N;let $,H;if(U&&q){const ue=this.center.lng*Math.PI/180,ae=this.center.lat*Math.PI/180;c.bD(S,ue)+c.bD(k,ae)<c.bD(P,ue)+c.bD(B,ae)?($=S,H=k):($=P,H=B)}else if(U)$=S,H=k;else{if(!q)return;$=P,H=B}const K=$/Math.PI*180,G=H/Math.PI*180,te=this.center.lat;this.setCenter(new c.S(K,c.ah(G,-90,90))),this.setZoom(this.zoom+Ft(te,this.center.lat))}locationToScreenPoint(e,n){const a=ii(e);if(n){const l=n.getElevationForLngLatZoom(e,this._helper._tileZoom);c.aR(a,a,1+l/c.bu)}return this._projectSurfacePointToScreen(a)}_projectSurfacePointToScreen(e){const n=c.bv();return c.aw(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new c.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,n){if(n){const a=n.pointCoordinate(e);if(a)return a}return c.a1.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,n){var a;return(a=this.screenPointToMercatorCoordinate(e,n))===null||a===void 0?void 0:a.toLngLat()}isPointOnMapSurface(e,n){const a=this._cameraPosition,l=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(a,l)}getRayDirectionFromPixel(e){const n=c.bv();n[0]=e.x/this.width*2-1,n[1]=-1*(e.y/this.height*2-1),n[2]=1,n[3]=1,c.aw(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];const a=c.bp();a[0]=n[0]-this._cameraPosition[0],a[1]=n[1]-this._cameraPosition[1],a[2]=n[2]-this._cameraPosition[2];const l=c.bp();return c.aV(l,a),l}isSurfacePointVisible(e){const n=this._cachedClippingPlane;return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const n=c.bv();return c.aw(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(e,n){const a=c.aX(e,n),l=c.bp(),u=c.bp();c.aR(u,n,a),c.aU(l,e,u);const f=1-c.aX(l,l);if(f<0)return null;const _=c.aX(e,e)-1,y=-a+(a<0?1:-1)*Math.sqrt(f),b=_/y,w=y;return{tMin:Math.min(b,w),tMax:Math.max(b,w)}}unprojectScreenPoint(e){const n=this._cameraPosition,a=this.getRayDirectionFromPixel(e),l=this.rayPlanetIntersection(n,a);if(l){const w=c.bp();c.aS(w,n,[a[0]*l.tMin,a[1]*l.tMin,a[2]*l.tMin]);const S=c.bp();return c.aV(S,w),Cs(S)}const u=this._cachedClippingPlane,f=u[0]*a[0]+u[1]*a[1]+u[2]*a[2],_=-c.b1(u,n)/f,y=c.bp();if(_>0)c.aS(y,n,[a[0]*_,a[1]*_,a[2]*_]);else{const w=c.bp();c.aS(w,n,[2*a[0],2*a[1],2*a[2]]);const S=c.b1(this._cachedClippingPlane,w);c.aU(y,w,[this._cachedClippingPlane[0]*S,this._cachedClippingPlane[1]*S,this._cachedClippingPlane[2]*S])}const b=function(w){const S=c.bp();return S[0]=w[0]*-w[3],S[1]=w[1]*-w[3],S[2]=w[2]*-w[3],{center:S,radius:Math.sqrt(1-w[3]*w[3])}}(u);return Cs(function(w,S,P){const I=c.bp();c.aU(I,P,w);const k=c.bp();return c.bq(k,w,I,S/c.a$(I)),k}(b.center,b.radius,y))}getMatrixForModel(e,n){const a=c.S.convert(e),l=1/c.bu,u=c.b9();return c.bz(u,u,a.lng/180*Math.PI),c.b7(u,u,-a.lat/180*Math.PI),c.M(u,u,[0,0,1+n/c.bu]),c.b7(u,u,.5*Math.PI),c.N(u,u,[l,l,l]),u}getProjectionDataForCustomLayer(e=!0){const n=this.getProjectionData({overscaledTileID:new c.Z(0,0,0,0,0),applyGlobeMatrix:e});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(e){}}class Ls{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,a){return this._helper.interpolatePadding(e,n,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n,a=!0){this._helper.resize(e,n,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,n){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new bi({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,n)=>this.getConstrained(e,n)}),this._globeness=1,this._mercatorTransform=new bt,this._verticalPerspectiveTransform=new zs}clone(){const e=new Ls;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const n=this._mercatorTransform.getProjectionData(e),a=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?a.mainMatrix:n.mainMatrix,clippingPlane:a.clippingPlane,tileMercatorCoords:a.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return c.bk(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return c.bk(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,n,a){const l=this._mercatorTransform.getPitchedTextCorrection(e,n,a),u=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,n,a);return c.bk(l,u,this._globeness)}projectTileCoordinates(e,n,a,l){return this.currentTransform.projectTileCoordinates(e,n,a,l)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){return this.currentTransform.lngLatToCameraDepth(e,n)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,n){return this.currentTransform.getConstrained(e,n)}calculateCenterFromCameraLngLatAlt(e,n,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,a,l)}setLocationAtPoint(e,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,n),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,n),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,n){return this.currentTransform.locationToScreenPoint(e,n)}screenPointToMercatorCoordinate(e,n){return this.currentTransform.screenPointToMercatorCoordinate(e,n)}screenPointToLocation(e,n){return this.currentTransform.screenPointToLocation(e,n)}isPointOnMapSurface(e,n){return this.currentTransform.isPointOnMapSurface(e,n)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,n){return this.currentTransform.getMatrixForModel(e,n)}getProjectionDataForCustomLayer(e=!0){const n=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return n;const a=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return a.fallbackMatrix=n.mainMatrix,a}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class yi{get useGlobeControls(){return!0}handlePanInertia(e,n){const a=zl(e,n);return Math.abs(a.lng-n.center.lng)>180&&(a.lng=n.center.lng+179.5*Math.sign(a.lng-n.center.lng)),{easingCenter:a,easingOffset:new c.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,n){const a=e.around,l=n.screenPointToLocation(a);e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta);const u=n.zoom;e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta);const f=n.zoom-u;if(f===0)return;const _=c.bA(n.center.lng,l.lng),y=_/(Math.abs(_/180)+1),b=c.bA(n.center.lat,l.lat),w=n.getRayDirectionFromPixel(a),S=n.cameraPosition,P=-1*c.aX(S,w),I=c.bp();c.aS(I,S,[w[0]*P,w[1]*P,w[2]*P]);const k=c.aZ(I)-1,O=Math.exp(.5*-Math.max(k-.3,0)),B=Jn(n.worldSize,n.center.lat)/Math.min(n.width,n.height),N=c.bn(B,.9,.5,1,.25),U=(1-c.af(-f))*Math.min(O,N),q=n.center.lat,$=n.zoom,H=new c.S(n.center.lng+y*U,c.ah(n.center.lat+b*U,-c.ai,c.ai));n.setLocationAtPoint(l,a);const K=n.center,G=c.bn(Math.abs(_),45,85,0,1),te=c.bn(B,.75,.35,0,1),ue=Math.pow(Math.max(G,te),.25),ae=c.bA(K.lng,H.lng),oe=c.bA(K.lat,H.lat);n.setCenter(new c.S(K.lng+ae*ue,K.lat+oe*ue).wrap()),n.setZoom($+Ft(q,n.center.lat))}handleMapControlsPan(e,n,a){if(!e.panDelta)return;const l=n.center.lat,u=n.zoom;n.setCenter(zl(e.panDelta,n).wrap()),n.setZoom(u+Ft(l,n.center.lat))}cameraForBoxAndBearing(e,n,a,l,u){const f=Bi(e,n,a,l,u),_=n.left/u.width*2-1,y=(u.width-n.right)/u.width*2-1,b=n.top/u.height*-2+1,w=(u.height-n.bottom)/u.height*-2+1,S=c.bA(a.getWest(),a.getEast())<0,P=S?a.getEast():a.getWest(),I=S?a.getWest():a.getEast(),k=Math.max(a.getNorth(),a.getSouth()),O=Math.min(a.getNorth(),a.getSouth()),B=P+.5*c.bA(P,I),N=k+.5*c.bA(k,O),U=u.clone();U.setCenter(f.center),U.setBearing(f.bearing),U.setPitch(0),U.setRoll(0),U.setZoom(f.zoom);const q=U.modelViewProjectionMatrix,$=[ii(a.getNorthWest()),ii(a.getNorthEast()),ii(a.getSouthWest()),ii(a.getSouthEast()),ii(new c.S(I,N)),ii(new c.S(P,N)),ii(new c.S(B,k)),ii(new c.S(B,O))],H=ii(f.center);let K=Number.POSITIVE_INFINITY;for(const G of $)_<0&&(K=yi.getLesserNonNegativeNonNull(K,yi.solveVectorScale(G,H,q,"x",_))),y>0&&(K=yi.getLesserNonNegativeNonNull(K,yi.solveVectorScale(G,H,q,"x",y))),b>0&&(K=yi.getLesserNonNegativeNonNull(K,yi.solveVectorScale(G,H,q,"y",b))),w<0&&(K=yi.getLesserNonNegativeNonNull(K,yi.solveVectorScale(G,H,q,"y",w)));if(Number.isFinite(K)&&K!==0)return f.zoom=U.zoom+c.ak(K),f;kl()}handleJumpToCenterZoom(e,n){const a=e.center.lat,l=e.getConstrained(n.center?c.S.convert(n.center):e.center,e.zoom).center;e.setCenter(l.wrap());const u=n.zoom!==void 0?+n.zoom:e.zoom+Ft(a,l.lat);e.zoom!==u&&e.setZoom(u)}handleEaseTo(e,n){const a=e.zoom,l=e.center,u=e.padding,f={roll:e.roll,pitch:e.pitch,bearing:e.bearing},_={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},y=n.zoom!==void 0,b=!e.isPaddingEqual(n.padding);let w=!1;const S=n.center?c.S.convert(n.center):l,P=e.getConstrained(S,a).center;da(e,P);const I=e.clone();I.setCenter(P),I.setZoom(y?+n.zoom:a+Ft(l.lat,S.lat)),I.setBearing(n.bearing);const k=new c.P(c.ah(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),c.ah(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));I.setLocationAtPoint(P,k);const O=(n.offset&&n.offsetAsPoint.mag())>0?I.center:P,B=y?+n.zoom:a+Ft(l.lat,O.lat),N=a+Ft(l.lat,0),U=B+Ft(O.lat,0),q=c.bA(l.lng,O.lng),$=c.bA(l.lat,O.lat),H=c.af(U-N);return w=B!==a,{easeFunc:K=>{if(c.be(f,_)||Ti({startEulerAngles:f,endEulerAngles:_,tr:e,k:K,useSlerp:f.roll!=_.roll}),b&&e.interpolatePadding(u,n.padding,K),n.around)c.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(n.around,n.aroundPoint);else{const G=U>N?Math.min(2,H):Math.max(.5,H),te=Math.pow(G,1-K),ue=vo(l,q,$,K*te);e.setCenter(ue.wrap())}if(w){const G=c.C.number(N,U,K)+Ft(0,e.center.lat);e.setZoom(G)}},isZooming:w,elevationCenter:O}}handleFlyTo(e,n){const a=n.zoom!==void 0,l=e.center,u=e.zoom,f=e.padding,_=!e.isPaddingEqual(n.padding),y=e.getConstrained(c.S.convert(n.center||n.locationAtOffset),u).center,b=a?+n.zoom:e.zoom+Ft(e.center.lat,y.lat),w=e.clone();w.setCenter(y),w.setZoom(b),w.setBearing(n.bearing);const S=new c.P(c.ah(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),c.ah(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));w.setLocationAtPoint(y,S);const P=w.center;da(e,P);const I=function($,H,K){const G=ii(H),te=ii(K),ue=c.aX(G,te),ae=Math.acos(ue),oe=_a($);return ae/(2*Math.PI)*oe}(e,l,P),k=u+Ft(l.lat,0),O=b+Ft(P.lat,0),B=c.af(O-k);let N;if(typeof n.minZoom=="number"){const $=+n.minZoom+Ft(P.lat,0),H=Math.min($,k,O)+Ft(0,P.lat),K=e.getConstrained(P,H).zoom+Ft(P.lat,0);N=c.af(K-k)}const U=c.bA(l.lng,P.lng),q=c.bA(l.lat,P.lat);return{easeFunc:($,H,K,G)=>{const te=vo(l,U,q,K);_&&e.interpolatePadding(f,n.padding,$);const ue=$===1?P:te;e.setCenter(ue.wrap());const ae=k+c.ak(H);e.setZoom($===1?b:ae+Ft(0,ue.lat))},scaleOfZoom:B,targetCenter:P,scaleOfMinZoom:N,pixelPathLength:I}}static solveVectorScale(e,n,a,l,u){const f=l==="x"?[a[0],a[4],a[8],a[12]]:[a[1],a[5],a[9],a[13]],_=[a[3],a[7],a[11],a[15]],y=e[0]*f[0]+e[1]*f[1]+e[2]*f[2],b=e[0]*_[0]+e[1]*_[1]+e[2]*_[2],w=n[0]*f[0]+n[1]*f[1]+n[2]*f[2],S=n[0]*_[0]+n[1]*_[1]+n[2]*_[2];return w+u*b===y+u*S||_[3]*(y-w)+f[3]*(S-b)+y*S==w*b?null:(w+f[3]-u*S-u*_[3])/(w-y-u*S+u*b)}static getLesserNonNegativeNonNull(e,n){return n!==null&&n>=0&&n<e?n:e}}class Ll{constructor(e){this._globe=e,this._mercatorCameraHelper=new _i,this._verticalPerspectiveCameraHelper=new yi}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,n){return this.currentHelper.handlePanInertia(e,n)}handleMapControlsRollPitchBearingZoom(e,n){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,n)}handleMapControlsPan(e,n,a){this.currentHelper.handleMapControlsPan(e,n,a)}cameraForBoxAndBearing(e,n,a,l,u){return this.currentHelper.cameraForBoxAndBearing(e,n,a,l,u)}handleJumpToCenterZoom(e,n){this.currentHelper.handleJumpToCenterZoom(e,n)}handleEaseTo(e,n){return this.currentHelper.handleEaseTo(e,n)}handleFlyTo(e,n){return this.currentHelper.handleFlyTo(e,n)}}const ya=(h,e)=>c.y(h,e&&e.filter(n=>n.identifier!=="source.canvas")),Xc=c.bE();class bo extends c.E{constructor(e,n={}){var a,l;super(),this._rtlPluginLoaded=()=>{for(const f in this.sourceCaches){const _=this.sourceCaches[f].getSource().type;_!=="vector"&&_!=="geojson"||this.sourceCaches[f].reload()}},this.map=e,this.dispatcher=new Ei(fn(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(f,_)=>this.getGlyphs(f,_)),this.dispatcher.registerMessageHandler("GI",(f,_)=>this.getImages(f,_)),this.imageManager=new Ts,this.imageManager.setEventedParent(this);const u=((a=e._container)===null||a===void 0?void 0:a.lang)||typeof document<"u"&&((l=document.documentElement)===null||l===void 0?void 0:l.lang)||void 0;this.glyphManager=new Or(e._requestManager,n.localIdeographFontFamily,u),this.lineAtlas=new gt(256,512),this.crossTileSymbolIndex=new Yn,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new c.bF,this._loaded=!1,this._availableImages=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast("SR",c.bG()),Gr().on(gn,this._rtlPluginLoaded),this.on("data",f=>{if(f.dataType!=="source"||f.sourceDataType!=="metadata")return;const _=this.sourceCaches[f.sourceId];if(!_)return;const y=_.getSource();if(y&&y.vectorLayerIds)for(const b in this._layers){const w=this._layers[b];w.source===y.id&&this._validateLayer(w)}})}setGlobalStateProperty(e,n){var a,l,u;this._checkLoaded();const f=n===null?(u=(l=(a=this.stylesheet.state)===null||a===void 0?void 0:a[e])===null||l===void 0?void 0:l.default)!==null&&u!==void 0?u:null:n;if(c.bH(f,this._globalState[e]))return this;this._globalState[e]=f,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const n=[];for(const a in e)!c.bH(this._globalState[a],e[a].default)&&(n.push(a),this._globalState[a]=e[a].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(e){if(e.length===0)return;const n=new Set;for(const a in this._layers){const l=this._layers[a],u=l.getLayoutAffectingGlobalStateRefs(),f=l.getPaintAffectingGlobalStateRefs();for(const _ of e)if(u.has(_)&&n.add(l.source),f.has(_))for(const{name:y,value:b}of f.get(_))this._updatePaintProperty(l,y,b)}for(const a in this.sourceCaches)n.has(a)&&(this._reloadSource(a),this._changed=!0)}loadURL(e,n={},a){this.fire(new c.l("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const l=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const u=this._loadStyleRequest;c.j(l,this._loadStyleRequest).then(f=>{this._loadStyleRequest=null,this._load(f.data,n,a)}).catch(f=>{this._loadStyleRequest=null,f&&!u.signal.aborted&&this.fire(new c.k(f))})}loadJSON(e,n={},a){this.fire(new c.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,Ee.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,a)}).catch(()=>{})}loadEmpty(){this.fire(new c.l("dataloading",{dataType:"style"})),this._load(Xc,{validate:!1})}_load(e,n,a){var l,u;let f=n.transformStyle?n.transformStyle(a,e):e;if(!n.validate||!ya(this,c.z(f))){f=Object.assign({},f),this._loaded=!0,this.stylesheet=f;for(const _ in f.sources)this.addSource(_,f.sources[_],{validate:!1});f.sprite?this._loadSprite(f.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(f.glyphs),this._createLayers(),this.light=new hn(this.stylesheet.light),this._setProjectionInternal(((l=this.stylesheet.projection)===null||l===void 0?void 0:l.type)||"mercator"),this.sky=new la(this.stylesheet.sky),this.map.setTerrain((u=this.stylesheet.terrain)!==null&&u!==void 0?u:null),this.fire(new c.l("data",{dataType:"style"})),this.fire(new c.l("style.load"))}}_createLayers(){var e;const n=c.bI(this.stylesheet.layers);this.dispatcher.broadcast("SL",n),this._order=n.map(a=>a.id),this._layers={},this.setGlobalState((e=this.stylesheet.state)!==null&&e!==void 0?e:null),this._serializedLayers=null;for(const a of n){const l=c.bJ(a);l.setEventedParent(this,{layer:{id:a.id}}),l.setGlobalState(this._globalState),this._layers[a.id]=l}}_loadSprite(e,n=!1,a=void 0){let l;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(u,f,_,y){return c._(this,void 0,void 0,function*(){const b=Sr(u),w=_>1?"@2x":"",S={},P={};for(const{id:I,url:k}of b){const O=f.transformRequest(jn(k,w,".json"),"SpriteJSON");S[I]=c.j(O,y);const B=f.transformRequest(jn(k,w,".png"),"SpriteImage");P[I]=Ot.getImage(B,y)}return yield Promise.all([...Object.values(S),...Object.values(P)]),function(I,k){return c._(this,void 0,void 0,function*(){const O={};for(const B in I){O[B]={};const N=Ee.getImageCanvasContext((yield k[B]).data),U=(yield I[B]).data;for(const q in U){const{width:$,height:H,x:K,y:G,sdf:te,pixelRatio:ue,stretchX:ae,stretchY:oe,content:he,textFitWidth:we,textFitHeight:Se}=U[q];O[B][q]={data:null,pixelRatio:ue,sdf:te,stretchX:ae,stretchY:oe,content:he,textFitWidth:we,textFitHeight:Se,spriteData:{width:$,height:H,x:K,y:G,context:N}}}}return O})}(S,P)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(u=>{if(this._spriteRequest=null,u)for(const f in u){this._spritesImagesIds[f]=[];const _=this._spritesImagesIds[f]?this._spritesImagesIds[f].filter(y=>!(y in u)):[];for(const y of _)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(const y in u[f]){const b=f==="default"?y:`${f}:${y}`;this._spritesImagesIds[f].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,u[f][y],!1):this.imageManager.addImage(b,u[f][y]),n&&(this._changedImages[b]=!0)}}}).catch(u=>{this._spriteRequest=null,l=u,this.fire(new c.k(l))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"})),a&&a(l)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}_validateLayer(e){const n=this.sourceCaches[e.source];if(!n)return;const a=e.sourceLayer;if(!a)return;const l=n.getSource();(l.type==="geojson"||l.vectorLayerIds&&l.vectorLayerIds.indexOf(a)===-1)&&this.fire(new c.k(new Error(`Source layer "${a}" does not exist on source "${l.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){const a=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?c.bK(a):a);const l=[];for(const u of e)if(a[u]){const f=n?c.bK(a[u]):a[u];l.push(f)}return l}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const n=Object.keys(this._layers);for(const a of n){const l=this._layers[a];l.type!=="custom"&&(e[a]=l.serialize())}return e}hasTransitions(){var e,n,a;if(!((e=this.light)===null||e===void 0)&&e.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((a=this.projection)===null||a===void 0)&&a.hasTransition())return!0;for(const l in this.sourceCaches)if(this.sourceCaches[l].hasTransition())return!0;for(const l in this._layers)if(this._layers[l].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const n=this._changed;if(n){const l=Object.keys(this._updatedLayers),u=Object.keys(this._removedLayers);(l.length||u.length)&&this._updateWorkerLayers(l,u);for(const f in this._updatedSources){const _=this._updatedSources[f];if(_==="reload")this._reloadSource(f);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(f)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const f in this._updatedPaintProps)this._layers[f].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const a={};for(const l in this.sourceCaches){const u=this.sourceCaches[l];a[l]=u.used,u.used=!1}for(const l of this._order){const u=this._layers[l];u.recalculate(e,this._availableImages),!u.isHidden(e.zoom)&&u.source&&(this.sourceCaches[u.source].used=!0)}for(const l in a){const u=this.sourceCaches[l];!!a[l]!=!!u.used&&u.fire(new c.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:l}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,n&&this.fire(new c.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var a;this._checkLoaded();const l=this.serialize();if(e=n.transformStyle?n.transformStyle(l,e):e,((a=n.validate)===null||a===void 0||a)&&ya(this,c.z(e)))return!1;(e=c.bK(e)).layers=c.bI(e.layers);const u=c.bL(l,e),f=this._getOperationsToPerform(u);if(f.unimplemented.length>0)throw new Error(`Unimplemented: ${f.unimplemented.join(", ")}.`);if(f.operations.length===0)return!1;for(const _ of f.operations)_();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const n=[],a=[];for(const l of e)switch(l.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,l.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,l.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,l.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,l.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,l.args));break;case"addSource":n.push(()=>this.addSource.apply(this,l.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,l.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,l.args));break;case"setLight":n.push(()=>this.setLight.apply(this,l.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,l.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,l.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,l.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,l.args));break;case"setSky":n.push(()=>this.setSky.apply(this,l.args));break;case"setProjection":this.setProjection.apply(this,l.args);break;case"setGlobalState":n.push(()=>this.setGlobalState.apply(this,l.args));break;case"setTransition":n.push(()=>{});break;default:a.push(l.command)}return{operations:n,unimplemented:a}}addImage(e,n){if(this.getImage(e))return this.fire(new c.k(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 c.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,a={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(c.z.source,`sources.${e}`,n,null,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const l=this.sourceCaches[e]=new Qe(e,n,this.dispatcher);l.style=this,l.setEventedParent(this,()=>({isSourceLoaded:l.loaded(),source:l.serialize(),sourceId:e})),l.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(const a in this._layers)if(this._layers[a].source===e)return this.fire(new c.k(new Error(`Source "${e}" cannot be removed while layer "${a}" is using it.`)));const n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new c.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);const a=this.sourceCaches[e].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,a={}){this._checkLoaded();const l=e.id;if(this.getLayer(l))return void this.fire(new c.k(new Error(`Layer "${l}" already exists on this map.`)));let u;if(e.type==="custom"){if(ya(this,c.bM(e)))return;u=c.bJ(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(l,e.source),e=c.bK(e),e=c.e(e,{source:l})),this._validate(c.z.layer,`layers.${l}`,e,{arrayIndex:-1},a))return;u=c.bJ(e),this._validateLayer(u),u.setEventedParent(this,{layer:{id:l}})}const f=n?this._order.indexOf(n):this._order.length;if(n&&f===-1)this.fire(new c.k(new Error(`Cannot add layer "${l}" before non-existing layer "${n}".`)));else{if(this._order.splice(f,0,l),this._layerOrderChanged=!0,this._layers[l]=u,this._removedLayers[l]&&u.source&&u.type!=="custom"){const _=this._removedLayers[l];delete this._removedLayers[l],_.type!==u.type?this._updatedSources[u.source]="clear":(this._updatedSources[u.source]="reload",this.sourceCaches[u.source].pause())}this._updateLayer(u),u.onAdd&&u.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new c.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;const a=this._order.indexOf(e);this._order.splice(a,1);const l=n?this._order.indexOf(n):this._order.length;n&&l===-1?this.fire(new c.k(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(l,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const n=this._layers[e];if(!n)return void this.fire(new c.k(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);const a=this._order.indexOf(e);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,a){this._checkLoaded();const l=this.getLayer(e);l?l.minzoom===n&&l.maxzoom===a||(n!=null&&(l.minzoom=n),a!=null&&(l.maxzoom=a),this._updateLayer(l)):this.fire(new c.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,a={}){this._checkLoaded();const l=this.getLayer(e);if(l){if(!c.bH(l.filter,n))return n==null?(l.setFilter(void 0),void this._updateLayer(l)):void(this._validate(c.z.filter,`layers.${l.id}.filter`,n,null,a)||(l.setFilter(c.bK(n)),this._updateLayer(l)))}else this.fire(new c.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return c.bK(this.getLayer(e).filter)}setLayoutProperty(e,n,a,l={}){this._checkLoaded();const u=this.getLayer(e);u?c.bH(u.getLayoutProperty(n),a)||(u.setLayoutProperty(n,a,l),this._updateLayer(u)):this.fire(new c.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){const a=this.getLayer(e);if(a)return a.getLayoutProperty(n);this.fire(new c.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,a,l={}){this._checkLoaded();const u=this.getLayer(e);u?c.bH(u.getPaintProperty(n),a)||this._updatePaintProperty(u,n,a,l):this.fire(new c.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,n,a,l={}){e.setPaintProperty(n,a,l)&&this._updateLayer(e),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();const a=e.source,l=e.sourceLayer,u=this.sourceCaches[a];if(u===void 0)return void this.fire(new c.k(new Error(`The source '${a}' does not exist in the map's style.`)));const f=u.getSource().type;f==="geojson"&&l?this.fire(new c.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):f!=="vector"||l?(e.id===void 0&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),u.setFeatureState(l,e.id,n)):this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();const a=e.source,l=this.sourceCaches[a];if(l===void 0)return void this.fire(new c.k(new Error(`The source '${a}' does not exist in the map's style.`)));const u=l.getSource().type,f=u==="vector"?e.sourceLayer:void 0;u!=="vector"||f?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new c.k(new Error("A feature id is required to remove its specific state property."))):l.removeFeatureState(f,e.id,n):this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const n=e.source,a=e.sourceLayer,l=this.sourceCaches[n];if(l!==void 0)return l.getSource().type!=="vector"||a?(e.id===void 0&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),l.getFeatureState(a,e.id)):void this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new c.k(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return c.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=c.bN(this.sourceCaches,u=>u.serialize()),n=this._serializeByIds(this._order,!0),a=this.map.getTerrain()||void 0,l=this.stylesheet;return c.bO({version:l.version,name:l.name,metadata:l.metadata,light:l.light,sky:l.sky,center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch,sprite:l.sprite,glyphs:l.glyphs,transition:l.transition,projection:l.projection,sources:e,layers:n,terrain:a},u=>u!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const n=f=>this._layers[f].type==="fill-extrusion",a={},l=[];for(let f=this._order.length-1;f>=0;f--){const _=this._order[f];if(n(_)){a[_]=f;for(const y of e){const b=y[_];if(b)for(const w of b)l.push(w)}}}l.sort((f,_)=>_.intersectionZ-f.intersectionZ);const u=[];for(let f=this._order.length-1;f>=0;f--){const _=this._order[f];if(n(_))for(let y=l.length-1;y>=0;y--){const b=l[y].feature;if(a[b.layer.id]<f)break;u.push(b),l.pop()}else for(const y of e){const b=y[_];if(b)for(const w of b)u.push(w.feature)}}return u}queryRenderedFeatures(e,n,a){n&&n.filter&&this._validate(c.z.filter,"queryRenderedFeatures.filter",n.filter,null,n);const l={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new c.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const b of n.layers){const w=this._layers[b];if(!w)return this.fire(new c.k(new Error(`The layer '${b}' does not exist in the map's style and cannot be queried for features.`))),[];l[w.source]=!0}}const u=[];n.availableImages=this._availableImages;const f=this._serializedAllLayers(),_=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,y=Object.assign(Object.assign({},n),{layers:_});for(const b in this.sourceCaches)n.layers&&!l[b]||u.push(Yi(this.sourceCaches[b],this._layers,f,e,y,a,this.map.terrain?(w,S,P)=>this.map.terrain.getElevation(w,S,P):void 0));return this.placement&&u.push(function(b,w,S,P,I,k,O){const B={},N=k.queryRenderedSymbols(P),U=[];for(const q of Object.keys(N).map(Number))U.push(O[q]);U.sort(Vn);for(const q of U){const $=q.featureIndex.lookupSymbolFeatures(N[q.bucketInstanceId],w,q.bucketIndex,q.sourceLayerIndex,I.filter,I.layers,I.availableImages,b);for(const H in $){const K=B[H]=B[H]||[],G=$[H];G.sort((te,ue)=>{const ae=q.featureSortOrder;if(ae){const oe=ae.indexOf(te.featureIndex);return ae.indexOf(ue.featureIndex)-oe}return ue.featureIndex-te.featureIndex});for(const te of G)K.push(te)}}return function(q,$,H){for(const K in q)for(const G of q[K])Un(G,H[$[K].source]);return q}(B,b,S)}(this._layers,f,this.sourceCaches,e,y,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(u)}querySourceFeatures(e,n){n&&n.filter&&this._validate(c.z.filter,"querySourceFeatures.filter",n.filter,null,n);const a=this.sourceCaches[e];return a?function(l,u){const f=l.getRenderableIds().map(b=>l.getTileByID(b)),_=[],y={};for(let b=0;b<f.length;b++){const w=f[b],S=w.tileID.canonical.key;y[S]||(y[S]=!0,w.querySourceFeatures(_,u))}return _}(a,n):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();const a=this.light.getLight();let l=!1;for(const f in e)if(!c.bH(e[f],a[f])){l=!0;break}if(!l)return;const u={now:Ee.now(),transition:c.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(u)}getProjection(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.projection}setProjection(e){if(this._checkLoaded(),this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=e,this._setProjectionInternal(e.type)}getSky(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.sky}setSky(e,n={}){this._checkLoaded();const a=this.getSky();let l=!1;if(!e&&!a)return;if(e&&!a)l=!0;else if(!e&&a)l=!0;else for(const f in e)if(!c.bH(e[f],a[f])){l=!0;break}if(!l)return;const u={now:Ee.now(),transition:c.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(u)}_setProjectionInternal(e){const n=function(a){if(Array.isArray(a)){const l=new ga({type:a});return{projection:l,transform:new Ls,cameraHelper:new Ll(l)}}switch(a){case"mercator":return{projection:new it,transform:new bt,cameraHelper:new _i};case"globe":{const l=new ga({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:l,transform:new Ls,cameraHelper:new Ll(l)}}case"vertical-perspective":return{projection:new Is,transform:new zs,cameraHelper:new yi};default:return c.w(`Unknown projection name: ${a}. Falling back to mercator projection.`),{projection:new it,transform:new bt,cameraHelper:new _i}}}(e);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const a in this.sourceCaches)this.sourceCaches[a].reload()}_validate(e,n,a,l,u={}){return(!u||u.validate!==!1)&&ya(this,e.call(c.z,c.e({key:n,style:this.serialize(),value:a,styleSpec:c.v},l)))}_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),Gr().off(gn,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const a=this.sourceCaches[n];a.setEventedParent(null),a.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(const n in this.sourceCaches)this.sourceCaches[n].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.sourceCaches)this._reloadSource(e)}_updatePlacement(e,n,a,l,u=!1){let f=!1,_=!1;const y={};for(const b of this._order){const w=this._layers[b];if(w.type!=="symbol")continue;if(!y[w.source]){const P=this.sourceCaches[w.source];y[w.source]=P.getRenderableIds(!0).map(I=>P.getTileByID(I)).sort((I,k)=>k.tileID.overscaledZ-I.tileID.overscaledZ||(I.tileID.isLessThan(k.tileID)?-1:1))}const S=this.crossTileSymbolIndex.addLayer(w,y[w.source],e.center.lng);f=f||S}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((u=u||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Ee.now(),e.zoom))&&(this.pauseablePlacement=new go(e,this.map.terrain,this._order,u,n,a,l,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(Ee.now()),_=!0),f&&this.pauseablePlacement.placement.setStale()),_||f)for(const b of this._order){const w=this._layers[b];w.type==="symbol"&&this.placement.updateLayerOpacities(w,y[w.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Ee.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return c._(this,void 0,void 0,function*(){const a=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const l=this.sourceCaches[n.source];return l&&l.setDependencies(n.tileID.key,n.type,n.icons),a})}getGlyphs(e,n){return c._(this,void 0,void 0,function*(){const a=yield this.glyphManager.getGlyphs(n.stacks),l=this.sourceCaches[n.source];return l&&l.setDependencies(n.tileID.key,n.type,[""]),a})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(c.z.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,a={},l){this._checkLoaded();const u=[{id:e,url:n}],f=[...Sr(this.stylesheet.sprite),...u];this._validate(c.z.sprite,"sprite",f,null,a)||(this.stylesheet.sprite=f,this._loadSprite(u,!0,l))}removeSprite(e){this._checkLoaded();const n=Sr(this.stylesheet.sprite);if(n.find(a=>a.id===e)){if(this._spritesImagesIds[e])for(const a of this._spritesImagesIds[e])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex(a=>a.id===e),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}else this.fire(new c.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return Sr(this.stylesheet.sprite)}setSprite(e,n={},a){this._checkLoaded(),e&&this._validate(c.z.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,a):(this._unloadSprite(),a&&a(null)))}}var Yc=c.aJ([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Kc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,a,l,u,f,_,y,b){this.context=e;let w=this.boundPaintVertexBuffers.length!==l.length;for(let S=0;!w&&S<l.length;S++)this.boundPaintVertexBuffers[S]!==l[S]&&(w=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==a||w||this.boundIndexBuffer!==u||this.boundVertexOffset!==f||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==y||this.boundDynamicVertexBuffer3!==b?this.freshBind(n,a,l,u,f,_,y,b):(e.bindVertexArray.set(this.vao),_&&_.bind(),u&&u.dynamicDraw&&u.bind(),y&&y.bind(),b&&b.bind())}freshBind(e,n,a,l,u,f,_,y){const b=e.numAttributes,w=this.context,S=w.gl;this.vao&&this.destroy(),this.vao=w.createVertexArray(),w.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=a,this.boundIndexBuffer=l,this.boundVertexOffset=u,this.boundDynamicVertexBuffer=f,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=y,n.enableAttributes(S,e);for(const P of a)P.enableAttributes(S,e);f&&f.enableAttributes(S,e),_&&_.enableAttributes(S,e),y&&y.enableAttributes(S,e),n.bind(),n.setVertexAttribPointers(S,e,u);for(const P of a)P.bind(),P.setVertexAttribPointers(S,e,u);f&&(f.bind(),f.setVertexAttribPointers(S,e,u)),l&&l.bind(),_&&(_.bind(),_.setVertexAttribPointers(S,e,u)),y&&(y.bind(),y.setVertexAttribPointers(S,e,u)),w.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const xa=(h,e,n,a,l)=>({u_texture:0,u_ele_delta:h,u_fog_matrix:e,u_fog_color:n?n.properties.get("fog-color"):c.bf.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:l?0:n?n.calculateFogBlendOpacity(a):0,u_horizon_color:n?n.properties.get("horizon-color"):c.bf.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:l?1:0}),wo={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Tn(h){const e=[];for(let n=0;n<h.length;n++){if(h[n]===null)continue;const a=h[n].split(" ");e.push(a.pop())}return e}class To{constructor(e,n,a,l,u,f,_,y,b=[]){const w=e.gl;this.program=w.createProgram();const S=Tn(n.staticAttributes),P=a?a.getBinderAttributes():[],I=S.concat(P),k=Ji.prelude.staticUniforms?Tn(Ji.prelude.staticUniforms):[],O=_.staticUniforms?Tn(_.staticUniforms):[],B=n.staticUniforms?Tn(n.staticUniforms):[],N=a?a.getBinderUniforms():[],U=k.concat(O).concat(B).concat(N),q=[];for(const ae of U)q.indexOf(ae)<0&&q.push(ae);const $=a?a.defines():[];vr(w)&&$.unshift("#version 300 es"),u&&$.push("#define OVERDRAW_INSPECTOR;"),f&&$.push("#define TERRAIN3D;"),y&&$.push(y),b&&$.push(...b);let H=$.concat(Ji.prelude.fragmentSource,_.fragmentSource,n.fragmentSource).join(`
740
740
  `),K=$.concat(Ji.prelude.vertexSource,_.vertexSource,n.vertexSource).join(`
741
- `);vr(w)||(H=function(ae){return ae.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(H),K=function(ae){return ae.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(K));const G=w.createShader(w.FRAGMENT_SHADER);if(w.isContextLost())return void(this.failedToCreate=!0);if(w.shaderSource(G,H),w.compileShader(G),!w.getShaderParameter(G,w.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${w.getShaderInfoLog(G)}`);w.attachShader(this.program,G);const te=w.createShader(w.VERTEX_SHADER);if(w.isContextLost())return void(this.failedToCreate=!0);if(w.shaderSource(te,K),w.compileShader(te),!w.getShaderParameter(te,w.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${w.getShaderInfoLog(te)}`);w.attachShader(this.program,te),this.attributes={};const ue={};this.numAttributes=I.length;for(let ae=0;ae<this.numAttributes;ae++)I[ae]&&(w.bindAttribLocation(this.program,ae,I[ae]),this.attributes[I[ae]]=ae);if(w.linkProgram(this.program),!w.getProgramParameter(this.program,w.LINK_STATUS))throw new Error(`Program failed to link: ${w.getProgramInfoLog(this.program)}`);w.deleteShader(te),w.deleteShader(G);for(let ae=0;ae<q.length;ae++){const oe=q[ae];if(oe&&!ue[oe]){const he=w.getUniformLocation(this.program,oe);he&&(ue[oe]=he)}}this.fixedUniforms=l(e,ue),this.terrainUniforms=((ae,oe)=>({u_depth:new c.bP(ae,oe.u_depth),u_terrain:new c.bP(ae,oe.u_terrain),u_terrain_dim:new c.bg(ae,oe.u_terrain_dim),u_terrain_matrix:new c.bR(ae,oe.u_terrain_matrix),u_terrain_unpack:new c.bS(ae,oe.u_terrain_unpack),u_terrain_exaggeration:new c.bg(ae,oe.u_terrain_exaggeration)}))(e,ue),this.projectionUniforms=((ae,oe)=>({u_projection_matrix:new c.bR(ae,oe.u_projection_matrix),u_projection_tile_mercator_coords:new c.bS(ae,oe.u_projection_tile_mercator_coords),u_projection_clipping_plane:new c.bS(ae,oe.u_projection_clipping_plane),u_projection_transition:new c.bg(ae,oe.u_projection_transition),u_projection_fallback_matrix:new c.bR(ae,oe.u_projection_fallback_matrix)}))(e,ue),this.binderUniforms=a?a.getUniforms(e,ue):[]}draw(e,n,a,l,u,f,_,y,b,w,S,P,I,k,O,B,N,U,q){const $=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(l),e.setColorMode(u),e.setCullFace(f),y){e.activeTexture.set($.TEXTURE2),$.bindTexture($.TEXTURE_2D,y.depthTexture),e.activeTexture.set($.TEXTURE3),$.bindTexture($.TEXTURE_2D,y.texture);for(const K in this.terrainUniforms)this.terrainUniforms[K].set(y[K])}if(b)for(const K in b)this.projectionUniforms[wo[K]].set(b[K]);if(_)for(const K in this.fixedUniforms)this.fixedUniforms[K].set(_[K]);B&&B.setUniforms(e,this.binderUniforms,k,{zoom:O});let H=0;switch(n){case $.LINES:H=2;break;case $.TRIANGLES:H=3;break;case $.LINE_STRIP:H=1}for(const K of I.get()){const G=K.vaos||(K.vaos={});(G[w]||(G[w]=new Kc)).bind(e,this,S,B?B.getPaintVertexBuffers():[],P,K.vertexOffset,N,U,q),$.drawElements(n,K.primitiveLength*H,$.UNSIGNED_SHORT,K.primitiveOffset*H*2)}}}function va(h,e,n){const a=1/c.aC(n,1,e.transform.tileZoom),l=Math.pow(2,n.tileID.overscaledZ),u=n.tileSize*Math.pow(2,e.transform.tileZoom)/l,f=u*(n.tileID.canonical.x+n.tileID.wrap*l),_=u*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[f>>16,_>>16],u_pixel_coord_lower:[65535&f,65535&_]}}const er=(h,e,n,a)=>{const l=h.style.light,u=l.properties.get("position"),f=[u.x,u.y,u.z],_=c.bV();l.properties.get("anchor")==="viewport"&&c.bW(_,h.transform.bearingInRadians),c.bX(f,f,_);const y=h.transform.transformLightDirection(f),b=l.properties.get("color");return{u_lightpos:f,u_lightpos_globe:y,u_lightintensity:l.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+e,u_opacity:n,u_fill_translate:a}},Jc=(h,e,n,a,l,u,f)=>c.e(er(h,e,n,a),va(u,h,f),{u_height_factor:-Math.pow(2,l.overscaledZ)/f.tileSize/8}),ba=(h,e,n,a)=>c.e(va(e,h,n),{u_fill_translate:a}),Ds=(h,e)=>({u_world:h,u_fill_translate:e}),Rs=(h,e,n,a,l)=>c.e(ba(h,e,n,l),{u_world:a}),Qc=(h,e,n,a,l)=>{const u=h.transform;let f,_,y=0;if(n.paint.get("circle-pitch-alignment")==="map"){const b=c.aC(e,1,u.zoom);f=!0,_=[b,b],y=b/(c.$*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*l}else f=!1,_=u.pixelsToGLUnits;return{u_camera_to_center_distance:u.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+f,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:y,u_translate:a}},wa=h=>({u_pixel_extrude_scale:[1/h.width,1/h.height]}),eh=h=>({u_viewport_size:[h.width,h.height]}),Pn=(h,e=1)=>({u_color:h,u_overlay:0,u_overlay_scale:e}),Ll=(h,e,n,a)=>{const l=c.aC(h,1,e)/(c.$*Math.pow(2,h.tileID.overscaledZ))*2*Math.PI*a;return{u_extrude_scale:c.aC(h,1,e),u_intensity:n,u_globe_extrude_scale:l}},Po=(h,e,n,a)=>{const l=c.L();c.bY(l,0,h.width,h.height,0,0,1);const u=h.context.gl;return{u_matrix:l,u_world:[u.drawingBufferWidth,u.drawingBufferHeight],u_image:n,u_color_ramp:a,u_opacity:e.paint.get("heatmap-opacity")}},th=(h,e,n)=>{const a=n.paint.get("hillshade-accent-color");let l;switch(n.paint.get("hillshade-method")){case"basic":l=4;break;case"combined":l=1;break;case"igor":l=2;break;case"multidirectional":l=3;break;default:l=0}const u=n.getIlluminationProperties();for(let f=0;f<u.directionRadians.length;f++)n.paint.get("hillshade-illumination-anchor")==="viewport"&&(u.directionRadians[f]+=h.transform.bearingInRadians);return{u_image:0,u_latrange:So(0,e.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:u.altitudeRadians,u_azimuths:u.directionRadians,u_accent:a,u_method:l,u_highlights:u.highlightColor,u_shadows:u.shadowColor}},Dl=(h,e)=>{const n=e.stride,a=c.L();return c.bY(a,0,c.$,-c.$,0,0,1),c.M(a,a,[0,-c.$,0]),{u_matrix:a,u_image:1,u_dimension:[n,n],u_zoom:h.overscaledZ,u_unpack:e.getUnpackVector()}};function So(h,e){const n=Math.pow(2,e.canonical.z),a=e.canonical.y;return[new c.a1(0,a/n).toLngLat().lat,new c.a1(0,(a+1)/n).toLngLat().lat]}const Rl=(h,e,n=0)=>({u_image:0,u_unpack:e.getUnpackVector(),u_dimension:[e.stride,e.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:h.paint.get("color-relief-opacity")}),Ta=(h,e,n,a)=>{const l=h.transform;return{u_translation:Io(h,e,n),u_ratio:a/c.aC(e,1,l.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]]}},Fl=(h,e,n,a,l)=>c.e(Ta(h,e,n,a),{u_image:0,u_image_height:l}),Bl=(h,e,n,a,l)=>{const u=h.transform,f=Mo(e,u);return{u_translation:Io(h,e,n),u_texsize:e.imageAtlasTexture.size,u_ratio:a/c.aC(e,1,u.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[f,l.fromScale,l.toScale],u_fade:l.t,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},Sn=(h,e,n,a,l,u)=>{const f=h.lineAtlas,_=Mo(e,h.transform),y=n.layout.get("line-cap")==="round",b=f.getDash(l.from,y),w=f.getDash(l.to,y),S=b.width*u.fromScale,P=w.width*u.toScale;return c.e(Ta(h,e,n,a),{u_patternscale_a:[_/S,-b.height/2],u_patternscale_b:[_/P,-w.height/2],u_sdfgamma:f.width/(256*Math.min(S,P)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:w.y,u_mix:u.t})};function Mo(h,e){return 1/c.aC(h,1,e.tileZoom)}function Io(h,e,n){return c.aD(h.transform,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Fs=(h,e,n,a,l)=>{return{u_tl_parent:h,u_scale_parent:e,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.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:(f=a.paint.get("raster-saturation"),f>0?1-1/(1.001-f):-f),u_contrast_factor:(u=a.paint.get("raster-contrast"),u>0?1/(1-u):1+u),u_spin_weights:ih(a.paint.get("raster-hue-rotate")),u_coords_top:[l[0].x,l[0].y,l[1].x,l[1].y],u_coords_bottom:[l[3].x,l[3].y,l[2].x,l[2].y]};var u,f};function ih(h){h*=Math.PI/180;const e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const Bs=(h,e,n,a,l,u,f,_,y,b,w,S,P)=>{const I=f.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:I.cameraToCenterDistance,u_pitch:I.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:I.width/I.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_label_plane_matrix:_,u_coord_matrix:y,u_is_text:+w,u_pitch_with_map:+a,u_is_along_line:l,u_is_variable_anchor:u,u_texsize:S,u_texture:0,u_translation:b,u_pitched_scale:P}},Ol=(h,e,n,a,l,u,f,_,y,b,w,S,P,I)=>{const k=f.transform;return c.e(Bs(h,e,n,a,l,u,f,_,y,b,w,S,I),{u_gamma_scale:a?Math.cos(k.pitch*Math.PI/180)*k.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:1})},rh=(h,e,n,a,l,u,f,_,y,b,w,S,P)=>c.e(Ol(h,e,n,a,l,u,f,_,y,b,!0,w,0,P),{u_texsize_icon:S,u_texture_icon:1}),jl=(h,e)=>({u_opacity:h,u_color:e}),Nl=(h,e,n,a,l)=>c.e(function(u,f,_,y){const b=_.imageManager.getPattern(u.from.toString()),w=_.imageManager.getPattern(u.to.toString()),{width:S,height:P}=_.imageManager.getPixelSize(),I=Math.pow(2,y.tileID.overscaledZ),k=y.tileSize*Math.pow(2,_.transform.tileZoom)/I,O=k*(y.tileID.canonical.x+y.tileID.wrap*I),B=k*y.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:b.tl,u_pattern_br_a:b.br,u_pattern_tl_b:w.tl,u_pattern_br_b:w.br,u_texsize:[S,P],u_mix:f.t,u_pattern_size_a:b.displaySize,u_pattern_size_b:w.displaySize,u_scale_a:f.fromScale,u_scale_b:f.toScale,u_tile_units_to_pixels:1/c.aC(y,1,_.transform.tileZoom),u_pixel_coord_upper:[O>>16,B>>16],u_pixel_coord_lower:[65535&O,65535&B]}}(n,l,e,a),{u_opacity:h}),Co=(h,e)=>{},Eo={fillExtrusion:(h,e)=>({u_lightpos:new c.bT(h,e.u_lightpos),u_lightpos_globe:new c.bT(h,e.u_lightpos_globe),u_lightintensity:new c.bg(h,e.u_lightintensity),u_lightcolor:new c.bT(h,e.u_lightcolor),u_vertical_gradient:new c.bg(h,e.u_vertical_gradient),u_opacity:new c.bg(h,e.u_opacity),u_fill_translate:new c.bU(h,e.u_fill_translate)}),fillExtrusionPattern:(h,e)=>({u_lightpos:new c.bT(h,e.u_lightpos),u_lightpos_globe:new c.bT(h,e.u_lightpos_globe),u_lightintensity:new c.bg(h,e.u_lightintensity),u_lightcolor:new c.bT(h,e.u_lightcolor),u_vertical_gradient:new c.bg(h,e.u_vertical_gradient),u_height_factor:new c.bg(h,e.u_height_factor),u_opacity:new c.bg(h,e.u_opacity),u_fill_translate:new c.bU(h,e.u_fill_translate),u_image:new c.bP(h,e.u_image),u_texsize:new c.bU(h,e.u_texsize),u_pixel_coord_upper:new c.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bU(h,e.u_pixel_coord_lower),u_scale:new c.bT(h,e.u_scale),u_fade:new c.bg(h,e.u_fade)}),fill:(h,e)=>({u_fill_translate:new c.bU(h,e.u_fill_translate)}),fillPattern:(h,e)=>({u_image:new c.bP(h,e.u_image),u_texsize:new c.bU(h,e.u_texsize),u_pixel_coord_upper:new c.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bU(h,e.u_pixel_coord_lower),u_scale:new c.bT(h,e.u_scale),u_fade:new c.bg(h,e.u_fade),u_fill_translate:new c.bU(h,e.u_fill_translate)}),fillOutline:(h,e)=>({u_world:new c.bU(h,e.u_world),u_fill_translate:new c.bU(h,e.u_fill_translate)}),fillOutlinePattern:(h,e)=>({u_world:new c.bU(h,e.u_world),u_image:new c.bP(h,e.u_image),u_texsize:new c.bU(h,e.u_texsize),u_pixel_coord_upper:new c.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bU(h,e.u_pixel_coord_lower),u_scale:new c.bT(h,e.u_scale),u_fade:new c.bg(h,e.u_fade),u_fill_translate:new c.bU(h,e.u_fill_translate)}),circle:(h,e)=>({u_camera_to_center_distance:new c.bg(h,e.u_camera_to_center_distance),u_scale_with_map:new c.bP(h,e.u_scale_with_map),u_pitch_with_map:new c.bP(h,e.u_pitch_with_map),u_extrude_scale:new c.bU(h,e.u_extrude_scale),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_globe_extrude_scale:new c.bg(h,e.u_globe_extrude_scale),u_translate:new c.bU(h,e.u_translate)}),collisionBox:(h,e)=>({u_pixel_extrude_scale:new c.bU(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_viewport_size:new c.bU(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new c.bQ(h,e.u_color),u_overlay:new c.bP(h,e.u_overlay),u_overlay_scale:new c.bg(h,e.u_overlay_scale)}),depth:Co,clippingMask:Co,heatmap:(h,e)=>({u_extrude_scale:new c.bg(h,e.u_extrude_scale),u_intensity:new c.bg(h,e.u_intensity),u_globe_extrude_scale:new c.bg(h,e.u_globe_extrude_scale)}),heatmapTexture:(h,e)=>({u_matrix:new c.bR(h,e.u_matrix),u_world:new c.bU(h,e.u_world),u_image:new c.bP(h,e.u_image),u_color_ramp:new c.bP(h,e.u_color_ramp),u_opacity:new c.bg(h,e.u_opacity)}),hillshade:(h,e)=>({u_image:new c.bP(h,e.u_image),u_latrange:new c.bU(h,e.u_latrange),u_exaggeration:new c.bg(h,e.u_exaggeration),u_altitudes:new c.b_(h,e.u_altitudes),u_azimuths:new c.b_(h,e.u_azimuths),u_accent:new c.bQ(h,e.u_accent),u_method:new c.bP(h,e.u_method),u_shadows:new c.bZ(h,e.u_shadows),u_highlights:new c.bZ(h,e.u_highlights)}),hillshadePrepare:(h,e)=>({u_matrix:new c.bR(h,e.u_matrix),u_image:new c.bP(h,e.u_image),u_dimension:new c.bU(h,e.u_dimension),u_zoom:new c.bg(h,e.u_zoom),u_unpack:new c.bS(h,e.u_unpack)}),colorRelief:(h,e)=>({u_image:new c.bP(h,e.u_image),u_unpack:new c.bS(h,e.u_unpack),u_dimension:new c.bU(h,e.u_dimension),u_elevation_stops:new c.bP(h,e.u_elevation_stops),u_color_stops:new c.bP(h,e.u_color_stops),u_color_ramp_size:new c.bP(h,e.u_color_ramp_size),u_opacity:new c.bg(h,e.u_opacity)}),line:(h,e)=>({u_translation:new c.bU(h,e.u_translation),u_ratio:new c.bg(h,e.u_ratio),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bU(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_translation:new c.bU(h,e.u_translation),u_ratio:new c.bg(h,e.u_ratio),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bU(h,e.u_units_to_pixels),u_image:new c.bP(h,e.u_image),u_image_height:new c.bg(h,e.u_image_height)}),linePattern:(h,e)=>({u_translation:new c.bU(h,e.u_translation),u_texsize:new c.bU(h,e.u_texsize),u_ratio:new c.bg(h,e.u_ratio),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_image:new c.bP(h,e.u_image),u_units_to_pixels:new c.bU(h,e.u_units_to_pixels),u_scale:new c.bT(h,e.u_scale),u_fade:new c.bg(h,e.u_fade)}),lineSDF:(h,e)=>({u_translation:new c.bU(h,e.u_translation),u_ratio:new c.bg(h,e.u_ratio),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bU(h,e.u_units_to_pixels),u_patternscale_a:new c.bU(h,e.u_patternscale_a),u_patternscale_b:new c.bU(h,e.u_patternscale_b),u_sdfgamma:new c.bg(h,e.u_sdfgamma),u_image:new c.bP(h,e.u_image),u_tex_y_a:new c.bg(h,e.u_tex_y_a),u_tex_y_b:new c.bg(h,e.u_tex_y_b),u_mix:new c.bg(h,e.u_mix)}),raster:(h,e)=>({u_tl_parent:new c.bU(h,e.u_tl_parent),u_scale_parent:new c.bg(h,e.u_scale_parent),u_buffer_scale:new c.bg(h,e.u_buffer_scale),u_fade_t:new c.bg(h,e.u_fade_t),u_opacity:new c.bg(h,e.u_opacity),u_image0:new c.bP(h,e.u_image0),u_image1:new c.bP(h,e.u_image1),u_brightness_low:new c.bg(h,e.u_brightness_low),u_brightness_high:new c.bg(h,e.u_brightness_high),u_saturation_factor:new c.bg(h,e.u_saturation_factor),u_contrast_factor:new c.bg(h,e.u_contrast_factor),u_spin_weights:new c.bT(h,e.u_spin_weights),u_coords_top:new c.bS(h,e.u_coords_top),u_coords_bottom:new c.bS(h,e.u_coords_bottom)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new c.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bP(h,e.u_is_size_feature_constant),u_size_t:new c.bg(h,e.u_size_t),u_size:new c.bg(h,e.u_size),u_camera_to_center_distance:new c.bg(h,e.u_camera_to_center_distance),u_pitch:new c.bg(h,e.u_pitch),u_rotate_symbol:new c.bP(h,e.u_rotate_symbol),u_aspect_ratio:new c.bg(h,e.u_aspect_ratio),u_fade_change:new c.bg(h,e.u_fade_change),u_label_plane_matrix:new c.bR(h,e.u_label_plane_matrix),u_coord_matrix:new c.bR(h,e.u_coord_matrix),u_is_text:new c.bP(h,e.u_is_text),u_pitch_with_map:new c.bP(h,e.u_pitch_with_map),u_is_along_line:new c.bP(h,e.u_is_along_line),u_is_variable_anchor:new c.bP(h,e.u_is_variable_anchor),u_texsize:new c.bU(h,e.u_texsize),u_texture:new c.bP(h,e.u_texture),u_translation:new c.bU(h,e.u_translation),u_pitched_scale:new c.bg(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new c.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bP(h,e.u_is_size_feature_constant),u_size_t:new c.bg(h,e.u_size_t),u_size:new c.bg(h,e.u_size),u_camera_to_center_distance:new c.bg(h,e.u_camera_to_center_distance),u_pitch:new c.bg(h,e.u_pitch),u_rotate_symbol:new c.bP(h,e.u_rotate_symbol),u_aspect_ratio:new c.bg(h,e.u_aspect_ratio),u_fade_change:new c.bg(h,e.u_fade_change),u_label_plane_matrix:new c.bR(h,e.u_label_plane_matrix),u_coord_matrix:new c.bR(h,e.u_coord_matrix),u_is_text:new c.bP(h,e.u_is_text),u_pitch_with_map:new c.bP(h,e.u_pitch_with_map),u_is_along_line:new c.bP(h,e.u_is_along_line),u_is_variable_anchor:new c.bP(h,e.u_is_variable_anchor),u_texsize:new c.bU(h,e.u_texsize),u_texture:new c.bP(h,e.u_texture),u_gamma_scale:new c.bg(h,e.u_gamma_scale),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_is_halo:new c.bP(h,e.u_is_halo),u_translation:new c.bU(h,e.u_translation),u_pitched_scale:new c.bg(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new c.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bP(h,e.u_is_size_feature_constant),u_size_t:new c.bg(h,e.u_size_t),u_size:new c.bg(h,e.u_size),u_camera_to_center_distance:new c.bg(h,e.u_camera_to_center_distance),u_pitch:new c.bg(h,e.u_pitch),u_rotate_symbol:new c.bP(h,e.u_rotate_symbol),u_aspect_ratio:new c.bg(h,e.u_aspect_ratio),u_fade_change:new c.bg(h,e.u_fade_change),u_label_plane_matrix:new c.bR(h,e.u_label_plane_matrix),u_coord_matrix:new c.bR(h,e.u_coord_matrix),u_is_text:new c.bP(h,e.u_is_text),u_pitch_with_map:new c.bP(h,e.u_pitch_with_map),u_is_along_line:new c.bP(h,e.u_is_along_line),u_is_variable_anchor:new c.bP(h,e.u_is_variable_anchor),u_texsize:new c.bU(h,e.u_texsize),u_texsize_icon:new c.bU(h,e.u_texsize_icon),u_texture:new c.bP(h,e.u_texture),u_texture_icon:new c.bP(h,e.u_texture_icon),u_gamma_scale:new c.bg(h,e.u_gamma_scale),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_is_halo:new c.bP(h,e.u_is_halo),u_translation:new c.bU(h,e.u_translation),u_pitched_scale:new c.bg(h,e.u_pitched_scale)}),background:(h,e)=>({u_opacity:new c.bg(h,e.u_opacity),u_color:new c.bQ(h,e.u_color)}),backgroundPattern:(h,e)=>({u_opacity:new c.bg(h,e.u_opacity),u_image:new c.bP(h,e.u_image),u_pattern_tl_a:new c.bU(h,e.u_pattern_tl_a),u_pattern_br_a:new c.bU(h,e.u_pattern_br_a),u_pattern_tl_b:new c.bU(h,e.u_pattern_tl_b),u_pattern_br_b:new c.bU(h,e.u_pattern_br_b),u_texsize:new c.bU(h,e.u_texsize),u_mix:new c.bg(h,e.u_mix),u_pattern_size_a:new c.bU(h,e.u_pattern_size_a),u_pattern_size_b:new c.bU(h,e.u_pattern_size_b),u_scale_a:new c.bg(h,e.u_scale_a),u_scale_b:new c.bg(h,e.u_scale_b),u_pixel_coord_upper:new c.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bU(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new c.bg(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_texture:new c.bP(h,e.u_texture),u_ele_delta:new c.bg(h,e.u_ele_delta),u_fog_matrix:new c.bR(h,e.u_fog_matrix),u_fog_color:new c.bQ(h,e.u_fog_color),u_fog_ground_blend:new c.bg(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new c.bg(h,e.u_fog_ground_blend_opacity),u_horizon_color:new c.bQ(h,e.u_horizon_color),u_horizon_fog_blend:new c.bg(h,e.u_horizon_fog_blend),u_is_globe_mode:new c.bg(h,e.u_is_globe_mode)}),terrainDepth:(h,e)=>({u_ele_delta:new c.bg(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_texture:new c.bP(h,e.u_texture),u_terrain_coords_id:new c.bg(h,e.u_terrain_coords_id),u_ele_delta:new c.bg(h,e.u_ele_delta)}),projectionErrorMeasurement:(h,e)=>({u_input:new c.bg(h,e.u_input),u_output_expected:new c.bg(h,e.u_output_expected)}),atmosphere:(h,e)=>({u_sun_pos:new c.bT(h,e.u_sun_pos),u_atmosphere_blend:new c.bg(h,e.u_atmosphere_blend),u_globe_position:new c.bT(h,e.u_globe_position),u_globe_radius:new c.bg(h,e.u_globe_radius),u_inv_proj_matrix:new c.bR(h,e.u_inv_proj_matrix)}),sky:(h,e)=>({u_sky_color:new c.bQ(h,e.u_sky_color),u_horizon_color:new c.bQ(h,e.u_horizon_color),u_horizon:new c.bU(h,e.u_horizon),u_horizon_normal:new c.bU(h,e.u_horizon_normal),u_sky_horizon_blend:new c.bg(h,e.u_sky_horizon_blend),u_sky_blend:new c.bg(h,e.u_sky_blend)})};class Vl{constructor(e,n,a){this.context=e;const l=e.gl;this.buffer=l.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Pa={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Cr{constructor(e,n,a,l){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=l,this.context=e;const u=e.gl;this.buffer=u.createBuffer(),e.bindVertexBuffer.set(this.buffer),u.bufferData(u.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?u.DYNAMIC_DRAW:u.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let a=0;a<this.attributes.length;a++){const l=n.attributes[this.attributes[a].name];l!==void 0&&e.enableVertexAttribArray(l)}}setVertexAttribPointers(e,n,a){for(let l=0;l<this.attributes.length;l++){const u=this.attributes[l],f=n.attributes[u.name];f!==void 0&&e.vertexAttribPointer(f,u.components,e[Pa[u.type]],!1,this.itemSize,u.offset+this.itemSize*(a||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class ht{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 Ao extends ht{getDefault(){return c.bf.transparent}set(e){const 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 ko extends ht{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Ul extends ht{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class zo extends ht{getDefault(){return[!0,!0,!0,!0]}set(e){const 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 Mn extends ht{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Lo extends ht{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class nh extends ht{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const 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 sh extends ht{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const 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 ah extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=e,this.dirty=!1}}class oh extends ht{getDefault(){return[0,1]}set(e){const 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 $l extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=e,this.dirty=!1}}class lh extends ht{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Zl extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.BLEND):n.disable(n.BLEND),this.current=e,this.dirty=!1}}class Sa extends ht{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const 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 Ma extends ht{getDefault(){return c.bf.transparent}set(e){const 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 Ia extends ht{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class Do extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=e,this.dirty=!1}}class In extends ht{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Os extends ht{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class es extends ht{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Gi extends ht{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Gl extends ht{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const 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 ql extends ht{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class Ro extends ht{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Cn extends ht{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class Ca extends ht{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ea extends ht{getDefault(){return null}set(e){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class js extends ht{getDefault(){return null}set(e){var n;if(e===this.current&&!this.dirty)return;const a=this.gl;vr(a)?a.bindVertexArray(e):(n=a.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Aa extends ht{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Wl extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class ts extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Jr extends ht{constructor(e,n){super(e),this.context=e,this.parent=n}getDefault(){return null}}class Hl extends Jr{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Fo extends Jr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class nt extends Jr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const Ns="Framebuffer is not complete";class ch{constructor(e,n,a,l,u){this.context=e,this.width=n,this.height=a;const f=e.gl,_=this.framebuffer=f.createFramebuffer();if(this.colorAttachment=new Hl(e,_),l)this.depthAttachment=u?new nt(e,_):new Fo(e,_);else if(u)throw new Error("Stencil cannot be set without depth");if(f.checkFramebufferStatus(f.FRAMEBUFFER)!==f.FRAMEBUFFER_COMPLETE)throw new Error(Ns)}destroy(){const e=this.context.gl,n=this.colorAttachment.get();if(n&&e.deleteTexture(n),this.depthAttachment){const a=this.depthAttachment.get();a&&e.deleteRenderbuffer(a)}e.deleteFramebuffer(this.framebuffer)}}class Xl{constructor(e){var n,a;if(this.gl=e,this.clearColor=new Ao(this),this.clearDepth=new ko(this),this.clearStencil=new Ul(this),this.colorMask=new zo(this),this.depthMask=new Mn(this),this.stencilMask=new Lo(this),this.stencilFunc=new nh(this),this.stencilOp=new sh(this),this.stencilTest=new ah(this),this.depthRange=new oh(this),this.depthTest=new $l(this),this.depthFunc=new lh(this),this.blend=new Zl(this),this.blendFunc=new Sa(this),this.blendColor=new Ma(this),this.blendEquation=new Ia(this),this.cullFace=new Do(this),this.cullFaceSide=new In(this),this.frontFace=new Os(this),this.program=new es(this),this.activeTexture=new Gi(this),this.viewport=new Gl(this),this.bindFramebuffer=new ql(this),this.bindRenderbuffer=new Ro(this),this.bindTexture=new Cn(this),this.bindVertexBuffer=new Ca(this),this.bindElementBuffer=new Ea(this),this.bindVertexArray=new js(this),this.pixelStoreUnpack=new Aa(this),this.pixelStoreUnpackPremultiplyAlpha=new Wl(this),this.pixelStoreUnpackFlipY=new ts(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),vr(e)){this.HALF_FLOAT=e.HALF_FLOAT;const l=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=e.RGBA16F)!==null&&n!==void 0?n:l==null?void 0:l.RGBA16F_EXT,this.RGB16F=(a=e.RGB16F)!==null&&a!==void 0?a:l==null?void 0:l.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const l=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=l==null?void 0:l.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 Vl(this,e,n)}createVertexBuffer(e,n,a){return new Cr(this,e,n,a)}createRenderbuffer(e,n,a){const l=this.gl,u=l.createRenderbuffer();return this.bindRenderbuffer.set(u),l.renderbufferStorage(l.RENDERBUFFER,e,n,a),this.bindRenderbuffer.set(null),u}createFramebuffer(e,n,a,l){return new ch(this,e,n,a,l)}clear({color:e,depth:n,stencil:a}){const l=this.gl;let u=0;e&&(u|=l.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(u|=l.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),a!==void 0&&(u|=l.STENCIL_BUFFER_BIT,this.clearStencil.set(a),this.stencilMask.set(255)),l.clear(u)}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){c.bH(e.blendFunction,Pt.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 vr(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 vr(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)}}let Qr;function Yl(h,e,n,a,l){const u=h.context,f=h.transform,_=u.gl,y=h.useProgram("collisionBox"),b=[];let w=0,S=0;for(let N=0;N<a.length;N++){const U=a[N],q=e.getTile(U).getBucket(n);if(!q)continue;const $=l?q.textCollisionBox:q.iconCollisionBox,H=q.collisionCircleArray;H.length>0&&(b.push({circleArray:H,circleOffset:S,coord:U}),w+=H.length/4,S=w),$&&y.draw(u,_.LINES,We.disabled,lt.disabled,h.colorModeForRenderPass(),Ue.disabled,wa(h.transform),h.style.map.terrain&&h.style.map.terrain.getTerrainData(U),f.getProjectionData({overscaledTileID:U,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,$.layoutVertexBuffer,$.indexBuffer,$.segments,null,h.transform.zoom,null,null,$.collisionVertexBuffer)}if(!l||!b.length)return;const P=h.useProgram("collisionCircle"),I=new c.b$;I.resize(4*w),I._trim();let k=0;for(const N of b)for(let U=0;U<N.circleArray.length/4;U++){const q=4*U,$=N.circleArray[q+0],H=N.circleArray[q+1],K=N.circleArray[q+2],G=N.circleArray[q+3];I.emplace(k++,$,H,K,G,0),I.emplace(k++,$,H,K,G,1),I.emplace(k++,$,H,K,G,2),I.emplace(k++,$,H,K,G,3)}(!Qr||Qr.length<2*w)&&(Qr=function(N){const U=2*N,q=new c.c1;q.resize(U),q._trim();for(let $=0;$<U;$++){const H=6*$;q.uint16[H+0]=4*$+0,q.uint16[H+1]=4*$+1,q.uint16[H+2]=4*$+2,q.uint16[H+3]=4*$+2,q.uint16[H+4]=4*$+3,q.uint16[H+5]=4*$+0}return q}(w));const O=u.createIndexBuffer(Qr,!0),B=u.createVertexBuffer(I,c.c0.members,!0);for(const N of b){const U=eh(h.transform);P.draw(u,_.TRIANGLES,We.disabled,lt.disabled,h.colorModeForRenderPass(),Ue.disabled,U,h.style.map.terrain&&h.style.map.terrain.getTerrainData(N.coord),null,n.id,B,O,c.aM.simpleSegment(0,2*N.circleOffset,N.circleArray.length,N.circleArray.length/2),null,h.transform.zoom,null,null,null)}B.destroy(),O.destroy()}const hh=c.ag(new Float32Array(16));function Kl(h,e,n,a,l,u){const{horizontalAlign:f,verticalAlign:_}=c.aH(h);return new c.P((-(f-.5)*e/l+a[0])*u,(-(_-.5)*n/l+a[1])*u)}function uh(h,e,n,a,l,u){const f=e.tileAnchorPoint.add(new c.P(e.translation[0],e.translation[1]));if(e.pitchWithMap){let _=a.mult(u);n||(_=_.rotate(-l));const y=f.add(_);return Ut(y.x,y.y,e.pitchedLabelPlaneMatrix,e.getElevation).point}if(n){const _=hi(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(h),y=Math.atan(_.y/_.x)+(_.x<0?Math.PI:0);return h.add(a.rotate(y))}return h.add(a)}function Bo(h,e,n,a,l,u,f,_,y,b,w,S){const P=h.text.placedSymbolArray,I=h.text.dynamicLayoutVertexArray,k=h.icon.dynamicLayoutVertexArray,O={};I.clear();for(let B=0;B<P.length;B++){const N=P.get(B),U=N.hidden||!N.crossTileID||h.allowVerticalPlacement&&!N.placedOrientation?null:a[N.crossTileID];if(U){const q=new c.P(N.anchorX,N.anchorY),$={getElevation:S,width:l.width,height:l.height,pitchedLabelPlaneMatrix:u,pitchWithMap:n,transform:l,tileAnchorPoint:q,translation:b,unwrappedTileID:w},H=n?Wr(q.x,q.y,$):hi(q.x,q.y,$),K=Te(l.cameraToCenterDistance,H.signedDistanceFromCamera);let G=c.ap(h.textSizeData,_,N)*K/c.aB;n&&(G*=h.tilePixelRatio/f);const{width:te,height:ue,anchor:ae,textOffset:oe,textBoxScale:he}=U,we=Kl(ae,te,ue,oe,he,G),Se=l.getPitchedTextCorrection(q.x+b[0],q.y+b[1],w),ye=uh(H.point,$,e,we,-l.bearingInRadians,Se),Le=h.allowVerticalPlacement&&N.placedOrientation===c.ao.vertical?Math.PI/2:0;for(let Ke=0;Ke<N.numGlyphs;Ke++)c.av(I,ye,Le);y&&N.associatedIconIndex>=0&&(O[N.associatedIconIndex]={shiftedAnchor:ye,angle:Le})}else xr(N.numGlyphs,I)}if(y){k.clear();const B=h.icon.placedSymbolArray;for(let N=0;N<B.length;N++){const U=B.get(N);if(U.hidden)xr(U.numGlyphs,k);else{const q=O[N];if(q)for(let $=0;$<U.numGlyphs;$++)c.av(k,q.shiftedAnchor,q.angle);else xr(U.numGlyphs,k)}}h.icon.dynamicLayoutVertexBuffer.updateData(k)}h.text.dynamicLayoutVertexBuffer.updateData(I)}function ka(h,e,n){return n.iconsInText&&e?"symbolTextAndIcon":h?"symbolSDF":"symbolIcon"}function Vs(h,e,n,a,l,u,f,_,y,b,w,S,P){const I=h.context,k=I.gl,O=h.transform,B=_==="map",N=y==="map",U=_!=="viewport"&&n.layout.get("symbol-placement")!=="point",q=B&&!N&&!U,$=!n.layout.get("symbol-sort-key").isConstant();let H=!1;const K=h.getDepthModeForSublayer(0,We.ReadOnly),G=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),te=[],ue=O.getCircleRadiusCorrection();for(const ae of a){const oe=e.getTile(ae),he=oe.getBucket(n);if(!he)continue;const we=l?he.text:he.icon;if(!we||!we.segments.get().length||!we.hasVisibleVertices)continue;const Se=we.programConfigurations.get(n.id),ye=l||he.sdfIcons,Le=l?he.textSizeData:he.iconSizeData,Ke=N||O.pitch!==0,dt=h.useProgram(ka(ye,l,he),Se),yt=c.an(Le,O.zoom),mt=h.style.map.terrain&&h.style.map.terrain.getTerrainData(ae);let Ct,zt,Xe,xt,Zt=[0,0],Yt=null;if(l)zt=oe.glyphAtlasTexture,Xe=k.LINEAR,Ct=oe.glyphAtlasTexture.size,he.iconsInText&&(Zt=oe.imageAtlasTexture.size,Yt=oe.imageAtlasTexture,xt=Ke||h.options.rotating||h.options.zooming||Le.kind==="composite"||Le.kind==="camera"?k.LINEAR:k.NEAREST);else{const Gt=n.layout.get("icon-size").constantOr(0)!==1||he.iconsNeedLinear;zt=oe.imageAtlasTexture,Xe=ye||h.options.rotating||h.options.zooming||Gt||Ke?k.LINEAR:k.NEAREST,Ct=oe.imageAtlasTexture.size}const ri=c.aC(oe,1,h.transform.zoom),Si=Nt(B,h.transform,ri),ar=c.L();c.aq(ar,Si);const tn=rt(N,B,h.transform,ri),rn=c.aD(O,oe,u,f),ps=O.getProjectionData({overscaledTileID:ae,applyGlobeMatrix:!P,applyTerrainMatrix:!0}),fs=G&&he.hasTextData(),Rn=n.layout.get("icon-text-fit")!=="none"&&fs&&he.hasIconData();if(U){const Gt=h.style.map.terrain?(Hi,qt)=>h.style.map.terrain.getElevation(ae,Hi,qt):null,Kt=n.layout.get("text-rotation-alignment")==="map";At(he,h,l,Si,ar,N,b,Kt,ae.toUnwrapped(),O.width,O.height,rn,Gt)}const Fn=l&&G||Rn,Li=U||Fn?hh:N?Si:h.transform.clipSpaceToPixelsMatrix,or=ye&&n.paint.get(l?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Mi;Mi=ye?he.iconsInText?rh(Le.kind,yt,q,N,U,Fn,h,Li,tn,rn,Ct,Zt,ue):Ol(Le.kind,yt,q,N,U,Fn,h,Li,tn,rn,l,Ct,0,ue):Bs(Le.kind,yt,q,N,U,Fn,h,Li,tn,rn,l,Ct,ue);const nn={program:dt,buffers:we,uniformValues:Mi,projectionData:ps,atlasTexture:zt,atlasTextureIcon:Yt,atlasInterpolation:Xe,atlasInterpolationIcon:xt,isSDF:ye,hasHalo:or};if($&&he.canOverlap){H=!0;const Gt=we.segments.get();for(const Kt of Gt)te.push({segments:new c.aM([Kt]),sortKey:Kt.sortKey,state:nn,terrainData:mt})}else te.push({segments:we.segments,sortKey:0,state:nn,terrainData:mt})}H&&te.sort((ae,oe)=>ae.sortKey-oe.sortKey);for(const ae of te){const oe=ae.state;if(I.activeTexture.set(k.TEXTURE0),oe.atlasTexture.bind(oe.atlasInterpolation,k.CLAMP_TO_EDGE),oe.atlasTextureIcon&&(I.activeTexture.set(k.TEXTURE1),oe.atlasTextureIcon&&oe.atlasTextureIcon.bind(oe.atlasInterpolationIcon,k.CLAMP_TO_EDGE)),oe.isSDF){const he=oe.uniformValues;oe.hasHalo&&(he.u_is_halo=1,Us(oe.buffers,ae.segments,n,h,oe.program,K,w,S,he,oe.projectionData,ae.terrainData)),he.u_is_halo=0}Us(oe.buffers,ae.segments,n,h,oe.program,K,w,S,oe.uniformValues,oe.projectionData,ae.terrainData)}}function Us(h,e,n,a,l,u,f,_,y,b,w){const S=a.context;l.draw(S,S.gl.TRIANGLES,u,f,_,Ue.backCCW,y,w,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,a.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function Oo(h,e,n,a,l){const u=h.context,f=u.gl,_=lt.disabled,y=new Pt([f.ONE,f.ONE],c.bf.transparent,[!0,!0,!0,!0]),b=e.getBucket(n);if(!b)return;const w=a.key;let S=n.heatmapFbos.get(w);S||(S=$s(u,e.tileSize,e.tileSize),n.heatmapFbos.set(w,S)),u.bindFramebuffer.set(S.framebuffer),u.viewport.set([0,0,e.tileSize,e.tileSize]),u.clear({color:c.bf.transparent});const P=b.programConfigurations.get(n.id),I=h.useProgram("heatmap",P,!l),k=h.transform.getProjectionData({overscaledTileID:e.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),O=h.style.map.terrain.getTerrainData(a);I.draw(u,f.TRIANGLES,We.disabled,_,y,Ue.disabled,Ll(e,h.transform.zoom,n.paint.get("heatmap-intensity"),1),O,k,n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,n.paint,h.transform.zoom,P)}function Jl(h,e,n,a,l){const u=h.context,f=u.gl,_=h.transform;u.setColorMode(h.colorModeForRenderPass());const y=Zs(u,e),b=n.key,w=e.heatmapFbos.get(b);if(!w)return;u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,w.colorAttachment.get()),u.activeTexture.set(f.TEXTURE1),y.bind(f.LINEAR,f.CLAMP_TO_EDGE);const S=_.getProjectionData({overscaledTileID:n,applyTerrainMatrix:l,applyGlobeMatrix:!a});h.useProgram("heatmapTexture").draw(u,f.TRIANGLES,We.disabled,lt.disabled,h.colorModeForRenderPass(),Ue.disabled,Po(h,e,0,1),null,S,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,_.zoom),w.destroy(),e.heatmapFbos.delete(b)}function $s(h,e,n){var a,l;const u=h.gl,f=u.createTexture();u.bindTexture(u.TEXTURE_2D,f),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.LINEAR),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.LINEAR);const _=(a=h.HALF_FLOAT)!==null&&a!==void 0?a:u.UNSIGNED_BYTE,y=(l=h.RGBA16F)!==null&&l!==void 0?l:u.RGBA;u.texImage2D(u.TEXTURE_2D,0,y,e,n,0,u.RGBA,_,null);const b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(f),b}function Zs(h,e){return e.colorRampTexture||(e.colorRampTexture=new c.T(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function Gs(h,e,n,a,l){if(!n||!a||!a.imageAtlas)return;const u=a.imageAtlas.patternPositions;let f=u[n.to.toString()],_=u[n.from.toString()];if(!f&&_&&(f=_),!_&&f&&(_=f),!f||!_){const y=l.getPaintProperty(e);f=u[y],_=u[y]}f&&_&&h.setConstantPatternPositions(f,_)}function za(h,e,n,a,l,u,f,_){const y=h.context.gl,b="fill-pattern",w=n.paint.get(b),S=w&&w.constantOr(1),P=n.getCrossfadeParameters();let I,k,O,B,N;const U=h.transform,q=n.paint.get("fill-translate"),$=n.paint.get("fill-translate-anchor");f?(k=S&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",I=y.LINES):(k=S?"fillPattern":"fill",I=y.TRIANGLES);const H=w.constantOr(null);for(const K of a){const G=e.getTile(K);if(S&&!G.patternsLoaded())continue;const te=G.getBucket(n);if(!te)continue;const ue=te.programConfigurations.get(n.id),ae=h.useProgram(k,ue),oe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(K);S&&(h.context.activeTexture.set(y.TEXTURE0),G.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),ue.updatePaintBuffers(P)),Gs(ue,b,H,G,n);const he=U.getProjectionData({overscaledTileID:K,applyGlobeMatrix:!_,applyTerrainMatrix:!0}),we=c.aD(U,G,q,$);if(f){B=te.indexBuffer2,N=te.segments2;const ye=[y.drawingBufferWidth,y.drawingBufferHeight];O=k==="fillOutlinePattern"&&S?Rs(h,P,G,ye,we):Ds(ye,we)}else B=te.indexBuffer,N=te.segments,O=S?ba(h,P,G,we):{u_fill_translate:we};const Se=h.stencilModeForClipping(K);ae.draw(h.context,I,l,Se,u,Ue.backCCW,O,oe,he,n.id,te.layoutVertexBuffer,B,N,n.paint,h.transform.zoom,ue)}}function jo(h,e,n,a,l,u,f,_){const y=h.context,b=y.gl,w="fill-extrusion-pattern",S=n.paint.get(w),P=S.constantOr(1),I=n.getCrossfadeParameters(),k=n.paint.get("fill-extrusion-opacity"),O=S.constantOr(null),B=h.transform;for(const N of a){const U=e.getTile(N),q=U.getBucket(n);if(!q)continue;const $=h.style.map.terrain&&h.style.map.terrain.getTerrainData(N),H=q.programConfigurations.get(n.id),K=h.useProgram(P?"fillExtrusionPattern":"fillExtrusion",H);P&&(h.context.activeTexture.set(b.TEXTURE0),U.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),H.updatePaintBuffers(I));const G=B.getProjectionData({overscaledTileID:N,applyGlobeMatrix:!_,applyTerrainMatrix:!0});Gs(H,w,O,U,n);const te=c.aD(B,U,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ue=n.paint.get("fill-extrusion-vertical-gradient"),ae=P?Jc(h,ue,k,te,N,I,U):er(h,ue,k,te);K.draw(y,y.gl.TRIANGLES,l,u,f,Ue.backCCW,ae,$,G,n.id,q.layoutVertexBuffer,q.indexBuffer,q.segments,n.paint,h.transform.zoom,H,h.style.map.terrain&&q.centroidVertexBuffer)}}function En(h,e,n,a,l,u,f,_,y){var b;const w=h.style.projection,S=h.context,P=h.transform,I=S.gl,k=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],O=h.useProgram("hillshade",null,!1,k),B=!h.options.moving;for(const N of a){const U=e.getTile(N),q=U.fbo;if(!q)continue;const $=w.getMeshFromTileID(S,N.canonical,_,!0,"raster"),H=(b=h.style.map.terrain)===null||b===void 0?void 0:b.getTerrainData(N);S.activeTexture.set(I.TEXTURE0),I.bindTexture(I.TEXTURE_2D,q.colorAttachment.get());const K=P.getProjectionData({overscaledTileID:N,aligned:B,applyGlobeMatrix:!y,applyTerrainMatrix:!0});O.draw(S,I.TRIANGLES,u,l[N.overscaledZ],f,Ue.backCCW,th(h,U,n),H,K,n.id,$.vertexBuffer,$.indexBuffer,$.segments)}}function No(h,e,n,a,l,u,f,_,y){var b;const w=h.style.projection,S=h.context,P=h.transform,I=S.gl,k=h.useProgram("colorRelief"),O=!h.options.moving;let B=!0,N=0;for(const U of a){const q=e.getTile(U),$=q.dem;if(B){const ae=I.getParameter(I.MAX_TEXTURE_SIZE),{elevationTexture:oe,colorTexture:he}=n.getColorRampTextures(S,ae,$.getUnpackVector());S.activeTexture.set(I.TEXTURE1),oe.bind(I.NEAREST,I.CLAMP_TO_EDGE),S.activeTexture.set(I.TEXTURE4),he.bind(I.LINEAR,I.CLAMP_TO_EDGE),B=!1,N=oe.size[0]}if(!$||!$.data)continue;const H=$.stride,K=$.getPixels();if(S.activeTexture.set(I.TEXTURE0),S.pixelStoreUnpackPremultiplyAlpha.set(!1),q.demTexture=q.demTexture||h.getTileTexture(H),q.demTexture){const ae=q.demTexture;ae.update(K,{premultiply:!1}),ae.bind(I.LINEAR,I.CLAMP_TO_EDGE)}else q.demTexture=new c.T(S,K,I.RGBA,{premultiply:!1}),q.demTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE);const G=w.getMeshFromTileID(S,U.canonical,_,!0,"raster"),te=(b=h.style.map.terrain)===null||b===void 0?void 0:b.getTerrainData(U),ue=P.getProjectionData({overscaledTileID:U,aligned:O,applyGlobeMatrix:!y,applyTerrainMatrix:!0});k.draw(S,I.TRIANGLES,u,l[U.overscaledZ],f,Ue.backCCW,Rl(n,q.dem,N),te,ue,n.id,G.vertexBuffer,G.indexBuffer,G.segments)}}const La=[new c.P(0,0),new c.P(c.$,0),new c.P(c.$,c.$),new c.P(0,c.$)];function An(h,e,n,a,l,u,f,_,y=!1,b=!1){const w=a[a.length-1].overscaledZ,S=h.context,P=S.gl,I=h.useProgram("raster"),k=h.transform,O=h.style.projection,B=h.colorModeForRenderPass(),N=!h.options.moving;for(const U of a){const q=h.getDepthModeForSublayer(U.overscaledZ-w,n.paint.get("raster-opacity")===1?We.ReadWrite:We.ReadOnly,P.LESS),$=e.getTile(U);$.registerFadeDuration(n.paint.get("raster-fade-duration"));const H=e.findLoadedParent(U,0),K=e.findLoadedSibling(U),G=Vo($,H||K||null,e,n,h.transform,h.style.map.terrain);let te,ue;const ae=n.paint.get("raster-resampling")==="nearest"?P.NEAREST:P.LINEAR;S.activeTexture.set(P.TEXTURE0),$.texture.bind(ae,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST),S.activeTexture.set(P.TEXTURE1),H?(H.texture.bind(ae,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST),te=Math.pow(2,H.tileID.overscaledZ-$.tileID.overscaledZ),ue=[$.tileID.canonical.x*te%1,$.tileID.canonical.y*te%1]):$.texture.bind(ae,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST),$.texture.useMipmap&&S.extTextureFilterAnisotropic&&h.transform.pitch>20&&P.texParameterf(P.TEXTURE_2D,S.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,S.extTextureFilterAnisotropicMax);const oe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(U),he=k.getProjectionData({overscaledTileID:U,aligned:N,applyGlobeMatrix:!b,applyTerrainMatrix:!0}),we=Fs(ue||[0,0],te||1,G,n,_),Se=O.getMeshFromTileID(S,U.canonical,u,f,"raster");I.draw(S,P.TRIANGLES,q,l?l[U.overscaledZ]:lt.disabled,B,y?Ue.frontCCW:Ue.backCCW,we,oe,he,n.id,Se.vertexBuffer,Se.indexBuffer,Se.segments)}}function Vo(h,e,n,a,l,u){const f=a.paint.get("raster-fade-duration");if(!u&&f>0){const _=Ee.now(),y=(_-h.timeAdded)/f,b=e?(_-e.timeAdded)/f:-1,w=n.getSource(),S=Re(l,{tileSize:w.tileSize,roundZoom:w.roundZoom}),P=!e||Math.abs(e.tileID.overscaledZ-S)>Math.abs(h.tileID.overscaledZ-S),I=P&&h.refreshedUponExpiration?1:c.ah(P?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-I}:{opacity:I,mix:0}}return{opacity:1,mix:0}}const Ql=new c.bf(1,0,0,1),ec=new c.bf(0,1,0,1),Da=new c.bf(0,0,1,1),Uo=new c.bf(1,0,1,1),dh=new c.bf(0,1,1,1);function $o(h,e,n,a){Tr(h,0,e+n/2,h.transform.width,n,a)}function kt(h,e,n,a){Tr(h,e-n/2,0,n,h.transform.height,a)}function Tr(h,e,n,a,l,u){const f=h.context,_=f.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,n*h.pixelRatio,a*h.pixelRatio,l*h.pixelRatio),f.clear({color:u}),_.disable(_.SCISSOR_TEST)}function qi(h,e,n){const a=h.context,l=a.gl,u=h.useProgram("debug"),f=We.disabled,_=lt.disabled,y=h.colorModeForRenderPass(),b="$debug",w=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);a.activeTexture.set(l.TEXTURE0);const S=e.getTileByID(n.key).latestRawTileData,P=Math.floor((S&&S.byteLength||0)/1024),I=e.getTile(n).tileSize,k=512/Math.min(I,512)*(n.overscaledZ/h.transform.zoom)*.5;let O=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(O+=` => ${n.overscaledZ}`),function(N,U){N.initDebugOverlayCanvas();const q=N.debugOverlayCanvas,$=N.context.gl,H=N.debugOverlayCanvas.getContext("2d");H.clearRect(0,0,q.width,q.height),H.shadowColor="white",H.shadowBlur=2,H.lineWidth=1.5,H.strokeStyle="white",H.textBaseline="top",H.font="bold 36px Open Sans, sans-serif",H.fillText(U,5,5),H.strokeText(U,5,5),N.debugOverlayTexture.update(q),N.debugOverlayTexture.bind($.LINEAR,$.CLAMP_TO_EDGE)}(h,`${O} ${P}kB`);const B=h.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});u.draw(a,l.TRIANGLES,f,_,Pt.alphaBlended,Ue.disabled,Pn(c.bf.transparent,k),null,B,b,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),u.draw(a,l.LINE_STRIP,f,_,y,Ue.disabled,Pn(c.bf.red),w,B,b,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function Ra(h,e,n,a){const{isRenderingGlobe:l}=a,u=h.context,f=u.gl,_=h.transform,y=h.colorModeForRenderPass(),b=h.getDepthModeFor3D(),w=h.useProgram("terrain");u.bindFramebuffer.set(null),u.viewport.set([0,0,h.width,h.height]);for(const S of n){const P=e.getTerrainMesh(S.tileID),I=h.renderToTexture.getTexture(S),k=e.getTerrainData(S.tileID);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,I.texture);const O=e.getMeshFrameDelta(_.zoom),B=_.calculateFogMatrix(S.tileID.toUnwrapped()),N=xa(O,B,h.style.sky,_.pitch,l),U=_.getProjectionData({overscaledTileID:S.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});w.draw(u,f.TRIANGLES,b,lt.disabled,y,Ue.backCCW,N,k,U,"terrain",P.vertexBuffer,P.indexBuffer,P.segments)}}function qs(h,e){if(!e.mesh){const n=new c.aL;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const a=new c.aN;a.emplaceBack(0,1,2),a.emplaceBack(0,2,3),e.mesh=new yn(h.createVertexBuffer(n,Kr.members),h.createIndexBuffer(a),c.aM.simpleSegment(0,0,n.length,a.length))}return e.mesh}class tc{constructor(e,n){this.context=new Xl(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:c.ag(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Qe.maxUnderzooming+Qe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Yn}resize(e,n,a){if(this.width=Math.floor(e*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const l of this.style._order)this.style._layers[l].resize()}setup(){const e=this.context,n=new c.aL;n.emplaceBack(0,0),n.emplaceBack(c.$,0),n.emplaceBack(0,c.$),n.emplaceBack(c.$,c.$),this.tileExtentBuffer=e.createVertexBuffer(n,Kr.members),this.tileExtentSegments=c.aM.simpleSegment(0,0,4,2);const a=new c.aL;a.emplaceBack(0,0),a.emplaceBack(c.$,0),a.emplaceBack(0,c.$),a.emplaceBack(c.$,c.$),this.debugBuffer=e.createVertexBuffer(a,Kr.members),this.debugSegments=c.aM.simpleSegment(0,0,4,5);const l=new c.c6;l.emplaceBack(0,0,0,0),l.emplaceBack(c.$,0,c.$,0),l.emplaceBack(0,c.$,0,c.$),l.emplaceBack(c.$,c.$,c.$,c.$),this.rasterBoundsBuffer=e.createVertexBuffer(l,Yc.members),this.rasterBoundsSegments=c.aM.simpleSegment(0,0,4,2);const u=new c.aL;u.emplaceBack(0,0),u.emplaceBack(c.$,0),u.emplaceBack(0,c.$),u.emplaceBack(c.$,c.$),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(u,Kr.members),this.rasterBoundsSegmentsPosOnly=c.aM.simpleSegment(0,0,4,5);const f=new c.aL;f.emplaceBack(0,0),f.emplaceBack(1,0),f.emplaceBack(0,1),f.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(f,Kr.members),this.viewportSegments=c.aM.simpleSegment(0,0,4,2);const _=new c.c7;_.emplaceBack(0),_.emplaceBack(1),_.emplaceBack(3),_.emplaceBack(2),_.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(_);const y=new c.aN;y.emplaceBack(1,0,2),y.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(y);const b=this.context.gl;this.stencilClearMode=new lt({func:b.ALWAYS,mask:0},0,255,b.ZERO,b.ZERO,b.ZERO),this.tileExtentMesh=new yn(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=c.L();c.bY(a,0,this.width,this.height,0,0,1),c.N(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const l={mainMatrix:a,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a};this.useProgram("clippingMask",null,!0).draw(e,n.TRIANGLES,We.disabled,this.stencilClearMode,Pt.disabled,Ue.disabled,null,null,l,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n,a){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source,this.nextStencilID+n.length>256&&this.clearStencil();const l=this.context;l.setColorMode(Pt.disabled),l.setDepthMode(We.disabled);const u={};for(const f of n)u[f.key]=this.nextStencilID++;this._renderTileMasks(u,n,a,!0),this._renderTileMasks(u,n,a,!1),this._tileClippingMaskIDs=u}_renderTileMasks(e,n,a,l){const u=this.context,f=u.gl,_=this.style.projection,y=this.transform,b=this.useProgram("clippingMask");for(const w of n){const S=e[w.key],P=this.style.map.terrain&&this.style.map.terrain.getTerrainData(w),I=_.getMeshFromTileID(this.context,w.canonical,l,!0,"stencil"),k=y.getProjectionData({overscaledTileID:w,applyGlobeMatrix:!a,applyTerrainMatrix:!0});b.draw(u,f.TRIANGLES,We.disabled,new lt({func:f.ALWAYS,mask:0},S,255,f.KEEP,f.KEEP,f.REPLACE),Pt.disabled,a?Ue.disabled:Ue.backCCW,null,P,k,"$clipping",I.vertexBuffer,I.indexBuffer,I.segments)}}_renderTilesDepthBuffer(){const e=this.context,n=e.gl,a=this.style.projection,l=this.transform,u=this.useProgram("depth"),f=this.getDepthModeFor3D(),_=ne(l,{tileSize:l.tileSize});for(const y of _){const b=this.style.map.terrain&&this.style.map.terrain.getTerrainData(y),w=a.getMeshFromTileID(this.context,y.canonical,!0,!0,"raster"),S=l.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!0,applyTerrainMatrix:!0});u.draw(e,n.TRIANGLES,f,lt.disabled,Pt.disabled,Ue.backCCW,null,b,S,"$clipping",w.vertexBuffer,w.indexBuffer,w.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new lt({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){const n=this.context.gl;return new lt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const n=this.context.gl,a=e.sort((f,_)=>_.overscaledZ-f.overscaledZ),l=a[a.length-1].overscaledZ,u=a[0].overscaledZ-l+1;if(u>1){this.currentStencilSource=void 0,this.nextStencilID+u>256&&this.clearStencil();const f={};for(let _=0;_<u;_++)f[_+l]=new lt({func:n.GEQUAL,mask:255},_+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=u,[f,a]}return[{[l]:lt.disabled},a]}stencilConfigForOverlapTwoPass(e){const n=this.context.gl,a=e.sort((f,_)=>_.overscaledZ-f.overscaledZ),l=a[a.length-1].overscaledZ,u=a[0].overscaledZ-l+1;if(this.clearStencil(),u>1){const f={},_={};for(let y=0;y<u;y++)f[y+l]=new lt({func:n.GREATER,mask:255},u+1+y,255,n.KEEP,n.KEEP,n.REPLACE),_[y+l]=new lt({func:n.GREATER,mask:255},1+y,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*u+1,[f,_,a]}return this.nextStencilID=3,[{[l]:new lt({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[l]:new lt({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},a]}colorModeForRenderPass(){const e=this.context.gl;return this._showOverdrawInspector?new Pt([e.CONSTANT_COLOR,e.ONE],new c.bf(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Pt.unblended:Pt.alphaBlended}getDepthModeForSublayer(e,n,a){if(!this.opaquePassEnabledForLayer())return We.disabled;const l=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new We(a||this.context.gl.LEQUAL,n,[l,l])}getDepthModeFor3D(){return new We(this.context.gl.LEQUAL,We.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){var a,l;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(Ee.now()),this.imageManager.beginFrame();const u=this.style._order,f=this.style.sourceCaches,_={},y={},b={},w={isRenderingToTexture:!1,isRenderingGlobe:((a=e.projection)===null||a===void 0?void 0:a.transitionState)>0};for(const P in f){const I=f[P];I.used&&I.prepare(this.context),_[P]=I.getVisibleCoordinates(!1),y[P]=_[P].slice().reverse(),b[P]=I.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let P=0;P<u.length;P++)if(this.style._layers[u[P]].is3D()){this.opaquePassCutoff=P;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const P of u){const I=this.style._layers[P];if(!I.hasOffscreenPass()||I.isHidden(this.transform.zoom))continue;const k=y[I.source];(I.type==="custom"||k.length)&&this.renderLayer(this,f[I.source],I,k,w)}if((l=this.style.projection)===null||l===void 0||l.updateGPUdependent({context:this.context,useProgram:P=>this.useProgram(P)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?c.bf.black:c.bf.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(P,I){const k=P.context,O=k.gl,B=((K,G,te)=>{const ue=Math.cos(G.rollInRadians),ae=Math.sin(G.rollInRadians),oe=Y(G),he=G.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:K.properties.get("sky-color"),u_horizon_color:K.properties.get("horizon-color"),u_horizon:[(G.width/2-oe*ae)*te,(G.height/2+oe*ue)*te],u_horizon_normal:[-ae,ue],u_sky_horizon_blend:K.properties.get("sky-horizon-blend")*G.height/2*te,u_sky_blend:he}})(I,P.style.map.transform,P.pixelRatio),N=new We(O.LEQUAL,We.ReadWrite,[0,1]),U=lt.disabled,q=P.colorModeForRenderPass(),$=P.useProgram("sky"),H=qs(k,I);$.draw(k,O.TRIANGLES,N,U,q,Ue.disabled,B,null,void 0,"sky",H.vertexBuffer,H.indexBuffer,H.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=u.length-1;this.currentLayer>=0;this.currentLayer--){const P=this.style._layers[u[this.currentLayer]],I=f[P.source],k=_[P.source];this._renderTileClippingMasks(P,k,!1),this.renderLayer(this,I,P,k,w)}this.renderPass="translucent";let S=!1;for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const P=this.style._layers[u[this.currentLayer]],I=f[P.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(P,w))continue;this.opaquePassEnabledForLayer()||S||(S=!0,w.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const k=(P.type==="symbol"?b:y)[P.source];this._renderTileClippingMasks(P,_[P.source],!!this.renderToTexture),this.renderLayer(this,I,P,k,w)}if(w.isRenderingGlobe&&function(P,I,k){const O=P.context,B=O.gl,N=P.useProgram("atmosphere"),U=new We(B.LEQUAL,We.ReadOnly,[0,1]),q=P.transform,$=function(he,we){const Se=he.properties.get("position"),ye=[-Se.x,-Se.y,-Se.z],Le=c.ag(new Float64Array(16));return he.properties.get("anchor")==="map"&&(c.b6(Le,Le,we.rollInRadians),c.b7(Le,Le,-we.pitchInRadians),c.b6(Le,Le,we.bearingInRadians),c.b7(Le,Le,we.center.lat*Math.PI/180),c.bz(Le,Le,-we.center.lng*Math.PI/180)),c.c5(ye,ye,Le),ye}(k,P.transform),H=q.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),K=I.properties.get("atmosphere-blend")*H.projectionTransition;if(K===0)return;const G=Jn(q.worldSize,q.center.lat),te=q.inverseProjectionMatrix,ue=new Float64Array(4);ue[3]=1,c.aw(ue,ue,q.modelViewProjectionMatrix),ue[0]/=ue[3],ue[1]/=ue[3],ue[2]/=ue[3],ue[3]=1,c.aw(ue,ue,te),ue[0]/=ue[3],ue[1]/=ue[3],ue[2]/=ue[3],ue[3]=1;const ae=((he,we,Se,ye,Le)=>({u_sun_pos:he,u_atmosphere_blend:we,u_globe_position:Se,u_globe_radius:ye,u_inv_proj_matrix:Le}))($,K,[ue[0],ue[1],ue[2]],G,te),oe=qs(O,I);N.draw(O,B.TRIANGLES,U,lt.disabled,Pt.alphaBlended,Ue.disabled,ae,null,null,"atmosphere",oe.vertexBuffer,oe.indexBuffer,oe.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const P=function(I,k){let O=null;const B=Object.values(I._layers).flatMap($=>$.source&&!$.isHidden(k)?[I.sourceCaches[$.source]]:[]),N=B.filter($=>$.getSource().type==="vector"),U=B.filter($=>$.getSource().type!=="vector"),q=$=>{(!O||O.getSource().maxzoom<$.getSource().maxzoom)&&(O=$)};return N.forEach($=>q($)),O||U.forEach($=>q($)),O}(this.style,this.transform.zoom);P&&function(I,k,O){for(let B=0;B<O.length;B++)qi(I,k,O[B])}(this,P,P.getVisibleCoordinates())}this.options.showPadding&&function(P){const I=P.transform.padding;$o(P,P.transform.height-(I.top||0),3,Ql),$o(P,I.bottom||0,3,ec),kt(P,I.left||0,3,Da),kt(P,P.transform.width-(I.right||0),3,Uo);const k=P.transform.centerPoint;(function(O,B,N,U){Tr(O,B-1,N-10,2,20,U),Tr(O,B-10,N-1,20,2,U)})(P,k.x,P.transform.height-k.y,dh)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,a=this.transform.modelViewProjectionMatrix;let l=this.terrainFacilitator.dirty;l||(l=e?!c.c8(n,a):!c.c9(n,a)),l||(l=this.style.map.terrain.sourceCache.anyTilesAfterTime(this.terrainFacilitator.renderTime)),l&&(c.ca(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(u,f){const _=u.context,y=_.gl,b=u.transform,w=Pt.unblended,S=new We(y.LEQUAL,We.ReadWrite,[0,1]),P=f.sourceCache.getRenderableTiles(),I=u.useProgram("terrainDepth");_.bindFramebuffer.set(f.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),_.clear({color:c.bf.transparent,depth:1});for(const k of P){const O=f.getTerrainMesh(k.tileID),B=f.getTerrainData(k.tileID),N=b.getProjectionData({overscaledTileID:k.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),U={u_ele_delta:f.getMeshFrameDelta(b.zoom)};I.draw(_,y.TRIANGLES,S,lt.disabled,w,Ue.backCCW,U,B,N,"terrain",O.vertexBuffer,O.indexBuffer,O.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain),function(u,f){const _=u.context,y=_.gl,b=u.transform,w=Pt.unblended,S=new We(y.LEQUAL,We.ReadWrite,[0,1]),P=f.getCoordsTexture(),I=f.sourceCache.getRenderableTiles(),k=u.useProgram("terrainCoords");_.bindFramebuffer.set(f.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),_.clear({color:c.bf.transparent,depth:1}),f.coordsIndex=[];for(const O of I){const B=f.getTerrainMesh(O.tileID),N=f.getTerrainData(O.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,P.texture);const U={u_terrain_coords_id:(255-f.coordsIndex.length)/255,u_texture:0,u_ele_delta:f.getMeshFrameDelta(b.zoom)},q=b.getProjectionData({overscaledTileID:O.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});k.draw(_,y.TRIANGLES,S,lt.disabled,w,Ue.backCCW,U,N,q,"terrain",B.vertexBuffer,B.indexBuffer,B.segments),f.coordsIndex.push(O.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain))}renderLayer(e,n,a,l,u){a.isHidden(this.transform.zoom)||(a.type==="background"||a.type==="custom"||(l||[]).length)&&(this.id=a.id,c.cb(a)?function(f,_,y,b,w,S){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:P}=S,I=lt.disabled,k=f.colorModeForRenderPass();(y._unevaluatedLayout.hasValue("text-variable-anchor")||y._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(O,B,N,U,q,$,H,K,G){const te=B.transform,ue=B.style.map.terrain,ae=q==="map",oe=$==="map";for(const he of O){const we=U.getTile(he),Se=we.getBucket(N);if(!Se||!Se.text||!Se.text.segments.get().length)continue;const ye=c.an(Se.textSizeData,te.zoom),Le=c.aC(we,1,B.transform.zoom),Ke=Nt(ae,B.transform,Le),dt=N.layout.get("icon-text-fit")!=="none"&&Se.hasIconData();if(ye){const yt=Math.pow(2,te.zoom-we.tileID.overscaledZ),mt=ue?(Ct,zt)=>ue.getElevation(he,Ct,zt):null;Bo(Se,ae,oe,G,te,Ke,yt,ye,dt,c.aD(te,we,H,K),he.toUnwrapped(),mt)}}}(b,f,y,_,y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),w),y.paint.get("icon-opacity").constantOr(1)!==0&&Vs(f,_,y,b,!1,y.paint.get("icon-translate"),y.paint.get("icon-translate-anchor"),y.layout.get("icon-rotation-alignment"),y.layout.get("icon-pitch-alignment"),y.layout.get("icon-keep-upright"),I,k,P),y.paint.get("text-opacity").constantOr(1)!==0&&Vs(f,_,y,b,!0,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),y.layout.get("text-keep-upright"),I,k,P),_.map.showCollisionBoxes&&(Yl(f,_,y,b,!0),Yl(f,_,y,b,!1))}(e,n,a,l,this.style.placement.variableOffsets,u):c.cc(a)?function(f,_,y,b,w){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:S}=w,P=y.paint.get("circle-opacity"),I=y.paint.get("circle-stroke-width"),k=y.paint.get("circle-stroke-opacity"),O=!y.layout.get("circle-sort-key").isConstant();if(P.constantOr(1)===0&&(I.constantOr(1)===0||k.constantOr(1)===0))return;const B=f.context,N=B.gl,U=f.transform,q=f.getDepthModeForSublayer(0,We.ReadOnly),$=lt.disabled,H=f.colorModeForRenderPass(),K=[],G=U.getCircleRadiusCorrection();for(let te=0;te<b.length;te++){const ue=b[te],ae=_.getTile(ue),oe=ae.getBucket(y);if(!oe)continue;const he=y.paint.get("circle-translate"),we=y.paint.get("circle-translate-anchor"),Se=c.aD(U,ae,he,we),ye=oe.programConfigurations.get(y.id),Le=f.useProgram("circle",ye),Ke=oe.layoutVertexBuffer,dt=oe.indexBuffer,yt=f.style.map.terrain&&f.style.map.terrain.getTerrainData(ue),mt={programConfiguration:ye,program:Le,layoutVertexBuffer:Ke,indexBuffer:dt,uniformValues:Qc(f,ae,y,Se,G),terrainData:yt,projectionData:U.getProjectionData({overscaledTileID:ue,applyGlobeMatrix:!S,applyTerrainMatrix:!0})};if(O){const Ct=oe.segments.get();for(const zt of Ct)K.push({segments:new c.aM([zt]),sortKey:zt.sortKey,state:mt})}else K.push({segments:oe.segments,sortKey:0,state:mt})}O&&K.sort((te,ue)=>te.sortKey-ue.sortKey);for(const te of K){const{programConfiguration:ue,program:ae,layoutVertexBuffer:oe,indexBuffer:he,uniformValues:we,terrainData:Se,projectionData:ye}=te.state;ae.draw(B,N.TRIANGLES,q,$,H,Ue.backCCW,we,Se,ye,y.id,oe,he,te.segments,y.paint,f.transform.zoom,ue)}}(e,n,a,l,u):c.cd(a)?function(f,_,y,b,w){if(y.paint.get("heatmap-opacity")===0)return;const S=f.context,{isRenderingToTexture:P,isRenderingGlobe:I}=w;if(f.style.map.terrain){for(const k of b){const O=_.getTile(k);_.hasRenderableParent(k)||(f.renderPass==="offscreen"?Oo(f,O,y,k,I):f.renderPass==="translucent"&&Jl(f,y,k,P,I))}S.viewport.set([0,0,f.width,f.height])}else f.renderPass==="offscreen"?function(k,O,B,N){const U=k.context,q=U.gl,$=k.transform,H=lt.disabled,K=new Pt([q.ONE,q.ONE],c.bf.transparent,[!0,!0,!0,!0]);(function(G,te,ue){const ae=G.gl;G.activeTexture.set(ae.TEXTURE1),G.viewport.set([0,0,te.width/4,te.height/4]);let oe=ue.heatmapFbos.get(c.c2);oe?(ae.bindTexture(ae.TEXTURE_2D,oe.colorAttachment.get()),G.bindFramebuffer.set(oe.framebuffer)):(oe=$s(G,te.width/4,te.height/4),ue.heatmapFbos.set(c.c2,oe))})(U,k,B),U.clear({color:c.bf.transparent});for(let G=0;G<N.length;G++){const te=N[G];if(O.hasRenderableParent(te))continue;const ue=O.getTile(te),ae=ue.getBucket(B);if(!ae)continue;const oe=ae.programConfigurations.get(B.id),he=k.useProgram("heatmap",oe),we=$.getProjectionData({overscaledTileID:te,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),Se=$.getCircleRadiusCorrection();he.draw(U,q.TRIANGLES,We.disabled,H,K,Ue.backCCW,Ll(ue,$.zoom,B.paint.get("heatmap-intensity"),Se),null,we,B.id,ae.layoutVertexBuffer,ae.indexBuffer,ae.segments,B.paint,$.zoom,oe)}U.viewport.set([0,0,k.width,k.height])}(f,_,y,b):f.renderPass==="translucent"&&function(k,O){const B=k.context,N=B.gl;B.setColorMode(k.colorModeForRenderPass());const U=O.heatmapFbos.get(c.c2);U&&(B.activeTexture.set(N.TEXTURE0),N.bindTexture(N.TEXTURE_2D,U.colorAttachment.get()),B.activeTexture.set(N.TEXTURE1),Zs(B,O).bind(N.LINEAR,N.CLAMP_TO_EDGE),k.useProgram("heatmapTexture").draw(B,N.TRIANGLES,We.disabled,lt.disabled,k.colorModeForRenderPass(),Ue.disabled,Po(k,O,0,1),null,null,O.id,k.viewportBuffer,k.quadTriangleIndexBuffer,k.viewportSegments,O.paint,k.transform.zoom))}(f,y)}(e,n,a,l,u):c.ce(a)?function(f,_,y,b,w){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:S}=w,P=y.paint.get("line-opacity"),I=y.paint.get("line-width");if(P.constantOr(1)===0||I.constantOr(1)===0)return;const k=f.getDepthModeForSublayer(0,We.ReadOnly),O=f.colorModeForRenderPass(),B=y.paint.get("line-dasharray"),N=y.paint.get("line-pattern"),U=N.constantOr(1),q=y.paint.get("line-gradient"),$=y.getCrossfadeParameters(),H=U?"linePattern":B?"lineSDF":q?"lineGradient":"line",K=f.context,G=K.gl,te=f.transform;let ue=!0;for(const ae of b){const oe=_.getTile(ae);if(U&&!oe.patternsLoaded())continue;const he=oe.getBucket(y);if(!he)continue;const we=he.programConfigurations.get(y.id),Se=f.context.program.get(),ye=f.useProgram(H,we),Le=ue||ye.program!==Se,Ke=f.style.map.terrain&&f.style.map.terrain.getTerrainData(ae),dt=N.constantOr(null);if(dt&&oe.imageAtlas){const Xe=oe.imageAtlas,xt=Xe.patternPositions[dt.to.toString()],Zt=Xe.patternPositions[dt.from.toString()];xt&&Zt&&we.setConstantPatternPositions(xt,Zt)}const yt=te.getProjectionData({overscaledTileID:ae,applyGlobeMatrix:!S,applyTerrainMatrix:!0}),mt=te.getPixelScale(),Ct=U?Bl(f,oe,y,mt,$):B?Sn(f,oe,y,mt,B,$):q?Fl(f,oe,y,mt,he.lineClipsArray.length):Ta(f,oe,y,mt);if(U)K.activeTexture.set(G.TEXTURE0),oe.imageAtlasTexture.bind(G.LINEAR,G.CLAMP_TO_EDGE),we.updatePaintBuffers($);else if(B&&(Le||f.lineAtlas.dirty))K.activeTexture.set(G.TEXTURE0),f.lineAtlas.bind(K);else if(q){const Xe=he.gradients[y.id];let xt=Xe.texture;if(y.gradientVersion!==Xe.version){let Zt=256;if(y.stepInterpolant){const Yt=_.getSource().maxzoom,ri=ae.canonical.z===Yt?Math.ceil(1<<f.transform.maxZoom-ae.canonical.z):1;Zt=c.ah(c.c3(he.maxLineLength/c.$*1024*ri),256,K.maxTextureSize)}Xe.gradient=c.c4({expression:y.gradientExpression(),evaluationKey:"lineProgress",resolution:Zt,image:Xe.gradient||void 0,clips:he.lineClipsArray}),Xe.texture?Xe.texture.update(Xe.gradient):Xe.texture=new c.T(K,Xe.gradient,G.RGBA),Xe.version=y.gradientVersion,xt=Xe.texture}K.activeTexture.set(G.TEXTURE0),xt.bind(y.stepInterpolant?G.NEAREST:G.LINEAR,G.CLAMP_TO_EDGE)}const zt=f.stencilModeForClipping(ae);ye.draw(K,G.TRIANGLES,k,zt,O,Ue.disabled,Ct,Ke,yt,y.id,he.layoutVertexBuffer,he.indexBuffer,he.segments,y.paint,f.transform.zoom,we,he.layoutVertexBuffer2),ue=!1}}(e,n,a,l,u):c.cf(a)?function(f,_,y,b,w){const S=y.paint.get("fill-color"),P=y.paint.get("fill-opacity");if(P.constantOr(1)===0)return;const{isRenderingToTexture:I}=w,k=f.colorModeForRenderPass(),O=y.paint.get("fill-pattern"),B=f.opaquePassEnabledForLayer()&&!O.constantOr(1)&&S.constantOr(c.bf.transparent).a===1&&P.constantOr(0)===1?"opaque":"translucent";if(f.renderPass===B){const N=f.getDepthModeForSublayer(1,f.renderPass==="opaque"?We.ReadWrite:We.ReadOnly);za(f,_,y,b,N,k,!1,I)}if(f.renderPass==="translucent"&&y.paint.get("fill-antialias")){const N=f.getDepthModeForSublayer(y.getPaintProperty("fill-outline-color")?2:0,We.ReadOnly);za(f,_,y,b,N,k,!0,I)}}(e,n,a,l,u):c.cg(a)?function(f,_,y,b,w){const S=y.paint.get("fill-extrusion-opacity");if(S===0)return;const{isRenderingToTexture:P}=w;if(f.renderPass==="translucent"){const I=new We(f.context.gl.LEQUAL,We.ReadWrite,f.depthRangeFor3D);if(S!==1||y.paint.get("fill-extrusion-pattern").constantOr(1))jo(f,_,y,b,I,lt.disabled,Pt.disabled,P),jo(f,_,y,b,I,f.stencilModeFor3D(),f.colorModeForRenderPass(),P);else{const k=f.colorModeForRenderPass();jo(f,_,y,b,I,lt.disabled,k,P)}}}(e,n,a,l,u):c.ch(a)?function(f,_,y,b,w){if(f.renderPass!=="offscreen"&&f.renderPass!=="translucent")return;const{isRenderingToTexture:S}=w,P=f.context,I=f.style.projection.useSubdivision,k=f.getDepthModeForSublayer(0,We.ReadOnly),O=f.colorModeForRenderPass();if(f.renderPass==="offscreen")(function(B,N,U,q,$,H,K){const G=B.context,te=G.gl;for(const ue of U){const ae=N.getTile(ue),oe=ae.dem;if(!oe||!oe.data||!ae.needsHillshadePrepare)continue;const he=oe.dim,we=oe.stride,Se=oe.getPixels();if(G.activeTexture.set(te.TEXTURE1),G.pixelStoreUnpackPremultiplyAlpha.set(!1),ae.demTexture=ae.demTexture||B.getTileTexture(we),ae.demTexture){const Le=ae.demTexture;Le.update(Se,{premultiply:!1}),Le.bind(te.NEAREST,te.CLAMP_TO_EDGE)}else ae.demTexture=new c.T(G,Se,te.RGBA,{premultiply:!1}),ae.demTexture.bind(te.NEAREST,te.CLAMP_TO_EDGE);G.activeTexture.set(te.TEXTURE0);let ye=ae.fbo;if(!ye){const Le=new c.T(G,{width:he,height:he,data:null},te.RGBA);Le.bind(te.LINEAR,te.CLAMP_TO_EDGE),ye=ae.fbo=G.createFramebuffer(he,he,!0,!1),ye.colorAttachment.set(Le.texture)}G.bindFramebuffer.set(ye.framebuffer),G.viewport.set([0,0,he,he]),B.useProgram("hillshadePrepare").draw(G,te.TRIANGLES,$,H,K,Ue.disabled,Dl(ae.tileID,oe),null,null,q.id,B.rasterBoundsBuffer,B.quadTriangleIndexBuffer,B.rasterBoundsSegments),ae.needsHillshadePrepare=!1}})(f,_,b,y,k,lt.disabled,O),P.viewport.set([0,0,f.width,f.height]);else if(f.renderPass==="translucent")if(I){const[B,N,U]=f.stencilConfigForOverlapTwoPass(b);En(f,_,y,U,B,k,O,!1,S),En(f,_,y,U,N,k,O,!0,S)}else{const[B,N]=f.getStencilConfigForOverlapAndUpdateStencilID(b);En(f,_,y,N,B,k,O,!1,S)}}(e,n,a,l,u):c.ci(a)?function(f,_,y,b,w){if(f.renderPass!=="translucent"||!b.length)return;const{isRenderingToTexture:S}=w,P=f.style.projection.useSubdivision,I=f.getDepthModeForSublayer(0,We.ReadOnly),k=f.colorModeForRenderPass();if(P){const[O,B,N]=f.stencilConfigForOverlapTwoPass(b);No(f,_,y,N,O,I,k,!1,S),No(f,_,y,N,B,I,k,!0,S)}else{const[O,B]=f.getStencilConfigForOverlapAndUpdateStencilID(b);No(f,_,y,B,O,I,k,!1,S)}}(e,n,a,l,u):c.cj(a)?function(f,_,y,b,w){if(f.renderPass!=="translucent"||y.paint.get("raster-opacity")===0||!b.length)return;const{isRenderingToTexture:S}=w,P=_.getSource(),I=f.style.projection.useSubdivision;if(P instanceof yr)An(f,_,y,b,null,!1,!1,P.tileCoords,P.flippedWindingOrder,S);else if(I){const[k,O,B]=f.stencilConfigForOverlapTwoPass(b);An(f,_,y,B,k,!1,!0,La,!1,S),An(f,_,y,B,O,!0,!0,La,!1,S)}else{const[k,O]=f.getStencilConfigForOverlapAndUpdateStencilID(b);An(f,_,y,O,k,!1,!0,La,!1,S)}}(e,n,a,l,u):c.ck(a)?function(f,_,y,b,w){const S=y.paint.get("background-color"),P=y.paint.get("background-opacity");if(P===0)return;const{isRenderingToTexture:I}=w,k=f.context,O=k.gl,B=f.style.projection,N=f.transform,U=N.tileSize,q=y.paint.get("background-pattern");if(f.isPatternMissing(q))return;const $=!q&&S.a===1&&P===1&&f.opaquePassEnabledForLayer()?"opaque":"translucent";if(f.renderPass!==$)return;const H=lt.disabled,K=f.getDepthModeForSublayer(0,$==="opaque"?We.ReadWrite:We.ReadOnly),G=f.colorModeForRenderPass(),te=f.useProgram(q?"backgroundPattern":"background"),ue=b||ne(N,{tileSize:U,terrain:f.style.map.terrain});q&&(k.activeTexture.set(O.TEXTURE0),f.imageManager.bind(f.context));const ae=y.getCrossfadeParameters();for(const oe of ue){const he=N.getProjectionData({overscaledTileID:oe,applyGlobeMatrix:!I,applyTerrainMatrix:!0}),we=q?Nl(P,f,q,{tileID:oe,tileSize:U},ae):jl(P,S),Se=f.style.map.terrain&&f.style.map.terrain.getTerrainData(oe),ye=B.getMeshFromTileID(k,oe.canonical,!1,!0,"raster");te.draw(k,O.TRIANGLES,K,H,G,Ue.backCCW,we,Se,he,y.id,ye.vertexBuffer,ye.indexBuffer,ye.segments)}}(e,0,a,l,u):c.cl(a)&&function(f,_,y,b){const{isRenderingGlobe:w}=b,S=f.context,P=y.implementation,I=f.style.projection,k=f.transform,O=k.getProjectionDataForCustomLayer(w),B={farZ:k.farZ,nearZ:k.nearZ,fov:k.fov*Math.PI/180,modelViewProjectionMatrix:k.modelViewProjectionMatrix,projectionMatrix:k.projectionMatrix,shaderData:{variantName:I.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
741
+ `);vr(w)||(H=function(ae){return ae.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(H),K=function(ae){return ae.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(K));const G=w.createShader(w.FRAGMENT_SHADER);if(w.isContextLost())return void(this.failedToCreate=!0);if(w.shaderSource(G,H),w.compileShader(G),!w.getShaderParameter(G,w.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${w.getShaderInfoLog(G)}`);w.attachShader(this.program,G);const te=w.createShader(w.VERTEX_SHADER);if(w.isContextLost())return void(this.failedToCreate=!0);if(w.shaderSource(te,K),w.compileShader(te),!w.getShaderParameter(te,w.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${w.getShaderInfoLog(te)}`);w.attachShader(this.program,te),this.attributes={};const ue={};this.numAttributes=I.length;for(let ae=0;ae<this.numAttributes;ae++)I[ae]&&(w.bindAttribLocation(this.program,ae,I[ae]),this.attributes[I[ae]]=ae);if(w.linkProgram(this.program),!w.getProgramParameter(this.program,w.LINK_STATUS))throw new Error(`Program failed to link: ${w.getProgramInfoLog(this.program)}`);w.deleteShader(te),w.deleteShader(G);for(let ae=0;ae<q.length;ae++){const oe=q[ae];if(oe&&!ue[oe]){const he=w.getUniformLocation(this.program,oe);he&&(ue[oe]=he)}}this.fixedUniforms=l(e,ue),this.terrainUniforms=((ae,oe)=>({u_depth:new c.bP(ae,oe.u_depth),u_terrain:new c.bP(ae,oe.u_terrain),u_terrain_dim:new c.bg(ae,oe.u_terrain_dim),u_terrain_matrix:new c.bR(ae,oe.u_terrain_matrix),u_terrain_unpack:new c.bS(ae,oe.u_terrain_unpack),u_terrain_exaggeration:new c.bg(ae,oe.u_terrain_exaggeration)}))(e,ue),this.projectionUniforms=((ae,oe)=>({u_projection_matrix:new c.bR(ae,oe.u_projection_matrix),u_projection_tile_mercator_coords:new c.bS(ae,oe.u_projection_tile_mercator_coords),u_projection_clipping_plane:new c.bS(ae,oe.u_projection_clipping_plane),u_projection_transition:new c.bg(ae,oe.u_projection_transition),u_projection_fallback_matrix:new c.bR(ae,oe.u_projection_fallback_matrix)}))(e,ue),this.binderUniforms=a?a.getUniforms(e,ue):[]}draw(e,n,a,l,u,f,_,y,b,w,S,P,I,k,O,B,N,U,q){const $=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(l),e.setColorMode(u),e.setCullFace(f),y){e.activeTexture.set($.TEXTURE2),$.bindTexture($.TEXTURE_2D,y.depthTexture),e.activeTexture.set($.TEXTURE3),$.bindTexture($.TEXTURE_2D,y.texture);for(const K in this.terrainUniforms)this.terrainUniforms[K].set(y[K])}if(b)for(const K in b)this.projectionUniforms[wo[K]].set(b[K]);if(_)for(const K in this.fixedUniforms)this.fixedUniforms[K].set(_[K]);B&&B.setUniforms(e,this.binderUniforms,k,{zoom:O});let H=0;switch(n){case $.LINES:H=2;break;case $.TRIANGLES:H=3;break;case $.LINE_STRIP:H=1}for(const K of I.get()){const G=K.vaos||(K.vaos={});(G[w]||(G[w]=new Kc)).bind(e,this,S,B?B.getPaintVertexBuffers():[],P,K.vertexOffset,N,U,q),$.drawElements(n,K.primitiveLength*H,$.UNSIGNED_SHORT,K.primitiveOffset*H*2)}}}function va(h,e,n){const a=1/c.aC(n,1,e.transform.tileZoom),l=Math.pow(2,n.tileID.overscaledZ),u=n.tileSize*Math.pow(2,e.transform.tileZoom)/l,f=u*(n.tileID.canonical.x+n.tileID.wrap*l),_=u*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[f>>16,_>>16],u_pixel_coord_lower:[65535&f,65535&_]}}const er=(h,e,n,a)=>{const l=h.style.light,u=l.properties.get("position"),f=[u.x,u.y,u.z],_=c.bV();l.properties.get("anchor")==="viewport"&&c.bW(_,h.transform.bearingInRadians),c.bX(f,f,_);const y=h.transform.transformLightDirection(f),b=l.properties.get("color");return{u_lightpos:f,u_lightpos_globe:y,u_lightintensity:l.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+e,u_opacity:n,u_fill_translate:a}},Jc=(h,e,n,a,l,u,f)=>c.e(er(h,e,n,a),va(u,h,f),{u_height_factor:-Math.pow(2,l.overscaledZ)/f.tileSize/8}),ba=(h,e,n,a)=>c.e(va(e,h,n),{u_fill_translate:a}),Ds=(h,e)=>({u_world:h,u_fill_translate:e}),Rs=(h,e,n,a,l)=>c.e(ba(h,e,n,l),{u_world:a}),Qc=(h,e,n,a,l)=>{const u=h.transform;let f,_,y=0;if(n.paint.get("circle-pitch-alignment")==="map"){const b=c.aC(e,1,u.zoom);f=!0,_=[b,b],y=b/(c.$*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*l}else f=!1,_=u.pixelsToGLUnits;return{u_camera_to_center_distance:u.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+f,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:y,u_translate:a}},wa=h=>({u_pixel_extrude_scale:[1/h.width,1/h.height]}),eh=h=>({u_viewport_size:[h.width,h.height]}),Pn=(h,e=1)=>({u_color:h,u_overlay:0,u_overlay_scale:e}),Dl=(h,e,n,a)=>{const l=c.aC(h,1,e)/(c.$*Math.pow(2,h.tileID.overscaledZ))*2*Math.PI*a;return{u_extrude_scale:c.aC(h,1,e),u_intensity:n,u_globe_extrude_scale:l}},Po=(h,e,n,a)=>{const l=c.L();c.bY(l,0,h.width,h.height,0,0,1);const u=h.context.gl;return{u_matrix:l,u_world:[u.drawingBufferWidth,u.drawingBufferHeight],u_image:n,u_color_ramp:a,u_opacity:e.paint.get("heatmap-opacity")}},th=(h,e,n)=>{const a=n.paint.get("hillshade-accent-color");let l;switch(n.paint.get("hillshade-method")){case"basic":l=4;break;case"combined":l=1;break;case"igor":l=2;break;case"multidirectional":l=3;break;default:l=0}const u=n.getIlluminationProperties();for(let f=0;f<u.directionRadians.length;f++)n.paint.get("hillshade-illumination-anchor")==="viewport"&&(u.directionRadians[f]+=h.transform.bearingInRadians);return{u_image:0,u_latrange:So(0,e.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:u.altitudeRadians,u_azimuths:u.directionRadians,u_accent:a,u_method:l,u_highlights:u.highlightColor,u_shadows:u.shadowColor}},Rl=(h,e)=>{const n=e.stride,a=c.L();return c.bY(a,0,c.$,-c.$,0,0,1),c.M(a,a,[0,-c.$,0]),{u_matrix:a,u_image:1,u_dimension:[n,n],u_zoom:h.overscaledZ,u_unpack:e.getUnpackVector()}};function So(h,e){const n=Math.pow(2,e.canonical.z),a=e.canonical.y;return[new c.a1(0,a/n).toLngLat().lat,new c.a1(0,(a+1)/n).toLngLat().lat]}const Fl=(h,e,n=0)=>({u_image:0,u_unpack:e.getUnpackVector(),u_dimension:[e.stride,e.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:h.paint.get("color-relief-opacity")}),Ta=(h,e,n,a)=>{const l=h.transform;return{u_translation:Io(h,e,n),u_ratio:a/c.aC(e,1,l.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]]}},Bl=(h,e,n,a,l)=>c.e(Ta(h,e,n,a),{u_image:0,u_image_height:l}),Ol=(h,e,n,a,l)=>{const u=h.transform,f=Mo(e,u);return{u_translation:Io(h,e,n),u_texsize:e.imageAtlasTexture.size,u_ratio:a/c.aC(e,1,u.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[f,l.fromScale,l.toScale],u_fade:l.t,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},Sn=(h,e,n,a,l,u)=>{const f=h.lineAtlas,_=Mo(e,h.transform),y=n.layout.get("line-cap")==="round",b=f.getDash(l.from,y),w=f.getDash(l.to,y),S=b.width*u.fromScale,P=w.width*u.toScale;return c.e(Ta(h,e,n,a),{u_patternscale_a:[_/S,-b.height/2],u_patternscale_b:[_/P,-w.height/2],u_sdfgamma:f.width/(256*Math.min(S,P)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:w.y,u_mix:u.t})};function Mo(h,e){return 1/c.aC(h,1,e.tileZoom)}function Io(h,e,n){return c.aD(h.transform,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Fs=(h,e,n,a,l)=>{return{u_tl_parent:h,u_scale_parent:e,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.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:(f=a.paint.get("raster-saturation"),f>0?1-1/(1.001-f):-f),u_contrast_factor:(u=a.paint.get("raster-contrast"),u>0?1/(1-u):1+u),u_spin_weights:ih(a.paint.get("raster-hue-rotate")),u_coords_top:[l[0].x,l[0].y,l[1].x,l[1].y],u_coords_bottom:[l[3].x,l[3].y,l[2].x,l[2].y]};var u,f};function ih(h){h*=Math.PI/180;const e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const Bs=(h,e,n,a,l,u,f,_,y,b,w,S,P)=>{const I=f.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:I.cameraToCenterDistance,u_pitch:I.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:I.width/I.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_label_plane_matrix:_,u_coord_matrix:y,u_is_text:+w,u_pitch_with_map:+a,u_is_along_line:l,u_is_variable_anchor:u,u_texsize:S,u_texture:0,u_translation:b,u_pitched_scale:P}},jl=(h,e,n,a,l,u,f,_,y,b,w,S,P,I)=>{const k=f.transform;return c.e(Bs(h,e,n,a,l,u,f,_,y,b,w,S,I),{u_gamma_scale:a?Math.cos(k.pitch*Math.PI/180)*k.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:1})},rh=(h,e,n,a,l,u,f,_,y,b,w,S,P)=>c.e(jl(h,e,n,a,l,u,f,_,y,b,!0,w,0,P),{u_texsize_icon:S,u_texture_icon:1}),Nl=(h,e)=>({u_opacity:h,u_color:e}),Vl=(h,e,n,a,l)=>c.e(function(u,f,_,y){const b=_.imageManager.getPattern(u.from.toString()),w=_.imageManager.getPattern(u.to.toString()),{width:S,height:P}=_.imageManager.getPixelSize(),I=Math.pow(2,y.tileID.overscaledZ),k=y.tileSize*Math.pow(2,_.transform.tileZoom)/I,O=k*(y.tileID.canonical.x+y.tileID.wrap*I),B=k*y.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:b.tl,u_pattern_br_a:b.br,u_pattern_tl_b:w.tl,u_pattern_br_b:w.br,u_texsize:[S,P],u_mix:f.t,u_pattern_size_a:b.displaySize,u_pattern_size_b:w.displaySize,u_scale_a:f.fromScale,u_scale_b:f.toScale,u_tile_units_to_pixels:1/c.aC(y,1,_.transform.tileZoom),u_pixel_coord_upper:[O>>16,B>>16],u_pixel_coord_lower:[65535&O,65535&B]}}(n,l,e,a),{u_opacity:h}),Co=(h,e)=>{},Eo={fillExtrusion:(h,e)=>({u_lightpos:new c.bT(h,e.u_lightpos),u_lightpos_globe:new c.bT(h,e.u_lightpos_globe),u_lightintensity:new c.bg(h,e.u_lightintensity),u_lightcolor:new c.bT(h,e.u_lightcolor),u_vertical_gradient:new c.bg(h,e.u_vertical_gradient),u_opacity:new c.bg(h,e.u_opacity),u_fill_translate:new c.bU(h,e.u_fill_translate)}),fillExtrusionPattern:(h,e)=>({u_lightpos:new c.bT(h,e.u_lightpos),u_lightpos_globe:new c.bT(h,e.u_lightpos_globe),u_lightintensity:new c.bg(h,e.u_lightintensity),u_lightcolor:new c.bT(h,e.u_lightcolor),u_vertical_gradient:new c.bg(h,e.u_vertical_gradient),u_height_factor:new c.bg(h,e.u_height_factor),u_opacity:new c.bg(h,e.u_opacity),u_fill_translate:new c.bU(h,e.u_fill_translate),u_image:new c.bP(h,e.u_image),u_texsize:new c.bU(h,e.u_texsize),u_pixel_coord_upper:new c.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bU(h,e.u_pixel_coord_lower),u_scale:new c.bT(h,e.u_scale),u_fade:new c.bg(h,e.u_fade)}),fill:(h,e)=>({u_fill_translate:new c.bU(h,e.u_fill_translate)}),fillPattern:(h,e)=>({u_image:new c.bP(h,e.u_image),u_texsize:new c.bU(h,e.u_texsize),u_pixel_coord_upper:new c.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bU(h,e.u_pixel_coord_lower),u_scale:new c.bT(h,e.u_scale),u_fade:new c.bg(h,e.u_fade),u_fill_translate:new c.bU(h,e.u_fill_translate)}),fillOutline:(h,e)=>({u_world:new c.bU(h,e.u_world),u_fill_translate:new c.bU(h,e.u_fill_translate)}),fillOutlinePattern:(h,e)=>({u_world:new c.bU(h,e.u_world),u_image:new c.bP(h,e.u_image),u_texsize:new c.bU(h,e.u_texsize),u_pixel_coord_upper:new c.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bU(h,e.u_pixel_coord_lower),u_scale:new c.bT(h,e.u_scale),u_fade:new c.bg(h,e.u_fade),u_fill_translate:new c.bU(h,e.u_fill_translate)}),circle:(h,e)=>({u_camera_to_center_distance:new c.bg(h,e.u_camera_to_center_distance),u_scale_with_map:new c.bP(h,e.u_scale_with_map),u_pitch_with_map:new c.bP(h,e.u_pitch_with_map),u_extrude_scale:new c.bU(h,e.u_extrude_scale),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_globe_extrude_scale:new c.bg(h,e.u_globe_extrude_scale),u_translate:new c.bU(h,e.u_translate)}),collisionBox:(h,e)=>({u_pixel_extrude_scale:new c.bU(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_viewport_size:new c.bU(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new c.bQ(h,e.u_color),u_overlay:new c.bP(h,e.u_overlay),u_overlay_scale:new c.bg(h,e.u_overlay_scale)}),depth:Co,clippingMask:Co,heatmap:(h,e)=>({u_extrude_scale:new c.bg(h,e.u_extrude_scale),u_intensity:new c.bg(h,e.u_intensity),u_globe_extrude_scale:new c.bg(h,e.u_globe_extrude_scale)}),heatmapTexture:(h,e)=>({u_matrix:new c.bR(h,e.u_matrix),u_world:new c.bU(h,e.u_world),u_image:new c.bP(h,e.u_image),u_color_ramp:new c.bP(h,e.u_color_ramp),u_opacity:new c.bg(h,e.u_opacity)}),hillshade:(h,e)=>({u_image:new c.bP(h,e.u_image),u_latrange:new c.bU(h,e.u_latrange),u_exaggeration:new c.bg(h,e.u_exaggeration),u_altitudes:new c.b_(h,e.u_altitudes),u_azimuths:new c.b_(h,e.u_azimuths),u_accent:new c.bQ(h,e.u_accent),u_method:new c.bP(h,e.u_method),u_shadows:new c.bZ(h,e.u_shadows),u_highlights:new c.bZ(h,e.u_highlights)}),hillshadePrepare:(h,e)=>({u_matrix:new c.bR(h,e.u_matrix),u_image:new c.bP(h,e.u_image),u_dimension:new c.bU(h,e.u_dimension),u_zoom:new c.bg(h,e.u_zoom),u_unpack:new c.bS(h,e.u_unpack)}),colorRelief:(h,e)=>({u_image:new c.bP(h,e.u_image),u_unpack:new c.bS(h,e.u_unpack),u_dimension:new c.bU(h,e.u_dimension),u_elevation_stops:new c.bP(h,e.u_elevation_stops),u_color_stops:new c.bP(h,e.u_color_stops),u_color_ramp_size:new c.bP(h,e.u_color_ramp_size),u_opacity:new c.bg(h,e.u_opacity)}),line:(h,e)=>({u_translation:new c.bU(h,e.u_translation),u_ratio:new c.bg(h,e.u_ratio),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bU(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_translation:new c.bU(h,e.u_translation),u_ratio:new c.bg(h,e.u_ratio),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bU(h,e.u_units_to_pixels),u_image:new c.bP(h,e.u_image),u_image_height:new c.bg(h,e.u_image_height)}),linePattern:(h,e)=>({u_translation:new c.bU(h,e.u_translation),u_texsize:new c.bU(h,e.u_texsize),u_ratio:new c.bg(h,e.u_ratio),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_image:new c.bP(h,e.u_image),u_units_to_pixels:new c.bU(h,e.u_units_to_pixels),u_scale:new c.bT(h,e.u_scale),u_fade:new c.bg(h,e.u_fade)}),lineSDF:(h,e)=>({u_translation:new c.bU(h,e.u_translation),u_ratio:new c.bg(h,e.u_ratio),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new c.bU(h,e.u_units_to_pixels),u_patternscale_a:new c.bU(h,e.u_patternscale_a),u_patternscale_b:new c.bU(h,e.u_patternscale_b),u_sdfgamma:new c.bg(h,e.u_sdfgamma),u_image:new c.bP(h,e.u_image),u_tex_y_a:new c.bg(h,e.u_tex_y_a),u_tex_y_b:new c.bg(h,e.u_tex_y_b),u_mix:new c.bg(h,e.u_mix)}),raster:(h,e)=>({u_tl_parent:new c.bU(h,e.u_tl_parent),u_scale_parent:new c.bg(h,e.u_scale_parent),u_buffer_scale:new c.bg(h,e.u_buffer_scale),u_fade_t:new c.bg(h,e.u_fade_t),u_opacity:new c.bg(h,e.u_opacity),u_image0:new c.bP(h,e.u_image0),u_image1:new c.bP(h,e.u_image1),u_brightness_low:new c.bg(h,e.u_brightness_low),u_brightness_high:new c.bg(h,e.u_brightness_high),u_saturation_factor:new c.bg(h,e.u_saturation_factor),u_contrast_factor:new c.bg(h,e.u_contrast_factor),u_spin_weights:new c.bT(h,e.u_spin_weights),u_coords_top:new c.bS(h,e.u_coords_top),u_coords_bottom:new c.bS(h,e.u_coords_bottom)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new c.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bP(h,e.u_is_size_feature_constant),u_size_t:new c.bg(h,e.u_size_t),u_size:new c.bg(h,e.u_size),u_camera_to_center_distance:new c.bg(h,e.u_camera_to_center_distance),u_pitch:new c.bg(h,e.u_pitch),u_rotate_symbol:new c.bP(h,e.u_rotate_symbol),u_aspect_ratio:new c.bg(h,e.u_aspect_ratio),u_fade_change:new c.bg(h,e.u_fade_change),u_label_plane_matrix:new c.bR(h,e.u_label_plane_matrix),u_coord_matrix:new c.bR(h,e.u_coord_matrix),u_is_text:new c.bP(h,e.u_is_text),u_pitch_with_map:new c.bP(h,e.u_pitch_with_map),u_is_along_line:new c.bP(h,e.u_is_along_line),u_is_variable_anchor:new c.bP(h,e.u_is_variable_anchor),u_texsize:new c.bU(h,e.u_texsize),u_texture:new c.bP(h,e.u_texture),u_translation:new c.bU(h,e.u_translation),u_pitched_scale:new c.bg(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new c.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bP(h,e.u_is_size_feature_constant),u_size_t:new c.bg(h,e.u_size_t),u_size:new c.bg(h,e.u_size),u_camera_to_center_distance:new c.bg(h,e.u_camera_to_center_distance),u_pitch:new c.bg(h,e.u_pitch),u_rotate_symbol:new c.bP(h,e.u_rotate_symbol),u_aspect_ratio:new c.bg(h,e.u_aspect_ratio),u_fade_change:new c.bg(h,e.u_fade_change),u_label_plane_matrix:new c.bR(h,e.u_label_plane_matrix),u_coord_matrix:new c.bR(h,e.u_coord_matrix),u_is_text:new c.bP(h,e.u_is_text),u_pitch_with_map:new c.bP(h,e.u_pitch_with_map),u_is_along_line:new c.bP(h,e.u_is_along_line),u_is_variable_anchor:new c.bP(h,e.u_is_variable_anchor),u_texsize:new c.bU(h,e.u_texsize),u_texture:new c.bP(h,e.u_texture),u_gamma_scale:new c.bg(h,e.u_gamma_scale),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_is_halo:new c.bP(h,e.u_is_halo),u_translation:new c.bU(h,e.u_translation),u_pitched_scale:new c.bg(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new c.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new c.bP(h,e.u_is_size_feature_constant),u_size_t:new c.bg(h,e.u_size_t),u_size:new c.bg(h,e.u_size),u_camera_to_center_distance:new c.bg(h,e.u_camera_to_center_distance),u_pitch:new c.bg(h,e.u_pitch),u_rotate_symbol:new c.bP(h,e.u_rotate_symbol),u_aspect_ratio:new c.bg(h,e.u_aspect_ratio),u_fade_change:new c.bg(h,e.u_fade_change),u_label_plane_matrix:new c.bR(h,e.u_label_plane_matrix),u_coord_matrix:new c.bR(h,e.u_coord_matrix),u_is_text:new c.bP(h,e.u_is_text),u_pitch_with_map:new c.bP(h,e.u_pitch_with_map),u_is_along_line:new c.bP(h,e.u_is_along_line),u_is_variable_anchor:new c.bP(h,e.u_is_variable_anchor),u_texsize:new c.bU(h,e.u_texsize),u_texsize_icon:new c.bU(h,e.u_texsize_icon),u_texture:new c.bP(h,e.u_texture),u_texture_icon:new c.bP(h,e.u_texture_icon),u_gamma_scale:new c.bg(h,e.u_gamma_scale),u_device_pixel_ratio:new c.bg(h,e.u_device_pixel_ratio),u_is_halo:new c.bP(h,e.u_is_halo),u_translation:new c.bU(h,e.u_translation),u_pitched_scale:new c.bg(h,e.u_pitched_scale)}),background:(h,e)=>({u_opacity:new c.bg(h,e.u_opacity),u_color:new c.bQ(h,e.u_color)}),backgroundPattern:(h,e)=>({u_opacity:new c.bg(h,e.u_opacity),u_image:new c.bP(h,e.u_image),u_pattern_tl_a:new c.bU(h,e.u_pattern_tl_a),u_pattern_br_a:new c.bU(h,e.u_pattern_br_a),u_pattern_tl_b:new c.bU(h,e.u_pattern_tl_b),u_pattern_br_b:new c.bU(h,e.u_pattern_br_b),u_texsize:new c.bU(h,e.u_texsize),u_mix:new c.bg(h,e.u_mix),u_pattern_size_a:new c.bU(h,e.u_pattern_size_a),u_pattern_size_b:new c.bU(h,e.u_pattern_size_b),u_scale_a:new c.bg(h,e.u_scale_a),u_scale_b:new c.bg(h,e.u_scale_b),u_pixel_coord_upper:new c.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new c.bU(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new c.bg(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_texture:new c.bP(h,e.u_texture),u_ele_delta:new c.bg(h,e.u_ele_delta),u_fog_matrix:new c.bR(h,e.u_fog_matrix),u_fog_color:new c.bQ(h,e.u_fog_color),u_fog_ground_blend:new c.bg(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new c.bg(h,e.u_fog_ground_blend_opacity),u_horizon_color:new c.bQ(h,e.u_horizon_color),u_horizon_fog_blend:new c.bg(h,e.u_horizon_fog_blend),u_is_globe_mode:new c.bg(h,e.u_is_globe_mode)}),terrainDepth:(h,e)=>({u_ele_delta:new c.bg(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_texture:new c.bP(h,e.u_texture),u_terrain_coords_id:new c.bg(h,e.u_terrain_coords_id),u_ele_delta:new c.bg(h,e.u_ele_delta)}),projectionErrorMeasurement:(h,e)=>({u_input:new c.bg(h,e.u_input),u_output_expected:new c.bg(h,e.u_output_expected)}),atmosphere:(h,e)=>({u_sun_pos:new c.bT(h,e.u_sun_pos),u_atmosphere_blend:new c.bg(h,e.u_atmosphere_blend),u_globe_position:new c.bT(h,e.u_globe_position),u_globe_radius:new c.bg(h,e.u_globe_radius),u_inv_proj_matrix:new c.bR(h,e.u_inv_proj_matrix)}),sky:(h,e)=>({u_sky_color:new c.bQ(h,e.u_sky_color),u_horizon_color:new c.bQ(h,e.u_horizon_color),u_horizon:new c.bU(h,e.u_horizon),u_horizon_normal:new c.bU(h,e.u_horizon_normal),u_sky_horizon_blend:new c.bg(h,e.u_sky_horizon_blend),u_sky_blend:new c.bg(h,e.u_sky_blend)})};class Ul{constructor(e,n,a){this.context=e;const l=e.gl;this.buffer=l.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Pa={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Cr{constructor(e,n,a,l){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=l,this.context=e;const u=e.gl;this.buffer=u.createBuffer(),e.bindVertexBuffer.set(this.buffer),u.bufferData(u.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?u.DYNAMIC_DRAW:u.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let a=0;a<this.attributes.length;a++){const l=n.attributes[this.attributes[a].name];l!==void 0&&e.enableVertexAttribArray(l)}}setVertexAttribPointers(e,n,a){for(let l=0;l<this.attributes.length;l++){const u=this.attributes[l],f=n.attributes[u.name];f!==void 0&&e.vertexAttribPointer(f,u.components,e[Pa[u.type]],!1,this.itemSize,u.offset+this.itemSize*(a||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class ht{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 Ao extends ht{getDefault(){return c.bf.transparent}set(e){const 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 ko extends ht{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class $l extends ht{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class zo extends ht{getDefault(){return[!0,!0,!0,!0]}set(e){const 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 Mn extends ht{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Lo extends ht{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class nh extends ht{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const 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 sh extends ht{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const 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 ah extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=e,this.dirty=!1}}class oh extends ht{getDefault(){return[0,1]}set(e){const 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 Zl extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=e,this.dirty=!1}}class lh extends ht{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Gl extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.BLEND):n.disable(n.BLEND),this.current=e,this.dirty=!1}}class Sa extends ht{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const 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 Ma extends ht{getDefault(){return c.bf.transparent}set(e){const 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 Ia extends ht{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class Do extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=e,this.dirty=!1}}class In extends ht{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Os extends ht{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class es extends ht{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Gi extends ht{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ql extends ht{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const 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 Wl extends ht{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class Ro extends ht{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Cn extends ht{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class Ca extends ht{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ea extends ht{getDefault(){return null}set(e){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class js extends ht{getDefault(){return null}set(e){var n;if(e===this.current&&!this.dirty)return;const a=this.gl;vr(a)?a.bindVertexArray(e):(n=a.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Aa extends ht{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Hl extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class ts extends ht{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Jr extends ht{constructor(e,n){super(e),this.context=e,this.parent=n}getDefault(){return null}}class Xl extends Jr{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Fo extends Jr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class nt extends Jr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const Ns="Framebuffer is not complete";class ch{constructor(e,n,a,l,u){this.context=e,this.width=n,this.height=a;const f=e.gl,_=this.framebuffer=f.createFramebuffer();if(this.colorAttachment=new Xl(e,_),l)this.depthAttachment=u?new nt(e,_):new Fo(e,_);else if(u)throw new Error("Stencil cannot be set without depth");if(f.checkFramebufferStatus(f.FRAMEBUFFER)!==f.FRAMEBUFFER_COMPLETE)throw new Error(Ns)}destroy(){const e=this.context.gl,n=this.colorAttachment.get();if(n&&e.deleteTexture(n),this.depthAttachment){const a=this.depthAttachment.get();a&&e.deleteRenderbuffer(a)}e.deleteFramebuffer(this.framebuffer)}}class Yl{constructor(e){var n,a;if(this.gl=e,this.clearColor=new Ao(this),this.clearDepth=new ko(this),this.clearStencil=new $l(this),this.colorMask=new zo(this),this.depthMask=new Mn(this),this.stencilMask=new Lo(this),this.stencilFunc=new nh(this),this.stencilOp=new sh(this),this.stencilTest=new ah(this),this.depthRange=new oh(this),this.depthTest=new Zl(this),this.depthFunc=new lh(this),this.blend=new Gl(this),this.blendFunc=new Sa(this),this.blendColor=new Ma(this),this.blendEquation=new Ia(this),this.cullFace=new Do(this),this.cullFaceSide=new In(this),this.frontFace=new Os(this),this.program=new es(this),this.activeTexture=new Gi(this),this.viewport=new ql(this),this.bindFramebuffer=new Wl(this),this.bindRenderbuffer=new Ro(this),this.bindTexture=new Cn(this),this.bindVertexBuffer=new Ca(this),this.bindElementBuffer=new Ea(this),this.bindVertexArray=new js(this),this.pixelStoreUnpack=new Aa(this),this.pixelStoreUnpackPremultiplyAlpha=new Hl(this),this.pixelStoreUnpackFlipY=new ts(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),vr(e)){this.HALF_FLOAT=e.HALF_FLOAT;const l=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=e.RGBA16F)!==null&&n!==void 0?n:l==null?void 0:l.RGBA16F_EXT,this.RGB16F=(a=e.RGB16F)!==null&&a!==void 0?a:l==null?void 0:l.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const l=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=l==null?void 0:l.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 Ul(this,e,n)}createVertexBuffer(e,n,a){return new Cr(this,e,n,a)}createRenderbuffer(e,n,a){const l=this.gl,u=l.createRenderbuffer();return this.bindRenderbuffer.set(u),l.renderbufferStorage(l.RENDERBUFFER,e,n,a),this.bindRenderbuffer.set(null),u}createFramebuffer(e,n,a,l){return new ch(this,e,n,a,l)}clear({color:e,depth:n,stencil:a}){const l=this.gl;let u=0;e&&(u|=l.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(u|=l.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),a!==void 0&&(u|=l.STENCIL_BUFFER_BIT,this.clearStencil.set(a),this.stencilMask.set(255)),l.clear(u)}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){c.bH(e.blendFunction,Pt.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 vr(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 vr(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)}}let Qr;function Kl(h,e,n,a,l){const u=h.context,f=h.transform,_=u.gl,y=h.useProgram("collisionBox"),b=[];let w=0,S=0;for(let N=0;N<a.length;N++){const U=a[N],q=e.getTile(U).getBucket(n);if(!q)continue;const $=l?q.textCollisionBox:q.iconCollisionBox,H=q.collisionCircleArray;H.length>0&&(b.push({circleArray:H,circleOffset:S,coord:U}),w+=H.length/4,S=w),$&&y.draw(u,_.LINES,We.disabled,lt.disabled,h.colorModeForRenderPass(),$e.disabled,wa(h.transform),h.style.map.terrain&&h.style.map.terrain.getTerrainData(U),f.getProjectionData({overscaledTileID:U,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,$.layoutVertexBuffer,$.indexBuffer,$.segments,null,h.transform.zoom,null,null,$.collisionVertexBuffer)}if(!l||!b.length)return;const P=h.useProgram("collisionCircle"),I=new c.b$;I.resize(4*w),I._trim();let k=0;for(const N of b)for(let U=0;U<N.circleArray.length/4;U++){const q=4*U,$=N.circleArray[q+0],H=N.circleArray[q+1],K=N.circleArray[q+2],G=N.circleArray[q+3];I.emplace(k++,$,H,K,G,0),I.emplace(k++,$,H,K,G,1),I.emplace(k++,$,H,K,G,2),I.emplace(k++,$,H,K,G,3)}(!Qr||Qr.length<2*w)&&(Qr=function(N){const U=2*N,q=new c.c1;q.resize(U),q._trim();for(let $=0;$<U;$++){const H=6*$;q.uint16[H+0]=4*$+0,q.uint16[H+1]=4*$+1,q.uint16[H+2]=4*$+2,q.uint16[H+3]=4*$+2,q.uint16[H+4]=4*$+3,q.uint16[H+5]=4*$+0}return q}(w));const O=u.createIndexBuffer(Qr,!0),B=u.createVertexBuffer(I,c.c0.members,!0);for(const N of b){const U=eh(h.transform);P.draw(u,_.TRIANGLES,We.disabled,lt.disabled,h.colorModeForRenderPass(),$e.disabled,U,h.style.map.terrain&&h.style.map.terrain.getTerrainData(N.coord),null,n.id,B,O,c.aM.simpleSegment(0,2*N.circleOffset,N.circleArray.length,N.circleArray.length/2),null,h.transform.zoom,null,null,null)}B.destroy(),O.destroy()}const hh=c.ag(new Float32Array(16));function Jl(h,e,n,a,l,u){const{horizontalAlign:f,verticalAlign:_}=c.aH(h);return new c.P((-(f-.5)*e/l+a[0])*u,(-(_-.5)*n/l+a[1])*u)}function uh(h,e,n,a,l,u){const f=e.tileAnchorPoint.add(new c.P(e.translation[0],e.translation[1]));if(e.pitchWithMap){let _=a.mult(u);n||(_=_.rotate(-l));const y=f.add(_);return Ut(y.x,y.y,e.pitchedLabelPlaneMatrix,e.getElevation).point}if(n){const _=hi(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(h),y=Math.atan(_.y/_.x)+(_.x<0?Math.PI:0);return h.add(a.rotate(y))}return h.add(a)}function Bo(h,e,n,a,l,u,f,_,y,b,w,S){const P=h.text.placedSymbolArray,I=h.text.dynamicLayoutVertexArray,k=h.icon.dynamicLayoutVertexArray,O={};I.clear();for(let B=0;B<P.length;B++){const N=P.get(B),U=N.hidden||!N.crossTileID||h.allowVerticalPlacement&&!N.placedOrientation?null:a[N.crossTileID];if(U){const q=new c.P(N.anchorX,N.anchorY),$={getElevation:S,width:l.width,height:l.height,pitchedLabelPlaneMatrix:u,pitchWithMap:n,transform:l,tileAnchorPoint:q,translation:b,unwrappedTileID:w},H=n?Wr(q.x,q.y,$):hi(q.x,q.y,$),K=Te(l.cameraToCenterDistance,H.signedDistanceFromCamera);let G=c.ap(h.textSizeData,_,N)*K/c.aB;n&&(G*=h.tilePixelRatio/f);const{width:te,height:ue,anchor:ae,textOffset:oe,textBoxScale:he}=U,we=Jl(ae,te,ue,oe,he,G),Se=l.getPitchedTextCorrection(q.x+b[0],q.y+b[1],w),ye=uh(H.point,$,e,we,-l.bearingInRadians,Se),Le=h.allowVerticalPlacement&&N.placedOrientation===c.ao.vertical?Math.PI/2:0;for(let Ke=0;Ke<N.numGlyphs;Ke++)c.av(I,ye,Le);y&&N.associatedIconIndex>=0&&(O[N.associatedIconIndex]={shiftedAnchor:ye,angle:Le})}else xr(N.numGlyphs,I)}if(y){k.clear();const B=h.icon.placedSymbolArray;for(let N=0;N<B.length;N++){const U=B.get(N);if(U.hidden)xr(U.numGlyphs,k);else{const q=O[N];if(q)for(let $=0;$<U.numGlyphs;$++)c.av(k,q.shiftedAnchor,q.angle);else xr(U.numGlyphs,k)}}h.icon.dynamicLayoutVertexBuffer.updateData(k)}h.text.dynamicLayoutVertexBuffer.updateData(I)}function ka(h,e,n){return n.iconsInText&&e?"symbolTextAndIcon":h?"symbolSDF":"symbolIcon"}function Vs(h,e,n,a,l,u,f,_,y,b,w,S,P){const I=h.context,k=I.gl,O=h.transform,B=_==="map",N=y==="map",U=_!=="viewport"&&n.layout.get("symbol-placement")!=="point",q=B&&!N&&!U,$=!n.layout.get("symbol-sort-key").isConstant();let H=!1;const K=h.getDepthModeForSublayer(0,We.ReadOnly),G=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),te=[],ue=O.getCircleRadiusCorrection();for(const ae of a){const oe=e.getTile(ae),he=oe.getBucket(n);if(!he)continue;const we=l?he.text:he.icon;if(!we||!we.segments.get().length||!we.hasVisibleVertices)continue;const Se=we.programConfigurations.get(n.id),ye=l||he.sdfIcons,Le=l?he.textSizeData:he.iconSizeData,Ke=N||O.pitch!==0,dt=h.useProgram(ka(ye,l,he),Se),yt=c.an(Le,O.zoom),mt=h.style.map.terrain&&h.style.map.terrain.getTerrainData(ae);let Ct,zt,Xe,xt,Zt=[0,0],Yt=null;if(l)zt=oe.glyphAtlasTexture,Xe=k.LINEAR,Ct=oe.glyphAtlasTexture.size,he.iconsInText&&(Zt=oe.imageAtlasTexture.size,Yt=oe.imageAtlasTexture,xt=Ke||h.options.rotating||h.options.zooming||Le.kind==="composite"||Le.kind==="camera"?k.LINEAR:k.NEAREST);else{const Gt=n.layout.get("icon-size").constantOr(0)!==1||he.iconsNeedLinear;zt=oe.imageAtlasTexture,Xe=ye||h.options.rotating||h.options.zooming||Gt||Ke?k.LINEAR:k.NEAREST,Ct=oe.imageAtlasTexture.size}const ri=c.aC(oe,1,h.transform.zoom),Si=Nt(B,h.transform,ri),ar=c.L();c.aq(ar,Si);const tn=rt(N,B,h.transform,ri),rn=c.aD(O,oe,u,f),ps=O.getProjectionData({overscaledTileID:ae,applyGlobeMatrix:!P,applyTerrainMatrix:!0}),fs=G&&he.hasTextData(),Rn=n.layout.get("icon-text-fit")!=="none"&&fs&&he.hasIconData();if(U){const Gt=h.style.map.terrain?(Hi,qt)=>h.style.map.terrain.getElevation(ae,Hi,qt):null,Kt=n.layout.get("text-rotation-alignment")==="map";At(he,h,l,Si,ar,N,b,Kt,ae.toUnwrapped(),O.width,O.height,rn,Gt)}const Fn=l&&G||Rn,Li=U||Fn?hh:N?Si:h.transform.clipSpaceToPixelsMatrix,or=ye&&n.paint.get(l?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Mi;Mi=ye?he.iconsInText?rh(Le.kind,yt,q,N,U,Fn,h,Li,tn,rn,Ct,Zt,ue):jl(Le.kind,yt,q,N,U,Fn,h,Li,tn,rn,l,Ct,0,ue):Bs(Le.kind,yt,q,N,U,Fn,h,Li,tn,rn,l,Ct,ue);const nn={program:dt,buffers:we,uniformValues:Mi,projectionData:ps,atlasTexture:zt,atlasTextureIcon:Yt,atlasInterpolation:Xe,atlasInterpolationIcon:xt,isSDF:ye,hasHalo:or};if($&&he.canOverlap){H=!0;const Gt=we.segments.get();for(const Kt of Gt)te.push({segments:new c.aM([Kt]),sortKey:Kt.sortKey,state:nn,terrainData:mt})}else te.push({segments:we.segments,sortKey:0,state:nn,terrainData:mt})}H&&te.sort((ae,oe)=>ae.sortKey-oe.sortKey);for(const ae of te){const oe=ae.state;if(I.activeTexture.set(k.TEXTURE0),oe.atlasTexture.bind(oe.atlasInterpolation,k.CLAMP_TO_EDGE),oe.atlasTextureIcon&&(I.activeTexture.set(k.TEXTURE1),oe.atlasTextureIcon&&oe.atlasTextureIcon.bind(oe.atlasInterpolationIcon,k.CLAMP_TO_EDGE)),oe.isSDF){const he=oe.uniformValues;oe.hasHalo&&(he.u_is_halo=1,Us(oe.buffers,ae.segments,n,h,oe.program,K,w,S,he,oe.projectionData,ae.terrainData)),he.u_is_halo=0}Us(oe.buffers,ae.segments,n,h,oe.program,K,w,S,oe.uniformValues,oe.projectionData,ae.terrainData)}}function Us(h,e,n,a,l,u,f,_,y,b,w){const S=a.context;l.draw(S,S.gl.TRIANGLES,u,f,_,$e.backCCW,y,w,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,a.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function Oo(h,e,n,a,l){const u=h.context,f=u.gl,_=lt.disabled,y=new Pt([f.ONE,f.ONE],c.bf.transparent,[!0,!0,!0,!0]),b=e.getBucket(n);if(!b)return;const w=a.key;let S=n.heatmapFbos.get(w);S||(S=$s(u,e.tileSize,e.tileSize),n.heatmapFbos.set(w,S)),u.bindFramebuffer.set(S.framebuffer),u.viewport.set([0,0,e.tileSize,e.tileSize]),u.clear({color:c.bf.transparent});const P=b.programConfigurations.get(n.id),I=h.useProgram("heatmap",P,!l),k=h.transform.getProjectionData({overscaledTileID:e.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),O=h.style.map.terrain.getTerrainData(a);I.draw(u,f.TRIANGLES,We.disabled,_,y,$e.disabled,Dl(e,h.transform.zoom,n.paint.get("heatmap-intensity"),1),O,k,n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,n.paint,h.transform.zoom,P)}function Ql(h,e,n,a,l){const u=h.context,f=u.gl,_=h.transform;u.setColorMode(h.colorModeForRenderPass());const y=Zs(u,e),b=n.key,w=e.heatmapFbos.get(b);if(!w)return;u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,w.colorAttachment.get()),u.activeTexture.set(f.TEXTURE1),y.bind(f.LINEAR,f.CLAMP_TO_EDGE);const S=_.getProjectionData({overscaledTileID:n,applyTerrainMatrix:l,applyGlobeMatrix:!a});h.useProgram("heatmapTexture").draw(u,f.TRIANGLES,We.disabled,lt.disabled,h.colorModeForRenderPass(),$e.disabled,Po(h,e,0,1),null,S,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,_.zoom),w.destroy(),e.heatmapFbos.delete(b)}function $s(h,e,n){var a,l;const u=h.gl,f=u.createTexture();u.bindTexture(u.TEXTURE_2D,f),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.LINEAR),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.LINEAR);const _=(a=h.HALF_FLOAT)!==null&&a!==void 0?a:u.UNSIGNED_BYTE,y=(l=h.RGBA16F)!==null&&l!==void 0?l:u.RGBA;u.texImage2D(u.TEXTURE_2D,0,y,e,n,0,u.RGBA,_,null);const b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(f),b}function Zs(h,e){return e.colorRampTexture||(e.colorRampTexture=new c.T(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function Gs(h,e,n,a,l){if(!n||!a||!a.imageAtlas)return;const u=a.imageAtlas.patternPositions;let f=u[n.to.toString()],_=u[n.from.toString()];if(!f&&_&&(f=_),!_&&f&&(_=f),!f||!_){const y=l.getPaintProperty(e);f=u[y],_=u[y]}f&&_&&h.setConstantPatternPositions(f,_)}function za(h,e,n,a,l,u,f,_){const y=h.context.gl,b="fill-pattern",w=n.paint.get(b),S=w&&w.constantOr(1),P=n.getCrossfadeParameters();let I,k,O,B,N;const U=h.transform,q=n.paint.get("fill-translate"),$=n.paint.get("fill-translate-anchor");f?(k=S&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",I=y.LINES):(k=S?"fillPattern":"fill",I=y.TRIANGLES);const H=w.constantOr(null);for(const K of a){const G=e.getTile(K);if(S&&!G.patternsLoaded())continue;const te=G.getBucket(n);if(!te)continue;const ue=te.programConfigurations.get(n.id),ae=h.useProgram(k,ue),oe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(K);S&&(h.context.activeTexture.set(y.TEXTURE0),G.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),ue.updatePaintBuffers(P)),Gs(ue,b,H,G,n);const he=U.getProjectionData({overscaledTileID:K,applyGlobeMatrix:!_,applyTerrainMatrix:!0}),we=c.aD(U,G,q,$);if(f){B=te.indexBuffer2,N=te.segments2;const ye=[y.drawingBufferWidth,y.drawingBufferHeight];O=k==="fillOutlinePattern"&&S?Rs(h,P,G,ye,we):Ds(ye,we)}else B=te.indexBuffer,N=te.segments,O=S?ba(h,P,G,we):{u_fill_translate:we};const Se=h.stencilModeForClipping(K);ae.draw(h.context,I,l,Se,u,$e.backCCW,O,oe,he,n.id,te.layoutVertexBuffer,B,N,n.paint,h.transform.zoom,ue)}}function jo(h,e,n,a,l,u,f,_){const y=h.context,b=y.gl,w="fill-extrusion-pattern",S=n.paint.get(w),P=S.constantOr(1),I=n.getCrossfadeParameters(),k=n.paint.get("fill-extrusion-opacity"),O=S.constantOr(null),B=h.transform;for(const N of a){const U=e.getTile(N),q=U.getBucket(n);if(!q)continue;const $=h.style.map.terrain&&h.style.map.terrain.getTerrainData(N),H=q.programConfigurations.get(n.id),K=h.useProgram(P?"fillExtrusionPattern":"fillExtrusion",H);P&&(h.context.activeTexture.set(b.TEXTURE0),U.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),H.updatePaintBuffers(I));const G=B.getProjectionData({overscaledTileID:N,applyGlobeMatrix:!_,applyTerrainMatrix:!0});Gs(H,w,O,U,n);const te=c.aD(B,U,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ue=n.paint.get("fill-extrusion-vertical-gradient"),ae=P?Jc(h,ue,k,te,N,I,U):er(h,ue,k,te);K.draw(y,y.gl.TRIANGLES,l,u,f,$e.backCCW,ae,$,G,n.id,q.layoutVertexBuffer,q.indexBuffer,q.segments,n.paint,h.transform.zoom,H,h.style.map.terrain&&q.centroidVertexBuffer)}}function En(h,e,n,a,l,u,f,_,y){var b;const w=h.style.projection,S=h.context,P=h.transform,I=S.gl,k=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],O=h.useProgram("hillshade",null,!1,k),B=!h.options.moving;for(const N of a){const U=e.getTile(N),q=U.fbo;if(!q)continue;const $=w.getMeshFromTileID(S,N.canonical,_,!0,"raster"),H=(b=h.style.map.terrain)===null||b===void 0?void 0:b.getTerrainData(N);S.activeTexture.set(I.TEXTURE0),I.bindTexture(I.TEXTURE_2D,q.colorAttachment.get());const K=P.getProjectionData({overscaledTileID:N,aligned:B,applyGlobeMatrix:!y,applyTerrainMatrix:!0});O.draw(S,I.TRIANGLES,u,l[N.overscaledZ],f,$e.backCCW,th(h,U,n),H,K,n.id,$.vertexBuffer,$.indexBuffer,$.segments)}}function No(h,e,n,a,l,u,f,_,y){var b;const w=h.style.projection,S=h.context,P=h.transform,I=S.gl,k=h.useProgram("colorRelief"),O=!h.options.moving;let B=!0,N=0;for(const U of a){const q=e.getTile(U),$=q.dem;if(B){const ae=I.getParameter(I.MAX_TEXTURE_SIZE),{elevationTexture:oe,colorTexture:he}=n.getColorRampTextures(S,ae,$.getUnpackVector());S.activeTexture.set(I.TEXTURE1),oe.bind(I.NEAREST,I.CLAMP_TO_EDGE),S.activeTexture.set(I.TEXTURE4),he.bind(I.LINEAR,I.CLAMP_TO_EDGE),B=!1,N=oe.size[0]}if(!$||!$.data)continue;const H=$.stride,K=$.getPixels();if(S.activeTexture.set(I.TEXTURE0),S.pixelStoreUnpackPremultiplyAlpha.set(!1),q.demTexture=q.demTexture||h.getTileTexture(H),q.demTexture){const ae=q.demTexture;ae.update(K,{premultiply:!1}),ae.bind(I.LINEAR,I.CLAMP_TO_EDGE)}else q.demTexture=new c.T(S,K,I.RGBA,{premultiply:!1}),q.demTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE);const G=w.getMeshFromTileID(S,U.canonical,_,!0,"raster"),te=(b=h.style.map.terrain)===null||b===void 0?void 0:b.getTerrainData(U),ue=P.getProjectionData({overscaledTileID:U,aligned:O,applyGlobeMatrix:!y,applyTerrainMatrix:!0});k.draw(S,I.TRIANGLES,u,l[U.overscaledZ],f,$e.backCCW,Fl(n,q.dem,N),te,ue,n.id,G.vertexBuffer,G.indexBuffer,G.segments)}}const La=[new c.P(0,0),new c.P(c.$,0),new c.P(c.$,c.$),new c.P(0,c.$)];function An(h,e,n,a,l,u,f,_,y=!1,b=!1){const w=a[a.length-1].overscaledZ,S=h.context,P=S.gl,I=h.useProgram("raster"),k=h.transform,O=h.style.projection,B=h.colorModeForRenderPass(),N=!h.options.moving;for(const U of a){const q=h.getDepthModeForSublayer(U.overscaledZ-w,n.paint.get("raster-opacity")===1?We.ReadWrite:We.ReadOnly,P.LESS),$=e.getTile(U);$.registerFadeDuration(n.paint.get("raster-fade-duration"));const H=e.findLoadedParent(U,0),K=e.findLoadedSibling(U),G=Vo($,H||K||null,e,n,h.transform,h.style.map.terrain);let te,ue;const ae=n.paint.get("raster-resampling")==="nearest"?P.NEAREST:P.LINEAR;S.activeTexture.set(P.TEXTURE0),$.texture.bind(ae,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST),S.activeTexture.set(P.TEXTURE1),H?(H.texture.bind(ae,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST),te=Math.pow(2,H.tileID.overscaledZ-$.tileID.overscaledZ),ue=[$.tileID.canonical.x*te%1,$.tileID.canonical.y*te%1]):$.texture.bind(ae,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST),$.texture.useMipmap&&S.extTextureFilterAnisotropic&&h.transform.pitch>20&&P.texParameterf(P.TEXTURE_2D,S.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,S.extTextureFilterAnisotropicMax);const oe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(U),he=k.getProjectionData({overscaledTileID:U,aligned:N,applyGlobeMatrix:!b,applyTerrainMatrix:!0}),we=Fs(ue||[0,0],te||1,G,n,_),Se=O.getMeshFromTileID(S,U.canonical,u,f,"raster");I.draw(S,P.TRIANGLES,q,l?l[U.overscaledZ]:lt.disabled,B,y?$e.frontCCW:$e.backCCW,we,oe,he,n.id,Se.vertexBuffer,Se.indexBuffer,Se.segments)}}function Vo(h,e,n,a,l,u){const f=a.paint.get("raster-fade-duration");if(!u&&f>0){const _=Ee.now(),y=(_-h.timeAdded)/f,b=e?(_-e.timeAdded)/f:-1,w=n.getSource(),S=Re(l,{tileSize:w.tileSize,roundZoom:w.roundZoom}),P=!e||Math.abs(e.tileID.overscaledZ-S)>Math.abs(h.tileID.overscaledZ-S),I=P&&h.refreshedUponExpiration?1:c.ah(P?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-I}:{opacity:I,mix:0}}return{opacity:1,mix:0}}const ec=new c.bf(1,0,0,1),tc=new c.bf(0,1,0,1),Da=new c.bf(0,0,1,1),Uo=new c.bf(1,0,1,1),dh=new c.bf(0,1,1,1);function $o(h,e,n,a){Tr(h,0,e+n/2,h.transform.width,n,a)}function kt(h,e,n,a){Tr(h,e-n/2,0,n,h.transform.height,a)}function Tr(h,e,n,a,l,u){const f=h.context,_=f.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,n*h.pixelRatio,a*h.pixelRatio,l*h.pixelRatio),f.clear({color:u}),_.disable(_.SCISSOR_TEST)}function qi(h,e,n){const a=h.context,l=a.gl,u=h.useProgram("debug"),f=We.disabled,_=lt.disabled,y=h.colorModeForRenderPass(),b="$debug",w=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);a.activeTexture.set(l.TEXTURE0);const S=e.getTileByID(n.key).latestRawTileData,P=Math.floor((S&&S.byteLength||0)/1024),I=e.getTile(n).tileSize,k=512/Math.min(I,512)*(n.overscaledZ/h.transform.zoom)*.5;let O=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(O+=` => ${n.overscaledZ}`),function(N,U){N.initDebugOverlayCanvas();const q=N.debugOverlayCanvas,$=N.context.gl,H=N.debugOverlayCanvas.getContext("2d");H.clearRect(0,0,q.width,q.height),H.shadowColor="white",H.shadowBlur=2,H.lineWidth=1.5,H.strokeStyle="white",H.textBaseline="top",H.font="bold 36px Open Sans, sans-serif",H.fillText(U,5,5),H.strokeText(U,5,5),N.debugOverlayTexture.update(q),N.debugOverlayTexture.bind($.LINEAR,$.CLAMP_TO_EDGE)}(h,`${O} ${P}kB`);const B=h.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});u.draw(a,l.TRIANGLES,f,_,Pt.alphaBlended,$e.disabled,Pn(c.bf.transparent,k),null,B,b,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),u.draw(a,l.LINE_STRIP,f,_,y,$e.disabled,Pn(c.bf.red),w,B,b,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function Ra(h,e,n,a){const{isRenderingGlobe:l}=a,u=h.context,f=u.gl,_=h.transform,y=h.colorModeForRenderPass(),b=h.getDepthModeFor3D(),w=h.useProgram("terrain");u.bindFramebuffer.set(null),u.viewport.set([0,0,h.width,h.height]);for(const S of n){const P=e.getTerrainMesh(S.tileID),I=h.renderToTexture.getTexture(S),k=e.getTerrainData(S.tileID);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,I.texture);const O=e.getMeshFrameDelta(_.zoom),B=_.calculateFogMatrix(S.tileID.toUnwrapped()),N=xa(O,B,h.style.sky,_.pitch,l),U=_.getProjectionData({overscaledTileID:S.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});w.draw(u,f.TRIANGLES,b,lt.disabled,y,$e.backCCW,N,k,U,"terrain",P.vertexBuffer,P.indexBuffer,P.segments)}}function qs(h,e){if(!e.mesh){const n=new c.aL;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const a=new c.aN;a.emplaceBack(0,1,2),a.emplaceBack(0,2,3),e.mesh=new yn(h.createVertexBuffer(n,Kr.members),h.createIndexBuffer(a),c.aM.simpleSegment(0,0,n.length,a.length))}return e.mesh}class ic{constructor(e,n){this.context=new Yl(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:c.ag(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Qe.maxUnderzooming+Qe.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Yn}resize(e,n,a){if(this.width=Math.floor(e*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const l of this.style._order)this.style._layers[l].resize()}setup(){const e=this.context,n=new c.aL;n.emplaceBack(0,0),n.emplaceBack(c.$,0),n.emplaceBack(0,c.$),n.emplaceBack(c.$,c.$),this.tileExtentBuffer=e.createVertexBuffer(n,Kr.members),this.tileExtentSegments=c.aM.simpleSegment(0,0,4,2);const a=new c.aL;a.emplaceBack(0,0),a.emplaceBack(c.$,0),a.emplaceBack(0,c.$),a.emplaceBack(c.$,c.$),this.debugBuffer=e.createVertexBuffer(a,Kr.members),this.debugSegments=c.aM.simpleSegment(0,0,4,5);const l=new c.c6;l.emplaceBack(0,0,0,0),l.emplaceBack(c.$,0,c.$,0),l.emplaceBack(0,c.$,0,c.$),l.emplaceBack(c.$,c.$,c.$,c.$),this.rasterBoundsBuffer=e.createVertexBuffer(l,Yc.members),this.rasterBoundsSegments=c.aM.simpleSegment(0,0,4,2);const u=new c.aL;u.emplaceBack(0,0),u.emplaceBack(c.$,0),u.emplaceBack(0,c.$),u.emplaceBack(c.$,c.$),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(u,Kr.members),this.rasterBoundsSegmentsPosOnly=c.aM.simpleSegment(0,0,4,5);const f=new c.aL;f.emplaceBack(0,0),f.emplaceBack(1,0),f.emplaceBack(0,1),f.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(f,Kr.members),this.viewportSegments=c.aM.simpleSegment(0,0,4,2);const _=new c.c7;_.emplaceBack(0),_.emplaceBack(1),_.emplaceBack(3),_.emplaceBack(2),_.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(_);const y=new c.aN;y.emplaceBack(1,0,2),y.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(y);const b=this.context.gl;this.stencilClearMode=new lt({func:b.ALWAYS,mask:0},0,255,b.ZERO,b.ZERO,b.ZERO),this.tileExtentMesh=new yn(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=c.L();c.bY(a,0,this.width,this.height,0,0,1),c.N(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const l={mainMatrix:a,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a};this.useProgram("clippingMask",null,!0).draw(e,n.TRIANGLES,We.disabled,this.stencilClearMode,Pt.disabled,$e.disabled,null,null,l,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n,a){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source,this.nextStencilID+n.length>256&&this.clearStencil();const l=this.context;l.setColorMode(Pt.disabled),l.setDepthMode(We.disabled);const u={};for(const f of n)u[f.key]=this.nextStencilID++;this._renderTileMasks(u,n,a,!0),this._renderTileMasks(u,n,a,!1),this._tileClippingMaskIDs=u}_renderTileMasks(e,n,a,l){const u=this.context,f=u.gl,_=this.style.projection,y=this.transform,b=this.useProgram("clippingMask");for(const w of n){const S=e[w.key],P=this.style.map.terrain&&this.style.map.terrain.getTerrainData(w),I=_.getMeshFromTileID(this.context,w.canonical,l,!0,"stencil"),k=y.getProjectionData({overscaledTileID:w,applyGlobeMatrix:!a,applyTerrainMatrix:!0});b.draw(u,f.TRIANGLES,We.disabled,new lt({func:f.ALWAYS,mask:0},S,255,f.KEEP,f.KEEP,f.REPLACE),Pt.disabled,a?$e.disabled:$e.backCCW,null,P,k,"$clipping",I.vertexBuffer,I.indexBuffer,I.segments)}}_renderTilesDepthBuffer(){const e=this.context,n=e.gl,a=this.style.projection,l=this.transform,u=this.useProgram("depth"),f=this.getDepthModeFor3D(),_=ne(l,{tileSize:l.tileSize});for(const y of _){const b=this.style.map.terrain&&this.style.map.terrain.getTerrainData(y),w=a.getMeshFromTileID(this.context,y.canonical,!0,!0,"raster"),S=l.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!0,applyTerrainMatrix:!0});u.draw(e,n.TRIANGLES,f,lt.disabled,Pt.disabled,$e.backCCW,null,b,S,"$clipping",w.vertexBuffer,w.indexBuffer,w.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new lt({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){const n=this.context.gl;return new lt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const n=this.context.gl,a=e.sort((f,_)=>_.overscaledZ-f.overscaledZ),l=a[a.length-1].overscaledZ,u=a[0].overscaledZ-l+1;if(u>1){this.currentStencilSource=void 0,this.nextStencilID+u>256&&this.clearStencil();const f={};for(let _=0;_<u;_++)f[_+l]=new lt({func:n.GEQUAL,mask:255},_+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=u,[f,a]}return[{[l]:lt.disabled},a]}stencilConfigForOverlapTwoPass(e){const n=this.context.gl,a=e.sort((f,_)=>_.overscaledZ-f.overscaledZ),l=a[a.length-1].overscaledZ,u=a[0].overscaledZ-l+1;if(this.clearStencil(),u>1){const f={},_={};for(let y=0;y<u;y++)f[y+l]=new lt({func:n.GREATER,mask:255},u+1+y,255,n.KEEP,n.KEEP,n.REPLACE),_[y+l]=new lt({func:n.GREATER,mask:255},1+y,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*u+1,[f,_,a]}return this.nextStencilID=3,[{[l]:new lt({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[l]:new lt({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},a]}colorModeForRenderPass(){const e=this.context.gl;return this._showOverdrawInspector?new Pt([e.CONSTANT_COLOR,e.ONE],new c.bf(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Pt.unblended:Pt.alphaBlended}getDepthModeForSublayer(e,n,a){if(!this.opaquePassEnabledForLayer())return We.disabled;const l=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new We(a||this.context.gl.LEQUAL,n,[l,l])}getDepthModeFor3D(){return new We(this.context.gl.LEQUAL,We.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){var a,l;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(Ee.now()),this.imageManager.beginFrame();const u=this.style._order,f=this.style.sourceCaches,_={},y={},b={},w={isRenderingToTexture:!1,isRenderingGlobe:((a=e.projection)===null||a===void 0?void 0:a.transitionState)>0};for(const P in f){const I=f[P];I.used&&I.prepare(this.context),_[P]=I.getVisibleCoordinates(!1),y[P]=_[P].slice().reverse(),b[P]=I.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let P=0;P<u.length;P++)if(this.style._layers[u[P]].is3D()){this.opaquePassCutoff=P;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const P of u){const I=this.style._layers[P];if(!I.hasOffscreenPass()||I.isHidden(this.transform.zoom))continue;const k=y[I.source];(I.type==="custom"||k.length)&&this.renderLayer(this,f[I.source],I,k,w)}if((l=this.style.projection)===null||l===void 0||l.updateGPUdependent({context:this.context,useProgram:P=>this.useProgram(P)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?c.bf.black:c.bf.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(P,I){const k=P.context,O=k.gl,B=((K,G,te)=>{const ue=Math.cos(G.rollInRadians),ae=Math.sin(G.rollInRadians),oe=Y(G),he=G.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:K.properties.get("sky-color"),u_horizon_color:K.properties.get("horizon-color"),u_horizon:[(G.width/2-oe*ae)*te,(G.height/2+oe*ue)*te],u_horizon_normal:[-ae,ue],u_sky_horizon_blend:K.properties.get("sky-horizon-blend")*G.height/2*te,u_sky_blend:he}})(I,P.style.map.transform,P.pixelRatio),N=new We(O.LEQUAL,We.ReadWrite,[0,1]),U=lt.disabled,q=P.colorModeForRenderPass(),$=P.useProgram("sky"),H=qs(k,I);$.draw(k,O.TRIANGLES,N,U,q,$e.disabled,B,null,void 0,"sky",H.vertexBuffer,H.indexBuffer,H.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=u.length-1;this.currentLayer>=0;this.currentLayer--){const P=this.style._layers[u[this.currentLayer]],I=f[P.source],k=_[P.source];this._renderTileClippingMasks(P,k,!1),this.renderLayer(this,I,P,k,w)}this.renderPass="translucent";let S=!1;for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const P=this.style._layers[u[this.currentLayer]],I=f[P.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(P,w))continue;this.opaquePassEnabledForLayer()||S||(S=!0,w.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const k=(P.type==="symbol"?b:y)[P.source];this._renderTileClippingMasks(P,_[P.source],!!this.renderToTexture),this.renderLayer(this,I,P,k,w)}if(w.isRenderingGlobe&&function(P,I,k){const O=P.context,B=O.gl,N=P.useProgram("atmosphere"),U=new We(B.LEQUAL,We.ReadOnly,[0,1]),q=P.transform,$=function(he,we){const Se=he.properties.get("position"),ye=[-Se.x,-Se.y,-Se.z],Le=c.ag(new Float64Array(16));return he.properties.get("anchor")==="map"&&(c.b6(Le,Le,we.rollInRadians),c.b7(Le,Le,-we.pitchInRadians),c.b6(Le,Le,we.bearingInRadians),c.b7(Le,Le,we.center.lat*Math.PI/180),c.bz(Le,Le,-we.center.lng*Math.PI/180)),c.c5(ye,ye,Le),ye}(k,P.transform),H=q.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),K=I.properties.get("atmosphere-blend")*H.projectionTransition;if(K===0)return;const G=Jn(q.worldSize,q.center.lat),te=q.inverseProjectionMatrix,ue=new Float64Array(4);ue[3]=1,c.aw(ue,ue,q.modelViewProjectionMatrix),ue[0]/=ue[3],ue[1]/=ue[3],ue[2]/=ue[3],ue[3]=1,c.aw(ue,ue,te),ue[0]/=ue[3],ue[1]/=ue[3],ue[2]/=ue[3],ue[3]=1;const ae=((he,we,Se,ye,Le)=>({u_sun_pos:he,u_atmosphere_blend:we,u_globe_position:Se,u_globe_radius:ye,u_inv_proj_matrix:Le}))($,K,[ue[0],ue[1],ue[2]],G,te),oe=qs(O,I);N.draw(O,B.TRIANGLES,U,lt.disabled,Pt.alphaBlended,$e.disabled,ae,null,null,"atmosphere",oe.vertexBuffer,oe.indexBuffer,oe.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const P=function(I,k){let O=null;const B=Object.values(I._layers).flatMap($=>$.source&&!$.isHidden(k)?[I.sourceCaches[$.source]]:[]),N=B.filter($=>$.getSource().type==="vector"),U=B.filter($=>$.getSource().type!=="vector"),q=$=>{(!O||O.getSource().maxzoom<$.getSource().maxzoom)&&(O=$)};return N.forEach($=>q($)),O||U.forEach($=>q($)),O}(this.style,this.transform.zoom);P&&function(I,k,O){for(let B=0;B<O.length;B++)qi(I,k,O[B])}(this,P,P.getVisibleCoordinates())}this.options.showPadding&&function(P){const I=P.transform.padding;$o(P,P.transform.height-(I.top||0),3,ec),$o(P,I.bottom||0,3,tc),kt(P,I.left||0,3,Da),kt(P,P.transform.width-(I.right||0),3,Uo);const k=P.transform.centerPoint;(function(O,B,N,U){Tr(O,B-1,N-10,2,20,U),Tr(O,B-10,N-1,20,2,U)})(P,k.x,P.transform.height-k.y,dh)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,a=this.transform.modelViewProjectionMatrix;let l=this.terrainFacilitator.dirty;l||(l=e?!c.c8(n,a):!c.c9(n,a)),l||(l=this.style.map.terrain.sourceCache.anyTilesAfterTime(this.terrainFacilitator.renderTime)),l&&(c.ca(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(u,f){const _=u.context,y=_.gl,b=u.transform,w=Pt.unblended,S=new We(y.LEQUAL,We.ReadWrite,[0,1]),P=f.sourceCache.getRenderableTiles(),I=u.useProgram("terrainDepth");_.bindFramebuffer.set(f.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),_.clear({color:c.bf.transparent,depth:1});for(const k of P){const O=f.getTerrainMesh(k.tileID),B=f.getTerrainData(k.tileID),N=b.getProjectionData({overscaledTileID:k.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),U={u_ele_delta:f.getMeshFrameDelta(b.zoom)};I.draw(_,y.TRIANGLES,S,lt.disabled,w,$e.backCCW,U,B,N,"terrain",O.vertexBuffer,O.indexBuffer,O.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain),function(u,f){const _=u.context,y=_.gl,b=u.transform,w=Pt.unblended,S=new We(y.LEQUAL,We.ReadWrite,[0,1]),P=f.getCoordsTexture(),I=f.sourceCache.getRenderableTiles(),k=u.useProgram("terrainCoords");_.bindFramebuffer.set(f.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),_.clear({color:c.bf.transparent,depth:1}),f.coordsIndex=[];for(const O of I){const B=f.getTerrainMesh(O.tileID),N=f.getTerrainData(O.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,P.texture);const U={u_terrain_coords_id:(255-f.coordsIndex.length)/255,u_texture:0,u_ele_delta:f.getMeshFrameDelta(b.zoom)},q=b.getProjectionData({overscaledTileID:O.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});k.draw(_,y.TRIANGLES,S,lt.disabled,w,$e.backCCW,U,N,q,"terrain",B.vertexBuffer,B.indexBuffer,B.segments),f.coordsIndex.push(O.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain))}renderLayer(e,n,a,l,u){a.isHidden(this.transform.zoom)||(a.type==="background"||a.type==="custom"||(l||[]).length)&&(this.id=a.id,c.cb(a)?function(f,_,y,b,w,S){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:P}=S,I=lt.disabled,k=f.colorModeForRenderPass();(y._unevaluatedLayout.hasValue("text-variable-anchor")||y._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(O,B,N,U,q,$,H,K,G){const te=B.transform,ue=B.style.map.terrain,ae=q==="map",oe=$==="map";for(const he of O){const we=U.getTile(he),Se=we.getBucket(N);if(!Se||!Se.text||!Se.text.segments.get().length)continue;const ye=c.an(Se.textSizeData,te.zoom),Le=c.aC(we,1,B.transform.zoom),Ke=Nt(ae,B.transform,Le),dt=N.layout.get("icon-text-fit")!=="none"&&Se.hasIconData();if(ye){const yt=Math.pow(2,te.zoom-we.tileID.overscaledZ),mt=ue?(Ct,zt)=>ue.getElevation(he,Ct,zt):null;Bo(Se,ae,oe,G,te,Ke,yt,ye,dt,c.aD(te,we,H,K),he.toUnwrapped(),mt)}}}(b,f,y,_,y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),w),y.paint.get("icon-opacity").constantOr(1)!==0&&Vs(f,_,y,b,!1,y.paint.get("icon-translate"),y.paint.get("icon-translate-anchor"),y.layout.get("icon-rotation-alignment"),y.layout.get("icon-pitch-alignment"),y.layout.get("icon-keep-upright"),I,k,P),y.paint.get("text-opacity").constantOr(1)!==0&&Vs(f,_,y,b,!0,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),y.layout.get("text-keep-upright"),I,k,P),_.map.showCollisionBoxes&&(Kl(f,_,y,b,!0),Kl(f,_,y,b,!1))}(e,n,a,l,this.style.placement.variableOffsets,u):c.cc(a)?function(f,_,y,b,w){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:S}=w,P=y.paint.get("circle-opacity"),I=y.paint.get("circle-stroke-width"),k=y.paint.get("circle-stroke-opacity"),O=!y.layout.get("circle-sort-key").isConstant();if(P.constantOr(1)===0&&(I.constantOr(1)===0||k.constantOr(1)===0))return;const B=f.context,N=B.gl,U=f.transform,q=f.getDepthModeForSublayer(0,We.ReadOnly),$=lt.disabled,H=f.colorModeForRenderPass(),K=[],G=U.getCircleRadiusCorrection();for(let te=0;te<b.length;te++){const ue=b[te],ae=_.getTile(ue),oe=ae.getBucket(y);if(!oe)continue;const he=y.paint.get("circle-translate"),we=y.paint.get("circle-translate-anchor"),Se=c.aD(U,ae,he,we),ye=oe.programConfigurations.get(y.id),Le=f.useProgram("circle",ye),Ke=oe.layoutVertexBuffer,dt=oe.indexBuffer,yt=f.style.map.terrain&&f.style.map.terrain.getTerrainData(ue),mt={programConfiguration:ye,program:Le,layoutVertexBuffer:Ke,indexBuffer:dt,uniformValues:Qc(f,ae,y,Se,G),terrainData:yt,projectionData:U.getProjectionData({overscaledTileID:ue,applyGlobeMatrix:!S,applyTerrainMatrix:!0})};if(O){const Ct=oe.segments.get();for(const zt of Ct)K.push({segments:new c.aM([zt]),sortKey:zt.sortKey,state:mt})}else K.push({segments:oe.segments,sortKey:0,state:mt})}O&&K.sort((te,ue)=>te.sortKey-ue.sortKey);for(const te of K){const{programConfiguration:ue,program:ae,layoutVertexBuffer:oe,indexBuffer:he,uniformValues:we,terrainData:Se,projectionData:ye}=te.state;ae.draw(B,N.TRIANGLES,q,$,H,$e.backCCW,we,Se,ye,y.id,oe,he,te.segments,y.paint,f.transform.zoom,ue)}}(e,n,a,l,u):c.cd(a)?function(f,_,y,b,w){if(y.paint.get("heatmap-opacity")===0)return;const S=f.context,{isRenderingToTexture:P,isRenderingGlobe:I}=w;if(f.style.map.terrain){for(const k of b){const O=_.getTile(k);_.hasRenderableParent(k)||(f.renderPass==="offscreen"?Oo(f,O,y,k,I):f.renderPass==="translucent"&&Ql(f,y,k,P,I))}S.viewport.set([0,0,f.width,f.height])}else f.renderPass==="offscreen"?function(k,O,B,N){const U=k.context,q=U.gl,$=k.transform,H=lt.disabled,K=new Pt([q.ONE,q.ONE],c.bf.transparent,[!0,!0,!0,!0]);(function(G,te,ue){const ae=G.gl;G.activeTexture.set(ae.TEXTURE1),G.viewport.set([0,0,te.width/4,te.height/4]);let oe=ue.heatmapFbos.get(c.c2);oe?(ae.bindTexture(ae.TEXTURE_2D,oe.colorAttachment.get()),G.bindFramebuffer.set(oe.framebuffer)):(oe=$s(G,te.width/4,te.height/4),ue.heatmapFbos.set(c.c2,oe))})(U,k,B),U.clear({color:c.bf.transparent});for(let G=0;G<N.length;G++){const te=N[G];if(O.hasRenderableParent(te))continue;const ue=O.getTile(te),ae=ue.getBucket(B);if(!ae)continue;const oe=ae.programConfigurations.get(B.id),he=k.useProgram("heatmap",oe),we=$.getProjectionData({overscaledTileID:te,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),Se=$.getCircleRadiusCorrection();he.draw(U,q.TRIANGLES,We.disabled,H,K,$e.backCCW,Dl(ue,$.zoom,B.paint.get("heatmap-intensity"),Se),null,we,B.id,ae.layoutVertexBuffer,ae.indexBuffer,ae.segments,B.paint,$.zoom,oe)}U.viewport.set([0,0,k.width,k.height])}(f,_,y,b):f.renderPass==="translucent"&&function(k,O){const B=k.context,N=B.gl;B.setColorMode(k.colorModeForRenderPass());const U=O.heatmapFbos.get(c.c2);U&&(B.activeTexture.set(N.TEXTURE0),N.bindTexture(N.TEXTURE_2D,U.colorAttachment.get()),B.activeTexture.set(N.TEXTURE1),Zs(B,O).bind(N.LINEAR,N.CLAMP_TO_EDGE),k.useProgram("heatmapTexture").draw(B,N.TRIANGLES,We.disabled,lt.disabled,k.colorModeForRenderPass(),$e.disabled,Po(k,O,0,1),null,null,O.id,k.viewportBuffer,k.quadTriangleIndexBuffer,k.viewportSegments,O.paint,k.transform.zoom))}(f,y)}(e,n,a,l,u):c.ce(a)?function(f,_,y,b,w){if(f.renderPass!=="translucent")return;const{isRenderingToTexture:S}=w,P=y.paint.get("line-opacity"),I=y.paint.get("line-width");if(P.constantOr(1)===0||I.constantOr(1)===0)return;const k=f.getDepthModeForSublayer(0,We.ReadOnly),O=f.colorModeForRenderPass(),B=y.paint.get("line-dasharray"),N=y.paint.get("line-pattern"),U=N.constantOr(1),q=y.paint.get("line-gradient"),$=y.getCrossfadeParameters(),H=U?"linePattern":B?"lineSDF":q?"lineGradient":"line",K=f.context,G=K.gl,te=f.transform;let ue=!0;for(const ae of b){const oe=_.getTile(ae);if(U&&!oe.patternsLoaded())continue;const he=oe.getBucket(y);if(!he)continue;const we=he.programConfigurations.get(y.id),Se=f.context.program.get(),ye=f.useProgram(H,we),Le=ue||ye.program!==Se,Ke=f.style.map.terrain&&f.style.map.terrain.getTerrainData(ae),dt=N.constantOr(null);if(dt&&oe.imageAtlas){const Xe=oe.imageAtlas,xt=Xe.patternPositions[dt.to.toString()],Zt=Xe.patternPositions[dt.from.toString()];xt&&Zt&&we.setConstantPatternPositions(xt,Zt)}const yt=te.getProjectionData({overscaledTileID:ae,applyGlobeMatrix:!S,applyTerrainMatrix:!0}),mt=te.getPixelScale(),Ct=U?Ol(f,oe,y,mt,$):B?Sn(f,oe,y,mt,B,$):q?Bl(f,oe,y,mt,he.lineClipsArray.length):Ta(f,oe,y,mt);if(U)K.activeTexture.set(G.TEXTURE0),oe.imageAtlasTexture.bind(G.LINEAR,G.CLAMP_TO_EDGE),we.updatePaintBuffers($);else if(B&&(Le||f.lineAtlas.dirty))K.activeTexture.set(G.TEXTURE0),f.lineAtlas.bind(K);else if(q){const Xe=he.gradients[y.id];let xt=Xe.texture;if(y.gradientVersion!==Xe.version){let Zt=256;if(y.stepInterpolant){const Yt=_.getSource().maxzoom,ri=ae.canonical.z===Yt?Math.ceil(1<<f.transform.maxZoom-ae.canonical.z):1;Zt=c.ah(c.c3(he.maxLineLength/c.$*1024*ri),256,K.maxTextureSize)}Xe.gradient=c.c4({expression:y.gradientExpression(),evaluationKey:"lineProgress",resolution:Zt,image:Xe.gradient||void 0,clips:he.lineClipsArray}),Xe.texture?Xe.texture.update(Xe.gradient):Xe.texture=new c.T(K,Xe.gradient,G.RGBA),Xe.version=y.gradientVersion,xt=Xe.texture}K.activeTexture.set(G.TEXTURE0),xt.bind(y.stepInterpolant?G.NEAREST:G.LINEAR,G.CLAMP_TO_EDGE)}const zt=f.stencilModeForClipping(ae);ye.draw(K,G.TRIANGLES,k,zt,O,$e.disabled,Ct,Ke,yt,y.id,he.layoutVertexBuffer,he.indexBuffer,he.segments,y.paint,f.transform.zoom,we,he.layoutVertexBuffer2),ue=!1}}(e,n,a,l,u):c.cf(a)?function(f,_,y,b,w){const S=y.paint.get("fill-color"),P=y.paint.get("fill-opacity");if(P.constantOr(1)===0)return;const{isRenderingToTexture:I}=w,k=f.colorModeForRenderPass(),O=y.paint.get("fill-pattern"),B=f.opaquePassEnabledForLayer()&&!O.constantOr(1)&&S.constantOr(c.bf.transparent).a===1&&P.constantOr(0)===1?"opaque":"translucent";if(f.renderPass===B){const N=f.getDepthModeForSublayer(1,f.renderPass==="opaque"?We.ReadWrite:We.ReadOnly);za(f,_,y,b,N,k,!1,I)}if(f.renderPass==="translucent"&&y.paint.get("fill-antialias")){const N=f.getDepthModeForSublayer(y.getPaintProperty("fill-outline-color")?2:0,We.ReadOnly);za(f,_,y,b,N,k,!0,I)}}(e,n,a,l,u):c.cg(a)?function(f,_,y,b,w){const S=y.paint.get("fill-extrusion-opacity");if(S===0)return;const{isRenderingToTexture:P}=w;if(f.renderPass==="translucent"){const I=new We(f.context.gl.LEQUAL,We.ReadWrite,f.depthRangeFor3D);if(S!==1||y.paint.get("fill-extrusion-pattern").constantOr(1))jo(f,_,y,b,I,lt.disabled,Pt.disabled,P),jo(f,_,y,b,I,f.stencilModeFor3D(),f.colorModeForRenderPass(),P);else{const k=f.colorModeForRenderPass();jo(f,_,y,b,I,lt.disabled,k,P)}}}(e,n,a,l,u):c.ch(a)?function(f,_,y,b,w){if(f.renderPass!=="offscreen"&&f.renderPass!=="translucent")return;const{isRenderingToTexture:S}=w,P=f.context,I=f.style.projection.useSubdivision,k=f.getDepthModeForSublayer(0,We.ReadOnly),O=f.colorModeForRenderPass();if(f.renderPass==="offscreen")(function(B,N,U,q,$,H,K){const G=B.context,te=G.gl;for(const ue of U){const ae=N.getTile(ue),oe=ae.dem;if(!oe||!oe.data||!ae.needsHillshadePrepare)continue;const he=oe.dim,we=oe.stride,Se=oe.getPixels();if(G.activeTexture.set(te.TEXTURE1),G.pixelStoreUnpackPremultiplyAlpha.set(!1),ae.demTexture=ae.demTexture||B.getTileTexture(we),ae.demTexture){const Le=ae.demTexture;Le.update(Se,{premultiply:!1}),Le.bind(te.NEAREST,te.CLAMP_TO_EDGE)}else ae.demTexture=new c.T(G,Se,te.RGBA,{premultiply:!1}),ae.demTexture.bind(te.NEAREST,te.CLAMP_TO_EDGE);G.activeTexture.set(te.TEXTURE0);let ye=ae.fbo;if(!ye){const Le=new c.T(G,{width:he,height:he,data:null},te.RGBA);Le.bind(te.LINEAR,te.CLAMP_TO_EDGE),ye=ae.fbo=G.createFramebuffer(he,he,!0,!1),ye.colorAttachment.set(Le.texture)}G.bindFramebuffer.set(ye.framebuffer),G.viewport.set([0,0,he,he]),B.useProgram("hillshadePrepare").draw(G,te.TRIANGLES,$,H,K,$e.disabled,Rl(ae.tileID,oe),null,null,q.id,B.rasterBoundsBuffer,B.quadTriangleIndexBuffer,B.rasterBoundsSegments),ae.needsHillshadePrepare=!1}})(f,_,b,y,k,lt.disabled,O),P.viewport.set([0,0,f.width,f.height]);else if(f.renderPass==="translucent")if(I){const[B,N,U]=f.stencilConfigForOverlapTwoPass(b);En(f,_,y,U,B,k,O,!1,S),En(f,_,y,U,N,k,O,!0,S)}else{const[B,N]=f.getStencilConfigForOverlapAndUpdateStencilID(b);En(f,_,y,N,B,k,O,!1,S)}}(e,n,a,l,u):c.ci(a)?function(f,_,y,b,w){if(f.renderPass!=="translucent"||!b.length)return;const{isRenderingToTexture:S}=w,P=f.style.projection.useSubdivision,I=f.getDepthModeForSublayer(0,We.ReadOnly),k=f.colorModeForRenderPass();if(P){const[O,B,N]=f.stencilConfigForOverlapTwoPass(b);No(f,_,y,N,O,I,k,!1,S),No(f,_,y,N,B,I,k,!0,S)}else{const[O,B]=f.getStencilConfigForOverlapAndUpdateStencilID(b);No(f,_,y,B,O,I,k,!1,S)}}(e,n,a,l,u):c.cj(a)?function(f,_,y,b,w){if(f.renderPass!=="translucent"||y.paint.get("raster-opacity")===0||!b.length)return;const{isRenderingToTexture:S}=w,P=_.getSource(),I=f.style.projection.useSubdivision;if(P instanceof yr)An(f,_,y,b,null,!1,!1,P.tileCoords,P.flippedWindingOrder,S);else if(I){const[k,O,B]=f.stencilConfigForOverlapTwoPass(b);An(f,_,y,B,k,!1,!0,La,!1,S),An(f,_,y,B,O,!0,!0,La,!1,S)}else{const[k,O]=f.getStencilConfigForOverlapAndUpdateStencilID(b);An(f,_,y,O,k,!1,!0,La,!1,S)}}(e,n,a,l,u):c.ck(a)?function(f,_,y,b,w){const S=y.paint.get("background-color"),P=y.paint.get("background-opacity");if(P===0)return;const{isRenderingToTexture:I}=w,k=f.context,O=k.gl,B=f.style.projection,N=f.transform,U=N.tileSize,q=y.paint.get("background-pattern");if(f.isPatternMissing(q))return;const $=!q&&S.a===1&&P===1&&f.opaquePassEnabledForLayer()?"opaque":"translucent";if(f.renderPass!==$)return;const H=lt.disabled,K=f.getDepthModeForSublayer(0,$==="opaque"?We.ReadWrite:We.ReadOnly),G=f.colorModeForRenderPass(),te=f.useProgram(q?"backgroundPattern":"background"),ue=b||ne(N,{tileSize:U,terrain:f.style.map.terrain});q&&(k.activeTexture.set(O.TEXTURE0),f.imageManager.bind(f.context));const ae=y.getCrossfadeParameters();for(const oe of ue){const he=N.getProjectionData({overscaledTileID:oe,applyGlobeMatrix:!I,applyTerrainMatrix:!0}),we=q?Vl(P,f,q,{tileID:oe,tileSize:U},ae):Nl(P,S),Se=f.style.map.terrain&&f.style.map.terrain.getTerrainData(oe),ye=B.getMeshFromTileID(k,oe.canonical,!1,!0,"raster");te.draw(k,O.TRIANGLES,K,H,G,$e.backCCW,we,Se,he,y.id,ye.vertexBuffer,ye.indexBuffer,ye.segments)}}(e,0,a,l,u):c.cl(a)&&function(f,_,y,b){const{isRenderingGlobe:w}=b,S=f.context,P=y.implementation,I=f.style.projection,k=f.transform,O=k.getProjectionDataForCustomLayer(w),B={farZ:k.farZ,nearZ:k.nearZ,fov:k.fov*Math.PI/180,modelViewProjectionMatrix:k.modelViewProjectionMatrix,projectionMatrix:k.projectionMatrix,shaderData:{variantName:I.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
742
742
  uniform mat4 u_projection_matrix;
743
- ${I.shaderPreludeCode.vertexSource}`,define:I.shaderDefine},defaultProjectionData:O},N=P.renderingMode?P.renderingMode:"2d";if(f.renderPass==="offscreen"){const U=P.prerender;U&&(f.setCustomLayerDefaults(),S.setColorMode(f.colorModeForRenderPass()),U.call(P,S.gl,B),S.setDirty(),f.setBaseState())}else if(f.renderPass==="translucent"){f.setCustomLayerDefaults(),S.setColorMode(f.colorModeForRenderPass()),S.setStencilMode(lt.disabled);const U=N==="3d"?f.getDepthModeFor3D():f.getDepthModeForSublayer(0,We.ReadOnly);S.setDepthMode(U),P.render(S.gl,B),S.setDirty(),f.setBaseState(),S.bindFramebuffer.set(null)}}(e,0,a,u))}saveTileTexture(e){const n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const n=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!n||!a}useProgram(e,n,a=!1,l=[]){this.cache=this.cache||{};const u=!!this.style.map.terrain,f=this.style.projection,_=a?Ji.projectionMercator:f.shaderPreludeCode,y=a?Mr:f.shaderDefine,b=e+(n?n.cacheKey:"")+`/${a?xn:f.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(u?"/terrain":"")+(l?`/${l.join("/")}`:"");return this.cache[b]||(this.cache[b]=new To(this.context,Ji[e],n,Eo[e],this._showOverdrawInspector,u,_,y,l)),this.cache[b]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new c.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}function kn(h,e){let n,a=!1,l=null,u=null;const f=()=>{l=null,a&&(h.apply(u,n),l=setTimeout(f,e),a=!1)};return(..._)=>(a=!0,u=this,n=_,l||f(),l)}class Fa{constructor(e){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(l=>l.split("=")).forEach(l=>{l[0]===this._hashName&&(a=l)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const a=n.join("/");let l=a;l.split("&").length>0&&(l=l.split("&")[0]),this._hashName&&(l=`${this._hashName}=${a}`);let u=window.location.hash.replace(l,"");u.startsWith("#&")?u=u.slice(0,1)+u.slice(2):u==="#"&&(u="");let f=window.location.href.replace(/(#.+)?$/,u);f=f.replace("&&","&"),window.history.replaceState(window.history.state,null,f)},this._updateHash=kn(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,l=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),u=Math.pow(10,l),f=Math.round(n.lng*u)/u,_=Math.round(n.lat*u)/u,y=this._map.getBearing(),b=this._map.getPitch();let w="";if(w+=e?`/${f}/${_}/${a}`:`${a}/${_}/${f}`,(y||b)&&(w+="/"+Math.round(10*y)/10),b&&(w+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let P=!1;const I=window.location.hash.slice(1).split("&").map(k=>{const O=k.split("=")[0];return O===S?(P=!0,`${O}=${w}`):k}).filter(k=>k);return P||I.push(`${S}=${w}`),`#${I.join("&")}`}return`#${w}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new c.S(+e[2],+e[1])}catch{return!1}const n=+e[0],a=+(e[3]||0),l=+(e[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&a>=-180&&a<=180&&l>=this._map.getMinPitch()&&l<=this._map.getMaxPitch()}}const Er={linearity:.3,easing:c.cm(0,0,.3,1)},Zo=c.e({deceleration:2500,maxSpeed:1400},Er),ic=c.e({deceleration:20,maxSpeed:1400},Er),rc=c.e({deceleration:1e3,maxSpeed:360},Er),nc=c.e({deceleration:1e3,maxSpeed:90},Er),sc=c.e({deceleration:1e3,maxSpeed:360},Er);class ac{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Ee.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=Ee.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,roll:0,pan:new c.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:u}of this._inertiaBuffer)n.zoom+=u.zoomDelta||0,n.bearing+=u.bearingDelta||0,n.pitch+=u.pitchDelta||0,n.roll+=u.rollDelta||0,u.panDelta&&n.pan._add(u.panDelta),u.around&&(n.around=u.around),u.pinchAround&&(n.pinchAround=u.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,l={};if(n.pan.mag()){const u=is(n.pan.mag(),a,c.e({},Zo,e||{})),f=n.pan.mult(u.amount/n.pan.mag()),_=this._map.cameraHelper.handlePanInertia(f,this._map.transform);l.center=_.easingCenter,l.offset=_.easingOffset,tr(l,u)}if(n.zoom){const u=is(n.zoom,a,ic);l.zoom=this._map.transform.zoom+u.amount,tr(l,u)}if(n.bearing){const u=is(n.bearing,a,rc);l.bearing=this._map.transform.bearing+c.ah(u.amount,-179,179),tr(l,u)}if(n.pitch){const u=is(n.pitch,a,nc);l.pitch=this._map.transform.pitch+u.amount,tr(l,u)}if(n.roll){const u=is(n.roll,a,sc);l.roll=this._map.transform.roll+c.ah(u.amount,-179,179),tr(l,u)}if(l.zoom||l.bearing){const u=n.pinchAround===void 0?n.around:n.pinchAround;l.around=u?this._map.unproject(u):this._map.getCenter()}return this.clear(),c.e(l,{noMoveStart:!0})}}function tr(h,e){(!h.duration||h.duration<e.duration)&&(h.duration=e.duration,h.easing=e.easing)}function is(h,e,n){const{maxSpeed:a,linearity:l,deceleration:u}=n,f=c.ah(h*l/(e/1e3),-a,a),_=Math.abs(f)/(u*l);return{easing:n.easing,duration:1e3*_,amount:f*(_/2)}}class ki extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a,l={}){a=a instanceof MouseEvent?a:new MouseEvent(e,a);const u=se.mousePos(n.getCanvas(),a),f=n.unproject(u);super(e,c.e({point:u,lngLat:f,originalEvent:a},l)),this._defaultPrevented=!1,this.target=n}}class rs extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){const l=e==="touchend"?a.changedTouches:a.touches,u=se.touchPos(n.getCanvasContainer(),l),f=u.map(y=>n.unproject(y)),_=u.reduce((y,b,w,S)=>y.add(b.div(S.length)),new c.P(0,0));super(e,{points:u,point:_,lngLats:f,lngLat:n.unproject(_),originalEvent:a}),this._defaultPrevented=!1}}class Go extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class oc{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Go(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new ki(e.type,this._map,e))}mouseup(e){this._map.fire(new ki(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new ki(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ki(e.type,this._map,e))}mouseover(e){this._map.fire(new ki(e.type,this._map,e))}mouseout(e){this._map.fire(new ki(e.type,this._map,e))}touchstart(e){return this._firePreventable(new rs(e.type,this._map,e))}touchmove(e){this._map.fire(new rs(e.type,this._map,e))}touchend(e){this._map.fire(new rs(e.type,this._map,e))}touchcancel(e){this._map.fire(new rs(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lc{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ki(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ki("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ki(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ns{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(c.P.convert(e),this._map.terrain)}}class qo{constructor(e,n){this._map=e,this._tr=new ns(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(se.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)<this._clickTolerance)return;const l=this._startPos;this._lastPos=a,this._box||(this._box=se.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const u=Math.min(l.x,a.x),f=Math.max(l.x,a.x),_=Math.min(l.y,a.y),y=Math.max(l.y,a.y);se.setTransform(this._box,`translate(${u}px,${_}px)`),this._box.style.width=f-u+"px",this._box.style.height=y-_+"px"}mouseupWindow(e,n){if(!this._active||e.button!==0)return;const a=this._startPos,l=n;if(this.reset(),se.suppressClick(),a.x!==l.x||a.y!==l.y)return this._map.fire(new c.l("boxzoomend",{originalEvent:e})),{cameraAnimation:u=>u.fitScreenCoordinates(a,l,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(se.remove(this._box),this._box=null),se.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new c.l(e,{originalEvent:n}))}}function ss(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);const n={};for(let a=0;a<h.length;a++)n[h[a].identifier]=e[a];return n}class cc{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,a){(this.centroid||a.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),a.length===this.numTouches&&(this.centroid=function(l){const u=new c.P(0,0);for(const f of l)u._add(f);return u.div(l.length)}(n),this.touches=ss(a,n)))}touchmove(e,n,a){if(this.aborted||!this.centroid)return;const l=ss(a,n);for(const u in this.touches){const f=l[u];(!f||f.dist(this.touches[u])>30)&&(this.aborted=!0)}}touchend(e,n,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const l=!this.aborted&&this.centroid;if(this.reset(),l)return l}}}class zi{constructor(e){this.singleTap=new cc(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,a){this.singleTap.touchstart(e,n,a)}touchmove(e,n,a){this.singleTap.touchmove(e,n,a)}touchend(e,n,a){const l=this.singleTap.touchend(e,n,a);if(l){const u=e.timeStamp-this.lastTime<500,f=!this.lastTap||this.lastTap.dist(l)<30;if(u&&f||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class ir{constructor(e){this._tr=new ns(e),this._zoomIn=new zi({numTouches:1,numTaps:2}),this._zoomOut=new zi({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,a){this._zoomIn.touchstart(e,n,a),this._zoomOut.touchstart(e,n,a)}touchmove(e,n,a){this._zoomIn.touchmove(e,n,a),this._zoomOut.touchmove(e,n,a)}touchend(e,n,a){const l=this._zoomIn.touchend(e,n,a),u=this._zoomOut.touchend(e,n,a),f=this._tr;return l?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:f.zoom+1,around:f.unproject(l)},{originalEvent:e})}):u?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:f.zoom-1,around:f.unproject(u)},{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 as{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.rollDelta||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=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const l=Array.isArray(n)?n[0]:n;return!this._moved&&l.dist(a)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=l,this._move(a,l))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&se.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}}const rr=0,os=2,ph={[rr]:1,[os]:2};class Ws{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){const n=se.mouseButton(e);this._eventButton=n}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(n,a){const l=ph[a];return n.buttons===void 0||(n.buttons&l)!==l}(e,this._eventButton)}isValidEndEvent(e){return se.mouseButton(e)===this._eventButton}}class fh{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)}}class mh{constructor(e=new Ws({checkCorrectEvent:()=>!0}),n=new fh){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(e,n,a){return e instanceof MouseEvent?n(e):typeof TouchEvent<"u"&&e instanceof TouchEvent?a(e):void 0}startMove(e){this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.startMove(n),n=>this.oneFingerTouchMoveStateManager.startMove(n))}endMove(e){this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.endMove(n),n=>this.oneFingerTouchMoveStateManager.endMove(n))}isValidStartEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidStartEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidStartEvent(n))}isValidMoveEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidMoveEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(n))}isValidEndEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidEndEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidEndEvent(n))}}const Hs=h=>{h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}};class Xs{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new c.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,a){return this._calculateTransform(e,n,a)}touchmove(e,n,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,n,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,a){this._calculateTransform(e,n,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,a){a.length>0&&(this._active=!0);const l=ss(a,n),u=new c.P(0,0),f=new c.P(0,0);let _=0;for(const b in l){const w=l[b],S=this._touches[b];S&&(u._add(w),f._add(w.sub(S)),_++,l[b]=w)}if(this._touches=l,this._shouldBePrevented(_)||!f.mag())return;const y=f.div(_);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:u.div(_),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class nr{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,n,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier],this._start([n[0],n[1]]))}touchmove(e,n,a){if(!this._firstTwoTouches)return;e.preventDefault();const[l,u]=this._firstTwoTouches,f=ze(a,n,l),_=ze(a,n,u);if(!f||!_)return;const y=this._aroundCenter?null:f.add(_).div(2);return this._move([f,_],y,e)}touchend(e,n,a){if(!this._firstTwoTouches)return;const[l,u]=this._firstTwoTouches,f=ze(a,n,l),_=ze(a,n,u);f&&_||(this._active&&se.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 ze(h,e,n){for(let a=0;a<h.length;a++)if(h[a].identifier===n)return e[a]}function Wo(h,e){return Math.log(h/e)/Math.LN2}class Ba extends nr{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,n){const a=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Wo(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Wo(this._distance,a),pinchAround:n}}}function Ho(h,e){return 180*h.angleWith(e)/Math.PI}class ls extends nr{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,a){const l=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Ho(this._vector,l),pinchAround:n}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const n=25/(Math.PI*this._minDiameter)*360,a=Ho(e,this._startVector);return Math.abs(a)<n}}function zn(h){return Math.abs(h.y)>Math.abs(h.x)}class Oa extends nr{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,a){super.touchstart(e,n,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,zn(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const l=e[0].sub(this._lastPoints[0]),u=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,u,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(l.y+u.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,a){if(this._valid!==void 0)return this._valid;const l=e.mag()>=2,u=n.mag()>=2;if(!l&&!u)return;if(!l||!u)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const f=e.y>0==n.y>0;return zn(e)&&zn(n)&&f}}const st={panStep:100,bearingStep:15,pitchStep:10};class ja{constructor(e){this._tr=new ns(e);const n=st;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,a=0,l=0,u=0,f=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),u=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),u=1);break;case 38:e.shiftKey?l=1:(e.preventDefault(),f=-1);break;case 40:e.shiftKey?l=-1:(e.preventDefault(),f=1);break;default:return}return this._rotationDisabled&&(a=0,l=0),{cameraAnimation:_=>{const y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:gh,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+l*this._pitchStep,offset:[-u*this._panStep,-f*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 gh(h){return h*(2-h)}const Na=4.000244140625,_h=1/450;class hc{constructor(e,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=e,this._tr=new ns(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=_h}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=Ee.now(),l=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%Na==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(l*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=se.mousePos(this._map.getCanvas(),e),a=this._tr;this._aroundPoint=this._aroundCenter?a.transform.locationToScreenPoint(c.S.convert(a.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const _=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=_),typeof this._targetZoom=="number"&&(this._targetZoom+=_)}if(this._delta!==0){const _=this._type==="wheel"&&Math.abs(this._delta)>Na?this._wheelZoomRate:this._defaultZoomRate;let y=2/(1+Math.exp(-Math.abs(this._delta*_)));this._delta<0&&y!==0&&(y=1/y);const b=typeof this._targetZoom!="number"?e.scale:c.af(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),c.ak(b*y)).zoom,this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom!="number"?e.zoom:this._targetZoom,a=this._startZoom,l=this._easing;let u,f=!1;if(this._type==="wheel"&&a&&l){const _=Ee.now()-this._lastWheelEventTime,y=Math.min((_+5)/200,1),b=l(y);u=c.C.number(a,n,b),y<1?this._frameId||(this._frameId=!0):f=!0}else u=n,f=!0;return this._active=!0,f&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=u,{noInertia:!0,needsRenderFrame:!f,zoomDelta:u-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=c.co;if(this._prevEase){const a=this._prevEase,l=(Ee.now()-a.start)/a.duration,u=a.easing(l+.01)-a.easing(l),f=.27/Math.sqrt(u*u+1e-4)*.01,_=Math.sqrt(.0729-f*f);n=c.cm(f,_,.25,1)}return this._prevEase={start:Ee.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Xo{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 Yo{constructor(e){this._tr=new ns(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class uc{constructor(){this._tap=new zi({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,n,a){if(!this._swipePoint)if(this._tapTime){const l=n[0],u=e.timeStamp-this._tapTime<500,f=this._tapPoint.dist(l)<30;u&&f?a.length>0&&(this._swipePoint=l,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,n,a)}touchmove(e,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const l=n[0],u=l.y-this._swipePoint.y;return this._swipePoint=l,e.preventDefault(),this._active=!0,{zoomDelta:u/128}}}else this._tap.touchmove(e,n,a)}touchend(e,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const l=this._tap.touchend(e,n,a);l&&(this._tapTime=e.timeStamp,this._tapPoint=l)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class dc{constructor(e,n,a){this._el=e,this._mousePan=n,this._touchPan=a}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ko{constructor(e,n,a,l){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=n,this._mousePitch=a,this._mouseRoll=l}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class pc{constructor(e,n,a,l){this._el=e,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=l,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class fc{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=se.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),l=document.createElement("div");l.className="maplibregl-desktop-message",l.textContent=n,this._container.appendChild(l);const u=document.createElement("div");u.className="maplibregl-mobile-message",u.textContent=a,this._container.appendChild(u),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(se.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new c.l("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const sr=h=>h.zoom||h.drag||h.roll||h.pitch||h.rotate;class wt extends c.l{}function cs(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta||h.rollDelta}class Jo{constructor(e,n){this.handleWindowEvent=l=>{this.handleEvent(l,`${l.type}Window`)},this.handleEvent=(l,u)=>{if(l.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const f=l.type==="renderFrame"?void 0:l,_={needsRenderFrame:!1},y={},b={};for(const{handlerName:P,handler:I,allowed:k}of this._handlers){if(!I.isEnabled())continue;let O;if(this._blockedByActive(b,k,P))I.reset();else if(I[u||l.type]){if(c.cp(l,u||l.type)){const B=se.mousePos(this._map.getCanvas(),l);O=I[u||l.type](l,B)}else if(c.cq(l,u||l.type)){const B=this._getMapTouches(l.touches),N=se.touchPos(this._map.getCanvas(),B);O=I[u||l.type](l,N,B)}else c.cr(u||l.type)||(O=I[u||l.type](l));this.mergeHandlerResult(_,y,O,P,f),O&&O.needsRenderFrame&&this._triggerRenderFrame()}(O||I.isActive())&&(b[P]=I)}const w={};for(const P in this._previousActiveHandlers)b[P]||(w[P]=f);this._previousActiveHandlers=b,(Object.keys(w).length||cs(_))&&(this._changes.push([_,y,w]),this._triggerRenderFrame()),(Object.keys(b).length||cs(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:S}=_;S&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],S(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ac(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[l,u,f]of this._listeners)se.addEventListener(l,u,l===document?this.handleWindowEvent:this.handleEvent,f)}destroy(){for(const[e,n,a]of this._listeners)se.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new oc(n,e));const l=n.boxZoom=new qo(n,e);this._add("boxZoom",l),e.interactive&&e.boxZoom&&l.enable();const u=n.cooperativeGestures=new fc(n,e.cooperativeGestures);this._add("cooperativeGestures",u),e.cooperativeGestures&&u.enable();const f=new ir(n),_=new Yo(n);n.doubleClickZoom=new Xo(_,f),this._add("tapZoom",f),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();const y=new uc;this._add("tapDragZoom",y);const b=n.touchPitch=new Oa(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);const w=()=>n.project(n.getCenter()),S=function({enable:$,clickTolerance:H,aroundCenter:K=!0,minPixelCenterThreshold:G=100,rotateDegreesPerPixelMoved:te=.8},ue){const ae=new Ws({checkCorrectEvent:oe=>se.mouseButton(oe)===0&&oe.ctrlKey||se.mouseButton(oe)===2&&!oe.ctrlKey});return new as({clickTolerance:H,move:(oe,he)=>{const we=ue();if(K&&Math.abs(we.y-oe.y)>G)return{bearingDelta:c.cn(new c.P(oe.x,he.y),he,we)};let Se=(he.x-oe.x)*te;return K&&he.y<we.y&&(Se=-Se),{bearingDelta:Se}},moveStateManager:ae,enable:$,assignEvents:Hs})}(e,w),P=function({enable:$,clickTolerance:H,pitchDegreesPerPixelMoved:K=-.5}){const G=new Ws({checkCorrectEvent:te=>se.mouseButton(te)===0&&te.ctrlKey||se.mouseButton(te)===2});return new as({clickTolerance:H,move:(te,ue)=>({pitchDelta:(ue.y-te.y)*K}),moveStateManager:G,enable:$,assignEvents:Hs})}(e),I=function({enable:$,clickTolerance:H,rollDegreesPerPixelMoved:K=.3},G){const te=new Ws({checkCorrectEvent:ue=>se.mouseButton(ue)===2&&ue.ctrlKey});return new as({clickTolerance:H,move:(ue,ae)=>{const oe=G();let he=(ae.x-ue.x)*K;return ae.y<oe.y&&(he=-he),{rollDelta:he}},moveStateManager:te,enable:$,assignEvents:Hs})}(e,w);n.dragRotate=new Ko(e,S,P,I),this._add("mouseRotate",S,["mousePitch"]),this._add("mousePitch",P,["mouseRotate","mouseRoll"]),this._add("mouseRoll",I,["mousePitch"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();const k=function({enable:$,clickTolerance:H}){const K=new Ws({checkCorrectEvent:G=>se.mouseButton(G)===0&&!G.ctrlKey});return new as({clickTolerance:H,move:(G,te)=>({around:te,panDelta:te.sub(G)}),activateOnStart:!0,moveStateManager:K,enable:$,assignEvents:Hs})}(e),O=new Xs(e,n);n.dragPan=new dc(a,k,O),this._add("mousePan",k),this._add("touchPan",O,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);const B=new ls,N=new Ba;n.touchZoomRotate=new pc(a,N,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);const U=n.scrollZoom=new hc(n,()=>this._triggerRenderFrame());this._add("scrollZoom",U,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);const q=n.keyboard=new ja(n);this._add("keyboard",q),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new lc(n))}_add(e,n,a){this._handlers.push({handlerName:e,handler:n,allowed:a}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!sr(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,a){for(const l in e)if(l!==a&&(!n||n.indexOf(l)<0))return!0;return!1}_getMapTouches(e){const n=[];for(const a of e)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(e,n,a,l,u){if(!a)return;c.e(e,a);const f={handlerName:l,originalEvent:a.originalEvent||u};a.zoomDelta!==void 0&&(n.zoom=f),a.panDelta!==void 0&&(n.drag=f),a.rollDelta!==void 0&&(n.roll=f),a.pitchDelta!==void 0&&(n.pitch=f),a.bearingDelta!==void 0&&(n.rotate=f)}_applyChanges(){const e={},n={},a={};for(const[l,u,f]of this._changes)l.panDelta&&(e.panDelta=(e.panDelta||new c.P(0,0))._add(l.panDelta)),l.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+l.zoomDelta),l.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+l.bearingDelta),l.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+l.pitchDelta),l.rollDelta&&(e.rollDelta=(e.rollDelta||0)+l.rollDelta),l.around!==void 0&&(e.around=l.around),l.pinchAround!==void 0&&(e.pinchAround=l.pinchAround),l.noInertia&&(e.noInertia=l.noInertia),c.e(n,u),c.e(a,f);this._updateMapTransform(e,n,a),this._changes=[]}_updateMapTransform(e,n,a){const l=this._map,u=l._getTransformForUpdate(),f=l.terrain;if(!(cs(e)||f&&this._terrainMovement))return this._fireEvents(n,a,!0);l._stop(!0);let{panDelta:_,zoomDelta:y,bearingDelta:b,pitchDelta:w,rollDelta:S,around:P,pinchAround:I}=e;I!==void 0&&(P=I),P=P||l.transform.centerPoint,f&&!u.isPointOnMapSurface(P)&&(P=u.centerPoint);const k={panDelta:_,zoomDelta:y,rollDelta:S,pitchDelta:w,bearingDelta:b,around:P};this._map.cameraHelper.useGlobeControls&&!u.isPointOnMapSurface(P)&&(P=u.centerPoint);const O=P.distSqr(u.centerPoint)<.01?u.center:u.screenPointToLocation(_?P.sub(_):P);f?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(k,u),this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?u.setCenter(u.screenPointToLocation(u.centerPoint.sub(_))):this._map.cameraHelper.handleMapControlsPan(k,u,O):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(k,u,O))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(k,u),this._map.cameraHelper.handleMapControlsPan(k,u,O)),l._applyUpdatedTransform(u),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,a,!0)}_fireEvents(e,n,a){const l=sr(this._eventsInProgress),u=sr(e),f={};for(const S in e){const{originalEvent:P}=e[S];this._eventsInProgress[S]||(f[`${S}start`]=P),this._eventsInProgress[S]=e[S]}!l&&u&&this._fireEvent("movestart",u.originalEvent);for(const S in f)this._fireEvent(S,f[S]);u&&this._fireEvent("move",u.originalEvent);for(const S in e){const{originalEvent:P}=e[S];this._fireEvent(S,P)}const _={};let y;for(const S in this._eventsInProgress){const{handlerName:P,originalEvent:I}=this._eventsInProgress[S];this._handlersById[P].isActive()||(delete this._eventsInProgress[S],y=n[P]||I,_[`${S}end`]=y)}for(const S in _)this._fireEvent(S,_[S]);const b=sr(this._eventsInProgress),w=(l||u)&&!b;if(w&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const S=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&S.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(S)}if(a&&w){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),P=I=>I!==0&&-this._bearingSnap<I&&I<this._bearingSnap;!S||!S.essential&&Ee.prefersReducedMotion?(this._map.fire(new c.l("moveend",{originalEvent:y})),P(this._map.getBearing())&&this._map.resetNorth()):(P(S.bearing||this._map.getBearing())&&(S.bearing=0),S.freezeElevation=!0,this._map.easeTo(S,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new c.l(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new wt("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class mc extends c.E{constructor(e,n,a){super(),this._renderFrameCallback=()=>{const l=Math.min((Ee.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(l)),l<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=a.bearingSnap,this.cameraHelper=n,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,n){e.apply(this.transform),this.transform=e,this.cameraHelper=n}getCenter(){return new c.S(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,n){return this.jumpTo({elevation:e},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,n,a){return e=c.P.convert(e).mult(-1),this.panTo(this.transform.center,c.e({offset:e},n),a)}panTo(e,n,a){return this.easeTo(c.e({center:e},n),a)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,a){return this.easeTo(c.e({zoom:e},n),a)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,n){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new c.l("movestart",n)).fire(new c.l("move",n)).fire(new c.l("moveend",n))),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,a){return this.easeTo(c.e({bearing:e},n),a)}resetNorth(e,n){return this.rotateTo(0,c.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(c.e({bearing:0,pitch:0,roll: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}getRoll(){return this.transform.roll}setRoll(e,n){return this.jumpTo({roll:e},n),this}cameraForBounds(e,n){e=Dt.convert(e).adjustAntiMeridian();const a=n&&n.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),a,n)}_cameraForBoxAndBearing(e,n,a,l){const u={top:0,bottom:0,right:0,left:0};if(typeof(l=c.e({padding:u,offset:[0,0],maxZoom:this.transform.maxZoom},l)).padding=="number"){const b=l.padding;l.padding={top:b,bottom:b,right:b,left:b}}const f=c.e(u,l.padding);l.padding=f;const _=this.transform,y=new Dt(e,n);return this.cameraHelper.cameraForBoxAndBearing(l,f,y,a,_)}fitBounds(e,n,a){return this._fitInternal(this.cameraForBounds(e,n),n,a)}fitScreenCoordinates(e,n,a,l,u){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(c.P.convert(e)),this.transform.screenPointToLocation(c.P.convert(n)),a,l),l,u)}_fitInternal(e,n,a){return e?(delete(n=c.e(e,n)).padding,n.linear?this.easeTo(n,a):this.flyTo(n,a)):this}jumpTo(e,n){this.stop();const a=this._getTransformForUpdate();let l=!1,u=!1,f=!1;const _=a.zoom;this.cameraHelper.handleJumpToCenterZoom(a,e);const y=a.zoom!==_;return"elevation"in e&&a.elevation!==+e.elevation&&a.setElevation(+e.elevation),"bearing"in e&&a.bearing!==+e.bearing&&(l=!0,a.setBearing(+e.bearing)),"pitch"in e&&a.pitch!==+e.pitch&&(u=!0,a.setPitch(+e.pitch)),"roll"in e&&a.roll!==+e.roll&&(f=!0,a.setRoll(+e.roll)),e.padding==null||a.isPaddingEqual(e.padding)||a.setPadding(e.padding),this._applyUpdatedTransform(a),this.fire(new c.l("movestart",n)).fire(new c.l("move",n)),y&&this.fire(new c.l("zoomstart",n)).fire(new c.l("zoom",n)).fire(new c.l("zoomend",n)),l&&this.fire(new c.l("rotatestart",n)).fire(new c.l("rotate",n)).fire(new c.l("rotateend",n)),u&&this.fire(new c.l("pitchstart",n)).fire(new c.l("pitch",n)).fire(new c.l("pitchend",n)),f&&this.fire(new c.l("rollstart",n)).fire(new c.l("roll",n)).fire(new c.l("rollend",n)),this.fire(new c.l("moveend",n))}calculateCameraOptionsFromTo(e,n,a,l=0){const u=c.a1.fromLngLat(e,n),f=c.a1.fromLngLat(a,l),_=f.x-u.x,y=f.y-u.y,b=f.z-u.z,w=Math.hypot(_,y,b);if(w===0)throw new Error("Can't calculate camera options with same From and To");const S=Math.hypot(_,y),P=c.ak(this.transform.cameraToCenterDistance/w/this.transform.tileSize),I=180*Math.atan2(_,-y)/Math.PI;let k=180*Math.acos(S/w)/Math.PI;return k=b<0?90-k:90+k,{center:f.toLngLat(),elevation:l,zoom:P,pitch:k,bearing:I}}calculateCameraOptionsFromCameraLngLatAltRotation(e,n,a,l,u){const f=this.transform.calculateCenterFromCameraLngLatAlt(e,n,a,l);return{center:f.center,elevation:f.elevation,zoom:f.zoom,bearing:a,pitch:l,roll:u}}easeTo(e,n){this._stop(!1,e.easeId),((e=c.e({offset:[0,0],duration:500,easing:c.co},e)).animate===!1||!e.essential&&Ee.prefersReducedMotion)&&(e.duration=0);const a=this._getTransformForUpdate(),l=this.getBearing(),u=a.pitch,f=a.roll,_="bearing"in e?this._normalizeBearing(e.bearing,l):l,y="pitch"in e?+e.pitch:u,b="roll"in e?this._normalizeBearing(e.roll,f):f,w="padding"in e?e.padding:a.padding,S=c.P.convert(e.offset);let P,I;e.around&&(P=c.S.convert(e.around),I=a.locationToScreenPoint(P));const k={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},O=this.cameraHelper.handleEaseTo(a,{bearing:_,pitch:y,roll:b,padding:w,around:P,aroundPoint:I,offsetAsPoint:S,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||l!==_,this._pitching=this._pitching||y!==u,this._rolling=this._rolling||b!==f,this._padding=!a.isPaddingEqual(w),this._zooming=this._zooming||O.isZooming,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,k),this.terrain&&this._prepareElevation(O.elevationCenter),this._ease(B=>{O.easeFunc(B),this.terrain&&!e.freezeElevation&&this._updateElevation(B),this._applyUpdatedTransform(a),this._fireMoveEvents(n)},B=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,B)},e),this}_prepareEase(e,n,a={}){this._moving=!0,n||a.moving||this.fire(new c.l("movestart",e)),this._zooming&&!a.zooming&&this.fire(new c.l("zoomstart",e)),this._rotating&&!a.rotating&&this.fire(new c.l("rotatestart",e)),this._pitching&&!a.pitching&&this.fire(new c.l("pitchstart",e)),this._rolling&&!a.rolling&&this.fire(new c.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(n-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.setElevation(c.C.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const n=e.getCameraLngLat(),a=e.getCameraAltitude(),l=this.terrain?this.terrain.getElevationForLngLatZoom(n,e.zoom):0;if(a<l){const u=this.calculateCameraOptionsFromTo(n,l,e.center,e.elevation);return{pitch:u.pitch,zoom:u.zoom}}return{}}_applyUpdatedTransform(e){const n=[];if(n.push(l=>this._elevateCameraIfInsideTerrain(l)),this.transformCameraUpdate&&n.push(l=>this.transformCameraUpdate(l)),!n.length)return;const a=e.clone();for(const l of n){const u=a.clone(),{center:f,zoom:_,roll:y,pitch:b,bearing:w,elevation:S}=l(u);f&&u.setCenter(f),S!==void 0&&u.setElevation(S),_!==void 0&&u.setZoom(_),y!==void 0&&u.setRoll(y),b!==void 0&&u.setPitch(b),w!==void 0&&u.setBearing(w),a.apply(u)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new c.l("move",e)),this._zooming&&this.fire(new c.l("zoom",e)),this._rotating&&this.fire(new c.l("rotate",e)),this._pitching&&this.fire(new c.l("pitch",e)),this._rolling&&this.fire(new c.l("roll",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,l=this._rotating,u=this._pitching,f=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,a&&this.fire(new c.l("zoomend",e)),l&&this.fire(new c.l("rotateend",e)),u&&this.fire(new c.l("pitchend",e)),f&&this.fire(new c.l("rollend",e)),this.fire(new c.l("moveend",e))}flyTo(e,n){if(!e.essential&&Ee.prefersReducedMotion){const he=c.Q(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(he,n)}this.stop(),e=c.e({offset:[0,0],speed:1.2,curve:1.42,easing:c.co},e);const a=this._getTransformForUpdate(),l=a.bearing,u=a.pitch,f=a.roll,_=a.padding,y="bearing"in e?this._normalizeBearing(e.bearing,l):l,b="pitch"in e?+e.pitch:u,w="roll"in e?this._normalizeBearing(e.roll,f):f,S="padding"in e?e.padding:a.padding,P=c.P.convert(e.offset);let I=a.centerPoint.add(P);const k=a.screenPointToLocation(I),O=this.cameraHelper.handleFlyTo(a,{bearing:y,pitch:b,roll:w,padding:S,locationAtOffset:k,offsetAsPoint:P,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let B=e.curve;const N=Math.max(a.width,a.height),U=N/O.scaleOfZoom,q=O.pixelPathLength;typeof O.scaleOfMinZoom=="number"&&(B=Math.sqrt(N/O.scaleOfMinZoom/q*2));const $=B*B;function H(he){const we=(U*U-N*N+(he?-1:1)*$*$*q*q)/(2*(he?U:N)*$*q);return Math.log(Math.sqrt(we*we+1)-we)}function K(he){return(Math.exp(he)-Math.exp(-he))/2}function G(he){return(Math.exp(he)+Math.exp(-he))/2}const te=H(!1);let ue=function(he){return G(te)/G(te+B*he)},ae=function(he){return N*((G(te)*(K(we=te+B*he)/G(we))-K(te))/$)/q;var we},oe=(H(!0)-te)/B;if(Math.abs(q)<2e-6||!isFinite(oe)){if(Math.abs(N-U)<1e-6)return this.easeTo(e,n);const he=U<N?-1:1;oe=Math.abs(Math.log(U/N))/B,ae=()=>0,ue=we=>Math.exp(he*B*we)}return e.duration="duration"in e?+e.duration:1e3*oe/("screenSpeed"in e?+e.screenSpeed/B:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=l!==y,this._pitching=b!==u,this._rolling=w!==f,this._padding=!a.isPaddingEqual(S),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(O.targetCenter),this._ease(he=>{const we=he*oe,Se=1/ue(we),ye=ae(we);this._rotating&&a.setBearing(c.C.number(l,y,he)),this._pitching&&a.setPitch(c.C.number(u,b,he)),this._rolling&&a.setRoll(c.C.number(f,w,he)),this._padding&&(a.interpolatePadding(_,S,he),I=a.centerPoint.add(P)),O.easeFunc(he,Se,ye,I),this.terrain&&!e.freezeElevation&&this._updateElevation(he),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 a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const l=this._onEaseEnd;delete this._onEaseEnd,l.call(this,n)}return e||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(e,n,a){a.animate===!1||a.duration===0?(e(1),n()):(this._easeStart=Ee.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=c.aO(e,-180,180);const a=Math.abs(e-n);return Math.abs(e-360-n)<a&&(e-=360),Math.abs(e+360-n)<a&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(c.S.convert(e),this.transform.tileZoom):null}}const Qo={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class el{constructor(e=Qo){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=se.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=se.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=se.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){se.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,n){const a=this._map._getUIString(`AttributionControl.${n}`);e.title=a,e.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(l=>typeof l!="string"?"":l)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const l=this._map.style.stylesheet;this.styleOwner=l.owner,this.styleId=l.id}const n=this._map.style.sourceCaches;for(const l in n){const u=n[l];if(u.used||u.usedForTerrain){const f=u.getSource();f.attribution&&e.indexOf(f.attribution)<0&&e.push(f.attribution)}}e=e.filter(l=>String(l).trim()),e.sort((l,u)=>l.length-u.length),e=e.filter((l,u)=>{for(let f=u+1;f<e.length;f++)if(e[f].indexOf(l)>=0)return!1;return!0});const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=se.sanitize(a),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class gc{constructor(e={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=se.create("div","maplibregl-ctrl");const n=se.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){se.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Pr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const l of a)if(l.id===e)return void(l.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Va=c.aJ([{name:"a_pos3d",type:"Int16",components:3}]);class Fe extends c.E{constructor(e){super(),this._lastTilesetChange=Ee.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];const a={};for(const l of ne(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))a[l.key]=!0,this._renderableTilesKeys.push(l.key),this._tiles[l.key]||(l.terrainRttPosMatrix32f=new Float64Array(16),c.bY(l.terrainRttPosMatrix32f,0,c.$,c.$,0,0,1),this._tiles[l.key]=new Zn(l,this.tileSize),this._lastTilesetChange=Ee.now());for(const l in this._tiles)a[l]||delete this._tiles[l]}freeRtt(e){for(const n in this._tiles){const a=this._tiles[n];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,n){return n?this._getTerrainCoordsForTileRanges(e,n):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const n={};for(const a of this._renderableTilesKeys){const l=this._tiles[a].tileID,u=e.clone(),f=c.ba();if(l.canonical.equals(e.canonical))c.bY(f,0,c.$,c.$,0,0,1);else if(l.canonical.isChildOf(e.canonical)){const _=l.canonical.z-e.canonical.z,y=l.canonical.x-(l.canonical.x>>_<<_),b=l.canonical.y-(l.canonical.y>>_<<_),w=c.$>>_;c.bY(f,0,w,w,0,0,1),c.M(f,f,[-y*w,-b*w,0])}else{if(!e.canonical.isChildOf(l.canonical))continue;{const _=e.canonical.z-l.canonical.z,y=e.canonical.x-(e.canonical.x>>_<<_),b=e.canonical.y-(e.canonical.y>>_<<_),w=c.$>>_;c.bY(f,0,c.$,c.$,0,0,1),c.M(f,f,[y*w,b*w,0]),c.N(f,f,[1/2**_,1/2**_,0])}}u.terrainRttPosMatrix32f=new Float32Array(f),n[a]=u}return n}_getTerrainCoordsForTileRanges(e,n){const a={};for(const l of this._renderableTilesKeys){const u=this._tiles[l].tileID;if(!this._isWithinTileRanges(u,n))continue;const f=e.clone(),_=c.ba();if(u.canonical.z===e.canonical.z){const y=e.canonical.x-u.canonical.x,b=e.canonical.y-u.canonical.y;c.bY(_,0,c.$,c.$,0,0,1),c.M(_,_,[y*c.$,b*c.$,0])}else if(u.canonical.z>e.canonical.z){const y=u.canonical.z-e.canonical.z,b=u.canonical.x-(u.canonical.x>>y<<y),w=u.canonical.y-(u.canonical.y>>y<<y),S=e.canonical.x-(u.canonical.x>>y),P=e.canonical.y-(u.canonical.y>>y),I=c.$>>y;c.bY(_,0,I,I,0,0,1),c.M(_,_,[-b*I+S*c.$,-w*I+P*c.$,0])}else{const y=e.canonical.z-u.canonical.z,b=e.canonical.x-(e.canonical.x>>y<<y),w=e.canonical.y-(e.canonical.y>>y<<y),S=(e.canonical.x>>y)-u.canonical.x,P=(e.canonical.y>>y)-u.canonical.y,I=c.$<<y;c.bY(_,0,I,I,0,0,1),c.M(_,_,[b*c.$+S*I,w*c.$+P*I,0])}f.terrainRttPosMatrix32f=new Float32Array(_),a[l]=f}return a}getSourceTile(e,n){const a=this.sourceCache._source;let l=e.overscaledZ-this.deltaZoom;if(l>a.maxzoom&&(l=a.maxzoom),l<a.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(l).key);let u=this.sourceCache.getTileByID(this._sourceTileCache[e.key]);if((!u||!u.dem)&&n)for(;l>=a.minzoom&&(!u||!u.dem);)u=this.sourceCache.getTileByID(e.scaledTo(l--).key);return u}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,n){return n[e.canonical.z]&&e.canonical.x>=n[e.canonical.z].minTileX&&e.canonical.x<=n[e.canonical.z].maxTileX&&e.canonical.y>=n[e.canonical.z].minTileY&&e.canonical.y<=n[e.canonical.z].maxTileY}}class Ne{constructor(e,n,a){this._meshCache={},this.painter=e,this.sourceCache=new Fe(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,a,l=c.$){var u;if(!(n>=0&&n<l&&a>=0&&a<l))return 0;const f=this.getTerrainData(e),_=(u=f.tile)===null||u===void 0?void 0:u.dem;if(!_)return 0;const y=c.cs([],[n/l*c.$,a/l*c.$],f.u_terrain_matrix),b=[y[0]*_.dim,y[1]*_.dim],w=Math.floor(b[0]),S=Math.floor(b[1]),P=b[0]-w,I=b[1]-S;return _.get(w,S)*(1-P)*(1-I)+_.get(w+1,S)*P*(1-I)+_.get(w,S+1)*(1-P)*I+_.get(w+1,S+1)*P*I}getElevationForLngLatZoom(e,n){if(!c.ct(n,e.wrap()))return 0;const{tileID:a,mercatorX:l,mercatorY:u}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(a,l%c.$,u%c.$,c.$)}getElevation(e,n,a,l=c.$){return this.getDEMElevation(e,n,a,l)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const l=this.painter.context,u=new c.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new c.T(l,u,l.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new c.T(l,new c.R({width:1,height:1}),l.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=c.ag([])}const n=this.sourceCache.getSourceTile(e,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const l=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new c.T(l,n.dem.getPixels(),l.gl.RGBA,{premultiply:!1}),n.demTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const a=n&&n+n.tileID.key+e.key;if(a&&!this._demMatrixCache[a]){const l=this.sourceCache.sourceCache._source.maxzoom;let u=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=l?u=e.canonical.z-l:c.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const f=e.canonical.x-(e.canonical.x>>u<<u),_=e.canonical.y-(e.canonical.y>>u<<u),y=c.cu(new Float64Array(16),[1/(c.$<<u),1/(c.$<<u),0]);c.M(y,y,[f*c.$,_*c.$,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:a?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){const n=this.painter,a=n.width/devicePixelRatio,l=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===a&&this._fbo.height===l||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new c.T(n.context,{width:a,height:l,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 c.T(n.context,{width:a,height:l,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(a,l,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,a,l))),this._fbo.colorAttachment.set(e==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let u=0,f=0;u<this._coordsTextureSize;u++)for(let _=0;_<this._coordsTextureSize;_++,f+=4)n[f+0]=255&_,n[f+1]=255&u,n[f+2]=_>>8<<4|u>>8,n[f+3]=0;const a=new c.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),l=new c.T(e,a,e.gl.RGBA,{premultiply:!1});return l.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=l,l}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),a=this.painter.context,l=a.gl,u=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),f=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),l.readPixels(u,_-f-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),w=this.coordsIndex[255-n[3]],S=w&&this.sourceCache.getTileByID(w);if(!S)return null;const P=this._coordsTextureSize,I=(1<<S.tileID.canonical.z)*P;return new c.a1((S.tileID.canonical.x*P+y)/I+S.tileID.wrap,(S.tileID.canonical.y*P+b)/I,this.getElevation(S.tileID,y,b,P))}depthAtPoint(e){const n=new Uint8Array(4),a=this.painter.context,l=a.gl;return a.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),l.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(e){var n;const a=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,l=a&&e.canonical.y===0,u=a&&e.canonical.y===(1<<e.canonical.z)-1,f=`m_${l?"n":""}_${u?"s":""}`;if(this._meshCache[f])return this._meshCache[f];const _=this.painter.context,y=new c.cv,b=new c.aN,w=this.meshSize,S=c.$/w,P=w*w;for(let G=0;G<=w;G++)for(let te=0;te<=w;te++)y.emplaceBack(te*S,G*S,0);for(let G=0;G<P;G+=w+1)for(let te=0;te<w;te++)b.emplaceBack(te+G,w+te+G+1,w+te+G+2),b.emplaceBack(te+G,w+te+G+2,te+G+1);const I=y.length,k=I+(w+1),O=(w+1)*w,B=l?c.bh:0,N=l?0:1,U=u?c.bi:c.$,q=u?0:1;for(let G=0;G<=w;G++)y.emplaceBack(G*S,B,N);for(let G=0;G<=w;G++)y.emplaceBack(G*S,U,q);for(let G=0;G<w;G++)b.emplaceBack(O+G,k+G,k+G+1),b.emplaceBack(O+G,k+G+1,O+G+1),b.emplaceBack(0+G,I+G+1,I+G),b.emplaceBack(0+G,0+G+1,I+G+1);const $=y.length,H=$+2*(w+1);for(const G of[0,1])for(let te=0;te<=w;te++)for(const ue of[0,1])y.emplaceBack(G*c.$,te*S,ue);for(let G=0;G<2*w;G+=2)b.emplaceBack($+G,$+G+1,$+G+3),b.emplaceBack($+G,$+G+3,$+G+2),b.emplaceBack(H+G,H+G+3,H+G+1),b.emplaceBack(H+G,H+G+2,H+G+3);const K=new yn(_.createVertexBuffer(y,Va.members),_.createIndexBuffer(b),c.aM.simpleSegment(0,0,y.length,b.length));return this._meshCache[f]=K,K}getMeshFrameDelta(e){return 2*Math.PI*c.bu/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,n){var a;const{tileID:l}=this._getOverscaledTileIDFromLngLatZoom(e,n);return(a=this.getMinMaxElevation(l).minElevation)!==null&&a!==void 0?a:0}getMinMaxElevation(e){const n=this.getTerrainData(e).tile,a={minElevation:null,maxElevation:null};return n&&n.dem&&(a.minElevation=n.dem.min*this.exaggeration,a.maxElevation=n.dem.max*this.exaggeration),a}_getOverscaledTileIDFromLngLatZoom(e,n){const a=c.a1.fromLngLat(e.wrap()),l=(1<<n)*c.$,u=a.x*l,f=a.y*l,_=Math.floor(u/c.$),y=Math.floor(f/c.$);return{tileID:new c.Z(n,0,n,_,y),mercatorX:u,mercatorY:f}}}class Ua{constructor(e,n,a){this._context=e,this._size=n,this._tileSize=a,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),a=new c.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return a.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(a.texture),{id:e,fbo:n,texture:a,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(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(e=>!e.inUse)===!1}}const en={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class $a{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new Ua(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(n)),this._coordsAscending={};for(const a in e.sourceCaches){this._coordsAscending[a]={};const l=e.sourceCaches[a].getVisibleCoordinates(),u=e.sourceCaches[a].getSource(),f=u instanceof yr?u.terrainTileRanges:null;for(const _ of l){const y=this.terrain.sourceCache.getTerrainCoords(_,f);for(const b in y)this._coordsAscending[a][b]||(this._coordsAscending[a][b]=[]),this._coordsAscending[a][b].push(y[b])}}this._coordsAscendingStr={};for(const a of e._order){const l=e._layers[a],u=l.source;if(en[l.type]&&!this._coordsAscendingStr[u]){this._coordsAscendingStr[u]={};for(const f in this._coordsAscending[u])this._coordsAscendingStr[u][f]=this._coordsAscending[u][f].map(_=>_.key).sort().join()}}for(const a of this._renderableTiles)for(const l in this._coordsAscendingStr){const u=this._coordsAscendingStr[l][a.tileID.key];u&&u!==a.rttCoords[l]&&(a.rtt=[])}}renderLayer(e,n){if(e.isHidden(this.painter.transform.zoom))return!1;const a=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),l=e.type,u=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(en[l]&&(this._prevType&&en[this._prevType]||this._stacks.push([]),this._prevType=l,this._stacks[this._stacks.length-1].push(e.id),!f))return!0;if(en[this._prevType]||en[l]&&f){this._prevType=l;const _=this._stacks.length-1,y=this._stacks[_]||[];for(const b of this._renderableTiles){if(this.pool.isFull()&&(Ra(this.painter,this.terrain,this._rttTiles,a),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(b),b.rtt[_]){const S=this.pool.getObjectForId(b.rtt[_].id);if(S.stamp===b.rtt[_].stamp){this.pool.useObject(S);continue}}const w=this.pool.getOrCreateFreeObject();this.pool.useObject(w),this.pool.stampObject(w),b.rtt[_]={id:w.id,stamp:w.stamp},u.context.bindFramebuffer.set(w.fbo.framebuffer),u.context.clear({color:c.bf.transparent,stencil:0}),u.currentStencilSource=void 0;for(let S=0;S<y.length;S++){const P=u.style._layers[y[S]],I=P.source?this._coordsAscending[P.source][b.tileID.key]:[b.tileID];u.context.viewport.set([0,0,w.fbo.width,w.fbo.height]),u._renderTileClippingMasks(P,I,!0),u.renderLayer(u,u.style.sourceCaches[P.source],P,I,a),P.source&&(b.rttCoords[P.source]=this._coordsAscendingStr[P.source][b.tileID.key])}}return Ra(this.painter,this.terrain,this._rttTiles,a),this._rttTiles=[],this.pool.freeAllObjects(),en[l]}return!1}}const Pi={"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","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},_c=be,Wi={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Qo,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 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],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:c.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0},yh={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Ys{constructor(e,n,a=!1){this.mousedown=u=>{this.startMove(u,se.mousePos(this.element,u)),se.addEventListener(window,"mousemove",this.mousemove),se.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=u=>{this.move(u,se.mousePos(this.element,u))},this.mouseup=u=>{this._rotatePitchHandler.dragEnd(u),this.offTemp()},this.touchstart=u=>{u.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=se.touchPos(this.element,u.targetTouches)[0],this.startMove(u,this._startPos),se.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.addEventListener(window,"touchend",this.touchend))},this.touchmove=u=>{u.targetTouches.length!==1?this.reset():(this._lastPos=se.touchPos(this.element,u.targetTouches)[0],this.move(u,this._lastPos))},this.touchend=u=>{u.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._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n;const l=new mh;this._rotatePitchHandler=new as({clickTolerance:3,move:(u,f)=>{const _=n.getBoundingClientRect(),y=new c.P((_.bottom-_.top)/2,(_.right-_.left)/2);return{bearingDelta:c.cn(new c.P(u.x,f.y),f,y),pitchDelta:a?-.5*(f.y-u.y):void 0}},moveStateManager:l,enable:!0,assignEvents:()=>{}}),this.map=e,se.addEventListener(n,"mousedown",this.mousedown),se.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),se.addEventListener(n,"touchcancel",this.reset)}startMove(e,n){this._rotatePitchHandler.dragStart(e,n),se.disableDrag()}move(e,n){const a=this.map,{bearingDelta:l,pitchDelta:u}=this._rotatePitchHandler.dragMove(e,n)||{};l&&a.setBearing(a.getBearing()+l),u&&a.setPitch(a.getPitch()+u)}off(){const e=this.element;se.removeEventListener(e,"mousedown",this.mousedown),se.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend),se.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){se.enableDrag(),se.removeEventListener(window,"mousemove",this.mousemove),se.removeEventListener(window,"mouseup",this.mouseup),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend)}}let _t;function Bt(h,e,n,a=!1){if(a||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return h==null?void 0:h.wrap();const l=new c.S(h.lng,h.lat);if(h=new c.S(h.lng,h.lat),e){const u=new c.S(h.lng-360,h.lat),f=new c.S(h.lng+360,h.lat),_=n.locationToScreenPoint(h).distSqr(e);n.locationToScreenPoint(u).distSqr(e)<_?h=u:n.locationToScreenPoint(f).distSqr(e)<_&&(h=f)}for(;Math.abs(h.lng-n.center.lng)>180;){const u=n.locationToScreenPoint(h);if(u.x>=0&&u.y>=0&&u.x<=n.width&&u.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==l.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(h))?h:l}const Za={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 hs(h,e,n){const a=h.classList;for(const l in Za)a.remove(`maplibregl-${n}-anchor-${l}`);a.add(`maplibregl-${n}-anchor-${e}`)}class us extends c.E{constructor(e){if(super(),this._onKeyPress=n=>{const a=n.code,l=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&l!==32&&l!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,l=this._element;this._popup&&(a===l||l.contains(a))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const a=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!a)&&this._map.once("render",this._update),this._lngLat=Bt(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let l="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?l=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(l=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let u="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?u="rotateX(0deg)":this._pitchAlignment==="map"&&(u=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),se.setTransform(this._element,`${Za[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${u} ${l}`),Ee.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new c.l("dragstart"))),this.fire(new c.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new c.l("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(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=c.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=se.create("div");const n=se.createNS("http://www.w3.org/2000/svg","svg"),a=41,l=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${l}px`),n.setAttributeNS(null,"viewBox",`0 0 ${l} ${a}`);const u=se.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"stroke","none"),u.setAttributeNS(null,"stroke-width","1"),u.setAttributeNS(null,"fill","none"),u.setAttributeNS(null,"fill-rule","evenodd");const f=se.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"fill-rule","nonzero");const _=se.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const y=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const N of y){const U=se.createNS("http://www.w3.org/2000/svg","ellipse");U.setAttributeNS(null,"opacity","0.04"),U.setAttributeNS(null,"cx","10.5"),U.setAttributeNS(null,"cy","5.80029008"),U.setAttributeNS(null,"rx",N.rx),U.setAttributeNS(null,"ry",N.ry),_.appendChild(U)}const b=se.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const w=se.createNS("http://www.w3.org/2000/svg","path");w.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(w);const S=se.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const P=se.createNS("http://www.w3.org/2000/svg","path");P.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(P);const I=se.createNS("http://www.w3.org/2000/svg","g");I.setAttributeNS(null,"transform","translate(6.0, 7.0)"),I.setAttributeNS(null,"fill","#FFFFFF");const k=se.createNS("http://www.w3.org/2000/svg","g");k.setAttributeNS(null,"transform","translate(8.0, 8.0)");const O=se.createNS("http://www.w3.org/2000/svg","circle");O.setAttributeNS(null,"fill","#000000"),O.setAttributeNS(null,"opacity","0.25"),O.setAttributeNS(null,"cx","5.5"),O.setAttributeNS(null,"cy","5.5"),O.setAttributeNS(null,"r","5.4999962");const B=se.createNS("http://www.w3.org/2000/svg","circle");B.setAttributeNS(null,"fill","#FFFFFF"),B.setAttributeNS(null,"cx","5.5"),B.setAttributeNS(null,"cy","5.5"),B.setAttributeNS(null,"r","5.4999962"),k.appendChild(O),k.appendChild(B),f.appendChild(_),f.appendChild(b),f.appendChild(S),f.appendChild(I),f.appendChild(k),n.appendChild(f),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",l*this._scale+"px"),this._element.appendChild(n),this._offset=c.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()}),hs(this._element,this._anchor,"marker"),e&&e.className)for(const n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),se.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=c.S.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const l=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":[l,-1*(38.1-13.5+l)],"bottom-right":[-l,-1*(38.1-13.5+l)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,a;const l=(n=this._map)===null||n===void 0?void 0:n.terrain,u=this._map.transform.isLocationOccluded(this._lngLat);if(!l||u){const I=u?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==I&&(this._element.style.opacity=I))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const f=this._map,_=f.terrain.depthAtPoint(this._pos),y=f.terrain.getElevationForLngLatZoom(this._lngLat,f.transform.tileZoom);if(f.transform.lngLatToCameraDepth(this._lngLat,y)-_<.006)return void(this._element.style.opacity=this._opacity);const b=-this._offset.y/f.transform.pixelsPerMeter,w=Math.sin(f.getPitch()*Math.PI/180)*b,S=f.terrain.depthAtPoint(new c.P(this._pos.x,this._pos.y-this._offset.y)),P=f.transform.lngLatToCameraDepth(this._lngLat,y+w)-S>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&P&&this._popup.remove(),this._element.style.opacity=P?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=c.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(this._opacity===void 0||e===void 0&&n===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const tl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ds=0,Ln=!1;const Ks={maxWidth:100,unit:"metric"};function Ga(h,e,n){const a=n&&n.maxWidth||100,l=h._container.clientHeight/2,u=h._container.clientWidth/2,f=h.unproject([u-a/2,l]),_=h.unproject([u+a/2,l]),y=Math.round(h.project(_).x-h.project(f).x),b=Math.min(a,y,h._container.clientWidth),w=f.distanceTo(_);if(n&&n.unit==="imperial"){const S=3.2808*w;S>5280?Dn(e,b,S/5280,h._getUIString("ScaleControl.Miles")):Dn(e,b,S,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Dn(e,b,w/1852,h._getUIString("ScaleControl.NauticalMiles")):w>=1e3?Dn(e,b,w/1e3,h._getUIString("ScaleControl.Kilometers")):Dn(e,b,w,h._getUIString("ScaleControl.Meters"))}function Dn(h,e,n,a){const l=function(u){const f=Math.pow(10,`${Math.floor(u)}`.length-1);let _=u/f;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b}(_),f*_}(n);h.style.width=e*(l/n)+"px",h.innerHTML=`${l}&nbsp;${a}`}const il={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},rl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function qa(h){if(h){if(typeof h=="number"){const e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new c.P(0,0),top:new c.P(0,h),"top-left":new c.P(e,e),"top-right":new c.P(-e,e),bottom:new c.P(0,-h),"bottom-left":new c.P(e,-e),"bottom-right":new c.P(-e,-e),left:new c.P(h,0),right:new c.P(-h,0)}}if(h instanceof c.P||Array.isArray(h)){const e=c.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:c.P.convert(h.center||[0,0]),top:c.P.convert(h.top||[0,0]),"top-left":c.P.convert(h["top-left"]||[0,0]),"top-right":c.P.convert(h["top-right"]||[0,0]),bottom:c.P.convert(h.bottom||[0,0]),"bottom-left":c.P.convert(h["bottom-left"]||[0,0]),"bottom-right":c.P.convert(h["bottom-right"]||[0,0]),left:c.P.convert(h.left||[0,0]),right:c.P.convert(h.right||[0,0])}}return qa(new c.P(0,0))}const nl=be;C.AJAXError=c.cz,C.Event=c.l,C.Evented=c.E,C.LngLat=c.S,C.MercatorCoordinate=c.a1,C.Point=c.P,C.addProtocol=c.cA,C.config=c.a,C.removeProtocol=c.cB,C.AttributionControl=el,C.BoxZoomHandler=qo,C.CanvasSource=Nr,C.CooperativeGesturesHandler=fc,C.DoubleClickZoomHandler=Xo,C.DragPanHandler=dc,C.DragRotateHandler=Ko,C.EdgeInsets=vn,C.FullscreenControl=class extends c.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n==null?void 0:n.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:c.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){se.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=se.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);se.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new c.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new c.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},C.GeoJSONSource=_r,C.GeolocateControl=class extends c.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new c.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&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 c.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const n=new c.S(e.coords.longitude,e.coords.latitude),a=e.coords.accuracy,l=this._map.getBearing(),u=c.e({bearing:l},this.options.fitBoundsOptions),f=Dt.fromLngLat(n,a);this._map.fitBounds(f,u,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const n=new c.S(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._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(e.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ln)return;this.options.trackUserLocation&&this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new c.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=se.create("button","maplibregl-ctrl-geolocate",this._container),se.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){c.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=se.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new us({element:this._dotElement}),this._circleElement=se.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new us({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{const a=(n==null?void 0:n[0])instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||a||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new c.l("trackuserlocationend")),this.fire(new c.l("userlocationlostfocus")))})}},this.options=c.e({},tl,h)}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return c._(this,arguments,void 0,function*(e=!1){if(_t!==void 0&&!e)return _t;if(window.navigator.permissions===void 0)return _t=!!window.navigator.geolocation,_t;try{_t=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{_t=!!window.navigator.geolocation}return _t})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),se.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ds=0,Ln=!1}_isOutOfMapMaxBounds(h){const 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}`)}}_updateCircleRadiusIfNeeded(){const h=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&h))return;const e=this._map.project(h),n=this._map.unproject([e.x+100,e.y]),a=h.distanceTo(n)/100,l=2*this._accuracy/a;this._circleElement.style.width=`${l.toFixed(2)}px`,this._circleElement.style.height=`${l.toFixed(2)}px`}trigger(){if(!this._setup)return c.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 c.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ds--,Ln=!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 c.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new c.l("trackuserlocationstart")),this.fire(new c.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(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"),ds++,ds>1?(h={maximumAge:6e5,timeout:0},Ln=!0):(h=this.options.positionOptions,Ln=!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)}},C.GlobeControl=class{constructor(){this._toggleProjection=()=>{var h;const e=(h=this._map.getProjection())===null||h===void 0?void 0:h.type;this._map.setProjection(e!=="mercator"&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var h;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((h=this._map.getProjection())===null||h===void 0?void 0:h.type)==="globe"?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=se.create("button","maplibregl-ctrl-globe",this._container),se.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){se.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},C.Hash=Fa,C.ImageSource=yr,C.KeyboardHandler=ja,C.LngLatBounds=Dt,C.LogoControl=gc,C.Map=class extends mc{constructor(h){var e,n;c.cw.mark(c.cx.create);const a=Object.assign(Object.assign(Object.assign({},Wi),h),{canvasContextAttributes:Object.assign(Object.assign({},Wi.canvasContextAttributes),h.canvasContextAttributes)});if(a.minZoom!=null&&a.maxZoom!=null&&a.minZoom>a.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(a.minPitch!=null&&a.maxPitch!=null&&a.minPitch>a.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(a.minPitch!=null&&a.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(a.maxPitch!=null&&a.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const l=new bt,u=new _i;if(a.minZoom!==void 0&&l.setMinZoom(a.minZoom),a.maxZoom!==void 0&&l.setMaxZoom(a.maxZoom),a.minPitch!==void 0&&l.setMinPitch(a.minPitch),a.maxPitch!==void 0&&l.setMaxPitch(a.maxPitch),a.renderWorldCopies!==void 0&&l.setRenderWorldCopies(a.renderWorldCopies),super(l,u,{bearingSnap:a.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Pr,this._controls=[],this._mapId=c.a7(),this._contextLost=_=>{_.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new c.l("webglcontextlost",{originalEvent:_}))},this._contextRestored=_=>{this._setupPainter(),this.resize(),this._update(),this.fire(new c.l("webglcontextrestored",{originalEvent:_}))},this._onMapScroll=_=>{if(_.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=a.interactive,this._maxTileCacheSize=a.maxTileCacheSize,this._maxTileCacheZoomLevels=a.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},a.canvasContextAttributes),this._trackResize=a.trackResize===!0,this._bearingSnap=a.bearingSnap,this._centerClampedToGround=a.centerClampedToGround,this._refreshExpiredTiles=a.refreshExpiredTiles===!0,this._fadeDuration=a.fadeDuration,this._crossSourceCollisions=a.crossSourceCollisions===!0,this._collectResourceTiming=a.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Pi),a.locale),this._clickTolerance=a.clickTolerance,this._overridePixelRatio=a.pixelRatio,this._maxCanvasSize=a.maxCanvasSize,this.transformCameraUpdate=a.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=a.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Ot.addThrottleControl(()=>this.isMoving()),this._requestManager=new $i(a.transformRequest),typeof a.container=="string"){if(this._container=document.getElementById(a.container),!this._container)throw new Error(`Container '${a.container}' not found.`)}else{if(!(a.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=a.container}if(a.maxBounds&&this.setMaxBounds(a.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let _=!1;const y=kn(b=>{this._trackResize&&!this._removed&&(this.resize(b),this.redraw())},50);this._resizeObserver=new ResizeObserver(b=>{_?y(b):_=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Jo(this,a),this._hash=a.hash&&new Fa(typeof a.hash=="string"&&a.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,roll:a.roll}),a.bounds&&(this.resize(),this.fitBounds(a.bounds,c.e({},a.fitBoundsOptions,{duration:0}))));const f=typeof a.style=="string"||((n=(e=a.style)===null||e===void 0?void 0:e.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,f),this._localIdeographFontFamily=a.localIdeographFontFamily,this._validateStyle=a.validateStyle,a.style&&this.setStyle(a.style,{localIdeographFontFamily:a.localIdeographFontFamily}),a.attributionControl&&this.addControl(new el(typeof a.attributionControl=="boolean"?void 0:a.attributionControl)),a.maplibreLogo&&this.addControl(new gc,a.logoPosition),this.on("style.load",()=>{if(f||this._resizeTransform(),this.transform.unmodified){const _=c.Q(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(_)}}),this.on("data",_=>{this._update(_.dataType==="style"),this.fire(new c.l(`${_.dataType}data`,_))}),this.on("dataloading",_=>{this.fire(new c.l(`${_.dataType}dataloading`,_))}),this.on("dataabort",_=>{this.fire(new c.l("sourcedataabort",_))})}_getMapId(){return this._mapId}setGlobalStateProperty(h,e){return this.style.setGlobalStateProperty(h,e),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new c.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const a=this._controlPositions[e];return e.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new c.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}coveringTiles(h){return ne(this.transform,h)}calculateCameraOptionsFromTo(h,e,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,a)}resize(h,e=!0){const[n,a]=this._containerDimensions(),l=this._getClampedPixelRatio(n,a);if(this._resizeCanvas(n,a,l),this.painter.resize(n,a,l),this.painter.overLimit()){const f=this.painter.context.gl;this._maxCanvasSize=[f.drawingBufferWidth,f.drawingBufferHeight];const _=this._getClampedPixelRatio(n,a);this._resizeCanvas(n,a,_),this.painter.resize(n,a,_)}this._resizeTransform(e);const u=!this._moving;return u&&(this.stop(),this.fire(new c.l("movestart",h)).fire(new c.l("move",h))),this.fire(new c.l("resize",h)),u&&this.fire(new c.l("moveend",h)),this}_resizeTransform(h=!0){var e;const[n,a]=this._containerDimensions();this.transform.resize(n,a,h),(e=this._requestedCameraState)===null||e===void 0||e.resize(n,a,h)}_getClampedPixelRatio(h,e){const{0:n,1:a}=this._maxCanvasSize,l=this.getPixelRatio(),u=h*l,f=e*l;return Math.min(u>n?n/u:1,f>a?a/f:1)*l}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(Dt.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.setMinZoom(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.setMaxZoom(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.setMinPitch(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)>180)throw new Error("maxPitch must be less than or equal to 180");if(h>=this.transform.minPitch)return this.transform.setMaxPitch(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.setRenderWorldCopies(h),this._update()}project(h){return this.transform.locationToScreenPoint(c.S.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.screenPointToLocation(c.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:u=>{const f=e.filter(y=>this.getLayer(y)),_=f.length!==0?this.queryRenderedFeatures(u.point,{layers:f}):[];_.length?a||(a=!0,n.call(this,new ki(h,this,u.originalEvent,{features:_}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:f=>{const _=e.filter(y=>this.getLayer(y));(_.length!==0?this.queryRenderedFeatures(f.point,{layers:_}):[]).length?a=!0:a&&(a=!1,n.call(this,new ki(h,this,f.originalEvent)))},mouseout:f=>{a&&(a=!1,n.call(this,new ki(h,this,f.originalEvent)))}}}}{const a=l=>{const u=e.filter(_=>this.getLayer(_)),f=u.length!==0?this.queryRenderedFeatures(l.point,{layers:u}):[];f.length&&(l.features=f,n.call(this,l),delete l.features)};return{layers:e,listener:n,delegates:{[h]:a}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;const a=this._delegatedListeners[h];for(let l=0;l<a.length;l++){const u=a[l];if(u.listener===n&&u.layers.length===e.length&&u.layers.every(f=>e.includes(f))){for(const f in u.delegates)this.off(f,u.delegates[f]);return void a.splice(l,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);const a=typeof e=="string"?[e]:e,l=this._createDelegatedListener(h,a,n);this._saveDelegatedListener(h,l);for(const u in l.delegates)this.on(u,l.delegates[u]);return{unsubscribe:()=>{this._removeDelegatedListener(h,a,n)}}}once(h,e,n){if(n===void 0)return super.once(h,e);const a=typeof e=="string"?[e]:e,l=this._createDelegatedListener(h,a,n);for(const u in l.delegates){const f=l.delegates[u];l.delegates[u]=(..._)=>{this._removeDelegatedListener(h,a,n),f(..._)}}this._saveDelegatedListener(h,l);for(const u in l.delegates)this.once(u,l.delegates[u]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n;const a=h instanceof c.P||Array.isArray(h),l=a?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(a?{}:h)||{},l instanceof c.P||typeof l[0]=="number")n=[c.P.convert(l)];else{const u=c.P.convert(l[0]),f=c.P.convert(l[1]);n=[u,new c.P(f.x,u.y),f,new c.P(u.x,f.y),u]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=c.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){var n,a;if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));const l=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new bo(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,l):this.style.loadJSON(h,e,l),this):((a=(n=this.style)===null||n===void 0?void 0:n.projection)===null||a===void 0||a.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new bo(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,"Style");c.j(n,new AbortController).then(a=>{this._updateDiff(a.data,e)}).catch(a=>{a&&this.fire(new c.k(a))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){c.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():c.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){const e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new c.k(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===h.source&&c.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."),a.type==="color-relief"&&a.source===h.source&&c.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Ne(this.painter,e,h),this.painter.renderToTexture=new $a(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=n=>{var a;n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),((a=n.source)===null||a===void 0?void 0:a.type)==="image"?this.terrain.sourceCache.freeRtt():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.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new c.l("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const e in h){const n=h[e]._tiles;for(const a in n){const l=n[a];if(l.state!=="loaded"&&l.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}setSourceTileLodParams(h,e,n){if(n){const a=this.getSource(n);if(!a)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);a.calculateTileZoom=ve(Math.max(1,h),Math.max(1,e))}else for(const a in this.style.sourceCaches)this.style.sourceCaches[a].getSource().calculateTileZoom=ve(Math.max(1,h),Math.max(1,e));return this._update(!0),this}refreshTiles(h,e){const n=this.style.sourceCaches[h];if(!n)throw new Error(`There is no source cache with ID "${h}", cannot refresh tile`);e===void 0?n.reload(!0):n.refreshTiles(e.map(a=>new c.a4(a.z,a.x,a.y)))}addImage(h,e,n={}){const{pixelRatio:a=1,sdf:l=!1,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||c.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new c.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:w,height:S,data:P}=e,I=e;return this.style.addImage(h,{data:new c.R({width:w,height:S},new Uint8Array(P)),pixelRatio:a,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:b,sdf:l,version:0,userImage:I}),I.onAdd&&I.onAdd(this,h),this}}{const{width:w,height:S,data:P}=Ee.getImageData(e);this.style.addImage(h,{data:new c.R({width:w,height:S},P),pixelRatio:a,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:b,sdf:l,version:0})}}updateImage(h,e){const n=this.style.getImage(h);if(!n)return this.fire(new c.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=e instanceof HTMLImageElement||c.b(e)?Ee.getImageData(e):e,{width:l,height:u,data:f}=a;if(l===void 0||u===void 0)return this.fire(new c.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(l!==n.data.width||u!==n.data.height)return this.fire(new c.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(e instanceof HTMLImageElement||c.b(e));return n.data.replace(f,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new c.k(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return Ot.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,a={}){return this.style.setPaintProperty(h,e,n,a),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,a={}){return this.style.setLayoutProperty(h,e,n,a),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,n=>{n||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(h,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const e=this._canvasContainer=se.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=se.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const l=this._controlContainer=se.create("div","maplibregl-control-container",h),u=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(f=>{u[f]=se.create("div",`maplibregl-ctrl-${f} `,l)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const h=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{e={requestedAttributes:h},a&&(e.statusMessage=a.statusMessage,e.type=a.type)},{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,h):this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h),!n){const a="Failed to initialize WebGL";throw e?(e.message=a,new Error(JSON.stringify(e))):new Error(a)}this.painter=new tc(n,this.transform),Mt.testSupport(n)}migrateProjection(h,e){super.migrateProjection(h,e),this.painter.transform=h,this.fire(new c.l("projectiontransition",{newProjection:this.style.projection.name}))}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){var e,n,a,l,u;const f=this._idleTriggered?this._fadeDuration:0,_=((e=this.style.projection)===null||e===void 0?void 0:e.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let y=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const S=this.transform.zoom,P=Ee.now();this.style.zoomHistory.update(S,P);const I=new c.F(S,{now:P,fadeDuration:f,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),k=I.crossFadingFactor();k===1&&k===this._crossFadingFactor||(y=!0,this._crossFadingFactor=k),this.style.update(I)}const b=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==_;(a=this.style.projection)===null||a===void 0||a.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((l=this.style.projection)===null||l===void 0?void 0:l.transitionState,(u=this.style.projection)===null||u===void 0?void 0:u.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||b)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,f,this._crossSourceCollisions,b),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,showPadding:this.showPadding}),this.fire(new c.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,c.cw.mark(c.cx.load),this.fire(new c.l("load"))),this.style&&(this.style.hasTransitions()||y)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const w=this._sourcesDirty||this._styleDirty||this._placementDirty;return w||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new c.l("idle")),!this._loaded||this._fullyLoaded||w||(this._fullyLoaded=!0,c.cw.mark(c.cx.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Ot.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),se.remove(this._canvasContainer),se.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),c.cw.clearMetrics(),this._removed=!0,this.fire(new c.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Ee.frame(this._frameRequest,h=>{c.cw.frame(h),this._frameRequest=null;try{this._render(h)}catch(e){if(!c.cy(e)&&!function(n){return n.message===Ns}(e))throw e}},()=>{}))}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 _c}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(h){return this._lazyInitEmptyStyle(),this.style.setProjection(h),this._update(!0)}},C.MapMouseEvent=ki,C.MapTouchEvent=rs,C.MapWheelEvent=Go,C.Marker=us,C.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const e=this._map.getZoom(),n=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);e.title=a,e.setAttribute("aria-label",a)},this.options=c.e({},yh,h),this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=se.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ys(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){se.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){const n=se.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},C.Popup=class extends c.E{constructor(h){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&se.remove(this._content),this._container&&(se.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new c.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=se.create("div","maplibregl-popup",this._map.getContainer()),this._tip=se.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const f of this.options.className.split(" "))this._container.classList.add(f);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=Bt(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const n=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let a=this.options.anchor;const l=qa(this.options.offset);if(!a){const f=this._container.offsetWidth,_=this._container.offsetHeight;let y;y=n.y+l.bottom.y<_?["top"]:n.y>this._map.transform.height-_?["bottom"]:[],n.x<f/2?y.push("left"):n.x>this._map.transform.width-f/2&&y.push("right"),a=y.length===0?"bottom":y.join("-")}let u=n.add(l[a]);this.options.subpixelPositioning||(u=u.round()),se.setTransform(this._container,`${Za[a]} translate(${u.x}px,${u.y}px)`),hs(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=c.e(Object.create(il),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 c.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=c.S.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const e=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=h;a=n.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=se.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=se.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const h=this._container.querySelector(rl);h&&h.focus()}},C.RasterDEMTileSource=mn,C.RasterTileSource=gr,C.ScaleControl=class{constructor(h){this._onMove=()=>{Ga(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Ga(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ks),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){se.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},C.ScrollZoomHandler=hc,C.Style=bo,C.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=se.create("button","maplibregl-ctrl-terrain",this._container),se.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){se.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},C.TwoFingersTouchPitchHandler=Oa,C.TwoFingersTouchRotateHandler=ls,C.TwoFingersTouchZoomHandler=Ba,C.TwoFingersTouchZoomRotateHandler=pc,C.VectorTileSource=Ki,C.VideoSource=$n,C.addSourceType=(h,e)=>c._(void 0,void 0,void 0,function*(){if(Ur(h))throw new Error(`A source type called "${h}" already exists.`);((n,a)=>{Vr[n]=a})(h,e)}),C.clearPrewarmedResources=function(){const h=mr;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(dn),mr=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()"))},C.createTileMesh=xo,C.getMaxParallelImageRequests=function(){return c.a.MAX_PARALLEL_IMAGE_REQUESTS},C.getRTLTextPluginStatus=function(){return Gr().getRTLTextPluginStatus()},C.getVersion=function(){return nl},C.getWorkerCount=function(){return mi.workerCount},C.getWorkerUrl=function(){return c.a.WORKER_URL},C.importScriptInWorkers=function(h){return Nn().broadcast("IS",h)},C.prewarm=function(){fn().acquire(dn)},C.setMaxParallelImageRequests=function(h){c.a.MAX_PARALLEL_IMAGE_REQUESTS=h},C.setRTLTextPlugin=function(h,e){return Gr().setRTLTextPlugin(h,e)},C.setWorkerCount=function(h){mi.workerCount=h},C.setWorkerUrl=function(h){c.a.WORKER_URL=h}});var Ze=J;return Ze})}(Tl)),Tl.exports}var ln=sp(),Xi=63710088e-1,ap={centimeters:Xi*100,centimetres:Xi*100,degrees:360/(2*Math.PI),feet:Xi*3.28084,inches:Xi*39.37,kilometers:Xi/1e3,kilometres:Xi/1e3,meters:Xi,metres:Xi,miles:Xi/1609.344,millimeters:Xi*1e3,millimetres:Xi*1e3,nauticalmiles:Xi/1852,radians:1,yards:Xi*1.0936};function Bc(me,j,J={}){const de={type:"Feature"};return(J.id===0||J.id)&&(de.id=J.id),J.bbox&&(de.bbox=J.bbox),de.properties=j||{},de.geometry=me,de}function op(me,j,J={}){if(me.length<2)throw new Error("coordinates must be an array of two or more positions");return Bc({type:"LineString",coordinates:me},j,J)}function lp(me,j="kilometers"){const J=ap[j];if(!J)throw new Error(j+" units is invalid");return me*J}function Pl(me){return me%360*Math.PI/180}function Oc(me,j,J){if(me!==null)for(var de,Ve,Ze,C,c,be,ct,ut=0,pt=0,Ee,se=me.type,Mt=se==="FeatureCollection",ei=se==="Feature",Ri=Mt?me.features.length:1,Ci=0;Ci<Ri;Ci++){ct=Mt?me.features[Ci].geometry:ei?me.geometry:me,Ee=ct?ct.type==="GeometryCollection":!1,c=Ee?ct.geometries.length:1;for(var It=0;It<c;It++){var ft=0,Ot=0;if(C=Ee?ct.geometries[It]:ct,C!==null){be=C.coordinates;var $i=C.type;switch(ut=0,$i){case null:break;case"Point":if(j(be,pt,Ci,ft,Ot)===!1)return!1;pt++,ft++;break;case"LineString":case"MultiPoint":for(de=0;de<be.length;de++){if(j(be[de],pt,Ci,ft,Ot)===!1)return!1;pt++,$i==="MultiPoint"&&ft++}$i==="LineString"&&ft++;break;case"Polygon":case"MultiLineString":for(de=0;de<be.length;de++){for(Ve=0;Ve<be[de].length-ut;Ve++){if(j(be[de][Ve],pt,Ci,ft,Ot)===!1)return!1;pt++}$i==="MultiLineString"&&ft++,$i==="Polygon"&&Ot++}$i==="Polygon"&&ft++;break;case"MultiPolygon":for(de=0;de<be.length;de++){for(Ot=0,Ve=0;Ve<be[de].length;Ve++){for(Ze=0;Ze<be[de][Ve].length-ut;Ze++){if(j(be[de][Ve][Ze],pt,Ci,ft,Ot)===!1)return!1;pt++}Ot++}ft++}break;case"GeometryCollection":for(de=0;de<C.geometries.length;de++)if(Oc(C.geometries[de],j)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function cp(me,j){var J,de,Ve,Ze,C,c,be,ct,ut,pt,Ee=0,se=me.type==="FeatureCollection",Mt=me.type==="Feature",ei=se?me.features.length:1;for(J=0;J<ei;J++){for(c=se?me.features[J].geometry:Mt?me.geometry:me,ct=se?me.features[J].properties:Mt?me.properties:{},ut=se?me.features[J].bbox:Mt?me.bbox:void 0,pt=se?me.features[J].id:Mt?me.id:void 0,be=c?c.type==="GeometryCollection":!1,C=be?c.geometries.length:1,Ve=0;Ve<C;Ve++){if(Ze=be?c.geometries[Ve]:c,Ze===null){if(j(null,Ee,ct,ut,pt)===!1)return!1;continue}switch(Ze.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(j(Ze,Ee,ct,ut,pt)===!1)return!1;break}case"GeometryCollection":{for(de=0;de<Ze.geometries.length;de++)if(j(Ze.geometries[de],Ee,ct,ut,pt)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}Ee++}}function hp(me,j){cp(me,function(J,de,Ve,Ze,C){var c=J===null?null:J.type;switch(c){case null:case"Point":case"LineString":case"Polygon":return j(Bc(J,Ve,{bbox:Ze,id:C}),de,0)===!1?!1:void 0}var be;switch(c){case"MultiPoint":be="Point";break;case"MultiLineString":be="LineString";break;case"MultiPolygon":be="Polygon";break}for(var ct=0;ct<J.coordinates.length;ct++){var ut=J.coordinates[ct],pt={type:be,coordinates:ut};if(j(Bc(pt,Ve),de,ct)===!1)return!1}})}function up(me,j){hp(me,function(J,de,Ve){var Ze=0;if(J.geometry){var C=J.geometry.type;if(!(C==="Point"||C==="MultiPoint")){var c,be=0,ct=0,ut=0;if(Oc(J,function(pt,Ee,se,Mt,ei){if(c===void 0||de>be||Mt>ct||ei>ut){c=pt,be=de,ct=Mt,ut=ei,Ze=0;return}var Ri=op([c,pt],J.properties);if(j(Ri,de,Ve,ei,Ze)===!1)return!1;Ze++,c=pt})===!1)return!1}}})}function dp(me,j,J){var de=J,Ve=!1;return up(me,function(Ze,C,c,be,ct){Ve===!1&&J===void 0?de=Ze:de=j(de,Ze,C,c,be,ct),Ve=!0}),de}function pp(me,j={}){if(me.bbox!=null&&j.recompute!==!0)return me.bbox;const J=[1/0,1/0,-1/0,-1/0];return Oc(me,de=>{J[0]>de[0]&&(J[0]=de[0]),J[1]>de[1]&&(J[1]=de[1]),J[2]<de[0]&&(J[2]=de[0]),J[3]<de[1]&&(J[3]=de[1])}),J}var lu=pp;class fp{constructor(j={}){this.type=j.type||"Feature",this.id=j.id||null,this.properties=j.properties||{},this.geometry=j.geometry||{},this.geometry.type=this.geometry.type||null,this.geometry.coordinates=this.geometry.coordinates||[]}get bbox(){return!this.geometry||!this.geometry.type||!this.geometry.coordinates.length?null:lu({type:"Feature",geometry:this.geometry})}toJSON(){return{type:this.type,id:this.id,bbox:this.bbox,properties:this.properties,geometry:this.geometry}}}class Fr extends fp{constructor(j={}){super(j),this.id=this.id||Fc(),this.featureType=sa(this)||null,this.properties.waymark=this.properties.waymark||{},this.active=!1,this.popup=this.createPopup(),this.popup&&(this.popup=this.popup),this.mapLibreMap=null,this.source=null,this.layer=null,this.style=null,this.highlightLayer=null}setActive(j=!0){this.active=j,this.active?this.showHighlight():this.hideHighlight()}addEvents(){this.mapLibreMap.on("mouseenter",this.id,()=>{this.mapLibreMap.getCanvas().style.cursor="pointer",!this.active&&this.showHighlight()}),this.mapLibreMap.on("mouseleave",this.id,()=>{this.mapLibreMap.getCanvas().style.cursor="",!this.active&&this.hideHighlight()})}addTo(j){if(!(!j||!j.addLayer)){if(this.mapLibreMap=j,this.source){this.source.setData(this.toJSON());return}this.mapLibreMap.addSource(this.id,{type:"geojson",data:this.toJSON()}),this.source=this.mapLibreMap.getSource(this.id),this.style=this.toStyle(),this.mapLibreMap.addLayer(this.style),this.layer=this.mapLibreMap.getLayer(this.id),this.highlightLayer=this.addHighlightLayer(),this.addEvents()}}hasMap(){return this.mapLibreMap!==null}remove(){this.mapLibreMap&&(this.highlightLayer&&this.mapLibreMap.removeLayer(`${this.id}-highlight`),this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.removeLayer(this.id),this.mapLibreMap.getSource(this.id)&&this.mapLibreMap.removeSource(this.id),this.mapLibreMap=null,this.source=null,this.layer=null,this.style=null)}getTitle(){var j;return((j=this.properties.waymark)==null?void 0:j.title)||null}getDescription(){var j;return((j=this.properties.waymark)==null?void 0:j.description)||null}containsText(j=""){let J=0;return J+=Object.values(this.properties).some(de=>de.toString().toLowerCase().includes(j.toLowerCase())),J>0}zoomIn(){if(!this.mapLibreMap)return;const j=16;this.mapLibreMap.getZoom()<j&&this.mapLibreMap.flyTo({center:[this.geometry.coordinates[0],this.geometry.coordinates[1]],zoom:j,...bs})}createPopup(){if(!this.getTitle()&&!this.getDescription())return null;const j=document.createElement("div");if(j.className="waymark-popup-content",this.getTitle()){const J=document.createElement("h3");J.textContent=this.getTitle(),j.appendChild(J)}if(this.getDescription()){const J=document.createElement("p");J.textContent=this.getDescription(),j.appendChild(J)}return new ln.Popup({}).setDOMContent(j)}openPopup(){if(!this.mapLibreMap||!this.popup)return;console.log("Opening popup for overlay:",this.id);const J=this.getBounds().getCenter();this.popup.setLngLat([J.lng,J.lat]).addTo(this.mapLibreMap)}show(){this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.setLayoutProperty(this.id,"visibility","visible")}hide(){this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.setLayoutProperty(this.id,"visibility","none")}addHighlightLayer(){const j=this.getHighlightStyle(),J={id:`${this.id}-highlight`,type:j.type,source:this.id,layout:j.layout||{},paint:j.paint||{}};return this.customizeHighlight(J),this.mapLibreMap.addLayer(J,this.id),this.mapLibreMap.setLayoutProperty(J.id,"visibility","none"),J}isHighlighted(){return this.highlightLayer?this.mapLibreMap.getLayoutProperty(`${this.id}-highlight`,"visibility")==="visible":!1}showHighlight(){this.highlightLayer&&this.mapLibreMap.setLayoutProperty(`${this.id}-highlight`,"visibility","visible")}hideHighlight(){this.highlightLayer&&this.mapLibreMap.setLayoutProperty(`${this.id}-highlight`,"visibility","none")}getHighlightStyle(){return this.toStyle()}toggleHighlight(){this.isHighlighted()?this.hideHighlight():this.showHighlight()}}const jc="#b42714";function cu(){const me="0123456789ABCDEF";let j="#";for(let J=0;J<6;J++)j+=me[Math.floor(Math.random()*16)];return j}class Nc extends Fr{constructor(j={}){const J={...j,geometry:{...j.geometry||{},type:"Point"}};super(J)}get bbox(){return null}addTo(j){var de;super.addTo(j);const J=(de=this.properties.waymark)==null?void 0:de.icon;J&&this.addIcon(J)}remove(){this.htmlMarker&&(this.htmlMarker.remove(),this.htmlMarker=null),this.mapLibreMap&&(this.mapLibreMap.getLayer(`${this.id}-icon`)&&this.mapLibreMap.removeLayer(`${this.id}-icon`),this.mapLibreMap.hasImage(`${this.id}-icon-img`)&&this.mapLibreMap.removeImage(`${this.id}-icon-img`)),super.remove()}addIcon(j){if(!this.mapLibreMap)return;if(j.html){if(this.mapLibreMap.getLayer(`${this.id}-icon`)&&this.mapLibreMap.removeLayer(`${this.id}-icon`),this.htmlMarker){const Ze=this.htmlMarker.getElement();Ze.innerHTML!==j.html&&(Ze.innerHTML=j.html),this.htmlMarker.setLngLat(this.geometry.coordinates)}else{const Ze=document.createElement("div");Ze.innerHTML=j.html,Ze.addEventListener("mouseenter",()=>{this.mapLibreMap.getCanvas().style.cursor="pointer",!this.active&&this.showHighlight()}),Ze.addEventListener("mouseleave",()=>{this.mapLibreMap.getCanvas().style.cursor="",!this.active&&this.hideHighlight()}),this.htmlMarker=new ln.Marker({element:Ze,anchor:"center"}).setLngLat(this.geometry.coordinates).addTo(this.mapLibreMap)}return}else this.htmlMarker&&(this.htmlMarker.remove(),this.htmlMarker=null);const J=`${this.id}-icon-img`,de=`${this.id}-icon`,Ve=()=>{this.mapLibreMap&&(this.mapLibreMap.getLayer(de)?(this.mapLibreMap.setLayoutProperty(de,"icon-image",J),this.mapLibreMap.setLayoutProperty(de,"icon-rotate",j.rotation||0)):this.mapLibreMap.addLayer({id:de,type:"symbol",source:this.id,layout:{"icon-image":J,"icon-size":1,"icon-allow-overlap":!0,"icon-rotate":j.rotation||0}}))};if(j.url)this.mapLibreMap.loadImage(j.url,(Ze,C)=>{if(Ze){console.error("Error loading icon:",Ze);return}this.mapLibreMap&&(this.mapLibreMap.hasImage(J)||this.mapLibreMap.addImage(J,C),Ve())});else if(j.svg){const Ze=new Image(j.width||32,j.height||32);Ze.onload=()=>{this.mapLibreMap&&(this.mapLibreMap.hasImage(J)||this.mapLibreMap.addImage(J,Ze),Ve())},Ze.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(j.svg)}}toStyle(){var J;const j=((J=this.properties.waymark)==null?void 0:J.paint)||{};return{id:this.id,type:"circle",source:this.id,paint:{"circle-radius":3,"circle-color":"#ffffff","circle-stroke-color":cu(),"circle-stroke-width":3,...j}}}hasElevationData(){return this.geometry.coordinates.length===3}getElevationString(){return this.hasElevationData()?"Elevation: "+Math.round(this.geometry.coordinates[2]*10)/10+"m":""}getBounds(){return new ln.LngLatBounds([this.geometry.coordinates[0],this.geometry.coordinates[1]],[this.geometry.coordinates[0],this.geometry.coordinates[1]])}getCoordsString(){return"Lat,Lng: "+this.geometry.coordinates[1].toFixed(6)+", "+this.geometry.coordinates[0].toFixed(6)}flyTo(){this.mapLibreMap.flyTo({center:[this.geometry.coordinates[0],this.geometry.coordinates[1]],...bs})}inBounds(j){return j.contains({lng:this.geometry.coordinates[0],lat:this.geometry.coordinates[1]})}customizeHighlight(j){j.paint["circle-stroke-color"]=jc,j.paint["circle-stroke-width"]+=2}}function hu(me){if(!me)throw new Error("coord is required");if(!Array.isArray(me)){if(me.type==="Feature"&&me.geometry!==null&&me.geometry.type==="Point")return[...me.geometry.coordinates];if(me.type==="Point")return[...me.coordinates]}if(Array.isArray(me)&&me.length>=2&&!Array.isArray(me[0])&&!Array.isArray(me[1]))return[...me];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function mp(me,j,J={}){var de=hu(me),Ve=hu(j),Ze=Pl(Ve[1]-de[1]),C=Pl(Ve[0]-de[0]),c=Pl(de[1]),be=Pl(Ve[1]),ct=Math.pow(Math.sin(Ze/2),2)+Math.pow(Math.sin(C/2),2)*Math.cos(c)*Math.cos(be);return lp(2*Math.atan2(Math.sqrt(ct),Math.sqrt(1-ct)),J.units)}function gp(me,j={}){return dp(me,(J,de)=>{const Ve=de.geometry.coordinates;return J+mp(Ve[0],Ve[1],j)},0)}class Vc extends Fr{constructor(j={}){var de;const J={...j,geometry:{...j.geometry||{},type:((de=j.geometry)==null?void 0:de.type)||"LineString"}};super(J)}toStyle(){var J;const j=((J=this.properties.waymark)==null?void 0:J.paint)||{};return{id:this.id,type:"line",source:this.id,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":cu(),"line-width":3,...j}}}addCoordinate(j=[]){!Array.isArray(j)||j.length<2||this.geometry.coordinates.push(j)}getLengthString(){let j="";j+="Length: ";const J=gp(this,{units:"kilometers"});return j+=Math.round(J*100)/100,j+="km",j}hasElevationData(){return this.getLinePositions().some(j=>j.length===3)}getElevationString(){if(!this.hasElevationData())return"";const j=this.getLinePositions();if(j.length===0)return"";let J=0,de=0,Ve=j[0][2],Ze=j[0][2];for(let C=1;C<j.length;C++){const c=j[C][2]-j[C-1][2];c>0?J+=c:de-=c,Ve=Math.max(Ve,j[C][2]),Ze=Math.min(Ze,j[C][2])}return"Elevation Gain: "+Math.round(J*10)/10+"m, Loss: "+Math.round(de*10)/10+"m, Max: "+Math.round(Ve*10)/10+"m, Min: "+Math.round(Ze*10)/10+"m"}getBounds(){const j=this.getLinePositions();return j.length?j.reduce((J,de)=>J.extend({lng:de[0],lat:de[1]}),new ln.LngLatBounds({lng:j[0][0],lat:j[0][1]},{lng:j[0][0],lat:j[0][1]})):new ln.LngLatBounds([0,0],[0,0])}getCoordsString(){const J=this.getBounds().getCenter();return"Centre Lat,Lng: "+J.lat.toFixed(6)+", "+J.lng.toFixed(6)}flyTo(){const j=this.getBounds();this.mapLibreMap.fitBounds(j,bs)}inBounds(j){return this.getLinePositions().some(de=>j.contains({lng:de[0],lat:de[1]}))}zoomIn(){if(this.mapLibreMap.getZoom()<16){const de=this.getLinePositions(),Ve=de.length?de[0]:[0,0];this.mapLibreMap.flyTo({center:[Ve[0],Ve[1]],zoom:16,...bs})}}getLinePositions(){const j=this.geometry;return j.type==="MultiLineString"?j.coordinates.reduce((J,de)=>J.concat(de),[]):j.coordinates||[]}customizeHighlight(j){j.paint["line-color"]=jc,j.paint["line-width"]+=2}}class Uc extends Fr{constructor(j={}){var de;const J={...j,geometry:{...j.geometry||{},type:((de=j.geometry)==null?void 0:de.type)||"Polygon"}};super(J),this.strokeLayer=null}addTo(j){super.addTo(j),this.strokeLayer||(this.mapLibreMap.addLayer(this.strokeStyle()),this.strokeLayer=this.mapLibreMap.getLayer(`${this.id}-stroke`))}remove(){this.mapLibreMap&&this.strokeLayer&&this.mapLibreMap.removeLayer(`${this.id}-stroke`),super.remove()}toStyle(){var J;const j=((J=this.properties.waymark)==null?void 0:J.paint)||{};return{id:this.id,type:"fill",source:this.id,layout:{},paint:{"fill-color":"#000000","fill-opacity":.2,"fill-outline-color":"#000000",...j}}}show(){this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.setLayoutProperty(this.id,"visibility","visible"),this.strokeLayer&&this.mapLibreMap.setLayoutProperty(`${this.id}-stroke`,"visibility","visible")}hide(){this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.setLayoutProperty(this.id,"visibility","none"),this.strokeLayer&&this.mapLibreMap.setLayoutProperty(`${this.id}-stroke`,"visibility","none")}strokeStyle(){var j;return{id:`${this.id}-stroke`,type:"line",source:this.id,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":((j=this.properties.waymark)==null?void 0:j.shape_colour)||"#000000","line-width":1,"line-opacity":1}}}hasElevationData(){return this.getPolygonPositions().some(j=>j.length===3)}getElevationString(){return this.hasElevationData()?"Elevation data available":""}getBounds(){const j=this.getPolygonPositions();return j.length?j.reduce((J,de)=>J.extend({lng:de[0],lat:de[1]}),new ln.LngLatBounds({lng:j[0][0],lat:j[0][1]},{lng:j[0][0],lat:j[0][1]})):new ln.LngLatBounds([0,0],[0,0])}getCoordsString(){const J=this.getBounds().getCenter();return"Centre Lat,Lng: "+J.lat.toFixed(6)+", "+J.lng.toFixed(6)}zoomIn(){const J=this.getBounds().getCenter();this.mapLibreMap.flyTo({center:[J.lng,J.lat],zoom:Math.max(this.mapLibreMap.getZoom(),16),...bs})}getPolygonPositions(){const j=this.geometry;return j.type==="MultiPolygon"?j.coordinates.reduce((J,de)=>(de.forEach(Ve=>J.push(...Ve)),J),[]):j.coordinates?j.coordinates.reduce((J,de)=>J.concat(de),[]):[]}flyTo(){const j=this.getBounds();this.mapLibreMap.fitBounds(j,bs)}inBounds(j){const J=this.getBounds();return!(J.getNorth()<j.getSouth()||J.getSouth()>j.getNorth()||J.getEast()<j.getWest()||J.getWest()>j.getEast())}getHighlightStyle(){return this.strokeStyle()}customizeHighlight(j){j.paint["line-color"]=jc,j.paint["line-width"]+=2}}class _p{constructor(j={}){this.type="FeatureCollection",this.id=j.id||null,this.properties=j.properties||{},this.features=Array.isArray(j.features)?j.features:[]}get bbox(){return this.features.length>0?lu({type:"FeatureCollection",features:this.features}):null}toJSON(){return{type:this.type,id:this.id,bbox:this.bbox,properties:this.properties,features:this.features}}}class ws extends _p{constructor(j={}){return super(j),this.id=this.id||Fc(),this.overlays=new Map,this.features.forEach(J=>{const de=$c(J);this.overlays.set(de.id,de)}),this.mapLibreMap=null,this}get overlaysArray(){return Array.from(this.overlays.values())}toJSON(){const j=super.toJSON();return j.features=this.overlaysArray.map(J=>J.toJSON()),j}hasOverlay(j){return this.overlays.has(j)}getOverlay(j){return this.overlays.get(j)||null}addOverlay(j){if(!(j instanceof Fr))throw new Error("WaymarkOverlay instance required");this.overlays.has(j.id)||(this.features.push(j.toJSON()),this.overlays.set(j.id,j))}removeOverlay(j){if(!this.overlays.has(j))throw new Error("Overlay not found in this map");this.overlays.delete(j)}getBounds(){if(!this.bbox||!isFinite(this.bbox[0])||!isFinite(this.bbox[1])||!isFinite(this.bbox[2])||!isFinite(this.bbox[3]))return null;const j=new ln.LngLatBounds([this.bbox[0],this.bbox[1]],[this.bbox[2],this.bbox[3]]);return j.isEmpty()?null:j}addTo(j){j&&(this.mapLibreMap=j,this.overlaysArray.length&&(this.overlaysArray.filter(J=>J.featureType==="shape").forEach(J=>{J.addTo(this.mapLibreMap)}),this.overlaysArray.filter(J=>J.featureType==="line").forEach(J=>{J.addTo(this.mapLibreMap)}),this.overlaysArray.filter(J=>J.featureType==="marker").forEach(J=>{J.addTo(this.mapLibreMap)}),this.getBounds()))}hasMap(){return this.mapLibreMap!==null}remove(){this.overlaysArray.forEach(j=>{j.remove()}),this.mapLibreMap=null}}function yp(me){const j=new Map,J=new Map,de=new Map;return{maps:J,mapsArray:()=>Array.from(J.values()),overlays:de,overlaysArray:()=>Array.from(de.values()),overlaysByType:()=>{const Ee=Array.from(de.values());return{markers:Ee.filter(se=>se.featureType==="marker"),lines:Ee.filter(se=>se.featureType==="line"),shapes:Ee.filter(se=>se.featureType==="shape")}},hasItem:Ee=>j.has(Ee),getItem:Ee=>j.get(Ee)||null,addItem:(Ee={})=>{if(!Ee||!Ee.type)throw new Error("Valid GeoJSON required");if(Ee.id&&j.has(Ee.id))throw new Error("GeoJSON with this ID already exists");let se=null;if(Ee instanceof ws)se=Ee,J.set(se.id,se),se.overlays.forEach(Mt=>{j.set(Mt.id,Mt)});else if(Ee instanceof Fr)se=Ee,de.set(se.id,se);else switch(Ee.type){case"FeatureCollection":se=pu(Ee),J.set(se.id,se),se.overlays.forEach(Mt=>{j.set(Mt.id,Mt)});break;case"Feature":se=$c(Ee),de.set(se.id,se);break;default:throw new Error("Valid GeoJSON Feature or FeatureCollection required")}return j.set(se.id,se),me.dispatchEvent("geojson-item-added",{item:se}),se},updateItem:(Ee={})=>{if(!Ee.id)throw new Error("Item must have an ID");if(!j.has(Ee.id))throw new Error("Item with this ID does not exist");return j.set(Ee.id,Ee),me.dispatchEvent("geojson-item-updated",{item:Ee}),Ee},removeItem:(Ee={})=>{if(!Ee.id)throw new Error("Item must have an ID");if(!j.has(Ee.id))throw new Error("Item with this ID does not exist");switch(j.delete(Ee.id),!0){case Ee instanceof ws:J.delete(Ee.id);break;case Ee instanceof Fr:de.delete(Ee.id);break;default:throw new Error("WaymarkMap or WaymarkOverlay instance required")}return me.dispatchEvent("geojson-item-removed",{item:Ee}),Ee}}}function xp(me){const j={mapLibreMap:me.mapLibreMap,view:{bearing:null,pitch:null,bounds:null,zoom:null,center:null}};function J(){const{overlays:de,maps:Ve}=me.geoJSONStore;j.mapLibreMap.on("load",()=>{j.view.bounds=j.mapLibreMap.getBounds(),j.view.bearing=j.mapLibreMap.getBearing(),j.view.pitch=j.mapLibreMap.getPitch(),j.view.zoom=j.mapLibreMap.getZoom(),j.view.center=j.mapLibreMap.getCenter(),me.dispatchEvent("maplibre-map-ready")}),j.mapLibreMap.on("rotateend",()=>{j.view.bearing=j.mapLibreMap.getBearing(),me.dispatchEvent("maplibre-map-view-change")}),j.mapLibreMap.on("pitchend",()=>{j.view.pitch=j.mapLibreMap.getPitch(),me.dispatchEvent("maplibre-map-view-change")}),j.mapLibreMap.on("moveend",()=>{j.view.bounds=j.mapLibreMap.getBounds(),j.view.center=j.mapLibreMap.getCenter(),j.view.zoom=j.mapLibreMap.getZoom(),me.dispatchEvent("maplibre-map-view-change")}),j.mapLibreMap.on("click",Ze=>{const C=[[Ze.point.x-10,Ze.point.y-10],[Ze.point.x+10,Ze.point.y+10]],c=j.mapLibreMap.queryRenderedFeatures(C);let be=null;for(const ct of c){const ut=ct.layer.id;if(de.has(ut)){be=de.get(ut);break}for(const pt of Ve.values())if(pt.hasOverlay(ut)){be=pt.getOverlay(ut);break}if(be)break}be?me.setActiveOverlay(be):me.setActiveOverlay()})}return J(),j}const Sl="waymark-event";class uu extends CustomEvent{constructor(j,J={},de={}){super(Sl,{detail:{eventName:j,...J,...de}})}}class du{constructor(j={}){const J={id:Fc(),mapOptions:{},geoJSON:null,onLoad:null,debug:!1};if(this.config={...J,...j},this.id=this.config.id,this.container=document.getElementById(this.id),this.container&&this.container.classList.contains("waymark-instance"))throw new Error(`Container with id ${this.id} already has a WaymarkInstance attached`);this.container||(this.container=document.createElement("div"),this.container.id=this.id,document.body.appendChild(this.container)),this.container.classList.add("waymark-instance"),this.addEventHandling(),this.geoJSONStore=yp(this),this.mapLibreMap=new ln.Map({container:this.container,...ip,...this.config.mapOptions||{}}),this.mapLibreStore=xp(this),this.activeOverlay=null}getAllMaps(){return this.geoJSONStore.mapsArray}getMapByID(j){return this.geoJSONStore.maps.get(j)}getAllOverlays(){return this.geoJSONStore.overlaysArray}getOverlayByID(j){return this.geoJSONStore.overlays.get(j)}dispatchEvent(j,J={}){const de=new uu(j,J,this);this.container&&this.container.dispatchEvent(de)}onEvent(j,J){this.container&&this.container.addEventListener(Sl,de=>{de.detail&&de.detail.eventName===j&&J(de)})}addEventHandling(){this.config.debug&&this.container.addEventListener(Sl,j=>{console.log(`[Waymark][${this.id}][Event]`,j.detail)}),this.onEvent("maplibre-map-ready",()=>{this.onEvent("geojson-item-added",j=>{var J;if(!((J=j.detail)!=null&&J.item))throw new Error("geojson-item-added event missing item detail");switch(!0){case j.detail.item instanceof ws:case j.detail.item instanceof Fr:j.detail.item.addTo(this.mapLibreStore.mapLibreMap);break;default:throw new Error("geojson-item-added event item must be WaymarkMap or WaymarkOverlay instance")}}),this.onEvent("geojson-item-removed",j=>{var J;if(!((J=j.detail)!=null&&J.item))throw new Error("geojson-item-removed event missing item detail");switch(!0){case j.detail.item instanceof ws:case j.detail.item instanceof Fr:j.detail.item.remove();break;default:throw new Error("geojson-item-removed event item must be WaymarkMap or WaymarkOverlay instance")}}),this.onEvent("geojson-item-updated",j=>{var J;if(!((J=j.detail)!=null&&J.item))throw new Error("geojson-item-updated event missing item detail");switch(!0){case j.detail.item instanceof ws:case j.detail.item instanceof Fr:j.detail.item.addTo(this.mapLibreStore.mapLibreMap);break;default:throw new Error("geojson-item-updated event item must be WaymarkMap or WaymarkOverlay instance")}}),this.config.geoJSON&&this.geoJSONStore.addItem(this.config.geoJSON),this.config.onLoad&&typeof this.config.onLoad=="function"&&this.config.onLoad(this)})}setActiveOverlay(j=null){if(!j){this.activeOverlay&&this.activeOverlay.setActive(!1),this.activeOverlay=null,this.dispatchEvent("state-active-overlay-unset");return}if(this.activeOverlay){if(this.activeOverlay===j){j.zoomIn();return}this.activeOverlay.setActive(!1),this.activeOverlay=null}this.activeOverlay=j,j.setActive(!0),j.flyTo(),j.openPopup(),this.dispatchEvent("state-active-overlay-set")}rotateMap(j="cw",J=90){const{mapLibreMap:de}=this.mapLibreStore;if(de.isRotating())return;const Ve=de.getBearing(),Ze=j==="cw"?Ve+J:Ve-J;de.rotateTo(Ze,rp)}pitchMap(j="down",J=15){const{mapLibreMap:de}=this.mapLibreStore,Ve=de.getPitch();let Ze=j==="down"?Ve+J:Ve-J;Ze=Math.max(0,Math.min(60,Ze)),de.easeTo({pitch:Ze,...aa},{easing:C=>C*(2-C)})}pointNorth(){const{mapLibreMap:j}=this.mapLibreStore;j&&j.easeTo({bearing:0,...aa})}set3D(j=!0){const{mapLibreMap:J}=this.mapLibreStore;j?J.easeTo({pitch:60,...aa},{easing:de=>de*(2-de)}):J.easeTo({pitch:0,...aa},{easing:de=>de*(2-de)})}toggle3D(){const{mapLibreMap:j,view:J}=this.mapLibreStore;J.pitch>0?j.easeTo({pitch:0,...aa},{easing:de=>de*(2-de)}):j.easeTo({pitch:60,...aa},{easing:de=>de*(2-de)})}resetView(){const{overlaysBounds:j}=this.geoJSONStore,{mapLibreMap:J}=this.mapLibreStore;this.pointNorth(),this.set3D(!1),J.fitBounds(j.value,bs)}}function vp(me={}){try{return new du(me)}catch(j){console.error("[Waymark]",j)}}function pu(me){return new ws(me)}function $c(me){if(me.type)switch(sa(me)){case"marker":return new Nc(me);case"line":return new Vc(me);case"shape":return new Uc(me);default:throw new Error("Unsupported feature type for overlay creation")}}function bp(me){return new Nc(me)}function wp(me){return new Vc(me)}function Tp(me){return new Uc(me)}ci.WaymarkEvent=uu,ci.WaymarkInstance=du,ci.WaymarkLine=Vc,ci.WaymarkMap=ws,ci.WaymarkMarker=Nc,ci.WaymarkOverlay=Fr,ci.WaymarkShape=Uc,ci.createInstance=vp,ci.createLine=wp,ci.createMap=pu,ci.createMarker=bp,ci.createOverlay=$c,ci.createShape=Tp,ci.waymarkEventName=Sl,Object.defineProperty(ci,Symbol.toStringTag,{value:"Module"})});
743
+ ${I.shaderPreludeCode.vertexSource}`,define:I.shaderDefine},defaultProjectionData:O},N=P.renderingMode?P.renderingMode:"2d";if(f.renderPass==="offscreen"){const U=P.prerender;U&&(f.setCustomLayerDefaults(),S.setColorMode(f.colorModeForRenderPass()),U.call(P,S.gl,B),S.setDirty(),f.setBaseState())}else if(f.renderPass==="translucent"){f.setCustomLayerDefaults(),S.setColorMode(f.colorModeForRenderPass()),S.setStencilMode(lt.disabled);const U=N==="3d"?f.getDepthModeFor3D():f.getDepthModeForSublayer(0,We.ReadOnly);S.setDepthMode(U),P.render(S.gl,B),S.setDirty(),f.setBaseState(),S.bindFramebuffer.set(null)}}(e,0,a,u))}saveTileTexture(e){const n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const n=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!n||!a}useProgram(e,n,a=!1,l=[]){this.cache=this.cache||{};const u=!!this.style.map.terrain,f=this.style.projection,_=a?Ji.projectionMercator:f.shaderPreludeCode,y=a?Mr:f.shaderDefine,b=e+(n?n.cacheKey:"")+`/${a?xn:f.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(u?"/terrain":"")+(l?`/${l.join("/")}`:"");return this.cache[b]||(this.cache[b]=new To(this.context,Ji[e],n,Eo[e],this._showOverdrawInspector,u,_,y,l)),this.cache[b]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new c.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}function kn(h,e){let n,a=!1,l=null,u=null;const f=()=>{l=null,a&&(h.apply(u,n),l=setTimeout(f,e),a=!1)};return(..._)=>(a=!0,u=this,n=_,l||f(),l)}class Fa{constructor(e){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(l=>l.split("=")).forEach(l=>{l[0]===this._hashName&&(a=l)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const a=n.join("/");let l=a;l.split("&").length>0&&(l=l.split("&")[0]),this._hashName&&(l=`${this._hashName}=${a}`);let u=window.location.hash.replace(l,"");u.startsWith("#&")?u=u.slice(0,1)+u.slice(2):u==="#"&&(u="");let f=window.location.href.replace(/(#.+)?$/,u);f=f.replace("&&","&"),window.history.replaceState(window.history.state,null,f)},this._updateHash=kn(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,l=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),u=Math.pow(10,l),f=Math.round(n.lng*u)/u,_=Math.round(n.lat*u)/u,y=this._map.getBearing(),b=this._map.getPitch();let w="";if(w+=e?`/${f}/${_}/${a}`:`${a}/${_}/${f}`,(y||b)&&(w+="/"+Math.round(10*y)/10),b&&(w+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let P=!1;const I=window.location.hash.slice(1).split("&").map(k=>{const O=k.split("=")[0];return O===S?(P=!0,`${O}=${w}`):k}).filter(k=>k);return P||I.push(`${S}=${w}`),`#${I.join("&")}`}return`#${w}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new c.S(+e[2],+e[1])}catch{return!1}const n=+e[0],a=+(e[3]||0),l=+(e[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&a>=-180&&a<=180&&l>=this._map.getMinPitch()&&l<=this._map.getMaxPitch()}}const Er={linearity:.3,easing:c.cm(0,0,.3,1)},Zo=c.e({deceleration:2500,maxSpeed:1400},Er),rc=c.e({deceleration:20,maxSpeed:1400},Er),nc=c.e({deceleration:1e3,maxSpeed:360},Er),sc=c.e({deceleration:1e3,maxSpeed:90},Er),ac=c.e({deceleration:1e3,maxSpeed:360},Er);class oc{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Ee.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=Ee.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,roll:0,pan:new c.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:u}of this._inertiaBuffer)n.zoom+=u.zoomDelta||0,n.bearing+=u.bearingDelta||0,n.pitch+=u.pitchDelta||0,n.roll+=u.rollDelta||0,u.panDelta&&n.pan._add(u.panDelta),u.around&&(n.around=u.around),u.pinchAround&&(n.pinchAround=u.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,l={};if(n.pan.mag()){const u=is(n.pan.mag(),a,c.e({},Zo,e||{})),f=n.pan.mult(u.amount/n.pan.mag()),_=this._map.cameraHelper.handlePanInertia(f,this._map.transform);l.center=_.easingCenter,l.offset=_.easingOffset,tr(l,u)}if(n.zoom){const u=is(n.zoom,a,rc);l.zoom=this._map.transform.zoom+u.amount,tr(l,u)}if(n.bearing){const u=is(n.bearing,a,nc);l.bearing=this._map.transform.bearing+c.ah(u.amount,-179,179),tr(l,u)}if(n.pitch){const u=is(n.pitch,a,sc);l.pitch=this._map.transform.pitch+u.amount,tr(l,u)}if(n.roll){const u=is(n.roll,a,ac);l.roll=this._map.transform.roll+c.ah(u.amount,-179,179),tr(l,u)}if(l.zoom||l.bearing){const u=n.pinchAround===void 0?n.around:n.pinchAround;l.around=u?this._map.unproject(u):this._map.getCenter()}return this.clear(),c.e(l,{noMoveStart:!0})}}function tr(h,e){(!h.duration||h.duration<e.duration)&&(h.duration=e.duration,h.easing=e.easing)}function is(h,e,n){const{maxSpeed:a,linearity:l,deceleration:u}=n,f=c.ah(h*l/(e/1e3),-a,a),_=Math.abs(f)/(u*l);return{easing:n.easing,duration:1e3*_,amount:f*(_/2)}}class ki extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a,l={}){a=a instanceof MouseEvent?a:new MouseEvent(e,a);const u=se.mousePos(n.getCanvas(),a),f=n.unproject(u);super(e,c.e({point:u,lngLat:f,originalEvent:a},l)),this._defaultPrevented=!1,this.target=n}}class rs extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){const l=e==="touchend"?a.changedTouches:a.touches,u=se.touchPos(n.getCanvasContainer(),l),f=u.map(y=>n.unproject(y)),_=u.reduce((y,b,w,S)=>y.add(b.div(S.length)),new c.P(0,0));super(e,{points:u,point:_,lngLats:f,lngLat:n.unproject(_),originalEvent:a}),this._defaultPrevented=!1}}class Go extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class lc{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Go(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new ki(e.type,this._map,e))}mouseup(e){this._map.fire(new ki(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new ki(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ki(e.type,this._map,e))}mouseover(e){this._map.fire(new ki(e.type,this._map,e))}mouseout(e){this._map.fire(new ki(e.type,this._map,e))}touchstart(e){return this._firePreventable(new rs(e.type,this._map,e))}touchmove(e){this._map.fire(new rs(e.type,this._map,e))}touchend(e){this._map.fire(new rs(e.type,this._map,e))}touchcancel(e){this._map.fire(new rs(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cc{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ki(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ki("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ki(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ns{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(c.P.convert(e),this._map.terrain)}}class qo{constructor(e,n){this._map=e,this._tr=new ns(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(se.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)<this._clickTolerance)return;const l=this._startPos;this._lastPos=a,this._box||(this._box=se.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const u=Math.min(l.x,a.x),f=Math.max(l.x,a.x),_=Math.min(l.y,a.y),y=Math.max(l.y,a.y);se.setTransform(this._box,`translate(${u}px,${_}px)`),this._box.style.width=f-u+"px",this._box.style.height=y-_+"px"}mouseupWindow(e,n){if(!this._active||e.button!==0)return;const a=this._startPos,l=n;if(this.reset(),se.suppressClick(),a.x!==l.x||a.y!==l.y)return this._map.fire(new c.l("boxzoomend",{originalEvent:e})),{cameraAnimation:u=>u.fitScreenCoordinates(a,l,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(se.remove(this._box),this._box=null),se.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new c.l(e,{originalEvent:n}))}}function ss(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);const n={};for(let a=0;a<h.length;a++)n[h[a].identifier]=e[a];return n}class hc{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,a){(this.centroid||a.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),a.length===this.numTouches&&(this.centroid=function(l){const u=new c.P(0,0);for(const f of l)u._add(f);return u.div(l.length)}(n),this.touches=ss(a,n)))}touchmove(e,n,a){if(this.aborted||!this.centroid)return;const l=ss(a,n);for(const u in this.touches){const f=l[u];(!f||f.dist(this.touches[u])>30)&&(this.aborted=!0)}}touchend(e,n,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const l=!this.aborted&&this.centroid;if(this.reset(),l)return l}}}class zi{constructor(e){this.singleTap=new hc(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,a){this.singleTap.touchstart(e,n,a)}touchmove(e,n,a){this.singleTap.touchmove(e,n,a)}touchend(e,n,a){const l=this.singleTap.touchend(e,n,a);if(l){const u=e.timeStamp-this.lastTime<500,f=!this.lastTap||this.lastTap.dist(l)<30;if(u&&f||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class ir{constructor(e){this._tr=new ns(e),this._zoomIn=new zi({numTouches:1,numTaps:2}),this._zoomOut=new zi({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,a){this._zoomIn.touchstart(e,n,a),this._zoomOut.touchstart(e,n,a)}touchmove(e,n,a){this._zoomIn.touchmove(e,n,a),this._zoomOut.touchmove(e,n,a)}touchend(e,n,a){const l=this._zoomIn.touchend(e,n,a),u=this._zoomOut.touchend(e,n,a),f=this._tr;return l?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:f.zoom+1,around:f.unproject(l)},{originalEvent:e})}):u?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:f.zoom-1,around:f.unproject(u)},{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 as{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.rollDelta||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=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const l=Array.isArray(n)?n[0]:n;return!this._moved&&l.dist(a)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=l,this._move(a,l))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&se.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}}const rr=0,os=2,ph={[rr]:1,[os]:2};class Ws{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){const n=se.mouseButton(e);this._eventButton=n}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(n,a){const l=ph[a];return n.buttons===void 0||(n.buttons&l)!==l}(e,this._eventButton)}isValidEndEvent(e){return se.mouseButton(e)===this._eventButton}}class fh{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)}}class mh{constructor(e=new Ws({checkCorrectEvent:()=>!0}),n=new fh){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(e,n,a){return e instanceof MouseEvent?n(e):typeof TouchEvent<"u"&&e instanceof TouchEvent?a(e):void 0}startMove(e){this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.startMove(n),n=>this.oneFingerTouchMoveStateManager.startMove(n))}endMove(e){this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.endMove(n),n=>this.oneFingerTouchMoveStateManager.endMove(n))}isValidStartEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidStartEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidStartEvent(n))}isValidMoveEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidMoveEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(n))}isValidEndEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidEndEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidEndEvent(n))}}const Hs=h=>{h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}};class Xs{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new c.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,a){return this._calculateTransform(e,n,a)}touchmove(e,n,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,n,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,a){this._calculateTransform(e,n,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,a){a.length>0&&(this._active=!0);const l=ss(a,n),u=new c.P(0,0),f=new c.P(0,0);let _=0;for(const b in l){const w=l[b],S=this._touches[b];S&&(u._add(w),f._add(w.sub(S)),_++,l[b]=w)}if(this._touches=l,this._shouldBePrevented(_)||!f.mag())return;const y=f.div(_);return this._sum._add(y),this._sum.mag()<this._clickTolerance?void 0:{around:u.div(_),panDelta:y}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class nr{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,n,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier],this._start([n[0],n[1]]))}touchmove(e,n,a){if(!this._firstTwoTouches)return;e.preventDefault();const[l,u]=this._firstTwoTouches,f=ze(a,n,l),_=ze(a,n,u);if(!f||!_)return;const y=this._aroundCenter?null:f.add(_).div(2);return this._move([f,_],y,e)}touchend(e,n,a){if(!this._firstTwoTouches)return;const[l,u]=this._firstTwoTouches,f=ze(a,n,l),_=ze(a,n,u);f&&_||(this._active&&se.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 ze(h,e,n){for(let a=0;a<h.length;a++)if(h[a].identifier===n)return e[a]}function Wo(h,e){return Math.log(h/e)/Math.LN2}class Ba extends nr{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,n){const a=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Wo(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Wo(this._distance,a),pinchAround:n}}}function Ho(h,e){return 180*h.angleWith(e)/Math.PI}class ls extends nr{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,a){const l=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Ho(this._vector,l),pinchAround:n}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const n=25/(Math.PI*this._minDiameter)*360,a=Ho(e,this._startVector);return Math.abs(a)<n}}function zn(h){return Math.abs(h.y)>Math.abs(h.x)}class Oa extends nr{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,a){super.touchstart(e,n,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,zn(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const l=e[0].sub(this._lastPoints[0]),u=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,u,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(l.y+u.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,a){if(this._valid!==void 0)return this._valid;const l=e.mag()>=2,u=n.mag()>=2;if(!l&&!u)return;if(!l||!u)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const f=e.y>0==n.y>0;return zn(e)&&zn(n)&&f}}const st={panStep:100,bearingStep:15,pitchStep:10};class ja{constructor(e){this._tr=new ns(e);const n=st;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,a=0,l=0,u=0,f=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),u=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),u=1);break;case 38:e.shiftKey?l=1:(e.preventDefault(),f=-1);break;case 40:e.shiftKey?l=-1:(e.preventDefault(),f=1);break;default:return}return this._rotationDisabled&&(a=0,l=0),{cameraAnimation:_=>{const y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:gh,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+l*this._pitchStep,offset:[-u*this._panStep,-f*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 gh(h){return h*(2-h)}const Na=4.000244140625,_h=1/450;class uc{constructor(e,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=e,this._tr=new ns(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=_h}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=Ee.now(),l=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%Na==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(l*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=se.mousePos(this._map.getCanvas(),e),a=this._tr;this._aroundPoint=this._aroundCenter?a.transform.locationToScreenPoint(c.S.convert(a.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const _=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=_),typeof this._targetZoom=="number"&&(this._targetZoom+=_)}if(this._delta!==0){const _=this._type==="wheel"&&Math.abs(this._delta)>Na?this._wheelZoomRate:this._defaultZoomRate;let y=2/(1+Math.exp(-Math.abs(this._delta*_)));this._delta<0&&y!==0&&(y=1/y);const b=typeof this._targetZoom!="number"?e.scale:c.af(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),c.ak(b*y)).zoom,this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom!="number"?e.zoom:this._targetZoom,a=this._startZoom,l=this._easing;let u,f=!1;if(this._type==="wheel"&&a&&l){const _=Ee.now()-this._lastWheelEventTime,y=Math.min((_+5)/200,1),b=l(y);u=c.C.number(a,n,b),y<1?this._frameId||(this._frameId=!0):f=!0}else u=n,f=!0;return this._active=!0,f&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=u,{noInertia:!0,needsRenderFrame:!f,zoomDelta:u-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=c.co;if(this._prevEase){const a=this._prevEase,l=(Ee.now()-a.start)/a.duration,u=a.easing(l+.01)-a.easing(l),f=.27/Math.sqrt(u*u+1e-4)*.01,_=Math.sqrt(.0729-f*f);n=c.cm(f,_,.25,1)}return this._prevEase={start:Ee.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Xo{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 Yo{constructor(e){this._tr=new ns(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class dc{constructor(){this._tap=new zi({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,n,a){if(!this._swipePoint)if(this._tapTime){const l=n[0],u=e.timeStamp-this._tapTime<500,f=this._tapPoint.dist(l)<30;u&&f?a.length>0&&(this._swipePoint=l,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,n,a)}touchmove(e,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const l=n[0],u=l.y-this._swipePoint.y;return this._swipePoint=l,e.preventDefault(),this._active=!0,{zoomDelta:u/128}}}else this._tap.touchmove(e,n,a)}touchend(e,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const l=this._tap.touchend(e,n,a);l&&(this._tapTime=e.timeStamp,this._tapPoint=l)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class pc{constructor(e,n,a){this._el=e,this._mousePan=n,this._touchPan=a}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ko{constructor(e,n,a,l){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=n,this._mousePitch=a,this._mouseRoll=l}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class fc{constructor(e,n,a,l){this._el=e,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=l,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class mc{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=se.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),l=document.createElement("div");l.className="maplibregl-desktop-message",l.textContent=n,this._container.appendChild(l);const u=document.createElement("div");u.className="maplibregl-mobile-message",u.textContent=a,this._container.appendChild(u),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(se.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new c.l("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const sr=h=>h.zoom||h.drag||h.roll||h.pitch||h.rotate;class wt extends c.l{}function cs(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta||h.rollDelta}class Jo{constructor(e,n){this.handleWindowEvent=l=>{this.handleEvent(l,`${l.type}Window`)},this.handleEvent=(l,u)=>{if(l.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const f=l.type==="renderFrame"?void 0:l,_={needsRenderFrame:!1},y={},b={};for(const{handlerName:P,handler:I,allowed:k}of this._handlers){if(!I.isEnabled())continue;let O;if(this._blockedByActive(b,k,P))I.reset();else if(I[u||l.type]){if(c.cp(l,u||l.type)){const B=se.mousePos(this._map.getCanvas(),l);O=I[u||l.type](l,B)}else if(c.cq(l,u||l.type)){const B=this._getMapTouches(l.touches),N=se.touchPos(this._map.getCanvas(),B);O=I[u||l.type](l,N,B)}else c.cr(u||l.type)||(O=I[u||l.type](l));this.mergeHandlerResult(_,y,O,P,f),O&&O.needsRenderFrame&&this._triggerRenderFrame()}(O||I.isActive())&&(b[P]=I)}const w={};for(const P in this._previousActiveHandlers)b[P]||(w[P]=f);this._previousActiveHandlers=b,(Object.keys(w).length||cs(_))&&(this._changes.push([_,y,w]),this._triggerRenderFrame()),(Object.keys(b).length||cs(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:S}=_;S&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],S(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new oc(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[l,u,f]of this._listeners)se.addEventListener(l,u,l===document?this.handleWindowEvent:this.handleEvent,f)}destroy(){for(const[e,n,a]of this._listeners)se.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new lc(n,e));const l=n.boxZoom=new qo(n,e);this._add("boxZoom",l),e.interactive&&e.boxZoom&&l.enable();const u=n.cooperativeGestures=new mc(n,e.cooperativeGestures);this._add("cooperativeGestures",u),e.cooperativeGestures&&u.enable();const f=new ir(n),_=new Yo(n);n.doubleClickZoom=new Xo(_,f),this._add("tapZoom",f),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();const y=new dc;this._add("tapDragZoom",y);const b=n.touchPitch=new Oa(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);const w=()=>n.project(n.getCenter()),S=function({enable:$,clickTolerance:H,aroundCenter:K=!0,minPixelCenterThreshold:G=100,rotateDegreesPerPixelMoved:te=.8},ue){const ae=new Ws({checkCorrectEvent:oe=>se.mouseButton(oe)===0&&oe.ctrlKey||se.mouseButton(oe)===2&&!oe.ctrlKey});return new as({clickTolerance:H,move:(oe,he)=>{const we=ue();if(K&&Math.abs(we.y-oe.y)>G)return{bearingDelta:c.cn(new c.P(oe.x,he.y),he,we)};let Se=(he.x-oe.x)*te;return K&&he.y<we.y&&(Se=-Se),{bearingDelta:Se}},moveStateManager:ae,enable:$,assignEvents:Hs})}(e,w),P=function({enable:$,clickTolerance:H,pitchDegreesPerPixelMoved:K=-.5}){const G=new Ws({checkCorrectEvent:te=>se.mouseButton(te)===0&&te.ctrlKey||se.mouseButton(te)===2});return new as({clickTolerance:H,move:(te,ue)=>({pitchDelta:(ue.y-te.y)*K}),moveStateManager:G,enable:$,assignEvents:Hs})}(e),I=function({enable:$,clickTolerance:H,rollDegreesPerPixelMoved:K=.3},G){const te=new Ws({checkCorrectEvent:ue=>se.mouseButton(ue)===2&&ue.ctrlKey});return new as({clickTolerance:H,move:(ue,ae)=>{const oe=G();let he=(ae.x-ue.x)*K;return ae.y<oe.y&&(he=-he),{rollDelta:he}},moveStateManager:te,enable:$,assignEvents:Hs})}(e,w);n.dragRotate=new Ko(e,S,P,I),this._add("mouseRotate",S,["mousePitch"]),this._add("mousePitch",P,["mouseRotate","mouseRoll"]),this._add("mouseRoll",I,["mousePitch"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();const k=function({enable:$,clickTolerance:H}){const K=new Ws({checkCorrectEvent:G=>se.mouseButton(G)===0&&!G.ctrlKey});return new as({clickTolerance:H,move:(G,te)=>({around:te,panDelta:te.sub(G)}),activateOnStart:!0,moveStateManager:K,enable:$,assignEvents:Hs})}(e),O=new Xs(e,n);n.dragPan=new pc(a,k,O),this._add("mousePan",k),this._add("touchPan",O,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);const B=new ls,N=new Ba;n.touchZoomRotate=new fc(a,N,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);const U=n.scrollZoom=new uc(n,()=>this._triggerRenderFrame());this._add("scrollZoom",U,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);const q=n.keyboard=new ja(n);this._add("keyboard",q),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new cc(n))}_add(e,n,a){this._handlers.push({handlerName:e,handler:n,allowed:a}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!sr(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,a){for(const l in e)if(l!==a&&(!n||n.indexOf(l)<0))return!0;return!1}_getMapTouches(e){const n=[];for(const a of e)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(e,n,a,l,u){if(!a)return;c.e(e,a);const f={handlerName:l,originalEvent:a.originalEvent||u};a.zoomDelta!==void 0&&(n.zoom=f),a.panDelta!==void 0&&(n.drag=f),a.rollDelta!==void 0&&(n.roll=f),a.pitchDelta!==void 0&&(n.pitch=f),a.bearingDelta!==void 0&&(n.rotate=f)}_applyChanges(){const e={},n={},a={};for(const[l,u,f]of this._changes)l.panDelta&&(e.panDelta=(e.panDelta||new c.P(0,0))._add(l.panDelta)),l.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+l.zoomDelta),l.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+l.bearingDelta),l.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+l.pitchDelta),l.rollDelta&&(e.rollDelta=(e.rollDelta||0)+l.rollDelta),l.around!==void 0&&(e.around=l.around),l.pinchAround!==void 0&&(e.pinchAround=l.pinchAround),l.noInertia&&(e.noInertia=l.noInertia),c.e(n,u),c.e(a,f);this._updateMapTransform(e,n,a),this._changes=[]}_updateMapTransform(e,n,a){const l=this._map,u=l._getTransformForUpdate(),f=l.terrain;if(!(cs(e)||f&&this._terrainMovement))return this._fireEvents(n,a,!0);l._stop(!0);let{panDelta:_,zoomDelta:y,bearingDelta:b,pitchDelta:w,rollDelta:S,around:P,pinchAround:I}=e;I!==void 0&&(P=I),P=P||l.transform.centerPoint,f&&!u.isPointOnMapSurface(P)&&(P=u.centerPoint);const k={panDelta:_,zoomDelta:y,rollDelta:S,pitchDelta:w,bearingDelta:b,around:P};this._map.cameraHelper.useGlobeControls&&!u.isPointOnMapSurface(P)&&(P=u.centerPoint);const O=P.distSqr(u.centerPoint)<.01?u.center:u.screenPointToLocation(_?P.sub(_):P);f?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(k,u),this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?u.setCenter(u.screenPointToLocation(u.centerPoint.sub(_))):this._map.cameraHelper.handleMapControlsPan(k,u,O):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(k,u,O))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(k,u),this._map.cameraHelper.handleMapControlsPan(k,u,O)),l._applyUpdatedTransform(u),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,a,!0)}_fireEvents(e,n,a){const l=sr(this._eventsInProgress),u=sr(e),f={};for(const S in e){const{originalEvent:P}=e[S];this._eventsInProgress[S]||(f[`${S}start`]=P),this._eventsInProgress[S]=e[S]}!l&&u&&this._fireEvent("movestart",u.originalEvent);for(const S in f)this._fireEvent(S,f[S]);u&&this._fireEvent("move",u.originalEvent);for(const S in e){const{originalEvent:P}=e[S];this._fireEvent(S,P)}const _={};let y;for(const S in this._eventsInProgress){const{handlerName:P,originalEvent:I}=this._eventsInProgress[S];this._handlersById[P].isActive()||(delete this._eventsInProgress[S],y=n[P]||I,_[`${S}end`]=y)}for(const S in _)this._fireEvent(S,_[S]);const b=sr(this._eventsInProgress),w=(l||u)&&!b;if(w&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const S=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&S.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(S)}if(a&&w){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),P=I=>I!==0&&-this._bearingSnap<I&&I<this._bearingSnap;!S||!S.essential&&Ee.prefersReducedMotion?(this._map.fire(new c.l("moveend",{originalEvent:y})),P(this._map.getBearing())&&this._map.resetNorth()):(P(S.bearing||this._map.getBearing())&&(S.bearing=0),S.freezeElevation=!0,this._map.easeTo(S,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new c.l(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new wt("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class gc extends c.E{constructor(e,n,a){super(),this._renderFrameCallback=()=>{const l=Math.min((Ee.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(l)),l<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=a.bearingSnap,this.cameraHelper=n,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,n){e.apply(this.transform),this.transform=e,this.cameraHelper=n}getCenter(){return new c.S(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,n){return this.jumpTo({elevation:e},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,n,a){return e=c.P.convert(e).mult(-1),this.panTo(this.transform.center,c.e({offset:e},n),a)}panTo(e,n,a){return this.easeTo(c.e({center:e},n),a)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,a){return this.easeTo(c.e({zoom:e},n),a)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,n){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new c.l("movestart",n)).fire(new c.l("move",n)).fire(new c.l("moveend",n))),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,a){return this.easeTo(c.e({bearing:e},n),a)}resetNorth(e,n){return this.rotateTo(0,c.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(c.e({bearing:0,pitch:0,roll: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}getRoll(){return this.transform.roll}setRoll(e,n){return this.jumpTo({roll:e},n),this}cameraForBounds(e,n){e=Dt.convert(e).adjustAntiMeridian();const a=n&&n.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),a,n)}_cameraForBoxAndBearing(e,n,a,l){const u={top:0,bottom:0,right:0,left:0};if(typeof(l=c.e({padding:u,offset:[0,0],maxZoom:this.transform.maxZoom},l)).padding=="number"){const b=l.padding;l.padding={top:b,bottom:b,right:b,left:b}}const f=c.e(u,l.padding);l.padding=f;const _=this.transform,y=new Dt(e,n);return this.cameraHelper.cameraForBoxAndBearing(l,f,y,a,_)}fitBounds(e,n,a){return this._fitInternal(this.cameraForBounds(e,n),n,a)}fitScreenCoordinates(e,n,a,l,u){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(c.P.convert(e)),this.transform.screenPointToLocation(c.P.convert(n)),a,l),l,u)}_fitInternal(e,n,a){return e?(delete(n=c.e(e,n)).padding,n.linear?this.easeTo(n,a):this.flyTo(n,a)):this}jumpTo(e,n){this.stop();const a=this._getTransformForUpdate();let l=!1,u=!1,f=!1;const _=a.zoom;this.cameraHelper.handleJumpToCenterZoom(a,e);const y=a.zoom!==_;return"elevation"in e&&a.elevation!==+e.elevation&&a.setElevation(+e.elevation),"bearing"in e&&a.bearing!==+e.bearing&&(l=!0,a.setBearing(+e.bearing)),"pitch"in e&&a.pitch!==+e.pitch&&(u=!0,a.setPitch(+e.pitch)),"roll"in e&&a.roll!==+e.roll&&(f=!0,a.setRoll(+e.roll)),e.padding==null||a.isPaddingEqual(e.padding)||a.setPadding(e.padding),this._applyUpdatedTransform(a),this.fire(new c.l("movestart",n)).fire(new c.l("move",n)),y&&this.fire(new c.l("zoomstart",n)).fire(new c.l("zoom",n)).fire(new c.l("zoomend",n)),l&&this.fire(new c.l("rotatestart",n)).fire(new c.l("rotate",n)).fire(new c.l("rotateend",n)),u&&this.fire(new c.l("pitchstart",n)).fire(new c.l("pitch",n)).fire(new c.l("pitchend",n)),f&&this.fire(new c.l("rollstart",n)).fire(new c.l("roll",n)).fire(new c.l("rollend",n)),this.fire(new c.l("moveend",n))}calculateCameraOptionsFromTo(e,n,a,l=0){const u=c.a1.fromLngLat(e,n),f=c.a1.fromLngLat(a,l),_=f.x-u.x,y=f.y-u.y,b=f.z-u.z,w=Math.hypot(_,y,b);if(w===0)throw new Error("Can't calculate camera options with same From and To");const S=Math.hypot(_,y),P=c.ak(this.transform.cameraToCenterDistance/w/this.transform.tileSize),I=180*Math.atan2(_,-y)/Math.PI;let k=180*Math.acos(S/w)/Math.PI;return k=b<0?90-k:90+k,{center:f.toLngLat(),elevation:l,zoom:P,pitch:k,bearing:I}}calculateCameraOptionsFromCameraLngLatAltRotation(e,n,a,l,u){const f=this.transform.calculateCenterFromCameraLngLatAlt(e,n,a,l);return{center:f.center,elevation:f.elevation,zoom:f.zoom,bearing:a,pitch:l,roll:u}}easeTo(e,n){this._stop(!1,e.easeId),((e=c.e({offset:[0,0],duration:500,easing:c.co},e)).animate===!1||!e.essential&&Ee.prefersReducedMotion)&&(e.duration=0);const a=this._getTransformForUpdate(),l=this.getBearing(),u=a.pitch,f=a.roll,_="bearing"in e?this._normalizeBearing(e.bearing,l):l,y="pitch"in e?+e.pitch:u,b="roll"in e?this._normalizeBearing(e.roll,f):f,w="padding"in e?e.padding:a.padding,S=c.P.convert(e.offset);let P,I;e.around&&(P=c.S.convert(e.around),I=a.locationToScreenPoint(P));const k={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},O=this.cameraHelper.handleEaseTo(a,{bearing:_,pitch:y,roll:b,padding:w,around:P,aroundPoint:I,offsetAsPoint:S,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||l!==_,this._pitching=this._pitching||y!==u,this._rolling=this._rolling||b!==f,this._padding=!a.isPaddingEqual(w),this._zooming=this._zooming||O.isZooming,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,k),this.terrain&&this._prepareElevation(O.elevationCenter),this._ease(B=>{O.easeFunc(B),this.terrain&&!e.freezeElevation&&this._updateElevation(B),this._applyUpdatedTransform(a),this._fireMoveEvents(n)},B=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,B)},e),this}_prepareEase(e,n,a={}){this._moving=!0,n||a.moving||this.fire(new c.l("movestart",e)),this._zooming&&!a.zooming&&this.fire(new c.l("zoomstart",e)),this._rotating&&!a.rotating&&this.fire(new c.l("rotatestart",e)),this._pitching&&!a.pitching&&this.fire(new c.l("pitchstart",e)),this._rolling&&!a.rolling&&this.fire(new c.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(n-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.setElevation(c.C.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const n=e.getCameraLngLat(),a=e.getCameraAltitude(),l=this.terrain?this.terrain.getElevationForLngLatZoom(n,e.zoom):0;if(a<l){const u=this.calculateCameraOptionsFromTo(n,l,e.center,e.elevation);return{pitch:u.pitch,zoom:u.zoom}}return{}}_applyUpdatedTransform(e){const n=[];if(n.push(l=>this._elevateCameraIfInsideTerrain(l)),this.transformCameraUpdate&&n.push(l=>this.transformCameraUpdate(l)),!n.length)return;const a=e.clone();for(const l of n){const u=a.clone(),{center:f,zoom:_,roll:y,pitch:b,bearing:w,elevation:S}=l(u);f&&u.setCenter(f),S!==void 0&&u.setElevation(S),_!==void 0&&u.setZoom(_),y!==void 0&&u.setRoll(y),b!==void 0&&u.setPitch(b),w!==void 0&&u.setBearing(w),a.apply(u)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new c.l("move",e)),this._zooming&&this.fire(new c.l("zoom",e)),this._rotating&&this.fire(new c.l("rotate",e)),this._pitching&&this.fire(new c.l("pitch",e)),this._rolling&&this.fire(new c.l("roll",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,l=this._rotating,u=this._pitching,f=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,a&&this.fire(new c.l("zoomend",e)),l&&this.fire(new c.l("rotateend",e)),u&&this.fire(new c.l("pitchend",e)),f&&this.fire(new c.l("rollend",e)),this.fire(new c.l("moveend",e))}flyTo(e,n){if(!e.essential&&Ee.prefersReducedMotion){const he=c.Q(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(he,n)}this.stop(),e=c.e({offset:[0,0],speed:1.2,curve:1.42,easing:c.co},e);const a=this._getTransformForUpdate(),l=a.bearing,u=a.pitch,f=a.roll,_=a.padding,y="bearing"in e?this._normalizeBearing(e.bearing,l):l,b="pitch"in e?+e.pitch:u,w="roll"in e?this._normalizeBearing(e.roll,f):f,S="padding"in e?e.padding:a.padding,P=c.P.convert(e.offset);let I=a.centerPoint.add(P);const k=a.screenPointToLocation(I),O=this.cameraHelper.handleFlyTo(a,{bearing:y,pitch:b,roll:w,padding:S,locationAtOffset:k,offsetAsPoint:P,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let B=e.curve;const N=Math.max(a.width,a.height),U=N/O.scaleOfZoom,q=O.pixelPathLength;typeof O.scaleOfMinZoom=="number"&&(B=Math.sqrt(N/O.scaleOfMinZoom/q*2));const $=B*B;function H(he){const we=(U*U-N*N+(he?-1:1)*$*$*q*q)/(2*(he?U:N)*$*q);return Math.log(Math.sqrt(we*we+1)-we)}function K(he){return(Math.exp(he)-Math.exp(-he))/2}function G(he){return(Math.exp(he)+Math.exp(-he))/2}const te=H(!1);let ue=function(he){return G(te)/G(te+B*he)},ae=function(he){return N*((G(te)*(K(we=te+B*he)/G(we))-K(te))/$)/q;var we},oe=(H(!0)-te)/B;if(Math.abs(q)<2e-6||!isFinite(oe)){if(Math.abs(N-U)<1e-6)return this.easeTo(e,n);const he=U<N?-1:1;oe=Math.abs(Math.log(U/N))/B,ae=()=>0,ue=we=>Math.exp(he*B*we)}return e.duration="duration"in e?+e.duration:1e3*oe/("screenSpeed"in e?+e.screenSpeed/B:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=l!==y,this._pitching=b!==u,this._rolling=w!==f,this._padding=!a.isPaddingEqual(S),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(O.targetCenter),this._ease(he=>{const we=he*oe,Se=1/ue(we),ye=ae(we);this._rotating&&a.setBearing(c.C.number(l,y,he)),this._pitching&&a.setPitch(c.C.number(u,b,he)),this._rolling&&a.setRoll(c.C.number(f,w,he)),this._padding&&(a.interpolatePadding(_,S,he),I=a.centerPoint.add(P)),O.easeFunc(he,Se,ye,I),this.terrain&&!e.freezeElevation&&this._updateElevation(he),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 a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const l=this._onEaseEnd;delete this._onEaseEnd,l.call(this,n)}return e||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(e,n,a){a.animate===!1||a.duration===0?(e(1),n()):(this._easeStart=Ee.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=c.aO(e,-180,180);const a=Math.abs(e-n);return Math.abs(e-360-n)<a&&(e-=360),Math.abs(e+360-n)<a&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(c.S.convert(e),this.transform.tileZoom):null}}const Qo={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class el{constructor(e=Qo){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=se.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=se.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=se.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){se.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,n){const a=this._map._getUIString(`AttributionControl.${n}`);e.title=a,e.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(l=>typeof l!="string"?"":l)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const l=this._map.style.stylesheet;this.styleOwner=l.owner,this.styleId=l.id}const n=this._map.style.sourceCaches;for(const l in n){const u=n[l];if(u.used||u.usedForTerrain){const f=u.getSource();f.attribution&&e.indexOf(f.attribution)<0&&e.push(f.attribution)}}e=e.filter(l=>String(l).trim()),e.sort((l,u)=>l.length-u.length),e=e.filter((l,u)=>{for(let f=u+1;f<e.length;f++)if(e[f].indexOf(l)>=0)return!1;return!0});const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=se.sanitize(a),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class _c{constructor(e={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=se.create("div","maplibregl-ctrl");const n=se.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){se.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Pr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const l of a)if(l.id===e)return void(l.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Va=c.aJ([{name:"a_pos3d",type:"Int16",components:3}]);class Fe extends c.E{constructor(e){super(),this._lastTilesetChange=Ee.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];const a={};for(const l of ne(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))a[l.key]=!0,this._renderableTilesKeys.push(l.key),this._tiles[l.key]||(l.terrainRttPosMatrix32f=new Float64Array(16),c.bY(l.terrainRttPosMatrix32f,0,c.$,c.$,0,0,1),this._tiles[l.key]=new Zn(l,this.tileSize),this._lastTilesetChange=Ee.now());for(const l in this._tiles)a[l]||delete this._tiles[l]}freeRtt(e){for(const n in this._tiles){const a=this._tiles[n];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,n){return n?this._getTerrainCoordsForTileRanges(e,n):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const n={};for(const a of this._renderableTilesKeys){const l=this._tiles[a].tileID,u=e.clone(),f=c.ba();if(l.canonical.equals(e.canonical))c.bY(f,0,c.$,c.$,0,0,1);else if(l.canonical.isChildOf(e.canonical)){const _=l.canonical.z-e.canonical.z,y=l.canonical.x-(l.canonical.x>>_<<_),b=l.canonical.y-(l.canonical.y>>_<<_),w=c.$>>_;c.bY(f,0,w,w,0,0,1),c.M(f,f,[-y*w,-b*w,0])}else{if(!e.canonical.isChildOf(l.canonical))continue;{const _=e.canonical.z-l.canonical.z,y=e.canonical.x-(e.canonical.x>>_<<_),b=e.canonical.y-(e.canonical.y>>_<<_),w=c.$>>_;c.bY(f,0,c.$,c.$,0,0,1),c.M(f,f,[y*w,b*w,0]),c.N(f,f,[1/2**_,1/2**_,0])}}u.terrainRttPosMatrix32f=new Float32Array(f),n[a]=u}return n}_getTerrainCoordsForTileRanges(e,n){const a={};for(const l of this._renderableTilesKeys){const u=this._tiles[l].tileID;if(!this._isWithinTileRanges(u,n))continue;const f=e.clone(),_=c.ba();if(u.canonical.z===e.canonical.z){const y=e.canonical.x-u.canonical.x,b=e.canonical.y-u.canonical.y;c.bY(_,0,c.$,c.$,0,0,1),c.M(_,_,[y*c.$,b*c.$,0])}else if(u.canonical.z>e.canonical.z){const y=u.canonical.z-e.canonical.z,b=u.canonical.x-(u.canonical.x>>y<<y),w=u.canonical.y-(u.canonical.y>>y<<y),S=e.canonical.x-(u.canonical.x>>y),P=e.canonical.y-(u.canonical.y>>y),I=c.$>>y;c.bY(_,0,I,I,0,0,1),c.M(_,_,[-b*I+S*c.$,-w*I+P*c.$,0])}else{const y=e.canonical.z-u.canonical.z,b=e.canonical.x-(e.canonical.x>>y<<y),w=e.canonical.y-(e.canonical.y>>y<<y),S=(e.canonical.x>>y)-u.canonical.x,P=(e.canonical.y>>y)-u.canonical.y,I=c.$<<y;c.bY(_,0,I,I,0,0,1),c.M(_,_,[b*c.$+S*I,w*c.$+P*I,0])}f.terrainRttPosMatrix32f=new Float32Array(_),a[l]=f}return a}getSourceTile(e,n){const a=this.sourceCache._source;let l=e.overscaledZ-this.deltaZoom;if(l>a.maxzoom&&(l=a.maxzoom),l<a.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(l).key);let u=this.sourceCache.getTileByID(this._sourceTileCache[e.key]);if((!u||!u.dem)&&n)for(;l>=a.minzoom&&(!u||!u.dem);)u=this.sourceCache.getTileByID(e.scaledTo(l--).key);return u}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,n){return n[e.canonical.z]&&e.canonical.x>=n[e.canonical.z].minTileX&&e.canonical.x<=n[e.canonical.z].maxTileX&&e.canonical.y>=n[e.canonical.z].minTileY&&e.canonical.y<=n[e.canonical.z].maxTileY}}class Ve{constructor(e,n,a){this._meshCache={},this.painter=e,this.sourceCache=new Fe(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,a,l=c.$){var u;if(!(n>=0&&n<l&&a>=0&&a<l))return 0;const f=this.getTerrainData(e),_=(u=f.tile)===null||u===void 0?void 0:u.dem;if(!_)return 0;const y=c.cs([],[n/l*c.$,a/l*c.$],f.u_terrain_matrix),b=[y[0]*_.dim,y[1]*_.dim],w=Math.floor(b[0]),S=Math.floor(b[1]),P=b[0]-w,I=b[1]-S;return _.get(w,S)*(1-P)*(1-I)+_.get(w+1,S)*P*(1-I)+_.get(w,S+1)*(1-P)*I+_.get(w+1,S+1)*P*I}getElevationForLngLatZoom(e,n){if(!c.ct(n,e.wrap()))return 0;const{tileID:a,mercatorX:l,mercatorY:u}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(a,l%c.$,u%c.$,c.$)}getElevation(e,n,a,l=c.$){return this.getDEMElevation(e,n,a,l)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const l=this.painter.context,u=new c.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new c.T(l,u,l.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new c.T(l,new c.R({width:1,height:1}),l.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=c.ag([])}const n=this.sourceCache.getSourceTile(e,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const l=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new c.T(l,n.dem.getPixels(),l.gl.RGBA,{premultiply:!1}),n.demTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const a=n&&n+n.tileID.key+e.key;if(a&&!this._demMatrixCache[a]){const l=this.sourceCache.sourceCache._source.maxzoom;let u=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=l?u=e.canonical.z-l:c.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const f=e.canonical.x-(e.canonical.x>>u<<u),_=e.canonical.y-(e.canonical.y>>u<<u),y=c.cu(new Float64Array(16),[1/(c.$<<u),1/(c.$<<u),0]);c.M(y,y,[f*c.$,_*c.$,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:a?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){const n=this.painter,a=n.width/devicePixelRatio,l=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===a&&this._fbo.height===l||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new c.T(n.context,{width:a,height:l,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 c.T(n.context,{width:a,height:l,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(a,l,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,a,l))),this._fbo.colorAttachment.set(e==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let u=0,f=0;u<this._coordsTextureSize;u++)for(let _=0;_<this._coordsTextureSize;_++,f+=4)n[f+0]=255&_,n[f+1]=255&u,n[f+2]=_>>8<<4|u>>8,n[f+3]=0;const a=new c.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),l=new c.T(e,a,e.gl.RGBA,{premultiply:!1});return l.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=l,l}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),a=this.painter.context,l=a.gl,u=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),f=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),l.readPixels(u,_-f-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),w=this.coordsIndex[255-n[3]],S=w&&this.sourceCache.getTileByID(w);if(!S)return null;const P=this._coordsTextureSize,I=(1<<S.tileID.canonical.z)*P;return new c.a1((S.tileID.canonical.x*P+y)/I+S.tileID.wrap,(S.tileID.canonical.y*P+b)/I,this.getElevation(S.tileID,y,b,P))}depthAtPoint(e){const n=new Uint8Array(4),a=this.painter.context,l=a.gl;return a.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),l.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(e){var n;const a=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,l=a&&e.canonical.y===0,u=a&&e.canonical.y===(1<<e.canonical.z)-1,f=`m_${l?"n":""}_${u?"s":""}`;if(this._meshCache[f])return this._meshCache[f];const _=this.painter.context,y=new c.cv,b=new c.aN,w=this.meshSize,S=c.$/w,P=w*w;for(let G=0;G<=w;G++)for(let te=0;te<=w;te++)y.emplaceBack(te*S,G*S,0);for(let G=0;G<P;G+=w+1)for(let te=0;te<w;te++)b.emplaceBack(te+G,w+te+G+1,w+te+G+2),b.emplaceBack(te+G,w+te+G+2,te+G+1);const I=y.length,k=I+(w+1),O=(w+1)*w,B=l?c.bh:0,N=l?0:1,U=u?c.bi:c.$,q=u?0:1;for(let G=0;G<=w;G++)y.emplaceBack(G*S,B,N);for(let G=0;G<=w;G++)y.emplaceBack(G*S,U,q);for(let G=0;G<w;G++)b.emplaceBack(O+G,k+G,k+G+1),b.emplaceBack(O+G,k+G+1,O+G+1),b.emplaceBack(0+G,I+G+1,I+G),b.emplaceBack(0+G,0+G+1,I+G+1);const $=y.length,H=$+2*(w+1);for(const G of[0,1])for(let te=0;te<=w;te++)for(const ue of[0,1])y.emplaceBack(G*c.$,te*S,ue);for(let G=0;G<2*w;G+=2)b.emplaceBack($+G,$+G+1,$+G+3),b.emplaceBack($+G,$+G+3,$+G+2),b.emplaceBack(H+G,H+G+3,H+G+1),b.emplaceBack(H+G,H+G+2,H+G+3);const K=new yn(_.createVertexBuffer(y,Va.members),_.createIndexBuffer(b),c.aM.simpleSegment(0,0,y.length,b.length));return this._meshCache[f]=K,K}getMeshFrameDelta(e){return 2*Math.PI*c.bu/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,n){var a;const{tileID:l}=this._getOverscaledTileIDFromLngLatZoom(e,n);return(a=this.getMinMaxElevation(l).minElevation)!==null&&a!==void 0?a:0}getMinMaxElevation(e){const n=this.getTerrainData(e).tile,a={minElevation:null,maxElevation:null};return n&&n.dem&&(a.minElevation=n.dem.min*this.exaggeration,a.maxElevation=n.dem.max*this.exaggeration),a}_getOverscaledTileIDFromLngLatZoom(e,n){const a=c.a1.fromLngLat(e.wrap()),l=(1<<n)*c.$,u=a.x*l,f=a.y*l,_=Math.floor(u/c.$),y=Math.floor(f/c.$);return{tileID:new c.Z(n,0,n,_,y),mercatorX:u,mercatorY:f}}}class Ua{constructor(e,n,a){this._context=e,this._size=n,this._tileSize=a,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),a=new c.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return a.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(a.texture),{id:e,fbo:n,texture:a,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(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(e=>!e.inUse)===!1}}const en={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class $a{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new Ua(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(n)),this._coordsAscending={};for(const a in e.sourceCaches){this._coordsAscending[a]={};const l=e.sourceCaches[a].getVisibleCoordinates(),u=e.sourceCaches[a].getSource(),f=u instanceof yr?u.terrainTileRanges:null;for(const _ of l){const y=this.terrain.sourceCache.getTerrainCoords(_,f);for(const b in y)this._coordsAscending[a][b]||(this._coordsAscending[a][b]=[]),this._coordsAscending[a][b].push(y[b])}}this._coordsAscendingStr={};for(const a of e._order){const l=e._layers[a],u=l.source;if(en[l.type]&&!this._coordsAscendingStr[u]){this._coordsAscendingStr[u]={};for(const f in this._coordsAscending[u])this._coordsAscendingStr[u][f]=this._coordsAscending[u][f].map(_=>_.key).sort().join()}}for(const a of this._renderableTiles)for(const l in this._coordsAscendingStr){const u=this._coordsAscendingStr[l][a.tileID.key];u&&u!==a.rttCoords[l]&&(a.rtt=[])}}renderLayer(e,n){if(e.isHidden(this.painter.transform.zoom))return!1;const a=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),l=e.type,u=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(en[l]&&(this._prevType&&en[this._prevType]||this._stacks.push([]),this._prevType=l,this._stacks[this._stacks.length-1].push(e.id),!f))return!0;if(en[this._prevType]||en[l]&&f){this._prevType=l;const _=this._stacks.length-1,y=this._stacks[_]||[];for(const b of this._renderableTiles){if(this.pool.isFull()&&(Ra(this.painter,this.terrain,this._rttTiles,a),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(b),b.rtt[_]){const S=this.pool.getObjectForId(b.rtt[_].id);if(S.stamp===b.rtt[_].stamp){this.pool.useObject(S);continue}}const w=this.pool.getOrCreateFreeObject();this.pool.useObject(w),this.pool.stampObject(w),b.rtt[_]={id:w.id,stamp:w.stamp},u.context.bindFramebuffer.set(w.fbo.framebuffer),u.context.clear({color:c.bf.transparent,stencil:0}),u.currentStencilSource=void 0;for(let S=0;S<y.length;S++){const P=u.style._layers[y[S]],I=P.source?this._coordsAscending[P.source][b.tileID.key]:[b.tileID];u.context.viewport.set([0,0,w.fbo.width,w.fbo.height]),u._renderTileClippingMasks(P,I,!0),u.renderLayer(u,u.style.sourceCaches[P.source],P,I,a),P.source&&(b.rttCoords[P.source]=this._coordsAscendingStr[P.source][b.tileID.key])}}return Ra(this.painter,this.terrain,this._rttTiles,a),this._rttTiles=[],this.pool.freeAllObjects(),en[l]}return!1}}const Pi={"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","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},yc=be,Wi={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Qo,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 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],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:c.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0},yh={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Ys{constructor(e,n,a=!1){this.mousedown=u=>{this.startMove(u,se.mousePos(this.element,u)),se.addEventListener(window,"mousemove",this.mousemove),se.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=u=>{this.move(u,se.mousePos(this.element,u))},this.mouseup=u=>{this._rotatePitchHandler.dragEnd(u),this.offTemp()},this.touchstart=u=>{u.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=se.touchPos(this.element,u.targetTouches)[0],this.startMove(u,this._startPos),se.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.addEventListener(window,"touchend",this.touchend))},this.touchmove=u=>{u.targetTouches.length!==1?this.reset():(this._lastPos=se.touchPos(this.element,u.targetTouches)[0],this.move(u,this._lastPos))},this.touchend=u=>{u.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._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n;const l=new mh;this._rotatePitchHandler=new as({clickTolerance:3,move:(u,f)=>{const _=n.getBoundingClientRect(),y=new c.P((_.bottom-_.top)/2,(_.right-_.left)/2);return{bearingDelta:c.cn(new c.P(u.x,f.y),f,y),pitchDelta:a?-.5*(f.y-u.y):void 0}},moveStateManager:l,enable:!0,assignEvents:()=>{}}),this.map=e,se.addEventListener(n,"mousedown",this.mousedown),se.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),se.addEventListener(n,"touchcancel",this.reset)}startMove(e,n){this._rotatePitchHandler.dragStart(e,n),se.disableDrag()}move(e,n){const a=this.map,{bearingDelta:l,pitchDelta:u}=this._rotatePitchHandler.dragMove(e,n)||{};l&&a.setBearing(a.getBearing()+l),u&&a.setPitch(a.getPitch()+u)}off(){const e=this.element;se.removeEventListener(e,"mousedown",this.mousedown),se.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend),se.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){se.enableDrag(),se.removeEventListener(window,"mousemove",this.mousemove),se.removeEventListener(window,"mouseup",this.mouseup),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend)}}let _t;function Bt(h,e,n,a=!1){if(a||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return h==null?void 0:h.wrap();const l=new c.S(h.lng,h.lat);if(h=new c.S(h.lng,h.lat),e){const u=new c.S(h.lng-360,h.lat),f=new c.S(h.lng+360,h.lat),_=n.locationToScreenPoint(h).distSqr(e);n.locationToScreenPoint(u).distSqr(e)<_?h=u:n.locationToScreenPoint(f).distSqr(e)<_&&(h=f)}for(;Math.abs(h.lng-n.center.lng)>180;){const u=n.locationToScreenPoint(h);if(u.x>=0&&u.y>=0&&u.x<=n.width&&u.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==l.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(h))?h:l}const Za={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 hs(h,e,n){const a=h.classList;for(const l in Za)a.remove(`maplibregl-${n}-anchor-${l}`);a.add(`maplibregl-${n}-anchor-${e}`)}class us extends c.E{constructor(e){if(super(),this._onKeyPress=n=>{const a=n.code,l=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&l!==32&&l!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,l=this._element;this._popup&&(a===l||l.contains(a))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const a=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!a)&&this._map.once("render",this._update),this._lngLat=Bt(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let l="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?l=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(l=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let u="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?u="rotateX(0deg)":this._pitchAlignment==="map"&&(u=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),se.setTransform(this._element,`${Za[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${u} ${l}`),Ee.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new c.l("dragstart"))),this.fire(new c.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new c.l("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(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=c.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=se.create("div");const n=se.createNS("http://www.w3.org/2000/svg","svg"),a=41,l=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${l}px`),n.setAttributeNS(null,"viewBox",`0 0 ${l} ${a}`);const u=se.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"stroke","none"),u.setAttributeNS(null,"stroke-width","1"),u.setAttributeNS(null,"fill","none"),u.setAttributeNS(null,"fill-rule","evenodd");const f=se.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"fill-rule","nonzero");const _=se.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const y=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const N of y){const U=se.createNS("http://www.w3.org/2000/svg","ellipse");U.setAttributeNS(null,"opacity","0.04"),U.setAttributeNS(null,"cx","10.5"),U.setAttributeNS(null,"cy","5.80029008"),U.setAttributeNS(null,"rx",N.rx),U.setAttributeNS(null,"ry",N.ry),_.appendChild(U)}const b=se.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const w=se.createNS("http://www.w3.org/2000/svg","path");w.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(w);const S=se.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const P=se.createNS("http://www.w3.org/2000/svg","path");P.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(P);const I=se.createNS("http://www.w3.org/2000/svg","g");I.setAttributeNS(null,"transform","translate(6.0, 7.0)"),I.setAttributeNS(null,"fill","#FFFFFF");const k=se.createNS("http://www.w3.org/2000/svg","g");k.setAttributeNS(null,"transform","translate(8.0, 8.0)");const O=se.createNS("http://www.w3.org/2000/svg","circle");O.setAttributeNS(null,"fill","#000000"),O.setAttributeNS(null,"opacity","0.25"),O.setAttributeNS(null,"cx","5.5"),O.setAttributeNS(null,"cy","5.5"),O.setAttributeNS(null,"r","5.4999962");const B=se.createNS("http://www.w3.org/2000/svg","circle");B.setAttributeNS(null,"fill","#FFFFFF"),B.setAttributeNS(null,"cx","5.5"),B.setAttributeNS(null,"cy","5.5"),B.setAttributeNS(null,"r","5.4999962"),k.appendChild(O),k.appendChild(B),f.appendChild(_),f.appendChild(b),f.appendChild(S),f.appendChild(I),f.appendChild(k),n.appendChild(f),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",l*this._scale+"px"),this._element.appendChild(n),this._offset=c.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()}),hs(this._element,this._anchor,"marker"),e&&e.className)for(const n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),se.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=c.S.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const l=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":[l,-1*(38.1-13.5+l)],"bottom-right":[-l,-1*(38.1-13.5+l)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,a;const l=(n=this._map)===null||n===void 0?void 0:n.terrain,u=this._map.transform.isLocationOccluded(this._lngLat);if(!l||u){const I=u?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==I&&(this._element.style.opacity=I))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const f=this._map,_=f.terrain.depthAtPoint(this._pos),y=f.terrain.getElevationForLngLatZoom(this._lngLat,f.transform.tileZoom);if(f.transform.lngLatToCameraDepth(this._lngLat,y)-_<.006)return void(this._element.style.opacity=this._opacity);const b=-this._offset.y/f.transform.pixelsPerMeter,w=Math.sin(f.getPitch()*Math.PI/180)*b,S=f.terrain.depthAtPoint(new c.P(this._pos.x,this._pos.y-this._offset.y)),P=f.transform.lngLatToCameraDepth(this._lngLat,y+w)-S>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&P&&this._popup.remove(),this._element.style.opacity=P?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=c.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(this._opacity===void 0||e===void 0&&n===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const tl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ds=0,Ln=!1;const Ks={maxWidth:100,unit:"metric"};function Ga(h,e,n){const a=n&&n.maxWidth||100,l=h._container.clientHeight/2,u=h._container.clientWidth/2,f=h.unproject([u-a/2,l]),_=h.unproject([u+a/2,l]),y=Math.round(h.project(_).x-h.project(f).x),b=Math.min(a,y,h._container.clientWidth),w=f.distanceTo(_);if(n&&n.unit==="imperial"){const S=3.2808*w;S>5280?Dn(e,b,S/5280,h._getUIString("ScaleControl.Miles")):Dn(e,b,S,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Dn(e,b,w/1852,h._getUIString("ScaleControl.NauticalMiles")):w>=1e3?Dn(e,b,w/1e3,h._getUIString("ScaleControl.Kilometers")):Dn(e,b,w,h._getUIString("ScaleControl.Meters"))}function Dn(h,e,n,a){const l=function(u){const f=Math.pow(10,`${Math.floor(u)}`.length-1);let _=u/f;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b}(_),f*_}(n);h.style.width=e*(l/n)+"px",h.innerHTML=`${l}&nbsp;${a}`}const il={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},rl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function qa(h){if(h){if(typeof h=="number"){const e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new c.P(0,0),top:new c.P(0,h),"top-left":new c.P(e,e),"top-right":new c.P(-e,e),bottom:new c.P(0,-h),"bottom-left":new c.P(e,-e),"bottom-right":new c.P(-e,-e),left:new c.P(h,0),right:new c.P(-h,0)}}if(h instanceof c.P||Array.isArray(h)){const e=c.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:c.P.convert(h.center||[0,0]),top:c.P.convert(h.top||[0,0]),"top-left":c.P.convert(h["top-left"]||[0,0]),"top-right":c.P.convert(h["top-right"]||[0,0]),bottom:c.P.convert(h.bottom||[0,0]),"bottom-left":c.P.convert(h["bottom-left"]||[0,0]),"bottom-right":c.P.convert(h["bottom-right"]||[0,0]),left:c.P.convert(h.left||[0,0]),right:c.P.convert(h.right||[0,0])}}return qa(new c.P(0,0))}const nl=be;C.AJAXError=c.cz,C.Event=c.l,C.Evented=c.E,C.LngLat=c.S,C.MercatorCoordinate=c.a1,C.Point=c.P,C.addProtocol=c.cA,C.config=c.a,C.removeProtocol=c.cB,C.AttributionControl=el,C.BoxZoomHandler=qo,C.CanvasSource=Nr,C.CooperativeGesturesHandler=mc,C.DoubleClickZoomHandler=Xo,C.DragPanHandler=pc,C.DragRotateHandler=Ko,C.EdgeInsets=vn,C.FullscreenControl=class extends c.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n==null?void 0:n.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:c.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){se.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=se.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);se.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new c.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new c.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},C.GeoJSONSource=_r,C.GeolocateControl=class extends c.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new c.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&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 c.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const n=new c.S(e.coords.longitude,e.coords.latitude),a=e.coords.accuracy,l=this._map.getBearing(),u=c.e({bearing:l},this.options.fitBoundsOptions),f=Dt.fromLngLat(n,a);this._map.fitBounds(f,u,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const n=new c.S(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._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(e.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ln)return;this.options.trackUserLocation&&this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new c.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=se.create("button","maplibregl-ctrl-geolocate",this._container),se.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){c.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=se.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new us({element:this._dotElement}),this._circleElement=se.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new us({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{const a=(n==null?void 0:n[0])instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||a||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new c.l("trackuserlocationend")),this.fire(new c.l("userlocationlostfocus")))})}},this.options=c.e({},tl,h)}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return c._(this,arguments,void 0,function*(e=!1){if(_t!==void 0&&!e)return _t;if(window.navigator.permissions===void 0)return _t=!!window.navigator.geolocation,_t;try{_t=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{_t=!!window.navigator.geolocation}return _t})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),se.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ds=0,Ln=!1}_isOutOfMapMaxBounds(h){const 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}`)}}_updateCircleRadiusIfNeeded(){const h=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&h))return;const e=this._map.project(h),n=this._map.unproject([e.x+100,e.y]),a=h.distanceTo(n)/100,l=2*this._accuracy/a;this._circleElement.style.width=`${l.toFixed(2)}px`,this._circleElement.style.height=`${l.toFixed(2)}px`}trigger(){if(!this._setup)return c.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 c.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ds--,Ln=!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 c.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new c.l("trackuserlocationstart")),this.fire(new c.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(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"),ds++,ds>1?(h={maximumAge:6e5,timeout:0},Ln=!0):(h=this.options.positionOptions,Ln=!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)}},C.GlobeControl=class{constructor(){this._toggleProjection=()=>{var h;const e=(h=this._map.getProjection())===null||h===void 0?void 0:h.type;this._map.setProjection(e!=="mercator"&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var h;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((h=this._map.getProjection())===null||h===void 0?void 0:h.type)==="globe"?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=se.create("button","maplibregl-ctrl-globe",this._container),se.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){se.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},C.Hash=Fa,C.ImageSource=yr,C.KeyboardHandler=ja,C.LngLatBounds=Dt,C.LogoControl=_c,C.Map=class extends gc{constructor(h){var e,n;c.cw.mark(c.cx.create);const a=Object.assign(Object.assign(Object.assign({},Wi),h),{canvasContextAttributes:Object.assign(Object.assign({},Wi.canvasContextAttributes),h.canvasContextAttributes)});if(a.minZoom!=null&&a.maxZoom!=null&&a.minZoom>a.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(a.minPitch!=null&&a.maxPitch!=null&&a.minPitch>a.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(a.minPitch!=null&&a.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(a.maxPitch!=null&&a.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const l=new bt,u=new _i;if(a.minZoom!==void 0&&l.setMinZoom(a.minZoom),a.maxZoom!==void 0&&l.setMaxZoom(a.maxZoom),a.minPitch!==void 0&&l.setMinPitch(a.minPitch),a.maxPitch!==void 0&&l.setMaxPitch(a.maxPitch),a.renderWorldCopies!==void 0&&l.setRenderWorldCopies(a.renderWorldCopies),super(l,u,{bearingSnap:a.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Pr,this._controls=[],this._mapId=c.a7(),this._contextLost=_=>{_.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new c.l("webglcontextlost",{originalEvent:_}))},this._contextRestored=_=>{this._setupPainter(),this.resize(),this._update(),this.fire(new c.l("webglcontextrestored",{originalEvent:_}))},this._onMapScroll=_=>{if(_.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=a.interactive,this._maxTileCacheSize=a.maxTileCacheSize,this._maxTileCacheZoomLevels=a.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},a.canvasContextAttributes),this._trackResize=a.trackResize===!0,this._bearingSnap=a.bearingSnap,this._centerClampedToGround=a.centerClampedToGround,this._refreshExpiredTiles=a.refreshExpiredTiles===!0,this._fadeDuration=a.fadeDuration,this._crossSourceCollisions=a.crossSourceCollisions===!0,this._collectResourceTiming=a.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Pi),a.locale),this._clickTolerance=a.clickTolerance,this._overridePixelRatio=a.pixelRatio,this._maxCanvasSize=a.maxCanvasSize,this.transformCameraUpdate=a.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=a.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Ot.addThrottleControl(()=>this.isMoving()),this._requestManager=new $i(a.transformRequest),typeof a.container=="string"){if(this._container=document.getElementById(a.container),!this._container)throw new Error(`Container '${a.container}' not found.`)}else{if(!(a.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=a.container}if(a.maxBounds&&this.setMaxBounds(a.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let _=!1;const y=kn(b=>{this._trackResize&&!this._removed&&(this.resize(b),this.redraw())},50);this._resizeObserver=new ResizeObserver(b=>{_?y(b):_=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Jo(this,a),this._hash=a.hash&&new Fa(typeof a.hash=="string"&&a.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,roll:a.roll}),a.bounds&&(this.resize(),this.fitBounds(a.bounds,c.e({},a.fitBoundsOptions,{duration:0}))));const f=typeof a.style=="string"||((n=(e=a.style)===null||e===void 0?void 0:e.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,f),this._localIdeographFontFamily=a.localIdeographFontFamily,this._validateStyle=a.validateStyle,a.style&&this.setStyle(a.style,{localIdeographFontFamily:a.localIdeographFontFamily}),a.attributionControl&&this.addControl(new el(typeof a.attributionControl=="boolean"?void 0:a.attributionControl)),a.maplibreLogo&&this.addControl(new _c,a.logoPosition),this.on("style.load",()=>{if(f||this._resizeTransform(),this.transform.unmodified){const _=c.Q(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(_)}}),this.on("data",_=>{this._update(_.dataType==="style"),this.fire(new c.l(`${_.dataType}data`,_))}),this.on("dataloading",_=>{this.fire(new c.l(`${_.dataType}dataloading`,_))}),this.on("dataabort",_=>{this.fire(new c.l("sourcedataabort",_))})}_getMapId(){return this._mapId}setGlobalStateProperty(h,e){return this.style.setGlobalStateProperty(h,e),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new c.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const a=this._controlPositions[e];return e.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new c.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}coveringTiles(h){return ne(this.transform,h)}calculateCameraOptionsFromTo(h,e,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,a)}resize(h,e=!0){const[n,a]=this._containerDimensions(),l=this._getClampedPixelRatio(n,a);if(this._resizeCanvas(n,a,l),this.painter.resize(n,a,l),this.painter.overLimit()){const f=this.painter.context.gl;this._maxCanvasSize=[f.drawingBufferWidth,f.drawingBufferHeight];const _=this._getClampedPixelRatio(n,a);this._resizeCanvas(n,a,_),this.painter.resize(n,a,_)}this._resizeTransform(e);const u=!this._moving;return u&&(this.stop(),this.fire(new c.l("movestart",h)).fire(new c.l("move",h))),this.fire(new c.l("resize",h)),u&&this.fire(new c.l("moveend",h)),this}_resizeTransform(h=!0){var e;const[n,a]=this._containerDimensions();this.transform.resize(n,a,h),(e=this._requestedCameraState)===null||e===void 0||e.resize(n,a,h)}_getClampedPixelRatio(h,e){const{0:n,1:a}=this._maxCanvasSize,l=this.getPixelRatio(),u=h*l,f=e*l;return Math.min(u>n?n/u:1,f>a?a/f:1)*l}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(Dt.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.setMinZoom(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.setMaxZoom(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.setMinPitch(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)>180)throw new Error("maxPitch must be less than or equal to 180");if(h>=this.transform.minPitch)return this.transform.setMaxPitch(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.setRenderWorldCopies(h),this._update()}project(h){return this.transform.locationToScreenPoint(c.S.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.screenPointToLocation(c.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:u=>{const f=e.filter(y=>this.getLayer(y)),_=f.length!==0?this.queryRenderedFeatures(u.point,{layers:f}):[];_.length?a||(a=!0,n.call(this,new ki(h,this,u.originalEvent,{features:_}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:f=>{const _=e.filter(y=>this.getLayer(y));(_.length!==0?this.queryRenderedFeatures(f.point,{layers:_}):[]).length?a=!0:a&&(a=!1,n.call(this,new ki(h,this,f.originalEvent)))},mouseout:f=>{a&&(a=!1,n.call(this,new ki(h,this,f.originalEvent)))}}}}{const a=l=>{const u=e.filter(_=>this.getLayer(_)),f=u.length!==0?this.queryRenderedFeatures(l.point,{layers:u}):[];f.length&&(l.features=f,n.call(this,l),delete l.features)};return{layers:e,listener:n,delegates:{[h]:a}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;const a=this._delegatedListeners[h];for(let l=0;l<a.length;l++){const u=a[l];if(u.listener===n&&u.layers.length===e.length&&u.layers.every(f=>e.includes(f))){for(const f in u.delegates)this.off(f,u.delegates[f]);return void a.splice(l,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);const a=typeof e=="string"?[e]:e,l=this._createDelegatedListener(h,a,n);this._saveDelegatedListener(h,l);for(const u in l.delegates)this.on(u,l.delegates[u]);return{unsubscribe:()=>{this._removeDelegatedListener(h,a,n)}}}once(h,e,n){if(n===void 0)return super.once(h,e);const a=typeof e=="string"?[e]:e,l=this._createDelegatedListener(h,a,n);for(const u in l.delegates){const f=l.delegates[u];l.delegates[u]=(..._)=>{this._removeDelegatedListener(h,a,n),f(..._)}}this._saveDelegatedListener(h,l);for(const u in l.delegates)this.once(u,l.delegates[u]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n;const a=h instanceof c.P||Array.isArray(h),l=a?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(a?{}:h)||{},l instanceof c.P||typeof l[0]=="number")n=[c.P.convert(l)];else{const u=c.P.convert(l[0]),f=c.P.convert(l[1]);n=[u,new c.P(f.x,u.y),f,new c.P(u.x,f.y),u]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=c.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){var n,a;if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));const l=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new bo(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,l):this.style.loadJSON(h,e,l),this):((a=(n=this.style)===null||n===void 0?void 0:n.projection)===null||a===void 0||a.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new bo(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,"Style");c.j(n,new AbortController).then(a=>{this._updateDiff(a.data,e)}).catch(a=>{a&&this.fire(new c.k(a))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){c.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():c.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){const e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new c.k(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===h.source&&c.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."),a.type==="color-relief"&&a.source===h.source&&c.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Ve(this.painter,e,h),this.painter.renderToTexture=new $a(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=n=>{var a;n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),((a=n.source)===null||a===void 0?void 0:a.type)==="image"?this.terrain.sourceCache.freeRtt():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.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new c.l("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const e in h){const n=h[e]._tiles;for(const a in n){const l=n[a];if(l.state!=="loaded"&&l.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}setSourceTileLodParams(h,e,n){if(n){const a=this.getSource(n);if(!a)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);a.calculateTileZoom=ve(Math.max(1,h),Math.max(1,e))}else for(const a in this.style.sourceCaches)this.style.sourceCaches[a].getSource().calculateTileZoom=ve(Math.max(1,h),Math.max(1,e));return this._update(!0),this}refreshTiles(h,e){const n=this.style.sourceCaches[h];if(!n)throw new Error(`There is no source cache with ID "${h}", cannot refresh tile`);e===void 0?n.reload(!0):n.refreshTiles(e.map(a=>new c.a4(a.z,a.x,a.y)))}addImage(h,e,n={}){const{pixelRatio:a=1,sdf:l=!1,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||c.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new c.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:w,height:S,data:P}=e,I=e;return this.style.addImage(h,{data:new c.R({width:w,height:S},new Uint8Array(P)),pixelRatio:a,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:b,sdf:l,version:0,userImage:I}),I.onAdd&&I.onAdd(this,h),this}}{const{width:w,height:S,data:P}=Ee.getImageData(e);this.style.addImage(h,{data:new c.R({width:w,height:S},P),pixelRatio:a,stretchX:u,stretchY:f,content:_,textFitWidth:y,textFitHeight:b,sdf:l,version:0})}}updateImage(h,e){const n=this.style.getImage(h);if(!n)return this.fire(new c.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=e instanceof HTMLImageElement||c.b(e)?Ee.getImageData(e):e,{width:l,height:u,data:f}=a;if(l===void 0||u===void 0)return this.fire(new c.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(l!==n.data.width||u!==n.data.height)return this.fire(new c.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(e instanceof HTMLImageElement||c.b(e));return n.data.replace(f,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new c.k(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return Ot.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,a={}){return this.style.setPaintProperty(h,e,n,a),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,a={}){return this.style.setLayoutProperty(h,e,n,a),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,n=>{n||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(h,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const e=this._canvasContainer=se.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=se.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const l=this._controlContainer=se.create("div","maplibregl-control-container",h),u=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(f=>{u[f]=se.create("div",`maplibregl-ctrl-${f} `,l)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const h=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{e={requestedAttributes:h},a&&(e.statusMessage=a.statusMessage,e.type=a.type)},{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,h):this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h),!n){const a="Failed to initialize WebGL";throw e?(e.message=a,new Error(JSON.stringify(e))):new Error(a)}this.painter=new ic(n,this.transform),Mt.testSupport(n)}migrateProjection(h,e){super.migrateProjection(h,e),this.painter.transform=h,this.fire(new c.l("projectiontransition",{newProjection:this.style.projection.name}))}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){var e,n,a,l,u;const f=this._idleTriggered?this._fadeDuration:0,_=((e=this.style.projection)===null||e===void 0?void 0:e.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let y=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const S=this.transform.zoom,P=Ee.now();this.style.zoomHistory.update(S,P);const I=new c.F(S,{now:P,fadeDuration:f,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),k=I.crossFadingFactor();k===1&&k===this._crossFadingFactor||(y=!0,this._crossFadingFactor=k),this.style.update(I)}const b=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==_;(a=this.style.projection)===null||a===void 0||a.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((l=this.style.projection)===null||l===void 0?void 0:l.transitionState,(u=this.style.projection)===null||u===void 0?void 0:u.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||b)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,f,this._crossSourceCollisions,b),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,showPadding:this.showPadding}),this.fire(new c.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,c.cw.mark(c.cx.load),this.fire(new c.l("load"))),this.style&&(this.style.hasTransitions()||y)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const w=this._sourcesDirty||this._styleDirty||this._placementDirty;return w||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new c.l("idle")),!this._loaded||this._fullyLoaded||w||(this._fullyLoaded=!0,c.cw.mark(c.cx.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Ot.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),se.remove(this._canvasContainer),se.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),c.cw.clearMetrics(),this._removed=!0,this.fire(new c.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Ee.frame(this._frameRequest,h=>{c.cw.frame(h),this._frameRequest=null;try{this._render(h)}catch(e){if(!c.cy(e)&&!function(n){return n.message===Ns}(e))throw e}},()=>{}))}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 yc}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(h){return this._lazyInitEmptyStyle(),this.style.setProjection(h),this._update(!0)}},C.MapMouseEvent=ki,C.MapTouchEvent=rs,C.MapWheelEvent=Go,C.Marker=us,C.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const e=this._map.getZoom(),n=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);e.title=a,e.setAttribute("aria-label",a)},this.options=c.e({},yh,h),this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=se.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ys(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){se.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){const n=se.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},C.Popup=class extends c.E{constructor(h){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&se.remove(this._content),this._container&&(se.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new c.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=se.create("div","maplibregl-popup",this._map.getContainer()),this._tip=se.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const f of this.options.className.split(" "))this._container.classList.add(f);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=Bt(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const n=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let a=this.options.anchor;const l=qa(this.options.offset);if(!a){const f=this._container.offsetWidth,_=this._container.offsetHeight;let y;y=n.y+l.bottom.y<_?["top"]:n.y>this._map.transform.height-_?["bottom"]:[],n.x<f/2?y.push("left"):n.x>this._map.transform.width-f/2&&y.push("right"),a=y.length===0?"bottom":y.join("-")}let u=n.add(l[a]);this.options.subpixelPositioning||(u=u.round()),se.setTransform(this._container,`${Za[a]} translate(${u.x}px,${u.y}px)`),hs(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=c.e(Object.create(il),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 c.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=c.S.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const e=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=h;a=n.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=se.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=se.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const h=this._container.querySelector(rl);h&&h.focus()}},C.RasterDEMTileSource=mn,C.RasterTileSource=gr,C.ScaleControl=class{constructor(h){this._onMove=()=>{Ga(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Ga(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ks),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){se.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},C.ScrollZoomHandler=uc,C.Style=bo,C.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=se.create("button","maplibregl-ctrl-terrain",this._container),se.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){se.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},C.TwoFingersTouchPitchHandler=Oa,C.TwoFingersTouchRotateHandler=ls,C.TwoFingersTouchZoomHandler=Ba,C.TwoFingersTouchZoomRotateHandler=fc,C.VectorTileSource=Ki,C.VideoSource=$n,C.addSourceType=(h,e)=>c._(void 0,void 0,void 0,function*(){if(Ur(h))throw new Error(`A source type called "${h}" already exists.`);((n,a)=>{Vr[n]=a})(h,e)}),C.clearPrewarmedResources=function(){const h=mr;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(dn),mr=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()"))},C.createTileMesh=xo,C.getMaxParallelImageRequests=function(){return c.a.MAX_PARALLEL_IMAGE_REQUESTS},C.getRTLTextPluginStatus=function(){return Gr().getRTLTextPluginStatus()},C.getVersion=function(){return nl},C.getWorkerCount=function(){return mi.workerCount},C.getWorkerUrl=function(){return c.a.WORKER_URL},C.importScriptInWorkers=function(h){return Nn().broadcast("IS",h)},C.prewarm=function(){fn().acquire(dn)},C.setMaxParallelImageRequests=function(h){c.a.MAX_PARALLEL_IMAGE_REQUESTS=h},C.setRTLTextPlugin=function(h,e){return Gr().setRTLTextPlugin(h,e)},C.setWorkerCount=function(h){mi.workerCount=h},C.setWorkerUrl=function(h){c.a.WORKER_URL=h}});var Ue=J;return Ue})}(Tl)),Tl.exports}var ln=sp(),Xi=63710088e-1,ap={centimeters:Xi*100,centimetres:Xi*100,degrees:360/(2*Math.PI),feet:Xi*3.28084,inches:Xi*39.37,kilometers:Xi/1e3,kilometres:Xi/1e3,meters:Xi,metres:Xi,miles:Xi/1609.344,millimeters:Xi*1e3,millimetres:Xi*1e3,nauticalmiles:Xi/1852,radians:1,yards:Xi*1.0936};function Oc(me,j,J={}){const de={type:"Feature"};return(J.id===0||J.id)&&(de.id=J.id),J.bbox&&(de.bbox=J.bbox),de.properties=j||{},de.geometry=me,de}function op(me,j,J={}){if(me.length<2)throw new Error("coordinates must be an array of two or more positions");return Oc({type:"LineString",coordinates:me},j,J)}function lp(me,j="kilometers"){const J=ap[j];if(!J)throw new Error(j+" units is invalid");return me*J}function Pl(me){return me%360*Math.PI/180}function jc(me,j,J){if(me!==null)for(var de,je,Ue,C,c,be,ct,ut=0,pt=0,Ee,se=me.type,Mt=se==="FeatureCollection",ei=se==="Feature",Ri=Mt?me.features.length:1,Ci=0;Ci<Ri;Ci++){ct=Mt?me.features[Ci].geometry:ei?me.geometry:me,Ee=ct?ct.type==="GeometryCollection":!1,c=Ee?ct.geometries.length:1;for(var It=0;It<c;It++){var ft=0,Ot=0;if(C=Ee?ct.geometries[It]:ct,C!==null){be=C.coordinates;var $i=C.type;switch(ut=0,$i){case null:break;case"Point":if(j(be,pt,Ci,ft,Ot)===!1)return!1;pt++,ft++;break;case"LineString":case"MultiPoint":for(de=0;de<be.length;de++){if(j(be[de],pt,Ci,ft,Ot)===!1)return!1;pt++,$i==="MultiPoint"&&ft++}$i==="LineString"&&ft++;break;case"Polygon":case"MultiLineString":for(de=0;de<be.length;de++){for(je=0;je<be[de].length-ut;je++){if(j(be[de][je],pt,Ci,ft,Ot)===!1)return!1;pt++}$i==="MultiLineString"&&ft++,$i==="Polygon"&&Ot++}$i==="Polygon"&&ft++;break;case"MultiPolygon":for(de=0;de<be.length;de++){for(Ot=0,je=0;je<be[de].length;je++){for(Ue=0;Ue<be[de][je].length-ut;Ue++){if(j(be[de][je][Ue],pt,Ci,ft,Ot)===!1)return!1;pt++}Ot++}ft++}break;case"GeometryCollection":for(de=0;de<C.geometries.length;de++)if(jc(C.geometries[de],j)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function cp(me,j){var J,de,je,Ue,C,c,be,ct,ut,pt,Ee=0,se=me.type==="FeatureCollection",Mt=me.type==="Feature",ei=se?me.features.length:1;for(J=0;J<ei;J++){for(c=se?me.features[J].geometry:Mt?me.geometry:me,ct=se?me.features[J].properties:Mt?me.properties:{},ut=se?me.features[J].bbox:Mt?me.bbox:void 0,pt=se?me.features[J].id:Mt?me.id:void 0,be=c?c.type==="GeometryCollection":!1,C=be?c.geometries.length:1,je=0;je<C;je++){if(Ue=be?c.geometries[je]:c,Ue===null){if(j(null,Ee,ct,ut,pt)===!1)return!1;continue}switch(Ue.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(j(Ue,Ee,ct,ut,pt)===!1)return!1;break}case"GeometryCollection":{for(de=0;de<Ue.geometries.length;de++)if(j(Ue.geometries[de],Ee,ct,ut,pt)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}Ee++}}function hp(me,j){cp(me,function(J,de,je,Ue,C){var c=J===null?null:J.type;switch(c){case null:case"Point":case"LineString":case"Polygon":return j(Oc(J,je,{bbox:Ue,id:C}),de,0)===!1?!1:void 0}var be;switch(c){case"MultiPoint":be="Point";break;case"MultiLineString":be="LineString";break;case"MultiPolygon":be="Polygon";break}for(var ct=0;ct<J.coordinates.length;ct++){var ut=J.coordinates[ct],pt={type:be,coordinates:ut};if(j(Oc(pt,je),de,ct)===!1)return!1}})}function up(me,j){hp(me,function(J,de,je){var Ue=0;if(J.geometry){var C=J.geometry.type;if(!(C==="Point"||C==="MultiPoint")){var c,be=0,ct=0,ut=0;if(jc(J,function(pt,Ee,se,Mt,ei){if(c===void 0||de>be||Mt>ct||ei>ut){c=pt,be=de,ct=Mt,ut=ei,Ue=0;return}var Ri=op([c,pt],J.properties);if(j(Ri,de,je,ei,Ue)===!1)return!1;Ue++,c=pt})===!1)return!1}}})}function dp(me,j,J){var de=J,je=!1;return up(me,function(Ue,C,c,be,ct){je===!1&&J===void 0?de=Ue:de=j(de,Ue,C,c,be,ct),je=!0}),de}function pp(me,j={}){if(me.bbox!=null&&j.recompute!==!0)return me.bbox;const J=[1/0,1/0,-1/0,-1/0];return jc(me,de=>{J[0]>de[0]&&(J[0]=de[0]),J[1]>de[1]&&(J[1]=de[1]),J[2]<de[0]&&(J[2]=de[0]),J[3]<de[1]&&(J[3]=de[1])}),J}var lu=pp;class fp{constructor(j={}){this.type=j.type||"Feature",this.id=j.id||null,this.properties=j.properties||{},this.geometry=j.geometry||{},this.geometry.type=this.geometry.type||null,this.geometry.coordinates=this.geometry.coordinates||[]}get bbox(){return!this.geometry||!this.geometry.type||!this.geometry.coordinates.length?null:lu({type:"Feature",geometry:this.geometry})}toJSON(){return{type:this.type,id:this.id,bbox:this.bbox,properties:this.properties,geometry:this.geometry}}}class Fr extends fp{constructor(j={}){super(j),this.id=this.id||Bc(),this.featureType=sa(this)||null,this.properties.waymark=this.properties.waymark||{},this.active=!1,this.popup=this.createPopup(),this.popup&&(this.popup=this.popup),this.mapLibreMap=null,this.source=null,this.layer=null,this.style=null,this.highlightLayer=null}setActive(j=!0){this.active=j,this.active?this.showHighlight():this.hideHighlight()}addEvents(){this.mapLibreMap.on("mouseenter",this.id,()=>{this.mapLibreMap.getCanvas().style.cursor="pointer",!this.active&&this.showHighlight()}),this.mapLibreMap.on("mouseleave",this.id,()=>{this.mapLibreMap.getCanvas().style.cursor="",!this.active&&this.hideHighlight()})}addTo(j){if(!(!j||!j.addLayer)){if(this.mapLibreMap=j,this.source){this.source.setData(this.toJSON());return}this.mapLibreMap.addSource(this.id,{type:"geojson",data:this.toJSON()}),this.source=this.mapLibreMap.getSource(this.id),this.style=this.toStyle(),this.mapLibreMap.addLayer(this.style),this.layer=this.mapLibreMap.getLayer(this.id),this.highlightLayer=this.addHighlightLayer(),this.addEvents()}}hasMap(){return this.mapLibreMap!==null}remove(){this.mapLibreMap&&(this.highlightLayer&&this.mapLibreMap.removeLayer(`${this.id}-highlight`),this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.removeLayer(this.id),this.mapLibreMap.getSource(this.id)&&this.mapLibreMap.removeSource(this.id),this.mapLibreMap=null,this.source=null,this.layer=null,this.style=null)}getTitle(){var j;return((j=this.properties.waymark)==null?void 0:j.title)||null}getDescription(){var j;return((j=this.properties.waymark)==null?void 0:j.description)||null}containsText(j=""){let J=0;return J+=Object.values(this.properties).some(de=>de.toString().toLowerCase().includes(j.toLowerCase())),J>0}zoomIn(){if(!this.mapLibreMap)return;const j=16;this.mapLibreMap.getZoom()<j&&this.mapLibreMap.flyTo({center:[this.geometry.coordinates[0],this.geometry.coordinates[1]],zoom:j,...bs})}createPopup(){if(!this.getTitle()&&!this.getDescription())return null;const j=document.createElement("div");if(j.className="waymark-popup-content",this.getTitle()){const J=document.createElement("h3");J.textContent=this.getTitle(),j.appendChild(J)}if(this.getDescription()){const J=document.createElement("div");J.innerHTML=this.getDescription(),j.appendChild(J)}return new ln.Popup({}).setDOMContent(j)}openPopup(j){if(!this.mapLibreMap||!this.popup)return;console.log("Opening popup for overlay:",this.id);const J=j||this.getBounds().getCenter();this.popup.setLngLat([J.lng,J.lat]).addTo(this.mapLibreMap)}show(){this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.setLayoutProperty(this.id,"visibility","visible")}hide(){this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.setLayoutProperty(this.id,"visibility","none")}addHighlightLayer(){const j=this.getHighlightStyle(),J={id:`${this.id}-highlight`,type:j.type,source:this.id,layout:j.layout||{},paint:j.paint||{}};return this.customizeHighlight(J),this.mapLibreMap.addLayer(J,this.id),this.mapLibreMap.setLayoutProperty(J.id,"visibility","none"),J}isHighlighted(){return this.highlightLayer?this.mapLibreMap.getLayoutProperty(`${this.id}-highlight`,"visibility")==="visible":!1}showHighlight(){this.highlightLayer&&this.mapLibreMap.setLayoutProperty(`${this.id}-highlight`,"visibility","visible")}hideHighlight(){this.highlightLayer&&this.mapLibreMap.setLayoutProperty(`${this.id}-highlight`,"visibility","none")}getHighlightStyle(){return this.toStyle()}toggleHighlight(){this.isHighlighted()?this.hideHighlight():this.showHighlight()}}const Nc="#b42714";function cu(){const me="0123456789ABCDEF";let j="#";for(let J=0;J<6;J++)j+=me[Math.floor(Math.random()*16)];return j}class Vc extends Fr{constructor(j={}){const J={...j,geometry:{...j.geometry||{},type:"Point"}};super(J)}get bbox(){return null}addTo(j){var de;super.addTo(j);const J=(de=this.properties.waymark)==null?void 0:de.icon;J&&this.addIcon(J)}remove(){this.htmlMarker&&(this.htmlMarker.remove(),this.htmlMarker=null),this.mapLibreMap&&(this.mapLibreMap.getLayer(`${this.id}-icon`)&&this.mapLibreMap.removeLayer(`${this.id}-icon`),this.mapLibreMap.hasImage(`${this.id}-icon-img`)&&this.mapLibreMap.removeImage(`${this.id}-icon-img`)),super.remove()}addIcon(j){if(!this.mapLibreMap)return;if(j.html){if(this.mapLibreMap.getLayer(`${this.id}-icon`)&&this.mapLibreMap.removeLayer(`${this.id}-icon`),this.htmlMarker){const Ue=this.htmlMarker.getElement();Ue.innerHTML!==j.html&&(Ue.innerHTML=j.html),this.htmlMarker.setLngLat(this.geometry.coordinates)}else{const Ue=document.createElement("div");Ue.innerHTML=j.html,Ue.addEventListener("mouseenter",()=>{this.mapLibreMap.getCanvas().style.cursor="pointer",!this.active&&this.showHighlight()}),Ue.addEventListener("mouseleave",()=>{this.mapLibreMap.getCanvas().style.cursor="",!this.active&&this.hideHighlight()}),this.htmlMarker=new ln.Marker({element:Ue,anchor:"center"}).setLngLat(this.geometry.coordinates).addTo(this.mapLibreMap)}return}else this.htmlMarker&&(this.htmlMarker.remove(),this.htmlMarker=null);const J=`${this.id}-icon-img`,de=`${this.id}-icon`,je=()=>{this.mapLibreMap&&(this.mapLibreMap.getLayer(de)?(this.mapLibreMap.setLayoutProperty(de,"icon-image",J),this.mapLibreMap.setLayoutProperty(de,"icon-rotate",j.rotation||0)):this.mapLibreMap.addLayer({id:de,type:"symbol",source:this.id,layout:{"icon-image":J,"icon-size":1,"icon-allow-overlap":!0,"icon-rotate":j.rotation||0}}))};if(j.url)this.mapLibreMap.loadImage(j.url,(Ue,C)=>{if(Ue){console.error("Error loading icon:",Ue);return}this.mapLibreMap&&(this.mapLibreMap.hasImage(J)||this.mapLibreMap.addImage(J,C),je())});else if(j.svg){const Ue=new Image(j.width||32,j.height||32);Ue.onload=()=>{this.mapLibreMap&&(this.mapLibreMap.hasImage(J)||this.mapLibreMap.addImage(J,Ue),je())},Ue.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(j.svg)}}toStyle(){var J;const j=((J=this.properties.waymark)==null?void 0:J.paint)||{};return{id:this.id,type:"circle",source:this.id,paint:{"circle-radius":3,"circle-color":"#ffffff","circle-stroke-color":cu(),"circle-stroke-width":3,...j}}}hasElevationData(){return this.geometry.coordinates.length===3}getElevationString(){return this.hasElevationData()?"Elevation: "+Math.round(this.geometry.coordinates[2]*10)/10+"m":""}getBounds(){return new ln.LngLatBounds([this.geometry.coordinates[0],this.geometry.coordinates[1]],[this.geometry.coordinates[0],this.geometry.coordinates[1]])}getCoordsString(){return"Lat,Lng: "+this.geometry.coordinates[1].toFixed(6)+", "+this.geometry.coordinates[0].toFixed(6)}flyTo(){this.mapLibreMap.flyTo({center:[this.geometry.coordinates[0],this.geometry.coordinates[1]],...bs})}inBounds(j){return j.contains({lng:this.geometry.coordinates[0],lat:this.geometry.coordinates[1]})}customizeHighlight(j){j.paint["circle-stroke-color"]=Nc,j.paint["circle-stroke-width"]+=2}}function hu(me){if(!me)throw new Error("coord is required");if(!Array.isArray(me)){if(me.type==="Feature"&&me.geometry!==null&&me.geometry.type==="Point")return[...me.geometry.coordinates];if(me.type==="Point")return[...me.coordinates]}if(Array.isArray(me)&&me.length>=2&&!Array.isArray(me[0])&&!Array.isArray(me[1]))return[...me];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function mp(me,j,J={}){var de=hu(me),je=hu(j),Ue=Pl(je[1]-de[1]),C=Pl(je[0]-de[0]),c=Pl(de[1]),be=Pl(je[1]),ct=Math.pow(Math.sin(Ue/2),2)+Math.pow(Math.sin(C/2),2)*Math.cos(c)*Math.cos(be);return lp(2*Math.atan2(Math.sqrt(ct),Math.sqrt(1-ct)),J.units)}function gp(me,j={}){return dp(me,(J,de)=>{const je=de.geometry.coordinates;return J+mp(je[0],je[1],j)},0)}class Uc extends Fr{constructor(j={}){var de;const J={...j,geometry:{...j.geometry||{},type:((de=j.geometry)==null?void 0:de.type)||"LineString"}};super(J)}toStyle(){var J;const j=((J=this.properties.waymark)==null?void 0:J.paint)||{};return{id:this.id,type:"line",source:this.id,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":cu(),"line-width":3,...j}}}addCoordinate(j=[]){!Array.isArray(j)||j.length<2||this.geometry.coordinates.push(j)}getLengthString(){let j="";j+="Length: ";const J=gp(this,{units:"kilometers"});return j+=Math.round(J*100)/100,j+="km",j}hasElevationData(){return this.getLinePositions().some(j=>j.length===3)}getElevationString(){if(!this.hasElevationData())return"";const j=this.getLinePositions();if(j.length===0)return"";let J=0,de=0,je=j[0][2],Ue=j[0][2];for(let C=1;C<j.length;C++){const c=j[C][2]-j[C-1][2];c>0?J+=c:de-=c,je=Math.max(je,j[C][2]),Ue=Math.min(Ue,j[C][2])}return"Elevation Gain: "+Math.round(J*10)/10+"m, Loss: "+Math.round(de*10)/10+"m, Max: "+Math.round(je*10)/10+"m, Min: "+Math.round(Ue*10)/10+"m"}getBounds(){const j=this.getLinePositions();return j.length?j.reduce((J,de)=>J.extend({lng:de[0],lat:de[1]}),new ln.LngLatBounds({lng:j[0][0],lat:j[0][1]},{lng:j[0][0],lat:j[0][1]})):new ln.LngLatBounds([0,0],[0,0])}getCoordsString(){const J=this.getBounds().getCenter();return"Centre Lat,Lng: "+J.lat.toFixed(6)+", "+J.lng.toFixed(6)}flyTo(){const j=this.getBounds();this.mapLibreMap.fitBounds(j,bs)}inBounds(j){return this.getLinePositions().some(de=>j.contains({lng:de[0],lat:de[1]}))}zoomIn(){if(this.mapLibreMap.getZoom()<16){const de=this.getLinePositions(),je=de.length?de[0]:[0,0];this.mapLibreMap.flyTo({center:[je[0],je[1]],zoom:16,...bs})}}getLinePositions(){const j=this.geometry;return j.type==="MultiLineString"?j.coordinates.reduce((J,de)=>J.concat(de),[]):j.coordinates||[]}customizeHighlight(j){j.paint["line-color"]=Nc,j.paint["line-width"]+=2}}class $c extends Fr{constructor(j={}){var de;const J={...j,geometry:{...j.geometry||{},type:((de=j.geometry)==null?void 0:de.type)||"Polygon"}};super(J),this.strokeLayer=null}addTo(j){super.addTo(j),this.strokeLayer||(this.mapLibreMap.addLayer(this.strokeStyle()),this.strokeLayer=this.mapLibreMap.getLayer(`${this.id}-stroke`))}remove(){this.mapLibreMap&&this.strokeLayer&&this.mapLibreMap.removeLayer(`${this.id}-stroke`),super.remove()}toStyle(){var J;const j=((J=this.properties.waymark)==null?void 0:J.paint)||{};return{id:this.id,type:"fill",source:this.id,layout:{},paint:{"fill-color":"#000000","fill-opacity":.2,"fill-outline-color":"#000000",...j}}}show(){this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.setLayoutProperty(this.id,"visibility","visible"),this.strokeLayer&&this.mapLibreMap.setLayoutProperty(`${this.id}-stroke`,"visibility","visible")}hide(){this.mapLibreMap.getLayer(this.id)&&this.mapLibreMap.setLayoutProperty(this.id,"visibility","none"),this.strokeLayer&&this.mapLibreMap.setLayoutProperty(`${this.id}-stroke`,"visibility","none")}strokeStyle(){var j;return{id:`${this.id}-stroke`,type:"line",source:this.id,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":((j=this.properties.waymark)==null?void 0:j.shape_colour)||"#000000","line-width":1,"line-opacity":1}}}hasElevationData(){return this.getPolygonPositions().some(j=>j.length===3)}getElevationString(){return this.hasElevationData()?"Elevation data available":""}getBounds(){const j=this.getPolygonPositions();return j.length?j.reduce((J,de)=>J.extend({lng:de[0],lat:de[1]}),new ln.LngLatBounds({lng:j[0][0],lat:j[0][1]},{lng:j[0][0],lat:j[0][1]})):new ln.LngLatBounds([0,0],[0,0])}getCoordsString(){const J=this.getBounds().getCenter();return"Centre Lat,Lng: "+J.lat.toFixed(6)+", "+J.lng.toFixed(6)}zoomIn(){const J=this.getBounds().getCenter();this.mapLibreMap.flyTo({center:[J.lng,J.lat],zoom:Math.max(this.mapLibreMap.getZoom(),16),...bs})}getPolygonPositions(){const j=this.geometry;return j.type==="MultiPolygon"?j.coordinates.reduce((J,de)=>(de.forEach(je=>J.push(...je)),J),[]):j.coordinates?j.coordinates.reduce((J,de)=>J.concat(de),[]):[]}flyTo(){const j=this.getBounds();this.mapLibreMap.fitBounds(j,bs)}inBounds(j){const J=this.getBounds();return!(J.getNorth()<j.getSouth()||J.getSouth()>j.getNorth()||J.getEast()<j.getWest()||J.getWest()>j.getEast())}getHighlightStyle(){return this.strokeStyle()}customizeHighlight(j){j.paint["line-color"]=Nc,j.paint["line-width"]+=2}}class _p{constructor(j={}){this.type="FeatureCollection",this.id=j.id||null,this.properties=j.properties||{},this.features=Array.isArray(j.features)?j.features:[]}get bbox(){return this.features.length>0?lu({type:"FeatureCollection",features:this.features}):null}toJSON(){return{type:this.type,id:this.id,bbox:this.bbox,properties:this.properties,features:this.features}}}class ws extends _p{constructor(j={}){return super(j),this.id=this.id||Bc(),this.overlays=new Map,this.features.forEach(J=>{var de;if(((de=J.geometry)==null?void 0:de.type)==="MultiPoint")(J.geometry.coordinates||[]).forEach(je=>{const Ue={...J,id:void 0,geometry:{type:"Point",coordinates:je}},C=Ml(Ue);C&&this.overlays.set(C.id,C)});else{const je=Ml(J);je&&this.overlays.set(je.id,je)}}),this.mapLibreMap=null,this}get overlaysArray(){return Array.from(this.overlays.values())}toJSON(){const j=super.toJSON();return j.features=this.overlaysArray.map(J=>J.toJSON()),j}hasOverlay(j){return this.overlays.has(j)}getOverlay(j){return this.overlays.get(j)||null}addOverlay(j){if(!(j instanceof Fr))throw new Error("WaymarkOverlay instance required");this.overlays.has(j.id)||(this.features.push(j.toJSON()),this.overlays.set(j.id,j))}removeOverlay(j){if(!this.overlays.has(j))throw new Error("Overlay not found in this map");this.overlays.delete(j)}getBounds(){if(!this.bbox||!isFinite(this.bbox[0])||!isFinite(this.bbox[1])||!isFinite(this.bbox[2])||!isFinite(this.bbox[3]))return null;const j=new ln.LngLatBounds([this.bbox[0],this.bbox[1]],[this.bbox[2],this.bbox[3]]);return j.isEmpty()?null:j}addTo(j){j&&(this.mapLibreMap=j,this.overlaysArray.length&&(this.overlaysArray.filter(J=>J.featureType==="shape").forEach(J=>{J.addTo(this.mapLibreMap)}),this.overlaysArray.filter(J=>J.featureType==="line").forEach(J=>{J.addTo(this.mapLibreMap)}),this.overlaysArray.filter(J=>J.featureType==="marker").forEach(J=>{J.addTo(this.mapLibreMap)}),this.getBounds()))}hasMap(){return this.mapLibreMap!==null}remove(){this.overlaysArray.forEach(j=>{j.remove()}),this.mapLibreMap=null}}function yp(me){const j=new Map,J=new Map,de=new Map;return{maps:J,mapsArray:()=>Array.from(J.values()),overlays:de,overlaysArray:()=>Array.from(de.values()),overlaysByType:()=>{const Ee=Array.from(de.values());return{markers:Ee.filter(se=>se.featureType==="marker"),lines:Ee.filter(se=>se.featureType==="line"),shapes:Ee.filter(se=>se.featureType==="shape")}},hasItem:Ee=>j.has(Ee),getItem:Ee=>j.get(Ee)||null,addItem:(Ee={})=>{if(!Ee||!Ee.type)throw new Error("Valid GeoJSON required");if(Ee.id&&j.has(Ee.id))throw new Error("GeoJSON with this ID already exists");let se=null;if(Ee instanceof ws)se=Ee,J.set(se.id,se),se.overlays.forEach(Mt=>{j.set(Mt.id,Mt)});else if(Ee instanceof Fr)se=Ee,de.set(se.id,se);else switch(Ee.type){case"FeatureCollection":se=pu(Ee),J.set(se.id,se),se.overlays.forEach(Mt=>{j.set(Mt.id,Mt)});break;case"Feature":se=Ml(Ee),de.set(se.id,se);break;default:throw new Error("Valid GeoJSON Feature or FeatureCollection required")}return j.set(se.id,se),me.dispatchEvent("geojson-item-added",{item:se}),se},updateItem:(Ee={})=>{if(!Ee.id)throw new Error("Item must have an ID");if(!j.has(Ee.id))throw new Error("Item with this ID does not exist");return j.set(Ee.id,Ee),me.dispatchEvent("geojson-item-updated",{item:Ee}),Ee},removeItem:(Ee={})=>{if(!Ee.id)throw new Error("Item must have an ID");if(!j.has(Ee.id))throw new Error("Item with this ID does not exist");switch(j.delete(Ee.id),!0){case Ee instanceof ws:J.delete(Ee.id);break;case Ee instanceof Fr:de.delete(Ee.id);break;default:throw new Error("WaymarkMap or WaymarkOverlay instance required")}return me.dispatchEvent("geojson-item-removed",{item:Ee}),Ee}}}function xp(me){const j={mapLibreMap:me.mapLibreMap,view:{bearing:null,pitch:null,bounds:null,zoom:null,center:null}};function J(){const{overlays:de,maps:je}=me.geoJSONStore;j.mapLibreMap.on("load",()=>{j.view.bounds=j.mapLibreMap.getBounds(),j.view.bearing=j.mapLibreMap.getBearing(),j.view.pitch=j.mapLibreMap.getPitch(),j.view.zoom=j.mapLibreMap.getZoom(),j.view.center=j.mapLibreMap.getCenter(),me.dispatchEvent("maplibre-map-ready")}),j.mapLibreMap.on("rotateend",()=>{j.view.bearing=j.mapLibreMap.getBearing(),me.dispatchEvent("maplibre-map-view-change")}),j.mapLibreMap.on("pitchend",()=>{j.view.pitch=j.mapLibreMap.getPitch(),me.dispatchEvent("maplibre-map-view-change")}),j.mapLibreMap.on("moveend",()=>{j.view.bounds=j.mapLibreMap.getBounds(),j.view.center=j.mapLibreMap.getCenter(),j.view.zoom=j.mapLibreMap.getZoom(),me.dispatchEvent("maplibre-map-view-change")}),j.mapLibreMap.on("click",Ue=>{const C=[[Ue.point.x-10,Ue.point.y-10],[Ue.point.x+10,Ue.point.y+10]],c=j.mapLibreMap.queryRenderedFeatures(C);let be=null;for(const ct of c){const ut=ct.layer.id;if(de.has(ut)){be=de.get(ut);break}for(const pt of je.values())if(pt.hasOverlay(ut)){be=pt.getOverlay(ut);break}if(be)break}be?me.setActiveOverlay(be,{lngLat:Ue.lngLat}):me.setActiveOverlay()})}return J(),j}const Sl="waymark-event";class uu extends CustomEvent{constructor(j,J={},de={}){super(Sl,{detail:{eventName:j,...J,...de}})}}class du{constructor(j={}){const J={id:Bc(),mapOptions:{},geoJSON:null,onLoad:null,debug:!1};if(this.config={...J,...j},this.id=this.config.id,this.container=document.getElementById(this.id),this.container&&this.container.classList.contains("waymark-instance"))throw new Error(`Container with id ${this.id} already has a WaymarkInstance attached`);this.container||(this.container=document.createElement("div"),this.container.id=this.id,document.body.appendChild(this.container)),this.container.classList.add("waymark-instance"),this.addEventHandling(),this.geoJSONStore=yp(this),this.mapLibreMap=new ln.Map({container:this.container,...ip,...this.config.mapOptions||{}}),this.mapLibreStore=xp(this),this.activeOverlay=null}getAllMaps(){return this.geoJSONStore.mapsArray}getMapByID(j){return this.geoJSONStore.maps.get(j)}getAllOverlays(){return this.geoJSONStore.overlaysArray}getOverlayByID(j){return this.geoJSONStore.overlays.get(j)}dispatchEvent(j,J={}){const de=new uu(j,J,this);this.container&&this.container.dispatchEvent(de)}onEvent(j,J){this.container&&this.container.addEventListener(Sl,de=>{de.detail&&de.detail.eventName===j&&J(de)})}addEventHandling(){this.config.debug&&this.container.addEventListener(Sl,j=>{console.log(`[Waymark][${this.id}][Event]`,j.detail)}),this.onEvent("maplibre-map-ready",()=>{this.onEvent("geojson-item-added",j=>{var J;if(!((J=j.detail)!=null&&J.item))throw new Error("geojson-item-added event missing item detail");switch(!0){case j.detail.item instanceof ws:case j.detail.item instanceof Fr:j.detail.item.addTo(this.mapLibreStore.mapLibreMap);break;default:throw new Error("geojson-item-added event item must be WaymarkMap or WaymarkOverlay instance")}}),this.onEvent("geojson-item-removed",j=>{var J;if(!((J=j.detail)!=null&&J.item))throw new Error("geojson-item-removed event missing item detail");switch(!0){case j.detail.item instanceof ws:case j.detail.item instanceof Fr:j.detail.item.remove();break;default:throw new Error("geojson-item-removed event item must be WaymarkMap or WaymarkOverlay instance")}}),this.onEvent("geojson-item-updated",j=>{var J;if(!((J=j.detail)!=null&&J.item))throw new Error("geojson-item-updated event missing item detail");switch(!0){case j.detail.item instanceof ws:case j.detail.item instanceof Fr:j.detail.item.addTo(this.mapLibreStore.mapLibreMap);break;default:throw new Error("geojson-item-updated event item must be WaymarkMap or WaymarkOverlay instance")}}),this.config.geoJSON&&this.geoJSONStore.addItem(this.config.geoJSON),this.config.onLoad&&typeof this.config.onLoad=="function"&&this.config.onLoad(this)})}setActiveOverlay(j=null,{lngLat:J}={}){if(!j){this.activeOverlay&&this.activeOverlay.setActive(!1),this.activeOverlay=null,this.dispatchEvent("state-active-overlay-unset");return}if(this.activeOverlay){if(this.activeOverlay===j){j.zoomIn();return}this.activeOverlay.setActive(!1),this.activeOverlay=null}this.activeOverlay=j,j.setActive(!0),j.flyTo(),j.openPopup(J),this.dispatchEvent("state-active-overlay-set")}rotateMap(j="cw",J=90){const{mapLibreMap:de}=this.mapLibreStore;if(de.isRotating())return;const je=de.getBearing(),Ue=j==="cw"?je+J:je-J;de.rotateTo(Ue,rp)}pitchMap(j="down",J=15){const{mapLibreMap:de}=this.mapLibreStore,je=de.getPitch();let Ue=j==="down"?je+J:je-J;Ue=Math.max(0,Math.min(60,Ue)),de.easeTo({pitch:Ue,...aa},{easing:C=>C*(2-C)})}pointNorth(){const{mapLibreMap:j}=this.mapLibreStore;j&&j.easeTo({bearing:0,...aa})}set3D(j=!0){const{mapLibreMap:J}=this.mapLibreStore;j?J.easeTo({pitch:60,...aa},{easing:de=>de*(2-de)}):J.easeTo({pitch:0,...aa},{easing:de=>de*(2-de)})}toggle3D(){const{mapLibreMap:j,view:J}=this.mapLibreStore;J.pitch>0?j.easeTo({pitch:0,...aa},{easing:de=>de*(2-de)}):j.easeTo({pitch:60,...aa},{easing:de=>de*(2-de)})}resetView(){const{overlaysBounds:j}=this.geoJSONStore,{mapLibreMap:J}=this.mapLibreStore;this.pointNorth(),this.set3D(!1),J.fitBounds(j.value,bs)}}function vp(me={}){try{return new du(me)}catch(j){console.error("[Waymark]",j)}}function pu(me){return new ws(me)}function Ml(me){if(me.type)switch(sa(me)){case"marker":return new Vc(me);case"line":return new Uc(me);case"shape":return new $c(me);default:return console.warn("[Waymark] Unsupported geometry type:",me.geometry.type),null}}function bp(me){return new Vc(me)}function wp(me){return new Uc(me)}function Tp(me){return new $c(me)}ci.WaymarkEvent=uu,ci.WaymarkInstance=du,ci.WaymarkLine=Uc,ci.WaymarkMap=ws,ci.WaymarkMarker=Vc,ci.WaymarkOverlay=Fr,ci.WaymarkShape=$c,ci.createInstance=vp,ci.createLine=wp,ci.createMap=pu,ci.createMarker=bp,ci.createOverlay=Ml,ci.createShape=Tp,ci.waymarkEventName=Sl,Object.defineProperty(ci,Symbol.toStringTag,{value:"Module"})});