import{o as Uo,i as Sc,g as ri,t as Ud,h as eh,B as sx,w as Pm,v as ax,s as cn,J as lx,b as Nd,d as zm,e as Ec,f as cx,H as ux,C as hx,K as dx,F as km,r as Lm,T as px,_ as fx,j as mx,L as _x}from"./Dwl-YlTk.js";import{u as Dm}from"./CEUF2dV8.js";import"./DWGXsa6z.js";const gx={class:"mb-2 rounded-2xl bg-[#F5F5F5] p-5 text-sm"},yx={class:"grid grid-cols-6 items-end"},xx={class:"col-span-4 font-normal"},vx={class:"mb-1"},bx={class:"text-2xs font-extralight"},wx={class:"col-span-1"},Tx=["href"],Ex={class:"mt-2 flex justify-center text-2xs"},Sx={class:"col-span-1"},Ax=["href"],Mx=ri("div",{class:"mt-2 flex justify-center text-2xs"},"route",-1),Rm={__name:"DealerCard",props:{dealer:{type:Object,required:!0},distance:{type:String,default:"-"}},setup(w){return(I,R)=>{const Z=sx;return Uo(),Sc("div",gx,[ri("div",yx,[ri("div",xx,[ri("div",vx,Ud(w.dealer.Naam),1),ri("div",bx,Ud(w.dealer.Adres),1)]),ri("div",wx,[ri("a",{class:"relative flex min-w-[65px] cursor-pointer flex-col justify-center text-dark hover:underline",target:"_blank",href:`https://www.google.com/maps/place/${w.dealer.Adres}`},[eh(Z,{class:"relative h-[32px] object-cover",name:"dealerpointergroup"}),ri("div",Ex,Ud(w.distance)+" km",1)],8,Tx)]),ri("div",Sx,[ri("a",{target:"_blank",href:`https://www.google.com/maps/place/${w.dealer.Adres}`,class:"relative flex min-w-[60px] cursor-pointer flex-col justify-center text-dark hover:underline"},[eh(Z,{class:"relative h-[24px] object-cover",name:"dealerroute"}),Mx],8,Ax)])])])}}};var Yn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xm(w){return w&&w.__esModule&&Object.prototype.hasOwnProperty.call(w,"default")?w.default:w}function Ix(w){if(w.__esModule)return w;var I=w.default;if(typeof I=="function"){var R=function Z(){return this instanceof Z?Reflect.construct(I,arguments,this.constructor):I.apply(this,arguments)};R.prototype=I.prototype}else R={};return Object.defineProperty(R,"__esModule",{value:!0}),Object.keys(w).forEach(function(Z){var re=Object.getOwnPropertyDescriptor(w,Z);Object.defineProperty(R,Z,re.get?re:{enumerable:!0,get:function(){return w[Z]}})}),R}var Hm={exports:{}};(function(w,I){var R={};(function(Z,re){w.exports=re()})(Yn,function(){var Z,re,_e;function we(s,le){if(!Z)Z=le;else if(!re)re=le;else{var Qe="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+Z+")(sharedChunk); ("+re+")(sharedChunk); self.onerror = null;",et={};Z(et),_e=le(et),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(_e.workerUrl=window.URL.createObjectURL(new Blob([Qe],{type:"text/javascript"})))}}we(["exports"],function(s){var le=typeof self<"u"?self:{},Qe="2.15.0";let et;const $e={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(et==null){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{et=R.API_URL_REGEX!=null?new RegExp(R.API_URL_REGEX):t}catch{et=t}}return et},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!$e.API_URL)return null;try{const t=new URL($e.API_URL);return t.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":t.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},Je={supported:!1,testSupport:function(t){!ot&&_t&&(St?ei(t):Ye=t)}};let Ye,_t,ot=!1,St=!1;function ei(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,_t),t.isContextLost())return;Je.supported=!0}catch{}t.deleteTexture(e),ot=!0}le.document&&(_t=le.document.createElement("img"),_t.onload=function(){Ye&&ei(Ye),Ye=null,St=!0},_t.onerror=function(){ot=!0,Ye=null},_t.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ct="01";function pi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Nt=Lt;function Lt(t,e,i,n){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=n}Lt.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,e){if(e===void 0&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,n=0;n<8;n++){var a=this.sampleCurveX(i)-t;if(Math.abs(a)<e)return i;var c=this.sampleCurveDerivativeX(i);if(Math.abs(c)<1e-6)break;i-=a/c}var h=0,p=1;for(i=t,n=0;n<20&&(a=this.sampleCurveX(i),!(Math.abs(a-t)<e));n++)t>a?h=i:p=i,i=.5*(p-h)+h;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var ti=pi(Nt),_i=ai;function ai(t,e){this.x=t,this.y=e}ai.prototype={clone:function(){return new ai(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),n=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=n,this},_rotateAround:function(t,e){var i=Math.cos(t),n=Math.sin(t),a=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-n*(this.y-e.y),this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},ai.convert=function(t){return t instanceof ai?t:Array.isArray(t)?new ai(t[0],t[1]):t};var Re=pi(_i);const In=Math.PI/180,Vo=180/Math.PI;function At(t){return t*In}function ki(t){return t*Vo}const Za=[[0,0],[1,0],[1,1],[0,1]];function Fs(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function Go(t,e,i,n){const a=new ti(t,e,i,n);return function(c){return a.solve(c)}}const Us=Go(.25,.1,.25,1);function Tt(t,e,i){return Math.min(i,Math.max(e,t))}function Qn(t,e,i){return(i=Tt((i-t)/(e-t),0,1))*i*(3-2*i)}function zi(t,e,i){const n=i-e,a=((t-e)%n+n)%n+e;return a===e?i:a}function Li(t,e,i){if(!t.length)return i(null,[]);let n=t.length;const a=new Array(t.length);let c=null;t.forEach((h,p)=>{e(h,(m,_)=>{m&&(c=m),a[p]=_,--n==0&&i(c,a)})})}function un(t){const e=[];for(const i in t)e.push(t[i]);return e}function xi(t,...e){for(const i of e)for(const n in i)t[n]=i[n];return t}let hn=1;function eo(){return hn++}function dn(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function Nr(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Ns(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function Cn(t,e){t.forEach(i=>{e[i]&&(e[i]=e[i].bind(e))})}function to(t,e){return t.indexOf(e,t.length-e.length)!==-1}function Mt(t,e,i){const n={};for(const a in t)n[a]=e.call(i||this,t[a],a,t);return n}function io(t,e,i){const n={};for(const a in t)e.call(i||this,t[a],a,t)&&(n[a]=t[a]);return n}function or(t){return Array.isArray(t)?t.map(or):typeof t=="object"&&t?Mt(t,or):t}const $o={};function li(t){$o[t]||(typeof console<"u"&&console.warn(t),$o[t]=!0)}function ur(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function js(t){let e=0;for(let i,n,a=0,c=t.length,h=c-1;a<c;h=a++)i=t[a],n=t[h],e+=(n.x-i.x)*(i.y+n.y);return e}function jr(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function sr(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,n,a,c)=>{const h=a||c;return e[n]=!h||h.toLowerCase(),""}),e["max-age"]){const i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e}let qo=null;function ro(t){if(qo==null){const e=t.navigator?t.navigator.userAgent:null;qo=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return qo}function Zo(t){try{const e=le[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}function pn(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}const no="mapbox-tiles";let Vs=500,Gs=50,hr,fn;function Wo(){try{return le.caches}catch{}}function Pn(){Wo()&&!hr&&(hr=le.caches.open(no))}function oo(t){const e=t.indexOf("?");if(e<0)return t;const i=function(a){const c=a.indexOf("?");return c>0?a.slice(c+1).split("&"):[]}(t),n=i.filter(a=>{const c=a.split("=");return c[0]==="language"||c[0]==="worldview"});return n.length?`${t.slice(0,e)}?${n.join("&")}`:t.slice(0,e)}let Xo=1/0;const zn={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(zn);class mn extends Error{constructor(e,i,n){i===401&&ue(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=i,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const kn=jr()?()=>self.worker&&self.worker.referrer:()=>(le.location.protocol==="blob:"?le.parent:le).location.href,Ln=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(kn())&&!/^\w+:/.test(i))){if(le.fetch&&le.Request&&le.AbortController&&le.Request.prototype.hasOwnProperty("signal"))return function(n,a){const c=new le.AbortController,h=new le.Request(n.url,{method:n.method||"GET",body:n.body,credentials:n.credentials,headers:n.headers,referrer:kn(),referrerPolicy:n.referrerPolicy,signal:c.signal});let p=!1,m=!1;const _=(x=h.url).indexOf("sku=")>0&&ue(x);var x;n.type==="json"&&h.headers.set("Accept","application/json");const b=(A,M,z)=>{if(m)return;if(A&&A.message!=="SecurityError"&&li(A.toString()),M&&z)return T(M);const B=Date.now();le.fetch(h).then(V=>{if(V.ok){const K=_?V.clone():null;return T(V,K,B)}return a(new mn(V.statusText,V.status,n.url))}).catch(V=>{V.name!=="AbortError"&&a(new Error(`${V.message} ${n.url}`))})},T=(A,M,z)=>{(n.type==="arrayBuffer"?A.arrayBuffer():n.type==="json"?A.json():A.text()).then(B=>{m||(M&&z&&function(V,K,G){if(Pn(),!hr)return;const X={status:K.status,statusText:K.statusText,headers:new le.Headers};K.headers.forEach((me,de)=>X.headers.set(de,me));const Y=sr(K.headers.get("Cache-Control")||"");if(Y["no-store"])return;Y["max-age"]&&X.headers.set("Expires",new Date(G+1e3*Y["max-age"]).toUTCString());const J=X.headers.get("Expires");J&&(new Date(J).getTime()-G<42e4||function(me,de){if(fn===void 0)try{new Response(new ReadableStream),fn=!0}catch{fn=!1}fn?de(me.body):me.blob().then(de)}(K,me=>{const de=new le.Response(me,X);Pn(),hr&&hr.then(Te=>Te.put(oo(V.url),de)).catch(Te=>li(Te.message))}))}(h,M,z),p=!0,a(null,B,A.headers.get("Cache-Control"),A.headers.get("Expires")))}).catch(B=>{m||a(new Error(B.message))})};return _?function(A,M){if(Pn(),!hr)return M(null);const z=oo(A.url);hr.then(B=>{B.match(z).then(V=>{const K=function(G){if(!G)return!1;const X=new Date(G.headers.get("Expires")||0),Y=sr(G.headers.get("Cache-Control")||"");return X>Date.now()&&!Y["no-cache"]}(V);B.delete(z),K&&B.put(z,V.clone()),M(null,V,K)}).catch(M)}).catch(M)}(h,b):b(null,null),{cancel:()=>{m=!0,p||c.abort()}}}(t,e);if(jr()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(n,a){const c=new le.XMLHttpRequest;c.open(n.method||"GET",n.url,!0),n.type==="arrayBuffer"&&(c.responseType="arraybuffer");for(const h in n.headers)c.setRequestHeader(h,n.headers[h]);return n.type==="json"&&(c.responseType="text",c.setRequestHeader("Accept","application/json")),c.withCredentials=n.credentials==="include",c.onerror=()=>{a(new Error(c.statusText))},c.onload=()=>{if((c.status>=200&&c.status<300||c.status===0)&&c.response!==null){let h=c.response;if(n.type==="json")try{h=JSON.parse(c.response)}catch(p){return a(p)}a(null,h,c.getResponseHeader("Cache-Control"),c.getResponseHeader("Expires"))}else a(new mn(c.statusText,c.status,n.url))},c.send(n.body),{cancel:()=>c.abort()}}(t,e)},so=function(t,e){return Ln(xi(t,{type:"arrayBuffer"}),e)};function $s(t){const e=le.document.createElement("a");return e.href=t,e.protocol===le.document.location.protocol&&e.host===le.document.location.host}const H="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let k,L;k=[],L=0;const W=function(t,e){if(Je.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),L>=$e.MAX_PARALLEL_IMAGE_REQUESTS){const c={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return k.push(c),c}L++;let i=!1;const n=()=>{if(!i)for(i=!0,L--;k.length&&L<$e.MAX_PARALLEL_IMAGE_REQUESTS;){const c=k.shift(),{requestParameters:h,callback:p,cancelled:m}=c;m||(c.cancel=W(h,p).cancel)}},a=so(t,(c,h,p,m)=>{n(),c?e(c):h&&(le.createImageBitmap?function(_,x){const b=new le.Blob([new Uint8Array(_)],{type:"image/png"});le.createImageBitmap(b).then(T=>{x(null,T)}).catch(T=>{x(new Error(`Could not load image because of ${T.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(h,(_,x)=>e(_,x,p,m)):function(_,x){const b=new le.Image,T=le.URL;b.onload=()=>{x(null,b),T.revokeObjectURL(b.src),b.onload=null,le.requestAnimationFrame(()=>{b.src=H})},b.onerror=()=>x(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 A=new le.Blob([new Uint8Array(_)],{type:"image/png"});b.src=_.byteLength?T.createObjectURL(A):H}(h,(_,x)=>e(_,x,p,m)))});return{cancel:()=>{a.cancel(),n()}}},Q="NO_ACCESS_TOKEN";function oe(t){return t.indexOf("mapbox:")===0}function ue(t){return $e.API_URL_REGEX.test(t)}function ce(t){return $e.API_CDN_URL_REGEX.test(t)}function ne(t){return $e.API_STYLE_REGEX.test(t)&&!xe(t)}function xe(t){return $e.API_SPRITE_REGEX.test(t)}const Ne=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function je(t){const e=t.match(Ne);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function Oe(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const dt="mapbox.eventData";function gt(t){if(!t)return null;const e=t.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent(le.atob(e[1]).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class pt{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const i=gt($e.ACCESS_TOKEN);let n="";return n=i&&i.u?le.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,(a,c)=>String.fromCharCode(+("0x"+c)))):$e.ACCESS_TOKEN||"",e?`${dt}.${e}:${n}`:`${dt}:${n}`}fetchEventData(){const e=Zo("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{const a=le.localStorage.getItem(i);a&&(this.eventData=JSON.parse(a));const c=le.localStorage.getItem(n);c&&(this.anonId=c)}catch{li("Unable to read from LocalStorage")}}saveEventData(){const e=Zo("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{le.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&le.localStorage.setItem(i,JSON.stringify(this.eventData))}catch{li("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,i,n,a){if(!$e.EVENTS_URL)return;const c=je($e.EVENTS_URL);c.params.push(`access_token=${a||$e.ACCESS_TOKEN||""}`);const h={event:this.type,created:new Date(e).toISOString()},p=i?xi(h,i):h,m={url:Oe(c),headers:{"Content-Type":"text/plain"},body:JSON.stringify([p])};this.pendingRequest=function(_,x){return Ln(xi(_,{method:"POST"}),x)}(m,_=>{this.pendingRequest=null,n(_),this.saveEventData(),this.processRequests(a)})}queueRequest(e,i){this.queue.push(e),this.processRequests(i)}}const yt=new class extends pt{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){$e.EVENTS_URL&&$e.ACCESS_TOKEN&&Array.isArray(t)&&t.some(i=>oe(i)||ue(i))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=gt($e.ACCESS_TOKEN),i=e?e.u:$e.ACCESS_TOKEN;let n=i!==this.eventData.tokenU;Ns(this.anonId)||(this.anonId=dn(),n=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const c=new Date(this.eventData.lastSuccess),h=new Date(a),p=(a-this.eventData.lastSuccess)/864e5;n=n||p>=1||p<-1||c.getDate()!==h.getDate()}else n=!0;n?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Qe,skuId:Ct,"enabled.telemetry":!1,userId:this.anonId},c=>{c||(this.eventData.lastSuccess=a,this.eventData.tokenU=i)},t):this.processRequests()}},It=yt.postTurnstileEvent.bind(yt),ci=new class extends pt{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,n){this.skuToken=e,this.errorCb=n,$e.EVENTS_URL&&(i||$e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(Q)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),Ns(this.anonId)||(this.anonId=dn()),this.postEvent(i,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Qe,skuId:Ct,skuToken:this.skuToken,userId:this.anonId},n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},t))}},vi=ci.postMapLoadEvent.bind(ci),Gi=new class extends pt{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){$e.EVENTS_URL&&(t||$e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:e,performanceData:i}=this.queue.shift(),n=function(a){const c=le.performance.getEntriesByType("resource"),h=le.performance.getEntriesByType("mark"),p=function(T){const A={};if(T){for(const M in T)if(M!=="other")for(const z of T[M]){const B=`${M}ResolveRangeMin`,V=`${M}ResolveRangeMax`,K=`${M}RequestCount`,G=`${M}RequestCachedCount`;A[B]=Math.min(A[B]||1/0,z.startTime),A[V]=Math.max(A[V]||-1/0,z.responseEnd);const X=Y=>{A[Y]===void 0&&(A[Y]=0),++A[Y]};z.transferSize!==void 0&&z.transferSize===0&&X(G),X(K)}}return A}(function(T,A){const M={};if(T)for(const z of T){const B=A(z);M[B]===void 0&&(M[B]=[]),M[B].push(z)}return M}(c,Ac)),m=le.devicePixelRatio,_=le.navigator.connection||le.navigator.mozConnection||le.navigator.webkitConnection,x={counters:[],metadata:[],attributes:[]},b=(T,A,M)=>{M!=null&&T.push({name:A,value:M.toString()})};for(const T in p)b(x.counters,T,p[T]);if(a.interactionRange[0]!==1/0&&a.interactionRange[1]!==-1/0&&(b(x.counters,"interactionRangeMin",a.interactionRange[0]),b(x.counters,"interactionRangeMax",a.interactionRange[1])),h)for(const T of Object.keys(ao)){const A=ao[T],M=h.find(z=>z.name===A);M&&b(x.counters,A,M.startTime)}return b(x.counters,"visibilityHidden",a.visibilityHidden),b(x.attributes,"style",function(T){if(T)for(const A of T){const M=A.name.split("?")[0];if(ne(M)){const z=M.split("/").slice(-2);if(z.length===2)return`mapbox://styles/${z[0]}/${z[1]}`}}}(c)),b(x.attributes,"terrainEnabled",a.terrainEnabled?"true":"false"),b(x.attributes,"fogEnabled",a.fogEnabled?"true":"false"),b(x.attributes,"projection",a.projection),b(x.attributes,"zoom",a.zoom),b(x.metadata,"devicePixelRatio",m),b(x.metadata,"connectionEffectiveType",_?_.effectiveType:void 0),b(x.metadata,"navigatorUserAgent",le.navigator.userAgent),b(x.metadata,"screenWidth",le.screen.width),b(x.metadata,"screenHeight",le.screen.height),b(x.metadata,"windowWidth",le.innerWidth),b(x.metadata,"windowHeight",le.innerHeight),b(x.metadata,"mapWidth",a.width/m),b(x.metadata,"mapHeight",a.height/m),b(x.metadata,"webglRenderer",a.renderer),b(x.metadata,"webglVendor",a.vendor),b(x.metadata,"sdkVersion",Qe),b(x.metadata,"sdkIdentifier","mapbox-gl-js"),x}(i);for(const a of n.metadata);for(const a of n.counters);for(const a of n.attributes);this.postEvent(e,n,()=>{},t)}},Ci=Gi.postPerformanceEvent.bind(Gi),Cr=new class extends pt{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,n){if(!$e.API_URL||!$e.SESSION_PATH)return;const a=je($e.API_URL+$e.SESSION_PATH);a.params.push(`sku=${e||""}`),a.params.push(`access_token=${n||$e.ACCESS_TOKEN||""}`);const c={url:Oe(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(h,p){return Ln(xi(h,{method:"GET"}),p)}(c,h=>{this.pendingRequest=null,i(h),this.saveEventData(),this.processRequests(n)})}getSessionAPI(t,e,i,n){this.skuToken=e,this.errorCb=n,$e.SESSION_PATH&&$e.API_URL&&(i||$e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(Q)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},t)}},Di=Cr.getSessionAPI.bind(Cr),Xi=new Set,ao={create:"create",load:"load",fullLoad:"fullLoad"},sh={mark(t){le.performance.mark(t)},measure(t,e,i){le.performance.measure(t,e,i)}};function Ac(t){const e=t.name.split("?")[0];return ce(e)&&e.includes("mapbox-gl.js")?"javascript":ce(e)&&e.includes("mapbox-gl.css")?"css":function(i){return $e.API_FONTS_REGEX.test(i)}(e)?"fontRange":xe(e)?"sprite":ne(e)?"style":function(i){return $e.API_TILEJSON_REGEX.test(i)}(e)?"tilejson":"other"}const Bt=le.performance;function Wa(t){const e=t?t.url.toString():void 0;return Bt.getEntriesByName(e)}let Ho,Xa,qs,Pr;const Vr={now:()=>qs!==void 0?qs:le.performance.now(),setNow(t){qs=t},restoreNow(){qs=void 0},frame(t){const e=le.requestAnimationFrame(t);return{cancel:()=>le.cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:n}=t;Pr||(Pr=le.document.createElement("canvas"));const a=Pr.getContext("2d",{willReadFrequently:!0});if(!a)throw new Error("failed to create canvas 2d context");return(i>Pr.width||n>Pr.height)&&(Pr.width=i,Pr.height=n),a.clearRect(-e,-e,i+2*e,n+2*e),a.drawImage(t,0,0,i,n),a.getImageData(-e,-e,i+2*e,n+2*e)},resolveURL:t=>(Ho||(Ho=le.document.createElement("a")),Ho.href=t,Ho.href),get devicePixelRatio(){return le.devicePixelRatio},get prefersReducedMotion(){return!!le.matchMedia&&(Xa==null&&(Xa=le.matchMedia("(prefers-reduced-motion: reduce)")),Xa.matches)}};function Ha(t,e,i){i[t]&&i[t].indexOf(e)!==-1||(i[t]=i[t]||[],i[t].push(e))}function Ka(t,e,i){if(i&&i[t]){const n=i[t].indexOf(e);n!==-1&&i[t].splice(n,1)}}class Dn{constructor(e,i={}){xi(this,i),this.type=e}}class Gr extends Dn{constructor(e,i={}){super("error",xi({error:e},i))}}class Ko{on(e,i){return this._listeners=this._listeners||{},Ha(e,i,this._listeners),this}off(e,i){return Ka(e,i,this._listeners),Ka(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},Ha(e,i,this._oneTimeListeners),this):new Promise(n=>this.once(e,n))}fire(e,i){typeof e=="string"&&(e=new Dn(e,i||{}));const n=e.type;if(this.listens(n)){e.target=this;const a=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const p of a)p.call(this,e);const c=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const p of c)Ka(n,p,this._oneTimeListeners),p.call(this,e);const h=this._eventedParent;h&&(xi(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),h.fire(e))}else e instanceof Gr&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,i){return this._eventedParent=e,this._eventedParentData=i,this}}var be=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"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":true,"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":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"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":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"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":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"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"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"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":true,"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"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":true,"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":false,"parameters":["zoom"]},"property-type":"data-constant"},"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"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":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"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":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"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"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function $r(t,...e){for(const i of e)for(const n in i)t[n]=i[n];return t}function bi(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Ri(t){if(Array.isArray(t))return t.map(Ri);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=Ri(t[i]);return e}return bi(t)}class Mc extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}var zr=Mc;class Ja{constructor(e,i=[]){this.parent=e,this.bindings={};for(const[n,a]of i)this.bindings[n]=a}concat(e){return new Ja(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var Ic=Ja;const lo={kind:"null"},Ze={kind:"number"},Et={kind:"string"},vt={kind:"boolean"},ar={kind:"color"},Tr={kind:"object"},bt={kind:"value"},lr={kind:"collator"},Jo={kind:"formatted"},Rn={kind:"resolvedImage"};function dr(t,e){return{kind:"array",itemType:t,N:e}}function ni(t){if(t.kind==="array"){const e=ni(t.itemType);return typeof t.N=="number"?`array<${e}, ${t.N}>`:t.itemType.kind==="value"?"array":`array<${e}>`}return t.kind}const Cc=[lo,Ze,Et,vt,ar,Jo,Tr,dr(bt),Rn];function qr(t,e){if(e.kind==="error")return null;if(t.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!qr(t.itemType,e.itemType))&&(typeof t.N!="number"||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if(t.kind==="value"){for(const i of Cc)if(!qr(i,e))return null}}return`Expected ${ni(t)} but found ${ni(e)} instead.`}function Yo(t,e){return e.some(i=>i.kind===t.kind)}function Qo(t,e){return e.some(i=>i==="null"?t===null:i==="array"?Array.isArray(t):i==="object"?t&&!Array.isArray(t)&&typeof t=="object":i===typeof t)}var Ya,Pc={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function es(t){return(t=Math.round(t))<0?0:t>255?255:t}function ts(t){return es(t[t.length-1]==="%"?parseFloat(t)/100*255:parseInt(t))}function Zs(t){return(e=t[t.length-1]==="%"?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function co(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{Ya={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in Pc)return Pc[i].slice();if(i[0]==="#")return i.length===4?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:i.length===7&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var n=i.indexOf("("),a=i.indexOf(")");if(n!==-1&&a+1===i.length){var c=i.substr(0,n),h=i.substr(n+1,a-(n+1)).split(","),p=1;switch(c){case"rgba":if(h.length!==4)return null;p=Zs(h.pop());case"rgb":return h.length!==3?null:[ts(h[0]),ts(h[1]),ts(h[2]),p];case"hsla":if(h.length!==4)return null;p=Zs(h.pop());case"hsl":if(h.length!==3)return null;var m=(parseFloat(h[0])%360+360)%360/360,_=Zs(h[1]),x=Zs(h[2]),b=x<=.5?x*(_+1):x+_-x*_,T=2*x-b;return[es(255*co(T,b,m+1/3)),es(255*co(T,b,m)),es(255*co(T,b,m-1/3)),p];default:return null}}return null}}catch{}class Ki{constructor(e,i,n,a=1){this.r=e,this.g=i,this.b=n,this.a=a}static parse(e){if(!e)return;if(e instanceof Ki)return e;if(typeof e!="string")return;const i=Ya(e);return i?new Ki(i[0]/255*i[3],i[1]/255*i[3],i[2]/255*i[3],i[3]):void 0}toString(){const[e,i,n,a]=this.toArray();return`rgba(${Math.round(e)},${Math.round(i)},${Math.round(n)},${a})`}toArray(){const{r:e,g:i,b:n,a}=this;return a===0?[0,0,0,0]:[255*e/a,255*i/a,255*n/a,a]}toArray01(){const{r:e,g:i,b:n,a}=this;return a===0?[0,0,0,0]:[e/a,i/a,n/a,a]}toArray01PremultipliedAlpha(){const{r:e,g:i,b:n,a}=this;return[e,i,n,a]}}Ki.black=new Ki(0,0,0,1),Ki.white=new Ki(1,1,1,1),Ki.transparent=new Ki(0,0,0,0),Ki.red=new Ki(1,0,0,1),Ki.blue=new Ki(0,0,1,1);var gi=Ki;class Qa{constructor(e,i,n){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class el{constructor(e,i,n,a,c){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=n,this.fontStack=a,this.textColor=c}}class Ji{constructor(e){this.sections=e}static fromString(e){return new Ji([new el(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof Ji?e:Ji.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const i of this.sections){if(i.image){e.push(["image",i.image.name]);continue}e.push(i.text);const n={};i.fontStack&&(n["text-font"]=["literal",i.fontStack.split(",")]),i.scale&&(n["font-scale"]=i.scale),i.textColor&&(n["text-color"]=["rgba"].concat(i.textColor.toArray())),e.push(n)}return e}}class pr{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new pr({name:e,available:!1}):null}serialize(){return["image",this.name]}}function zc(t,e,i,n){return typeof t=="number"&&t>=0&&t<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?n===void 0||typeof n=="number"&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof n=="number"?[t,e,i,n]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function is(t){if(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||t instanceof gi||t instanceof Qa||t instanceof Ji||t instanceof pr)return!0;if(Array.isArray(t)){for(const e of t)if(!is(e))return!1;return!0}if(typeof t=="object"){for(const e in t)if(!is(t[e]))return!1;return!0}return!1}function fi(t){if(t===null)return lo;if(typeof t=="string")return Et;if(typeof t=="boolean")return vt;if(typeof t=="number")return Ze;if(t instanceof gi)return ar;if(t instanceof Qa)return lr;if(t instanceof Ji)return Jo;if(t instanceof pr)return Rn;if(Array.isArray(t)){const e=t.length;let i;for(const n of t){const a=fi(n);if(i){if(i===a)continue;i=bt;break}i=a}return dr(i||bt,e)}return Tr}function rs(t){const e=typeof t;return t===null?"":e==="string"||e==="number"||e==="boolean"?String(t):t instanceof gi||t instanceof Ji||t instanceof pr?t.toString():JSON.stringify(t)}class tl{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!is(e[1]))return i.error("invalid value");const n=e[1];let a=fi(n);const c=i.expectedType;return a.kind!=="array"||a.N!==0||!c||c.kind!=="array"||typeof c.N=="number"&&c.N!==0||(a=c),new tl(a,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof gi?["rgba"].concat(this.value.toArray()):this.value instanceof Ji?this.value.serialize():this.value}}var Bn=tl,Ni=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const il={string:Et,number:Ze,boolean:vt,object:Tr};class rl{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let n,a=1;const c=e[0];if(c==="array"){let p,m;if(e.length>2){const _=e[1];if(typeof _!="string"||!(_ in il)||_==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);p=il[_],a++}else p=bt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);m=e[2],a++}n=dr(p,m)}else n=il[c];const h=[];for(;a<e.length;a++){const p=i.parse(e[a],a,bt);if(!p)return null;h.push(p)}return new rl(n,h)}evaluate(e){for(let i=0;i<this.args.length;i++){const n=this.args[i].evaluate(e);if(!qr(this.type,fi(n)))return n;if(i===this.args.length-1)throw new Ni(`Expected value to be of type ${ni(this.type)}, but found ${ni(fi(n))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,i=[e.kind];if(e.kind==="array"){const n=e.itemType;if(n.kind==="string"||n.kind==="number"||n.kind==="boolean"){i.push(n.kind);const a=e.N;(typeof a=="number"||this.args.length>1)&&i.push(a)}}return i.concat(this.args.map(n=>n.serialize()))}}var Zr=rl;class _n{constructor(e){this.type=Jo,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&typeof n=="object")return i.error("First argument must be an image or text section.");const a=[];let c=!1;for(let h=1;h<=e.length-1;++h){const p=e[h];if(c&&typeof p=="object"&&!Array.isArray(p)){c=!1;let m=null;if(p["font-scale"]&&(m=i.parse(p["font-scale"],1,Ze),!m))return null;let _=null;if(p["text-font"]&&(_=i.parse(p["text-font"],1,dr(Et)),!_))return null;let x=null;if(p["text-color"]&&(x=i.parse(p["text-color"],1,ar),!x))return null;const b=a[a.length-1];b.scale=m,b.font=_,b.textColor=x}else{const m=i.parse(e[h],1,bt);if(!m)return null;const _=m.type.kind;if(_!=="string"&&_!=="value"&&_!=="null"&&_!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,a.push({content:m,scale:null,font:null,textColor:null})}}return new _n(a)}evaluate(e){return new Ji(this.sections.map(i=>{const n=i.content.evaluate(e);return fi(n)===Rn?new el("",n,null,null,null):new el(rs(n),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null)}))}eachChild(e){for(const i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const i of this.sections){e.push(i.content.serialize());const n={};i.scale&&(n["font-scale"]=i.scale.serialize()),i.font&&(n["text-font"]=i.font.serialize()),i.textColor&&(n["text-color"]=i.textColor.serialize()),e.push(n)}return e}}class Ws{constructor(e){this.type=Rn,this.input=e}static parse(e,i){if(e.length!==2)return i.error("Expected two arguments.");const n=i.parse(e[1],1,Et);return n?new Ws(n):i.error("No image name provided.")}evaluate(e){const i=this.input.evaluate(e),n=pr.fromString(i);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(i)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const ah={"to-boolean":vt,"to-color":ar,"to-number":Ze,"to-string":Et};class nl{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const n=e[0];if((n==="to-boolean"||n==="to-string")&&e.length!==2)return i.error("Expected one argument.");const a=ah[n],c=[];for(let h=1;h<e.length;h++){const p=i.parse(e[h],h,bt);if(!p)return null;c.push(p)}return new nl(a,c)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let i,n;for(const a of this.args){if(i=a.evaluate(e),n=null,i instanceof gi)return i;if(typeof i=="string"){const c=e.parseColor(i);if(c)return c}else if(Array.isArray(i)&&(n=i.length<3||i.length>4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:zc(i[0],i[1],i[2],i[3]),!n))return new gi(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new Ni(n||`Could not parse color from value '${typeof i=="string"?i:String(JSON.stringify(i))}'`)}if(this.type.kind==="number"){let i=null;for(const n of this.args){if(i=n.evaluate(e),i===null)return 0;const a=Number(i);if(!isNaN(a))return a}throw new Ni(`Could not convert ${JSON.stringify(i)} to number.`)}return this.type.kind==="formatted"?Ji.fromString(rs(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?pr.fromString(rs(this.args[0].evaluate(e))):rs(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new _n([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Ws(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}var uo=nl;const kr=["Unknown","Point","LineString","Polygon"];var ol=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?kr[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||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=gi.parse(t)),e}};class On{constructor(e,i,n,a){this.name=e,this.type=i,this._evaluate=n,this.args=a}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,i){const n=e[0],a=On.definitions[n];if(!a)return i.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const c=Array.isArray(a)?a[0]:a.type,h=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,p=h.filter(([_])=>!Array.isArray(_)||_.length===e.length-1);let m=null;for(const[_,x]of p){m=new hl(i.registry,i.path,null,i.scope);const b=[];let T=!1;for(let A=1;A<e.length;A++){const M=e[A],z=Array.isArray(_)?_[A-1]:_.type,B=m.parse(M,1+b.length,z);if(!B){T=!0;break}b.push(B)}if(!T)if(Array.isArray(_)&&_.length!==b.length)m.error(`Expected ${_.length} arguments, but found ${b.length} instead.`);else{for(let A=0;A<b.length;A++){const M=Array.isArray(_)?_[A]:_.type,z=b[A];m.concat(A+1).checkSubtype(M,z.type)}if(m.errors.length===0)return new On(n,c,x,b)}}if(p.length===1)i.errors.push(...m.errors);else{const _=(p.length?p:h).map(([b])=>{return T=b,Array.isArray(T)?`(${T.map(ni).join(", ")})`:`(${ni(T.type)}...)`;var T}).join(" | "),x=[];for(let b=1;b<e.length;b++){const T=i.parse(e[b],1+x.length);if(!T)return null;x.push(ni(T.type))}i.error(`Expected arguments of type ${_}, but found (${x.join(", ")}) instead.`)}return null}static register(e,i){On.definitions=i;for(const n in i)e[n]=On}}var Wr=On;class ns{constructor(e,i,n){this.type=lr,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(e.length!==2)return i.error("Expected one argument.");const n=e[1];if(typeof n!="object"||Array.isArray(n))return i.error("Collator options argument must be an object.");const a=i.parse(n["case-sensitive"]!==void 0&&n["case-sensitive"],1,vt);if(!a)return null;const c=i.parse(n["diacritic-sensitive"]!==void 0&&n["diacritic-sensitive"],1,vt);if(!c)return null;let h=null;return n.locale&&(h=i.parse(n.locale,1,Et),!h)?null:new ns(a,c,h)}evaluate(e){return new Qa(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Xr=8192;function Xs(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function ho(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function os(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,a=Math.pow(2,e.z);return[Math.round(i*a*Xr),Math.round(n*a*Xr)]}function kc(t,e,i){const n=t[0]-e[0],a=t[1]-e[1],c=t[0]-i[0],h=t[1]-i[1];return n*h-c*a==0&&n*c<=0&&a*h<=0}function Hs(t,e){let i=!1;for(let h=0,p=e.length;h<p;h++){const m=e[h];for(let _=0,x=m.length;_<x-1;_++){if(kc(t,m[_],m[_+1]))return!1;(a=m[_])[1]>(n=t)[1]!=(c=m[_+1])[1]>n[1]&&n[0]<(c[0]-a[0])*(n[1]-a[1])/(c[1]-a[1])+a[0]&&(i=!i)}}var n,a,c;return i}function sl(t,e){for(let i=0;i<e.length;i++)if(Hs(t,e[i]))return!0;return!1}function al(t,e,i,n){const a=n[0]-i[0],c=n[1]-i[1],h=(t[0]-i[0])*c-a*(t[1]-i[1]),p=(e[0]-i[0])*c-a*(e[1]-i[1]);return h>0&&p<0||h<0&&p>0}function po(t,e,i){for(const _ of i)for(let x=0;x<_.length-1;++x)if((p=[(h=_[x+1])[0]-(c=_[x])[0],h[1]-c[1]])[0]*(m=[(a=e)[0]-(n=t)[0],a[1]-n[1]])[1]-p[1]*m[0]!=0&&al(n,a,c,h)&&al(c,h,n,a))return!0;var n,a,c,h,p,m;return!1}function Ot(t,e){for(let i=0;i<t.length;++i)if(!Hs(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(po(t[i],t[i+1],e))return!1;return!0}function lh(t,e){for(let i=0;i<e.length;i++)if(Ot(t,e[i]))return!0;return!1}function ll(t,e,i){const n=[];for(let a=0;a<t.length;a++){const c=[];for(let h=0;h<t[a].length;h++){const p=os(t[a][h],i);Xs(e,p),c.push(p)}n.push(c)}return n}function Lc(t,e,i){const n=[];for(let a=0;a<t.length;a++){const c=ll(t[a],e,i);n.push(c)}return n}function cl(t,e,i,n){if(t[0]<i[0]||t[0]>i[2]){const a=.5*n;let c=t[0]-i[0]>a?-n:i[0]-t[0]>a?n:0;c===0&&(c=t[0]-i[2]>a?-n:i[2]-t[0]>a?n:0),t[0]+=c}Xs(e,t)}function Dc(t,e,i,n){const a=Math.pow(2,n.z)*Xr,c=[n.x*Xr,n.y*Xr],h=[];if(!t)return h;for(const p of t)for(const m of p){const _=[m.x+c[0],m.y+c[1]];cl(_,e,i,a),h.push(_)}return h}function ul(t,e,i,n){const a=Math.pow(2,n.z)*Xr,c=[n.x*Xr,n.y*Xr],h=[];if(!t)return h;for(const m of t){const _=[];for(const x of m){const b=[x.x+c[0],x.y+c[1]];Xs(e,b),_.push(b)}h.push(_)}if(e[2]-e[0]<=a/2){(p=e)[0]=p[1]=1/0,p[2]=p[3]=-1/0;for(const m of h)for(const _ of m)cl(_,e,i,a)}var p;return h}class fo{constructor(e,i){this.type=vt,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(is(e[1])){const n=e[1];if(n.type==="FeatureCollection")for(let a=0;a<n.features.length;++a){const c=n.features[a].geometry.type;if(c==="Polygon"||c==="MultiPolygon")return new fo(n,n.features[a].geometry)}else if(n.type==="Feature"){const a=n.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new fo(n,n.geometry)}else if(n.type==="Polygon"||n.type==="MultiPolygon")return new fo(n,n)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(i,n){const a=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],h=i.canonicalID();if(!h)return!1;if(n.type==="Polygon"){const p=ll(n.coordinates,c,h),m=Dc(i.geometry(),a,c,h);if(!ho(a,c))return!1;for(const _ of m)if(!Hs(_,p))return!1}if(n.type==="MultiPolygon"){const p=Lc(n.coordinates,c,h),m=Dc(i.geometry(),a,c,h);if(!ho(a,c))return!1;for(const _ of m)if(!sl(_,p))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(i,n){const a=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],h=i.canonicalID();if(!h)return!1;if(n.type==="Polygon"){const p=ll(n.coordinates,c,h),m=ul(i.geometry(),a,c,h);if(!ho(a,c))return!1;for(const _ of m)if(!Ot(_,p))return!1}if(n.type==="MultiPolygon"){const p=Lc(n.coordinates,c,h),m=ul(i.geometry(),a,c,h);if(!ho(a,c))return!1;for(const _ of m)if(!lh(_,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var Ks=fo;function mo(t){if(t instanceof Wr&&(t.name==="get"&&t.args.length===1||t.name==="feature-state"||t.name==="has"&&t.args.length===1||t.name==="properties"||t.name==="geometry-type"||t.name==="id"||/^filter-/.test(t.name))||t instanceof Ks)return!1;let e=!0;return t.eachChild(i=>{e&&!mo(i)&&(e=!1)}),e}function Hr(t){if(t instanceof Wr&&t.name==="feature-state")return!1;let e=!0;return t.eachChild(i=>{e&&!Hr(i)&&(e=!1)}),e}function Fn(t,e){if(t instanceof Wr&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild(n=>{i&&!Fn(n,e)&&(i=!1)}),i}class Js{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(e.length!==2||typeof e[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const n=e[1];return i.scope.has(n)?new Js(n,i.scope.get(n)):i.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var Rc=Js;class ss{constructor(e,i=[],n,a=new Ic,c=[]){this.registry=e,this.path=i,this.key=i.map(h=>`[${h}]`).join(""),this.scope=a,this.errors=c,this.expectedType=n}parse(e,i,n,a,c={}){return i?this.concat(i,n,a)._parse(e,c):this._parse(e,c)}_parse(e,i){function n(a,c,h){return h==="assert"?new Zr(c,[a]):h==="coerce"?new uo(c,[a]):a}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const a=e[0];if(typeof a!="string")return this.error(`Expression name must be a string, but found ${typeof a} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const c=this.registry[a];if(c){let h=c.parse(e,this);if(!h)return null;if(this.expectedType){const p=this.expectedType,m=h.type;if(p.kind!=="string"&&p.kind!=="number"&&p.kind!=="boolean"&&p.kind!=="object"&&p.kind!=="array"||m.kind!=="value")if(p.kind!=="color"&&p.kind!=="formatted"&&p.kind!=="resolvedImage"||m.kind!=="value"&&m.kind!=="string"){if(this.checkSubtype(p,m))return null}else h=n(h,p,i.typeAnnotation||"coerce");else h=n(h,p,i.typeAnnotation||"assert")}if(!(h instanceof Bn)&&h.type.kind!=="resolvedImage"&&dl(h)){const p=new ol;try{h=new Bn(h.type,h.evaluate(p))}catch(m){return this.error(m.message),null}}return h}return this.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,n){const a=typeof e=="number"?this.path.concat(e):this.path,c=n?this.scope.concat(n):this.scope;return new ss(this.registry,a,i||null,c,this.errors)}error(e,...i){const n=`${this.key}${i.map(a=>`[${a}]`).join("")}`;this.errors.push(new zr(n,e))}checkSubtype(e,i){const n=qr(e,i);return n&&this.error(n),n}}var hl=ss;function dl(t){if(t instanceof Rc)return dl(t.boundExpression);if(t instanceof Wr&&t.name==="error"||t instanceof ns||t instanceof Ks)return!1;const e=t instanceof uo||t instanceof Zr;let i=!0;return t.eachChild(n=>{i=e?i&&dl(n):i&&n instanceof Bn}),!!i&&mo(t)&&Fn(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Ys(t,e){const i=t.length-1;let n,a,c=0,h=i,p=0;for(;c<=h;)if(p=Math.floor((c+h)/2),n=t[p],a=t[p+1],n<=e){if(p===i||e<a)return p;c=p+1}else{if(!(n>e))throw new Ni("Input is not a number.");h=p-1}return 0}class Qs{constructor(e,i,n){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[a,c]of n)this.labels.push(a),this.outputs.push(c)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");const n=i.parse(e[1],1,Ze);if(!n)return null;const a=[];let c=null;i.expectedType&&i.expectedType.kind!=="value"&&(c=i.expectedType);for(let h=1;h<e.length;h+=2){const p=h===1?-1/0:e[h],m=e[h+1],_=h,x=h+1;if(typeof p!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',_);if(a.length&&a[a.length-1][0]>=p)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',_);const b=i.parse(m,x,c);if(!b)return null;c=c||b.type,a.push([p,b])}return new Qs(c,n,a)}evaluate(e){const i=this.labels,n=this.outputs;if(i.length===1)return n[0].evaluate(e);const a=this.input.evaluate(e);if(a<=i[0])return n[0].evaluate(e);const c=i.length;return a>=i[c-1]?n[c-1].evaluate(e):n[Ys(i,a)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let i=0;i<this.labels.length;i++)i>0&&e.push(this.labels[i]),e.push(this.outputs[i].serialize());return e}}var pl=Qs;function Pt(t,e,i){return t*(1-i)+e*i}var as=Object.freeze({__proto__:null,array:function(t,e,i){return t.map((n,a)=>Pt(n,e[a],i))},color:function(t,e,i){return new gi(Pt(t.r,e.r,i),Pt(t.g,e.g,i),Pt(t.b,e.b,i),Pt(t.a,e.a,i))},number:Pt});const Bc=.95047,fl=1.08883,Oc=4/29,Un=6/29,ml=3*Un*Un,ch=Un*Un*Un,uh=Math.PI/180,hh=180/Math.PI;function _l(t){return t>ch?Math.pow(t,1/3):t/ml+Oc}function gl(t){return t>Un?t*t*t:ml*(t-Oc)}function yl(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function ea(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Fc(t){const e=ea(t.r),i=ea(t.g),n=ea(t.b),a=_l((.4124564*e+.3575761*i+.1804375*n)/Bc),c=_l((.2126729*e+.7151522*i+.072175*n)/1);return{l:116*c-16,a:500*(a-c),b:200*(c-_l((.0193339*e+.119192*i+.9503041*n)/fl)),alpha:t.a}}function Uc(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*gl(e),i=Bc*gl(i),n=fl*gl(n),new gi(yl(3.2404542*i-1.5371385*e-.4985314*n),yl(-.969266*i+1.8760108*e+.041556*n),yl(.0556434*i-.2040259*e+1.0572252*n),t.alpha)}function dh(t,e,i){const n=e-t;return t+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const ls={forward:Fc,reverse:Uc,interpolate:function(t,e,i){return{l:Pt(t.l,e.l,i),a:Pt(t.a,e.a,i),b:Pt(t.b,e.b,i),alpha:Pt(t.alpha,e.alpha,i)}}},_o={forward:function(t){const{l:e,a:i,b:n}=Fc(t),a=Math.atan2(n,i)*hh;return{h:a<0?a+360:a,c:Math.sqrt(i*i+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*uh,i=t.c;return Uc({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:dh(t.h,e.h,i),c:Pt(t.c,e.c,i),l:Pt(t.l,e.l,i),alpha:Pt(t.alpha,e.alpha,i)}}};var xl=Object.freeze({__proto__:null,hcl:_o,lab:ls});class cs{constructor(e,i,n,a,c){this.type=e,this.operator=i,this.interpolation=n,this.input=a,this.labels=[],this.outputs=[];for(const[h,p]of c)this.labels.push(h),this.outputs.push(p)}static interpolationFactor(e,i,n,a){let c=0;if(e.name==="exponential")c=vl(i,e.base,n,a);else if(e.name==="linear")c=vl(i,1,n,a);else if(e.name==="cubic-bezier"){const h=e.controlPoints;c=new ti(h[0],h[1],h[2],h[3]).solve(vl(i,1,n,a))}return c}static parse(e,i){let[n,a,c,...h]=e;if(!Array.isArray(a)||a.length===0)return i.error("Expected an interpolation type expression.",1);if(a[0]==="linear")a={name:"linear"};else if(a[0]==="exponential"){const _=a[1];if(typeof _!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:_}}else{if(a[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);{const _=a.slice(1);if(_.length!==4||_.some(x=>typeof x!="number"||x<0||x>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:_}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(c=i.parse(c,2,Ze),!c)return null;const p=[];let m=null;n==="interpolate-hcl"||n==="interpolate-lab"?m=ar:i.expectedType&&i.expectedType.kind!=="value"&&(m=i.expectedType);for(let _=0;_<h.length;_+=2){const x=h[_],b=h[_+1],T=_+3,A=_+4;if(typeof x!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',T);if(p.length&&p[p.length-1][0]>=x)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',T);const M=i.parse(b,A,m);if(!M)return null;m=m||M.type,p.push([x,M])}return m.kind==="number"||m.kind==="color"||m.kind==="array"&&m.itemType.kind==="number"&&typeof m.N=="number"?new cs(m,n,a,c,p):i.error(`Type ${ni(m)} is not interpolatable.`)}evaluate(e){const i=this.labels,n=this.outputs;if(i.length===1)return n[0].evaluate(e);const a=this.input.evaluate(e);if(a<=i[0])return n[0].evaluate(e);const c=i.length;if(a>=i[c-1])return n[c-1].evaluate(e);const h=Ys(i,a),p=cs.interpolationFactor(this.interpolation,a,i[h],i[h+1]),m=n[h].evaluate(e),_=n[h+1].evaluate(e);return this.operator==="interpolate"?as[this.type.kind.toLowerCase()](m,_,p):this.operator==="interpolate-hcl"?_o.reverse(_o.interpolate(_o.forward(m),_o.forward(_),p)):ls.reverse(ls.interpolate(ls.forward(m),ls.forward(_),p))}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const i=[this.operator,e,this.input.serialize()];for(let n=0;n<this.labels.length;n++)i.push(this.labels[n],this.outputs[n].serialize());return i}}function vl(t,e,i,n){const a=n-i,c=t-i;return a===0?0:e===1?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)}var Lr=cs;class ta{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expectected at least one argument.");let n=null;const a=i.expectedType;a&&a.kind!=="value"&&(n=a);const c=[];for(const p of e.slice(1)){const m=i.parse(p,1+c.length,n,void 0,{typeAnnotation:"omit"});if(!m)return null;n=n||m.type,c.push(m)}const h=a&&c.some(p=>qr(a,p.type));return new ta(h?bt:n,c)}evaluate(e){let i,n=null,a=0;for(const c of this.args){if(a++,n=c.evaluate(e),n&&n instanceof pr&&!n.available&&(i||(i=n),n=null,a===this.args.length))return i;if(n!==null)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(i=>{e.push(i.serialize())}),e}}var bl=ta;class ia{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const n=[];for(let c=1;c<e.length-1;c+=2){const h=e[c];if(typeof h!="string")return i.error(`Expected string, but found ${typeof h} instead.`,c);if(/[^a-zA-Z0-9_]/.test(h))return i.error("Variable names must contain only alphanumeric characters or '_'.",c);const p=i.parse(e[c+1],c+1);if(!p)return null;n.push([h,p])}const a=i.parse(e[e.length-1],e.length-1,i.expectedType,n);return a?new ia(n,a):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[i,n]of this.bindings)e.push(i,n.serialize());return e.push(this.result.serialize()),e}}var Nc=ia;class wl{constructor(e,i,n){this.type=e,this.index=i,this.input=n}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,Ze),a=i.parse(e[2],2,dr(i.expectedType||bt));return n&&a?new wl(a.type.itemType,n,a):null}evaluate(e){const i=this.index.evaluate(e),n=this.input.evaluate(e);if(i<0)throw new Ni(`Array index out of bounds: ${i} < 0.`);if(i>=n.length)throw new Ni(`Array index out of bounds: ${i} > ${n.length-1}.`);if(i!==Math.floor(i))throw new Ni(`Array index must be an integer, but found ${i} instead.`);return n[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var ph=wl;class Tl{constructor(e,i){this.type=vt,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,bt),a=i.parse(e[2],2,bt);return n&&a?Yo(n.type,[vt,Et,Ze,lo,bt])?new Tl(n,a):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${ni(n.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(n==null)return!1;if(!Qo(i,["boolean","string","number","null"]))throw new Ni(`Expected first argument to be of type boolean, string, number or null, but found ${ni(fi(i))} instead.`);if(!Qo(n,["string","array"]))throw new Ni(`Expected second argument to be of type array or string, but found ${ni(fi(n))} instead.`);return n.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var ra=Tl;class us{constructor(e,i,n){this.type=Ze,this.needle=e,this.haystack=i,this.fromIndex=n}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,bt),a=i.parse(e[2],2,bt);if(!n||!a)return null;if(!Yo(n.type,[vt,Et,Ze,lo,bt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${ni(n.type)} instead`);if(e.length===4){const c=i.parse(e[3],3,Ze);return c?new us(n,a,c):null}return new us(n,a)}evaluate(e){const i=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!Qo(i,["boolean","string","number","null"]))throw new Ni(`Expected first argument to be of type boolean, string, number or null, but found ${ni(fi(i))} instead.`);if(!Qo(n,["string","array"]))throw new Ni(`Expected second argument to be of type array or string, but found ${ni(fi(n))} instead.`);if(this.fromIndex){const a=this.fromIndex.evaluate(e);return n.indexOf(i,a)}return n.indexOf(i)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var jc=us;class El{constructor(e,i,n,a,c,h){this.inputType=e,this.type=i,this.input=n,this.cases=a,this.outputs=c,this.otherwise=h}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let n,a;i.expectedType&&i.expectedType.kind!=="value"&&(a=i.expectedType);const c={},h=[];for(let _=2;_<e.length-1;_+=2){let x=e[_];const b=e[_+1];Array.isArray(x)||(x=[x]);const T=i.concat(_);if(x.length===0)return T.error("Expected at least one branch label.");for(const M of x){if(typeof M!="number"&&typeof M!="string")return T.error("Branch labels must be numbers or strings.");if(typeof M=="number"&&Math.abs(M)>Number.MAX_SAFE_INTEGER)return T.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof M=="number"&&Math.floor(M)!==M)return T.error("Numeric branch labels must be integer values.");if(n){if(T.checkSubtype(n,fi(M)))return null}else n=fi(M);if(c[String(M)]!==void 0)return T.error("Branch labels must be unique.");c[String(M)]=h.length}const A=i.parse(b,_,a);if(!A)return null;a=a||A.type,h.push(A)}const p=i.parse(e[1],1,bt);if(!p)return null;const m=i.parse(e[e.length-1],e.length-1,a);return m?p.type.kind!=="value"&&i.concat(1).checkSubtype(n,p.type)?null:new El(n,a,p,c,h,m):null}evaluate(e){const i=this.input.evaluate(e);return(fi(i)===this.inputType&&this.outputs[this.cases[i]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],i=Object.keys(this.cases).sort(),n=[],a={};for(const h of i){const p=a[this.cases[h]];p===void 0?(a[this.cases[h]]=n.length,n.push([this.cases[h],[h]])):n[p][1].push(h)}const c=h=>this.inputType.kind==="number"?Number(h):h;for(const[h,p]of n)e.push(p.length===1?c(p[0]):p.map(c)),e.push(this.outputs[h].serialize());return e.push(this.otherwise.serialize()),e}}var fh=El;class Sl{constructor(e,i,n){this.type=e,this.branches=i,this.otherwise=n}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let n;i.expectedType&&i.expectedType.kind!=="value"&&(n=i.expectedType);const a=[];for(let h=1;h<e.length-1;h+=2){const p=i.parse(e[h],h,vt);if(!p)return null;const m=i.parse(e[h+1],h+1,n);if(!m)return null;a.push([p,m]),n=n||m.type}const c=i.parse(e[e.length-1],e.length-1,n);return c?new Sl(n,a,c):null}evaluate(e){for(const[i,n]of this.branches)if(i.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[i,n]of this.branches)e(i),e(n);e(this.otherwise)}outputDefined(){return this.branches.every(([e,i])=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(i=>{e.push(i.serialize())}),e}}var Vc=Sl;class hs{constructor(e,i,n,a){this.type=e,this.input=i,this.beginIndex=n,this.endIndex=a}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,bt),a=i.parse(e[2],2,Ze);if(!n||!a)return null;if(!Yo(n.type,[dr(bt),Et,bt]))return i.error(`Expected first argument to be of type array or string, but found ${ni(n.type)} instead`);if(e.length===4){const c=i.parse(e[3],3,Ze);return c?new hs(n.type,n,a,c):null}return new hs(n.type,n,a)}evaluate(e){const i=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!Qo(i,["string","array"]))throw new Ni(`Expected first argument to be of type array or string, but found ${ni(fi(i))} instead.`);if(this.endIndex){const a=this.endIndex.evaluate(e);return i.slice(n,a)}return i.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Gc=hs;function na(t,e){return t==="=="||t==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function $c(t,e,i,n){return n.compare(e,i)===0}function go(t,e,i){const n=t!=="=="&&t!=="!=";return class Km{constructor(c,h,p){this.type=vt,this.lhs=c,this.rhs=h,this.collator=p,this.hasUntypedArgument=c.type.kind==="value"||h.type.kind==="value"}static parse(c,h){if(c.length!==3&&c.length!==4)return h.error("Expected two or three arguments.");const p=c[0];let m=h.parse(c[1],1,bt);if(!m)return null;if(!na(p,m.type))return h.concat(1).error(`"${p}" comparisons are not supported for type '${ni(m.type)}'.`);let _=h.parse(c[2],2,bt);if(!_)return null;if(!na(p,_.type))return h.concat(2).error(`"${p}" comparisons are not supported for type '${ni(_.type)}'.`);if(m.type.kind!==_.type.kind&&m.type.kind!=="value"&&_.type.kind!=="value")return h.error(`Cannot compare types '${ni(m.type)}' and '${ni(_.type)}'.`);n&&(m.type.kind==="value"&&_.type.kind!=="value"?m=new Zr(_.type,[m]):m.type.kind!=="value"&&_.type.kind==="value"&&(_=new Zr(m.type,[_])));let x=null;if(c.length===4){if(m.type.kind!=="string"&&_.type.kind!=="string"&&m.type.kind!=="value"&&_.type.kind!=="value")return h.error("Cannot use collator to compare non-string types.");if(x=h.parse(c[3],3,lr),!x)return null}return new Km(m,_,x)}evaluate(c){const h=this.lhs.evaluate(c),p=this.rhs.evaluate(c);if(n&&this.hasUntypedArgument){const m=fi(h),_=fi(p);if(m.kind!==_.kind||m.kind!=="string"&&m.kind!=="number")throw new Ni(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${m.kind}, ${_.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const m=fi(h),_=fi(p);if(m.kind!=="string"||_.kind!=="string")return e(c,h,p)}return this.collator?i(c,h,p,this.collator.evaluate(c)):e(c,h,p)}eachChild(c){c(this.lhs),c(this.rhs),this.collator&&c(this.collator)}outputDefined(){return!0}serialize(){const c=[t];return this.eachChild(h=>{c.push(h.serialize())}),c}}}const mh=go("==",function(t,e,i){return e===i},$c),_h=go("!=",function(t,e,i){return e!==i},function(t,e,i,n){return!$c(0,e,i,n)}),gh=go("<",function(t,e,i){return e<i},function(t,e,i,n){return n.compare(e,i)<0}),yh=go(">",function(t,e,i){return e>i},function(t,e,i,n){return n.compare(e,i)>0}),xh=go("<=",function(t,e,i){return e<=i},function(t,e,i,n){return n.compare(e,i)<=0}),qc=go(">=",function(t,e,i){return e>=i},function(t,e,i,n){return n.compare(e,i)>=0});class oa{constructor(e,i,n,a,c,h){this.type=Et,this.number=e,this.locale=i,this.currency=n,this.unit=a,this.minFractionDigits=c,this.maxFractionDigits=h}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");const n=i.parse(e[1],1,Ze);if(!n)return null;const a=e[2];if(typeof a!="object"||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let c=null;if(a.locale&&(c=i.parse(a.locale,1,Et),!c))return null;let h=null;if(a.currency&&(h=i.parse(a.currency,1,Et),!h))return null;let p=null;if(a.unit&&(p=i.parse(a.unit,1,Et),!p))return null;let m=null;if(a["min-fraction-digits"]&&(m=i.parse(a["min-fraction-digits"],1,Ze),!m))return null;let _=null;return a["max-fraction-digits"]&&(_=i.parse(a["max-fraction-digits"],1,Ze),!_)?null:new oa(n,c,h,p,m,_)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class yo{constructor(e){this.type=Ze,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const n=i.parse(e[1],1);return n?n.type.kind!=="array"&&n.type.kind!=="string"&&n.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${ni(n.type)} instead.`):new yo(n):null}evaluate(e){const i=this.input.evaluate(e);if(typeof i=="string"||Array.isArray(i))return i.length;throw new Ni(`Expected value to be of type string or array, but found ${ni(fi(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}const Zc={"==":mh,"!=":_h,">":yh,"<":gh,">=":qc,"<=":xh,array:Zr,at:ph,boolean:Zr,case:Vc,coalesce:bl,collator:ns,format:_n,image:Ws,in:ra,"index-of":jc,interpolate:Lr,"interpolate-hcl":Lr,"interpolate-lab":Lr,length:yo,let:Nc,literal:Bn,match:fh,number:Zr,"number-format":oa,object:Zr,slice:Gc,step:pl,string:Zr,"to-boolean":uo,"to-color":uo,"to-number":uo,"to-string":uo,var:Rc,within:Ks};function Wc(t,[e,i,n,a]){e=e.evaluate(t),i=i.evaluate(t),n=n.evaluate(t);const c=a?a.evaluate(t):1,h=zc(e,i,n,c);if(h)throw new Ni(h);return new gi(e/255*c,i/255*c,n/255*c,c)}function Kr(t,e){return t in e}function sa(t,e){const i=e[t];return i===void 0?null:i}function fr(t){return{type:t}}Wr.register(Zc,{error:[{kind:"error"},[Et],(t,[e])=>{throw new Ni(e.evaluate(t))}],typeof:[Et,[bt],(t,[e])=>ni(fi(e.evaluate(t)))],"to-rgba":[dr(Ze,4),[ar],(t,[e])=>e.evaluate(t).toArray()],rgb:[ar,[Ze,Ze,Ze],Wc],rgba:[ar,[Ze,Ze,Ze,Ze],Wc],has:{type:vt,overloads:[[[Et],(t,[e])=>Kr(e.evaluate(t),t.properties())],[[Et,Tr],(t,[e,i])=>Kr(e.evaluate(t),i.evaluate(t))]]},get:{type:bt,overloads:[[[Et],(t,[e])=>sa(e.evaluate(t),t.properties())],[[Et,Tr],(t,[e,i])=>sa(e.evaluate(t),i.evaluate(t))]]},"feature-state":[bt,[Et],(t,[e])=>sa(e.evaluate(t),t.featureState||{})],properties:[Tr,[],t=>t.properties()],"geometry-type":[Et,[],t=>t.geometryType()],id:[bt,[],t=>t.id()],zoom:[Ze,[],t=>t.globals.zoom],pitch:[Ze,[],t=>t.globals.pitch||0],"distance-from-center":[Ze,[],t=>t.distanceFromCenter()],"heatmap-density":[Ze,[],t=>t.globals.heatmapDensity||0],"line-progress":[Ze,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[Ze,[],t=>t.globals.skyRadialProgress||0],accumulated:[bt,[],t=>t.globals.accumulated===void 0?null:t.globals.accumulated],"+":[Ze,fr(Ze),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Ze,fr(Ze),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Ze,overloads:[[[Ze,Ze],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Ze],(t,[e])=>-e.evaluate(t)]]},"/":[Ze,[Ze,Ze],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Ze,[Ze,Ze],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Ze,[],()=>Math.LN2],pi:[Ze,[],()=>Math.PI],e:[Ze,[],()=>Math.E],"^":[Ze,[Ze,Ze],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Ze,[Ze],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Ze,[Ze],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Ze,[Ze],(t,[e])=>Math.log(e.evaluate(t))],log2:[Ze,[Ze],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Ze,[Ze],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Ze,[Ze],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Ze,[Ze],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Ze,[Ze],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Ze,[Ze],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Ze,[Ze],(t,[e])=>Math.atan(e.evaluate(t))],min:[Ze,fr(Ze),(t,e)=>Math.min(...e.map(i=>i.evaluate(t)))],max:[Ze,fr(Ze),(t,e)=>Math.max(...e.map(i=>i.evaluate(t)))],abs:[Ze,[Ze],(t,[e])=>Math.abs(e.evaluate(t))],round:[Ze,[Ze],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ze,[Ze],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Ze,[Ze],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[vt,[Et,bt],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[vt,[bt],(t,[e])=>t.id()===e.value],"filter-type-==":[vt,[Et],(t,[e])=>t.geometryType()===e.value],"filter-<":[vt,[Et,bt],(t,[e,i])=>{const n=t.properties()[e.value],a=i.value;return typeof n==typeof a&&n<a}],"filter-id-<":[vt,[bt],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<n}],"filter->":[vt,[Et,bt],(t,[e,i])=>{const n=t.properties()[e.value],a=i.value;return typeof n==typeof a&&n>a}],"filter-id->":[vt,[bt],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-<=":[vt,[Et,bt],(t,[e,i])=>{const n=t.properties()[e.value],a=i.value;return typeof n==typeof a&&n<=a}],"filter-id-<=":[vt,[bt],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<=n}],"filter->=":[vt,[Et,bt],(t,[e,i])=>{const n=t.properties()[e.value],a=i.value;return typeof n==typeof a&&n>=a}],"filter-id->=":[vt,[bt],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[vt,[bt],(t,[e])=>e.value in t.properties()],"filter-has-id":[vt,[],t=>t.id()!==null&&t.id()!==void 0],"filter-type-in":[vt,[dr(Et)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[vt,[dr(bt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[vt,[Et,dr(bt)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[vt,[Et,dr(bt)],(t,[e,i])=>function(n,a,c,h){for(;c<=h;){const p=c+h>>1;if(a[p]===n)return!0;a[p]>n?h=p-1:c=p+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:vt,overloads:[[[vt,vt],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[fr(vt),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:vt,overloads:[[[vt,vt],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[fr(vt),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[vt,[vt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[vt,[Et],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Et,[Et],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Et,[Et],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Et,fr(bt),(t,e)=>e.map(i=>rs(i.evaluate(t))).join("")],"resolved-locale":[Et,[lr],(t,[e])=>e.evaluate(t).resolvedLocale()]});var ds=Zc;function Xc(t){return{result:"success",value:t}}function Nn(t){return{result:"error",value:t}}function xo(t){return t["property-type"]==="data-driven"}function aa(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function la(t){return!!t.expression&&t.expression.interpolated}function zt(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":t===null?"null":typeof t}function ps(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Hc(t){return t}function ca(t,e){const i=e.type==="color",n=t.stops&&typeof t.stops[0][0]=="object",a=n||!(n||t.property!==void 0),c=t.type||(la(e)?"exponential":"interval");if(i&&((t=$r({},t)).stops&&(t.stops=t.stops.map(_=>[_[0],gi.parse(_[1])])),t.default=gi.parse(t.default?t.default:e.default)),t.colorSpace&&t.colorSpace!=="rgb"&&!xl[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let h,p,m;if(c==="exponential")h=Jr;else if(c==="interval")h=ua;else if(c==="categorical"){h=Kc,p=Object.create(null);for(const _ of t.stops)p[_[0]]=_[1];m=typeof t.stops[0][0]}else{if(c!=="identity")throw new Error(`Unknown function type "${c}"`);h=Jc}if(n){const _={},x=[];for(let A=0;A<t.stops.length;A++){const M=t.stops[A],z=M[0].zoom;_[z]===void 0&&(_[z]={zoom:z,type:t.type,property:t.property,default:t.default,stops:[]},x.push(z)),_[z].stops.push([M[0].value,M[1]])}const b=[];for(const A of x)b.push([_[A].zoom,ca(_[A],e)]);const T={name:"linear"};return{kind:"composite",interpolationType:T,interpolationFactor:Lr.interpolationFactor.bind(void 0,T),zoomStops:b.map(A=>A[0]),evaluate:({zoom:A},M)=>Jr({stops:b,base:t.base},e,A).evaluate(A,M)}}if(a){const _=c==="exponential"?{name:"exponential",base:t.base!==void 0?t.base:1}:null;return{kind:"camera",interpolationType:_,interpolationFactor:Lr.interpolationFactor.bind(void 0,_),zoomStops:t.stops.map(x=>x[0]),evaluate:({zoom:x})=>h(t,e,x,p,m)}}return{kind:"source",evaluate(_,x){const b=x&&x.properties?x.properties[t.property]:void 0;return b===void 0?vo(t.default,e.default):h(t,e,b,p,m)}}}function vo(t,e,i){return t!==void 0?t:e!==void 0?e:i!==void 0?i:void 0}function Kc(t,e,i,n,a){return vo(typeof i===a?n[i]:void 0,t.default,e.default)}function ua(t,e,i){if(zt(i)!=="number")return vo(t.default,e.default);const n=t.stops.length;if(n===1||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const a=Ys(t.stops.map(c=>c[0]),i);return t.stops[a][1]}function Jr(t,e,i){const n=t.base!==void 0?t.base:1;if(zt(i)!=="number")return vo(t.default,e.default);const a=t.stops.length;if(a===1||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[a-1][0])return t.stops[a-1][1];const c=Ys(t.stops.map(x=>x[0]),i),h=function(x,b,T,A){const M=A-T,z=x-T;return M===0?0:b===1?z/M:(Math.pow(b,z)-1)/(Math.pow(b,M)-1)}(i,n,t.stops[c][0],t.stops[c+1][0]),p=t.stops[c][1],m=t.stops[c+1][1];let _=as[e.type]||Hc;if(t.colorSpace&&t.colorSpace!=="rgb"){const x=xl[t.colorSpace];_=(b,T)=>x.reverse(x.interpolate(x.forward(b),x.forward(T),h))}return typeof p.evaluate=="function"?{evaluate(...x){const b=p.evaluate.apply(void 0,x),T=m.evaluate.apply(void 0,x);if(b!==void 0&&T!==void 0)return _(b,T,h)}}:_(p,m,h)}function Jc(t,e,i){return e.type==="color"?i=gi.parse(i):e.type==="formatted"?i=Ji.fromString(i.toString()):e.type==="resolvedImage"?i=pr.fromString(i.toString()):zt(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0),vo(i,t.default,e.default)}class ha{constructor(e,i){this.expression=e,this._warningHistory={},this._evaluator=new ol,this._defaultValue=i?function(n){return n.type==="color"&&(ps(n.default)||Array.isArray(n.default))?new gi(0,0,0,0):n.type==="color"?gi.parse(n.default)||null:n.default===void 0?null:n.default}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null}evaluateWithoutErrorHandling(e,i,n,a,c,h,p,m){return this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=n,this._evaluator.canonical=a||null,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=h,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null,this.expression.evaluate(this._evaluator)}evaluate(e,i,n,a,c,h,p,m){this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=n||null,this._evaluator.canonical=a||null,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null;try{const _=this.expression.evaluate(this._evaluator);if(_==null||typeof _=="number"&&_!=_)return this._defaultValue;if(this._enumValues&&!(_ in this._enumValues))throw new Ni(`Expected value to be one of ${Object.keys(this._enumValues).map(x=>JSON.stringify(x)).join(", ")}, but found ${JSON.stringify(_)} instead.`);return _}catch(_){return this._warningHistory[_.message]||(this._warningHistory[_.message]=!0,typeof console<"u"&&console.warn(_.message)),this._defaultValue}}}function bo(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0]in ds}function wo(t,e){const i=new hl(ds,[],e?function(a){const c={color:ar,string:Et,number:Ze,enum:Et,boolean:vt,formatted:Jo,resolvedImage:Rn};return a.type==="array"?dr(c[a.value]||bt,a.length):c[a.type]}(e):void 0),n=i.parse(t,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?Xc(new ha(n,e)):Nn(i.errors)}class Al{constructor(e,i){this.kind=e,this._styleExpression=i,this.isStateDependent=e!=="constant"&&!Hr(i.expression)}evaluateWithoutErrorHandling(e,i,n,a,c,h){return this._styleExpression.evaluateWithoutErrorHandling(e,i,n,a,c,h)}evaluate(e,i,n,a,c,h){return this._styleExpression.evaluate(e,i,n,a,c,h)}}class fs{constructor(e,i,n,a){this.kind=e,this.zoomStops=n,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!Hr(i.expression),this.interpolationType=a}evaluateWithoutErrorHandling(e,i,n,a,c,h){return this._styleExpression.evaluateWithoutErrorHandling(e,i,n,a,c,h)}evaluate(e,i,n,a,c,h){return this._styleExpression.evaluate(e,i,n,a,c,h)}interpolationFactor(e,i,n){return this.interpolationType?Lr.interpolationFactor(this.interpolationType,e,i,n):0}}function ms(t,e){if((t=wo(t,e)).result==="error")return t;const i=t.value.expression,n=mo(i);if(!n&&!xo(e))return Nn([new zr("","data expressions not supported")]);const a=Fn(i,["zoom","pitch","distance-from-center"]);if(!a&&!aa(e))return Nn([new zr("","zoom expressions not supported")]);const c=pa(i);return c||a?c instanceof zr?Nn([c]):c instanceof Lr&&!la(e)?Nn([new zr("",'"interpolate" expressions cannot be used with this property')]):Xc(c?new fs(n?"camera":"composite",t.value,c.labels,c instanceof Lr?c.interpolation:void 0):new Al(n?"constant":"source",t.value)):Nn([new zr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class da{constructor(e,i){this._parameters=e,this._specification=i,$r(this,ca(this._parameters,this._specification))}static deserialize(e){return new da(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function pa(t){let e=null;if(t instanceof Nc)e=pa(t.result);else if(t instanceof bl){for(const i of t.args)if(e=pa(i),e)break}else(t instanceof pl||t instanceof Lr)&&t.input instanceof Wr&&t.input.name==="zoom"&&(e=t);return e instanceof zr||t.eachChild(i=>{const n=pa(i);n instanceof zr?e=n:!e&&n?e=new zr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new zr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class We{constructor(e,i,n,a){this.message=(e?`${e}: `:"")+n,a&&(this.identifier=a),i!=null&&i.__line__&&(this.line=i.__line__)}}function Er(t){const e=t.key,i=t.value,n=t.valueSpec||{},a=t.objectElementValidators||{},c=t.style,h=t.styleSpec;let p=[];const m=zt(i);if(m!=="object")return[new We(e,i,`object expected, ${m} found`)];for(const _ in i){const x=_.split(".")[0];let b;a[x]?b=a[x]:n[x]?b=$i:a["*"]?b=a["*"]:n["*"]&&(b=$i),b?p=p.concat(b({key:(e&&`${e}.`)+_,value:i[_],valueSpec:n[x]||n["*"],style:c,styleSpec:h,object:i,objectKey:_},i)):p.push(new We(e,i[_],`unknown property "${_}"`))}for(const _ in n)a[_]||n[_].required&&n[_].default===void 0&&i[_]===void 0&&p.push(new We(e,i,`missing required property "${_}"`));return p}function Yc(t){const e=t.value,i=t.valueSpec,n=t.style,a=t.styleSpec,c=t.key,h=t.arrayElementValidator||$i;if(zt(e)!=="array")return[new We(c,e,`array expected, ${zt(e)} found`)];if(i.length&&e.length!==i.length)return[new We(c,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new We(c,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let p={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};a.$version<7&&(p.function=i.function),zt(i.value)==="object"&&(p=i.value);let m=[];for(let _=0;_<e.length;_++)m=m.concat(h({array:e,arrayIndex:_,value:e[_],valueSpec:p,style:n,styleSpec:a,key:`${c}[${_}]`}));return m}function _s(t){const e=t.key,i=t.value,n=t.valueSpec;let a=zt(i);if(a==="number"&&i!=i&&(a="NaN"),a!=="number")return[new We(e,i,`number expected, ${a} found`)];if("minimum"in n){let c=n.minimum;if(zt(n.minimum)==="array"&&(c=n.minimum[t.arrayIndex]),i<c)return[new We(e,i,`${i} is less than the minimum value ${c}`)]}if("maximum"in n){let c=n.maximum;if(zt(n.maximum)==="array"&&(c=n.maximum[t.arrayIndex]),i>c)return[new We(e,i,`${i} is greater than the maximum value ${c}`)]}return[]}function gs(t){const e=t.valueSpec,i=bi(t.value.type);let n,a,c,h={};const p=i!=="categorical"&&t.value.property===void 0,m=!p,_=zt(t.value.stops)==="array"&&zt(t.value.stops[0])==="array"&&zt(t.value.stops[0][0])==="object",x=Er({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(A){if(i==="identity")return[new We(A.key,A.value,'identity function may not have a "stops" property')];let M=[];const z=A.value;return M=M.concat(Yc({key:A.key,value:z,valueSpec:A.valueSpec,style:A.style,styleSpec:A.styleSpec,arrayElementValidator:b})),zt(z)==="array"&&z.length===0&&M.push(new We(A.key,z,"array must have at least one stop")),M},default:function(A){return $i({key:A.key,value:A.value,valueSpec:e,style:A.style,styleSpec:A.styleSpec})}}});return i==="identity"&&p&&x.push(new We(t.key,t.value,'missing required property "property"')),i==="identity"||t.value.stops||x.push(new We(t.key,t.value,'missing required property "stops"')),i==="exponential"&&t.valueSpec.expression&&!la(t.valueSpec)&&x.push(new We(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(m&&!xo(t.valueSpec)?x.push(new We(t.key,t.value,"property functions not supported")):p&&!aa(t.valueSpec)&&x.push(new We(t.key,t.value,"zoom functions not supported"))),i!=="categorical"&&!_||t.value.property!==void 0||x.push(new We(t.key,t.value,'"property" property is required')),x;function b(A){let M=[];const z=A.value,B=A.key;if(zt(z)!=="array")return[new We(B,z,`array expected, ${zt(z)} found`)];if(z.length!==2)return[new We(B,z,`array length 2 expected, length ${z.length} found`)];if(_){if(zt(z[0])!=="object")return[new We(B,z,`object expected, ${zt(z[0])} found`)];if(z[0].zoom===void 0)return[new We(B,z,"object stop key must have zoom")];if(z[0].value===void 0)return[new We(B,z,"object stop key must have value")];const V=bi(z[0].zoom);if(typeof V!="number")return[new We(B,z[0].zoom,"stop zoom values must be numbers")];if(c&&c>V)return[new We(B,z[0].zoom,"stop zoom values must appear in ascending order")];V!==c&&(c=V,a=void 0,h={}),M=M.concat(Er({key:`${B}[0]`,value:z[0],valueSpec:{zoom:{}},style:A.style,styleSpec:A.styleSpec,objectElementValidators:{zoom:_s,value:T}}))}else M=M.concat(T({key:`${B}[0]`,value:z[0],valueSpec:{},style:A.style,styleSpec:A.styleSpec},z));return bo(Ri(z[1]))?M.concat([new We(`${B}[1]`,z[1],"expressions are not allowed in function stops.")]):M.concat($i({key:`${B}[1]`,value:z[1],valueSpec:e,style:A.style,styleSpec:A.styleSpec}))}function T(A,M){const z=zt(A.value),B=bi(A.value),V=A.value!==null?A.value:M;if(n){if(z!==n)return[new We(A.key,V,`${z} stop domain type must match previous stop domain type ${n}`)]}else n=z;if(z!=="number"&&z!=="string"&&z!=="boolean"&&typeof B!="number"&&typeof B!="string"&&typeof B!="boolean")return[new We(A.key,V,"stop domain value must be a number, string, or boolean")];if(z!=="number"&&i!=="categorical"){let K=`number expected, ${z} found`;return xo(e)&&i===void 0&&(K+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new We(A.key,V,K)]}return i!=="categorical"||z!=="number"||typeof B=="number"&&isFinite(B)&&Math.floor(B)===B?i!=="categorical"&&z==="number"&&typeof B=="number"&&typeof a=="number"&&a!==void 0&&B<a?[new We(A.key,V,"stop domain values must appear in ascending order")]:(a=B,i==="categorical"&&B in h?[new We(A.key,V,"stop domain values must be unique")]:(h[B]=!0,[])):[new We(A.key,V,`integer expected, found ${String(B)}`)]}}function Bi(t){const e=(t.expressionContext==="property"?ms:wo)(Ri(t.value),t.valueSpec);if(e.result==="error")return e.value.map(n=>new We(`${t.key}${n.key}`,t.value,n.message));const i=e.value.expression||e.value._styleExpression.expression;if(t.expressionContext==="property"&&t.propertyKey==="text-font"&&!i.outputDefined())return[new We(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if(t.expressionContext==="property"&&t.propertyType==="layout"&&!Hr(i))return[new We(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if(t.expressionContext==="filter")return ys(i,t);if(t.expressionContext&&t.expressionContext.indexOf("cluster")===0){if(!Fn(i,["zoom","feature-state"]))return[new We(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(t.expressionContext==="cluster-initial"&&!mo(i))return[new We(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ys(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const a of e.valueSpec.expression.parameters)i.delete(a);if(i.size===0)return[];const n=[];return t instanceof Wr&&i.has(t.name)?[new We(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild(a=>{n.push(...ys(a,e))}),n)}function fa(t){const e=t.key,i=t.value,n=t.valueSpec,a=[];return Array.isArray(n.values)?n.values.indexOf(bi(i))===-1&&a.push(new We(e,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(n.values).indexOf(bi(i))===-1&&a.push(new We(e,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),a}function Ml(t){if(t===!0||t===!1)return!0;if(!Array.isArray(t)||t.length===0)return!1;switch(t[0]){case"has":return t.length>=2&&t[1]!=="$id"&&t[1]!=="$type";case"in":return t.length>=3&&(typeof t[1]!="string"||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return t.length!==3||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Ml(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function ma(t,e="fill"){if(t==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Ml(t)||(t=Eo(t));const i=t;let n=!0;try{n=function(_){if(!To(_))return _;let x=Ri(_);return _a(x),x=Qc(x),x}(i)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
and paste the contents of this message in the report.
Thank you!
Filter Expression:
${JSON.stringify(i,null,2)}
        `)}const a=be[`filter_${e}`],c=wo(n,a);let h=null;if(c.result==="error")throw new Error(c.value.map(_=>`${_.key}: ${_.message}`).join(", "));h=(_,x,b)=>c.value.evaluate(_,x,{},b);let p=null,m=null;if(n!==i){const _=wo(i,a);if(_.result==="error")throw new Error(_.value.map(x=>`${x.key}: ${x.message}`).join(", "));p=(x,b,T,A,M)=>_.value.evaluate(x,b,{},T,void 0,void 0,A,M),m=!mo(_.value.expression)}return{filter:h,dynamicFilter:p||void 0,needGeometry:eu(n),needFeature:!!m}}function Qc(t){if(!Array.isArray(t))return t;const e=function(i){if(Il.has(i[0])){for(let n=1;n<i.length;n++)if(To(i[n]))return!0}return i}(t);return e===!0?e:e.map(i=>Qc(i))}function _a(t){let e=!1;const i=[];if(t[0]==="case"){for(let n=1;n<t.length-1;n+=2)e=e||To(t[n]),i.push(t[n+1]);i.push(t[t.length-1])}else if(t[0]==="match"){e=e||To(t[1]);for(let n=2;n<t.length-1;n+=2)i.push(t[n+1]);i.push(t[t.length-1])}else if(t[0]==="step"){e=e||To(t[1]);for(let n=1;n<t.length-1;n+=2)i.push(t[n+1])}e&&(t.length=0,t.push("any",...i));for(let n=1;n<t.length;n++)_a(t[n])}function To(t){if(!Array.isArray(t))return!1;if((e=t[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let i=1;i<t.length;i++)if(To(t[i]))return!0;return!1}const Il=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function vh(t,e){return t<e?-1:t>e?1:0}function eu(t){if(!Array.isArray(t))return!1;if(t[0]==="within")return!0;for(let e=1;e<t.length;e++)if(eu(t[e]))return!0;return!1}function Eo(t){if(!t)return!0;const e=t[0];return t.length<=1?e!=="any":e==="=="?Cl(t[1],t[2],"=="):e==="!="?ga(Cl(t[1],t[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Cl(t[1],t[2],e):e==="any"?(i=t.slice(1),["any"].concat(i.map(Eo))):e==="all"?["all"].concat(t.slice(1).map(Eo)):e==="none"?["all"].concat(t.slice(1).map(Eo).map(ga)):e==="in"?Pl(t[1],t.slice(2)):e==="!in"?ga(Pl(t[1],t.slice(2))):e==="has"?zl(t[1]):e==="!has"?ga(zl(t[1])):e!=="within"||t;var i}function Cl(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Pl(t,e){if(e.length===0)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(i=>typeof i!=typeof e[0])?["filter-in-large",t,["literal",e.sort(vh)]]:["filter-in-small",t,["literal",e]]}}function zl(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ga(t){return["!",t]}function xs(t){return Ml(Ri(t.value))?Bi($r({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):vs(t)}function vs(t){const e=t.value,i=t.key;if(zt(e)!=="array")return[new We(i,e,`array expected, ${zt(e)} found`)];const n=t.styleSpec;let a,c=[];if(e.length<1)return[new We(i,e,"filter array must have at least 1 element")];switch(c=c.concat(fa({key:`${i}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),bi(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&bi(e[1])==="$type"&&c.push(new We(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&c.push(new We(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(a=zt(e[1]),a!=="string"&&c.push(new We(`${i}[1]`,e[1],`string expected, ${a} found`)));for(let h=2;h<e.length;h++)a=zt(e[h]),bi(e[1])==="$type"?c=c.concat(fa({key:`${i}[${h}]`,value:e[h],valueSpec:n.geometry_type,style:t.style,styleSpec:t.styleSpec})):a!=="string"&&a!=="number"&&a!=="boolean"&&c.push(new We(`${i}[${h}]`,e[h],`string, number, or boolean expected, ${a} found`));break;case"any":case"all":case"none":for(let h=1;h<e.length;h++)c=c.concat(vs({key:`${i}[${h}]`,value:e[h],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":a=zt(e[1]),e.length!==2?c.push(new We(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):a!=="string"&&c.push(new We(`${i}[1]`,e[1],`string expected, ${a} found`));break;case"within":a=zt(e[1]),e.length!==2?c.push(new We(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):a!=="object"&&c.push(new We(`${i}[1]`,e[1],`object expected, ${a} found`))}return c}function kl(t,e){const i=t.key,n=t.style,a=t.styleSpec,c=t.value,h=t.objectKey,p=a[`${e}_${t.layerType}`];if(!p)return[];const m=h.match(/^(.*)-transition$/);if(e==="paint"&&m&&p[m[1]]&&p[m[1]].transition)return $i({key:i,value:c,valueSpec:a.transition,style:n,styleSpec:a});const _=t.valueSpec||p[h];if(!_)return[new We(i,c,`unknown property "${h}"`)];let x;if(zt(c)==="string"&&xo(_)&&!_.tokens&&(x=/^{([^}]+)}$/.exec(c))){const T=`\`{ "type": "identity", "property": ${x?JSON.stringify(x[1]):'"_"'} }\``;return[new We(i,c,`"${h}" does not support interpolation syntax
Use an identity property function instead: ${T}.`)]}const b=[];return t.layerType==="symbol"&&(h==="text-field"&&n&&!n.glyphs&&b.push(new We(i,c,'use of "text-field" requires a style "glyphs" property')),h==="text-font"&&ps(Ri(c))&&bi(c.type)==="identity"&&b.push(new We(i,c,'"text-font" does not support identity functions'))),b.concat($i({key:t.key,value:c,valueSpec:_,style:n,styleSpec:a,expressionContext:"property",propertyType:e,propertyKey:h}))}function tu(t){return kl(t,"paint")}function Ll(t){return kl(t,"layout")}function iu(t){let e=[];const i=t.value,n=t.key,a=t.style,c=t.styleSpec;i.type||i.ref||e.push(new We(n,i,'either "type" or "ref" is required'));let h=bi(i.type);const p=bi(i.ref);if(i.id){const m=bi(i.id);for(let _=0;_<t.arrayIndex;_++){const x=a.layers[_];bi(x.id)===m&&e.push(new We(n,i.id,`duplicate layer id "${i.id}", previously used at line ${x.id.__line__}`))}}if("ref"in i){let m;["type","source","source-layer","filter","layout"].forEach(_=>{_ in i&&e.push(new We(n,i[_],`"${_}" is prohibited for ref layers`))}),a.layers.forEach(_=>{bi(_.id)===p&&(m=_)}),m?m.ref?e.push(new We(n,i.ref,"ref cannot reference another ref layer")):h=bi(m.type):typeof p=="string"&&e.push(new We(n,i.ref,`ref layer "${p}" not found`))}else if(h!=="background"&&h!=="sky")if(i.source){const m=a.sources&&a.sources[i.source],_=m&&bi(m.type);m?_==="vector"&&h==="raster"?e.push(new We(n,i.source,`layer "${i.id}" requires a raster source`)):_==="raster"&&h!=="raster"?e.push(new We(n,i.source,`layer "${i.id}" requires a vector source`)):_!=="vector"||i["source-layer"]?_==="raster-dem"&&h!=="hillshade"?e.push(new We(n,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):h!=="line"||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||_==="geojson"&&m.lineMetrics||e.push(new We(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new We(n,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new We(n,i.source,`source "${i.source}" not found`))}else e.push(new We(n,i,'missing required property "source"'));return e=e.concat(Er({key:n,value:i,valueSpec:c.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>$i({key:`${n}.type`,value:i.type,valueSpec:c.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:m=>xs($r({layerType:h},m)),layout:m=>Er({layer:i,key:m.key,value:m.value,valueSpec:{},style:m.style,styleSpec:m.styleSpec,objectElementValidators:{"*":_=>Ll($r({layerType:h},_))}}),paint:m=>Er({layer:i,key:m.key,value:m.value,valueSpec:{},style:m.style,styleSpec:m.styleSpec,objectElementValidators:{"*":_=>tu($r({layerType:h},_))}})}})),e}function gn(t){const e=t.value,i=t.key,n=zt(e);return n!=="string"?[new We(i,e,`string expected, ${n} found`)]:[]}const ru={promoteId:function({key:t,value:e}){if(zt(e)==="string")return gn({key:t,value:e});{const i=[];for(const n in e)i.push(...gn({key:`${t}.${n}`,value:e[n]}));return i}}};function nu(t){const e=t.value,i=t.key,n=t.styleSpec,a=t.style;if(!e.type)return[new We(i,e,'"type" is required')];const c=bi(e.type);let h;switch(c){case"vector":case"raster":case"raster-dem":return h=Er({key:i,value:e,valueSpec:n[`source_${c.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:ru}),h;case"geojson":if(h=Er({key:i,value:e,valueSpec:n.source_geojson,style:a,styleSpec:n,objectElementValidators:ru}),e.cluster)for(const p in e.clusterProperties){const[m,_]=e.clusterProperties[p],x=typeof m=="string"?[m,["accumulated"],["get",p]]:m;h.push(...Bi({key:`${i}.${p}.map`,value:_,expressionContext:"cluster-map"})),h.push(...Bi({key:`${i}.${p}.reduce`,value:x,expressionContext:"cluster-reduce"}))}return h;case"video":return Er({key:i,value:e,valueSpec:n.source_video,style:a,styleSpec:n});case"image":return Er({key:i,value:e,valueSpec:n.source_image,style:a,styleSpec:n});case"canvas":return[new We(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return fa({key:`${i}.type`,value:e.type,valueSpec:{values:bh(n)},style:a,styleSpec:n})}}function bh(t){return t.source.reduce((e,i)=>{const n=t[i];return n.type.type==="enum"&&(e=e.concat(Object.keys(n.type.values))),e},[])}function ou(t){const e=t.value,i=t.styleSpec,n=i.light,a=t.style;let c=[];const h=zt(e);if(e===void 0)return c;if(h!=="object")return c=c.concat([new We("light",e,`object expected, ${h} found`)]),c;for(const p in e){const m=p.match(/^(.*)-transition$/);c=c.concat(m&&n[m[1]]&&n[m[1]].transition?$i({key:p,value:e[p],valueSpec:i.transition,style:a,styleSpec:i}):n[p]?$i({key:p,value:e[p],valueSpec:n[p],style:a,styleSpec:i}):[new We(p,e[p],`unknown property "${p}"`)])}return c}function Dl(t){const e=t.value,i=t.key,n=t.style,a=t.styleSpec,c=a.terrain;let h=[];const p=zt(e);if(e===void 0)return h;if(p!=="object")return h=h.concat([new We("terrain",e,`object expected, ${p} found`)]),h;for(const m in e){const _=m.match(/^(.*)-transition$/);h=h.concat(_&&c[_[1]]&&c[_[1]].transition?$i({key:m,value:e[m],valueSpec:a.transition,style:n,styleSpec:a}):c[m]?$i({key:m,value:e[m],valueSpec:c[m],style:n,styleSpec:a}):[new We(m,e[m],`unknown property "${m}"`)])}if(e.source){const m=n.sources&&n.sources[e.source],_=m&&bi(m.type);m?_!=="raster-dem"&&h.push(new We(i,e.source,`terrain cannot be used with a source of type ${String(_)}, it only be used with a "raster-dem" source type`)):h.push(new We(i,e.source,`source "${e.source}" not found`))}else h.push(new We(i,e,'terrain is missing required property "source"'));return h}function su(t){const e=t.value,i=t.style,n=t.styleSpec,a=n.fog;let c=[];const h=zt(e);if(e===void 0)return c;if(h!=="object")return c=c.concat([new We("fog",e,`object expected, ${h} found`)]),c;for(const p in e){const m=p.match(/^(.*)-transition$/);c=c.concat(m&&a[m[1]]&&a[m[1]].transition?$i({key:p,value:e[p],valueSpec:n.transition,style:i,styleSpec:n}):a[p]?$i({key:p,value:e[p],valueSpec:a[p],style:i,styleSpec:n}):[new We(p,e[p],`unknown property "${p}"`)])}return c}const au={"*":()=>[],array:Yc,boolean:function(t){const e=t.value,i=t.key,n=zt(e);return n!=="boolean"?[new We(i,e,`boolean expected, ${n} found`)]:[]},number:_s,color:function(t){const e=t.key,i=t.value,n=zt(i);return n!=="string"?[new We(e,i,`color expected, ${n} found`)]:Ya(i)===null?[new We(e,i,`color expected, "${i}" found`)]:[]},enum:fa,filter:xs,function:gs,layer:iu,object:Er,source:nu,light:ou,terrain:Dl,fog:su,string:gn,formatted:function(t){return gn(t).length===0?[]:Bi(t)},resolvedImage:function(t){return gn(t).length===0?[]:Bi(t)},projection:function(t){const e=t.value,i=t.styleSpec,n=i.projection,a=t.style;let c=[];const h=zt(e);if(h==="object")for(const p in e)c=c.concat($i({key:p,value:e[p],valueSpec:n[p],style:a,styleSpec:i}));else h!=="string"&&(c=c.concat([new We("projection",e,`object or string expected, ${h} found`)]));return c}};function $i(t){const e=t.value,i=t.valueSpec,n=t.styleSpec;return i.expression&&ps(bi(e))?gs(t):i.expression&&bo(Ri(e))?Bi(t):i.type&&au[i.type]?au[i.type](t):Er($r({},t,{valueSpec:i.type?n[i.type]:i}))}function wh(t){const e=t.value,i=t.key,n=gn(t);return n.length||(e.indexOf("{fontstack}")===-1&&n.push(new We(i,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&n.push(new We(i,e,'"glyphs" url must include a "{range}" token'))),n}function lu(t,e=be){return mr($i({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:wh,"*":()=>[]}}))}const Th=t=>mr(tu(t)),Eh=t=>mr(Ll(t));function mr(t){return t.slice().sort((e,i)=>e.line&&i.line?e.line-i.line:0)}function cu(t,e){let i=!1;if(e&&e.length)for(const n of e)t.fire(new Gr(new Error(n.message))),i=!0;return i}var Sh=Dr,Sr=3;function Dr(t,e,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var a=new Int32Array(this.arrayBuffer);t=a[0],this.d=(e=a[1])+2*(i=a[2]);for(var c=0;c<this.d*this.d;c++){var h=a[Sr+c],p=a[Sr+c+1];n.push(h===p?null:a.subarray(h,p))}var m=a[Sr+n.length+1];this.keys=a.subarray(a[Sr+n.length],m),this.bboxes=a.subarray(m),this.insert=this._insertReadonly}else{this.d=e+2*i;for(var _=0;_<this.d*this.d;_++)n.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;var x=i/e*t;this.min=-x,this.max=t+x}Dr.prototype.insert=function(t,e,i,n,a){this._forEachCell(e,i,n,a,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(a)},Dr.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Dr.prototype._insertCell=function(t,e,i,n,a,c){this.cells[a].push(c)},Dr.prototype.query=function(t,e,i,n,a){var c=this.min,h=this.max;if(t<=c&&e<=c&&h<=i&&h<=n&&!a)return Array.prototype.slice.call(this.keys);var p=[];return this._forEachCell(t,e,i,n,this._queryCell,p,{},a),p},Dr.prototype._queryCell=function(t,e,i,n,a,c,h,p){var m=this.cells[a];if(m!==null)for(var _=this.keys,x=this.bboxes,b=0;b<m.length;b++){var T=m[b];if(h[T]===void 0){var A=4*T;(p?p(x[A+0],x[A+1],x[A+2],x[A+3]):t<=x[A+2]&&e<=x[A+3]&&i>=x[A+0]&&n>=x[A+1])?(h[T]=!0,c.push(_[T])):h[T]=!1}}},Dr.prototype._forEachCell=function(t,e,i,n,a,c,h,p){for(var m=this._convertToCellCoord(t),_=this._convertToCellCoord(e),x=this._convertToCellCoord(i),b=this._convertToCellCoord(n),T=m;T<=x;T++)for(var A=_;A<=b;A++){var M=this.d*A+T;if((!p||p(this._convertFromCellCoord(T),this._convertFromCellCoord(A),this._convertFromCellCoord(T+1),this._convertFromCellCoord(A+1)))&&a.call(this,t,e,i,n,M,c,h,p))return}},Dr.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Dr.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Dr.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=Sr+this.cells.length+1+1,i=0,n=0;n<this.cells.length;n++)i+=this.cells[n].length;var a=new Int32Array(e+i+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;for(var c=e,h=0;h<t.length;h++){var p=t[h];a[Sr+h]=c,a.set(p,c),c+=p.length}return a[Sr+t.length]=c,a.set(this.keys,c),a[Sr+t.length+1]=c+=this.keys.length,a.set(this.bboxes,c),c+=this.bboxes.length,a.buffer};var jn=pi(Sh);const ya={};function Xe(t,e,i={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ya[e]={klass:t,omit:i.omit||[]}}Xe(Object,"Object"),jn.serialize=function(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}},jn.deserialize=function(t){return new jn(t.buffer)},Object.defineProperty(jn,"name",{value:"Grid"}),Xe(jn,"Grid"),Xe(gi,"Color"),Xe(Error,"Error"),Xe(mn,"AJAXError"),Xe(pr,"ResolvedImage"),Xe(da,"StylePropertyFunction"),Xe(ha,"StyleExpression",{omit:["_evaluator"]}),Xe(fs,"ZoomDependentExpression"),Xe(Al,"ZoomConstantExpression"),Xe(Wr,"CompoundExpression",{omit:["_evaluate"]});for(const t in ds)ya[ds[t]._classRegistryKey]||Xe(ds[t],`Expression${t}`);function Rl(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||t.constructor&&t.constructor.name==="ArrayBuffer")}function Bl(t){return le.ImageBitmap&&t instanceof le.ImageBitmap}function So(t,e){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Rl(t)||Bl(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.push(i.buffer),i}if(t instanceof le.ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const n of t)i.push(So(n,e));return i}if(typeof t=="object"){const i=t.constructor,n=i._classRegistryKey;if(!n)throw new Error(`can't serialize object of unregistered class ${n}`);const a=i.serialize?i.serialize(t,e):{};if(!i.serialize){for(const c in t)t.hasOwnProperty(c)&&(ya[n].omit.indexOf(c)>=0||(a[c]=So(t[c],e)));t instanceof Error&&(a.message=t.message)}if(a.$name)throw new Error("$name property is reserved for worker serialization logic.");return n!=="Object"&&(a.$name=n),a}throw new Error("can't serialize object of type "+typeof t)}function Vn(t){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Rl(t)||Bl(t)||ArrayBuffer.isView(t)||t instanceof le.ImageData)return t;if(Array.isArray(t))return t.map(Vn);if(typeof t=="object"){const e=t.$name||"Object",{klass:i}=ya[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const a of Object.keys(t))a!=="$name"&&(n[a]=Vn(t[a]));return n}throw new Error("can't deserialize object of type "+typeof t)}const qe={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function Ol(t){for(const e of t)if(Fl(e.charCodeAt(0)))return!0;return!1}function Ah(t){for(const e of t)if(!uu(e.charCodeAt(0)))return!1;return!0}function uu(t){return!(qe.Arabic(t)||qe["Arabic Supplement"](t)||qe["Arabic Extended-A"](t)||qe["Arabic Presentation Forms-A"](t)||qe["Arabic Presentation Forms-B"](t))}function Fl(t){return!(t!==746&&t!==747&&(t<4352||!(qe["Bopomofo Extended"](t)||qe.Bopomofo(t)||qe["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||qe["CJK Compatibility Ideographs"](t)||qe["CJK Compatibility"](t)||qe["CJK Radicals Supplement"](t)||qe["CJK Strokes"](t)||!(!qe["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||t===12336)||qe["CJK Unified Ideographs Extension A"](t)||qe["CJK Unified Ideographs"](t)||qe["Enclosed CJK Letters and Months"](t)||qe["Hangul Compatibility Jamo"](t)||qe["Hangul Jamo Extended-A"](t)||qe["Hangul Jamo Extended-B"](t)||qe["Hangul Jamo"](t)||qe["Hangul Syllables"](t)||qe.Hiragana(t)||qe["Ideographic Description Characters"](t)||qe.Kanbun(t)||qe["Kangxi Radicals"](t)||qe["Katakana Phonetic Extensions"](t)||qe.Katakana(t)&&t!==12540||!(!qe["Halfwidth and Fullwidth Forms"](t)||t===65288||t===65289||t===65293||t>=65306&&t<=65310||t===65339||t===65341||t===65343||t>=65371&&t<=65503||t===65507||t>=65512&&t<=65519)||!(!qe["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||qe["Unified Canadian Aboriginal Syllabics"](t)||qe["Unified Canadian Aboriginal Syllabics Extended"](t)||qe["Vertical Forms"](t)||qe["Yijing Hexagram Symbols"](t)||qe["Yi Syllables"](t)||qe["Yi Radicals"](t))))}function hu(t){return!(Fl(t)||function(e){return!!(qe["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||qe["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||qe["Letterlike Symbols"](e)||qe["Number Forms"](e)||qe["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||qe["Control Pictures"](e)&&e!==9251||qe["Optical Character Recognition"](e)||qe["Enclosed Alphanumerics"](e)||qe["Geometric Shapes"](e)||qe["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||qe["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||qe["CJK Symbols and Punctuation"](e)||qe.Katakana(e)||qe["Private Use Area"](e)||qe["CJK Compatibility Forms"](e)||qe["Small Form Variants"](e)||qe["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(t))}function du(t){return t>=1424&&t<=2303||qe["Arabic Presentation Forms-A"](t)||qe["Arabic Presentation Forms-B"](t)}function Mh(t,e){return!(!e&&du(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||qe.Khmer(t))}function Ih(t){for(const e of t)if(du(e.charCodeAt(0)))return!0;return!1}const Ul="deferred",Nl="loading",jl="loaded";let Ao=null,l="unavailable",r=null;const o=function(t){t&&typeof t=="string"&&t.indexOf("NetworkError")>-1&&(l="error"),Ao&&Ao(t)};function u(){d.fire(new Dn("pluginStateChange",{pluginStatus:l,pluginURL:r}))}const d=new Ko,f=function(){return l},g=function(){if(l!==Ul||!r)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");l=Nl,u(),r&&so({url:r},t=>{t?o(t):(l=jl,u())})},y={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>l===jl||y.applyArabicShaping!=null,isLoading:()=>l===Nl,setState(t){l=t.pluginStatus,r=t.pluginURL},isParsed:()=>y.applyArabicShaping!=null&&y.processBidirectionalText!=null&&y.processStyledBidirectionalText!=null,getPluginURL:()=>r};class v{constructor(e,i){this.zoom=e,i?(this.now=i.now,this.fadeDuration=i.fadeDuration,this.transition=i.transition,this.pitch=i.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(e){return function(i,n){for(const a of i)if(!Mh(a.charCodeAt(0),n))return!1;return!0}(e,y.isLoaded())}}class S{constructor(e,i){this.property=e,this.value=i,this.expression=function(n,a){if(ps(n))return new da(n,a);if(bo(n)){const c=ms(n,a);if(c.result==="error")throw new Error(c.value.map(h=>`${h.key}: ${h.message}`).join(", "));return c.value}{let c=n;return typeof n=="string"&&a.type==="color"&&(c=gi.parse(n)),{kind:"constant",evaluate:()=>c}}}(i===void 0?e.specification.default:i,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,i,n){return this.property.possiblyEvaluate(this,e,i,n)}}class E{constructor(e){this.property=e,this.value=new S(e,void 0)}transitioned(e,i){return new D(this.property,this.value,i,xi({},e.transition,this.transition),e.now)}untransitioned(){return new D(this.property,this.value,null,{},0)}}class C{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return or(this._values[e].value.value)}setValue(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new E(this._values[e].property)),this._values[e].value=new S(this._values[e].property,i===null?void 0:or(i))}getTransition(e){return or(this._values[e].transition)}setTransition(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new E(this._values[e].property)),this._values[e].transition=or(i)||void 0}serialize(){const e={};for(const i of Object.keys(this._values)){const n=this.getValue(i);n!==void 0&&(e[i]=n);const a=this.getTransition(i);a!==void 0&&(e[`${i}-transition`]=a)}return e}transitioned(e,i){const n=new F(this._properties);for(const a of Object.keys(this._values))n._values[a]=this._values[a].transitioned(e,i._values[a]);return n}untransitioned(){const e=new F(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class D{constructor(e,i,n,a,c){const h=a.delay||0,p=a.duration||0;c=c||0,this.property=e,this.value=i,this.begin=c+h,this.end=this.begin+p,e.specification.transition&&(a.delay||a.duration)&&(this.prior=n)}possiblyEvaluate(e,i,n){const a=e.now||0,c=this.value.possiblyEvaluate(e,i,n),h=this.prior;if(h){if(a>this.end)return this.prior=null,c;if(this.value.isDataDriven())return this.prior=null,c;if(a<this.begin)return h.possiblyEvaluate(e,i,n);{const p=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(h.possiblyEvaluate(e,i,n),c,Fs(p))}}return c}}class F{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,n){const a=new j(this._properties);for(const c of Object.keys(this._values))a._values[c]=this._values[c].possiblyEvaluate(e,i,n);return a}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class N{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return or(this._values[e].value)}setValue(e,i){this._values[e]=new S(this._values[e].property,i===null?void 0:or(i))}serialize(){const e={};for(const i of Object.keys(this._values)){const n=this.getValue(i);n!==void 0&&(e[i]=n)}return e}possiblyEvaluate(e,i,n){const a=new j(this._properties);for(const c of Object.keys(this._values))a._values[c]=this._values[c].possiblyEvaluate(e,i,n);return a}}class U{constructor(e,i,n){this.property=e,this.value=i,this.parameters=n}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,i,n,a){return this.property.evaluate(this.value,this.parameters,e,i,n,a)}}class j{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class P{constructor(e){this.specification=e}possiblyEvaluate(e,i){return e.expression.evaluate(i)}interpolate(e,i,n){const a=as[this.specification.type];return a?a(e,i,n):e}}class O{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,n,a){return new U(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(i,null,{},n,a)}:e.expression,i)}interpolate(e,i,n){if(e.value.kind!=="constant"||i.value.kind!=="constant")return e;if(e.value.value===void 0||i.value.value===void 0)return new U(this,{kind:"constant",value:void 0},e.parameters);const a=as[this.specification.type];return a?new U(this,{kind:"constant",value:a(e.value.value,i.value.value,n)},e.parameters):e}evaluate(e,i,n,a,c,h){return e.kind==="constant"?e.value:e.evaluate(i,n,a,c,h)}}class ${constructor(e){this.specification=e}possiblyEvaluate(e,i,n,a){return!!e.expression.evaluate(i,null,{},n,a)}interpolate(){return!1}}class q{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const i=new v(0,{});for(const n in e){const a=e[n];a.specification.overridable&&this.overridableProperties.push(n);const c=this.defaultPropertyValues[n]=new S(a,void 0),h=this.defaultTransitionablePropertyValues[n]=new E(a);this.defaultTransitioningPropertyValues[n]=h.untransitioned(),this.defaultPossiblyEvaluatedValues[n]=c.possiblyEvaluate(i)}}}function ee(t,e){return 256*(t=Tt(Math.floor(t),0,255))+Tt(Math.floor(e),0,255)}Xe(O,"DataDrivenProperty"),Xe(P,"DataConstantProperty"),Xe($,"ColorRampProperty");const ie={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class te{constructor(e,i){this._structArray=e,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ae{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,i){return e._trim(),i&&(e.isTransferred=!0,i.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const i=Object.create(this.prototype);return i.arrayBuffer=e.arrayBuffer,i.length=e.length,i.capacity=e.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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function se(t,e=1){let i=0,n=0;return{members:t.map(a=>{const c=ie[a.type].BYTES_PER_ELEMENT,h=i=fe(i,Math.max(e,c)),p=a.components||1;return n=Math.max(n,c),i+=c*p,{name:a.name,type:a.type,components:p,offset:h}}),size:fe(i,Math.max(n,e)),alignment:e}}function fe(t,e){return Math.ceil(t/e)*e}class ke extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const a=2*e;return this.int16[a+0]=i,this.int16[a+1]=n,e}}ke.prototype.bytesPerElement=4,Xe(ke,"StructArrayLayout2i4");class he extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,n)}emplace(e,i,n,a){const c=3*e;return this.int16[c+0]=i,this.int16[c+1]=n,this.int16[c+2]=a,e}}he.prototype.bytesPerElement=6,Xe(he,"StructArrayLayout3i6");class Se extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,a)}emplace(e,i,n,a,c){const h=4*e;return this.int16[h+0]=i,this.int16[h+1]=n,this.int16[h+2]=a,this.int16[h+3]=c,e}}Se.prototype.bytesPerElement=8,Xe(Se,"StructArrayLayout4i8");class ge extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c,h,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,n,a,c,h,p)}emplace(e,i,n,a,c,h,p,m){const _=6*e,x=12*e,b=3*e;return this.int16[_+0]=i,this.int16[_+1]=n,this.uint8[x+4]=a,this.uint8[x+5]=c,this.uint8[x+6]=h,this.uint8[x+7]=p,this.float32[b+2]=m,e}}ge.prototype.bytesPerElement=12,Xe(ge,"StructArrayLayout2i4ub1f12");class ze extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,a)}emplace(e,i,n,a,c){const h=4*e;return this.float32[h+0]=i,this.float32[h+1]=n,this.float32[h+2]=a,this.float32[h+3]=c,e}}ze.prototype.bytesPerElement=16,Xe(ze,"StructArrayLayout4f16");class pe extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,n,a,c)}emplace(e,i,n,a,c,h){const p=6*e,m=3*e;return this.uint16[p+0]=i,this.uint16[p+1]=n,this.uint16[p+2]=a,this.uint16[p+3]=c,this.float32[m+2]=h,e}}pe.prototype.bytesPerElement=12,Xe(pe,"StructArrayLayout4ui1f12");class Ee extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,a)}emplace(e,i,n,a,c){const h=4*e;return this.uint16[h+0]=i,this.uint16[h+1]=n,this.uint16[h+2]=a,this.uint16[h+3]=c,e}}Ee.prototype.bytesPerElement=8,Xe(Ee,"StructArrayLayout4ui8");class De extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,i,n,a,c,h)}emplace(e,i,n,a,c,h,p){const m=6*e;return this.int16[m+0]=i,this.int16[m+1]=n,this.int16[m+2]=a,this.int16[m+3]=c,this.int16[m+4]=h,this.int16[m+5]=p,e}}De.prototype.bytesPerElement=12,Xe(De,"StructArrayLayout6i12");class Ie extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c,h,p,m,_,x,b,T){const A=this.length;return this.resize(A+1),this.emplace(A,e,i,n,a,c,h,p,m,_,x,b,T)}emplace(e,i,n,a,c,h,p,m,_,x,b,T,A){const M=12*e;return this.int16[M+0]=i,this.int16[M+1]=n,this.int16[M+2]=a,this.int16[M+3]=c,this.uint16[M+4]=h,this.uint16[M+5]=p,this.uint16[M+6]=m,this.uint16[M+7]=_,this.int16[M+8]=x,this.int16[M+9]=b,this.int16[M+10]=T,this.int16[M+11]=A,e}}Ie.prototype.bytesPerElement=24,Xe(Ie,"StructArrayLayout4i4ui4i24");class Be extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,i,n,a,c,h)}emplace(e,i,n,a,c,h,p){const m=10*e,_=5*e;return this.int16[m+0]=i,this.int16[m+1]=n,this.int16[m+2]=a,this.float32[_+2]=c,this.float32[_+3]=h,this.float32[_+4]=p,e}}Be.prototype.bytesPerElement=20,Xe(Be,"StructArrayLayout3i3f20");class it extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[1*e+0]=i,e}}it.prototype.bytesPerElement=4,Xe(it,"StructArrayLayout1ul4");class lt extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c,h,p,m,_,x,b,T,A){const M=this.length;return this.resize(M+1),this.emplace(M,e,i,n,a,c,h,p,m,_,x,b,T,A)}emplace(e,i,n,a,c,h,p,m,_,x,b,T,A,M){const z=20*e,B=10*e;return this.int16[z+0]=i,this.int16[z+1]=n,this.int16[z+2]=a,this.int16[z+3]=c,this.int16[z+4]=h,this.float32[B+3]=p,this.float32[B+4]=m,this.float32[B+5]=_,this.float32[B+6]=x,this.int16[z+14]=b,this.uint32[B+8]=T,this.uint16[z+18]=A,this.uint16[z+19]=M,e}}lt.prototype.bytesPerElement=40,Xe(lt,"StructArrayLayout5i4f1i1ul2ui40");class He extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c,h,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,n,a,c,h,p)}emplace(e,i,n,a,c,h,p,m){const _=8*e;return this.int16[_+0]=i,this.int16[_+1]=n,this.int16[_+2]=a,this.int16[_+4]=c,this.int16[_+5]=h,this.int16[_+6]=p,this.int16[_+7]=m,e}}He.prototype.bytesPerElement=16,Xe(He,"StructArrayLayout3i2i2i16");class st extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,n,a,c)}emplace(e,i,n,a,c,h){const p=4*e,m=8*e;return this.float32[p+0]=i,this.float32[p+1]=n,this.float32[p+2]=a,this.int16[m+6]=c,this.int16[m+7]=h,e}}st.prototype.bytesPerElement=16,Xe(st,"StructArrayLayout2f1f2i16");class wt extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,a)}emplace(e,i,n,a,c){const h=12*e,p=3*e;return this.uint8[h+0]=i,this.uint8[h+1]=n,this.float32[p+1]=a,this.float32[p+2]=c,e}}wt.prototype.bytesPerElement=12,Xe(wt,"StructArrayLayout2ub2f12");class xt extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,n)}emplace(e,i,n,a){const c=3*e;return this.float32[c+0]=i,this.float32[c+1]=n,this.float32[c+2]=a,e}}xt.prototype.bytesPerElement=12,Xe(xt,"StructArrayLayout3f12");class tt extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,n)}emplace(e,i,n,a){const c=3*e;return this.uint16[c+0]=i,this.uint16[c+1]=n,this.uint16[c+2]=a,e}}tt.prototype.bytesPerElement=6,Xe(tt,"StructArrayLayout3ui6");class Ft extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c,h,p,m,_,x,b,T,A,M,z,B,V,K,G,X,Y){const J=this.length;return this.resize(J+1),this.emplace(J,e,i,n,a,c,h,p,m,_,x,b,T,A,M,z,B,V,K,G,X,Y)}emplace(e,i,n,a,c,h,p,m,_,x,b,T,A,M,z,B,V,K,G,X,Y,J){const me=30*e,de=15*e,Te=60*e;return this.int16[me+0]=i,this.int16[me+1]=n,this.int16[me+2]=a,this.float32[de+2]=c,this.float32[de+3]=h,this.uint16[me+8]=p,this.uint16[me+9]=m,this.uint32[de+5]=_,this.uint32[de+6]=x,this.uint32[de+7]=b,this.uint16[me+16]=T,this.uint16[me+17]=A,this.uint16[me+18]=M,this.float32[de+10]=z,this.float32[de+11]=B,this.uint8[Te+48]=V,this.uint8[Te+49]=K,this.uint8[Te+50]=G,this.uint32[de+13]=X,this.int16[me+28]=Y,this.uint8[Te+58]=J,e}}Ft.prototype.bytesPerElement=60,Xe(Ft,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class jt extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c,h,p,m,_,x,b,T,A,M,z,B,V,K,G,X,Y,J,me,de,Te,Le,ye,Ae,Me,Ce){const Fe=this.length;return this.resize(Fe+1),this.emplace(Fe,e,i,n,a,c,h,p,m,_,x,b,T,A,M,z,B,V,K,G,X,Y,J,me,de,Te,Le,ye,Ae,Me,Ce)}emplace(e,i,n,a,c,h,p,m,_,x,b,T,A,M,z,B,V,K,G,X,Y,J,me,de,Te,Le,ye,Ae,Me,Ce,Fe){const ve=38*e,Ve=19*e;return this.int16[ve+0]=i,this.int16[ve+1]=n,this.int16[ve+2]=a,this.float32[Ve+2]=c,this.float32[Ve+3]=h,this.int16[ve+8]=p,this.int16[ve+9]=m,this.int16[ve+10]=_,this.int16[ve+11]=x,this.int16[ve+12]=b,this.int16[ve+13]=T,this.uint16[ve+14]=A,this.uint16[ve+15]=M,this.uint16[ve+16]=z,this.uint16[ve+17]=B,this.uint16[ve+18]=V,this.uint16[ve+19]=K,this.uint16[ve+20]=G,this.uint16[ve+21]=X,this.uint16[ve+22]=Y,this.uint16[ve+23]=J,this.uint16[ve+24]=me,this.uint16[ve+25]=de,this.uint16[ve+26]=Te,this.uint16[ve+27]=Le,this.uint16[ve+28]=ye,this.uint32[Ve+15]=Ae,this.float32[Ve+16]=Me,this.float32[Ve+17]=Ce,this.float32[Ve+18]=Fe,e}}jt.prototype.bytesPerElement=76,Xe(jt,"StructArrayLayout3i2f6i15ui1ul3f76");class Vt extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[1*e+0]=i,e}}Vt.prototype.bytesPerElement=4,Xe(Vt,"StructArrayLayout1f4");class Gt extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,a,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,n,a,c)}emplace(e,i,n,a,c,h){const p=5*e;return this.float32[p+0]=i,this.float32[p+1]=n,this.float32[p+2]=a,this.float32[p+3]=c,this.float32[p+4]=h,e}}Gt.prototype.bytesPerElement=20,Xe(Gt,"StructArrayLayout5f20");class qi extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,a){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,a)}emplace(e,i,n,a,c){const h=6*e;return this.uint32[3*e+0]=i,this.uint16[h+2]=n,this.uint16[h+3]=a,this.uint16[h+4]=c,e}}qi.prototype.bytesPerElement=12,Xe(qi,"StructArrayLayout1ul3ui12");class Oi extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const a=2*e;return this.uint16[a+0]=i,this.uint16[a+1]=n,e}}Oi.prototype.bytesPerElement=4,Xe(Oi,"StructArrayLayout2ui4");class _r extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[1*e+0]=i,e}}_r.prototype.bytesPerElement=2,Xe(_r,"StructArrayLayout1ui2");class Rr extends ae{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const a=2*e;return this.float32[a+0]=i,this.float32[a+1]=n,e}}Rr.prototype.bytesPerElement=8,Xe(Rr,"StructArrayLayout2f8");class oi extends te{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}oi.prototype.size=40;class $t extends lt{get(e){return new oi(this,e)}}Xe($t,"CollisionBoxArray");class Dt extends te{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}Dt.prototype.size=60;class wi extends Ft{get(e){return new Dt(this,e)}}Xe(wi,"PlacedSymbolArray");class Hi extends te{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}Hi.prototype.size=76;class ii extends jt{get(e){return new Hi(this,e)}}Xe(ii,"SymbolInstanceArray");class Yi extends Vt{getoffsetX(e){return this.float32[1*e+0]}}Xe(Yi,"GlyphOffsetArray");class xa extends ke{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Xe(xa,"SymbolLineVertexArray");class Gn extends te{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]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Gn.prototype.size=12;class bs extends qi{get(e){return new Gn(this,e)}}Xe(bs,"FeatureIndexArray");class Yr extends Oi{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Xe(Yr,"FillExtrusionCentroidArray");const yn=se([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),$n=se([{name:"a_dash",components:4,type:"Uint16"}]);var va={exports:{}},ws={exports:{}};ws.exports=function(t,e){var i,n,a,c,h,p,m,_;for(n=t.length-(i=3&t.length),a=e,h=3432918353,p=461845907,_=0;_<n;)m=255&t.charCodeAt(_)|(255&t.charCodeAt(++_))<<8|(255&t.charCodeAt(++_))<<16|(255&t.charCodeAt(++_))<<24,++_,a=27492+(65535&(c=5*(65535&(a=(a^=m=(65535&(m=(m=(65535&m)*h+(((m>>>16)*h&65535)<<16)&4294967295)<<15|m>>>17))*p+(((m>>>16)*p&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+((58964+(c>>>16)&65535)<<16);switch(m=0,i){case 3:m^=(255&t.charCodeAt(_+2))<<16;case 2:m^=(255&t.charCodeAt(_+1))<<8;case 1:a^=m=(65535&(m=(m=(65535&(m^=255&t.charCodeAt(_)))*h+(((m>>>16)*h&65535)<<16)&4294967295)<<15|m>>>17))*p+(((m>>>16)*p&65535)<<16)&4294967295}return a^=t.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0};var Vl=ws.exports,Qd={exports:{}};Qd.exports=function(t,e){for(var i,n=t.length,a=e^n,c=0;n>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24))+((1540483477*(i>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++c;switch(n){case 3:a^=(255&t.charCodeAt(c+2))<<16;case 2:a^=(255&t.charCodeAt(c+1))<<8;case 1:a=1540483477*(65535&(a^=255&t.charCodeAt(c)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0};var ep=Vl,k_=Qd.exports;va.exports=ep,va.exports.murmur3=ep,va.exports.murmur2=k_;var Ch=pi(va.exports);class pu{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,i,n,a){this.ids.push(tp(e)),this.positions.push(i,n,a)}getPositions(e){const i=tp(e);let n=0,a=this.ids.length-1;for(;n<a;){const h=n+a>>1;this.ids[h]>=i?a=h:n=h+1}const c=[];for(;this.ids[n]===i;)c.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return c}static serialize(e,i){const n=new Float64Array(e.ids),a=new Uint32Array(e.positions);return Ph(n,a,0,n.length-1),i&&i.push(n.buffer,a.buffer),{ids:n,positions:a}}static deserialize(e){const i=new pu;return i.ids=e.ids,i.positions=e.positions,i.indexed=!0,i}}function tp(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Ch(String(t))}function Ph(t,e,i,n){for(;i<n;){const a=t[i+n>>1];let c=i-1,h=n+1;for(;;){do c++;while(t[c]<a);do h--;while(t[h]>a);if(c>=h)break;fu(t,c,h),fu(e,3*c,3*h),fu(e,3*c+1,3*h+1),fu(e,3*c+2,3*h+2)}h-i<n-h?(Ph(t,e,i,h),i=h+1):(Ph(t,e,h+1,n),n=h)}}function fu(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}Xe(pu,"FeaturePositionMap");class qn{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,i){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,i),this.initialized=!0),!!this.location}}class mu extends qn{constructor(e){super(e),this.current=0}set(e,i,n){this.fetchUniformLocation(e,i)&&this.current!==n&&(this.current=n,this.gl.uniform1f(this.location,n))}}class ip extends qn{constructor(e){super(e),this.current=[0,0,0,0]}set(e,i,n){this.fetchUniformLocation(e,i)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]&&n[3]===this.current[3]||(this.current=n,this.gl.uniform4f(this.location,n[0],n[1],n[2],n[3])))}}class rp extends qn{constructor(e){super(e),this.current=gi.transparent}set(e,i,n){this.fetchUniformLocation(e,i)&&(n.r===this.current.r&&n.g===this.current.g&&n.b===this.current.b&&n.a===this.current.a||(this.current=n,this.gl.uniform4f(this.location,n.r,n.g,n.b,n.a)))}}const L_=new Float32Array(16),D_=new Float32Array(9),R_=new Float32Array(4);function zh(t){return[ee(255*t.r,255*t.g),ee(255*t.b,255*t.a)]}class Gl{constructor(e,i,n){this.value=e,this.uniformNames=i.map(a=>`u_${a}`),this.type=n}setUniform(e,i,n,a,c){i.set(e,c,a.constantOr(this.value))}getBinding(e,i){return this.type==="color"?new rp(e):new mu(e)}}class ba{constructor(e,i){this.uniformNames=i.map(n=>`u_${n}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,i,n,a,c){const h=c==="u_pattern"||c==="u_dash"?this.pattern:c==="u_pixel_ratio"?this.pixelRatio:null;h&&i.set(e,c,h)}getBinding(e,i){return i==="u_pattern"||i==="u_dash"?new ip(e):new mu(e)}}class Zn{constructor(e,i,n,a){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=i.map(c=>({name:`a_${c}`,type:"Float32",components:n==="color"?2:1,offset:0})),this.paintVertexArray=new a}populatePaintArray(e,i,n,a,c,h){const p=this.paintVertexArray.length,m=this.expression.evaluate(new v(0),i,{},c,a,h);this.paintVertexArray.resize(e),this._setPaintValue(p,e,m)}updatePaintArray(e,i,n,a,c){const h=this.expression.evaluate({zoom:0},n,a,void 0,c);this._setPaintValue(e,i,h)}_setPaintValue(e,i,n){if(this.type==="color"){const a=zh(n);for(let c=e;c<i;c++)this.paintVertexArray.emplace(c,a[0],a[1])}else{for(let a=e;a<i;a++)this.paintVertexArray.emplace(a,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Qr{constructor(e,i,n,a,c,h){this.expression=e,this.uniformNames=i.map(p=>`u_${p}_t`),this.type=n,this.useIntegerZoom=a,this.zoom=c,this.maxValue=0,this.paintVertexAttributes=i.map(p=>({name:`a_${p}`,type:"Float32",components:n==="color"?4:2,offset:0})),this.paintVertexArray=new h}populatePaintArray(e,i,n,a,c,h){const p=this.expression.evaluate(new v(this.zoom),i,{},c,a,h),m=this.expression.evaluate(new v(this.zoom+1),i,{},c,a,h),_=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(_,e,p,m)}updatePaintArray(e,i,n,a,c){const h=this.expression.evaluate({zoom:this.zoom},n,a,void 0,c),p=this.expression.evaluate({zoom:this.zoom+1},n,a,void 0,c);this._setPaintValue(e,i,h,p)}_setPaintValue(e,i,n,a){if(this.type==="color"){const c=zh(n),h=zh(a);for(let p=e;p<i;p++)this.paintVertexArray.emplace(p,c[0],c[1],h[0],h[1])}else{for(let c=e;c<i;c++)this.paintVertexArray.emplace(c,n,a);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,i,n,a,c){const h=this.useIntegerZoom?Math.floor(n.zoom):n.zoom,p=Tt(this.expression.interpolationFactor(h,this.zoom,this.zoom+1),0,1);i.set(e,c,p)}getBinding(e,i){return new mu(e)}}class Mo{constructor(e,i,n,a,c){this.expression=e,this.layerId=c,this.paintVertexAttributes=(n==="array"?$n:yn).members;for(let h=0;h<i.length;++h);this.paintVertexArray=new a}populatePaintArray(e,i,n){const a=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(a,e,i.patterns&&i.patterns[this.layerId],n)}updatePaintArray(e,i,n,a,c,h){this._setPaintValues(e,i,n.patterns&&n.patterns[this.layerId],h)}_setPaintValues(e,i,n,a){if(!a||!n)return;const c=a[n];if(!c)return;const{tl:h,br:p,pixelRatio:m}=c;for(let _=e;_<i;_++)this.paintVertexArray.emplace(_,h[0],h[1],p[0],p[1],m)}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Io{constructor(e,i,n=()=>!0){this.binders={},this._buffers=[];const a=[];for(const c in e.paint._values){if(!n(c))continue;const h=e.paint.get(c);if(!(h instanceof U&&xo(h.property.specification)))continue;const p=O_(c,e.type),m=h.value,_=h.property.specification.type,x=!!h.property.useIntegerZoom,b=c==="line-dasharray"||c.endsWith("pattern"),T=c==="line-dasharray"&&e.layout.get("line-cap").value.kind!=="constant";if(m.kind!=="constant"||T)if(m.kind==="source"||T||b){const A=np(c,_,"source");this.binders[c]=b?new Mo(m,p,_,A,e.id):new Zn(m,p,_,A),a.push(`/a_${c}`)}else{const A=np(c,_,"composite");this.binders[c]=new Qr(m,p,_,x,i,A),a.push(`/z_${c}`)}else this.binders[c]=b?new ba(m.value,p):new Gl(m.value,p,_),a.push(`/u_${c}`)}this.cacheKey=a.sort().join("")}getMaxValue(e){const i=this.binders[e];return i instanceof Zn||i instanceof Qr?i.maxValue:0}populatePaintArrays(e,i,n,a,c,h){for(const p in this.binders){const m=this.binders[p];(m instanceof Zn||m instanceof Qr||m instanceof Mo)&&m.populatePaintArray(e,i,n,a,c,h)}}setConstantPatternPositions(e){for(const i in this.binders){const n=this.binders[i];n instanceof ba&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,i,n,a,c,h){let p=!1;for(const m in e){const _=i.getPositions(m);for(const x of _){const b=n.feature(x.index);for(const T in this.binders){const A=this.binders[T];if((A instanceof Zn||A instanceof Qr||A instanceof Mo)&&A.expression.isStateDependent===!0){const M=a.paint.get(T);A.expression=M.value,A.updatePaintArray(x.start,x.end,b,e[m],c,h),p=!0}}}}return p}defines(){const e=[];for(const i in this.binders){const n=this.binders[i];(n instanceof Gl||n instanceof ba)&&e.push(...n.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return e}getBinderAttributes(){const e=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof Zn||n instanceof Qr||n instanceof Mo)for(let a=0;a<n.paintVertexAttributes.length;a++)e.push(n.paintVertexAttributes[a].name)}return e}getBinderUniforms(){const e=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof Gl||n instanceof ba||n instanceof Qr)for(const a of n.uniformNames)e.push(a)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const i=[];for(const n in this.binders){const a=this.binders[n];if(a instanceof Gl||a instanceof ba||a instanceof Qr)for(const c of a.uniformNames)i.push({name:c,property:n,binding:a.getBinding(e,c)})}return i}setUniforms(e,i,n,a,c){for(const{name:h,property:p,binding:m}of n)this.binders[p].setUniform(e,m,c,a.get(p),h)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Zn||i instanceof Qr||i instanceof Mo)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const i in this.binders){const n=this.binders[i];(n instanceof Zn||n instanceof Qr||n instanceof Mo)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const i=this.binders[e];(i instanceof Zn||i instanceof Qr||i instanceof Mo)&&i.destroy()}}}class Ts{constructor(e,i,n=()=>!0){this.programConfigurations={};for(const a of e)this.programConfigurations[a.id]=new Io(a,i,n);this.needsUpload=!1,this._featureMap=new pu,this._bufferOffset=0}populatePaintArrays(e,i,n,a,c,h,p){for(const m in this.programConfigurations)this.programConfigurations[m].populatePaintArrays(e,i,a,c,h,p);i.id!==void 0&&this._featureMap.add(i.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,n,a,c){for(const h of n)this.needsUpload=this.programConfigurations[h.id].updatePaintArrays(e,this._featureMap,i,h,a,c)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const B_={"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","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function O_(t,e){return B_[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const F_={"line-pattern":{source:pe,composite:pe},"fill-pattern":{source:pe,composite:pe},"fill-extrusion-pattern":{source:pe,composite:pe},"line-dasharray":{source:Ee,composite:Ee}},U_={color:{source:Rr,composite:ze},number:{source:Vt,composite:Rr}};function np(t,e,i){const n=F_[t];return n&&n[i]||U_[e][i]}Xe(Gl,"ConstantBinder"),Xe(ba,"PatternConstantBinder"),Xe(Zn,"SourceExpressionBinder"),Xe(Mo,"PatternCompositeBinder"),Xe(Qr,"CompositeExpressionBinder"),Xe(Io,"ProgramConfiguration",{omit:["_buffers"]}),Xe(Ts,"ProgramConfigurationSet");const op="-transition";class en extends Ko{constructor(e,i){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&e.type!=="sky"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),i.layout&&(this._unevaluatedLayout=new N(i.layout)),i.paint)){this._transitionablePaint=new C(i.paint);for(const n in e.paint)this.setPaintProperty(n,e.paint[n],{validate:!1});for(const n in e.layout)this.setLayoutProperty(n,e.layout[n],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new j(i.paint)}}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,i,n={}){i!=null&&this._validate(Eh,`layers.${this.id}.layout.${e}`,e,i,n)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,i):this.visibility=i)}getPaintProperty(e){return to(e,op)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i,n={}){if(i!=null&&this._validate(Th,`layers.${this.id}.paint.${e}`,e,i,n))return!1;if(to(e,op))return this._transitionablePaint.setTransition(e.slice(0,-11),i||void 0),!1;{const a=this._transitionablePaint._values[e],c=a.value.isDataDriven(),h=a.value;this._transitionablePaint.setValue(e,i),this._handleSpecialPaintPropertyUpdate(e);const p=this._transitionablePaint._values[e].value,m=p.isDataDriven(),_=to(e,"pattern")||e==="line-dasharray";return m||c||_||this._handleOverridablePaintPropertyUpdate(e,h,p)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,i,n){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),io(e,(i,n)=>!(i===void 0||n==="layout"&&!Object.keys(i).length||n==="paint"&&!Object.keys(i).length))}_validate(e,i,n,a,c={}){return(!c||c.validate!==!1)&&cu(this,e.call(lu,{key:i,layerType:this.type,objectKey:n,value:a,styleSpec:be,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const i=this.paint.get(e);if(i instanceof U&&xo(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=ma(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const N_=se([{name:"a_pos",components:2,type:"Int16"}],4),j_=se([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Ti{constructor(e=[]){this.segments=e}prepareSegment(e,i,n,a){let c=this.segments[this.segments.length-1];return e>Ti.MAX_VERTEX_ARRAY_LENGTH&&li(`Max vertices per segment is ${Ti.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!c||c.vertexLength+e>Ti.MAX_VERTEX_ARRAY_LENGTH||c.sortKey!==a)&&(c={vertexOffset:i.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},a!==void 0&&(c.sortKey=a),this.segments.push(c)),c}get(){return this.segments}destroy(){for(const e of this.segments)for(const i in e.vaos)e.vaos[i].destroy()}static simpleSegment(e,i,n,a){return new Ti([{vertexOffset:e,primitiveOffset:i,vertexLength:n,primitiveLength:a,vaos:{},sortKey:0}])}}Ti.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Xe(Ti,"SegmentVector");var nt=8192;class Co{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):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 qt?new qt(e.lng,e.lat):qt.convert(e),this}setSouthWest(e){return this._sw=e instanceof qt?new qt(e.lng,e.lat):qt.convert(e),this}extend(e){const i=this._sw,n=this._ne;let a,c;if(e instanceof qt)a=e,c=e;else{if(!(e instanceof Co))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Co.convert(e)):this.extend(qt.convert(e)):typeof e=="object"&&e!==null&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(qt.convert(e)):this;if(a=e._sw,c=e._ne,!a||!c)return this}return i||n?(i.lng=Math.min(a.lng,i.lng),i.lat=Math.min(a.lat,i.lat),n.lng=Math.max(c.lng,n.lng),n.lat=Math.max(c.lat,n.lat)):(this._sw=new qt(a.lng,a.lat),this._ne=new qt(c.lng,c.lat)),this}getCenter(){return new qt((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 qt(this.getWest(),this.getNorth())}getSouthEast(){return new qt(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:i,lat:n}=qt.convert(e);let a=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&a}static convert(e){return!e||e instanceof Co?e:new Co(e)}}var _u=1e-6,gr=typeof Float32Array<"u"?Float32Array:Array;function sp(){var t=new gr(9);return gr!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function ap(t,e,i){var n=e[0],a=e[1],c=e[2],h=e[3],p=e[4],m=e[5],_=e[6],x=e[7],b=e[8],T=i[0],A=i[1],M=i[2],z=i[3],B=i[4],V=i[5],K=i[6],G=i[7],X=i[8];return t[0]=T*n+A*h+M*_,t[1]=T*a+A*p+M*x,t[2]=T*c+A*m+M*b,t[3]=z*n+B*h+V*_,t[4]=z*a+B*p+V*x,t[5]=z*c+B*m+V*b,t[6]=K*n+G*h+X*_,t[7]=K*a+G*p+X*x,t[8]=K*c+G*m+X*b,t}function tn(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function kh(t,e){var i=e[0],n=e[1],a=e[2],c=e[3],h=e[4],p=e[5],m=e[6],_=e[7],x=e[8],b=e[9],T=e[10],A=e[11],M=e[12],z=e[13],B=e[14],V=e[15],K=i*p-n*h,G=i*m-a*h,X=i*_-c*h,Y=n*m-a*p,J=n*_-c*p,me=a*_-c*m,de=x*z-b*M,Te=x*B-T*M,Le=x*V-A*M,ye=b*B-T*z,Ae=b*V-A*z,Me=T*V-A*B,Ce=K*Me-G*Ae+X*ye+Y*Le-J*Te+me*de;return Ce?(t[0]=(p*Me-m*Ae+_*ye)*(Ce=1/Ce),t[1]=(a*Ae-n*Me-c*ye)*Ce,t[2]=(z*me-B*J+V*Y)*Ce,t[3]=(T*J-b*me-A*Y)*Ce,t[4]=(m*Le-h*Me-_*Te)*Ce,t[5]=(i*Me-a*Le+c*Te)*Ce,t[6]=(B*X-M*me-V*G)*Ce,t[7]=(x*me-T*X+A*G)*Ce,t[8]=(h*Ae-p*Le+_*de)*Ce,t[9]=(n*Le-i*Ae-c*de)*Ce,t[10]=(M*J-z*X+V*K)*Ce,t[11]=(b*X-x*J-A*K)*Ce,t[12]=(p*Te-h*ye-m*de)*Ce,t[13]=(i*ye-n*Te+a*de)*Ce,t[14]=(z*G-M*Y-B*K)*Ce,t[15]=(x*Y-b*G+T*K)*Ce,t):null}function Es(t,e,i){var n=e[0],a=e[1],c=e[2],h=e[3],p=e[4],m=e[5],_=e[6],x=e[7],b=e[8],T=e[9],A=e[10],M=e[11],z=e[12],B=e[13],V=e[14],K=e[15],G=i[0],X=i[1],Y=i[2],J=i[3];return t[0]=G*n+X*p+Y*b+J*z,t[1]=G*a+X*m+Y*T+J*B,t[2]=G*c+X*_+Y*A+J*V,t[3]=G*h+X*x+Y*M+J*K,t[4]=(G=i[4])*n+(X=i[5])*p+(Y=i[6])*b+(J=i[7])*z,t[5]=G*a+X*m+Y*T+J*B,t[6]=G*c+X*_+Y*A+J*V,t[7]=G*h+X*x+Y*M+J*K,t[8]=(G=i[8])*n+(X=i[9])*p+(Y=i[10])*b+(J=i[11])*z,t[9]=G*a+X*m+Y*T+J*B,t[10]=G*c+X*_+Y*A+J*V,t[11]=G*h+X*x+Y*M+J*K,t[12]=(G=i[12])*n+(X=i[13])*p+(Y=i[14])*b+(J=i[15])*z,t[13]=G*a+X*m+Y*T+J*B,t[14]=G*c+X*_+Y*A+J*V,t[15]=G*h+X*x+Y*M+J*K,t}function $l(t,e,i){var n,a,c,h,p,m,_,x,b,T,A,M,z=i[0],B=i[1],V=i[2];return e===t?(t[12]=e[0]*z+e[4]*B+e[8]*V+e[12],t[13]=e[1]*z+e[5]*B+e[9]*V+e[13],t[14]=e[2]*z+e[6]*B+e[10]*V+e[14],t[15]=e[3]*z+e[7]*B+e[11]*V+e[15]):(a=e[1],c=e[2],h=e[3],p=e[4],m=e[5],_=e[6],x=e[7],b=e[8],T=e[9],A=e[10],M=e[11],t[0]=n=e[0],t[1]=a,t[2]=c,t[3]=h,t[4]=p,t[5]=m,t[6]=_,t[7]=x,t[8]=b,t[9]=T,t[10]=A,t[11]=M,t[12]=n*z+p*B+b*V+e[12],t[13]=a*z+m*B+T*V+e[13],t[14]=c*z+_*B+A*V+e[14],t[15]=h*z+x*B+M*V+e[15]),t}function Ss(t,e,i){var n=i[0],a=i[1],c=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*a,t[5]=e[5]*a,t[6]=e[6]*a,t[7]=e[7]*a,t[8]=e[8]*c,t[9]=e[9]*c,t[10]=e[10]*c,t[11]=e[11]*c,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Lh(t,e,i){var n=Math.sin(i),a=Math.cos(i),c=e[4],h=e[5],p=e[6],m=e[7],_=e[8],x=e[9],b=e[10],T=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=c*a+_*n,t[5]=h*a+x*n,t[6]=p*a+b*n,t[7]=m*a+T*n,t[8]=_*a-c*n,t[9]=x*a-h*n,t[10]=b*a-p*n,t[11]=T*a-m*n,t}function gu(t,e,i){var n=Math.sin(i),a=Math.cos(i),c=e[0],h=e[1],p=e[2],m=e[3],_=e[8],x=e[9],b=e[10],T=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=c*a-_*n,t[1]=h*a-x*n,t[2]=p*a-b*n,t[3]=m*a-T*n,t[8]=c*n+_*a,t[9]=h*n+x*a,t[10]=p*n+b*a,t[11]=m*n+T*a,t}function lp(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function cp(t,e,i){var n,a,c,h=i[0],p=i[1],m=i[2],_=Math.hypot(h,p,m);return _<_u?null:(h*=_=1/_,p*=_,m*=_,n=Math.sin(e),a=Math.cos(e),t[0]=h*h*(c=1-a)+a,t[1]=p*h*c+m*n,t[2]=m*h*c-p*n,t[3]=0,t[4]=h*p*c-m*n,t[5]=p*p*c+a,t[6]=m*p*c+h*n,t[7]=0,t[8]=h*m*c+p*n,t[9]=p*m*c-h*n,t[10]=m*m*c+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var V_=Es;function Dh(){var t=new gr(3);return gr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function up(t){var e=new gr(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ql(t){return Math.hypot(t[0],t[1],t[2])}function wa(t,e,i){var n=new gr(3);return n[0]=t,n[1]=e,n[2]=i,n}function Wn(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function Rh(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function hp(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t}function Zl(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t}function Wl(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t}function Ar(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function Xl(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t}function Qi(t,e){var i=e[0],n=e[1],a=e[2],c=i*i+n*n+a*a;return c>0&&(c=1/Math.sqrt(c)),t[0]=e[0]*c,t[1]=e[1]*c,t[2]=e[2]*c,t}function Br(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Bh(t,e,i){var n=e[0],a=e[1],c=e[2],h=i[0],p=i[1],m=i[2];return t[0]=a*m-c*p,t[1]=c*h-n*m,t[2]=n*p-a*h,t}function yi(t,e,i){var n=e[0],a=e[1],c=e[2],h=i[3]*n+i[7]*a+i[11]*c+i[15];return t[0]=(i[0]*n+i[4]*a+i[8]*c+i[12])/(h=h||1),t[1]=(i[1]*n+i[5]*a+i[9]*c+i[13])/h,t[2]=(i[2]*n+i[6]*a+i[10]*c+i[14])/h,t}function dp(t,e,i){var n=i[0],a=i[1],c=i[2],h=e[0],p=e[1],m=e[2],_=a*m-c*p,x=c*h-n*m,b=n*p-a*h,T=a*b-c*x,A=c*_-n*b,M=n*x-a*_,z=2*i[3];return x*=z,b*=z,A*=2,M*=2,t[0]=h+(_*=z)+(T*=2),t[1]=p+x+A,t[2]=m+b+M,t}var Hl,rn=Rh,G_=hp,$_=ql;function pp(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function fp(t,e){var i=e[0],n=e[1],a=e[2],c=e[3],h=i*i+n*n+a*a+c*c;return h>0&&(h=1/Math.sqrt(h)),t[0]=i*h,t[1]=n*h,t[2]=a*h,t[3]=c*h,t}function As(t,e,i){var n=e[0],a=e[1],c=e[2],h=e[3];return t[0]=i[0]*n+i[4]*a+i[8]*c+i[12]*h,t[1]=i[1]*n+i[5]*a+i[9]*c+i[13]*h,t[2]=i[2]*n+i[6]*a+i[10]*c+i[14]*h,t[3]=i[3]*n+i[7]*a+i[11]*c+i[15]*h,t}function mp(){var t=new gr(4);return gr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function _p(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function gp(t,e,i){i*=.5;var n=e[0],a=e[1],c=e[2],h=e[3],p=Math.sin(i),m=Math.cos(i);return t[0]=n*m+h*p,t[1]=a*m+c*p,t[2]=c*m-a*p,t[3]=h*m-n*p,t}function yp(t,e,i){i*=.5;var n=e[0],a=e[1],c=e[2],h=e[3],p=Math.sin(i),m=Math.cos(i);return t[0]=n*m-c*p,t[1]=a*m+h*p,t[2]=c*m+n*p,t[3]=h*m-a*p,t}Dh(),Hl=new gr(4),gr!=Float32Array&&(Hl[0]=0,Hl[1]=0,Hl[2]=0,Hl[3]=0);var q_=fp;Dh(),wa(1,0,0),wa(0,1,0),mp(),mp(),sp();const Z_=se([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:xp}=Z_,vp=se([{name:"a_pos_3",components:3,type:"Int16"}]);var Kl=se([{name:"a_pos",type:"Int16",components:2}]);class Oh{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,n){const a=Br(i,this.dir);if(Math.abs(a)<1e-6)return!1;const c=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1]+(e[2]-this.pos[2])*i[2])/a;return n[0]=this.pos[0]+this.dir[0]*c,n[1]=this.pos[1]+this.dir[1]*c,n[2]=this.pos[2]+this.dir[2]*c,!0}closestPointOnSphere(e,i,n){if(function(A,M){var z=A[0],B=A[1],V=A[2],K=M[0],G=M[1],X=M[2];return Math.abs(z-K)<=_u*Math.max(1,Math.abs(z),Math.abs(K))&&Math.abs(B-G)<=_u*Math.max(1,Math.abs(B),Math.abs(G))&&Math.abs(V-X)<=_u*Math.max(1,Math.abs(V),Math.abs(X))}(this.pos,e)||i===0)return n[0]=n[1]=n[2]=0,!1;const[a,c,h]=this.dir,p=this.pos[0]-e[0],m=this.pos[1]-e[1],_=this.pos[2]-e[2],x=a*a+c*c+h*h,b=2*(p*a+m*c+_*h),T=b*b-4*x*(p*p+m*m+_*_-i*i);if(T<0){const A=Math.max(-b/2,0),M=p+a*A,z=m+c*A,B=_+h*A,V=Math.hypot(M,z,B);return n[0]=M*i/V,n[1]=z*i/V,n[2]=B*i/V,!1}{const A=(-b-Math.sqrt(T))/(2*x);if(A<0){const M=Math.hypot(p,m,_);return n[0]=p*i/M,n[1]=m*i/M,n[2]=_*i/M,!1}return n[0]=p+a*A,n[1]=m+c*A,n[2]=_+h*A,!0}}}class Fh{constructor(e,i,n,a,c){this.TL=e,this.TR=i,this.BR=n,this.BL=a,this.horizon=c}static fromInvProjectionMatrix(e,i,n){const a=[-1,1,1],c=[1,1,1],h=[1,-1,1],p=[-1,-1,1],m=yi(a,a,e),_=yi(c,c,e),x=yi(h,h,e),b=yi(p,p,e);return new Fh(m,_,x,b,i/n)}}class Uh{constructor(e,i){this.points=e,this.planes=i}static fromInvProjectionMatrix(e,i,n,a){const c=Math.pow(2,n),h=[[-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(m=>{const _=As([],m,e),x=1/_[3]/i*c;return function(b,T,A){return b[0]=T[0]*A[0],b[1]=T[1]*A[1],b[2]=T[2]*A[2],b[3]=T[3]*A[3],b}(_,_,[x,x,a?1/_[3]:x,x])}),p=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(m=>{const _=Qi([],Bh([],rn([],h[m[0]],h[m[1]]),rn([],h[m[2]],h[m[1]]))),x=-Br(_,h[m[1]]);return _.concat(x)});return new Uh(h,p)}}class er{static fromPoints(e){const i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const a of e)Zl(i,i,a),Wl(n,n,a);return new er(i,n)}static applyTransform(e,i){const n=e.getCorners();for(let a=0;a<n.length;++a)yi(n[a],n[a],i);return er.fromPoints(n)}constructor(e,i){this.min=e,this.max=i,this.center=Ar([],Wn([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],n=up(this.min),a=up(this.max);for(let c=0;c<i.length;c++)n[c]=i[c]?this.min[c]:this.center[c],a[c]=i[c]?this.center[c]:this.max[c];return a[2]=this.max[2],new er(n,a)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,i=this.max;return[[e[0],e[1],e[2]],[i[0],e[1],e[2]],[i[0],i[1],e[2]],[e[0],i[1],e[2]],[e[0],e[1],i[2]],[i[0],e[1],i[2]],[i[0],i[1],i[2]],[e[0],i[1],i[2]]]}intersects(e){const i=this.getCorners();let n=!0;for(let a=0;a<e.planes.length;a++){const c=e.planes[a];let h=0;for(let p=0;p<i.length;p++)h+=Br(c,i[p])+c[3]>=0;if(h===0)return 0;h!==i.length&&(n=!1)}if(n)return 2;for(let a=0;a<3;a++){let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let p=0;p<e.points.length;p++){const m=e.points[p][a]-this.min[a];c=Math.min(c,m),h=Math.max(h,m)}if(h<0||c>this.max[a]-this.min[a])return 0}return 1}}const Nh=5,bp=6,xn=nt/Math.PI/2,W_=16383,Ms=64,Jl=[Ms,32,16],Or=-xn,Fr=xn,X_=[new er([Or,Or,Or],[Fr,Fr,Fr]),new er([Or,Or,Or],[0,0,Fr]),new er([0,Or,Or],[Fr,0,Fr]),new er([Or,0,Or],[0,Fr,Fr]),new er([0,0,Or],[Fr,Fr,Fr])];function yu(t){return t*xn/ec}function wp(t,e,i,n=!0){const a=Ar([],t._camera.position,t.worldSize),c=[e,i,1,1];As(c,c,t.pixelMatrixInverse),pp(c,c,1/c[3]);const h=Qi([],rn([],c,a)),p=t.globeMatrix,m=[p[12],p[13],p[14]],_=rn([],m,a),x=ql(_),b=Qi([],_),T=t.worldSize/(2*Math.PI),A=Br(b,h),M=Math.asin(T/x);if(M<Math.acos(A)){if(!n)return null;const Le=[],ye=[];Ar(Le,h,x/A),Qi(ye,rn(ye,Le,_)),Qi(h,Wn(h,_,Ar(h,ye,Math.tan(M)*x)))}const z=[];new Oh(a,h).closestPointOnSphere(m,T,z);const B=Qi([],pn(p,0)),V=Qi([],pn(p,1)),K=Qi([],pn(p,2)),G=Br(B,z),X=Br(V,z),Y=Br(K,z),J=ki(Math.asin(-X/T));let me=ki(Math.atan2(G,Y));me=t.center.lng+function(Le,ye){const Ae=(ye-Le+180)%360-180;return Ae<-180?Ae+360:Ae}(t.center.lng,me);const de=bn(me),Te=Tt(wn(J),0,1);return new Aa(de,Te)}class H_{constructor(e,i,n){this.a=rn([],e,n),this.b=rn([],i,n),this.center=n;const a=Qi([],this.a),c=Qi([],this.b);this.angle=Math.acos(Br(a,c))}}function jh(t,e){if(t.angle===0)return null;let i;return i=t.a[e]===0?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[e]/t.a[e]/Math.sin(t.angle)-1/Math.tan(t.angle)),i<0||i>1?null:function(n,a,c,h){const p=Math.sin(c);return n*(Math.sin((1-h)*c)/p)+a*(Math.sin(h*c)/p)}(t.a[e],t.b[e],t.angle,Tt(i,0,1))+t.center[e]}function vn(t){if(t.z<=1)return X_[t.z+2*t.y+t.x];const e=Vh(xu(t));return er.fromPoints(e)}function Is(t,e,i){return Ar(t,t,1-i),Xl(t,t,e,i)}function Tp(t,e){const i=Sa(e.zoom);if(i===0)return vn(t);const n=xu(t),a=Vh(n),c=bn(n.getWest())*e.worldSize,h=bn(n.getEast())*e.worldSize,p=wn(n.getNorth())*e.worldSize,m=wn(n.getSouth())*e.worldSize,_=[c,p,0],x=[h,p,0],b=[c,m,0],T=[h,m,0],A=kh([],e.globeMatrix);return yi(_,_,A),yi(x,x,A),yi(b,b,A),yi(T,T,A),a[0]=Is(a[0],b,i),a[1]=Is(a[1],T,i),a[2]=Is(a[2],x,i),a[3]=Is(a[3],_,i),er.fromPoints(a)}function Ep(t,e,i){for(const n of t)yi(n,n,e),Ar(n,n,i)}function K_(t,e,i){const n=e/t.worldSize,a=t.globeMatrix;if(i.z<=1){const de=vn(i).getCorners();return Ep(de,a,n),er.fromPoints(de)}const c=xu(i),h=Vh(c);Ep(h,a,n);const p=Number.MAX_VALUE,m=[-p,-p,-p],_=[p,p,p];if(c.contains(t.center)){for(const Le of h)Zl(_,_,Le),Wl(m,m,Le);m[2]=0;const de=t.point,Te=[de.x*n,de.y*n,0];return Zl(_,_,Te),Wl(m,m,Te),new er(_,m)}const x=[a[12]*n,a[13]*n,a[14]*n],b=c.getCenter(),T=Tt(t.center.lat,-Wi,Wi),A=Tt(b.lat,-Wi,Wi),M=bn(t.center.lng),z=wn(T);let B=M-bn(b.lng);const V=z-wn(A);B>.5?B-=1:B<-.5&&(B+=1);let K=0;Math.abs(B)>Math.abs(V)?K=B>=0?1:3:(K=V>=0?0:2,Xl(x,x,[a[4]*n,a[5]*n,a[6]*n],-Math.sin(At(V>=0?c.getSouth():c.getNorth()))*xn));const G=h[K],X=h[(K+1)%4],Y=new H_(G,X,x),J=[jh(Y,0)||G[0],jh(Y,1)||G[1],jh(Y,2)||G[2]],me=Sa(t.zoom);if(me>0){const de=function({x:Le,y:ye,z:Ae},Me,Ce,Fe,ve){const Ve=1/(1<<Ae);let Ke=Le*Ve,Ge=Ke+Ve,ct=ye*Ve,Ue=ct+Ve,rt=0;const ut=(Ke+Ge)/2-Fe;return ut>.5?rt=-1:ut<-.5&&(rt=1),Ke=((Ke+rt)*Me-(Fe*=Me))*Ce+Fe,Ge=((Ge+rt)*Me-Fe)*Ce+Fe,ct=(ct*Me-(ve*=Me))*Ce+ve,Ue=(Ue*Me-ve)*Ce+ve,[[Ke,Ue,0],[Ge,Ue,0],[Ge,ct,0],[Ke,ct,0]]}(i,e,t._pixelsPerMercatorPixel,M,z);for(let Le=0;Le<h.length;Le++)Is(h[Le],de[Le],me);const Te=Wn([],de[K],de[(K+1)%4]);Ar(Te,Te,.5),Is(J,Te,me)}for(const de of h)Zl(_,_,de),Wl(m,m,de);return _[2]=Math.min(G[2],X[2]),Zl(_,_,J),Wl(m,m,J),new er(_,m)}function xu({x:t,y:e,z:i}){const n=1/(1<<i),a=new qt(Mr(t*n),Zi((e+1)*n)),c=new qt(Mr((t+1)*n),Zi(e*n));return new Co(a,c)}function Vh(t){const e=At(t.getNorth()),i=At(t.getSouth()),n=Math.cos(e),a=Math.cos(i),c=Math.sin(e),h=Math.sin(i),p=t.getWest(),m=t.getEast();return[Ta(a,h,p),Ta(a,h,m),Ta(n,c,m),Ta(n,c,p)]}function Ta(t,e,i,n=xn){return i=At(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function Ea(t,e,i){return Ta(Math.cos(At(t)),Math.sin(At(t)),e,i)}function Yl(t,e,i,n){const a=1<<i.z,c=(t/nt+i.x)/a;return Ea(Zi((e/nt+i.y)/a),Mr(c),n)}function vu({min:t,max:e}){return W_/Math.max(e[0]-t[0],e[1]-t[1],e[2]-t[2])}const Sp=new Float64Array(16);function Ql(t){const e=vu(t),i=lp(Sp,[e,e,e]);return $l(i,i,((n=[])[0]=-(a=t.min)[0],n[1]=-a[1],n[2]=-a[2],n));var n,a}function Gh(t){const e=(n=t.min,(i=Sp)[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=n[0],i[13]=n[1],i[14]=n[2],i[15]=1,i);var i,n;const a=1/vu(t);return Ss(e,e,[a,a,a])}function Ap(t,e,i,n,a){const c=function(m){const _=nt/(2*Math.PI);return m/(2*Math.PI)/_}(i),h=[t,e,-i/(2*Math.PI)],p=tn(new Float64Array(16));return $l(p,p,h),Ss(p,p,[c,c,c]),Lh(p,p,At(-a)),gu(p,p,At(-n)),p}function Sa(t){return Qn(Nh,bp,t)}function Mp(t,e){const i=Ea(e.lat,e.lng),n=function(M){const z=Ea(M._center.lat,M._center.lng);let B=Bh([],wa(0,1,0),z);const V=cp([],-M.angle,z);B=yi(B,B,V),cp(V,-M._pitch,B);const K=Qi([],z);return Ar(K,K,yu(M.cameraToCenterDistance/M.pixelsPerMeter)),yi(K,K,V),Wn([],z,K)}(t);return h=(a=Rh([],n,i))[0],p=a[1],m=a[2],_=(c=i)[0],x=c[1],b=c[2],A=(T=Math.sqrt(h*h+p*p+m*m)*Math.sqrt(_*_+x*x+b*b))&&Br(a,c)/T,Math.acos(Math.min(Math.max(A,-1),1));var a,c,h,p,m,_,x,b,T,A}function $h(t,e){return Mp(t,e)>Math.PI/2*1.01}const Ip=At(85),J_=Math.cos(Ip),Y_=Math.sin(Ip),ec=63710088e-1,Cp=2*Math.PI*ec;class Po{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,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 Po(zi(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const i=Math.PI/180,n=this.lat*i,a=e.lat*i,c=Math.sin(n)*Math.sin(a)+Math.cos(n)*Math.cos(a)*Math.cos((e.lng-this.lng)*i);return ec*Math.acos(Math.min(c,1))}toBounds(e=0){const i=360*e/40075017,n=i/Math.cos(Math.PI/180*this.lat);return new Co(new Po(this.lng-n,this.lat-i),new Po(this.lng+n,this.lat+i))}toEcef(e){const i=yu(e);return Ea(this.lat,this.lng,xn+i)}static convert(e){if(e instanceof Po)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Po(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Po(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}var qt=Po;function qh(t){return Cp*Math.cos(t*Math.PI/180)}function bn(t){return(180+t)/360}function wn(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function nn(t,e){return t/qh(e)}function Mr(t){return 360*t-180}function Zi(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Pp(t,e){return t*qh(Zi(e))}const Wi=85.051129;function zp(t){return 1/Math.cos(t*Math.PI/180)}class Aa{constructor(e,i,n=0){this.x=+e,this.y=+i,this.z=+n}static fromLngLat(e,i=0){const n=qt.convert(e);return new Aa(bn(n.lng),wn(n.lat),nn(i,n.lat))}toLngLat(){return new qt(Mr(this.x),Zi(this.y))}toAltitude(){return Pp(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Cp*zp(Zi(this.y))}}function Zh(t,e,i,n,a,c,h,p,m){const _=(e+n)/2,x=(i+a)/2,b=new Re(_,x);p(b),function(T,A,M,z,B,V){const K=M-B,G=z-V;return Math.abs((z-A)*K-(M-T)*G)/Math.hypot(K,G)}(b.x,b.y,c.x,c.y,h.x,h.y)>=m?(Zh(t,e,i,_,x,c,b,p,m),Zh(t,_,x,n,a,b,h,p,m)):t.push(h)}function kp(t,e,i){let n=t[0],a=n.x,c=n.y;e(n);const h=[n];for(let p=1;p<t.length;p++){const m=t[p],{x:_,y:x}=m;e(m),Zh(h,a,c,_,x,n,m,e,i),a=_,c=x,n=m}return h}function Wh(t,e,i,n){if(n(e,i)){const a=e.add(i)._mult(.5);Wh(t,e,a,n),Wh(t,a,i,n)}else t.push(i)}function Q_(t,e){let i=t[0];const n=[i];for(let a=1;a<t.length;a++){const c=t[a];Wh(n,i,c,e),i=c}return n}const Xh=Math.pow(2,14)-1,Lp=-Xh-1;function eg(t,e){const i=Math.round(t.x*e),n=Math.round(t.y*e);return t.x=Tt(i,Lp,Xh),t.y=Tt(n,Lp,Xh),(i<t.x||i>t.x+1||n<t.y||n>t.y+1)&&li("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Xn(t,e,i){const n=t.loadGeometry(),a=t.extent,c=nt/a;if(e&&i&&i.projection.isReprojectedInTileSpace){const h=1<<e.z,{scale:p,x:m,y:_,projection:x}=i,b=T=>{const A=Mr((e.x+T.x/a)/h),M=Zi((e.y+T.y/a)/h),z=x.project(A,M);T.x=(z.x*p-m)*a,T.y=(z.y*p-_)*a};for(let T=0;T<n.length;T++)if(t.type!==1)n[T]=kp(n[T],b,1);else{const A=[];for(const M of n[T])M.x<0||M.x>=a||M.y<0||M.y>=a||(b(M),A.push(M));n[T]=A}}for(const h of n)for(const p of h)eg(p,c);return n}function Cs(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Xn(t):[]}}function bu(t,e,i,n,a){t.emplaceBack(2*e+(n+1)/2,2*i+(a+1)/2)}function wu(t,e,i){t.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class Hh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new ke,this.indexArray=new tt,this.segments=new Ti,this.programConfigurations=new Ts(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(e,i,n,a){const c=this.layers[0],h=[];let p=null;c.type==="circle"&&(p=c.layout.get("circle-sort-key"));for(const{feature:_,id:x,index:b,sourceLayerIndex:T}of e){const A=this.layers[0]._featureFilter.needGeometry,M=Cs(_,A);if(!this.layers[0]._featureFilter.filter(new v(this.zoom),M,n))continue;const z=p?p.evaluate(M,{},n):void 0,B={id:x,properties:_.properties,type:_.type,sourceLayerIndex:T,index:b,geometry:A?M.geometry:Xn(_,n,a),patterns:{},sortKey:z};h.push(B)}p&&h.sort((_,x)=>_.sortKey-x.sortKey);let m=null;a.projection.name==="globe"&&(this.globeExtVertexArray=new De,m=a.projection);for(const _ of h){const{geometry:x,index:b,sourceLayerIndex:T}=_,A=e[b].feature;this.addFeature(_,x,b,i.availableImages,n,m),i.featureIndex.insert(A,x,b,T,this.index)}}update(e,i,n,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,n,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,N_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,j_.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,i,n,a,c,h){for(const p of i)for(const m of p){const _=m.x,x=m.y;if(_<0||_>=nt||x<0||x>=nt)continue;if(h){const A=h.projectTilePoint(_,x,c),M=h.upVector(c,_,x),z=this.globeExtVertexArray;wu(z,A,M),wu(z,A,M),wu(z,A,M),wu(z,A,M)}const b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),T=b.vertexLength;bu(this.layoutVertexArray,_,x,-1,-1),bu(this.layoutVertexArray,_,x,1,-1),bu(this.layoutVertexArray,_,x,1,1),bu(this.layoutVertexArray,_,x,-1,1),this.indexArray.emplaceBack(T,T+1,T+2),this.indexArray.emplaceBack(T,T+2,T+3),b.vertexLength+=4,b.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},a,c)}}function Dp(t,e){for(let i=0;i<t.length;i++)if(Ps(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ps(t,e[i]))return!0;return!!Kh(t,e)}function tg(t,e,i){return!!Ps(t,e)||!!Jh(e,t,i)}function Rp(t,e){if(t.length===1)return Op(e,t[0]);for(let i=0;i<e.length;i++){const n=e[i];for(let a=0;a<n.length;a++)if(Ps(t,n[a]))return!0}for(let i=0;i<t.length;i++)if(Op(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Kh(t,e[i]))return!0;return!1}function ig(t,e,i){if(t.length>1){if(Kh(t,e))return!0;for(let n=0;n<e.length;n++)if(Jh(e[n],t,i))return!0}for(let n=0;n<t.length;n++)if(Jh(t[n],e,i))return!0;return!1}function Kh(t,e){if(t.length===0||e.length===0)return!1;for(let i=0;i<t.length-1;i++){const n=t[i],a=t[i+1];for(let c=0;c<e.length-1;c++)if(rg(n,a,e[c],e[c+1]))return!0}return!1}function rg(t,e,i,n){return ur(t,i,n)!==ur(e,i,n)&&ur(t,e,i)!==ur(t,e,n)}function Jh(t,e,i){const n=i*i;if(e.length===1)return t.distSqr(e[0])<n;for(let a=1;a<e.length;a++)if(Bp(t,e[a-1],e[a])<n)return!0;return!1}function Bp(t,e,i){const n=e.distSqr(i);if(n===0)return t.distSqr(e);const a=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n;return t.distSqr(a<0?e:a>1?i:i.sub(e)._mult(a)._add(e))}function Op(t,e){let i,n,a,c=!1;for(let h=0;h<t.length;h++){i=t[h];for(let p=0,m=i.length-1;p<i.length;m=p++)n=i[p],a=i[m],n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(c=!c)}return c}function Ps(t,e){let i=!1;for(let n=0,a=t.length-1;n<t.length;a=n++){const c=t[n],h=t[a];c.y>e.y!=h.y>e.y&&e.x<(h.x-c.x)*(e.y-c.y)/(h.y-c.y)+c.x&&(i=!i)}return i}function Fp(t,e,i,n,a){for(const h of t)if(e<=h.x&&i<=h.y&&n>=h.x&&a>=h.y)return!0;const c=[new Re(e,i),new Re(e,a),new Re(n,a),new Re(n,i)];if(t.length>2){for(const h of c)if(Ps(t,h))return!0}for(let h=0;h<t.length-1;h++)if(ng(t[h],t[h+1],c))return!0;return!1}function ng(t,e,i){const n=i[0],a=i[2];if(t.x<n.x&&e.x<n.x||t.x>a.x&&e.x>a.x||t.y<n.y&&e.y<n.y||t.y>a.y&&e.y>a.y)return!1;const c=ur(t,e,i[0]);return c!==ur(t,e,i[1])||c!==ur(t,e,i[2])||c!==ur(t,e,i[3])}function Ma(t,e,i){const n=e.paint.get(t).value;return n.kind==="constant"?n.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Tu(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Up(t,e,i,n,a){if(!e[0]&&!e[1])return t;const c=Re.convert(e)._mult(a);i==="viewport"&&c._rotate(-n);const h=[];for(let p=0;p<t.length;p++)h.push(t[p].sub(c));return h}function Np(t,e,i,n){const a=Re.convert(t)._mult(n);return e==="viewport"&&a._rotate(-i),a}Xe(Hh,"CircleBucket",{omit:["layers"]});const og=new q({"circle-sort-key":new O(be.layout_circle["circle-sort-key"])});var sg={paint:new q({"circle-radius":new O(be.paint_circle["circle-radius"]),"circle-color":new O(be.paint_circle["circle-color"]),"circle-blur":new O(be.paint_circle["circle-blur"]),"circle-opacity":new O(be.paint_circle["circle-opacity"]),"circle-translate":new P(be.paint_circle["circle-translate"]),"circle-translate-anchor":new P(be.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new P(be.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new P(be.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new O(be.paint_circle["circle-stroke-width"]),"circle-stroke-color":new O(be.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new O(be.paint_circle["circle-stroke-opacity"])}),layout:og};function jp(t,e,i,n,a,c,h,p,m){if(c&&t.queryGeometry.isAboveHorizon)return!1;c&&(m*=t.pixelToTileUnitsFactor);const _=t.tileID.canonical,x=i.projection.upVectorScale(_,i.center.lat,i.worldSize).metersToTile;for(const b of e)for(const T of b){const A=T.add(p),M=a&&i.elevation?i.elevation.exaggeration()*a.getElevationAt(A.x,A.y,!0):0,z=i.projection.projectTilePoint(A.x,A.y,_);if(M>0){const G=i.projection.upVector(_,A.x,A.y);z.x+=G[0]*x*M,z.y+=G[1]*x*M,z.z+=G[2]*x*M}const B=c?A:ag(z.x,z.y,z.z,n),V=c?t.tilespaceRays.map(G=>cg(G,M)):t.queryGeometry.screenGeometry,K=As([],[z.x,z.y,z.z,1],n);if(!h&&c?m*=K[3]/i.cameraToCenterDistance:h&&!c&&(m*=i.cameraToCenterDistance/K[3]),c){const G=Zi((T.y/nt+_.y)/(1<<_.z));m/=i.projection.pixelsPerMeter(G,1)/nn(1,G)}if(tg(V,B,m))return!0}return!1}function ag(t,e,i,n){const a=As([],[t,e,i,1],n);return new Re(a[0]/a[3],a[1]/a[3])}const Vp=wa(0,0,0),lg=wa(0,0,1);function cg(t,e){const i=Dh();return Vp[2]=e,t.intersectsPlane(Vp,lg,i),new Re(i[0],i[1])}class Gp extends Hh{}function $p(t,{width:e,height:i},n,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==e*i*n)throw new RangeError("mismatched image size")}else a=new Uint8Array(e*i*n);return t.width=e,t.height=i,t.data=a,t}function qp(t,e,i){const{width:n,height:a}=e;n===t.width&&a===t.height||(Yh(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,n),height:Math.min(t.height,a)},i),t.width=n,t.height=a,t.data=e.data)}function Yh(t,e,i,n,a,c){if(a.width===0||a.height===0)return e;if(a.width>t.width||a.height>t.height||i.x>t.width-a.width||i.y>t.height-a.height)throw new RangeError("out of range source coordinates for image copy");if(a.width>e.width||a.height>e.height||n.x>e.width-a.width||n.y>e.height-a.height)throw new RangeError("out of range destination coordinates for image copy");const h=t.data,p=e.data;for(let m=0;m<a.height;m++){const _=((i.y+m)*t.width+i.x)*c,x=((n.y+m)*e.width+n.x)*c;for(let b=0;b<a.width*c;b++)p[x+b]=h[_+b]}return e}Xe(Gp,"HeatmapBucket",{omit:["layers"]});class Hn{constructor(e,i){$p(this,e,1,i)}resize(e){qp(this,new Hn(e),1)}clone(){return new Hn({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,n,a,c){Yh(e,i,n,a,c,1)}}class yr{constructor(e,i){$p(this,e,4,i)}resize(e){qp(this,new yr(e),4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new yr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,n,a,c){Yh(e,i,n,a,c,4)}}Xe(Hn,"AlphaImage"),Xe(yr,"RGBAImage");var ug={paint:new q({"heatmap-radius":new O(be.paint_heatmap["heatmap-radius"]),"heatmap-weight":new O(be.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new P(be.paint_heatmap["heatmap-intensity"]),"heatmap-color":new $(be.paint_heatmap["heatmap-color"]),"heatmap-opacity":new P(be.paint_heatmap["heatmap-opacity"])})};function Qh(t){const e={},i=t.resolution||256,n=t.clips?t.clips.length:1,a=t.image||new yr({width:i,height:n}),c=(h,p,m)=>{e[t.evaluationKey]=m;const _=t.expression.evaluate(e);a.data[h+p+0]=Math.floor(255*_.r/_.a),a.data[h+p+1]=Math.floor(255*_.g/_.a),a.data[h+p+2]=Math.floor(255*_.b/_.a),a.data[h+p+3]=Math.floor(255*_.a)};if(t.clips)for(let h=0,p=0;h<n;++h,p+=4*i)for(let m=0,_=0;m<i;m++,_+=4){const x=m/(i-1),{start:b,end:T}=t.clips[h];c(p,_,b*(1-x)+T*x)}else for(let h=0,p=0;h<i;h++,p+=4)c(0,p,h/(i-1));return a}var hg={paint:new q({"hillshade-illumination-direction":new P(be.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new P(be.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new P(be.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new P(be.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new P(be.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new P(be.paint_hillshade["hillshade-accent-color"])})};const dg=se([{name:"a_pos",components:2,type:"Int16"}],4),{members:pg}=dg;var ed={exports:{}};function Eu(t,e,i){i=i||2;var n,a,c,h,p,m,_,x=e&&e.length,b=x?e[0]*i:t.length,T=Zp(t,0,b,i,!0),A=[];if(!T||T.next===T.prev)return A;if(x&&(T=function(z,B,V,K){var G,X,Y,J=[];for(G=0,X=B.length;G<X;G++)(Y=Zp(z,B[G]*K,G<X-1?B[G+1]*K:z.length,K,!1))===Y.next&&(Y.steiner=!0),J.push(bg(Y));for(J.sort(yg),G=0;G<J.length;G++)V=xg(J[G],V);return V}(t,e,T,i)),t.length>80*i){n=c=t[0],a=h=t[1];for(var M=i;M<b;M+=i)(p=t[M])<n&&(n=p),(m=t[M+1])<a&&(a=m),p>c&&(c=p),m>h&&(h=m);_=(_=Math.max(c-n,h-a))!==0?32767/_:0}return tc(T,A,i,n,a,_,0),A}function Zp(t,e,i,n,a){var c,h;if(a===rd(t,e,i,n)>0)for(c=e;c<i;c+=n)h=Hp(c,t[c],t[c+1],h);else for(c=i-n;c>=e;c-=n)h=Hp(c,t[c],t[c+1],h);return h&&Su(h,h.next)&&(rc(h),h=h.next),h}function zs(t,e){if(!t)return t;e||(e=t);var i,n=t;do if(i=!1,n.steiner||!Su(n,n.next)&&Ei(n.prev,n,n.next)!==0)n=n.next;else{if(rc(n),(n=e=n.prev)===n.next)break;i=!0}while(i||n!==e);return e}function tc(t,e,i,n,a,c,h){if(t){!h&&c&&function(x,b,T,A){var M=x;do M.z===0&&(M.z=td(M.x,M.y,b,T,A)),M.prevZ=M.prev,M.nextZ=M.next,M=M.next;while(M!==x);M.prevZ.nextZ=null,M.prevZ=null,function(z){var B,V,K,G,X,Y,J,me,de=1;do{for(V=z,z=null,X=null,Y=0;V;){for(Y++,K=V,J=0,B=0;B<de&&(J++,K=K.nextZ);B++);for(me=de;J>0||me>0&&K;)J!==0&&(me===0||!K||V.z<=K.z)?(G=V,V=V.nextZ,J--):(G=K,K=K.nextZ,me--),X?X.nextZ=G:z=G,G.prevZ=X,X=G;V=K}X.nextZ=null,de*=2}while(Y>1)}(M)}(t,n,a,c);for(var p,m,_=t;t.prev!==t.next;)if(p=t.prev,m=t.next,c?mg(t,n,a,c):fg(t))e.push(p.i/i|0),e.push(t.i/i|0),e.push(m.i/i|0),rc(t),t=m.next,_=m.next;else if((t=m)===_){h?h===1?tc(t=_g(zs(t),e,i),e,i,n,a,c,2):h===2&&gg(t,e,i,n,a,c):tc(zs(t),e,i,n,a,c,1);break}}}function fg(t){var e=t.prev,i=t,n=t.next;if(Ei(e,i,n)>=0)return!1;for(var a=e.x,c=i.x,h=n.x,p=e.y,m=i.y,_=n.y,x=a<c?a<h?a:h:c<h?c:h,b=p<m?p<_?p:_:m<_?m:_,T=a>c?a>h?a:h:c>h?c:h,A=p>m?p>_?p:_:m>_?m:_,M=n.next;M!==e;){if(M.x>=x&&M.x<=T&&M.y>=b&&M.y<=A&&Ia(a,p,c,m,h,_,M.x,M.y)&&Ei(M.prev,M,M.next)>=0)return!1;M=M.next}return!0}function mg(t,e,i,n){var a=t.prev,c=t,h=t.next;if(Ei(a,c,h)>=0)return!1;for(var p=a.x,m=c.x,_=h.x,x=a.y,b=c.y,T=h.y,A=p<m?p<_?p:_:m<_?m:_,M=x<b?x<T?x:T:b<T?b:T,z=p>m?p>_?p:_:m>_?m:_,B=x>b?x>T?x:T:b>T?b:T,V=td(A,M,e,i,n),K=td(z,B,e,i,n),G=t.prevZ,X=t.nextZ;G&&G.z>=V&&X&&X.z<=K;){if(G.x>=A&&G.x<=z&&G.y>=M&&G.y<=B&&G!==a&&G!==h&&Ia(p,x,m,b,_,T,G.x,G.y)&&Ei(G.prev,G,G.next)>=0||(G=G.prevZ,X.x>=A&&X.x<=z&&X.y>=M&&X.y<=B&&X!==a&&X!==h&&Ia(p,x,m,b,_,T,X.x,X.y)&&Ei(X.prev,X,X.next)>=0))return!1;X=X.nextZ}for(;G&&G.z>=V;){if(G.x>=A&&G.x<=z&&G.y>=M&&G.y<=B&&G!==a&&G!==h&&Ia(p,x,m,b,_,T,G.x,G.y)&&Ei(G.prev,G,G.next)>=0)return!1;G=G.prevZ}for(;X&&X.z<=K;){if(X.x>=A&&X.x<=z&&X.y>=M&&X.y<=B&&X!==a&&X!==h&&Ia(p,x,m,b,_,T,X.x,X.y)&&Ei(X.prev,X,X.next)>=0)return!1;X=X.nextZ}return!0}function _g(t,e,i){var n=t;do{var a=n.prev,c=n.next.next;!Su(a,c)&&Wp(a,n,n.next,c)&&ic(a,c)&&ic(c,a)&&(e.push(a.i/i|0),e.push(n.i/i|0),e.push(c.i/i|0),rc(n),rc(n.next),n=t=c),n=n.next}while(n!==t);return zs(n)}function gg(t,e,i,n,a,c){var h=t;do{for(var p=h.next.next;p!==h.prev;){if(h.i!==p.i&&wg(h,p)){var m=Xp(h,p);return h=zs(h,h.next),m=zs(m,m.next),tc(h,e,i,n,a,c,0),void tc(m,e,i,n,a,c,0)}p=p.next}h=h.next}while(h!==t)}function yg(t,e){return t.x-e.x}function xg(t,e){var i=function(a,c){var h,p=c,m=a.x,_=a.y,x=-1/0;do{if(_<=p.y&&_>=p.next.y&&p.next.y!==p.y){var b=p.x+(_-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(b<=m&&b>x&&(x=b,h=p.x<p.next.x?p:p.next,b===m))return h}p=p.next}while(p!==c);if(!h)return null;var T,A=h,M=h.x,z=h.y,B=1/0;p=h;do m>=p.x&&p.x>=M&&m!==p.x&&Ia(_<z?m:x,_,M,z,_<z?x:m,_,p.x,p.y)&&(T=Math.abs(_-p.y)/(m-p.x),ic(p,a)&&(T<B||T===B&&(p.x>h.x||p.x===h.x&&vg(h,p)))&&(h=p,B=T)),p=p.next;while(p!==A);return h}(t,e);if(!i)return e;var n=Xp(i,t);return zs(n,n.next),zs(i,i.next)}function vg(t,e){return Ei(t.prev,t,e.prev)<0&&Ei(e.next,t,t.next)<0}function td(t,e,i,n,a){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*a|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*a|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function bg(t){var e=t,i=t;do(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next;while(e!==t);return i}function Ia(t,e,i,n,a,c,h,p){return(a-h)*(e-p)>=(t-h)*(c-p)&&(t-h)*(n-p)>=(i-h)*(e-p)&&(i-h)*(c-p)>=(a-h)*(n-p)}function wg(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(i,n){var a=i;do{if(a.i!==i.i&&a.next.i!==i.i&&a.i!==n.i&&a.next.i!==n.i&&Wp(a,a.next,i,n))return!0;a=a.next}while(a!==i);return!1}(t,e)&&(ic(t,e)&&ic(e,t)&&function(i,n){var a=i,c=!1,h=(i.x+n.x)/2,p=(i.y+n.y)/2;do a.y>p!=a.next.y>p&&a.next.y!==a.y&&h<(a.next.x-a.x)*(p-a.y)/(a.next.y-a.y)+a.x&&(c=!c),a=a.next;while(a!==i);return c}(t,e)&&(Ei(t.prev,t,e.prev)||Ei(t,e.prev,e))||Su(t,e)&&Ei(t.prev,t,t.next)>0&&Ei(e.prev,e,e.next)>0)}function Ei(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Su(t,e){return t.x===e.x&&t.y===e.y}function Wp(t,e,i,n){var a=Mu(Ei(t,e,i)),c=Mu(Ei(t,e,n)),h=Mu(Ei(i,n,t)),p=Mu(Ei(i,n,e));return a!==c&&h!==p||!(a!==0||!Au(t,i,e))||!(c!==0||!Au(t,n,e))||!(h!==0||!Au(i,t,n))||!(p!==0||!Au(i,e,n))}function Au(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Mu(t){return t>0?1:t<0?-1:0}function ic(t,e){return Ei(t.prev,t,t.next)<0?Ei(t,e,t.next)>=0&&Ei(t,t.prev,e)>=0:Ei(t,e,t.prev)<0||Ei(t,t.next,e)<0}function Xp(t,e){var i=new id(t.i,t.x,t.y),n=new id(e.i,e.x,e.y),a=t.next,c=e.prev;return t.next=e,e.prev=t,i.next=a,a.prev=i,n.next=i,i.prev=n,c.next=n,n.prev=c,n}function Hp(t,e,i,n){var a=new id(t,e,i);return n?(a.next=n.next,a.prev=n,n.next.prev=a,n.next=a):(a.prev=a,a.next=a),a}function rc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function id(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function rd(t,e,i,n){for(var a=0,c=e,h=i-n;c<i;c+=n)a+=(t[h]-t[c])*(t[c+1]+t[h+1]),h=c;return a}ed.exports=Eu,ed.exports.default=Eu,Eu.deviation=function(t,e,i,n){var a=e&&e.length,c=Math.abs(rd(t,0,a?e[0]*i:t.length,i));if(a)for(var h=0,p=e.length;h<p;h++)c-=Math.abs(rd(t,e[h]*i,h<p-1?e[h+1]*i:t.length,i));var m=0;for(h=0;h<n.length;h+=3){var _=n[h]*i,x=n[h+1]*i,b=n[h+2]*i;m+=Math.abs((t[_]-t[b])*(t[x+1]-t[_+1])-(t[_]-t[x])*(t[b+1]-t[_+1]))}return c===0&&m===0?0:Math.abs((m-c)/c)},Eu.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},n=0,a=0;a<t.length;a++){for(var c=0;c<t[a].length;c++)for(var h=0;h<e;h++)i.vertices.push(t[a][c][h]);a>0&&i.holes.push(n+=t[a-1].length)}return i};var nd=pi(ed.exports);function Tg(t,e,i,n,a){Kp(t,e,i||0,n||t.length-1,a||Eg)}function Kp(t,e,i,n,a){for(;n>i;){if(n-i>600){var c=n-i+1,h=e-i+1,p=Math.log(c),m=.5*Math.exp(2*p/3),_=.5*Math.sqrt(p*m*(c-m)/c)*(h-c/2<0?-1:1);Kp(t,e,Math.max(i,Math.floor(e-h*m/c+_)),Math.min(n,Math.floor(e+(c-h)*m/c+_)),a)}var x=t[e],b=i,T=n;for(nc(t,i,e),a(t[n],x)>0&&nc(t,i,n);b<T;){for(nc(t,b,T),b++,T--;a(t[b],x)<0;)b++;for(;a(t[T],x)>0;)T--}a(t[i],x)===0?nc(t,i,T):nc(t,++T,n),T<=e&&(i=T+1),e<=T&&(n=T-1)}}function nc(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Eg(t,e){return t<e?-1:t>e?1:0}function od(t,e){const i=t.length;if(i<=1)return[t];const n=[];let a,c;for(let h=0;h<i;h++){const p=js(t[h]);p!==0&&(t[h].area=Math.abs(p),c===void 0&&(c=p<0),c===p<0?(a&&n.push(a),a=[t[h]]):a.push(t[h]))}if(a&&n.push(a),e>1)for(let h=0;h<n.length;h++)n[h].length<=e||(Tg(n[h],e,1,n[h].length-1,Sg),n[h]=n[h].slice(0,e));return n}function Sg(t,e){return e.area-t.area}function sd(t,e,i){const n=i.patternDependencies;let a=!1;for(const c of e){const h=c.paint.get(`${t}-pattern`);h.isConstant()||(a=!0);const p=h.constantOr(null);p&&(a=!0,n[p]=!0)}return a}function ad(t,e,i,n,a){const c=a.patternDependencies;for(const h of e){const p=h.paint.get(`${t}-pattern`).value;if(p.kind!=="constant"){let m=p.evaluate({zoom:n},i,{},a.availableImages);m=m&&m.name?m.name:m,c[m]=!0,i.patterns[h.id]=m}}return i}class Iu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ke,this.indexArray=new tt,this.indexArray2=new Oi,this.programConfigurations=new Ts(e.layers,e.zoom),this.segments=new Ti,this.segments2=new Ti,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection}populate(e,i,n,a){this.hasPattern=sd("fill",this.layers,i);const c=this.layers[0].layout.get("fill-sort-key"),h=[];for(const{feature:p,id:m,index:_,sourceLayerIndex:x}of e){const b=this.layers[0]._featureFilter.needGeometry,T=Cs(p,b);if(!this.layers[0]._featureFilter.filter(new v(this.zoom),T,n))continue;const A=c?c.evaluate(T,{},n,i.availableImages):void 0,M={id:m,properties:p.properties,type:p.type,sourceLayerIndex:x,index:_,geometry:b?T.geometry:Xn(p,n,a),patterns:{},sortKey:A};h.push(M)}c&&h.sort((p,m)=>p.sortKey-m.sortKey);for(const p of h){const{geometry:m,index:_,sourceLayerIndex:x}=p;if(this.hasPattern){const b=ad("fill",this.layers,p,this.zoom,i);this.patternFeatures.push(b)}else this.addFeature(p,m,_,n,{},i.availableImages);i.featureIndex.insert(e[_].feature,m,_,x,this.index)}}update(e,i,n,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,n,a)}addFeatures(e,i,n,a,c){for(const h of this.patternFeatures)this.addFeature(h,h.geometry,h.index,i,n,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,pg),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,i,n,a,c,h=[]){for(const p of od(i,500)){let m=0;for(const M of p)m+=M.length;const _=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray),x=_.vertexLength,b=[],T=[];for(const M of p){if(M.length===0)continue;M!==p[0]&&T.push(b.length/2);const z=this.segments2.prepareSegment(M.length,this.layoutVertexArray,this.indexArray2),B=z.vertexLength;this.layoutVertexArray.emplaceBack(M[0].x,M[0].y),this.indexArray2.emplaceBack(B+M.length-1,B),b.push(M[0].x),b.push(M[0].y);for(let V=1;V<M.length;V++)this.layoutVertexArray.emplaceBack(M[V].x,M[V].y),this.indexArray2.emplaceBack(B+V-1,B+V),b.push(M[V].x),b.push(M[V].y);z.vertexLength+=M.length,z.primitiveLength+=M.length}const A=nd(b,T);for(let M=0;M<A.length;M+=3)this.indexArray.emplaceBack(x+A[M],x+A[M+1],x+A[M+2]);_.vertexLength+=m,_.primitiveLength+=A.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,h,a)}}Xe(Iu,"FillBucket",{omit:["layers","patternFeatures"]});const Ag=new q({"fill-sort-key":new O(be.layout_fill["fill-sort-key"])});var Mg={paint:new q({"fill-antialias":new P(be.paint_fill["fill-antialias"]),"fill-opacity":new O(be.paint_fill["fill-opacity"]),"fill-color":new O(be.paint_fill["fill-color"]),"fill-outline-color":new O(be.paint_fill["fill-outline-color"]),"fill-translate":new P(be.paint_fill["fill-translate"]),"fill-translate-anchor":new P(be.paint_fill["fill-translate-anchor"]),"fill-pattern":new O(be.paint_fill["fill-pattern"])}),layout:Ag};const Ig=se([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Cg=se([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Pg=se([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:zg}=Ig;var Cu={},kg=_i,Jp=Ca;function Ca(t,e,i,n,a){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=a,t.readFields(Lg,this,e)}function Lg(t,e,i){t==1?e.id=i.readVarint():t==2?function(n,a){for(var c=n.readVarint()+n.pos;n.pos<c;){var h=a._keys[n.readVarint()],p=a._values[n.readVarint()];a.properties[h]=p}}(i,e):t==3?e.type=i.readVarint():t==4&&(e._geometry=i.pos)}function Dg(t){for(var e,i,n=0,a=0,c=t.length,h=c-1;a<c;h=a++)n+=((i=t[h]).x-(e=t[a]).x)*(e.y+i.y);return n}Ca.types=["Unknown","Point","LineString","Polygon"],Ca.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,n=1,a=0,c=0,h=0,p=[];t.pos<i;){if(a<=0){var m=t.readVarint();n=7&m,a=m>>3}if(a--,n===1||n===2)c+=t.readSVarint(),h+=t.readSVarint(),n===1&&(e&&p.push(e),e=[]),e.push(new kg(c,h));else{if(n!==7)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&p.push(e),p},Ca.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,a=0,c=0,h=1/0,p=-1/0,m=1/0,_=-1/0;t.pos<e;){if(n<=0){var x=t.readVarint();i=7&x,n=x>>3}if(n--,i===1||i===2)(a+=t.readSVarint())<h&&(h=a),a>p&&(p=a),(c+=t.readSVarint())<m&&(m=c),c>_&&(_=c);else if(i!==7)throw new Error("unknown command "+i)}return[h,m,p,_]},Ca.prototype.toGeoJSON=function(t,e,i){var n,a,c=this.extent*Math.pow(2,i),h=this.extent*t,p=this.extent*e,m=this.loadGeometry(),_=Ca.types[this.type];function x(A){for(var M=0;M<A.length;M++){var z=A[M];A[M]=[360*(z.x+h)/c-180,360/Math.PI*Math.atan(Math.exp((180-360*(z.y+p)/c)*Math.PI/180))-90]}}switch(this.type){case 1:var b=[];for(n=0;n<m.length;n++)b[n]=m[n][0];x(m=b);break;case 2:for(n=0;n<m.length;n++)x(m[n]);break;case 3:for(m=function(A){var M=A.length;if(M<=1)return[A];for(var z,B,V=[],K=0;K<M;K++){var G=Dg(A[K]);G!==0&&(B===void 0&&(B=G<0),B===G<0?(z&&V.push(z),z=[A[K]]):z.push(A[K]))}return z&&V.push(z),V}(m),n=0;n<m.length;n++)for(a=0;a<m[n].length;a++)x(m[n][a])}m.length===1?m=m[0]:_="Multi"+_;var T={type:"Feature",geometry:{type:_,coordinates:m},properties:this.properties};return"id"in this&&(T.id=this.id),T};var Rg=Jp,Yp=Qp;function Qp(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Bg,this,e),this.length=this._features.length}function Bg(t,e,i){t===15?e.version=i.readVarint():t===1?e.name=i.readString():t===5?e.extent=i.readVarint():t===2?e._features.push(i.pos):t===3?e._keys.push(i.readString()):t===4&&e._values.push(function(n){for(var a=null,c=n.readVarint()+n.pos;n.pos<c;){var h=n.readVarint()>>3;a=h===1?n.readString():h===2?n.readFloat():h===3?n.readDouble():h===4?n.readVarint64():h===5?n.readVarint():h===6?n.readSVarint():h===7?n.readBoolean():null}return a}(i))}Qp.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Rg(this._pbf,e,this.extent,this._keys,this._values)};var Og=Yp;function Fg(t,e,i){if(t===3){var n=new Og(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var ld=Cu.VectorTile=function(t,e){this.layers=t.readFields(Fg,{},e)},Pu=Cu.VectorTileFeature=Jp;function zu(t,e,i,n){const a=[],c=n===0?(h,p,m,_,x,b)=>{h.push(new Re(b,m+(b-p)/(_-p)*(x-m)))}:(h,p,m,_,x,b)=>{h.push(new Re(p+(b-m)/(x-m)*(_-p),b))};for(const h of t){const p=[];for(const m of h){if(m.length<=2)continue;const _=[];for(let T=0;T<m.length-1;T++){const A=m[T].x,M=m[T].y,z=m[T+1].x,B=m[T+1].y,V=n===0?A:M,K=n===0?z:B;V<e?K>e&&c(_,A,M,z,B,e):V>i?K<i&&c(_,A,M,z,B,i):_.push(m[T]),K<e&&V>=e&&c(_,A,M,z,B,e),K>i&&V<=i&&c(_,A,M,z,B,i)}let x=m[m.length-1];const b=n===0?x.x:x.y;b>=e&&b<=i&&_.push(x),_.length&&(x=_[_.length-1],_[0].x===x.x&&_[0].y===x.y||_.push(_[0]),p.push(_))}p.length&&a.push(p)}return a}Cu.VectorTileLayer=Yp;const Ug=Pu.types,Ng=Math.pow(2,13);function oc(t,e,i,n,a,c,h,p){t.emplaceBack((e<<1)+h,(i<<1)+c,(Math.floor(n*Ng)<<1)+a,Math.round(p))}function sc(t,e,i){t.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class ef{constructor(){this.acc=new Re(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new Re(e.x,e.y),this.max=new Re(e.x,e.y))}append(e,i){this.currentPolyCount.edges++,this.acc._add(e);const n=this.min,a=this.max;e.x<n.x?n.x=e.x:e.x>a.x&&(a.x=e.x),e.y<n.y?n.y=e.y:e.y>a.y&&(a.y=e.y),((e.x===0||e.x===nt)&&e.x===i.x)!=((e.y===0||e.y===nt)&&e.y===i.y)&&this.processBorderOverlap(e,i),i.x<0!=e.x<0&&this.addBorderIntersection(0,Pt(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>nt!=e.x>nt&&this.addBorderIntersection(1,Pt(i.y,e.y,(nt-i.x)/(e.x-i.x))),i.y<0!=e.y<0&&this.addBorderIntersection(2,Pt(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>nt!=e.y>nt&&this.addBorderIntersection(3,Pt(i.x,e.x,(nt-i.y)/(e.y-i.y)))}addBorderIntersection(e,i){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const n=this.borders[e];i<n[0]&&(n[0]=i),i>n[1]&&(n[1]=i)}processBorderOverlap(e,i){if(e.x===i.x){if(e.y===i.y)return;const n=e.x===0?0:1;this.addBorderIntersection(n,i.y),this.addBorderIntersection(n,e.y)}else{const n=e.y===0?2:3;this.addBorderIntersection(n,i.x),this.addBorderIntersection(n,e.x)}}centroid(){const e=this.polyCount.reduce((i,n)=>i+n.edges,0);return e!==0?this.acc.div(e)._round():new Re(0,0)}span(){return new Re(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,i)=>e+ +(i[0]!==Number.MAX_VALUE),0)}}class ac{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new Se,this.centroidVertexArray=new Yr,this.indexArray=new tt,this.programConfigurations=new Ts(e.layers,e.zoom),this.segments=new Ti,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=e.enableTerrain}populate(e,i,n,a){this.features=[],this.hasPattern=sd("fill-extrusion",this.layers,i),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(c){const h=Math.exp(Math.PI*(1-c.y/(1<<c.z)*2));return 80150034*h/(h*h+1)/nt/(1<<c.z)}(n),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:c,id:h,index:p,sourceLayerIndex:m}of e){const _=this.layers[0]._featureFilter.needGeometry,x=Cs(c,_);if(!this.layers[0]._featureFilter.filter(new v(this.zoom),x,n))continue;const b={id:h,sourceLayerIndex:m,index:p,geometry:_?x.geometry:Xn(c,n,a),properties:c.properties,type:c.type,patterns:{}},T=this.layoutVertexArray.length;this.hasPattern?this.features.push(ad("fill-extrusion",this.layers,b,this.zoom,i)):this.addFeature(b,b.geometry,p,n,{},i.availableImages,a),i.featureIndex.insert(c,b.geometry,p,m,this.index,T)}this.sortBorders()}addFeatures(e,i,n,a,c){for(const h of this.features){const{geometry:p}=h;this.addFeature(h,p,h.index,i,n,a,c)}this.sortBorders()}update(e,i,n,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,n,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,zg),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Pg.members,!0))),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.centroidVertexArray.length!==0&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Cg.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,i,n,a,c,h,p){const m=[new Re(0,0),new Re(nt,nt)],_=p.projection,x=_.name==="globe",b=this.enableTerrain&&!x?new ef:null,T=Ug[e.type]==="Polygon";x&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new De);const A=od(i,500);for(let V=A.length-1;V>=0;V--){const K=A[V];(K.length===0||(M=K[0]).every(G=>G.x<=0)||M.every(G=>G.x>=nt)||M.every(G=>G.y<=0)||M.every(G=>G.y>=nt))&&A.splice(V,1)}var M;let z;if(x)z=lf(A,m,a);else{z=[];for(const V of A)z.push({polygon:V,bounds:m})}const B=T?this.edgeRadius:0;for(const{polygon:V,bounds:K}of z){let G=0,X=0;for(const J of V)T&&!J[0].equals(J[J.length-1])&&J.push(J[0]),X+=T?J.length-1:J.length;const Y=this.segments.prepareSegment((T?5:4)*X,this.layoutVertexArray,this.indexArray);if(T){const J=[],me=[];G=Y.vertexLength;for(const Te of V){let Le,ye;Te.length&&Te!==V[0]&&me.push(J.length/2),Le=Te[1].sub(Te[0])._perp()._unit();for(let Ae=1;Ae<Te.length;Ae++){const Me=Te[Ae],Ce=Te[Ae===Te.length-1?1:Ae+1];let{x:Fe,y:ve}=Me;if(B){ye=Ce.sub(Me)._perp()._unit();const Ve=Le.add(ye)._unit(),Ke=B*Math.min(4,1/(Le.x*Ve.x+Le.y*Ve.y));Fe+=Ke*Ve.x,ve+=Ke*Ve.y,Le=ye}oc(this.layoutVertexArray,Fe,ve,0,0,1,1,0),Y.vertexLength++,J.push(Me.x,Me.y),x&&sc(this.layoutVertexExtArray,_.projectTilePoint(Fe,ve,a),_.upVector(a,Fe,ve))}}const de=nd(J,me);for(let Te=0;Te<de.length;Te+=3)this.indexArray.emplaceBack(G+de[Te],G+de[Te+2],G+de[Te+1]),Y.primitiveLength++}for(const J of V){b&&J.length&&b.startRing(J[0]);let me,de,Te,Le=J.length>4&&of(J[J.length-2],J[0],J[1]),ye=B?jg(J[J.length-2],J[0],J[1],B):0;de=J[1].sub(J[0])._perp()._unit();let Ae=!0;for(let Me=1,Ce=0;Me<J.length;Me++){let Fe=J[Me-1],ve=J[Me];const Ve=J[Me===J.length-1?1:Me+1];if(b&&T&&b.currentPolyCount.top++,nf(ve,Fe,K)){B&&(de=Ve.sub(ve)._perp()._unit(),Ae=!Ae);continue}b&&b.append(ve,Fe);const Ke=ve.sub(Fe)._perp(),Ge=Ke.x/(Math.abs(Ke.x)+Math.abs(Ke.y)),ct=Ke.y>0?1:0,Ue=Fe.dist(ve);if(Ce+Ue>32768&&(Ce=0),B){Te=Ve.sub(ve)._perp()._unit();let ht=rf(Fe,ve,Ve,tf(de,Te),B);isNaN(ht)&&(ht=0);const at=ve.sub(Fe)._unit();Fe=Fe.add(at.mult(ye))._round(),ve=ve.add(at.mult(-ht))._round(),ye=ht,de=Te}const rt=Y.vertexLength,ut=J.length>4&&of(Fe,ve,Ve);let kt=sf(Ce,Le,Ae);if(oc(this.layoutVertexArray,Fe.x,Fe.y,Ge,ct,0,0,kt),oc(this.layoutVertexArray,Fe.x,Fe.y,Ge,ct,0,1,kt),Ce+=Ue,kt=sf(Ce,ut,!Ae),Le=ut,oc(this.layoutVertexArray,ve.x,ve.y,Ge,ct,0,0,kt),oc(this.layoutVertexArray,ve.x,ve.y,Ge,ct,0,1,kt),Y.vertexLength+=4,this.indexArray.emplaceBack(rt+0,rt+1,rt+2),this.indexArray.emplaceBack(rt+1,rt+3,rt+2),Y.primitiveLength+=2,B){const ht=G+(Me===1?J.length-2:Me-2),at=Me===1?G:ht+1;if(this.indexArray.emplaceBack(rt+1,ht,rt+3),this.indexArray.emplaceBack(ht,at,rt+3),Y.primitiveLength+=2,me===void 0&&(me=rt),!nf(Ve,J[Me],K)){const Qt=Me===J.length-1?me:Y.vertexLength;this.indexArray.emplaceBack(rt+2,rt+3,Qt),this.indexArray.emplaceBack(rt+3,Qt+1,Qt),this.indexArray.emplaceBack(rt+3,at,Qt+1),Y.primitiveLength+=3}Ae=!Ae}if(x){const ht=this.layoutVertexExtArray,at=_.projectTilePoint(Fe.x,Fe.y,a),Qt=_.projectTilePoint(ve.x,ve.y,a),ft=_.upVector(a,Fe.x,Fe.y),mt=_.upVector(a,ve.x,ve.y);sc(ht,at,ft),sc(ht,at,ft),sc(ht,Qt,mt),sc(ht,Qt,mt)}}T&&(G+=J.length-1)}}if(b&&b.polyCount.length>0){if(b.borders){b.vertexArrayOffset=this.centroidVertexArray.length;const V=b.borders,K=this.featuresOnBorder.push(b)-1;for(let G=0;G<4;G++)V[G][0]!==Number.MAX_VALUE&&this.borders[G].push(K)}this.encodeCentroid(b.borders?void 0:b.centroid(),b)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,h,a)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((i,n)=>this.featuresOnBorder[i].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}encodeCentroid(e,i,n=!0){let a,c;if(e)if(e.y!==0){const p=i.span()._mult(this.tileToMeter);a=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(p.x/10)),c=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(p.y/10))}else a=Math.ceil(7*(e.x+450)),c=0;else a=0,c=+n;let h=n?this.centroidVertexArray.length:i.vertexArrayOffset;for(const p of i.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*p.edges+p.top);for(let m=0;m<p.top;m++)this.centroidVertexArray.emplace(h++,a,c);for(let m=0;m<2*p.edges;m++)this.centroidVertexArray.emplace(h++,0,c),this.centroidVertexArray.emplace(h++,a,c)}}}function tf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function jg(t,e,i,n){const a=e.sub(t)._perp()._unit(),c=i.sub(e)._perp()._unit();return rf(t,e,i,tf(a,c),n)}function rf(t,e,i,n,a){const c=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,a*c/n)}function nf(t,e,i){return t.x<i[0].x&&e.x<i[0].x||t.x>i[1].x&&e.x>i[1].x||t.y<i[0].y&&e.y<i[0].y||t.y>i[1].y&&e.y>i[1].y}function of(t,e,i){if(t.x<0||t.x>=nt||e.x<0||e.x>=nt||i.x<0||i.x>=nt)return!1;const n=i.sub(e),a=n.perp(),c=t.sub(e);return(n.x*c.x+n.y*c.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(c.x*c.x+c.y*c.y))>-.866&&a.x*c.x+a.y*c.y<0}function sf(t,e,i){const n=e?2|t:-3&t;return i?1|n:-2&n}function af(){const t=Math.PI/32,e=Math.tan(t),i=ec;return i*Math.sqrt(1+2*e*e)-i}function lf(t,e,i){const n=1<<i.z,a=Mr(i.x/n),c=Mr((i.x+1)/n),h=Zi(i.y/n),p=Zi((i.y+1)/n);return function(m,_,x,b,T=0,A){const M=[];if(!m.length||!x||!b)return M;const z=(J,me)=>{for(const de of J)M.push({polygon:de,bounds:me})},B=Math.ceil(Math.log2(x)),V=Math.ceil(Math.log2(b)),K=B-V,G=[];for(let J=0;J<Math.abs(K);J++)G.push(K>0?0:1);for(let J=0;J<Math.min(B,V);J++)G.push(0),G.push(1);let X=m;if(X=zu(X,_[0].y-T,_[1].y+T,1),X=zu(X,_[0].x-T,_[1].x+T,0),!X.length)return M;const Y=[];for(G.length?Y.push({polygons:X,bounds:_,depth:0}):z(X,_);Y.length;){const J=Y.pop(),me=J.depth,de=G[me],Te=J.bounds[0],Le=J.bounds[1],ye=de===0?Te.x:Te.y,Ae=de===0?Le.x:Le.y,Me=A?A(de,ye,Ae):.5*(ye+Ae),Ce=zu(J.polygons,ye-T,Me+T,de),Fe=zu(J.polygons,Me-T,Ae+T,de);if(Ce.length){const ve=[Te,new Re(de===0?Me:Le.x,de===1?Me:Le.y)];G.length>me+1?Y.push({polygons:Ce,bounds:ve,depth:me+1}):z(Ce,ve)}if(Fe.length){const ve=[new Re(de===0?Me:Te.x,de===1?Me:Te.y),Le];G.length>me+1?Y.push({polygons:Fe,bounds:ve,depth:me+1}):z(Fe,ve)}}return M}(t,e,Math.ceil((c-a)/11.25),Math.ceil((h-p)/11.25),1,(m,_,x)=>{if(m===0)return .5*(_+x);{const b=Zi((i.y+_/nt)/n);return(wn(.5*(Zi((i.y+x/nt)/n)+b))*n-i.y)*nt}})}Xe(ac,"FillExtrusionBucket",{omit:["layers","features"]}),Xe(ef,"PartMetadata");const Vg=new q({"fill-extrusion-edge-radius":new P(be["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var Gg={paint:new q({"fill-extrusion-opacity":new P(be["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new O(be["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new P(be["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new P(be["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new O(be["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new O(be["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new O(be["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new P(be["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new P(be["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new P(be["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new P(be["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:Vg};function cf(t,e,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class ku{constructor(e,i,n){this.z=e,this.x=i,this.y=n,this.key=lc(0,e,e,i,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,i){const n=function(c,h,p){var m=cf(256*c,256*(h=Math.pow(2,p)-h-1),p),_=cf(256*(c+1),256*(h+1),p);return m[0]+","+m[1]+","+_[0]+","+_[1]}(this.x,this.y,this.z),a=function(c,h,p){let m,_="";for(let x=c;x>0;x--)m=1<<x-1,_+=(h&m?1:0)+(p&m?2:0);return _}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(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(i==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",a).replace("{bbox-epsg-3857}",n)}toString(){return`${this.z}/${this.x}/${this.y}`}}class uf{constructor(e,i){this.wrap=e,this.canonical=i,this.key=lc(e,i.z,i.z,i.x,i.y)}}class tr{constructor(e,i,n,a,c){this.overscaledZ=e,this.wrap=i,this.canonical=new ku(n,+a,+c),this.key=i===0&&e===n?this.canonical.key:lc(i,e,n,a,c)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const i=this.canonical.z-e;return e>this.canonical.z?new tr(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new tr(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(e,i=!0){if(this.overscaledZ===e&&i)return this.key;if(e>this.canonical.z)return lc(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return lc(this.wrap*+i,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const i=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new tr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,n=2*this.canonical.x,a=2*this.canonical.y;return[new tr(i,this.wrap,i,n,a),new tr(i,this.wrap,i,n+1,a),new tr(i,this.wrap,i,n,a+1),new tr(i,this.wrap,i,n+1,a+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new tr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new tr(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new uf(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function lc(t,e,i,n,a){const c=1<<Math.min(i,22);let h=c*(a%c)+n%c;return t&&i<22&&(h+=c*c*((t<0?-2*t-1:2*t)%(1<<2*(22-i)))),16*(32*h+i)+(e-i)}Xe(ku,"CanonicalTileID"),Xe(tr,"OverscaledTileID",{omit:["projMatrix"]});class Pa extends Re{constructor(e,i,n){super(e,i),this.z=n}}function cc(t,e){return t.x*e.x+t.y*e.y}function hf(t,e){if(t.length===1){let i=0;const n=e[i++];let a;for(;!a||n.equals(a);)if(a=e[i++],!a)return 1/0;for(;i<e.length;i++){const c=e[i],h=t[0],p=a.sub(n),m=c.sub(n),_=h.sub(n),x=cc(p,p),b=cc(p,m),T=cc(m,m),A=cc(_,p),M=cc(_,m),z=x*T-b*b,B=(T*A-b*M)/z,V=(x*M-b*A)/z,K=n.z*(1-B-V)+a.z*B+c.z*V;if(isFinite(K))return K}return 1/0}{let i=1/0;for(const n of e)i=Math.min(i,n.z);return i}}function df(t,e,i,n,a,c,h,p){const m=h*a.getElevationAt(t,e,!0,!0),_=c[0]!==0,x=_?c[1]===0?h*(c[0]/7-450):h*function(b,T,A){const M=Math.floor(T[0]/8),z=Math.floor(T[1]/8),B=10*(T[0]-8*M),V=10*(T[1]-8*z),K=b.getElevationAt(M,z,!0,!0),G=b.getMeterToDEM(A),X=Math.floor(.5*(B*G-1)),Y=Math.floor(.5*(V*G-1)),J=b.tileCoordToPixel(M,z),me=2*X+1,de=2*Y+1,Te=function(Fe,ve,Ve,Ke,Ge){return[Fe.getElevationAtPixel(ve,Ve,!0),Fe.getElevationAtPixel(ve+Ge,Ve,!0),Fe.getElevationAtPixel(ve,Ve+Ge,!0),Fe.getElevationAtPixel(ve+Ke,Ve+Ge,!0)]}(b,J.x-X,J.y-Y,me,de),Le=Math.abs(Te[0]-Te[1]),ye=Math.abs(Te[2]-Te[3]),Ae=Math.abs(Te[0]-Te[2])+Math.abs(Te[1]-Te[3]),Me=Math.min(.25,.5*G*(Le+ye)/me),Ce=Math.min(.25,.5*G*Ae/de);return K+Math.max(Me*B,Ce*V)}(a,c,p):m;return{base:m+(i===0)?-1:i,top:_?Math.max(x+n,m+i+2):m+n}}const $g=se([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:qg}=$g,Zg=se([{name:"a_packed",components:4,type:"Float32"}]),{members:Wg}=Zg,Xg=Pu.types,Hg=Math.cos(Math.PI/180*37.5);class Lu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new ge,this.layoutVertexArray2=new ze,this.indexArray=new tt,this.programConfigurations=new Ts(e.layers,e.zoom),this.segments=new Ti,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(e,i,n,a){this.hasPattern=sd("line",this.layers,i);const c=this.layers[0].layout.get("line-sort-key"),h=[];for(const{feature:x,id:b,index:T,sourceLayerIndex:A}of e){const M=this.layers[0]._featureFilter.needGeometry,z=Cs(x,M);if(!this.layers[0]._featureFilter.filter(new v(this.zoom),z,n))continue;const B=c?c.evaluate(z,{},n):void 0,V={id:b,properties:x.properties,type:x.type,sourceLayerIndex:A,index:T,geometry:M?z.geometry:Xn(x,n,a),patterns:{},sortKey:B};h.push(V)}c&&h.sort((x,b)=>x.sortKey-b.sortKey);const{lineAtlas:p,featureIndex:m}=i,_=this.addConstantDashes(p);for(const x of h){const{geometry:b,index:T,sourceLayerIndex:A}=x;if(_&&this.addFeatureDashes(x,p),this.hasPattern){const M=ad("line",this.layers,x,this.zoom,i);this.patternFeatures.push(M)}else this.addFeature(x,b,T,n,p.positions,i.availableImages);m.insert(e[T].feature,b,T,A,this.index)}}addConstantDashes(e){let i=!1;for(const n of this.layers){const a=n.paint.get("line-dasharray").value,c=n.layout.get("line-cap").value;if(a.kind!=="constant"||c.kind!=="constant")i=!0;else{const h=c.value,p=a.value;if(!p)continue;e.addDash(p,h)}}return i}addFeatureDashes(e,i){const n=this.zoom;for(const a of this.layers){const c=a.paint.get("line-dasharray").value,h=a.layout.get("line-cap").value;if(c.kind==="constant"&&h.kind==="constant")continue;let p,m;if(c.kind==="constant"){if(p=c.value,!p)continue}else p=c.evaluate({zoom:n},e);m=h.kind==="constant"?h.value:h.evaluate({zoom:n},e),i.addDash(p,m),e.patterns[a.id]=i.getKey(p,m)}}update(e,i,n,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,n,a)}addFeatures(e,i,n,a,c){for(const h of this.patternFeatures)this.addFeature(h,h.geometry,h.index,i,n,a)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Wg)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,qg),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,i,n,a,c,h){const p=this.layers[0].layout,m=p.get("line-join").evaluate(e,{}),_=p.get("line-cap").evaluate(e,{}),x=p.get("line-miter-limit"),b=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const T of i)this.addLine(T,e,m,_,x,b);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,h,a)}addLine(e,i,n,a,c,h){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let V=0;V<e.length-1;V++)this.totalDistance+=e[V].dist(e[V+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const p=Xg[i.type]==="Polygon";let m=e.length;for(;m>=2&&e[m-1].equals(e[m-2]);)m--;let _=0;for(;_<m-1&&e[_].equals(e[_+1]);)_++;if(m<(p?3:2))return;n==="bevel"&&(c=1.05);const x=this.overscaling<=16?15*nt/(512*this.overscaling):0,b=this.segments.prepareSegment(10*m,this.layoutVertexArray,this.indexArray);let T,A,M,z,B;this.e1=this.e2=-1,p&&(T=e[m-2],B=e[_].sub(T)._unit()._perp());for(let V=_;V<m;V++){if(M=V===m-1?p?e[_+1]:void 0:e[V+1],M&&e[V].equals(M))continue;B&&(z=B),T&&(A=T),T=e[V],B=M?M.sub(T)._unit()._perp():z,z=z||B;let K=z.add(B);K.x===0&&K.y===0||K._unit();const G=z.x*B.x+z.y*B.y,X=K.x*B.x+K.y*B.y,Y=X!==0?1/X:1/0,J=2*Math.sqrt(2-2*X),me=X<Hg&&A&&M,de=z.x*B.y-z.y*B.x>0;if(me&&V>_){const ye=T.dist(A);if(ye>2*x){const Ae=T.sub(T.sub(A)._mult(x/ye)._round());this.updateDistance(A,Ae),this.addCurrentVertex(Ae,z,0,0,b),A=Ae}}const Te=A&&M;let Le=Te?n:p?"butt":a;if(Te&&Le==="round"&&(Y<h?Le="miter":Y<=2&&(Le="fakeround")),Le==="miter"&&Y>c&&(Le="bevel"),Le==="bevel"&&(Y>2&&(Le="flipbevel"),Y<c&&(Le="miter")),A&&this.updateDistance(A,T),Le==="miter")K._mult(Y),this.addCurrentVertex(T,K,0,0,b);else if(Le==="flipbevel"){if(Y>100)K=B.mult(-1);else{const ye=Y*z.add(B).mag()/z.sub(B).mag();K._perp()._mult(ye*(de?-1:1))}this.addCurrentVertex(T,K,0,0,b),this.addCurrentVertex(T,K.mult(-1),0,0,b)}else if(Le==="bevel"||Le==="fakeround"){const ye=-Math.sqrt(Y*Y-1),Ae=de?ye:0,Me=de?0:ye;if(A&&this.addCurrentVertex(T,z,Ae,Me,b),Le==="fakeround"){const Ce=Math.round(180*J/Math.PI/20);for(let Fe=1;Fe<Ce;Fe++){let ve=Fe/Ce;if(ve!==.5){const Ke=ve-.5;ve+=ve*Ke*(ve-1)*((1.0904+G*(G*(3.55645-1.43519*G)-3.2452))*Ke*Ke+(.848013+G*(.215638*G-1.06021)))}const Ve=B.sub(z)._mult(ve)._add(z)._unit()._mult(de?-1:1);this.addHalfVertex(T,Ve.x,Ve.y,!1,de,0,b)}}M&&this.addCurrentVertex(T,B,-Ae,-Me,b)}else if(Le==="butt")this.addCurrentVertex(T,K,0,0,b);else if(Le==="square"){const ye=A?1:-1;A||this.addCurrentVertex(T,K,ye,ye,b),this.addCurrentVertex(T,K,0,0,b),A&&this.addCurrentVertex(T,K,ye,ye,b)}else Le==="round"&&(A&&(this.addCurrentVertex(T,z,0,0,b),this.addCurrentVertex(T,z,1,1,b,!0)),M&&(this.addCurrentVertex(T,B,-1,-1,b,!0),this.addCurrentVertex(T,B,0,0,b)));if(me&&V<m-1){const ye=T.dist(M);if(ye>2*x){const Ae=T.add(M.sub(T)._mult(x/ye)._round());this.updateDistance(T,Ae),this.addCurrentVertex(Ae,B,0,0,b),T=Ae}}}}addCurrentVertex(e,i,n,a,c,h=!1){const p=i.y*a-i.x,m=-i.y-i.x*a;this.addHalfVertex(e,i.x+i.y*n,i.y-i.x*n,h,!1,n,c),this.addHalfVertex(e,p,m,h,!0,-a,c)}addHalfVertex({x:e,y:i},n,a,c,h,p,m){this.layoutVertexArray.emplaceBack((e<<1)+(c?1:0),(i<<1)+(h?1:0),Math.round(63*n)+128,Math.round(63*a)+128,1+(p===0?0:p<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const _=m.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,_),m.primitiveLength++),h?this.e2=_:this.e1=_}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,i){this.distance+=e.dist(i),this.updateScaledDistance()}}Xe(Lu,"LineBucket",{omit:["layers","patternFeatures"]});const Kg=new q({"line-cap":new O(be.layout_line["line-cap"]),"line-join":new O(be.layout_line["line-join"]),"line-miter-limit":new P(be.layout_line["line-miter-limit"]),"line-round-limit":new P(be.layout_line["line-round-limit"]),"line-sort-key":new O(be.layout_line["line-sort-key"])});var pf={paint:new q({"line-opacity":new O(be.paint_line["line-opacity"]),"line-color":new O(be.paint_line["line-color"]),"line-translate":new P(be.paint_line["line-translate"]),"line-translate-anchor":new P(be.paint_line["line-translate-anchor"]),"line-width":new O(be.paint_line["line-width"]),"line-gap-width":new O(be.paint_line["line-gap-width"]),"line-offset":new O(be.paint_line["line-offset"]),"line-blur":new O(be.paint_line["line-blur"]),"line-dasharray":new O(be.paint_line["line-dasharray"]),"line-pattern":new O(be.paint_line["line-pattern"]),"line-gradient":new $(be.paint_line["line-gradient"]),"line-trim-offset":new P(be.paint_line["line-trim-offset"])}),layout:Kg};const ff=new class extends O{possiblyEvaluate(t,e){return e=new v(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=xi({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}(pf.paint.properties["line-width"].specification);function mf(t,e){return e>0?e+2*t:t}ff.useIntegerZoom=!0;const Jg=se([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Yg=se([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Qg=se([{name:"a_projected_pos",components:4,type:"Float32"}],4);se([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const ey=se([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),ty=se([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);se([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const _f=se([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),iy=se([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);se([{name:"triangle",components:3,type:"Uint16"}]),se([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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"},{type:"Uint8",name:"flipState"}]),se([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),se([{type:"Float32",name:"offsetX"}]),se([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var ji=24;const on=128;function cd(t,e){const{expression:i}=e;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new v(t+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:n,interpolationType:a}=i;let c=0;for(;c<n.length&&n[c]<=t;)c++;c=Math.max(0,c-1);let h=c;for(;h<n.length&&n[h]<t+1;)h++;h=Math.min(n.length-1,h);const p=n[c],m=n[h];return i.kind==="composite"?{kind:"composite",minZoom:p,maxZoom:m,interpolationType:a}:{kind:"camera",minZoom:p,maxZoom:m,minSize:i.evaluate(new v(p)),maxSize:i.evaluate(new v(m)),interpolationType:a}}}function Du(t,{uSize:e,uSizeT:i},{lowerSize:n,upperSize:a}){return t.kind==="source"?n/on:t.kind==="composite"?Pt(n/on,a/on,i):e}function za(t,e){let i=0,n=0;if(t.kind==="constant")n=t.layoutSize;else if(t.kind!=="source"){const{interpolationType:a,minZoom:c,maxZoom:h}=t,p=a?Tt(Lr.interpolationFactor(a,e,c,h),0,1):0;t.kind==="camera"?n=Pt(t.minSize,t.maxSize,p):i=p}return{uSizeT:i,uSize:n}}var ry=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:on,evaluateSizeForFeature:Du,evaluateSizeForZoom:za,getSizeData:cd});function ny(t,e,i){return t.sections.forEach(n=>{n.text=function(a,c,h){const p=c.layout.get("text-transform").evaluate(h,{});return p==="uppercase"?a=a.toLocaleUpperCase():p==="lowercase"&&(a=a.toLocaleLowerCase()),y.applyArabicShaping&&(a=y.applyArabicShaping(a)),a}(n.text,e,i)}),t}const uc={"!":"︕","#":"＃",$:"＄","%":"％","&":"＆","(":"︵",")":"︶","*":"＊","+":"＋",",":"︐","-":"︲",".":"・","/":"／",":":"︓",";":"︔","<":"︿","=":"＝",">":"﹀","?":"︖","@":"＠","[":"﹇","\\":"＼","]":"﹈","^":"＾",_:"︳","`":"｀","{":"︷","|":"―","}":"︸","~":"～","¢":"￠","£":"￡","¥":"￥","¦":"￤","¬":"￢","¯":"￣","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"￦","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","！":"︕","（":"︵","）":"︶","，":"︐","－":"︲","．":"・","：":"︓","；":"︔","＜":"︿","＞":"﹀","？":"︖","［":"﹇","］":"﹈","＿":"︳","｛":"︷","｜":"―","｝":"︸","｟":"︵","｠":"︶","｡":"︒","｢":"﹁","｣":"﹂","←":"↑","→":"↓"};function oy(t){return t==="︶"||t==="﹈"||t==="︸"||t==="﹄"||t==="﹂"||t==="︾"||t==="︼"||t==="︺"||t==="︘"||t==="﹀"||t==="︐"||t==="︓"||t==="︔"||t==="｀"||t==="￣"||t==="︑"||t==="︒"}function sy(t){return t==="︵"||t==="﹇"||t==="︷"||t==="﹃"||t==="﹁"||t==="︽"||t==="︻"||t==="︹"||t==="︗"||t==="︿"}var gf=Ht,yf=function(t,e,i,n,a){var c,h,p=8*a-n-1,m=(1<<p)-1,_=m>>1,x=-7,b=i?a-1:0,T=i?-1:1,A=t[e+b];for(b+=T,c=A&(1<<-x)-1,A>>=-x,x+=p;x>0;c=256*c+t[e+b],b+=T,x-=8);for(h=c&(1<<-x)-1,c>>=-x,x+=n;x>0;h=256*h+t[e+b],b+=T,x-=8);if(c===0)c=1-_;else{if(c===m)return h?NaN:1/0*(A?-1:1);h+=Math.pow(2,n),c-=_}return(A?-1:1)*h*Math.pow(2,c-n)},xf=function(t,e,i,n,a,c){var h,p,m,_=8*c-a-1,x=(1<<_)-1,b=x>>1,T=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=n?0:c-1,M=n?1:-1,z=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,h=x):(h=Math.floor(Math.log(e)/Math.LN2),e*(m=Math.pow(2,-h))<1&&(h--,m*=2),(e+=h+b>=1?T/m:T*Math.pow(2,1-b))*m>=2&&(h++,m/=2),h+b>=x?(p=0,h=x):h+b>=1?(p=(e*m-1)*Math.pow(2,a),h+=b):(p=e*Math.pow(2,b-1)*Math.pow(2,a),h=0));a>=8;t[i+A]=255&p,A+=M,p/=256,a-=8);for(h=h<<a|p,_+=a;_>0;t[i+A]=255&h,A+=M,h/=256,_-=8);t[i+A-M]|=128*z};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function Ht(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ht.Varint=0,Ht.Fixed64=1,Ht.Bytes=2,Ht.Fixed32=5;var ud=4294967296,vf=1/ud,bf=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function Kn(t){return t.type===Ht.Bytes?t.readVarint()+t.pos:t.pos+1}function ka(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function wf(t,e,i){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(var a=i.pos-1;a>=t;a--)i.buf[a+n]=i.buf[a]}function ay(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function ly(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function cy(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function uy(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function hy(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function dy(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function py(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function fy(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function my(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function Ru(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function La(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Tf(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Ht.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var n=this.readVarint(),a=n>>3,c=this.pos;this.type=7&n,t(a,e,this),this.pos===c&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Ru(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Tf(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Ru(this.buf,this.pos)+Ru(this.buf,this.pos+4)*ud;return this.pos+=8,t},readSFixed64:function(){var t=Ru(this.buf,this.pos)+Tf(this.buf,this.pos+4)*ud;return this.pos+=8,t},readFloat:function(){var t=yf(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=yf(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i<128?e:(e|=(127&(i=n[this.pos++]))<<7,i<128?e:(e|=(127&(i=n[this.pos++]))<<14,i<128?e:(e|=(127&(i=n[this.pos++]))<<21,i<128?e:function(a,c,h){var p,m,_=h.buf;if(p=(112&(m=_[h.pos++]))>>4,m<128||(p|=(127&(m=_[h.pos++]))<<3,m<128)||(p|=(127&(m=_[h.pos++]))<<10,m<128)||(p|=(127&(m=_[h.pos++]))<<17,m<128)||(p|=(127&(m=_[h.pos++]))<<24,m<128)||(p|=(1&(m=_[h.pos++]))<<31,m<128))return ka(a,p,c);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&bf?function(i,n,a){return bf.decode(i.subarray(n,a))}(this.buf,e,t):function(i,n,a){for(var c="",h=n;h<a;){var p,m,_,x=i[h],b=null,T=x>239?4:x>223?3:x>191?2:1;if(h+T>a)break;T===1?x<128&&(b=x):T===2?(192&(p=i[h+1]))==128&&(b=(31&x)<<6|63&p)<=127&&(b=null):T===3?(m=i[h+2],(192&(p=i[h+1]))==128&&(192&m)==128&&((b=(15&x)<<12|(63&p)<<6|63&m)<=2047||b>=55296&&b<=57343)&&(b=null)):T===4&&(m=i[h+2],_=i[h+3],(192&(p=i[h+1]))==128&&(192&m)==128&&(192&_)==128&&((b=(15&x)<<18|(63&p)<<12|(63&m)<<6|63&_)<=65535||b>=1114112)&&(b=null)),b===null?(b=65533,T=1):b>65535&&(b-=65536,c+=String.fromCharCode(b>>>10&1023|55296),b=56320|1023&b),c+=String.fromCharCode(b),h+=T}return c}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Ht.Bytes)return t.push(this.readVarint(e));var i=Kn(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Ht.Bytes)return t.push(this.readSVarint());var e=Kn(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Ht.Bytes)return t.push(this.readBoolean());var e=Kn(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Ht.Bytes)return t.push(this.readFloat());var e=Kn(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Ht.Bytes)return t.push(this.readDouble());var e=Kn(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Ht.Bytes)return t.push(this.readFixed32());var e=Kn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Ht.Bytes)return t.push(this.readSFixed32());var e=Kn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Ht.Bytes)return t.push(this.readFixed64());var e=Kn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Ht.Bytes)return t.push(this.readSFixed64());var e=Kn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Ht.Varint)for(;this.buf[this.pos++]>127;);else if(e===Ht.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ht.Fixed32)this.pos+=4;else{if(e!==Ht.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),La(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),La(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),La(this.buf,-1&t,this.pos),La(this.buf,Math.floor(t*vf),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),La(this.buf,-1&t,this.pos),La(this.buf,Math.floor(t*vf),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(e,i){var n,a;if(e>=0?(n=e%4294967296|0,a=e/4294967296|0):(a=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,a=a+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");i.realloc(10),function(c,h,p){p.buf[p.pos++]=127&c|128,c>>>=7,p.buf[p.pos++]=127&c|128,c>>>=7,p.buf[p.pos++]=127&c|128,c>>>=7,p.buf[p.pos++]=127&c|128,p.buf[p.pos]=127&(c>>>=7)}(n,0,i),function(c,h){var p=(7&c)<<4;h.buf[h.pos++]|=p|((c>>>=3)?128:0),c&&(h.buf[h.pos++]=127&c|((c>>>=7)?128:0),c&&(h.buf[h.pos++]=127&c|((c>>>=7)?128:0),c&&(h.buf[h.pos++]=127&c|((c>>>=7)?128:0),c&&(h.buf[h.pos++]=127&c|((c>>>=7)?128:0),c&&(h.buf[h.pos++]=127&c)))))}(a,i)}(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:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(n,a,c){for(var h,p,m=0;m<a.length;m++){if((h=a.charCodeAt(m))>55295&&h<57344){if(!p){h>56319||m+1===a.length?(n[c++]=239,n[c++]=191,n[c++]=189):p=h;continue}if(h<56320){n[c++]=239,n[c++]=191,n[c++]=189,p=h;continue}h=p-55296<<10|h-56320|65536,p=null}else p&&(n[c++]=239,n[c++]=191,n[c++]=189,p=null);h<128?n[c++]=h:(h<2048?n[c++]=h>>6|192:(h<65536?n[c++]=h>>12|224:(n[c++]=h>>18|240,n[c++]=h>>12&63|128),n[c++]=h>>6&63|128),n[c++]=63&h|128)}return c}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&wf(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),xf(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),xf(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var n=this.pos-i;n>=128&&wf(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,Ht.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ay,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,ly,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,hy,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,cy,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,uy,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,dy,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,py,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,fy,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,my,e)},writeBytesField:function(t,e){this.writeTag(t,Ht.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ht.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ht.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ht.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ht.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ht.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ht.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ht.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ht.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ht.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};var Bu=pi(gf);const hd=3;function _y(t,e,i){e.glyphs=[],t===1&&i.readMessage(gy,e)}function gy(t,e,i){if(t===3){const{id:n,bitmap:a,width:c,height:h,left:p,top:m,advance:_}=i.readMessage(yy,{});e.glyphs.push({id:n,bitmap:new Hn({width:c+2*hd,height:h+2*hd},a),metrics:{width:c,height:h,left:p,top:m,advance:_}})}else t===4?e.ascender=i.readSVarint():t===5&&(e.descender=i.readSVarint())}function yy(t,e,i){t===1?e.id=i.readVarint():t===2?e.bitmap=i.readBytes():t===3?e.width=i.readVarint():t===4?e.height=i.readVarint():t===5?e.left=i.readSVarint():t===6?e.top=i.readSVarint():t===7&&(e.advance=i.readVarint())}const Ef=hd;function dd(t){let e=0,i=0;for(const h of t)e+=h.w*h.h,i=Math.max(i,h.w);t.sort((h,p)=>p.h-h.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let a=0,c=0;for(const h of t)for(let p=n.length-1;p>=0;p--){const m=n[p];if(!(h.w>m.w||h.h>m.h)){if(h.x=m.x,h.y=m.y,c=Math.max(c,h.y+h.h),a=Math.max(a,h.x+h.w),h.w===m.w&&h.h===m.h){const _=n.pop();p<n.length&&(n[p]=_)}else h.h===m.h?(m.x+=h.w,m.w-=h.w):h.w===m.w?(m.y+=h.h,m.h-=h.h):(n.push({x:m.x+h.w,y:m.y,w:m.w-h.w,h:h.h}),m.y+=h.h,m.h-=h.h);break}}return{w:a,h:c,fill:e/(a*c)||0}}const cr=1;class pd{constructor(e,{pixelRatio:i,version:n,stretchX:a,stretchY:c,content:h}){this.paddedRect=e,this.pixelRatio=i,this.stretchX=a,this.stretchY=c,this.content=h,this.version=n}get tl(){return[this.paddedRect.x+cr,this.paddedRect.y+cr]}get br(){return[this.paddedRect.x+this.paddedRect.w-cr,this.paddedRect.y+this.paddedRect.h-cr]}get displaySize(){return[(this.paddedRect.w-2*cr)/this.pixelRatio,(this.paddedRect.h-2*cr)/this.pixelRatio]}}class Sf{constructor(e,i){const n={},a={};this.haveRenderCallbacks=[];const c=[];this.addImages(e,n,c),this.addImages(i,a,c);const{w:h,h:p}=dd(c),m=new yr({width:h||1,height:p||1});for(const _ in e){const x=e[_],b=n[_].paddedRect;yr.copy(x.data,m,{x:0,y:0},{x:b.x+cr,y:b.y+cr},x.data)}for(const _ in i){const x=i[_],b=a[_].paddedRect,T=b.x+cr,A=b.y+cr,M=x.data.width,z=x.data.height;yr.copy(x.data,m,{x:0,y:0},{x:T,y:A},x.data),yr.copy(x.data,m,{x:0,y:z-1},{x:T,y:A-1},{width:M,height:1}),yr.copy(x.data,m,{x:0,y:0},{x:T,y:A+z},{width:M,height:1}),yr.copy(x.data,m,{x:M-1,y:0},{x:T-1,y:A},{width:1,height:z}),yr.copy(x.data,m,{x:0,y:0},{x:T+M,y:A},{width:1,height:z})}this.image=m,this.iconPositions=n,this.patternPositions=a}addImages(e,i,n){for(const a in e){const c=e[a],h={x:0,y:0,w:c.data.width+2*cr,h:c.data.height+2*cr};n.push(h),i[a]=new pd(h,c),c.hasRenderCallback&&this.haveRenderCallbacks.push(a)}}patchUpdatedImages(e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(n=>e.hasImage(n)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),i),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),i)}patchUpdatedImage(e,i,n){if(!e||!i||e.version===i.version)return;e.version=i.version;const[a,c]=e.tl;n.update(i.data,void 0,{x:a,y:c})}}Xe(pd,"ImagePosition"),Xe(Sf,"ImageAtlas");const Ir={horizontal:1,vertical:2,horizontalOnly:3},Af=-17;class hc{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,i){const n=new hc;return n.scale=e||1,n.fontStack=i,n}static forImage(e){const i=new hc;return i.imageName=e,i}}class Da{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i){const n=new Da;for(let a=0;a<e.sections.length;a++){const c=e.sections[a];c.image?n.addImageSection(c):n.addTextSection(c,i)}return n}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(e){this.text=function(i,n){let a="";for(let c=0;c<i.length;c++){const h=i.charCodeAt(c+1)||null,p=i.charCodeAt(c-1)||null;a+=!n&&(h&&hu(h)&&!uc[i[c+1]]||p&&hu(p)&&!uc[i[c-1]])||!uc[i[c]]?i[c]:uc[i[c]]}return a}(this.text,e)}trim(){let e=0;for(let n=0;n<this.text.length&&Ou[this.text.charCodeAt(n)];n++)e++;let i=this.text.length;for(let n=this.text.length-1;n>=0&&n>=e&&Ou[this.text.charCodeAt(n)];n--)i--;this.text=this.text.substring(e,i),this.sectionIndex=this.sectionIndex.slice(e,i)}substring(e,i){const n=new Da;return n.text=this.text.substring(e,i),n.sectionIndex=this.sectionIndex.slice(e,i),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,i)=>Math.max(e,this.sections[i].scale),0)}addTextSection(e,i){this.text+=e.text,this.sections.push(hc.forText(e.scale,e.fontStack||i));const n=this.sections.length-1;for(let a=0;a<e.text.length;++a)this.sectionIndex.push(n)}addImageSection(e){const i=e.image?e.image.name:"";if(i.length===0)return void li("Can't add FormattedSection with an empty image.");const n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push(hc.forImage(i)),this.sectionIndex.push(this.sections.length-1)):li("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function fd(t,e,i,n,a,c,h,p,m,_,x,b,T,A,M){const z=Da.fromFeature(t,a);b===Ir.vertical&&z.verticalizePunctuation(T);let B=[];const V=function(J,me,de,Te,Le,ye){if(!J)return[];const Ae=[],Me=function(Ve,Ke,Ge,ct,Ue,rt){let ut=0;for(let kt=0;kt<Ve.length();kt++){const ht=Ve.getSection(kt);ut+=Mf(Ve.getCharCode(kt),ht,ct,Ue,Ke,rt)}return ut/Math.max(1,Math.ceil(ut/Ge))}(J,me,de,Te,Le,ye),Ce=J.text.indexOf("​")>=0;let Fe=0;for(let Ve=0;Ve<J.length();Ve++){const Ke=J.getSection(Ve),Ge=J.getCharCode(Ve);if(Ou[Ge]||(Fe+=Mf(Ge,Ke,Te,Le,me,ye)),Ve<J.length()-1){const ct=!((ve=Ge)<11904||!(qe["Bopomofo Extended"](ve)||qe.Bopomofo(ve)||qe["CJK Compatibility Forms"](ve)||qe["CJK Compatibility Ideographs"](ve)||qe["CJK Compatibility"](ve)||qe["CJK Radicals Supplement"](ve)||qe["CJK Strokes"](ve)||qe["CJK Symbols and Punctuation"](ve)||qe["CJK Unified Ideographs Extension A"](ve)||qe["CJK Unified Ideographs"](ve)||qe["Enclosed CJK Letters and Months"](ve)||qe["Halfwidth and Fullwidth Forms"](ve)||qe.Hiragana(ve)||qe["Ideographic Description Characters"](ve)||qe["Kangxi Radicals"](ve)||qe["Katakana Phonetic Extensions"](ve)||qe.Katakana(ve)||qe["Vertical Forms"](ve)||qe["Yi Radicals"](ve)||qe["Yi Syllables"](ve)));(xy[Ge]||ct||Ke.imageName)&&Ae.push(Cf(Ve+1,Fe,Me,Ae,vy(Ge,J.getCharCode(Ve+1),ct&&Ce),!1))}}var ve;return Pf(Cf(J.length(),Fe,Me,Ae,0,!0))}(z,_,c,e,n,A),{processBidirectionalText:K,processStyledBidirectionalText:G}=y;if(K&&z.sections.length===1){const J=K(z.toString(),V);for(const me of J){const de=new Da;de.text=me,de.sections=z.sections;for(let Te=0;Te<me.length;Te++)de.sectionIndex.push(0);B.push(de)}}else if(G){const J=G(z.text,z.sectionIndex,V);for(const me of J){const de=new Da;de.text=me[0],de.sectionIndex=me[1],de.sections=z.sections,B.push(de)}}else B=function(J,me){const de=[],Te=J.text;let Le=0;for(const ye of me)de.push(J.substring(Le,ye)),Le=ye;return Le<Te.length&&de.push(J.substring(Le,Te.length)),de}(z,V);const X=[],Y={positionedLines:X,text:z.toString(),top:x[1],bottom:x[1],left:x[0],right:x[0],writingMode:b,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(J,me,de,Te,Le,ye,Ae,Me,Ce,Fe,ve,Ve){let Ke=0,Ge=0,ct=0;const Ue=Me==="right"?1:Me==="left"?0:.5;let rt=!1;for(const ft of Le){const mt=ft.getSections();for(const Zt of mt){if(Zt.imageName)continue;const Kt=me[Zt.fontStack];if(Kt&&(rt=Kt.ascender!==void 0&&Kt.descender!==void 0,!rt))break}if(!rt)break}let ut=0;for(const ft of Le){ft.trim();const mt=ft.getMaxScale(),Zt=(mt-1)*ji,Kt={positionedGlyphs:[],lineOffset:0};J.positionedLines[ut]=Kt;const Jt=Kt.positionedGlyphs;let Wt=0;if(!ft.length()){Ge+=ye,++ut;continue}let ui=0,mi=0;for(let Xt=0;Xt<ft.length();Xt++){const Pi=ft.getSection(Xt),Ai=ft.getSectionIndex(Xt),hi=ft.getCharCode(Xt);let Rt=Pi.scale,Mi=null,Yt=null,ir=null,Ii=ji,Vi=0;const Fi=!(Ce===Ir.horizontal||!ve&&!Fl(hi)||ve&&(Ou[hi]||(kt=hi,qe.Arabic(kt)||qe["Arabic Supplement"](kt)||qe["Arabic Extended-A"](kt)||qe["Arabic Presentation Forms-A"](kt)||qe["Arabic Presentation Forms-B"](kt))));if(Pi.imageName){const rr=Te[Pi.imageName];if(!rr)continue;ir=Pi.imageName,J.iconsInText=J.iconsInText||!0,Yt=rr.paddedRect;const Ui=rr.displaySize;Rt=Rt*ji/Ve,Mi={width:Ui[0],height:Ui[1],left:cr,top:-Ef,advance:Fi?Ui[1]:Ui[0],localGlyph:!1},Vi=rt?-Mi.height*Rt:Af+mt*ji-Ui[1]*Rt,Ii=Mi.advance;const ln=(Fi?Ui[0]:Ui[1])*Rt-ji*mt;ln>0&&ln>Wt&&(Wt=ln)}else{const rr=de[Pi.fontStack];if(!rr)continue;rr[hi]&&(Yt=rr[hi]);const Ui=me[Pi.fontStack];if(!Ui)continue;const ln=Ui.glyphs[hi];if(!ln)continue;if(Mi=ln.metrics,Ii=hi!==8203?ji:0,rt){const ja=Ui.ascender!==void 0?Math.abs(Ui.ascender):0,bc=Ui.descender!==void 0?Math.abs(Ui.descender):0,wc=(ja+bc)*Rt;ui<wc&&(ui=wc,mi=(ja-bc)/2*Rt),Vi=-ja*Rt}else Vi=Af+(mt-Rt)*ji}Fi?(J.verticalizable=!0,Jt.push({glyph:hi,imageName:ir,x:Ke,y:Ge+Vi,vertical:Fi,scale:Rt,localGlyph:Mi.localGlyph,fontStack:Pi.fontStack,sectionIndex:Ai,metrics:Mi,rect:Yt}),Ke+=Ii*Rt+Fe):(Jt.push({glyph:hi,imageName:ir,x:Ke,y:Ge+Vi,vertical:Fi,scale:Rt,localGlyph:Mi.localGlyph,fontStack:Pi.fontStack,sectionIndex:Ai,metrics:Mi,rect:Yt}),Ke+=Mi.advance*Rt+Fe)}Jt.length!==0&&(ct=Math.max(Ke-Fe,ct),rt?zf(Jt,Ue,Wt,mi,ye*mt/2):zf(Jt,Ue,Wt,0,ye/2)),Ke=0;const Si=ye*mt+Wt;Kt.lineOffset=Math.max(Wt,Zt),Ge+=Si,++ut}var kt;const ht=Ge,{horizontalAlign:at,verticalAlign:Qt}=md(Ae);(function(ft,mt,Zt,Kt,Jt,Wt){const ui=(mt-Zt)*Jt,mi=-Wt*Kt;for(const Si of ft)for(const Xt of Si.positionedGlyphs)Xt.x+=ui,Xt.y+=mi})(J.positionedLines,Ue,at,Qt,ct,ht),J.top+=-Qt*ht,J.bottom=J.top+ht,J.left+=-at*ct,J.right=J.left+ct,J.hasBaseline=rt}(Y,e,i,n,B,h,p,m,b,_,T,M),!function(J){for(const me of J)if(me.positionedGlyphs.length!==0)return!1;return!0}(X)&&Y}const Ou={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},xy={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Mf(t,e,i,n,a,c){if(e.imageName){const h=n[e.imageName];return h?h.displaySize[0]*e.scale*ji/c+a:0}{const h=i[e.fontStack],p=h&&h.glyphs[t];return p?p.metrics.advance*e.scale+a:0}}function If(t,e,i,n){const a=Math.pow(t-e,2);return n?t<e?a/2:2*a:a+Math.abs(i)*i}function vy(t,e,i){let n=0;return t===10&&(n-=1e4),i&&(n+=150),t!==40&&t!==65288||(n+=50),e!==41&&e!==65289||(n+=50),n}function Cf(t,e,i,n,a,c){let h=null,p=If(e,i,a,c);for(const m of n){const _=If(e-m.x,i,a,c)+m.badness;_<=p&&(h=m,p=_)}return{index:t,x:e,priorBreak:h,badness:p}}function Pf(t){return t?Pf(t.priorBreak).concat(t.index):[]}function md(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function zf(t,e,i,n,a){if(!(e||i||n||a))return;const c=t.length-1,h=t[c],p=(h.x+h.metrics.advance*h.scale)*e;for(let m=0;m<=c;m++)t[m].x-=p,t[m].y+=i+n+a}function by(t,e,i){const{horizontalAlign:n,verticalAlign:a}=md(i),c=e[0]-t.displaySize[0]*n,h=e[1]-t.displaySize[1]*a;return{image:t,top:h,bottom:h+t.displaySize[1],left:c,right:c+t.displaySize[0]}}function kf(t,e,i,n,a,c){const h=t.image;let p;if(h.content){const B=h.content,V=h.pixelRatio||1;p=[B[0]/V,B[1]/V,h.displaySize[0]-B[2]/V,h.displaySize[1]-B[3]/V]}const m=e.left*c,_=e.right*c;let x,b,T,A;i==="width"||i==="both"?(A=a[0]+m-n[3],b=a[0]+_+n[1]):(A=a[0]+(m+_-h.displaySize[0])/2,b=A+h.displaySize[0]);const M=e.top*c,z=e.bottom*c;return i==="height"||i==="both"?(x=a[1]+M-n[0],T=a[1]+z+n[2]):(x=a[1]+(M+z-h.displaySize[1])/2,T=x+h.displaySize[1]),{image:h,top:x,right:b,bottom:T,left:A,collisionPadding:p}}class Jn extends Re{constructor(e,i,n,a,c){super(e,i),this.angle=a,this.z=n,c!==void 0&&(this.segment=c)}clone(){return new Jn(this.x,this.y,this.z,this.angle,this.segment)}}function Lf(t,e,i,n,a){if(e.segment===void 0)return!0;let c=e,h=e.segment+1,p=0;for(;p>-i/2;){if(h--,h<0)return!1;p-=t[h].dist(c),c=t[h]}p+=t[h].dist(t[h+1]),h++;const m=[];let _=0;for(;p<i/2;){const x=t[h],b=t[h+1];if(!b)return!1;let T=t[h-1].angleTo(x)-x.angleTo(b);for(T=Math.abs((T+3*Math.PI)%(2*Math.PI)-Math.PI),m.push({distance:p,angleDelta:T}),_+=T;p-m[0].distance>n;)_-=m.shift().angleDelta;if(_>a)return!1;h++,p+=x.dist(b)}return!0}function Df(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function Rf(t,e,i){return t?.6*e*i:0}function Bf(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function wy(t,e,i,n,a,c){const h=Rf(i,a,c),p=Bf(i,n)*c;let m=0;const _=Df(t)/2;for(let x=0;x<t.length-1;x++){const b=t[x],T=t[x+1],A=b.dist(T);if(m+A>_){const M=(_-m)/A,z=Pt(b.x,T.x,M),B=Pt(b.y,T.y,M),V=new Jn(z,B,0,T.angleTo(b),x);return!h||Lf(t,V,p,h,e)?V:void 0}m+=A}}function Ty(t,e,i,n,a,c,h,p,m){const _=Rf(n,c,h),x=Bf(n,a),b=x*h,T=t[0].x===0||t[0].x===m||t[0].y===0||t[0].y===m;return e-b<e/4&&(e=b+e/4),Of(t,T?e/2*p%e:(x/2+2*c)*h*p%e,e,_,i,b,T,!1,m)}function Of(t,e,i,n,a,c,h,p,m){const _=c/2,x=Df(t);let b=0,T=e-i,A=[];for(let M=0;M<t.length-1;M++){const z=t[M],B=t[M+1],V=z.dist(B),K=B.angleTo(z);for(;T+i<b+V;){T+=i;const G=(T-b)/V,X=Pt(z.x,B.x,G),Y=Pt(z.y,B.y,G);if(X>=0&&X<m&&Y>=0&&Y<m&&T-_>=0&&T+_<=x){const J=new Jn(X,Y,0,K,M);J._round(),n&&!Lf(t,J,c,n,a)||A.push(J)}}b+=V}return p||A.length||h||(A=Of(t,b/2,i,n,a,c,h,!0,m)),A}function Ff(t,e,i,n,a){const c=[];for(let h=0;h<t.length;h++){const p=t[h];let m;for(let _=0;_<p.length-1;_++){let x=p[_],b=p[_+1];x.x<e&&b.x<e||(x.x<e?x=new Re(e,x.y+(e-x.x)/(b.x-x.x)*(b.y-x.y))._round():b.x<e&&(b=new Re(e,x.y+(e-x.x)/(b.x-x.x)*(b.y-x.y))._round()),x.y<i&&b.y<i||(x.y<i?x=new Re(x.x+(i-x.y)/(b.y-x.y)*(b.x-x.x),i)._round():b.y<i&&(b=new Re(x.x+(i-x.y)/(b.y-x.y)*(b.x-x.x),i)._round()),x.x>=n&&b.x>=n||(x.x>=n?x=new Re(n,x.y+(n-x.x)/(b.x-x.x)*(b.y-x.y))._round():b.x>=n&&(b=new Re(n,x.y+(n-x.x)/(b.x-x.x)*(b.y-x.y))._round()),x.y>=a&&b.y>=a||(x.y>=a?x=new Re(x.x+(a-x.y)/(b.y-x.y)*(b.x-x.x),a)._round():b.y>=a&&(b=new Re(x.x+(a-x.y)/(b.y-x.y)*(b.x-x.x),a)._round()),m&&x.equals(m[m.length-1])||(m=[x],c.push(m)),m.push(b)))))}}return c}Xe(Jn,"Anchor");const dc=1e20;function Uf(t,e,i,n,a,c,h,p,m){for(let _=e;_<e+n;_++)Nf(t,i*c+_,c,a,h,p,m);for(let _=i;_<i+a;_++)Nf(t,_*c+e,1,n,h,p,m)}function Nf(t,e,i,n,a,c,h){c[0]=0,h[0]=-dc,h[1]=dc,a[0]=t[e];for(let p=1,m=0,_=0;p<n;p++){a[p]=t[e+p*i];const x=p*p;do{const b=c[m];_=(a[p]-a[b]+x-b*b)/(p-b)/2}while(_<=h[m]&&--m>-1);m++,c[m]=p,h[m]=_,h[m+1]=dc}for(let p=0,m=0;p<n;p++){for(;h[m+1]<p;)m++;const _=c[m],x=p-_;t[e+p*i]=a[_]+x*x}}const sn=2,_d={none:0,ideographs:1,all:2};class Ra{constructor(e,i,n){this.requestManager=e,this.localGlyphMode=i,this.localFontFamily=n,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,i){const n=[];for(const a in e)for(const c of e[a])n.push({stack:a,id:c});Li(n,({stack:a,id:c},h)=>{let p=this.entries[a];p||(p=this.entries[a]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let m=p.glyphs[c];if(m!==void 0)return void h(null,{stack:a,id:c,glyph:m});if(m=this._tinySDF(p,a,c),m)return p.glyphs[c]=m,void h(null,{stack:a,id:c,glyph:m});const _=Math.floor(c/256);if(256*_>65535)return void h(new Error("glyphs > 65535 not supported"));if(p.ranges[_])return void h(null,{stack:a,id:c,glyph:m});let x=p.requests[_];x||(x=p.requests[_]=[],Ra.loadGlyphRange(a,_,this.url,this.requestManager,(b,T)=>{if(T){p.ascender=T.ascender,p.descender=T.descender;for(const A in T.glyphs)this._doesCharSupportLocalGlyph(+A)||(p.glyphs[+A]=T.glyphs[+A]);p.ranges[_]=!0}for(const A of x)A(b,T);delete p.requests[_]})),x.push((b,T)=>{b?h(b):T&&h(null,{stack:a,id:c,glyph:T.glyphs[c]||null})})},(a,c)=>{if(a)i(a);else if(c){const h={};for(const{stack:p,id:m,glyph:_}of c)h[p]===void 0&&(h[p]={}),h[p].glyphs===void 0&&(h[p].glyphs={}),h[p].glyphs[m]=_&&{id:_.id,bitmap:_.bitmap.clone(),metrics:_.metrics},h[p].ascender=this.entries[p].ascender,h[p].descender=this.entries[p].descender;i(null,h)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==_d.none&&(this.localGlyphMode===_d.all?!!this.localFontFamily:!!this.localFontFamily&&(qe["CJK Unified Ideographs"](e)||qe["Hangul Syllables"](e)||qe.Hiragana(e)||qe.Katakana(e)||qe["CJK Symbols and Punctuation"](e)))}_tinySDF(e,i,n){const a=this.localFontFamily;if(!a||!this._doesCharSupportLocalGlyph(n))return;let c=e.tinySDF;if(!c){let z="400";/bold/i.test(i)?z="900":/medium/i.test(i)?z="500":/light/i.test(i)&&(z="200"),c=e.tinySDF=new Ra.TinySDF({fontFamily:a,fontWeight:z,fontSize:24*sn,buffer:3*sn,radius:8*sn}),c.fontWeight=z}if(this.localGlyphs[c.fontWeight][n])return this.localGlyphs[c.fontWeight][n];const h=String.fromCharCode(n),{data:p,width:m,height:_,glyphWidth:x,glyphHeight:b,glyphLeft:T,glyphTop:A,glyphAdvance:M}=c.draw(h);return this.localGlyphs[c.fontWeight][n]={id:n,bitmap:new Hn({width:m,height:_},p),metrics:{width:x/sn,height:b/sn,left:T/sn,top:A/sn-27,advance:M/sn,localGlyph:!0}}}}Ra.loadGlyphRange=function(t,e,i,n,a){const c=256*e,h=c+255,p=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${c}-${h}`),zn.Glyphs);so(p,(m,_)=>{if(m)a(m);else if(_){const x={},b=function(T){return new Bu(T).readFields(_y,{})}(_);for(const T of b.glyphs)x[T.id]=T;a(null,{glyphs:x,ascender:b.ascender,descender:b.descender})}})},Ra.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:a="sans-serif",fontWeight:c="normal",fontStyle:h="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const p=this.size=t+4*e,m=this._createCanvas(p),_=this.ctx=m.getContext("2d",{willReadFrequently:!0});_.font=`${h} ${c} ${t}px ${a}`,_.textBaseline="alphabetic",_.textAlign="left",_.fillStyle="black",this.gridOuter=new Float64Array(p*p),this.gridInner=new Float64Array(p*p),this.f=new Float64Array(p),this.z=new Float64Array(p+1),this.v=new Uint16Array(p)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:a,actualBoundingBoxRight:c}=this.ctx.measureText(t),h=Math.ceil(i),p=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c-a))),m=Math.min(this.size-this.buffer,h+Math.ceil(n)),_=p+2*this.buffer,x=m+2*this.buffer,b=Math.max(_*x,0),T=new Uint8ClampedArray(b),A={data:T,width:_,height:x,glyphWidth:p,glyphHeight:m,glyphTop:h,glyphLeft:0,glyphAdvance:e};if(p===0||m===0)return A;const{ctx:M,buffer:z,gridInner:B,gridOuter:V}=this;M.clearRect(z,z,p,m),M.fillText(t,z,z+h);const K=M.getImageData(z,z,p,m);V.fill(dc,0,b),B.fill(0,0,b);for(let G=0;G<m;G++)for(let X=0;X<p;X++){const Y=K.data[4*(G*p+X)+3]/255;if(Y===0)continue;const J=(G+z)*_+X+z;if(Y===1)V[J]=0,B[J]=dc;else{const me=.5-Y;V[J]=me>0?me*me:0,B[J]=me<0?me*me:0}}Uf(V,0,0,_,x,_,this.f,this.v,this.z),Uf(B,z,z,p,m,_,this.f,this.v,this.z);for(let G=0;G<b;G++){const X=Math.sqrt(V[G])-Math.sqrt(B[G]);T[G]=Math.round(255-255*(X/this.radius+this.cutoff))}return A}};const Ba=cr;function jf(t,e,i,n){const a=[],c=t.image,h=c.pixelRatio,p=c.paddedRect.w-2*Ba,m=c.paddedRect.h-2*Ba,_=t.right-t.left,x=t.bottom-t.top,b=c.stretchX||[[0,p]],T=c.stretchY||[[0,m]],A=(ye,Ae)=>ye+Ae[1]-Ae[0],M=b.reduce(A,0),z=T.reduce(A,0),B=p-M,V=m-z;let K=0,G=M,X=0,Y=z,J=0,me=B,de=0,Te=V;if(c.content&&n){const ye=c.content;K=Fu(b,0,ye[0]),X=Fu(T,0,ye[1]),G=Fu(b,ye[0],ye[2]),Y=Fu(T,ye[1],ye[3]),J=ye[0]-K,de=ye[1]-X,me=ye[2]-ye[0]-G,Te=ye[3]-ye[1]-Y}const Le=(ye,Ae,Me,Ce)=>{const Fe=Uu(ye.stretch-K,G,_,t.left),ve=Nu(ye.fixed-J,me,ye.stretch,M),Ve=Uu(Ae.stretch-X,Y,x,t.top),Ke=Nu(Ae.fixed-de,Te,Ae.stretch,z),Ge=Uu(Me.stretch-K,G,_,t.left),ct=Nu(Me.fixed-J,me,Me.stretch,M),Ue=Uu(Ce.stretch-X,Y,x,t.top),rt=Nu(Ce.fixed-de,Te,Ce.stretch,z),ut=new Re(Fe,Ve),kt=new Re(Ge,Ve),ht=new Re(Ge,Ue),at=new Re(Fe,Ue),Qt=new Re(ve/h,Ke/h),ft=new Re(ct/h,rt/h),mt=e*Math.PI/180;if(mt){const Jt=Math.sin(mt),Wt=Math.cos(mt),ui=[Wt,-Jt,Jt,Wt];ut._matMult(ui),kt._matMult(ui),at._matMult(ui),ht._matMult(ui)}const Zt=ye.stretch+ye.fixed,Kt=Ae.stretch+Ae.fixed;return{tl:ut,tr:kt,bl:at,br:ht,tex:{x:c.paddedRect.x+Ba+Zt,y:c.paddedRect.y+Ba+Kt,w:Me.stretch+Me.fixed-Zt,h:Ce.stretch+Ce.fixed-Kt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Qt,pixelOffsetBR:ft,minFontScaleX:me/h/_,minFontScaleY:Te/h/x,isSDF:i}};if(n&&(c.stretchX||c.stretchY)){const ye=Vf(b,B,M),Ae=Vf(T,V,z);for(let Me=0;Me<ye.length-1;Me++){const Ce=ye[Me],Fe=ye[Me+1];for(let ve=0;ve<Ae.length-1;ve++)a.push(Le(Ce,Ae[ve],Fe,Ae[ve+1]))}}else a.push(Le({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:p+1},{fixed:0,stretch:m+1}));return a}function Fu(t,e,i){let n=0;for(const a of t)n+=Math.max(e,Math.min(i,a[1]))-Math.max(e,Math.min(i,a[0]));return n}function Vf(t,e,i){const n=[{fixed:-Ba,stretch:0}];for(const[a,c]of t){const h=n[n.length-1];n.push({fixed:a-h.stretch,stretch:h.stretch}),n.push({fixed:a-h.stretch,stretch:h.stretch+(c-a)})}return n.push({fixed:e+Ba,stretch:i}),n}function Uu(t,e,i,n){return t/e*i+n}function Nu(t,e,i,n){return t-e*i/n}function Ey(t,e,i,n){const a=e+t.positionedLines[n].lineOffset;return n===0?i+a/2:i+(a+(e+t.positionedLines[n-1].lineOffset))/2}class Sy{constructor(e=[],i=Ay){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:i,compare:n}=this,a=i[e];for(;e>0;){const c=e-1>>1,h=i[c];if(n(a,h)>=0)break;i[e]=h,e=c}i[e]=a}_down(e){const{data:i,compare:n}=this,a=this.length>>1,c=i[e];for(;e<a;){let h=1+(e<<1),p=i[h];const m=h+1;if(m<this.length&&n(i[m],p)<0&&(h=m,p=i[m]),n(p,c)>=0)break;i[e]=p,e=h}i[e]=c}}function Ay(t,e){return t<e?-1:t>e?1:0}function My(t,e=1,i=!1){let n=1/0,a=1/0,c=-1/0,h=-1/0;const p=t[0];for(let A=0;A<p.length;A++){const M=p[A];(!A||M.x<n)&&(n=M.x),(!A||M.y<a)&&(a=M.y),(!A||M.x>c)&&(c=M.x),(!A||M.y>h)&&(h=M.y)}const m=Math.min(c-n,h-a);let _=m/2;const x=new Sy([],Iy);if(m===0)return new Re(n,a);for(let A=n;A<c;A+=m)for(let M=a;M<h;M+=m)x.push(new Oa(A+_,M+_,_,t));let b=function(A){let M=0,z=0,B=0;const V=A[0];for(let K=0,G=V.length,X=G-1;K<G;X=K++){const Y=V[K],J=V[X],me=Y.x*J.y-J.x*Y.y;z+=(Y.x+J.x)*me,B+=(Y.y+J.y)*me,M+=3*me}return new Oa(z/M,B/M,0,A)}(t),T=x.length;for(;x.length;){const A=x.pop();(A.d>b.d||!b.d)&&(b=A,i&&console.log("found best %d after %d probes",Math.round(1e4*A.d)/1e4,T)),A.max-b.d<=e||(_=A.h/2,x.push(new Oa(A.p.x-_,A.p.y-_,_,t)),x.push(new Oa(A.p.x+_,A.p.y-_,_,t)),x.push(new Oa(A.p.x-_,A.p.y+_,_,t)),x.push(new Oa(A.p.x+_,A.p.y+_,_,t)),T+=4)}return i&&(console.log(`num probes: ${T}`),console.log(`best distance: ${b.d}`)),b.p}function Iy(t,e){return e.max-t.max}class Oa{constructor(e,i,n,a){this.p=new Re(e,i),this.h=n,this.d=function(c,h){let p=!1,m=1/0;for(let _=0;_<h.length;_++){const x=h[_];for(let b=0,T=x.length,A=T-1;b<T;A=b++){const M=x[b],z=x[A];M.y>c.y!=z.y>c.y&&c.x<(z.x-M.x)*(c.y-M.y)/(z.y-M.y)+M.x&&(p=!p),m=Math.min(m,Bp(c,M,z))}}return(p?1:-1)*Math.sqrt(m)}(this.p,a),this.max=this.d+this.h*Math.SQRT2}}const Fa=7,gd=Number.POSITIVE_INFINITY,Cy=Math.sqrt(2);function Gf(t,[e,i]){let n=0,a=0;if(i===gd){e<0&&(e=0);const c=e/Cy;switch(t){case"top-right":case"top-left":a=c-Fa;break;case"bottom-right":case"bottom-left":a=-c+Fa;break;case"bottom":a=-e+Fa;break;case"top":a=e-Fa}switch(t){case"top-right":case"bottom-right":n=-c;break;case"top-left":case"bottom-left":n=c;break;case"left":n=e;break;case"right":n=-e}}else{switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":a=i-Fa;break;case"bottom-right":case"bottom-left":case"bottom":a=-i+Fa}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}}return[n,a]}function Py(t,e,i,n,a,c,h,p,m,_){t.createArrays(),t.tilePixelRatio=nt/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const x=t.layers[0].layout,b=t.layers[0]._unevaluatedLayout._values,T={};if(t.textSizeData.kind==="composite"){const{minZoom:z,maxZoom:B}=t.textSizeData;T.compositeTextSizes=[b["text-size"].possiblyEvaluate(new v(z),p),b["text-size"].possiblyEvaluate(new v(B),p)]}if(t.iconSizeData.kind==="composite"){const{minZoom:z,maxZoom:B}=t.iconSizeData;T.compositeIconSizes=[b["icon-size"].possiblyEvaluate(new v(z),p),b["icon-size"].possiblyEvaluate(new v(B),p)]}T.layoutTextSize=b["text-size"].possiblyEvaluate(new v(m+1),p),T.layoutIconSize=b["icon-size"].possiblyEvaluate(new v(m+1),p),T.textMaxSize=b["text-size"].possiblyEvaluate(new v(18),p);const A=x.get("text-rotation-alignment")==="map"&&x.get("symbol-placement")!=="point",M=x.get("text-size");for(const z of t.features){const B=x.get("text-font").evaluate(z,{},p).join(","),V=M.evaluate(z,{},p),K=T.layoutTextSize.evaluate(z,{},p),G=(T.layoutIconSize.evaluate(z,{},p),{horizontal:{},vertical:void 0}),X=z.text;let Y,J=[0,0];if(X){const Te=X.toString(),Le=x.get("text-letter-spacing").evaluate(z,{},p)*ji,ye=x.get("text-line-height").evaluate(z,{},p)*ji,Ae=Ah(Te)?Le:0,Me=x.get("text-anchor").evaluate(z,{},p),Ce=x.get("text-variable-anchor");if(!Ce){const Ge=x.get("text-radial-offset").evaluate(z,{},p);J=Ge?Gf(Me,[Ge*ji,gd]):x.get("text-offset").evaluate(z,{},p).map(ct=>ct*ji)}let Fe=A?"center":x.get("text-justify").evaluate(z,{},p);const ve=x.get("symbol-placement")==="point",Ve=ve?x.get("text-max-width").evaluate(z,{},p)*ji:1/0,Ke=Ge=>{t.allowVerticalPlacement&&Ol(Te)&&(G.vertical=fd(X,e,i,a,B,Ve,ye,Me,Ge,Ae,J,Ir.vertical,!0,K,V))};if(!A&&Ce){const Ge=Fe==="auto"?Ce.map(Ue=>yd(Ue)):[Fe];let ct=!1;for(let Ue=0;Ue<Ge.length;Ue++){const rt=Ge[Ue];if(!G.horizontal[rt])if(ct)G.horizontal[rt]=G.horizontal[0];else{const ut=fd(X,e,i,a,B,Ve,ye,"center",rt,Ae,J,Ir.horizontal,!1,K,V);ut&&(G.horizontal[rt]=ut,ct=ut.positionedLines.length===1)}}Ke("left")}else{if(Fe==="auto"&&(Fe=yd(Me)),ve||x.get("text-writing-mode").indexOf("horizontal")>=0||!Ol(Te)){const Ge=fd(X,e,i,a,B,Ve,ye,Me,Fe,Ae,J,Ir.horizontal,!1,K,V);Ge&&(G.horizontal[Fe]=Ge)}Ke(ve?"left":Fe)}}let me=!1;if(z.icon&&z.icon.name){const Te=n[z.icon.name];Te&&(Y=by(a[z.icon.name],x.get("icon-offset").evaluate(z,{},p),x.get("icon-anchor").evaluate(z,{},p)),me=Te.sdf,t.sdfIcons===void 0?t.sdfIcons=Te.sdf:t.sdfIcons!==Te.sdf&&li("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Te.pixelRatio!==t.pixelRatio||x.get("icon-rotate").constantOr(1)!==0)&&(t.iconsNeedLinear=!0))}const de=qf(G.horizontal)||G.vertical;t.iconsInText||(t.iconsInText=!!de&&de.iconsInText),(de||Y)&&zy(t,z,G,Y,n,T,K,0,J,me,h,p,_)}c&&t.generateCollisionDebugBuffers(m,t.collisionBoxArray)}function yd(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function zy(t,e,i,n,a,c,h,p,m,_,x,b,T){let A=c.textMaxSize.evaluate(e,{},b);A===void 0&&(A=h);const M=t.layers[0].layout,z=M.get("icon-offset").evaluate(e,{},b),B=qf(i.horizontal)||i.vertical,V=T.name==="globe",K=ji,G=h/K,X=t.tilePixelRatio*A/K,Y=(Me=t.overscaling,t.zoom>18&&Me>2&&(Me>>=1),Math.max(nt/(512*Me),1)*M.get("symbol-spacing")),J=M.get("text-padding")*t.tilePixelRatio,me=M.get("icon-padding")*t.tilePixelRatio,de=At(M.get("text-max-angle")),Te=M.get("text-rotation-alignment")==="map"&&M.get("symbol-placement")!=="point",Le=M.get("icon-rotation-alignment")==="map"&&M.get("symbol-placement")!=="point",ye=M.get("symbol-placement"),Ae=Y/2;var Me;const Ce=M.get("icon-text-fit");let Fe;n&&Ce!=="none"&&(t.allowVerticalPlacement&&i.vertical&&(Fe=kf(n,i.vertical,Ce,M.get("icon-text-fit-padding"),z,G)),B&&(n=kf(n,B,Ce,M.get("icon-text-fit-padding"),z,G)));const ve=(Ve,Ke,Ge)=>{if(Ke.x<0||Ke.x>=nt||Ke.y<0||Ke.y>=nt)return;let ct=null;if(V){const{x:Ue,y:rt,z:ut}=T.projectTilePoint(Ke.x,Ke.y,Ge);ct={anchor:new Jn(Ue,rt,ut,0,void 0),up:T.upVector(Ge,Ke.x,Ke.y)}}(function(Ue,rt,ut,kt,ht,at,Qt,ft,mt,Zt,Kt,Jt,Wt,ui,mi,Si,Xt,Pi,Ai,hi,Rt,Mi,Yt,ir,Ii){const Vi=Ue.addToLineVertexArray(rt,kt);let Fi,rr,Ui,ln,ja,bc,wc,Em=0,Sm=0,Am=0,Mm=0,Ld=-1,Dd=-1;const An={};let Im=Ch("");const Ds=ut?ut.anchor:rt;let Rd=0,Bd=0;if(mt._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Rd,Bd]=mt.layout.get("text-offset").evaluate(Rt,{},Ii).map(xr=>xr*ji):(Rd=mt.layout.get("text-radial-offset").evaluate(Rt,{},Ii)*ji,Bd=gd),Ue.allowVerticalPlacement&&ht.vertical){const xr=ht.vertical;if(mi)bc=xd(xr),ft&&(wc=xd(ft));else{const vr=mt.layout.get("text-rotate").evaluate(Rt,{},Ii)+90;Ui=ju(Zt,Ds,rt,Kt,Jt,Wt,xr,ui,vr,Si),ft&&(ln=ju(Zt,Ds,rt,Kt,Jt,Wt,ft,Pi,vr))}}if(at){const xr=mt.layout.get("icon-rotate").evaluate(Rt,{},Ii),vr=mt.layout.get("icon-text-fit")!=="none",Tc=jf(at,xr,Yt,vr),Fd=ft?jf(ft,xr,Yt,vr):void 0;rr=ju(Zt,Ds,rt,Kt,Jt,Wt,at,Pi,xr),Em=4*Tc.length;const Cm=Ue.iconSizeData;let Rs=null;Cm.kind==="source"?(Rs=[on*mt.layout.get("icon-size").evaluate(Rt,{},Ii)],Rs[0]>zo&&li(`${Ue.layerIds[0]}: Value for "icon-size" is >= ${pc}. Reduce your "icon-size".`)):Cm.kind==="composite"&&(Rs=[on*Mi.compositeIconSizes[0].evaluate(Rt,{},Ii),on*Mi.compositeIconSizes[1].evaluate(Rt,{},Ii)],(Rs[0]>zo||Rs[1]>zo)&&li(`${Ue.layerIds[0]}: Value for "icon-size" is >= ${pc}. Reduce your "icon-size".`)),Ue.addSymbols(Ue.icon,Tc,Rs,hi,Ai,Rt,!1,ut,rt,Vi.lineStartIndex,Vi.lineLength,-1,ir,Ii),Ld=Ue.icon.placedSymbolArray.length-1,Fd&&(Sm=4*Fd.length,Ue.addSymbols(Ue.icon,Fd,Rs,hi,Ai,Rt,Ir.vertical,ut,rt,Vi.lineStartIndex,Vi.lineLength,-1,ir,Ii),Dd=Ue.icon.placedSymbolArray.length-1)}for(const xr in ht.horizontal){const vr=ht.horizontal[xr];Fi||(Im=Ch(vr.text),mi?ja=xd(vr):Fi=ju(Zt,Ds,rt,Kt,Jt,Wt,vr,ui,mt.layout.get("text-rotate").evaluate(Rt,{},Ii),Si));const Tc=vr.positionedLines.length===1;if(Am+=$f(Ue,ut,rt,vr,Qt,mt,mi,Rt,Si,Vi,ht.vertical?Ir.horizontal:Ir.horizontalOnly,Tc?Object.keys(ht.horizontal):[xr],An,Ld,Mi,ir,Ii),Tc)break}ht.vertical&&(Mm+=$f(Ue,ut,rt,ht.vertical,Qt,mt,mi,Rt,Si,Vi,Ir.vertical,["vertical"],An,Dd,Mi,ir,Ii));let Oo=-1;const Od=(xr,vr)=>xr?Math.max(xr,vr):vr;Oo=Od(ja,Oo),Oo=Od(bc,Oo),Oo=Od(wc,Oo);const ox=Oo>-1?1:0;Ue.glyphOffsetArray.length>=Lo.MAX_GLYPHS&&li("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Rt.sortKey!==void 0&&Ue.addToSortKeyRanges(Ue.symbolInstances.length,Rt.sortKey),Ue.symbolInstances.emplaceBack(Ds.x,Ds.y,Ds.z,rt.x,rt.y,An.right>=0?An.right:-1,An.center>=0?An.center:-1,An.left>=0?An.left:-1,An.vertical>=0?An.vertical:-1,Ld,Dd,Im,Fi!==void 0?Fi:Ue.collisionBoxArray.length,Fi!==void 0?Fi+1:Ue.collisionBoxArray.length,Ui!==void 0?Ui:Ue.collisionBoxArray.length,Ui!==void 0?Ui+1:Ue.collisionBoxArray.length,rr!==void 0?rr:Ue.collisionBoxArray.length,rr!==void 0?rr+1:Ue.collisionBoxArray.length,ln||Ue.collisionBoxArray.length,ln?ln+1:Ue.collisionBoxArray.length,Kt,Am,Mm,Em,Sm,ox,0,Rd,Bd,Oo)})(t,Ke,ct,Ve,i,n,a,Fe,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,J,Te,m,0,me,Le,z,e,c,_,x,b)};if(ye==="line")for(const Ve of Ff(e.geometry,0,0,nt,nt)){const Ke=Ty(Ve,Y,de,i.vertical||B,n,K,X,t.overscaling,nt);for(const Ge of Ke)B&&ky(t,B.text,Ae,Ge)||ve(Ve,Ge,b)}else if(ye==="line-center"){for(const Ve of e.geometry)if(Ve.length>1){const Ke=wy(Ve,de,i.vertical||B,n,K,X);Ke&&ve(Ve,Ke,b)}}else if(e.type==="Polygon")for(const Ve of od(e.geometry,0)){const Ke=My(Ve,16);ve(Ve[0],new Jn(Ke.x,Ke.y,0,0,void 0),b)}else if(e.type==="LineString")for(const Ve of e.geometry)ve(Ve,new Jn(Ve[0].x,Ve[0].y,0,0,void 0),b);else if(e.type==="Point")for(const Ve of e.geometry)for(const Ke of Ve)ve([Ke],new Jn(Ke.x,Ke.y,0,0,void 0),b)}const pc=255,zo=pc*on;function $f(t,e,i,n,a,c,h,p,m,_,x,b,T,A,M,z,B){const V=function(X,Y,J,me,de,Te,Le,ye){const Ae=[];if(Y.positionedLines.length===0)return Ae;const Me=me.layout.get("text-rotate").evaluate(Te,{})*Math.PI/180,Ce=function(Ge){const ct=Ge[0],Ue=Ge[1],rt=ct*Ue;return rt>0?[ct,-Ue]:rt<0?[-ct,Ue]:ct===0?[Ue,ct]:[Ue,-ct]}(J);let Fe=Math.abs(Y.top-Y.bottom);for(const Ge of Y.positionedLines)Fe-=Ge.lineOffset;const ve=Y.positionedLines.length,Ve=Fe/ve;let Ke=Y.top-J[1];for(let Ge=0;Ge<ve;++Ge){const ct=Y.positionedLines[Ge];Ke=Ey(Y,Ve,Ke,Ge);for(const Ue of ct.positionedGlyphs){if(!Ue.rect)continue;const rt=Ue.rect||{};let ut=Ef+1,kt=!0,ht=1,at=0;if(Ue.imageName){const Yt=Le[Ue.imageName];if(!Yt)continue;if(Yt.sdf){li("SDF images are not supported in formatted text and will be ignored.");continue}kt=!1,ht=Yt.pixelRatio,ut=cr/ht}const Qt=(de||ye)&&Ue.vertical,ft=Ue.metrics.advance*Ue.scale/2,mt=Ue.metrics,Zt=Ue.rect;if(Zt===null)continue;ye&&Y.verticalizable&&(at=Ue.imageName?ft-Ue.metrics.width*Ue.scale/2:0);const Kt=de?[Ue.x+ft,Ue.y]:[0,0];let Jt=[0,0],Wt=[0,0],ui=!1;de||(Qt?(Wt=[Ue.x+ft+Ce[0],Ue.y+Ce[1]-at],ui=!0):Jt=[Ue.x+ft+J[0],Ue.y+J[1]-at]);const mi=Zt.w*Ue.scale/(ht*(Ue.localGlyph?sn:1)),Si=Zt.h*Ue.scale/(ht*(Ue.localGlyph?sn:1));let Xt,Pi,Ai,hi;if(Qt){const Yt=Ue.y-Ke,ir=new Re(-ft,ft-Yt),Ii=-Math.PI/2,Vi=new Re(...Wt);Xt=new Re(-ft+Jt[0],Jt[1]),Xt._rotateAround(Ii,ir)._add(Vi),Xt.x+=-Yt+ft,Xt.y-=(mt.left-ut)*Ue.scale;const Fi=Ue.imageName?mt.advance*Ue.scale:ji*Ue.scale,rr=String.fromCharCode(Ue.glyph);oy(rr)?Xt.x+=(1-ut)*Ue.scale:sy(rr)?Xt.x+=Fi-mt.height*Ue.scale+(-ut-1)*Ue.scale:Xt.x+=Ue.imageName||mt.width+2*ut===Zt.w&&mt.height+2*ut===Zt.h?(Fi-Si)/2:(Fi-(mt.height+2*ut)*Ue.scale)/2,Pi=new Re(Xt.x,Xt.y-mi),Ai=new Re(Xt.x+Si,Xt.y),hi=new Re(Xt.x+Si,Xt.y-mi)}else{const Yt=(mt.left-ut)*Ue.scale-ft+Jt[0],ir=(-mt.top-ut)*Ue.scale+Jt[1],Ii=Yt+mi,Vi=ir+Si;Xt=new Re(Yt,ir),Pi=new Re(Ii,ir),Ai=new Re(Yt,Vi),hi=new Re(Ii,Vi)}if(Me){let Yt;Yt=de?new Re(0,0):ui?new Re(Ce[0],Ce[1]):new Re(J[0],J[1]),Xt._rotateAround(Me,Yt),Pi._rotateAround(Me,Yt),Ai._rotateAround(Me,Yt),hi._rotateAround(Me,Yt)}const Rt=new Re(0,0),Mi=new Re(0,0);Ae.push({tl:Xt,tr:Pi,bl:Ai,br:hi,tex:rt,writingMode:Y.writingMode,glyphOffset:Kt,sectionIndex:Ue.sectionIndex,isSDF:kt,pixelOffsetTL:Rt,pixelOffsetBR:Mi,minFontScaleX:0,minFontScaleY:0})}}return Ae}(0,n,m,c,h,p,a,t.allowVerticalPlacement),K=t.textSizeData;let G=null;K.kind==="source"?(G=[on*c.layout.get("text-size").evaluate(p,{},B)],G[0]>zo&&li(`${t.layerIds[0]}: Value for "text-size" is >= ${pc}. Reduce your "text-size".`)):K.kind==="composite"&&(G=[on*M.compositeTextSizes[0].evaluate(p,{},B),on*M.compositeTextSizes[1].evaluate(p,{},B)],(G[0]>zo||G[1]>zo)&&li(`${t.layerIds[0]}: Value for "text-size" is >= ${pc}. Reduce your "text-size".`)),t.addSymbols(t.text,V,G,m,h,p,x,e,i,_.lineStartIndex,_.lineLength,A,z,B);for(const X of b)T[X]=t.text.placedSymbolArray.length-1;return 4*V.length}function qf(t){for(const e in t)return t[e];return null}function ju(t,e,i,n,a,c,h,p,m,_){let x=h.top,b=h.bottom,T=h.left,A=h.right;const M=h.collisionPadding;if(M&&(T-=M[0],x-=M[1],A+=M[2],b+=M[3]),m){const z=new Re(T,x),B=new Re(A,x),V=new Re(T,b),K=new Re(A,b),G=At(m);let X=new Re(0,0);_&&(X=new Re(_[0],_[1])),z._rotateAround(G,X),B._rotateAround(G,X),V._rotateAround(G,X),K._rotateAround(G,X),T=Math.min(z.x,B.x,V.x,K.x),A=Math.max(z.x,B.x,V.x,K.x),x=Math.min(z.y,B.y,V.y,K.y),b=Math.max(z.y,B.y,V.y,K.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,T,x,A,b,p,n,a,c),t.length-1}function xd(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function ky(t,e,i,n){const a=t.compareText;if(e in a){const c=a[e];for(let h=c.length-1;h>=0;h--)if(n.dist(c[h])<i)return!0}else a[e]=[];return a[e].push(n),!1}function Zf(t,e){const i=t.fovAboveCenter,n=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,a=(t._camera.position[2]*t.worldSize-n)/Math.cos(t._pitch),c=Math.sin(i)*a/Math.sin(Math.max(Math.PI/2-t._pitch-i,.01)),h=Math.sin(t._pitch)*c+a;return Math.min(1.01*h,a*(1/t._horizonShift))}function ks(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};const i=Math.pow(2,-t.z),n=t.x*i,a=(t.x+1)*i,c=t.y*i,h=(t.y+1)*i,p=Mr(n),m=Mr(a),_=Zi(c),x=Zi(h),b=e.project(p,_),T=e.project(m,_),A=e.project(m,x),M=e.project(p,x);let z=Math.min(b.x,T.x,A.x,M.x),B=Math.min(b.y,T.y,A.y,M.y),V=Math.max(b.x,T.x,A.x,M.x),K=Math.max(b.y,T.y,A.y,M.y);const G=i/16;function X(J,me,de,Te,Le,ye){const Ae=(de+Le)/2,Me=(Te+ye)/2,Ce=e.project(Mr(Ae),Zi(Me)),Fe=Math.max(0,z-Ce.x,B-Ce.y,Ce.x-V,Ce.y-K);z=Math.min(z,Ce.x),V=Math.max(V,Ce.x),B=Math.min(B,Ce.y),K=Math.max(K,Ce.y),Fe>G&&(X(J,Ce,de,Te,Ae,Me),X(Ce,me,Ae,Me,Le,ye))}X(b,T,n,c,a,c),X(T,A,a,c,a,h),X(A,M,a,h,n,h),X(M,b,n,h,n,c),z-=G,B-=G,V+=G,K+=G;const Y=1/Math.max(V-z,K-B);return{scale:Y,x:z*Y,y:B*Y,x2:V*Y,y2:K*Y,projection:e}}const Ly=tn(new Float32Array(16));class ko{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,i){return{x:0,y:0,z:0}}unproject(e,i){return new qt(0,0)}projectTilePoint(e,i,n){return{x:e,y:i,z:0}}locationPoint(e,i,n=!0){return e._coordinatePoint(e.locationCoordinate(i),n)}pixelsPerMeter(e,i){return nn(1,e)*i}pixelSpaceConversion(e,i,n){return 1}farthestPixelDistance(e){return Zf(e,e.pixelsPerMeter)}pointCoordinate(e,i,n,a){const c=e.horizonLineFromTop(!1),h=new Re(i,Math.max(c,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(h,a))}pointCoordinate3D(e,i,n){const a=new Re(i,n);if(e.elevation)return e.elevation.pointCoordinate(a);{const c=this.pointCoordinate(e,a.x,a.y,0);return[c.x,c.y,c.z]}}isPointAboveHorizon(e,i){if(e.elevation)return!this.pointCoordinate3D(e,i.x,i.y);const n=e.horizonLineFromTop();return i.y<n}createInversionMatrix(e,i){return Ly}createTileMatrix(e,i,n){let a,c,h;const p=n.canonical,m=tn(new Float64Array(16));if(this.isReprojectedInTileSpace){const _=ks(p,this);a=1,c=_.x+n.wrap*_.scale,h=_.y,Ss(m,m,[a/_.scale,a/_.scale,e.pixelsPerMeter/i])}else a=i/e.zoomScale(p.z),c=(p.x+Math.pow(2,p.z)*n.wrap)*a,h=p.y*a;return $l(m,m,[c,h,0]),Ss(m,m,[a/nt,a/nt,1]),m}upVector(e,i,n){return[0,0,1]}upVectorScale(e,i,n){return{metersToTile:1}}}class Dy extends ko{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[i,n]=this.parallels=e.parallels||[29.5,45.5],a=Math.sin(At(i));this.n=(a+Math.sin(At(n)))/2,this.c=1+a*(2*this.n-a),this.r0=Math.sqrt(this.c)/this.n}project(e,i){const{n,c:a,r0:c}=this,h=At(e-this.center[0]),p=At(i),m=Math.sqrt(a-2*n*Math.sin(p))/n;return{x:m*Math.sin(h*n),y:m*Math.cos(h*n)-c,z:0}}unproject(e,i){const{n,c:a,r0:c}=this,h=c+i;let p=Math.atan2(e,Math.abs(h))*Math.sign(h);h*n<0&&(p-=Math.PI*Math.sign(e)*Math.sign(h));const m=At(this.center[0])*n;p=zi(p,-Math.PI-m,Math.PI-m);const _=Tt(ki(p/n)+this.center[0],-180,180),x=Math.asin(Tt((a-(e*e+h*h)*n*n)/(2*n),-1,1)),b=Tt(ki(x),-Wi,Wi);return new qt(_,b)}}const fc=1.340264,mc=-.081106,_c=893e-6,gc=.003796,Vu=Math.sqrt(3)/2;class Ry extends ko{project(e,i){i=i/180*Math.PI,e=e/180*Math.PI;const n=Math.asin(Vu*Math.sin(i)),a=n*n,c=a*a*a;return{x:.5*(e*Math.cos(n)/(Vu*(fc+3*mc*a+c*(7*_c+9*gc*a)))/Math.PI+.5),y:1-.5*(n*(fc+mc*a+c*(_c+gc*a))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let n=i=(2*(1-i)-1)*Math.PI,a=n*n,c=a*a*a;for(let x,b,T,A=0;A<12&&(b=n*(fc+mc*a+c*(_c+gc*a))-i,T=fc+3*mc*a+c*(7*_c+9*gc*a),x=b/T,n=Tt(n-x,-Math.PI/3,Math.PI/3),a=n*n,c=a*a*a,!(Math.abs(x)<1e-12));++A);const h=Vu*e*(fc+3*mc*a+c*(7*_c+9*gc*a))/Math.cos(n),p=Math.asin(Math.sin(n)/Vu),m=Tt(180*h/Math.PI,-180,180),_=Tt(180*p/Math.PI,-Wi,Wi);return new qt(m,_)}}class By extends ko{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){return{x:.5+e/360,y:.5-i/360,z:0}}unproject(e,i){const n=360*(e-.5),a=Tt(360*(.5-i),-Wi,Wi);return new qt(n,a)}}const Ua=Math.PI/2;function Gu(t){return Math.tan((Ua+t)/2)}class Oy extends ko{constructor(e){super(e),this.center=e.center||[0,30];const[i,n]=this.parallels=e.parallels||[30,30];let a=At(i),c=At(n);this.southernCenter=a+c<0,this.southernCenter&&(a=-a,c=-c);const h=Math.cos(a),p=Gu(a);this.n=a===c?Math.sin(a):Math.log(h/Math.cos(c))/Math.log(Gu(c)/p),this.f=h*Math.pow(Gu(a),this.n)/this.n}project(e,i){i=At(i),this.southernCenter&&(i=-i),e=At(e-this.center[0]);const n=1e-6,{n:a,f:c}=this;c>0?i<-Ua+n&&(i=-Ua+n):i>Ua-n&&(i=Ua-n);const h=c/Math.pow(Gu(i),a);let p=h*Math.sin(a*e),m=c-h*Math.cos(a*e);return p=.5*(p/Math.PI+.5),m=.5*(m/Math.PI+.5),{x:p,y:this.southernCenter?m:1-m,z:0}}unproject(e,i){e=(2*e-.5)*Math.PI,this.southernCenter&&(i=1-i),i=(2*(1-i)-.5)*Math.PI;const{n,f:a}=this,c=a-i,h=Math.sign(c),p=Math.sign(n)*Math.sqrt(e*e+c*c);let m=Math.atan2(e,Math.abs(c))*h;c*n<0&&(m-=Math.PI*Math.sign(e)*h);const _=Tt(ki(m/n)+this.center[0],-180,180),x=Tt(ki(2*Math.atan(Math.pow(a/p,1/n))-Ua),-Wi,Wi);return new qt(_,this.southernCenter?-x:x)}}class Wf extends ko{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,i){return{x:bn(e),y:wn(i),z:0}}unproject(e,i){const n=Mr(e),a=Zi(i);return new qt(n,a)}}const Xf=At(Wi);class Fy extends ko{project(e,i){const n=(i=At(i))*i,a=n*n;return{x:.5*((e=At(e))*(.8707-.131979*n+a*(a*(.003971*n-.001529*a)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+n*(.015085+a*(.028874*n-.044475-.005916*a)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let n=i=(2*(1-i)-1)*Math.PI,a=25,c=0,h=n*n;do{h=n*n;const _=h*h;c=(n*(1.007226+h*(.015085+_*(.028874*h-.044475-.005916*_)))-i)/(1.007226+h*(.045255+_*(.259866*h-.311325-.005916*11*_))),n=Tt(n-c,-Xf,Xf)}while(Math.abs(c)>1e-6&&--a>0);h=n*n;const p=Tt(ki(e/(.8707+h*(h*(h*h*h*(.003971-.001529*h)-.013791)-.131979))),-180,180),m=ki(n);return new qt(p,m)}}const Hf=At(Wi);class Uy extends ko{project(e,i){i=At(i),e=At(e);const n=Math.cos(i),a=2/Math.PI,c=Math.acos(n*Math.cos(e/2)),h=Math.sin(c)/c,p=.5*(e*a+2*n*Math.sin(e/2)/h)||0,m=.5*(i+Math.sin(i)/h)||0;return{x:.5*(p/Math.PI+.5),y:1-.5*(m/Math.PI+1),z:0}}unproject(e,i){let n=e=(2*e-.5)*Math.PI,a=i=(2*(1-i)-1)*Math.PI,c=25;const h=1e-6;let p=0,m=0;do{const _=Math.cos(a),x=Math.sin(a),b=2*x*_,T=x*x,A=_*_,M=Math.cos(n/2),z=Math.sin(n/2),B=2*M*z,V=z*z,K=1-A*M*M,G=K?1/K:0,X=K?Math.acos(_*M)*Math.sqrt(1/K):0,Y=.5*(2*X*_*z+2*n/Math.PI)-e,J=.5*(X*x+a)-i,me=.5*G*(A*V+X*_*M*T)+1/Math.PI,de=G*(B*b/4-X*x*z),Te=.125*G*(b*z-X*x*A*B),Le=.5*G*(T*M+X*V*_)+.5,ye=de*Te-Le*me;p=(J*de-Y*Le)/ye,m=(Y*Te-J*me)/ye,n=Tt(n-p,-Math.PI,Math.PI),a=Tt(a-m,-Hf,Hf)}while((Math.abs(p)>h||Math.abs(m)>h)&&--c>0);return new qt(ki(n),ki(a))}}class Kf extends ko{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(At(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){const{scale:n,cosPhi:a}=this;return{x:At(e)*a*n+.5,y:-Math.sin(At(i))/a*n+.5,z:0}}unproject(e,i){const{scale:n,cosPhi:a}=this,c=-(i-.5)/n,h=Tt(ki((e-.5)/n)/a,-180,180),p=Math.asin(Tt(c*a,-1,1)),m=Tt(ki(p),-Wi,Wi);return new qt(h,m)}}class Ny extends Wf{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const a=Yl(e,i,n);return yi(a,a,Ql(vn(n))),{x:a[0],y:a[1],z:a[2]}}locationPoint(e,i){const n=Ea(i.lat,i.lng),a=Qi([],n),c=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude;Xl(n,n,a,nn(1,0)*nt*c);const h=tn(new Float64Array(16));return Es(h,e.pixelMatrix,e.globeMatrix),yi(n,n,h),new Re(n[0],n[1])}pixelsPerMeter(e,i){return nn(1,0)*i}pixelSpaceConversion(e,i,n){const a=nn(1,e)*i,c=Pt(nn(1,45)*i,a,n);return this.pixelsPerMeter(e,i)/c}createTileMatrix(e,i,n){const a=Gh(vn(n.canonical));return Es(new Float64Array(16),e.globeMatrix,a)}createInversionMatrix(e,i){const{center:n}=e,a=Ql(vn(i));return gu(a,a,At(n.lng)),Lh(a,a,At(n.lat)),Ss(a,a,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(a)}pointCoordinate(e,i,n,a){return wp(e,i,n,!0)||new Aa(0,0)}pointCoordinate3D(e,i,n){const a=this.pointCoordinate(e,i,n,0);return[a.x,a.y,a.z]}isPointAboveHorizon(e,i){return!wp(e,i.x,i.y,!1)}farthestPixelDistance(e){const i=function(a,c){const h=a.cameraToCenterDistance,p=a._centerAltitude*c,m=a._camera,_=a._camera.forward(),x=Wn([],Ar([],_,-h),[0,0,p]),b=a.worldSize/(2*Math.PI),T=[0,0,-b],A=a.width/a.height,M=Math.tan(a.fovAboveCenter),z=Ar([],m.up(),M),B=Ar([],m.right(),M*A),V=Qi([],Wn([],Wn([],_,z),B)),K=[];let G;if(new Oh(x,V).closestPointOnSphere(T,b,K)){const X=Wn([],K,T),Y=rn([],X,x);G=Math.cos(a.fovAboveCenter)*ql(Y)}else{const X=rn([],x,T),Y=rn([],T,x);Qi(Y,Y);const J=ql(X)-b;G=Math.sqrt(J*(J+2*b));const me=Math.acos(G/(b+J))-Math.acos(Br(_,Y));G*=Math.cos(me)}return 1.01*G}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Sa(e.zoom);if(n>0){const a=Zf(e,nn(1,e.center.lat)*e.worldSize),c=e.worldSize/(2*Math.PI),h=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Pt(i,a+c*(1-Math.cos(h)),Math.pow(n,10))}return i}upVector(e,i,n){return Yl(i,n,e,1)}upVectorScale(e){return{metersToTile:yu(vu(vn(e)))}}}function Jf(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new Wf(t);case"equirectangular":return new By(t);case"naturalEarth":return new Fy(t);case"equalEarth":return new Ry(t);case"winkelTripel":return new Uy(t);case"albers":return i?new Kf(t):new Dy(t);case"lambertConformalConic":return i?new Kf(t):new Oy(t);case"globe":return new Ny(t)}throw new Error(`Invalid projection name: ${t.name}`)}const jy=Pu.types,Vy=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function $u(t,e,i,n,a,c,h,p,m,_,x,b,T){const A=p?Math.min(zo,Math.round(p[0])):0,M=p?Math.min(zo,Math.round(p[1])):0;t.emplaceBack(e,i,Math.round(32*n),Math.round(32*a),c,h,(A<<1)+(m?1:0),M,16*_,16*x,256*b,256*T)}function qu(t,e,i,n,a,c,h){t.emplaceBack(e,i,n,a,c,h)}function Zu(t,e,i,n,a){t.emplaceBack(e,i,n,a),t.emplaceBack(e,i,n,a),t.emplaceBack(e,i,n,a),t.emplaceBack(e,i,n,a)}function Gy(t){for(const e of t.sections)if(Ih(e.text))return!0;return!1}class vd{constructor(e){this.layoutVertexArray=new Ie,this.indexArray=new tt,this.programConfigurations=e,this.segments=new Ti,this.dynamicLayoutVertexArray=new ze,this.opacityVertexArray=new it,this.placedSymbolArray=new wi,this.globeExtVertexArray=new Be}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,i,n,a){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Jg.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Qg.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Vy,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Yg.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||a)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Xe(vd,"SymbolBuffers");class bd{constructor(e,i,n){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new n,this.segments=new Ti,this.collisionVertexArray=new wt,this.collisionVertexArrayExt=new xt}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,ey.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,ty.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Xe(bd,"CollisionBuffers");class Lo{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(h=>h.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=tn([]),this.placementViewportMatrix=tn([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=cd(this.zoom,i["text-size"]),this.iconSizeData=cd(this.zoom,i["icon-size"]);const n=this.layers[0].layout,a=n.get("symbol-sort-key"),c=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey=c!=="viewport-y"&&a.constantOr(1)!==void 0,this.sortFeaturesByY=(c==="viewport-y"||c==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(h=>Ir[h]),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new vd(new Ts(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new vd(new Ts(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Yi,this.lineVertexArray=new xa,this.symbolInstances=new ii}calculateGlyphDependencies(e,i,n,a,c){for(let h=0;h<e.length;h++)if(i[e.charCodeAt(h)]=!0,a&&c){const p=uc[e.charAt(h)];p&&(i[p.charCodeAt(0)]=!0)}}populate(e,i,n,a){const c=this.layers[0],h=c.layout,p=this.projection.name==="globe",m=h.get("text-font"),_=h.get("text-field"),x=h.get("icon-image"),b=(_.value.kind!=="constant"||_.value.value instanceof Ji&&!_.value.value.isEmpty()||_.value.value.toString().length>0)&&(m.value.kind!=="constant"||m.value.value.length>0),T=x.value.kind!=="constant"||!!x.value.value||Object.keys(x.parameters).length>0,A=h.get("symbol-sort-key");if(this.features=[],!b&&!T)return;const M=i.iconDependencies,z=i.glyphDependencies,B=i.availableImages,V=new v(this.zoom);for(const{feature:K,id:G,index:X,sourceLayerIndex:Y}of e){const J=c._featureFilter.needGeometry,me=Cs(K,J);if(!c._featureFilter.filter(V,me,n))continue;if(J||(me.geometry=Xn(K,n,a)),p&&K.type!==1&&n.z<=5){const ye=me.geometry,Ae=.98078528056,Me=(Ce,Fe)=>Br(Yl(Ce.x,Ce.y,n,1),Yl(Fe.x,Fe.y,n,1))<Ae;for(let Ce=0;Ce<ye.length;Ce++)ye[Ce]=Q_(ye[Ce],Me)}let de,Te;if(b){const ye=c.getValueAndResolveTokens("text-field",me,n,B),Ae=Ji.factory(ye);Gy(Ae)&&(this.hasRTLText=!0),(!this.hasRTLText||f()==="unavailable"||this.hasRTLText&&y.isParsed())&&(de=ny(Ae,c,me))}if(T){const ye=c.getValueAndResolveTokens("icon-image",me,n,B);Te=ye instanceof pr?ye:pr.fromString(ye)}if(!de&&!Te)continue;const Le=this.sortFeaturesByKey?A.evaluate(me,{},n):void 0;if(this.features.push({id:G,text:de,icon:Te,index:X,sourceLayerIndex:Y,geometry:me.geometry,properties:K.properties,type:jy[K.type],sortKey:Le}),Te&&(M[Te.name]=!0),de){const ye=m.evaluate(me,{},n).join(","),Ae=h.get("text-rotation-alignment")==="map"&&h.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Ir.vertical)>=0;for(const Me of de.sections)if(Me.image)M[Me.image.name]=!0;else{const Ce=Ol(de.toString()),Fe=Me.fontStack||ye,ve=z[Fe]=z[Fe]||{};this.calculateGlyphDependencies(Me.text,ve,Ae,this.allowVerticalPlacement,Ce)}}}h.get("symbol-placement")==="line"&&(this.features=function(K){const G={},X={},Y=[];let J=0;function me(ye){Y.push(K[ye]),J++}function de(ye,Ae,Me){const Ce=X[ye];return delete X[ye],X[Ae]=Ce,Y[Ce].geometry[0].pop(),Y[Ce].geometry[0]=Y[Ce].geometry[0].concat(Me[0]),Ce}function Te(ye,Ae,Me){const Ce=G[Ae];return delete G[Ae],G[ye]=Ce,Y[Ce].geometry[0].shift(),Y[Ce].geometry[0]=Me[0].concat(Y[Ce].geometry[0]),Ce}function Le(ye,Ae,Me){const Ce=Me?Ae[0][Ae[0].length-1]:Ae[0][0];return`${ye}:${Ce.x}:${Ce.y}`}for(let ye=0;ye<K.length;ye++){const Ae=K[ye],Me=Ae.geometry,Ce=Ae.text?Ae.text.toString():null;if(!Ce){me(ye);continue}const Fe=Le(Ce,Me),ve=Le(Ce,Me,!0);if(Fe in X&&ve in G&&X[Fe]!==G[ve]){const Ve=Te(Fe,ve,Me),Ke=de(Fe,ve,Y[Ve].geometry);delete G[Fe],delete X[ve],X[Le(Ce,Y[Ke].geometry,!0)]=Ke,Y[Ve].geometry=null}else Fe in X?de(Fe,ve,Me):ve in G?Te(Fe,ve,Me):(me(ye),G[Fe]=J-1,X[ve]=J-1)}return Y.filter(ye=>ye.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((K,G)=>K.sortKey-G.sortKey)}update(e,i,n,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,i,this.layers,n,a),this.icon.programConfigurations.updatePaintArrays(e,i,this.layers,n,a))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Jf(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){const n=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:a,y:c}of i)this.lineVertexArray.emplaceBack(a,c);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,i,n,a,c,h,p,m,_,x,b,T,A,M){const z=e.indexArray,B=e.layoutVertexArray,V=e.globeExtVertexArray,K=e.segments.prepareSegment(4*i.length,B,z,this.canOverlap?h.sortKey:void 0),G=this.glyphOffsetArray.length,X=K.vertexLength,Y=this.allowVerticalPlacement&&p===Ir.vertical?Math.PI/2:0,J=h.text&&h.text.sections;for(let de=0;de<i.length;de++){const{tl:Te,tr:Le,bl:ye,br:Ae,tex:Me,pixelOffsetTL:Ce,pixelOffsetBR:Fe,minFontScaleX:ve,minFontScaleY:Ve,glyphOffset:Ke,isSDF:Ge,sectionIndex:ct}=i[de],Ue=K.vertexLength,rt=Ke[1];if($u(B,_.x,_.y,Te.x,rt+Te.y,Me.x,Me.y,n,Ge,Ce.x,Ce.y,ve,Ve),$u(B,_.x,_.y,Le.x,rt+Le.y,Me.x+Me.w,Me.y,n,Ge,Fe.x,Ce.y,ve,Ve),$u(B,_.x,_.y,ye.x,rt+ye.y,Me.x,Me.y+Me.h,n,Ge,Ce.x,Fe.y,ve,Ve),$u(B,_.x,_.y,Ae.x,rt+Ae.y,Me.x+Me.w,Me.y+Me.h,n,Ge,Fe.x,Fe.y,ve,Ve),m){const{x:ut,y:kt,z:ht}=m.anchor,[at,Qt,ft]=m.up;qu(V,ut,kt,ht,at,Qt,ft),qu(V,ut,kt,ht,at,Qt,ft),qu(V,ut,kt,ht,at,Qt,ft),qu(V,ut,kt,ht,at,Qt,ft),Zu(e.dynamicLayoutVertexArray,ut,kt,ht,Y)}else Zu(e.dynamicLayoutVertexArray,_.x,_.y,_.z,Y);z.emplaceBack(Ue,Ue+1,Ue+2),z.emplaceBack(Ue+1,Ue+2,Ue+3),K.vertexLength+=4,K.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Ke[0]),de!==i.length-1&&ct===i[de+1].sectionIndex||e.programConfigurations.populatePaintArrays(B.length,h,h.index,{},A,M,J&&J[ct])}const me=m?m.anchor:_;e.placedSymbolArray.emplaceBack(me.x,me.y,me.z,_.x,_.y,G,this.glyphOffsetArray.length-G,X,x,b,_.segment,n?n[0]:0,n?n[1]:0,a[0],a[1],p,0,!1,0,T,0)}_commitLayoutVertex(e,i,n,a,c,h,p){e.emplaceBack(i,n,a,c,h,Math.round(p.x),Math.round(p.y))}_addCollisionDebugVertices(e,i,n,a,c,h,p){const m=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),_=m.vertexLength,x=p.tileAnchorX,b=p.tileAnchorY;for(let A=0;A<4;A++)n.collisionVertexArray.emplaceBack(0,0,0,0);n.collisionVertexArrayExt.emplaceBack(i,-e.padding,-e.padding),n.collisionVertexArrayExt.emplaceBack(i,e.padding,-e.padding),n.collisionVertexArrayExt.emplaceBack(i,e.padding,e.padding),n.collisionVertexArrayExt.emplaceBack(i,-e.padding,e.padding),this._commitLayoutVertex(n.layoutVertexArray,a,c,h,x,b,new Re(e.x1,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,a,c,h,x,b,new Re(e.x2,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,a,c,h,x,b,new Re(e.x2,e.y2)),this._commitLayoutVertex(n.layoutVertexArray,a,c,h,x,b,new Re(e.x1,e.y2)),m.vertexLength+=4;const T=n.indexArray;T.emplaceBack(_,_+1),T.emplaceBack(_+1,_+2),T.emplaceBack(_+2,_+3),T.emplaceBack(_+3,_),m.primitiveLength+=4}_addTextDebugCollisionBoxes(e,i,n,a,c,h){for(let p=a;p<c;p++){const m=n.get(p),_=this.getSymbolInstanceTextSize(e,h,i,p);this._addCollisionDebugVertices(m,_,this.textCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,h)}}_addIconDebugCollisionBoxes(e,i,n,a,c,h){for(let p=a;p<c;p++){const m=n.get(p),_=this.getSymbolInstanceIconSize(e,i,h.placedIconSymbolIndex);this._addCollisionDebugVertices(m,_,this.iconCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,h)}}generateCollisionDebugBuffers(e,i){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new bd(He,_f.members,Oi),this.iconCollisionBox=new bd(He,_f.members,Oi);const n=za(this.iconSizeData,e),a=za(this.textSizeData,e);for(let c=0;c<this.symbolInstances.length;c++){const h=this.symbolInstances.get(c);this._addTextDebugCollisionBoxes(a,e,i,h.textBoxStartIndex,h.textBoxEndIndex,h),this._addTextDebugCollisionBoxes(a,e,i,h.verticalTextBoxStartIndex,h.verticalTextBoxEndIndex,h),this._addIconDebugCollisionBoxes(n,e,i,h.iconBoxStartIndex,h.iconBoxEndIndex,h),this._addIconDebugCollisionBoxes(n,e,i,h.verticalIconBoxStartIndex,h.verticalIconBoxEndIndex,h)}}getSymbolInstanceTextSize(e,i,n,a){const c=this.text.placedSymbolArray.get(i.rightJustifiedTextSymbolIndex>=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:a),h=Du(this.textSizeData,e,c)/ji;return this.tilePixelRatio*h}getSymbolInstanceIconSize(e,i,n){const a=this.icon.placedSymbolArray.get(n),c=Du(this.iconSizeData,e,a);return this.tilePixelRatio*c}_commitDebugCollisionVertexUpdate(e,i,n){e.emplaceBack(i,-n,-n),e.emplaceBack(i,n,-n),e.emplaceBack(i,n,n),e.emplaceBack(i,-n,n)}_updateTextDebugCollisionBoxes(e,i,n,a,c,h){for(let p=a;p<c;p++){const m=n.get(p),_=this.getSymbolInstanceTextSize(e,h,i,p);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,_,m.padding)}}_updateIconDebugCollisionBoxes(e,i,n,a,c,h){for(let p=a;p<c;p++){const m=n.get(p),_=this.getSymbolInstanceIconSize(e,i,h);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,_,m.padding)}}updateCollisionDebugBuffers(e,i){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const n=za(this.iconSizeData,e),a=za(this.textSizeData,e);for(let c=0;c<this.symbolInstances.length;c++){const h=this.symbolInstances.get(c);this._updateTextDebugCollisionBoxes(a,e,i,h.textBoxStartIndex,h.textBoxEndIndex,h),this._updateTextDebugCollisionBoxes(a,e,i,h.verticalTextBoxStartIndex,h.verticalTextBoxEndIndex,h),this._updateIconDebugCollisionBoxes(n,e,i,h.iconBoxStartIndex,h.iconBoxEndIndex,h.placedIconSymbolIndex),this._updateIconDebugCollisionBoxes(n,e,i,h.verticalIconBoxStartIndex,h.verticalIconBoxEndIndex,h.placedIconSymbolIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,i,n,a,c,h,p,m,_){const x={};if(i<n){const{x1:b,y1:T,x2:A,y2:M,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:K,tileAnchorX:G,tileAnchorY:X,featureIndex:Y}=e.get(i);x.textBox={x1:b,y1:T,x2:A,y2:M,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:K,tileAnchorX:G,tileAnchorY:X},x.textFeatureIndex=Y}if(a<c){const{x1:b,y1:T,x2:A,y2:M,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:K,tileAnchorX:G,tileAnchorY:X,featureIndex:Y}=e.get(a);x.verticalTextBox={x1:b,y1:T,x2:A,y2:M,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:K,tileAnchorX:G,tileAnchorY:X},x.verticalTextFeatureIndex=Y}if(h<p){const{x1:b,y1:T,x2:A,y2:M,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:K,tileAnchorX:G,tileAnchorY:X,featureIndex:Y}=e.get(h);x.iconBox={x1:b,y1:T,x2:A,y2:M,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:K,tileAnchorX:G,tileAnchorY:X},x.iconFeatureIndex=Y}if(m<_){const{x1:b,y1:T,x2:A,y2:M,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:K,tileAnchorX:G,tileAnchorY:X,featureIndex:Y}=e.get(m);x.verticalIconBox={x1:b,y1:T,x2:A,y2:M,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:K,tileAnchorX:G,tileAnchorY:X},x.verticalIconFeatureIndex=Y}return x}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const n=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,i){const n=e.placedSymbolArray.get(i),a=n.vertexStartIndex+4*n.numGlyphs;for(let c=n.vertexStartIndex;c<a;c+=4)e.indexArray.emplaceBack(c,c+1,c+2),e.indexArray.emplaceBack(c+1,c+2,c+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(e),n=Math.cos(e),a=[],c=[],h=[];for(let p=0;p<this.symbolInstances.length;++p){h.push(p);const m=this.symbolInstances.get(p);a.push(0|Math.round(i*m.tileAnchorX+n*m.tileAnchorY)),c.push(m.featureIndex)}return h.sort((p,m)=>a[p]-a[m]||c[m]-c[p]),h}addToSortKeyRanges(e,i){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===i?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const n=this.symbolInstances.get(i);this.featureSortOrder.push(n.featureIndex);const{rightJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:c,leftJustifiedTextSymbolIndex:h,verticalPlacedTextSymbolIndex:p,placedIconSymbolIndex:m,verticalPlacedIconSymbolIndex:_}=n;a>=0&&this.addIndicesForPlacedSymbol(this.text,a),c>=0&&c!==a&&this.addIndicesForPlacedSymbol(this.text,c),h>=0&&h!==c&&h!==a&&this.addIndicesForPlacedSymbol(this.text,h),p>=0&&this.addIndicesForPlacedSymbol(this.text,p),m>=0&&this.addIndicesForPlacedSymbol(this.icon,m),_>=0&&this.addIndicesForPlacedSymbol(this.icon,_)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Xe(Lo,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Lo.MAX_GLYPHS=65535,Lo.addDynamicAttributes=Zu;const $y=new q({"symbol-placement":new P(be.layout_symbol["symbol-placement"]),"symbol-spacing":new P(be.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new P(be.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new O(be.layout_symbol["symbol-sort-key"]),"symbol-z-order":new P(be.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new P(be.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new P(be.layout_symbol["icon-ignore-placement"]),"icon-optional":new P(be.layout_symbol["icon-optional"]),"icon-rotation-alignment":new P(be.layout_symbol["icon-rotation-alignment"]),"icon-size":new O(be.layout_symbol["icon-size"]),"icon-text-fit":new P(be.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new P(be.layout_symbol["icon-text-fit-padding"]),"icon-image":new O(be.layout_symbol["icon-image"]),"icon-rotate":new O(be.layout_symbol["icon-rotate"]),"icon-padding":new P(be.layout_symbol["icon-padding"]),"icon-keep-upright":new P(be.layout_symbol["icon-keep-upright"]),"icon-offset":new O(be.layout_symbol["icon-offset"]),"icon-anchor":new O(be.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new P(be.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new P(be.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new P(be.layout_symbol["text-rotation-alignment"]),"text-field":new O(be.layout_symbol["text-field"]),"text-font":new O(be.layout_symbol["text-font"]),"text-size":new O(be.layout_symbol["text-size"]),"text-max-width":new O(be.layout_symbol["text-max-width"]),"text-line-height":new O(be.layout_symbol["text-line-height"]),"text-letter-spacing":new O(be.layout_symbol["text-letter-spacing"]),"text-justify":new O(be.layout_symbol["text-justify"]),"text-radial-offset":new O(be.layout_symbol["text-radial-offset"]),"text-variable-anchor":new P(be.layout_symbol["text-variable-anchor"]),"text-anchor":new O(be.layout_symbol["text-anchor"]),"text-max-angle":new P(be.layout_symbol["text-max-angle"]),"text-writing-mode":new P(be.layout_symbol["text-writing-mode"]),"text-rotate":new O(be.layout_symbol["text-rotate"]),"text-padding":new P(be.layout_symbol["text-padding"]),"text-keep-upright":new P(be.layout_symbol["text-keep-upright"]),"text-transform":new O(be.layout_symbol["text-transform"]),"text-offset":new O(be.layout_symbol["text-offset"]),"text-allow-overlap":new P(be.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new P(be.layout_symbol["text-ignore-placement"]),"text-optional":new P(be.layout_symbol["text-optional"])});var wd={paint:new q({"icon-opacity":new O(be.paint_symbol["icon-opacity"]),"icon-color":new O(be.paint_symbol["icon-color"]),"icon-halo-color":new O(be.paint_symbol["icon-halo-color"]),"icon-halo-width":new O(be.paint_symbol["icon-halo-width"]),"icon-halo-blur":new O(be.paint_symbol["icon-halo-blur"]),"icon-translate":new P(be.paint_symbol["icon-translate"]),"icon-translate-anchor":new P(be.paint_symbol["icon-translate-anchor"]),"text-opacity":new O(be.paint_symbol["text-opacity"]),"text-color":new O(be.paint_symbol["text-color"],{runtimeType:ar,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new O(be.paint_symbol["text-halo-color"]),"text-halo-width":new O(be.paint_symbol["text-halo-width"]),"text-halo-blur":new O(be.paint_symbol["text-halo-blur"]),"text-translate":new P(be.paint_symbol["text-translate"]),"text-translate-anchor":new P(be.paint_symbol["text-translate-anchor"])}),layout:$y};class Yf{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:lo,this.defaultValue=e}evaluate(e){if(e.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Xe(Yf,"FormatSectionOverride",{omit:["defaultValue"]});class Wu extends en{constructor(e){super(e,wd)}recalculate(e,i){super.recalculate(e,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")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const n=this.layout.get("text-writing-mode");if(n){const a=[];for(const c of n)a.indexOf(c)<0&&a.push(c);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,i,n,a){const c=this.layout.get(e).evaluate(i,{},n,a),h=this._unevaluatedLayout._values[e];return h.isDataDriven()||bo(h.value)||!c?c:function(p,m){return m.replace(/{([^{}]+)}/g,(_,x)=>x in p?String(p[x]):"")}(i.properties,c)}createBucket(e){return new Lo(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of wd.paint.overridableProperties){if(!Wu.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),n=new Yf(i),a=new ha(n,i.property.specification);let c=null;c=i.value.kind==="constant"||i.value.kind==="source"?new Al("source",a):new fs("composite",a,i.value.zoomStops,i.value._interpolationType),this.paint._values[e]=new U(i.property,c,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,n){return!(!this.layout||i.isDataDriven()||n.isDataDriven())&&Wu.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const n=e.get("text-field"),a=wd.paint.properties[i];let c=!1;const h=p=>{for(const m of p)if(a.overrides&&a.overrides.hasOverride(m))return void(c=!0)};if(n.value.kind==="constant"&&n.value.value instanceof Ji)h(n.value.value.sections);else if(n.value.kind==="source"){const p=_=>{c||(_ instanceof Bn&&fi(_.value)===Jo?h(_.value.sections):_ instanceof _n?h(_.sections):_.eachChild(p))},m=n.value;m._styleExpression&&p(m._styleExpression.expression)}return c}getProgramConfiguration(e){return new Io(this,e)}}var qy={paint:new q({"background-color":new P(be.paint_background["background-color"]),"background-pattern":new P(be.paint_background["background-pattern"]),"background-opacity":new P(be.paint_background["background-opacity"])})},Zy={paint:new q({"raster-opacity":new P(be.paint_raster["raster-opacity"]),"raster-hue-rotate":new P(be.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new P(be.paint_raster["raster-brightness-min"]),"raster-brightness-max":new P(be.paint_raster["raster-brightness-max"]),"raster-saturation":new P(be.paint_raster["raster-saturation"]),"raster-contrast":new P(be.paint_raster["raster-contrast"]),"raster-resampling":new P(be.paint_raster["raster-resampling"]),"raster-fade-duration":new P(be.paint_raster["raster-fade-duration"])})};class Wy extends en{constructor(e){super(e,{}),this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isLayerDraped(){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var Xy={paint:new q({"sky-type":new P(be.paint_sky["sky-type"]),"sky-atmosphere-sun":new P(be.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new P(be.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new P(be.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new P(be.paint_sky["sky-gradient-radius"]),"sky-gradient":new $(be.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new P(be.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new P(be.paint_sky["sky-atmosphere-color"]),"sky-opacity":new P(be.paint_sky["sky-opacity"])})};function Td(t,e,i){const n=[0,0,1],a=_p([]);return yp(a,a,i?-At(t)+Math.PI:At(t)),gp(a,a,-At(e)),dp(n,n,a),Qi(n,n)}const Hy={circle:class extends en{constructor(t){super(t,sg)}createBucket(t){return new Hh(t)}queryRadius(t){const e=t;return Ma("circle-radius",this,e)+Ma("circle-stroke-width",this,e)+Tu(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,n,a,c,h,p){const m=Np(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),c.angle,t.pixelToTileUnitsFactor),_=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return jp(t,n,c,h,p,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",m,_)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new Io(this,t)}},heatmap:class extends en{createBucket(t){return new Gp(t)}constructor(t){super(t,ug),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Qh({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(t){return Ma("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,n,a,c,h,p){const m=this.paint.get("heatmap-radius").evaluate(e,i);return jp(t,n,c,h,p,!0,!0,new Re(0,0),m)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new Io(this,t)}},hillshade:class extends en{constructor(t){super(t,hg)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends en{constructor(t){super(t,Mg)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new Io(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];i.value.kind==="constant"&&i.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Iu(t)}queryRadius(){return Tu(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,n,a,c){return!t.queryGeometry.isAboveHorizon&&Rp(Up(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),c.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return!0}},"fill-extrusion":class extends en{constructor(t){super(t,Gg)}createBucket(t){return new ac(t)}queryRadius(){return Tu(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new Io(this,t)}queryIntersectsFeature(t,e,i,n,a,c,h,p,m){const _=Np(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),c.angle,t.pixelToTileUnitsFactor),x=this.paint.get("fill-extrusion-height").evaluate(e,i),b=this.paint.get("fill-extrusion-base").evaluate(e,i),T=[0,0],A=p&&c.elevation,M=c.elevation?c.elevation.exaggeration():1,z=t.tile.getBucket(this);if(A&&z instanceof ac){const X=z.centroidVertexArray,Y=m+1;Y<X.length&&(T[0]=X.geta_centroid_pos0(Y),T[1]=X.geta_centroid_pos1(Y))}if(T[0]===0&&T[1]===1)return!1;c.projection.name==="globe"&&(n=lf([n],[new Re(0,0),new Re(nt,nt)],t.tileID.canonical).map(X=>X.polygon).flat());const B=A?p:null,[V,K]=function(X,Y,J,me,de,Te,Le,ye,Ae,Me,Ce){return X.projection.name==="globe"?function(Fe,ve,Ve,Ke,Ge,ct,Ue,rt,ut,kt,ht){const at=[],Qt=[],ft=Fe.projection.upVectorScale(ht,Fe.center.lat,Fe.worldSize).metersToTile,mt=[0,0,0,1],Zt=[0,0,0,1],Kt=(Wt,ui,mi,Si)=>{Wt[0]=ui,Wt[1]=mi,Wt[2]=Si,Wt[3]=1},Jt=af();Ve>0&&(Ve+=Jt),Ke+=Jt;for(const Wt of ve){const ui=[],mi=[];for(const Si of Wt){const Xt=Si.x+Ge.x,Pi=Si.y+Ge.y,Ai=Fe.projection.projectTilePoint(Xt,Pi,ht),hi=Fe.projection.upVector(ht,Si.x,Si.y);let Rt=Ve,Mi=Ke;if(Ue){const Yt=df(Xt,Pi,Ve,Ke,Ue,rt,ut,kt);Rt+=Yt.base,Mi+=Yt.top}Ve!==0?Kt(mt,Ai.x+hi[0]*ft*Rt,Ai.y+hi[1]*ft*Rt,Ai.z+hi[2]*ft*Rt):Kt(mt,Ai.x,Ai.y,Ai.z),Kt(Zt,Ai.x+hi[0]*ft*Mi,Ai.y+hi[1]*ft*Mi,Ai.z+hi[2]*ft*Mi),yi(mt,mt,ct),yi(Zt,Zt,ct),ui.push(new Pa(mt[0],mt[1],mt[2])),mi.push(new Pa(Zt[0],Zt[1],Zt[2]))}at.push(ui),Qt.push(mi)}return[at,Qt]}(X,Y,J,me,de,Te,Le,ye,Ae,Me,Ce):Le?function(Fe,ve,Ve,Ke,Ge,ct,Ue,rt,ut){const kt=[],ht=[],at=[0,0,0,1];for(const Qt of Fe){const ft=[],mt=[];for(const Zt of Qt){const Kt=Zt.x+Ke.x,Jt=Zt.y+Ke.y,Wt=df(Kt,Jt,ve,Ve,ct,Ue,rt,ut);at[0]=Kt,at[1]=Jt,at[2]=Wt.base,at[3]=1,As(at,at,Ge),at[3]=Math.max(at[3],1e-5);const ui=new Pa(at[0]/at[3],at[1]/at[3],at[2]/at[3]);at[0]=Kt,at[1]=Jt,at[2]=Wt.top,at[3]=1,As(at,at,Ge),at[3]=Math.max(at[3],1e-5);const mi=new Pa(at[0]/at[3],at[1]/at[3],at[2]/at[3]);ft.push(ui),mt.push(mi)}kt.push(ft),ht.push(mt)}return[kt,ht]}(Y,J,me,de,Te,Le,ye,Ae,Me):function(Fe,ve,Ve,Ke,Ge){const ct=[],Ue=[],rt=Ge[8]*ve,ut=Ge[9]*ve,kt=Ge[10]*ve,ht=Ge[11]*ve,at=Ge[8]*Ve,Qt=Ge[9]*Ve,ft=Ge[10]*Ve,mt=Ge[11]*Ve;for(const Zt of Fe){const Kt=[],Jt=[];for(const Wt of Zt){const ui=Wt.x+Ke.x,mi=Wt.y+Ke.y,Si=Ge[0]*ui+Ge[4]*mi+Ge[12],Xt=Ge[1]*ui+Ge[5]*mi+Ge[13],Pi=Ge[2]*ui+Ge[6]*mi+Ge[14],Ai=Ge[3]*ui+Ge[7]*mi+Ge[15],hi=Si+rt,Rt=Xt+ut,Mi=Pi+kt,Yt=Math.max(Ai+ht,1e-5),ir=Si+at,Ii=Xt+Qt,Vi=Pi+ft,Fi=Math.max(Ai+mt,1e-5);Kt.push(new Pa(hi/Yt,Rt/Yt,Mi/Yt)),Jt.push(new Pa(ir/Fi,Ii/Fi,Vi/Fi))}ct.push(Kt),Ue.push(Jt)}return[ct,Ue]}(Y,J,me,de,Te)}(c,n,b,x,_,h,B,T,M,c.center.lat,t.tileID.canonical),G=t.queryGeometry;return function(X,Y,J){let me=1/0;Rp(J,Y)&&(me=hf(J,Y[0]));for(let de=0;de<Y.length;de++){const Te=Y[de],Le=X[de];for(let ye=0;ye<Te.length-1;ye++){const Ae=Te[ye],Me=[Ae,Te[ye+1],Le[ye+1],Le[ye],Ae];Dp(J,Me)&&(me=Math.min(me,hf(J,Me)))}}return me!==1/0&&me}(V,K,G.isPointQuery()?G.screenBounds:G.screenGeometry)}},line:class extends en{constructor(t){super(t,pf),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof pl,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=ff.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Lu(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(t){return new Io(this,t)}queryRadius(t){const e=t,i=mf(Ma("line-width",this,e),Ma("line-gap-width",this,e)),n=Ma("line-offset",this,e);return i/2+Math.abs(n)+Tu(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,a,c){if(t.queryGeometry.isAboveHorizon)return!1;const h=Up(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),c.angle,t.pixelToTileUnitsFactor),p=t.pixelToTileUnitsFactor/2*mf(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),m=this.paint.get("line-offset").evaluate(e,i);return m&&(n=function(_,x){const b=[],T=new Re(0,0);for(let A=0;A<_.length;A++){const M=_[A],z=[];for(let B=0;B<M.length;B++){const V=M[B],K=M[B+1],G=B===0?T:V.sub(M[B-1])._unit()._perp(),X=B===M.length-1?T:K.sub(V)._unit()._perp(),Y=G._add(X)._unit();Y._mult(1/(Y.x*X.x+Y.y*X.y)),z.push(Y._mult(x)._add(V))}b.push(z)}return b}(n,m*t.pixelToTileUnitsFactor)),function(_,x,b){for(let T=0;T<x.length;T++){const A=x[T];if(_.length>=3){for(let M=0;M<A.length;M++)if(Ps(_,A[M]))return!0}if(ig(_,A,b))return!0}return!1}(h,n,p)}isTileClipped(){return!0}},symbol:Wu,background:class extends en{constructor(t){super(t,qy)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends en{constructor(t){super(t,Zy)}getProgramIds(){return["raster"]}},sky:class extends en{constructor(t){super(t,Xy),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="sky-gradient"?this._updateColorRamp():t!=="sky-atmosphere-sun"&&t!=="sky-atmosphere-halo-color"&&t!=="sky-atmosphere-color"&&t!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Qh({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(t,e){if(this.paint.get("sky-type")==="atmosphere"){const n=this.paint.get("sky-atmosphere-sun"),a=!n,c=t.style.light,h=c.properties.get("position");return a&&c.properties.get("anchor")==="viewport"&&li("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),a?Td(h.azimuthal,90-h.polar,e):Td(n[0],90-n[1],e)}const i=this.paint.get("sky-gradient-center");return Td(i[0],90-i[1],e)}is3D(){return!1}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return t==="atmosphere"?["skyboxCapture","skybox"]:t==="gradient"?["skyboxGradient"]:null}}};class yc{constructor(e,i,n,a){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(i,a)}update(e,i,n){const{width:a,height:c}=e,{context:h}=this,{gl:p}=h,{HTMLImageElement:m,HTMLCanvasElement:_,HTMLVideoElement:x,ImageData:b,ImageBitmap:T}=le;if(p.bindTexture(p.TEXTURE_2D,this.texture),h.pixelStoreUnpackFlipY.set(!1),h.pixelStoreUnpack.set(1),h.pixelStoreUnpackPremultiplyAlpha.set(this.format===p.RGBA&&(!i||i.premultiply!==!1)),n||this.size&&this.size[0]===a&&this.size[1]===c){const{x:A,y:M}=n||{x:0,y:0};e instanceof m||e instanceof _||e instanceof x||e instanceof b||T&&e instanceof T?p.texSubImage2D(p.TEXTURE_2D,0,A,M,p.RGBA,p.UNSIGNED_BYTE,e):p.texSubImage2D(p.TEXTURE_2D,0,A,M,a,c,p.RGBA,p.UNSIGNED_BYTE,e.data)}else this.size=[a,c],e instanceof m||e instanceof _||e instanceof x||e instanceof b||T&&e instanceof T?p.texImage2D(p.TEXTURE_2D,0,this.format,this.format,p.UNSIGNED_BYTE,e):p.texImage2D(p.TEXTURE_2D,0,this.format,a,c,0,this.format,p.UNSIGNED_BYTE,e.data);this.useMipmap=!!(i&&i.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&p.generateMipmap(p.TEXTURE_2D)}bind(e,i){const{context:n}=this,{gl:a}=n;a.bindTexture(a.TEXTURE_2D,this.texture),e!==this.filter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap?e===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_NEAREST:e),this.filter=e),i!==this.wrap&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,i),a.texParameteri(a.TEXTURE_2D,a.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:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Ky{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Jy{constructor(){this.tasks={},this.taskQueue=[],Cn(["process"],this),this.invoker=new Ky(this.process),this.nextId=0}add(e,i){const n=this.nextId++,a=function({type:c,isSymbolTile:h,zoom:p}){return p=p||0,c==="message"?0:c!=="maybePrepare"||h?c!=="parseTile"||h?c==="parseTile"&&h?300-p:c==="maybePrepare"&&h?400-p:500:200-p:100-p}(i);if(a===0){jr();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:i,priority:a,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){jr();try{if(this.taskQueue=this.taskQueue.filter(n=>!!this.tasks[n]),!this.taskQueue.length)return;const e=this.pick();if(e===null)return;const i=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!i)return;i.fn()}finally{}}pick(){let e=null,i=1/0;for(let a=0;a<this.taskQueue.length;a++){const c=this.tasks[this.taskQueue[a]];c.priority<i&&(i=c.priority,e=a)}if(e===null)return null;const n=this.taskQueue[e];return this.taskQueue.splice(e,1),n}remove(){this.invoker.remove()}}class Qf{constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i<e.length;i++){const n=e[i];this._stringToNumber[n]=i,this._numberToString[i]=n}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const Yy=["tile","layer","source","sourceLayer","state"];class em{constructor(e,i,n,a,c){this.type="Feature",this._vectorTileFeature=e,this._z=i,this._x=n,this._y=a,this.properties=e.properties,this.id=c}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};this.id!==void 0&&(e.id=this.id);for(const i of Yy)this[i]!==void 0&&(e[i]=this[i]);return e}}const Ur=32,Tn=33,Do=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,i=0,n=0,a=0,c=0,h=0,p=0;for(1&e?a=c=h=Ur:i=n=p=Ur;(e>>=1)>1;){const _=i+a>>1,x=n+c>>1;1&e?(a=i,c=n,i=h,n=p):(i=a,n=c,a=h,c=p),h=_,p=x}const m=4*t;Do[m+0]=i,Do[m+1]=n,Do[m+2]=a,Do[m+3]=c}const En=new Uint16Array(2178),Ro=new Uint8Array(1089),Xu=new Uint16Array(1089);function tm(t){return t===0?-.03125:t===32?.03125:0}var im=se([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const rm={type:2,extent:nt,loadGeometry:()=>[[new Re(0,0),new Re(nt+1,0),new Re(nt+1,nt+1),new Re(0,nt+1),new Re(0,0)]]};class Ed{constructor(e,i,n,a,c){this.tileID=e,this.uid=eo(),this.uses=0,this.tileSize=i,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=c,this.expiredRequestCount=0,this.state="loading",a&&a.transform&&(this.projection=a.transform.projection)}registerFadeDuration(e){const i=e+this.timeAdded;i<Vr.now()||this.fadeEndTime&&i<this.fadeEndTime||(this.fadeEndTime=i)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=ks(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,i,n){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(a,c){const h={};if(!c)return h;for(const p of a){const m=p.layerIds.map(_=>c.getLayer(_)).filter(Boolean);if(m.length!==0){p.layers=m,p.stateDependentLayerIds&&(p.stateDependentLayers=p.stateDependentLayerIds.map(_=>m.filter(x=>x.id===_)[0]));for(const _ of m)h[_.id]=p}}return h}(e.buckets,i.style),this.hasSymbolBuckets=!1;for(const a in this.buckets){const c=this.buckets[a];if(c instanceof Lo){if(this.hasSymbolBuckets=!0,!n)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const c=this.buckets[a];if(c instanceof Lo&&c.hasRTLText){this.hasRTLText=!0,y.isLoading()||y.isLoaded()||f()!=="deferred"||g();break}}this.queryPadding=0;for(const a in this.buckets){const c=this.buckets[a];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(a).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new $t}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const n in this.buckets){const a=this.buckets[n];a.uploadPending()&&a.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new yc(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new yc(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new yc(e,this.lineAtlas.image,i.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,i,n,a,c,h,p,m){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:a,pixelPosMatrix:p,transform:h,params:c,tileTransform:this.tileTransform},e,i,n):{}}querySourceFeatures(e,i){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const a=n.loadVTLayers(),c=i?i.sourceLayer:"",h=a._geojsonTileLayer||a[c];if(!h)return;const p=ma(i&&i.filter),{z:m,x:_,y:x}=this.tileID.canonical,b={z:m,x:_,y:x};for(let T=0;T<h.length;T++){const A=h.feature(T);if(p.needGeometry){const B=Cs(A,!0);if(!p.filter(new v(this.tileID.overscaledZ),B,this.tileID.canonical))continue}else if(!p.filter(new v(this.tileID.overscaledZ),A))continue;const M=n.getId(A,c),z=new em(A,m,_,x,M);z.tile=b,e.push(z)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const i=this.expirationTime;if(e.cacheControl){const n=sr(e.cacheControl);n["max-age"]&&(this.expirationTime=Date.now()+1e3*n["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const n=Date.now();let a=!1;if(this.expirationTime>n)a=!1;else if(i)if(this.expirationTime<i)a=!0;else{const c=this.expirationTime-i;c?this.expirationTime=n+Math.max(c,3e4):a=!0}else a=!0;a?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(e,i){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0||!i)return;const n=this.latestFeatureIndex.loadVTLayers(),a=i.style.listImages();for(const c in this.buckets){if(!i.style.hasLayer(c))continue;const h=this.buckets[c],p=h.layers[0].sourceLayer||"_geojsonTileLayer",m=n[p],_=e[p];if(!m||!_||Object.keys(_).length===0)continue;if(h.update(_,m,a,this.imageAtlas&&this.imageAtlas.patternPositions||{}),h instanceof Lu||h instanceof Iu){const b=i.style._getSourceCache(h.layers[0].source);i._terrain&&i._terrain.enabled&&b&&h.programConfigurations.needsUpload&&i._terrain._clearRenderCacheForTile(b.id,this.tileID)}const x=i&&i.style&&i.style.getLayer(c);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(h)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Vr.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=Vr.now()+e}setTexture(e,i){const n=i.context,a=n.gl;this.texture=this.texture||i.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new yc(n,e,a.RGBA,{useMipmap:!0}),this.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE))}setDependencies(e,i){const n={};for(const a of i)n[a]=!0;this.dependencies[e]=n}hasDependency(e,i){for(const n of e){const a=this.dependencies[n];if(a){for(const c of i)if(a[c])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,i){if(!i||i.name==="mercator"||this._tileDebugBuffer)return;const n=Xn(rm,this.tileID.canonical,this.tileTransform)[0],a=new ke,c=new _r;for(let h=0;h<n.length;h++){const{x:p,y:m}=n[h];a.emplaceBack(p,m),c.emplaceBack(h)}c.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(c),this._tileDebugBuffer=e.createVertexBuffer(a,Kl.members),this._tileDebugSegments=Ti.simpleSegment(0,0,a.length,c.length)}_makeTileBoundsBuffers(e,i){if(this._tileBoundsBuffer||!i||i.name==="mercator")return;const n=Xn(rm,this.tileID.canonical,this.tileTransform)[0];let a,c;if(this.isRaster){const h=function(p,m){const _=ks(p,m),x=Math.pow(2,p.z);for(let B=0;B<Tn;B++)for(let V=0;V<Tn;V++){const K=Mr((p.x+(V+tm(V))/Ur)/x),G=Zi((p.y+(B+tm(B))/Ur)/x),X=m.project(K,G),Y=B*Tn+V;En[2*Y+0]=Math.round((X.x*_.scale-_.x)*nt),En[2*Y+1]=Math.round((X.y*_.scale-_.y)*nt)}Ro.fill(0),Xu.fill(0);for(let B=2045;B>=0;B--){const V=4*B,K=Do[V+0],G=Do[V+1],X=Do[V+2],Y=Do[V+3],J=K+X>>1,me=G+Y>>1,de=J+me-G,Te=me+K-J,Le=G*Tn+K,ye=Y*Tn+X,Ae=me*Tn+J,Me=Math.hypot((En[2*Le+0]+En[2*ye+0])/2-En[2*Ae+0],(En[2*Le+1]+En[2*ye+1])/2-En[2*Ae+1])>=16;Ro[Ae]=Ro[Ae]||(Me?1:0),B<1022&&(Ro[Ae]=Ro[Ae]||Ro[(G+Te>>1)*Tn+(K+de>>1)]||Ro[(Y+Te>>1)*Tn+(X+de>>1)])}const b=new Se,T=new tt;let A=0;function M(B,V){const K=V*Tn+B;return Xu[K]===0&&(b.emplaceBack(En[2*K+0],En[2*K+1],B*nt/Ur,V*nt/Ur),Xu[K]=++A),Xu[K]-1}function z(B,V,K,G,X,Y){const J=B+K>>1,me=V+G>>1;if(Math.abs(B-X)+Math.abs(V-Y)>1&&Ro[me*Tn+J])z(X,Y,B,V,J,me),z(K,G,X,Y,J,me);else{const de=M(B,V),Te=M(K,G),Le=M(X,Y);T.emplaceBack(de,Te,Le)}}return z(0,0,Ur,Ur,Ur,0),z(Ur,Ur,0,0,0,Ur),{vertices:b,indices:T}}(this.tileID.canonical,i);a=h.vertices,c=h.indices}else{a=new Se,c=new tt;for(const{x:p,y:m}of n)a.emplaceBack(p,m,0,0);const h=nd(a.int16,void 0,4);for(let p=0;p<h.length;p+=3)c.emplaceBack(h[p],h[p+1],h[p+2])}this._tileBoundsBuffer=e.createVertexBuffer(a,im.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(c),this._tileBoundsSegments=Ti.simpleSegment(0,0,a.length,c.length)}_makeGlobeTileDebugBuffers(e,i){const n=i.projection;if(!n||n.name!=="globe"||i.freezeTileCoverage)return;const a=this.tileID.canonical,c=Ql(Tp(a,i)),h=Sa(i.zoom);let p;h>0&&(p=kh(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,a,i,c,p,h),this._makeGlobeTileDebugTextBuffer(e,a,i,c,p,h)}_globePoint(e,i,n,a,c,h,p){let m=Yl(e,i,n);if(h){const _=1<<n.z,x=bn(a.center.lng),b=wn(a.center.lat),T=(n.x+.5)/_-x;let A=0;T>.5?A=-1:T<-.5&&(A=1);let M=(e/nt+n.x)/_+A,z=(i/nt+n.y)/_;M=(M-x)*a._pixelsPerMercatorPixel+x,z=(z-b)*a._pixelsPerMercatorPixel+b;const B=[M*a.worldSize,z*a.worldSize,0];yi(B,B,h),m=Is(m,B,p)}return yi(m,m,c)}_makeGlobeTileDebugBorderBuffer(e,i,n,a,c,h){const p=new ke,m=new _r,_=new he,x=(T,A,M,z,B)=>{const V=(M-T)/(B-1),K=(z-A)/(B-1),G=p.length;for(let X=0;X<B;X++){const Y=T+X*V,J=A+X*K;p.emplaceBack(Y,J);const me=this._globePoint(Y,J,i,n,a,c,h);_.emplaceBack(me[0],me[1],me[2]),m.emplaceBack(G+X)}},b=nt;x(0,0,b,0,16),x(b,0,b,b,16),x(b,b,0,b,16),x(0,b,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(m),this._tileDebugBuffer=e.createVertexBuffer(p,Kl.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(_,vp.members),this._tileDebugSegments=Ti.simpleSegment(0,0,p.length,m.length)}_makeGlobeTileDebugTextBuffer(e,i,n,a,c,h){const p=nt/4,m=new ke,_=new tt,x=new he,b=25;_.reserve(32),m.reserve(b),x.reserve(b);const T=(A,M)=>b*A+M;for(let A=0;A<b;A++){const M=A*p;for(let z=0;z<b;z++){const B=z*p;m.emplaceBack(B,M);const V=this._globePoint(B,M,i,n,a,c,h);x.emplaceBack(V[0],V[1],V[2])}}for(let A=0;A<4;A++)for(let M=0;M<4;M++){const z=T(A,M),B=T(A,M+1),V=T(A+1,M),K=T(A+1,M+1);_.emplaceBack(z,B,V),_.emplaceBack(V,B,K)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(_),this._tileDebugTextBuffer=e.createVertexBuffer(m,Kl.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(x,vp.members),this._tileDebugTextSegments=Ti.simpleSegment(0,0,b,32)}}class Qy{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,i,n){const a=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][a]=this.stateChanges[e][a]||{},xi(this.stateChanges[e][a],n),this.deletedStates[e]===null){this.deletedStates[e]={};for(const c in this.state[e])c!==a&&(this.deletedStates[e][c]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][a]===null){this.deletedStates[e][a]={};for(const c in this.state[e][a])n[c]||(this.deletedStates[e][a][c]=null)}else for(const c in n)this.deletedStates[e]&&this.deletedStates[e][a]&&this.deletedStates[e][a][c]===null&&delete this.deletedStates[e][a][c]}removeFeatureState(e,i,n){if(this.deletedStates[e]===null)return;const a=String(i);if(this.deletedStates[e]=this.deletedStates[e]||{},n&&i!==void 0)this.deletedStates[e][a]!==null&&(this.deletedStates[e][a]=this.deletedStates[e][a]||{},this.deletedStates[e][a][n]=null);else if(i!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][a])for(n in this.deletedStates[e][a]={},this.stateChanges[e][a])this.deletedStates[e][a][n]=null;else this.deletedStates[e][a]=null;else this.deletedStates[e]=null}getState(e,i){const n=String(i),a=xi({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const c=this.deletedStates[e][i];if(c===null)return{};for(const h in c)delete a[h]}return a}initializeTileState(e,i){e.setFeatureState(this.state,i)}coalesceChanges(e,i){const n={};for(const a in this.stateChanges){this.state[a]=this.state[a]||{};const c={};for(const h in this.stateChanges[a])this.state[a][h]||(this.state[a][h]={}),xi(this.state[a][h],this.stateChanges[a][h]),c[h]=this.state[a][h];n[a]=c}for(const a in this.deletedStates){this.state[a]=this.state[a]||{};const c={};if(this.deletedStates[a]===null)for(const h in this.state[a])c[h]={},this.state[a][h]={};else for(const h in this.deletedStates[a]){if(this.deletedStates[a][h]===null)this.state[a][h]={};else if(this.state[a][h])for(const p of Object.keys(this.deletedStates[a][h]))delete this.state[a][h][p];c[h]=this.state[a][h]}n[a]=n[a]||{},xi(n[a],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(n).length!==0)for(const a in e)e[a].setFeatureState(n,i)}}class nm{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,i){const n=this.toIdx(e,i);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,i){return this.leaves[this.toIdx(e,i)]}toIdx(e,i){return i*this.size+e}}function om(t,e,i,n){let a=0,c=Number.MAX_VALUE;for(let h=0;h<3;h++)if(Math.abs(n[h])<1e-15){if(i[h]<t[h]||i[h]>e[h])return null}else{const p=1/n[h];let m=(t[h]-i[h])*p,_=(e[h]-i[h])*p;if(m>_){const x=m;m=_,_=x}if(m>a&&(a=m),_<c&&(c=_),a>c)return null}return a}function sm(t,e,i,n,a,c,h,p,m,_,x){const b=n-t,T=a-e,A=c-i,M=h-t,z=p-e,B=m-i,V=x[1]*B-x[2]*z,K=x[2]*M-x[0]*B,G=x[0]*z-x[1]*M,X=b*V+T*K+A*G;if(Math.abs(X)<1e-15)return null;const Y=1/X,J=_[0]-t,me=_[1]-e,de=_[2]-i,Te=(J*V+me*K+de*G)*Y;if(Te<0||Te>1)return null;const Le=me*A-de*T,ye=de*b-J*A,Ae=J*T-me*b,Me=(x[0]*Le+x[1]*ye+x[2]*Ae)*Y;return Me<0||Te+Me>1?null:(M*Le+z*ye+B*Ae)*Y}function am(t,e,i){return(t-e)/(i-e)}function lm(t,e,i,n,a,c,h,p,m){const _=1<<i,x=c-n,b=h-a,T=(t+1)/_*x+n,A=(e+0)/_*b+a,M=(e+1)/_*b+a;p[0]=(t+0)/_*x+n,p[1]=A,m[0]=T,m[1]=M}class cm{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const i=function(c){const h=Math.ceil(Math.log2(c.dim/8)),p=[];let m=Math.ceil(Math.pow(2,h));const _=1/m,x=(A,M,z,B,V)=>{const K=B?1:0,G=(A+1)*z-K,X=M*z,Y=(M+1)*z-K;V[0]=A*z,V[1]=X,V[2]=G,V[3]=Y};let b=new nm(m);const T=[];for(let A=0;A<m*m;A++){x(A%m,Math.floor(A/m),_,!1,T);const M=Bo(T[0],T[1],c),z=Bo(T[2],T[1],c),B=Bo(T[2],T[3],c),V=Bo(T[0],T[3],c);b.minimums.push(Math.min(M,z,B,V)),b.maximums.push(Math.max(M,z,B,V)),b.leaves.push(1)}for(p.push(b),m/=2;m>=1;m/=2){const A=p[p.length-1];b=new nm(m);for(let M=0;M<m*m;M++){x(M%m,Math.floor(M/m),2,!0,T);const z=A.getElevation(T[0],T[1]),B=A.getElevation(T[2],T[1]),V=A.getElevation(T[2],T[3]),K=A.getElevation(T[0],T[3]),G=A.isLeaf(T[0],T[1]),X=A.isLeaf(T[2],T[1]),Y=A.isLeaf(T[2],T[3]),J=A.isLeaf(T[0],T[3]),me=Math.min(z.min,B.min,V.min,K.min),de=Math.max(z.max,B.max,V.max,K.max),Te=G&&X&&Y&&J;b.maximums.push(de),b.minimums.push(me),b.leaves.push(de-me<=5&&Te?1:0)}p.push(b)}return p}(this.dem),n=i.length-1,a=i[n];this._addNode(a.minimums[0],a.maximums[0],a.leaves[0]),this._construct(i,0,0,n,0)}raycastRoot(e,i,n,a,c,h,p=1){return om([e,i,-100],[n,a,this.maximums[0]*p],c,h)}raycast(e,i,n,a,c,h,p=1){if(!this.nodeCount)return null;const m=this.raycastRoot(e,i,n,a,c,h,p);if(m==null)return null;const _=[],x=[],b=[],T=[],A=[{idx:0,t:m,nodex:0,nodey:0,depth:0}];for(;A.length>0;){const{idx:M,t:z,nodex:B,nodey:V,depth:K}=A.pop();if(this.leaves[M]){lm(B,V,K,e,i,n,a,b,T);const X=1<<K,Y=(B+0)/X,J=(B+1)/X,me=(V+0)/X,de=(V+1)/X,Te=Bo(Y,me,this.dem)*p,Le=Bo(J,me,this.dem)*p,ye=Bo(J,de,this.dem)*p,Ae=Bo(Y,de,this.dem)*p,Me=sm(b[0],b[1],Te,T[0],b[1],Le,T[0],T[1],ye,c,h),Ce=sm(T[0],T[1],ye,b[0],T[1],Ae,b[0],b[1],Te,c,h),Fe=Math.min(Me!==null?Me:Number.MAX_VALUE,Ce!==null?Ce:Number.MAX_VALUE);if(Fe!==Number.MAX_VALUE)return Fe;{const ve=Xl([],c,h,z);if(um(Te,Le,Ae,ye,am(ve[0],b[0],T[0]),am(ve[1],b[1],T[1]))>=ve[2])return z}continue}let G=0;for(let X=0;X<this._siblingOffset.length;X++){lm((B<<1)+this._siblingOffset[X][0],(V<<1)+this._siblingOffset[X][1],K+1,e,i,n,a,b,T),b[2]=-100,T[2]=this.maximums[this.childOffsets[M]+X]*p;const Y=om(b,T,c,h);if(Y!=null){const J=Y;_[X]=J;let me=!1;for(let de=0;de<G&&!me;de++)J>=_[x[de]]&&(x.splice(de,0,X),me=!0);me||(x[G]=X),G++}}for(let X=0;X<G;X++){const Y=x[X];A.push({idx:this.childOffsets[M]+Y,t:_[Y],nodex:(B<<1)+this._siblingOffset[Y][0],nodey:(V<<1)+this._siblingOffset[Y][1],depth:K+1})}}return null}_addNode(e,i,n){return this.minimums.push(e),this.maximums.push(i),this.leaves.push(n),this.childOffsets.push(0),this.nodeCount++}_construct(e,i,n,a,c){if(e[a].isLeaf(i,n)===1)return;this.childOffsets[c]||(this.childOffsets[c]=this.nodeCount);const h=a-1,p=e[h];let m=0,_=0;for(let x=0;x<this._siblingOffset.length;x++){const b=2*i+this._siblingOffset[x][0],T=2*n+this._siblingOffset[x][1],A=p.getElevation(b,T),M=p.isLeaf(b,T),z=this._addNode(A.min,A.max,M);M&&(m|=1<<x),_||(_=z)}for(let x=0;x<this._siblingOffset.length;x++)m&1<<x||this._construct(e,2*i+this._siblingOffset[x][0],2*n+this._siblingOffset[x][1],h,_+x)}}function um(t,e,i,n,a,c){return Pt(Pt(t,i,c),Pt(e,n,c),a)}function Bo(t,e,i){const n=i.dim,a=Tt(t*n-.5,0,n-1),c=Tt(e*n-.5,0,n-1),h=Math.floor(a),p=Math.floor(c),m=Math.min(h+1,n-1),_=Math.min(p+1,n-1);return um(i.get(h,p),i.get(m,p),i.get(h,_),i.get(m,_),a-h,c-p)}const hm={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function ex(t,e,i){return(256*t*256+256*e+i)/10-1e4}function tx(t,e,i){return 256*t+e+i/256-32768}class Hu{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,i,n,a=!1,c=!1){if(this.uid=e,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(n&&n!=="mapbox"&&n!=="terrarium")return li(`"${n}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=i.height;const h=this.dim=i.height-2,p=new Uint32Array(i.data.buffer);if(this.pixels=new Uint8Array(i.data.buffer),this.encoding=n||"mapbox",this.borderReady=a,!a){for(let m=0;m<h;m++)p[this._idx(-1,m)]=p[this._idx(0,m)],p[this._idx(h,m)]=p[this._idx(h-1,m)],p[this._idx(m,-1)]=p[this._idx(m,0)],p[this._idx(m,h)]=p[this._idx(m,h-1)];p[this._idx(-1,-1)]=p[this._idx(0,0)],p[this._idx(h,-1)]=p[this._idx(h-1,0)],p[this._idx(-1,h)]=p[this._idx(0,h-1)],p[this._idx(h,h)]=p[this._idx(h-1,h-1)],c&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new cm(this)}get(e,i,n=!1){n&&(e=Tt(e,-1,this.dim),i=Tt(i,-1,this.dim));const a=4*this._idx(e,i);return(this.encoding==="terrarium"?tx:ex)(this.pixels[a],this.pixels[a+1],this.pixels[a+2])}static getUnpackVector(e){return hm[e]}get unpackVector(){return hm[this.encoding]}_idx(e,i){if(e<-1||e>=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+(e+1)}static pack(e,i){const n=[0,0,0,0],a=Hu.getUnpackVector(i);let c=Math.floor((e+a[3])/a[2]);return n[2]=c%256,c=Math.floor(c/256),n[1]=c%256,c=Math.floor(c/256),n[0]=c,n}getPixels(){return new yr({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let a=i*this.dim,c=i*this.dim+this.dim,h=n*this.dim,p=n*this.dim+this.dim;switch(i){case-1:a=c-1;break;case 1:c=a+1}switch(n){case-1:h=p-1;break;case 1:p=h+1}const m=-i*this.dim,_=-n*this.dim;for(let x=h;x<p;x++)for(let b=a;b<c;b++){const T=4*this._idx(b,x),A=4*this._idx(b+m,x+_);this.pixels[T+0]=e.pixels[A+0],this.pixels[T+1]=e.pixels[A+1],this.pixels[T+2]=e.pixels[A+2],this.pixels[T+3]=e.pixels[A+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Xe(Hu,"DEMData"),Xe(cm,"DemMinMaxQuadTree",{omit:["dem"]});class ix{constructor(e,i){this.max=e,this.onRemove=i,this.reset()}reset(){for(const e in this.data)for(const i of this.data[e])i.timeout&&clearTimeout(i.timeout),this.onRemove(i.value);return this.data={},this.order=[],this}add(e,i,n){const a=e.wrapped().key;this.data[a]===void 0&&(this.data[a]=[]);const c={value:i,timeout:void 0};if(n!==void 0&&(c.timeout=setTimeout(()=>{this.remove(e,c)},n)),this.data[a].push(c),this.order.push(a),this.order.length>this.max){const h=this._getAndRemoveByKey(this.order[0]);h&&this.onRemove(h)}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 i=this.data[e].shift();return i.timeout&&clearTimeout(i.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),i.value}getByKey(e){const i=this.data[e];return i?i[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,i){if(!this.has(e))return this;const n=e.wrapped().key,a=i===void 0?0:this.data[n].indexOf(i),c=this.data[n][a];return this.data[n].splice(a,1),c.timeout&&clearTimeout(c.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(c.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const i=this._getAndRemoveByKey(this.order[0]);i&&this.onRemove(i)}return this}filter(e){const i=[];for(const n in this.data)for(const a of this.data[n])e(a.value)||i.push(a);for(const n of i)this.remove(n.value.tileID,n)}}class Na{constructor(e,i,n){this.func=e,this.mask=i,this.range=n}}Na.ReadOnly=!1,Na.ReadWrite=!0,Na.disabled=new Na(519,Na.ReadOnly,[0,1]);const Sd=7680;class Ad{constructor(e,i,n,a,c,h){this.test=e,this.ref=i,this.mask=n,this.fail=a,this.depthFail=c,this.pass=h}}Ad.disabled=new Ad({func:519,mask:0},0,0,Sd,Sd,Sd);class Sn{constructor(e,i,n){this.blendFunction=e,this.blendColor=i,this.mask=n}}Sn.Replace=[1,0],Sn.disabled=new Sn(Sn.Replace,gi.transparent,[!1,!1,!1,!1]),Sn.unblended=new Sn(Sn.Replace,gi.transparent,[!0,!0,!0,!0]),Sn.alphaBlended=new Sn([1,771],gi.transparent,[!0,!0,!0,!0]);const Md=1029,Id=2305;class an{constructor(e,i,n){this.enable=e,this.mode=i,this.frontFace=n}}an.disabled=new an(!1,Md,Id),an.backCCW=new an(!0,Md,Id),an.backCW=new an(!0,Md,2304),an.frontCW=new an(!0,1028,2304),an.frontCCW=new an(!0,1028,Id);class Ls extends Ko{constructor(e,i,n){super(),this.id=e,this._onlySymbols=n,i.on("data",a=>{a.dataType==="source"&&a.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&a.dataType==="source"&&a.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),i.on("error",()=>{this._sourceErrored=!0}),this._source=i,this._tiles={},this._cache=new ix(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=i.minTileCacheSize,this._maxTileCacheSize=i.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Qy,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(e){this.map=e,this._minTileCacheSize=this._minTileCacheSize===void 0&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const e in this._tiles){const i=this._tiles[e];if(i.state!=="loaded"&&i.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)}_loadTile(e,i){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,i)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}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 i in this._tiles){const n=this._tiles[i];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return un(this._tiles).map(e=>e.tileID).sort(dm).map(e=>e.key)}getRenderableIds(e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,e)&&i.push(this._tiles[n]);return e?i.sort((n,a)=>{const c=n.tileID,h=a.tileID,p=new Re(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),m=new Re(h.canonical.x,h.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-h.overscaledZ||m.y-p.y||m.x-p.x}).map(n=>n.tileID.key):i.map(n=>n.tileID).sort(dm).map(n=>n.key)}hasRenderableParent(e){const i=this.findLoadedParent(e,0);return!!i&&this._isIdRenderable(i.tileID.key)}_isIdRenderable(e,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(i||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(+e,"reloading")}}_reloadTile(e,i){const n=this._tiles[e];n&&(n.state!=="loading"&&(n.state=i),this._loadTile(n,this._tileLoaded.bind(this,n,e,i)))}_tileLoaded(e,i,n,a){if(a)if(e.state="errored",a.status!==404)this._source.fire(new Gr(a,{tile:e}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const c=this.map.painter.terrain;this.update(this.transform,c.getScaledDemTileSize(),!0),c.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=Vr.now(),n==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),this._source.type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Dn("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const i=this.getRenderableIds();for(let a=0;a<i.length;a++){const c=i[a];if(e.neighboringTiles&&e.neighboringTiles[c]){const h=this.getTileByID(c);n(e,h),n(h,e)}}function n(a,c){if(!a.dem||a.dem.borderReady)return;a.needsHillshadePrepare=!0,a.needsDEMTextureUpload=!0;let h=c.tileID.canonical.x-a.tileID.canonical.x;const p=c.tileID.canonical.y-a.tileID.canonical.y,m=Math.pow(2,a.tileID.canonical.z),_=c.tileID.key;h===0&&p===0||Math.abs(p)>1||(Math.abs(h)>1&&(Math.abs(h+m)===1?h+=m:Math.abs(h-m)===1&&(h-=m)),c.dem&&a.dem&&(a.dem.backfillBorder(c.dem,h,p),a.neighboringTiles&&a.neighboringTiles[_]&&(a.neighboringTiles[_].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,i,n,a){for(const c in this._tiles){let h=this._tiles[c];if(a[c]||!h.hasData()||h.tileID.overscaledZ<=i||h.tileID.overscaledZ>n)continue;let p=h.tileID;for(;h&&h.tileID.overscaledZ>i+1;){const _=h.tileID.scaledTo(h.tileID.overscaledZ-1);h=this._tiles[_.key],h&&h.hasData()&&(p=_)}let m=p;for(;m.overscaledZ>i;)if(m=m.scaledTo(m.overscaledZ-1),e[m.key]){a[p.key]=p;break}}}findLoadedParent(e,i){if(e.key in this._loadedParentTiles){const n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=i?n:null}for(let n=e.overscaledZ-1;n>=i;n--){const a=e.scaledTo(n),c=this._getLoadedTile(a);if(c)return c}}_getLoadedTile(e){const i=this._tiles[e.key];return i&&i.hasData()?i:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,i){i=i||this._source.tileSize;const n=Math.ceil(e.width/i)+1,a=Math.ceil(e.height/i)+1,c=Math.floor(n*a*5),h=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,c):c,p=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,h):h;this._cache.setMaxSize(p)}handleWrapJump(e){const i=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,i){const n={};for(const a in this._tiles){const c=this._tiles[a];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+i),n[c.tileID.key]=c}this._tiles=n;for(const a in this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const a in this._tiles)this._setTileReloadTimer(+a,this._tiles[a])}}update(e,i,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;let a;this.updateCacheSize(e,i),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(p=>new tr(p.canonical.z,p.wrap,p.canonical.z,p.canonical.x,p.canonical.y)):(a=e.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(a=a.filter(p=>this._source.hasTile(p)))):a=[];const c=this._updateRetainedTiles(a);if(pm(this._source.type)&&a.length!==0){const p={},m={},_=Object.keys(c);for(const b of _){const T=c[b],A=this._tiles[b];if(!A||A.fadeEndTime&&A.fadeEndTime<=Vr.now())continue;const M=this.findLoadedParent(T,Math.max(T.overscaledZ-Ls.maxOverzooming,this._source.minzoom));M&&(this._addTile(M.tileID),p[M.tileID.key]=M.tileID),m[b]=T}const x=a[a.length-1].overscaledZ;for(const b in this._tiles){const T=this._tiles[b];if(c[b]||!T.hasData())continue;let A=T.tileID;for(;A.overscaledZ>x;){A=A.scaledTo(A.overscaledZ-1);const M=this._tiles[A.key];if(M&&M.hasData()&&m[A.key]){c[b]=T.tileID;break}}}for(const b in p)c[b]||(this._coveredTiles[b]=!0,c[b]=p[b])}for(const p in c)this._tiles[p].clearFadeHold();const h=function(p,m){const _=[];for(const x in p)x in m||_.push(x);return _}(this._tiles,c);for(const p of h){const m=this._tiles[p];m.hasSymbolBuckets&&!m.holdingForFade()?m.setHoldDuration(this.map._fadeDuration):m.hasSymbolBuckets&&!m.symbolFadeFinished()||this._removeTile(+p)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const i={};if(e.length===0)return i;const n={},a=e.reduce((_,x)=>Math.min(_,x.overscaledZ),1/0),c=e[0].overscaledZ,h=Math.max(c-Ls.maxOverzooming,this._source.minzoom),p=Math.max(c+Ls.maxUnderzooming,this._source.minzoom),m={};for(const _ of e){const x=this._addTile(_);i[_.key]=_,x.hasData()||a<this._source.maxzoom&&(m[_.key]=_)}this._retainLoadedChildren(m,a,p,i);for(const _ of e){let x=this._tiles[_.key];if(x.hasData())continue;if(_.canonical.z>=this._source.maxzoom){const T=_.children(this._source.maxzoom)[0],A=this.getTile(T);if(A&&A.hasData()){i[T.key]=T;continue}}else{const T=_.children(this._source.maxzoom);if(i[T[0].key]&&i[T[1].key]&&i[T[2].key]&&i[T[3].key])continue}let b=x.wasRequested();for(let T=_.overscaledZ-1;T>=h;--T){const A=_.scaledTo(T);if(n[A.key]||(n[A.key]=!0,x=this.getTile(A),!x&&b&&(x=this._addTile(A)),x&&(i[A.key]=A,b=x.wasRequested(),x.hasData())))break}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const i=[];let n,a=this._tiles[e].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){n=this._loadedParentTiles[a.key];break}i.push(a.key);const c=a.scaledTo(a.overscaledZ-1);if(n=this._getLoadedTile(c),n)break;a=c}for(const c of i)this._loadedParentTiles[c]=n}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const n=!!i;if(!n){const a=this.map?this.map.painter:null;i=new Ed(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,a,this._isRaster),this._loadTile(i,this._tileLoaded.bind(this,i,e.key,i.state))}return i?(i.uses++,this._tiles[e.key]=i,n||this._source.fire(new Dn("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i):null}_setTileReloadTimer(e,i){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const n=i.getExpiryTimeout();n&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},n))}_removeTile(e){const i=this._tiles[e];i&&(i.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),i.uses>0||(i.hasData()&&i.state!=="reloading"?this._cache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,i,n){const a=[],c=this.transform;if(!c)return a;const h=c.projection.name==="globe",p=bn(c.center.lng);for(const m in this._tiles){const _=this._tiles[m];if(n&&_.clearQueryDebugViz(),_.holdingForFade())continue;let x;if(h){const b=_.tileID.canonical;if(b.z===0){const T=[Math.abs(Tt(p,...xc(b,-1))-p),Math.abs(Tt(p,...xc(b,1))-p)];x=[0,2*T.indexOf(Math.min(...T))-1]}else{const T=[Math.abs(Tt(p,...xc(b,-1))-p),Math.abs(Tt(p,...xc(b,0))-p),Math.abs(Tt(p,...xc(b,1))-p)];x=[T.indexOf(Math.min(...T))-1]}}else x=[0];for(const b of x){const T=e.containsTile(_,c,i,b);T&&a.push(T)}}return a}getVisibleCoordinates(e){const i=this.getRenderableIds(e).map(n=>this._tiles[n].tileID);for(const n of i)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return i}hasTransition(){if(this._source.hasTransition())return!0;if(pm(this._source.type))for(const e in this._tiles){const i=this._tiles[e];if(i.fadeEndTime!==void 0&&i.fadeEndTime>=Vr.now())return!0}return!1}setFeatureState(e,i,n){this._state.updateState(e=e||"_geojsonTileLayer",i,n)}removeFeatureState(e,i,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",i,n)}getFeatureState(e,i){return this._state.getState(e=e||"_geojsonTileLayer",i)}setDependencies(e,i,n){const a=this._tiles[e];a&&a.setDependencies(i,n)}reloadTilesForDependencies(e,i){for(const n in this._tiles)this._tiles[n].hasDependency(e,i)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(e,i))}_preloadTiles(e,i){if(!this._sourceLoaded){const p=()=>{this._sourceLoaded&&(this._source.off("data",p),this._preloadTiles(e,i))};return void this._source.on("data",p)}const n=new Map,a=Array.isArray(e)?e:[e],c=this.map.painter.terrain,h=this.usedForTerrain&&c?c.getScaledDemTileSize():this._source.tileSize;for(const p of a){const m=p.coveringTiles({tileSize:h,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const _ of m)n.set(_.key,_);this.usedForTerrain&&p.updateElevation(!1)}Li(Array.from(n.values()),(p,m)=>{const _=new Ed(p,this._source.tileSize*p.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(_,x=>{this._source.type==="raster-dem"&&_.dem&&this._backfillDEM(_),m(x,_)})},i)}}function dm(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function pm(t){return t==="raster"||t==="image"||t==="video"||t==="custom"}function xc(t,e){const i=1<<t.z;return[t.x/i+e,(t.x+1)/i+e]}Ls.maxOverzooming=10,Ls.maxUnderzooming=3;class Ku{constructor(e,i,n){this._demTile=e,this._dem=this._demTile.dem,this._scale=i,this._offset=n}static create(e,i,n){const a=n||e.findDEMTileFor(i);if(!a||!a.dem)return;const c=a.dem,h=a.tileID,p=1<<i.canonical.z-h.canonical.z;return new Ku(a,a.tileSize/nt/p,[(i.canonical.x/p-h.canonical.x)*c.dim,(i.canonical.y/p-h.canonical.y)*c.dim])}tileCoordToPixel(e,i){const n=i*this._scale+this._offset[1],a=Math.floor(e*this._scale+this._offset[0]),c=Math.floor(n);return new Re(a,c)}getElevationAt(e,i,n,a){const c=e*this._scale+this._offset[0],h=i*this._scale+this._offset[1],p=Math.floor(c),m=Math.floor(h),_=this._dem;return a=!!a,n?Pt(Pt(_.get(p,m,a),_.get(p,m+1,a),h-m),Pt(_.get(p+1,m,a),_.get(p+1,m+1,a),h-m),c-p):_.get(p,m,a)}getElevationAtPixel(e,i,n){return this._dem.get(e,i,!!n)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*nn(1,e)*this._dem.stride}}class fm{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new jn(nt,16,0),this.featureIndexArray=new bs,this.promoteId=i}insert(e,i,n,a,c,h=0){const p=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,a,c,h);const m=this.grid;for(let _=0;_<i.length;_++){const x=i[_],b=[1/0,1/0,-1/0,-1/0];for(let T=0;T<x.length;T++){const A=x[T];b[0]=Math.min(b[0],A.x),b[1]=Math.min(b[1],A.y),b[2]=Math.max(b[2],A.x),b[3]=Math.max(b[3],A.y)}b[0]<nt&&b[1]<nt&&b[2]>=0&&b[3]>=0&&m.insert(p,b[0],b[1],b[2],b[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new ld(new Bu(this.rawTileData)).layers,this.sourceLayerCoder=new Qf(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,i,n,a){this.loadVTLayers();const c=e.params||{},h=ma(c.filter),p=e.tileResult,m=e.transform,_=p.bufferedTilespaceBounds,x=this.grid.query(_.min.x,_.min.y,_.max.x,_.max.y,(M,z,B,V)=>Fp(p.bufferedTilespaceGeometry,M,z,B,V));x.sort(rx);let b=null;m.elevation&&x.length>0&&(b=Ku.create(m.elevation,this.tileID));const T={};let A;for(let M=0;M<x.length;M++){const z=x[M];if(z===A)continue;A=z;const B=this.featureIndexArray.get(z);let V=null;this.loadMatchingFeature(T,B,h,c.layers,c.availableImages,i,n,a,(K,G,X,Y=0)=>(V||(V=Xn(K,this.tileID.canonical,e.tileTransform)),G.queryIntersectsFeature(p,K,X,V,this.z,e.transform,e.pixelPosMatrix,b,Y)))}return T}loadMatchingFeature(e,i,n,a,c,h,p,m,_){const{featureIndex:x,bucketIndex:b,sourceLayerIndex:T,layoutVertexArrayOffset:A}=i,M=this.bucketLayerIDs[b];if(a&&!function(K,G){for(let X=0;X<K.length;X++)if(G.indexOf(K[X])>=0)return!0;return!1}(a,M))return;const z=this.sourceLayerCoder.decode(T),B=this.vtLayers[z].feature(x);if(n.needGeometry){const K=Cs(B,!0);if(!n.filter(new v(this.tileID.overscaledZ),K,this.tileID.canonical))return}else if(!n.filter(new v(this.tileID.overscaledZ),B))return;const V=this.getId(B,z);for(let K=0;K<M.length;K++){const G=M[K];if(a&&a.indexOf(G)<0)continue;const X=h[G];if(!X)continue;let Y={};V!==void 0&&m&&(Y=m.getState(X.sourceLayer||"_geojsonTileLayer",V));const J=xi({},p[G]);J.paint=mm(J.paint,X.paint,B,Y,c),J.layout=mm(J.layout,X.layout,B,Y,c);const me=!_||_(B,X,Y,A);if(!me)continue;const de=new em(B,this.z,this.x,this.y,V);de.layer=J;let Te=e[G];Te===void 0&&(Te=e[G]=[]),Te.push({featureIndex:x,feature:de,intersectionZ:me})}}lookupSymbolFeatures(e,i,n,a,c,h,p,m){const _={};this.loadVTLayers();const x=ma(c);for(const b of e)this.loadMatchingFeature(_,{bucketIndex:n,sourceLayerIndex:a,featureIndex:b,layoutVertexArrayOffset:0},x,h,p,m,i);return _}loadFeature(e){const{featureIndex:i,sourceLayerIndex:n}=e;this.loadVTLayers();const a=this.sourceLayerCoder.decode(n),c=this.vtFeatures[a];if(c[i])return c[i];const h=this.vtLayers[a].feature(i);return c[i]=h,h}hasLayer(e){for(const i of this.bucketLayerIDs)for(const n of i)if(e===n)return!0;return!1}getId(e,i){let n=e.id;if(this.promoteId){const a=typeof this.promoteId=="string"?this.promoteId:this.promoteId[i];a!=null&&(n=e.properties[a]),typeof n=="boolean"&&(n=Number(n))}return n}}function mm(t,e,i,n,a){return Mt(t,(c,h)=>{const p=e instanceof j?e.get(h):null;return p&&p.evaluate?p.evaluate(i,n,a):p})}function rx(t,e){return e-t}Xe(fm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class _m{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.image=new Hn({width:e,height:i}),this.positions={},this.uploaded=!1}getDash(e,i){const n=this.getKey(e,i);return this.positions[n]}trim(){const e=this.width,i=this.height=Nr(this.nextRow);this.image.resize({width:e,height:i})}getKey(e,i){return e.join(",")+i}getDashRanges(e,i,n){const a=[];let c=e.length%2==1?-e[e.length-1]*n:0,h=e[0]*n,p=!0;a.push({left:c,right:h,isDash:p,zeroLength:e[0]===0});let m=e[0];for(let _=1;_<e.length;_++){p=!p;const x=e[_];c=m*n,m+=x,h=m*n,a.push({left:c,right:h,isDash:p,zeroLength:x===0})}return a}addRoundDash(e,i,n){const a=i/2;for(let c=-n;c<=n;c++){const h=this.width*(this.nextRow+n+c);let p=0,m=e[p];for(let _=0;_<this.width;_++){_/m.right>1&&(m=e[++p]);const x=Math.abs(_-m.left),b=Math.abs(_-m.right),T=Math.min(x,b);let A;const M=c/n*(a+1);if(m.isDash){const z=a-Math.abs(M);A=Math.sqrt(T*T+z*z)}else A=a-Math.sqrt(T*T+M*M);this.image.data[h+_]=Math.max(0,Math.min(255,A+128))}}}addRegularDash(e,i){for(let m=e.length-1;m>=0;--m){const _=e[m],x=e[m+1];_.zeroLength?e.splice(m,1):x&&x.isDash===_.isDash&&(x.left=_.left,e.splice(m,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 c=this.width*this.nextRow;let h=0,p=e[h];for(let m=0;m<this.width;m++){m/p.right>1&&(p=e[++h]);const _=Math.abs(m-p.left),x=Math.abs(m-p.right),b=Math.min(_,x);this.image.data[c+m]=Math.max(0,Math.min(255,(p.isDash?b:-b)+i+128))}}addDash(e,i){const n=this.getKey(e,i);if(this.positions[n])return this.positions[n];const a=i==="round",c=a?7:0,h=2*c+1;if(this.nextRow+h>this.height)return li("LineAtlas out of space"),null;e.length===0&&e.push(1);let p=0;for(let x=0;x<e.length;x++)e[x]<0&&(li("Negative value is found in line dasharray, replacing values with 0"),e[x]=0),p+=e[x];if(p!==0){const x=this.width/p,b=this.getDashRanges(e,this.width,x);a?this.addRoundDash(b,x,c):this.addRegularDash(b,i==="square"?.5*x:0)}const m=this.nextRow+c;this.nextRow+=h;const _={tl:[m,c],br:[p,0]};return this.positions[n]=_,_}}Xe(_m,"LineAtlas");const gm=1*sn;class ym{constructor(e){const i={},n=[];for(const p in e){const m=e[p],_=i[p]={};for(const x in m.glyphs){const b=m.glyphs[+x];if(!b||b.bitmap.width===0||b.bitmap.height===0)continue;const T=b.metrics.localGlyph?gm:1,A={x:0,y:0,w:b.bitmap.width+2*T,h:b.bitmap.height+2*T};n.push(A),_[x]=A}}const{w:a,h:c}=dd(n),h=new Hn({width:a||1,height:c||1});for(const p in e){const m=e[p];for(const _ in m.glyphs){const x=m.glyphs[+_];if(!x||x.bitmap.width===0||x.bitmap.height===0)continue;const b=i[p][_],T=x.metrics.localGlyph?gm:1;Hn.copy(x.bitmap,h,{x:0,y:0},{x:b.x+T,y:b.y+T},x.bitmap)}}this.image=h,this.positions=i}}Xe(ym,"GlyphAtlas");class nx{constructor(e){this.tileID=new tr(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.enableTerrain=!!e.enableTerrain,this.isSymbolTile=e.isSymbolTile,this.tileTransform=ks(e.tileID.canonical,e.projection),this.projection=e.projection}parse(e,i,n,a,c){this.status="parsing",this.data=e,this.collisionBoxArray=new $t;const h=new Qf(Object.keys(e.layers).sort()),p=new fm(this.tileID,this.promoteId);p.bucketLayerIDs=[];const m={},_=new _m(256,256),x={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:_,availableImages:n},b=i.familiesBySource[this.source];for(const Y in b){const J=e.layers[Y];if(!J)continue;let me=!1,de=!1;for(const ye of b[Y])ye[0].type==="symbol"?me=!0:de=!0;if(this.isSymbolTile===!0&&!me||this.isSymbolTile===!1&&!de)continue;J.version===1&&li(`Vector tile source "${this.source}" layer "${Y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Te=h.encode(Y),Le=[];for(let ye=0;ye<J.length;ye++){const Ae=J.feature(ye),Me=p.getId(Ae,Y);Le.push({feature:Ae,id:Me,index:ye,sourceLayerIndex:Te})}for(const ye of b[Y]){const Ae=ye[0];this.isSymbolTile!==void 0&&Ae.type==="symbol"!==this.isSymbolTile||Ae.minzoom&&this.zoom<Math.floor(Ae.minzoom)||Ae.maxzoom&&this.zoom>=Ae.maxzoom||Ae.visibility!=="none"&&(Cd(ye,this.zoom,n),(m[Ae.id]=Ae.createBucket({index:p.bucketLayerIDs.length,layers:ye,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Te,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:n})).populate(Le,x,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(ye.map(Me=>Me.id)))}}let T,A,M,z;_.trim();const B={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},V=()=>{if(T)return c(T);if(A&&M&&z){const Y=new ym(A),J=new Sf(M,z);for(const me in m){const de=m[me];de instanceof Lo?(Cd(de.layers,this.zoom,n),Py(de,A,Y.positions,M,J.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):de.hasPattern&&(de instanceof Lu||de instanceof Iu||de instanceof ac)&&(Cd(de.layers,this.zoom,n),de.addFeatures(x,this.tileID.canonical,J.patternPositions,n,this.tileTransform))}this.status="done",c(null,{buckets:un(m).filter(me=>!me.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Y.image,lineAtlas:_,imageAtlas:J,glyphMap:this.returnDependencies?A:null,iconMap:this.returnDependencies?M:null,glyphPositions:this.returnDependencies?Y.positions:null})}},K=Mt(x.glyphDependencies,Y=>Object.keys(Y).map(Number));Object.keys(K).length?a.send("getGlyphs",{uid:this.uid,stacks:K},(Y,J)=>{T||(T=Y,A=J,V())},void 0,!1,B):A={};const G=Object.keys(x.iconDependencies);G.length?a.send("getImages",{icons:G,source:this.source,tileID:this.tileID,type:"icons"},(Y,J)=>{T||(T=Y,M=J,V())},void 0,!1,B):M={};const X=Object.keys(x.patternDependencies);X.length?a.send("getImages",{icons:X,source:this.source,tileID:this.tileID,type:"patterns"},(Y,J)=>{T||(T=Y,z=J,V())},void 0,!1,B):z={},V()}}function Cd(t,e,i){const n=new v(e);for(const a of t)a.recalculate(n,i)}class xm{constructor(e){this.entries={},this.scheduler=e}request(e,i,n,a){const c=this.entries[e]=this.entries[e]||{callbacks:[]};if(c.result){const[h,p]=c.result;return this.scheduler?this.scheduler.add(()=>{a(h,p)},i):a(h,p),()=>{}}return c.callbacks.push(a),c.cancel||(c.cancel=n((h,p)=>{c.result=[h,p];for(const m of c.callbacks)this.scheduler?this.scheduler.add(()=>{m(h,p)},i):m(h,p);setTimeout(()=>delete this.entries[e],3e3)})),()=>{c.result||(c.callbacks=c.callbacks.filter(h=>h!==a),c.callbacks.length||(c.cancel(),delete this.entries[e]))}}}function vm(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},a=>{const c=so(t.request,(h,p,m,_)=>{h?a(h):p&&a(null,{vectorTile:i?void 0:new ld(new Bu(p)),rawData:p,cacheControl:m,expires:_})});return()=>{c.cancel(),a()}},e)}const bm=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Pd{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,n]=new Uint8Array(e,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const a=n>>4;if(a!==1)throw new Error(`Got v${a} data when expected v1.`);const c=bm[15&n];if(!c)throw new Error("Unrecognized array type.");const[h]=new Uint16Array(e,2,1),[p]=new Uint32Array(e,4,1);return new Pd(p,h,c,e)}constructor(e,i=64,n=Float64Array,a){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const c=bm.indexOf(this.ArrayType),h=2*e*this.ArrayType.BYTES_PER_ELEMENT,p=e*this.IndexArrayType.BYTES_PER_ELEMENT,m=(8-p%8)%8;if(c<0)throw new Error(`Unexpected typed array class: ${n}.`);a&&a instanceof ArrayBuffer?(this.data=a,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+m,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+h+p+m),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+m,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+c]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=e)}add(e,i){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=i,n}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return zd(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,n,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:h,nodeSize:p}=this,m=[0,c.length-1,0],_=[];for(;m.length;){const x=m.pop()||0,b=m.pop()||0,T=m.pop()||0;if(b-T<=p){for(let B=T;B<=b;B++){const V=h[2*B],K=h[2*B+1];V>=e&&V<=n&&K>=i&&K<=a&&_.push(c[B])}continue}const A=T+b>>1,M=h[2*A],z=h[2*A+1];M>=e&&M<=n&&z>=i&&z<=a&&_.push(c[A]),(x===0?e<=M:i<=z)&&(m.push(T),m.push(A-1),m.push(1-x)),(x===0?n>=M:a>=z)&&(m.push(A+1),m.push(b),m.push(1-x))}return _}within(e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:a,coords:c,nodeSize:h}=this,p=[0,a.length-1,0],m=[],_=n*n;for(;p.length;){const x=p.pop()||0,b=p.pop()||0,T=p.pop()||0;if(b-T<=h){for(let B=T;B<=b;B++)Tm(c[2*B],c[2*B+1],e,i)<=_&&m.push(a[B]);continue}const A=T+b>>1,M=c[2*A],z=c[2*A+1];Tm(M,z,e,i)<=_&&m.push(a[A]),(x===0?e-n<=M:i-n<=z)&&(p.push(T),p.push(A-1),p.push(1-x)),(x===0?e+n>=M:i+n>=z)&&(p.push(A+1),p.push(b),p.push(1-x))}return m}}function zd(t,e,i,n,a,c){if(a-n<=i)return;const h=n+a>>1;wm(t,e,h,n,a,c),zd(t,e,i,n,h-1,1-c),zd(t,e,i,h+1,a,1-c)}function wm(t,e,i,n,a,c){for(;a>n;){if(a-n>600){const _=a-n+1,x=i-n+1,b=Math.log(_),T=.5*Math.exp(2*b/3),A=.5*Math.sqrt(b*T*(_-T)/_)*(x-_/2<0?-1:1);wm(t,e,i,Math.max(n,Math.floor(i-x*T/_+A)),Math.min(a,Math.floor(i+(_-x)*T/_+A)),c)}const h=e[2*i+c];let p=n,m=a;for(vc(t,e,n,i),e[2*a+c]>h&&vc(t,e,n,a);p<m;){for(vc(t,e,p,m),p++,m--;e[2*p+c]<h;)p++;for(;e[2*m+c]>h;)m--}e[2*n+c]===h?vc(t,e,n,m):(m++,vc(t,e,m,a)),m<=i&&(n=m+1),i<=m&&(a=m-1)}}function vc(t,e,i,n){kd(t,i,n),kd(e,2*i,2*n),kd(e,2*i+1,2*n+1)}function kd(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function Tm(t,e,i,n){const a=t-i,c=e-n;return a*a+c*c}s.ARRAY_TYPE=gr,s.AUTH_ERR_MSG=Q,s.Aabb=er,s.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},Cn(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=jr()?t:le,this.scheduler=new Jy}send(t,e,i,n,a=!1,c){const h=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=c,this.callbacks[h]=i);const p=ro(this.globalScope)?void 0:[];return this.target.postMessage({id:h,type:t,hasCallback:!!i,targetMapId:n,mustQueue:a,sourceMapId:this.mapId,data:So(e,p)},p),{cancel:()=>{i&&delete this.callbacks[h],this.target.postMessage({id:h,type:"<cancel>",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){const n=this.cancelCallbacks[i];delete this.cancelCallbacks[i],n&&n.cancel()}else if(e.mustQueue||jr()){const n=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add(()=>this.processTask(i,e),n&&n.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if(e.type==="<response>"){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Vn(e.error)):i(null,Vn(e.data)))}else{const i=ro(this.globalScope)?void 0:[],n=e.hasCallback?(c,h)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:c?So(c):null,data:So(h,i)},i)}:c=>{},a=Vn(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,a,n);else if(this.parent.getWorkerSource){const c=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,c[0],a.source)[c[1]](a,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},s.CanonicalTileID=ku,s.Color=gi,s.ColorMode=Sn,s.CullFaceMode=an,s.DEMData=Hu,s.DataConstantProperty=P,s.DedupedRequest=xm,s.DepthMode=Na,s.EXTENT=nt,s.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,n=1<<i,a=Math.floor(t.x),c=Math.floor((t.x-a)*n),h=Math.floor(t.y*n),p=this.findDEMTileFor(new tr(i,a,i,c,h));return!(!p||!p.dem)}getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){if(this.isUsingMockSource())return null;e==null&&(e=null);const n=this._source();if(!n||t.y<0||t.y>1)return e;const a=n.getSource().maxzoom,c=1<<a,h=Math.floor(t.x),p=t.x-h,m=new tr(a,h,a,Math.floor(p*c),Math.floor(t.y*c)),_=this.findDEMTileFor(m);if(!_||!_.dem)return e;const x=_.dem,b=1<<_.tileID.canonical.z,T=(p*b-_.tileID.canonical.x)*x.dim,A=(t.y*b-_.tileID.canonical.y)*x.dim,M=Math.floor(T),z=Math.floor(A);return(i?this.exaggeration():1)*Pt(Pt(x.get(M,z),x.get(M,z+1),A-z),Pt(x.get(M+1,z),x.get(M+1,z+1),A-z),T-M)}getAtTileOffset(t,e,i){const n=1<<t.canonical.z;return this.getAtPointOrZero(new Aa(t.wrap+(t.canonical.x+e/nt)/n,(t.canonical.y+i/nt)/n))}getAtTileOffsetFunc(t,e,i,n){return a=>{const c=this.getAtTileOffset(t,a.x,a.y),h=n.upVector(t.canonical,a.x,a.y);return Ar(h,h,c*n.upVectorScale(t.canonical,e,i).metersToTile),h}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const a=Ku.create(this,t,n);return!!a&&(e.forEach(c=>{c[2]=this.exaggeration()*a.getElevationAt(c[0],c[1],i)}),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,a=1<<t.canonical.z-n.canonical.z;let c=t.canonical.x/a-n.canonical.x,h=t.canonical.y/a-n.canonical.y,p=0;for(let m=0;m<t.canonical.z-n.canonical.z&&!i.leaves[p];m++){c*=2,h*=2;const _=2*Math.floor(h)+Math.floor(c);p=i.childOffsets[p]+_,c%=1,h%=1}return{min:this.exaggeration()*i.minimums[p],max:this.exaggeration()*i.maximums[p]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},s.ErrorEvent=Gr,s.EvaluationParameters=v,s.Event=Dn,s.Evented=Ko,s.FillExtrusionBucket=ac,s.Frustum=Uh,s.FrustumCorners=Fh,s.GLOBE_RADIUS=xn,s.GLOBE_SCALE_MATCH_LATITUDE=45,s.GLOBE_ZOOM_THRESHOLD_MAX=bp,s.GLOBE_ZOOM_THRESHOLD_MIN=Nh,s.GlobeSharedBuffers=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const t of this._wireframeSegments)t.destroy()}}_fillGridMeshWithLods(t,e){const i=new ke,n=new tt,a=[],c=t+1+2,h=e[0]+1,p=e[0]+1+(1+e.length),m=(_,x,b)=>{let T=_===c-1?_-2:_===0?_:_-1;return T+=b?24575:0,[T,x]};for(let _=0;_<c;++_)i.emplaceBack(...m(_,0,!0));for(let _=0;_<h;++_)for(let x=0;x<c;++x)i.emplaceBack(...m(x,_,(x===0||x===c-1)&&!0));for(let _=0;_<e.length;++_){const x=e[_];for(let b=0;b<c;++b)i.emplaceBack(...m(b,x,!0))}for(let _=0;_<e.length;++_){const x=n.length,b=e[_]+1+2,T=new tt;for(let z=0;z<b-1;z++){const B=z===b-2,V=B?c*(p-e.length+_-z):c;for(let K=0;K<c-1;K++){const G=z*c+K;z===0||B||K===0||K===c-2?(T.emplaceBack(G+1,G,G+V),T.emplaceBack(G+V,G+V+1,G+1)):(n.emplaceBack(G+1,G,G+V),n.emplaceBack(G+V,G+V+1,G+1))}}const A=Ti.simpleSegment(0,x,i.length,n.length-x);for(let z=0;z<T.uint16.length;z+=3)n.emplaceBack(T.uint16[z],T.uint16[z+1],T.uint16[z+2]);const M=Ti.simpleSegment(0,x,i.length,n.length-x);a.push({withoutSkirts:A,withSkirts:M})}return{vertices:i,indices:n,segments:a}}_createGrid(t){const e=this._fillGridMeshWithLods(Ms,Jl);this._gridSegments=e.segments,this._gridBuffer=t.createVertexBuffer(e.vertices,Kl.members),this._gridIndexBuffer=t.createIndexBuffer(e.indices,!0)}_createPoles(t){const e=new tt;for(let a=0;a<=Ms;a++)e.emplaceBack(0,a+1,a+2);this._poleIndexBuffer=t.createIndexBuffer(e,!0);const i=new Gt,n=new Gt;this._poleSegments=[];for(let a=0,c=0;a<Nh;a++){const h=360/(1<<a);i.emplaceBack(0,-xn,0,.5,0),n.emplaceBack(0,-xn,0,.5,1);for(let p=0;p<=Ms;p++){const m=p/Ms,_=Pt(0,h,m),[x,b,T]=Ta(J_,Y_,_,xn);i.emplaceBack(x,b,T,m,0),n.emplaceBack(x,b,T,m,1)}this._poleSegments.push(Ti.simpleSegment(c,0,66,64)),c+=66}this._poleNorthVertexBuffer=t.createVertexBuffer(i,xp,!1),this._poleSouthVertexBuffer=t.createVertexBuffer(n,xp,!1)}getGridBuffers(t,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[t].withSkirts:this._gridSegments[t].withoutSkirts]}getPoleBuffers(t){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[t]]}getWirefameBuffers(t,e){if(!this._wireframeSegments){const i=new Oi,n=Ms,a=n+1+2,c=1;this._wireframeSegments=[];for(let h=0,p=0;h<Jl.length;h++){const m=Jl[h];for(let x=c;x<m+c;x++)for(let b=c;b<n+c;b++){const T=x*a+b;i.emplaceBack(T,T+1),i.emplaceBack(T,T+a),i.emplaceBack(T,T+a+1)}const _=m*n*3;this._wireframeSegments.push(Ti.simpleSegment(0,p,(m+1)*a,_)),p+=_}this._wireframeIndexBuffer=t.createIndexBuffer(i)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[e]]}},s.GlyphManager=Ra,s.ImagePosition=pd,s.KDBush=Pd,s.LivePerformanceUtils=sh,s.LngLat=qt,s.LngLatBounds=Co,s.LocalGlyphMode=_d,s.MAX_MERCATOR_LATITUDE=Wi,s.MercatorCoordinate=Aa,s.ONE_EM=ji,s.OverscaledTileID=tr,s.PerformanceMarkers=ao,s.Point=Re,s.Properties=q,s.RGBAImage=yr,s.Ray=Oh,s.RequestManager=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let e="";for(let i=0;i<10;i++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Ct,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!oe(t))return t;const i=je(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!oe(t))return t;const i=je(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!oe(t))return t;const a=je(t);return a.path=`/v4/${a.authority}.json`,a.params.push("secure"),i&&a.params.push(`language=${i}`),n&&a.params.push(`worldview=${n}`),this._makeAPIURL(a,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const a=je(t);return oe(t)?(a.path=`/styles/v1${a.path}/sprite${e}${i}`,this._makeAPIURL(a,this._customAccessToken||n)):(a.path+=`${e}${i}`,Oe(a))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!oe(t))return t;const n=je(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&n.authority!=="raster"&&i===512?"@2x":""}${Je.supported?".webp":"$1"}`),n.authority==="raster"?n.path=`/${$e.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${$e.TILE_URL_VERSION}${n.path}`);const a=this._customAccessToken||function(c){for(const h of c){const p=h.match(/^access_token=(.*)$/);if(p)return p[1]}return null}(n.params)||$e.ACCESS_TOKEN;return $e.REQUIRE_ACCESS_TOKEN&&a&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,a)}canonicalizeTileURL(t,e){const i=je(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${$e.RASTER_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${$e.TILE_URL_VERSION}/`,"")}`;let a=i.params;return e&&(a=a.filter(c=>!c.match(/^access_token=/))),a.length&&(n+=`?${a.join("&")}`),n}canonicalizeTileset(t,e){const i=!!e&&oe(e),n=[];for(const a of t.tiles||[])ue(a)?n.push(this.canonicalizeTileURL(a,i)):n.push(a);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=je($e.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,t.protocol==="http"){const a=t.params.indexOf("secure");a>=0&&t.params.splice(a,1)}if(n.path!=="/"&&(t.path=`${n.path}${t.path}`),!$e.REQUIRE_ACCESS_TOKEN)return Oe(t);if(e=e||$e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if(e[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter(a=>a.indexOf("access_token")===-1),t.params.push(`access_token=${e||""}`),Oe(t)}},s.ResourceType=zn,s.SegmentVector=Ti,s.SourceCache=Ls,s.StencilMode=Ad,s.StructArrayLayout1ui2=_r,s.StructArrayLayout2f1f2i16=st,s.StructArrayLayout2i4=ke,s.StructArrayLayout2ui4=Oi,s.StructArrayLayout3f12=xt,s.StructArrayLayout3ui6=tt,s.StructArrayLayout4i8=Se,s.StructArrayLayout5f20=Gt,s.Texture=yc,s.Tile=Ed,s.Transitionable=C,s.Uniform1f=mu,s.Uniform1i=class extends qn{constructor(t){super(t),this.current=0}set(t,e,i){this.fetchUniformLocation(t,e)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},s.Uniform2f=class extends qn{constructor(t){super(t),this.current=[0,0]}set(t,e,i){this.fetchUniformLocation(t,e)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}},s.Uniform3f=class extends qn{constructor(t){super(t),this.current=[0,0,0]}set(t,e,i){this.fetchUniformLocation(t,e)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}},s.Uniform4f=ip,s.UniformColor=rp,s.UniformMatrix2f=class extends qn{constructor(t){super(t),this.current=R_}set(t,e,i){if(this.fetchUniformLocation(t,e)){for(let n=0;n<4;n++)if(i[n]!==this.current[n]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}},s.UniformMatrix3f=class extends qn{constructor(t){super(t),this.current=D_}set(t,e,i){if(this.fetchUniformLocation(t,e)){for(let n=0;n<9;n++)if(i[n]!==this.current[n]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}},s.UniformMatrix4f=class extends qn{constructor(t){super(t),this.current=L_}set(t,e,i){if(this.fetchUniformLocation(t,e)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let n=1;n<16;n++)if(i[n]!==this.current[n]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}},s.UnwrappedTileID=uf,s.ValidationError=We,s.VectorTileFeature=Pu,s.VectorTileWorkerSource=class extends Ko{constructor(t,e,i,n,a){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=a||vm,this.loading={},this.loaded={},this.deduped=new xm(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,n=t&&t.request,a=n&&n.collectResourceTiming,c=this.loading[i]=new nx(t);c.abort=this.loadVectorData(t,(h,p)=>{const m=!this.loading[i];if(delete this.loading[i],m||h||!p)return c.status="done",m||(this.loaded[i]=c),e(h);const _=p.rawData,x={};p.expires&&(x.expires=p.expires),p.cacheControl&&(x.cacheControl=p.cacheControl),c.vectorTile=p.vectorTile||new ld(new Bu(_));const b=()=>{c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,(T,A)=>{if(T||!A)return e(T);const M={};if(a){const z=Wa(n);z.length>0&&(M.resourceTiming=JSON.parse(JSON.stringify(z)))}e(null,xi({rawTileData:_.slice(0)},A,x,M))})};this.isSpriteLoaded?b():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(b,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):b()}),this.loaded=this.loaded||{},this.loaded[i]=c})}reloadTile(t,e){const i=this.loaded,n=t.uid,a=this;if(i&&i[n]){const c=i[n];c.showCollisionBoxes=t.showCollisionBoxes,c.enableTerrain=!!t.enableTerrain,c.projection=t.projection,c.tileTransform=ks(t.tileID.canonical,t.projection);const h=(p,m)=>{const _=c.reloadCallback;_&&(delete c.reloadCallback,c.parse(c.vectorTile,a.layerIndex,this.availableImages,a.actor,_)),e(p,m)};c.status==="parsing"?c.reloadCallback=h:c.status==="done"&&(c.vectorTile?c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,h):h())}}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}},s.WritingMode=Ir,s.ZoomDependentExpression=fs,s.add=Wn,s.addDynamicAttributes=Zu,s.adjoint=function(t,e){var i=e[0],n=e[1],a=e[2],c=e[3],h=e[4],p=e[5],m=e[6],_=e[7],x=e[8];return t[0]=h*x-p*_,t[1]=a*_-n*x,t[2]=n*p-a*h,t[3]=p*m-c*x,t[4]=i*x-a*m,t[5]=a*c-i*p,t[6]=c*_-h*m,t[7]=n*m-i*_,t[8]=i*h-n*c,t},s.asyncAll=Li,s.bezier=Go,s.bindAll=Cn,s.boundsAttributes=im,s.bufferConvexPolygon=function(t,e){const i=[];for(let n=0;n<t.length;n++){const a=zi(n-1,-1,t.length-1),c=zi(n+1,-1,t.length-1),h=t[n],p=t[c],m=t[a].sub(h).unit(),_=p.sub(h).unit(),x=_.angleWithSep(m.x,m.y),b=m.add(_).unit().mult(-1*e/Math.sin(x/2));i.push(h.add(b))}return i},s.cacheEntryPossiblyAdded=function(t){Xo++,Xo>Gs&&(t.getActor().send("enforceCacheSizeLimit",Vs),Xo=0)},s.calculateGlobeLabelMatrix=function(t,e){const{x:i,y:n}=t.point,a=Ap(i,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return Es(a,a,Gh(vn(e)))},s.calculateGlobeMatrix=function(t){const{x:e,y:i}=t.point,{lng:n,lat:a}=t._center;return Ap(e,i,t.worldSize,n,a)},s.calculateGlobeMercatorMatrix=function(t){const e=t.pixelsPerMeter,i=e/nn(1,t.center.lat),n=tn(new Float64Array(16));return $l(n,n,[t.point.x,t.point.y,0]),Ss(n,n,[i,i,e]),Float32Array.from(n)},s.circumferenceAtLatitude=qh,s.clamp=Tt,s.clearTileCache=function(t){if(!Wo())return;const e=le.caches.delete(no);t&&e.catch(t).then(()=>t())},s.clipLine=Ff,s.clone=function(t){var e=new gr(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},s.clone$1=or,s.collisionCircleLayout=iy,s.config=$e,s.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},s.create=function(){var t=new gr(16);return gr!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},s.create$1=sp,s.createExpression=wo,s.createLayout=se,s.createStyleLayer=function(t){return t.type==="custom"?new Wy(t):new Hy[t.type](t)},s.cross=Bh,s.degToRad=At,s.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},s.div=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},s.dot=Br,s.earthRadius=ec,s.ease=Us,s.easeCubicInOut=Fs,s.ecefToLatLng=function([t,e,i]){const n=Math.hypot(t,e,i),a=Math.atan2(t,i),c=.5*Math.PI-Math.acos(-e/n);return new qt(ki(a),ki(c))},s.emitValidationErrors=cu,s.endsWith=to,s.enforceCacheSizeLimit=function(t){Pn(),hr&&hr.then(e=>{e.keys().then(i=>{for(let n=0;n<i.length-t;n++)e.delete(i[n])})})},s.evaluateSizeForFeature=Du,s.evaluateSizeForZoom=za,s.evaluateVariableOffset=Gf,s.evented=d,s.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},s.exactEquals$1=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},s.exported=Vr,s.exported$1=Je,s.extend=xi,s.extend$1=$r,s.fillExtrusionHeightLift=af,s.filterObject=io,s.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},s.fromQuat=function(t,e){var i=e[0],n=e[1],a=e[2],c=e[3],h=i+i,p=n+n,m=a+a,_=i*h,x=n*h,b=n*p,T=a*h,A=a*p,M=a*m,z=c*h,B=c*p,V=c*m;return t[0]=1-b-M,t[1]=x+V,t[2]=T-B,t[3]=0,t[4]=x-V,t[5]=1-_-M,t[6]=A+z,t[7]=0,t[8]=T+B,t[9]=A-z,t[10]=1-_-b,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},s.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=i,t[2]=0,t[3]=-i,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},s.fromScaling=lp,s.furthestTileCorner=function(t){const e=Math.round((t+45+360)%360/90)%4;return Za[e]},s.getAABBPointSquareDist=function(t,e,i){let n=0;for(let a=0;a<2;++a){const c=i?i[a]:0;t[a]>c&&(n+=(t[a]-c)*(t[a]-c)),e[a]<c&&(n+=(c-e[a])*(c-e[a]))}return n},s.getAnchorAlignment=md,s.getAnchorJustification=yd,s.getBounds=function(t){let e=1/0,i=1/0,n=-1/0,a=-1/0;for(const c of t)e=Math.min(e,c.x),i=Math.min(i,c.y),n=Math.max(n,c.x),a=Math.max(a,c.y);return{min:new Re(e,i),max:new Re(n,a)}},s.getColumn=pn,s.getDefaultExportFromCjs=pi,s.getGridMatrix=function(t,e,i,n){const a=e.getNorth(),c=e.getSouth(),h=e.getWest(),p=e.getEast(),m=1<<t.z,_=p-h,x=a-c,b=_/Ms,T=-x/Jl[i],A=[0,b,0,T,0,0,a,h,0];if(t.z>0){const M=180/n;ap(A,A,[M/_+1,0,0,0,M/x+1,0,-.5*M/b,.5*M/T,1])}return A[2]=m,A[5]=t.x,A[8]=t.y,A},s.getImage=W,s.getJSON=function(t,e){return Ln(xi(t,{type:"json"}),e)},s.getLatitudinalLod=function(t){const e=Wi-5;t=Tt(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(At(t))),3);return Math.round(i*(Jl.length-1))},s.getMapSessionAPI=Di,s.getPerformanceMeasurement=Wa,s.getProjection=Jf,s.getRTLTextPluginStatus=f,s.getReferrer=kn,s.getTilePoint=function(t,{x:e,y:i},n=0){return new Re(((e-n)*t.scale-t.x)*nt,(i*t.scale-t.y)*nt)},s.getTileVec3=function(t,e,i=0){return wa(((e.x-i)*t.scale-t.x)*nt,(e.y*t.scale-t.y)*nt,Pp(e.z,e.y))},s.getVideo=function(t,e){const i=le.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let n=0;n<t.length;n++){const a=le.document.createElement("source");$s(t[n])||(i.crossOrigin="Anonymous"),a.src=t[n],i.appendChild(a)}return{cancel:()=>{}}},s.globeCenterToScreenPoint=function(t){const e=[0,0,0],i=tn(new Float64Array(16));return Es(i,t.pixelMatrix,t.globeMatrix),yi(e,e,i),new Re(e[0],e[1])},s.globeDenormalizeECEF=Gh,s.globeECEFOrigin=function(t,e){const i=[0,0,0];return yi(i,i,Ql(vn(e.canonical))),yi(i,i,t),i},s.globeMetersToEcef=yu,s.globeNormalizeECEF=Ql,s.globePixelsToTileUnits=function(t,e){return nt/(512*Math.pow(2,t))*vu(vn(e))},s.globePoleMatrixForTile=function(t,e,i){const n=tn(new Float64Array(16)),a=(e/(1<<t)-.5)*Math.PI*2;return gu(n,i.globeMatrix,a),Float32Array.from(n)},s.globeTileBounds=vn,s.globeTiltAtLngLat=Mp,s.globeToMercatorTransition=Sa,s.globeUseCustomAntiAliasing=function(t,e,i){const n=Sa(i.zoom),a=t.style.map._antialias,c=!!e.extStandardDerivatives,h=e.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return n===0&&!a&&!h&&c},s.identity=tn,s.identity$1=_p,s.invert=kh,s.isFullscreen=function(){return!!le.document.fullscreenElement||!!le.document.webkitFullscreenElement},s.isLngLatBehindGlobe=$h,s.isMapAuthenticated=function(t){return Xi.has(t)},s.isMapboxURL=oe,s.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!ro(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},s.latFromMercatorY=Zi,s.latLngToECEF=Ea,s.len=$_,s.length=ql,s.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},s.lngFromMercatorX=Mr,s.loadVectorTile=vm,s.makeRequest=Ln,s.mapValue=function(t,e,i,n,a){return Tt((t-e)/(i-e)*(a-n)+n,n,a)},s.mercatorScale=zp,s.mercatorXfromLng=bn,s.mercatorYfromLat=wn,s.mercatorZfromAltitude=nn,s.mul=V_,s.mul$1=G_,s.multiply=Es,s.multiply$1=ap,s.multiply$2=hp,s.nextPowerOfTwo=Nr,s.normalize=Qi,s.normalize$1=q_,s.normalize$2=fp,s.number=Pt,s.ortho=function(t,e,i,n,a,c,h){var p=1/(e-i),m=1/(n-a),_=1/(c-h);return t[0]=-2*p,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*m,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*_,t[11]=0,t[12]=(e+i)*p,t[13]=(a+n)*m,t[14]=(h+c)*_,t[15]=1,t},s.pbf=gf,s.perspective=function(t,e,i,n,a){var c,h=1/Math.tan(e/2);return t[0]=h/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,a!=null&&a!==1/0?(t[10]=(a+n)*(c=1/(n-a)),t[14]=2*a*n*c):(t[10]=-1,t[14]=-2*n),t},s.pick=function(t,e){const i={};for(let n=0;n<e.length;n++){const a=e[n];a in t&&(i[a]=t[a])}return i},s.plugin=y,s.pointGeometry=_i,s.polesInViewport=function(t){const e=tn(new Float64Array(16));Es(e,t.pixelMatrix,t.globeMatrix);const i=[0,Or,0],n=[0,Fr,0];return yi(i,i,e),yi(n,n,e),[i[0]>0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!$h(t,new qt(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!$h(t,new qt(t.center.lat,-90))]},s.polygonContainsPoint=Ps,s.polygonIntersectsBox=Fp,s.polygonIntersectsPolygon=Dp,s.polygonizeBounds=function(t,e,i=0,n=!0){const a=new Re(i,i),c=t.sub(a),h=e.add(a),p=[c,new Re(h.x,c.y),h,new Re(c.x,h.y)];return n&&p.push(c.clone()),p},s.posAttributes=Kl,s.postMapLoadEvent=vi,s.postPerformanceEvent=Ci,s.postTurnstileEvent=It,s.potpack=dd,s.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},s.radToDeg=ki,s.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],s.registerForPluginStateChange=function(t){return t({pluginStatus:l,pluginURL:r}),d.on("pluginStateChange",t),t},s.removeAuthState=function(t){Xi.delete(t)},s.renderColorRamp=Qh,s.resample=kp,s.rotateX=Lh,s.rotateX$1=gp,s.rotateY=gu,s.rotateY$1=yp,s.rotateZ=function(t,e,i){var n=Math.sin(i),a=Math.cos(i),c=e[0],h=e[1],p=e[2],m=e[3],_=e[4],x=e[5],b=e[6],T=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=c*a+_*n,t[1]=h*a+x*n,t[2]=p*a+b*n,t[3]=m*a+T*n,t[4]=_*a-c*n,t[5]=x*a-h*n,t[6]=b*a-p*n,t[7]=T*a-m*n,t},s.rotateZ$1=function(t,e,i){i*=.5;var n=e[0],a=e[1],c=e[2],h=e[3],p=Math.sin(i),m=Math.cos(i);return t[0]=n*m+a*p,t[1]=a*m-n*p,t[2]=c*m+h*p,t[3]=h*m-c*p,t},s.scale=Ss,s.scale$1=pp,s.scale$2=Ar,s.scaleAndAdd=Xl,s.set=function(t,e,i,n){return t[0]=e,t[1]=i,t[2]=n,t},s.setCacheLimits=function(t,e){Vs=t,Gs=e},s.setColumn=function(t,e,i){t[4*e+0]=i[0],t[4*e+1]=i[1],t[4*e+2]=i[2],t[4*e+3]=i[3]},s.setRTLTextPlugin=function(t,e,i=!1){if(l===Ul||l===Nl||l===jl)throw new Error("setRTLTextPlugin cannot be called multiple times.");r=Vr.resolveURL(t),l=Ul,Ao=e,u(),i||g()},s.smoothstep=Qn,s.spec=be,s.squaredLength=function(t){var e=t[0],i=t[1],n=t[2];return e*e+i*i+n*n},s.storeAuthState=function(t,e){e?Xi.add(t):Xi.delete(t)},s.sub=rn,s.subtract=Rh,s.symbolSize=ry,s.tileAABB=function(t,e,i,n,a,c,h,p,m){if(m.name==="globe")return K_(t,e,new ku(i,n,a));const _=ks({z:i,x:n,y:a},m);return new er([(c+_.x/_.scale)*e,e*(_.y/_.scale),h],[(c+_.x2/_.scale)*e,e*(_.y2/_.scale),p])},s.tileCornersToBounds=xu,s.tileTransform=ks,s.transformMat3=function(t,e,i){var n=e[0],a=e[1],c=e[2];return t[0]=n*i[0]+a*i[3]+c*i[6],t[1]=n*i[1]+a*i[4]+c*i[7],t[2]=n*i[2]+a*i[5]+c*i[8],t},s.transformMat4=yi,s.transformMat4$1=As,s.transformQuat=dp,s.transitionTileAABBinECEF=Tp,s.translate=$l,s.transpose=function(t,e){if(t===e){var i=e[1],n=e[2],a=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=n,t[7]=a}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},s.triggerPluginCompletionEvent=o,s.uniqueId=eo,s.updateGlobeVertexNormal=function(t,e,i,n,a){const c=5*e+2;t.float32[c+0]=i,t.float32[c+1]=n,t.float32[c+2]=a},s.validateCustomStyleLayer=function(t){const e=[],i=t.id;return i===void 0&&e.push({message:`layers.${i}: missing required property "id"`}),t.render===void 0&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&t.renderingMode!=="2d"&&t.renderingMode!=="3d"&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},s.validateFilter=t=>mr(xs(t)),s.validateFog=t=>mr(su(t)),s.validateLayer=t=>mr(iu(t)),s.validateLight=t=>mr(ou(t)),s.validateSource=t=>mr(nu(t)),s.validateStyle=lu,s.validateTerrain=t=>mr(Dl(t)),s.values=un,s.vectorTile=Cu,s.version=Qe,s.warnOnce=li,s.window=le,s.wrap=zi}),we(["./shared"],function(s){function le(H){if(typeof H=="number"||typeof H=="boolean"||typeof H=="string"||H==null)return JSON.stringify(H);if(Array.isArray(H)){let L="[";for(const W of H)L+=`${le(W)},`;return`${L}]`}let k="{";for(const L of Object.keys(H).sort())k+=`${L}:${le(H[L])},`;return`${k}}`}function Qe(H){let k="";for(const L of s.refProperties)k+=`/${le(H[L])}`;return k}class et{constructor(k){this.keyCache={},k&&this.replace(k)}replace(k){this._layerConfigs={},this._layers={},this.update(k,[])}update(k,L){for(const Q of k)this._layerConfigs[Q.id]=Q,(this._layers[Q.id]=s.createStyleLayer(Q)).compileFilter(),this.keyCache[Q.id]&&delete this.keyCache[Q.id];for(const Q of L)delete this.keyCache[Q],delete this._layerConfigs[Q],delete this._layers[Q];this.familiesBySource={};const W=function(Q,oe){const ue={};for(let ne=0;ne<Q.length;ne++){const xe=oe&&oe[Q[ne].id]||Qe(Q[ne]);oe&&(oe[Q[ne].id]=xe);let Ne=ue[xe];Ne||(Ne=ue[xe]=[]),Ne.push(Q[ne])}const ce=[];for(const ne in ue)ce.push(ue[ne]);return ce}(s.values(this._layerConfigs),this.keyCache);for(const Q of W){const oe=Q.map(je=>this._layers[je.id]),ue=oe[0];if(ue.visibility==="none")continue;const ce=ue.source||"";let ne=this.familiesBySource[ce];ne||(ne=this.familiesBySource[ce]={});const xe=ue.sourceLayer||"_geojsonTileLayer";let Ne=ne[xe];Ne||(Ne=ne[xe]=[]),Ne.push(oe)}}}class $e{loadTile(k,L){const{uid:W,encoding:Q,rawImageData:oe,padding:ue,buildQuadTree:ce}=k,ne=s.window.ImageBitmap&&oe instanceof s.window.ImageBitmap?this.getImageData(oe,ue):oe;L(null,new s.DEMData(W,ne,Q,ue<1,ce))}getImageData(k,L){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(k.width,k.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=k.width,this.offscreenCanvas.height=k.height,this.offscreenCanvasContext.drawImage(k,0,0,k.width,k.height);const W=this.offscreenCanvasContext.getImageData(-L,-L,k.width+2*L,k.height+2*L);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),W}}function Je(H,k){if(H.length!==0){Ye(H[0],k);for(var L=1;L<H.length;L++)Ye(H[L],!k)}}function Ye(H,k){for(var L=0,W=0,Q=0,oe=H.length,ue=oe-1;Q<oe;ue=Q++){var ce=(H[Q][0]-H[ue][0])*(H[ue][1]+H[Q][1]),ne=L+ce;W+=Math.abs(L)>=Math.abs(ce)?L-ne+ce:ce-ne+L,L=ne}L+W>=0!=!!k&&H.reverse()}var _t=s.getDefaultExportFromCjs(function H(k,L){var W,Q=k&&k.type;if(Q==="FeatureCollection")for(W=0;W<k.features.length;W++)H(k.features[W],L);else if(Q==="GeometryCollection")for(W=0;W<k.geometries.length;W++)H(k.geometries[W],L);else if(Q==="Feature")H(k.geometry,L);else if(Q==="Polygon")Je(k.coordinates,L);else if(Q==="MultiPolygon")for(W=0;W<k.coordinates.length;W++)Je(k.coordinates[W],L);return k});const ot=s.VectorTileFeature.prototype.toGeoJSON;var St={exports:{}},ei=s.pointGeometry,Ct=s.vectorTile.VectorTileFeature,pi=Nt;function Nt(H,k){this.options=k||{},this.features=H,this.length=H.length}function Lt(H,k){this.id=typeof H.id=="number"?H.id:void 0,this.type=H.type,this.rawGeometry=H.type===1?[H.geometry]:H.geometry,this.properties=H.tags,this.extent=k||4096}Nt.prototype.feature=function(H){return new Lt(this.features[H],this.options.extent)},Lt.prototype.loadGeometry=function(){var H=this.rawGeometry;this.geometry=[];for(var k=0;k<H.length;k++){for(var L=H[k],W=[],Q=0;Q<L.length;Q++)W.push(new ei(L[Q][0],L[Q][1]));this.geometry.push(W)}return this.geometry},Lt.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var H=this.geometry,k=1/0,L=-1/0,W=1/0,Q=-1/0,oe=0;oe<H.length;oe++)for(var ue=H[oe],ce=0;ce<ue.length;ce++){var ne=ue[ce];k=Math.min(k,ne.x),L=Math.max(L,ne.x),W=Math.min(W,ne.y),Q=Math.max(Q,ne.y)}return[k,W,L,Q]},Lt.prototype.toGeoJSON=Ct.prototype.toGeoJSON;var ti=s.pbf,_i=pi;function ai(H){var k=new ti;return function(L,W){for(var Q in L.layers)W.writeMessage(3,Re,L.layers[Q])}(H,k),k.finish()}function Re(H,k){var L;k.writeVarintField(15,H.version||1),k.writeStringField(1,H.name||""),k.writeVarintField(5,H.extent||4096);var W={keys:[],values:[],keycache:{},valuecache:{}};for(L=0;L<H.length;L++)W.feature=H.feature(L),k.writeMessage(2,In,W);var Q=W.keys;for(L=0;L<Q.length;L++)k.writeStringField(3,Q[L]);var oe=W.values;for(L=0;L<oe.length;L++)k.writeMessage(4,Fs,oe[L])}function In(H,k){var L=H.feature;L.id!==void 0&&k.writeVarintField(1,L.id),k.writeMessage(2,Vo,H),k.writeVarintField(3,L.type),k.writeMessage(4,Za,L)}function Vo(H,k){var L=H.feature,W=H.keys,Q=H.values,oe=H.keycache,ue=H.valuecache;for(var ce in L.properties){var ne=L.properties[ce],xe=oe[ce];if(ne!==null){xe===void 0&&(W.push(ce),oe[ce]=xe=W.length-1),k.writeVarint(xe);var Ne=typeof ne;Ne!=="string"&&Ne!=="boolean"&&Ne!=="number"&&(ne=JSON.stringify(ne));var je=Ne+":"+ne,Oe=ue[je];Oe===void 0&&(Q.push(ne),ue[je]=Oe=Q.length-1),k.writeVarint(Oe)}}}function At(H,k){return(k<<3)+(7&H)}function ki(H){return H<<1^H>>31}function Za(H,k){for(var L=H.loadGeometry(),W=H.type,Q=0,oe=0,ue=L.length,ce=0;ce<ue;ce++){var ne=L[ce],xe=1;W===1&&(xe=ne.length),k.writeVarint(At(1,xe));for(var Ne=W===3?ne.length-1:ne.length,je=0;je<Ne;je++){je===1&&W!==1&&k.writeVarint(At(2,Ne-1));var Oe=ne[je].x-Q,dt=ne[je].y-oe;k.writeVarint(ki(Oe)),k.writeVarint(ki(dt)),Q+=Oe,oe+=dt}W===3&&k.writeVarint(At(7,1))}}function Fs(H,k){var L=typeof H;L==="string"?k.writeStringField(1,H):L==="boolean"?k.writeBooleanField(7,H):L==="number"&&(H%1!=0?k.writeDoubleField(3,H):H<0?k.writeSVarintField(6,H):k.writeVarintField(5,H))}St.exports=ai,St.exports.fromVectorTileJs=ai,St.exports.fromGeojsonVt=function(H,k){k=k||{};var L={};for(var W in H)L[W]=new _i(H[W].features,k),L[W].name=W,L[W].version=k.version,L[W].extent=k.extent;return ai({layers:L})},St.exports.GeoJSONWrapper=_i;var Go=s.getDefaultExportFromCjs(St.exports);const Us={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:H=>H},Tt=Math.fround||(Qn=new Float32Array(1),H=>(Qn[0]=+H,Qn[0]));var Qn;const zi=3,Li=5,un=6;class xi{constructor(k){this.options=Object.assign(Object.create(Us),k),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(k){const{log:L,minZoom:W,maxZoom:Q}=this.options;L&&console.time("total time");const oe=`prepare ${k.length} points`;L&&console.time(oe),this.points=k;const ue=[];for(let ne=0;ne<k.length;ne++){const xe=k[ne];if(!xe.geometry)continue;const[Ne,je]=xe.geometry.coordinates,Oe=Tt(dn(Ne)),dt=Tt(Nr(je));ue.push(Oe,dt,1/0,ne,-1,1),this.options.reduce&&ue.push(0)}let ce=this.trees[Q+1]=this._createTree(ue);L&&console.timeEnd(oe);for(let ne=Q;ne>=W;ne--){const xe=+Date.now();ce=this.trees[ne]=this._createTree(this._cluster(ce,ne)),L&&console.log("z%d: %d clusters in %dms",ne,ce.numItems,+Date.now()-xe)}return L&&console.timeEnd("total time"),this}getClusters(k,L){let W=((k[0]+180)%360+360)%360-180;const Q=Math.max(-90,Math.min(90,k[1]));let oe=k[2]===180?180:((k[2]+180)%360+360)%360-180;const ue=Math.max(-90,Math.min(90,k[3]));if(k[2]-k[0]>=360)W=-180,oe=180;else if(W>oe){const je=this.getClusters([W,Q,180,ue],L),Oe=this.getClusters([-180,Q,oe,ue],L);return je.concat(Oe)}const ce=this.trees[this._limitZoom(L)],ne=ce.range(dn(W),Nr(ue),dn(oe),Nr(Q)),xe=ce.data,Ne=[];for(const je of ne){const Oe=this.stride*je;Ne.push(xe[Oe+Li]>1?hn(xe,Oe,this.clusterProps):this.points[xe[Oe+zi]])}return Ne}getChildren(k){const L=this._getOriginId(k),W=this._getOriginZoom(k),Q="No cluster with the specified id.",oe=this.trees[W];if(!oe)throw new Error(Q);const ue=oe.data;if(L*this.stride>=ue.length)throw new Error(Q);const ce=this.options.radius/(this.options.extent*Math.pow(2,W-1)),ne=oe.within(ue[L*this.stride],ue[L*this.stride+1],ce),xe=[];for(const Ne of ne){const je=Ne*this.stride;ue[je+4]===k&&xe.push(ue[je+Li]>1?hn(ue,je,this.clusterProps):this.points[ue[je+zi]])}if(xe.length===0)throw new Error(Q);return xe}getLeaves(k,L,W){const Q=[];return this._appendLeaves(Q,k,L=L||10,W=W||0,0),Q}getTile(k,L,W){const Q=this.trees[this._limitZoom(k)],oe=Math.pow(2,k),{extent:ue,radius:ce}=this.options,ne=ce/ue,xe=(W-ne)/oe,Ne=(W+1+ne)/oe,je={features:[]};return this._addTileFeatures(Q.range((L-ne)/oe,xe,(L+1+ne)/oe,Ne),Q.data,L,W,oe,je),L===0&&this._addTileFeatures(Q.range(1-ne/oe,xe,1,Ne),Q.data,oe,W,oe,je),L===oe-1&&this._addTileFeatures(Q.range(0,xe,ne/oe,Ne),Q.data,-1,W,oe,je),je.features.length?je:null}getClusterExpansionZoom(k){let L=this._getOriginZoom(k)-1;for(;L<=this.options.maxZoom;){const W=this.getChildren(k);if(L++,W.length!==1)break;k=W[0].properties.cluster_id}return L}_appendLeaves(k,L,W,Q,oe){const ue=this.getChildren(L);for(const ce of ue){const ne=ce.properties;if(ne&&ne.cluster?oe+ne.point_count<=Q?oe+=ne.point_count:oe=this._appendLeaves(k,ne.cluster_id,W,Q,oe):oe<Q?oe++:k.push(ce),k.length===W)break}return oe}_createTree(k){const L=new s.KDBush(k.length/this.stride|0,this.options.nodeSize,Float32Array);for(let W=0;W<k.length;W+=this.stride)L.add(k[W],k[W+1]);return L.finish(),L.data=k,L}_addTileFeatures(k,L,W,Q,oe,ue){for(const ce of k){const ne=ce*this.stride,xe=L[ne+Li]>1;let Ne,je,Oe;if(xe)Ne=eo(L,ne,this.clusterProps),je=L[ne],Oe=L[ne+1];else{const pt=this.points[L[ne+zi]];Ne=pt.properties;const[yt,It]=pt.geometry.coordinates;je=dn(yt),Oe=Nr(It)}const dt={type:1,geometry:[[Math.round(this.options.extent*(je*oe-W)),Math.round(this.options.extent*(Oe*oe-Q))]],tags:Ne};let gt;gt=xe||this.options.generateId?L[ne+zi]:this.points[L[ne+zi]].id,gt!==void 0&&(dt.id=gt),ue.features.push(dt)}}_limitZoom(k){return Math.max(this.options.minZoom,Math.min(Math.floor(+k),this.options.maxZoom+1))}_cluster(k,L){const{radius:W,extent:Q,reduce:oe,minPoints:ue}=this.options,ce=W/(Q*Math.pow(2,L)),ne=k.data,xe=[],Ne=this.stride;for(let je=0;je<ne.length;je+=Ne){if(ne[je+2]<=L)continue;ne[je+2]=L;const Oe=ne[je],dt=ne[je+1],gt=k.within(ne[je],ne[je+1],ce),pt=ne[je+Li];let yt=pt;for(const It of gt){const ci=It*Ne;ne[ci+2]>L&&(yt+=ne[ci+Li])}if(yt>pt&&yt>=ue){let It,ci=Oe*pt,vi=dt*pt,Gi=-1;const Ci=((je/Ne|0)<<5)+(L+1)+this.points.length;for(const Cr of gt){const Di=Cr*Ne;if(ne[Di+2]<=L)continue;ne[Di+2]=L;const Xi=ne[Di+Li];ci+=ne[Di]*Xi,vi+=ne[Di+1]*Xi,ne[Di+4]=Ci,oe&&(It||(It=this._map(ne,je,!0),Gi=this.clusterProps.length,this.clusterProps.push(It)),oe(It,this._map(ne,Di)))}ne[je+4]=Ci,xe.push(ci/yt,vi/yt,1/0,Ci,-1,yt),oe&&xe.push(Gi)}else{for(let It=0;It<Ne;It++)xe.push(ne[je+It]);if(yt>1)for(const It of gt){const ci=It*Ne;if(!(ne[ci+2]<=L)){ne[ci+2]=L;for(let vi=0;vi<Ne;vi++)xe.push(ne[ci+vi])}}}}return xe}_getOriginId(k){return k-this.points.length>>5}_getOriginZoom(k){return(k-this.points.length)%32}_map(k,L,W){if(k[L+Li]>1){const ue=this.clusterProps[k[L+un]];return W?Object.assign({},ue):ue}const Q=this.points[k[L+zi]].properties,oe=this.options.map(Q);return W&&oe===Q?Object.assign({},oe):oe}}function hn(H,k,L){return{type:"Feature",id:H[k+zi],properties:eo(H,k,L),geometry:{type:"Point",coordinates:[(W=H[k],360*(W-.5)),Ns(H[k+1])]}};var W}function eo(H,k,L){const W=H[k+Li],Q=W>=1e4?`${Math.round(W/1e3)}k`:W>=1e3?Math.round(W/100)/10+"k":W,oe=H[k+un],ue=oe===-1?{}:Object.assign({},L[oe]);return Object.assign(ue,{cluster:!0,cluster_id:H[k+zi],point_count:W,point_count_abbreviated:Q})}function dn(H){return H/360+.5}function Nr(H){const k=Math.sin(H*Math.PI/180),L=.5-.25*Math.log((1+k)/(1-k))/Math.PI;return L<0?0:L>1?1:L}function Ns(H){const k=(180-360*H)*Math.PI/180;return 360*Math.atan(Math.exp(k))/Math.PI-90}function Cn(H,k,L,W){for(var Q,oe=W,ue=L-k>>1,ce=L-k,ne=H[k],xe=H[k+1],Ne=H[L],je=H[L+1],Oe=k+3;Oe<L;Oe+=3){var dt=to(H[Oe],H[Oe+1],ne,xe,Ne,je);if(dt>oe)Q=Oe,oe=dt;else if(dt===oe){var gt=Math.abs(Oe-ue);gt<ce&&(Q=Oe,ce=gt)}}oe>W&&(Q-k>3&&Cn(H,k,Q,W),H[Q+2]=oe,L-Q>3&&Cn(H,Q,L,W))}function to(H,k,L,W,Q,oe){var ue=Q-L,ce=oe-W;if(ue!==0||ce!==0){var ne=((H-L)*ue+(k-W)*ce)/(ue*ue+ce*ce);ne>1?(L=Q,W=oe):ne>0&&(L+=ue*ne,W+=ce*ne)}return(ue=H-L)*ue+(ce=k-W)*ce}function Mt(H,k,L,W){var Q={id:H===void 0?null:H,type:k,geometry:L,tags:W,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(oe){var ue=oe.geometry,ce=oe.type;if(ce==="Point"||ce==="MultiPoint"||ce==="LineString")io(oe,ue);else if(ce==="Polygon"||ce==="MultiLineString")for(var ne=0;ne<ue.length;ne++)io(oe,ue[ne]);else if(ce==="MultiPolygon")for(ne=0;ne<ue.length;ne++)for(var xe=0;xe<ue[ne].length;xe++)io(oe,ue[ne][xe])}(Q),Q}function io(H,k){for(var L=0;L<k.length;L+=3)H.minX=Math.min(H.minX,k[L]),H.minY=Math.min(H.minY,k[L+1]),H.maxX=Math.max(H.maxX,k[L]),H.maxY=Math.max(H.maxY,k[L+1])}function or(H,k,L,W){if(k.geometry){var Q=k.geometry.coordinates,oe=k.geometry.type,ue=Math.pow(L.tolerance/((1<<L.maxZoom)*L.extent),2),ce=[],ne=k.id;if(L.promoteId?ne=k.properties[L.promoteId]:L.generateId&&(ne=W||0),oe==="Point")$o(Q,ce);else if(oe==="MultiPoint")for(var xe=0;xe<Q.length;xe++)$o(Q[xe],ce);else if(oe==="LineString")li(Q,ce,ue,!1);else if(oe==="MultiLineString"){if(L.lineMetrics){for(xe=0;xe<Q.length;xe++)li(Q[xe],ce=[],ue,!1),H.push(Mt(ne,"LineString",ce,k.properties));return}ur(Q,ce,ue,!1)}else if(oe==="Polygon")ur(Q,ce,ue,!0);else{if(oe!=="MultiPolygon"){if(oe==="GeometryCollection"){for(xe=0;xe<k.geometry.geometries.length;xe++)or(H,{id:ne,geometry:k.geometry.geometries[xe],properties:k.properties},L,W);return}throw new Error("Input data is not a valid GeoJSON object.")}for(xe=0;xe<Q.length;xe++){var Ne=[];ur(Q[xe],Ne,ue,!0),ce.push(Ne)}}H.push(Mt(ne,oe,ce,k.properties))}}function $o(H,k){k.push(js(H[0])),k.push(jr(H[1])),k.push(0)}function li(H,k,L,W){for(var Q,oe,ue=0,ce=0;ce<H.length;ce++){var ne=js(H[ce][0]),xe=jr(H[ce][1]);k.push(ne),k.push(xe),k.push(0),ce>0&&(ue+=W?(Q*xe-ne*oe)/2:Math.sqrt(Math.pow(ne-Q,2)+Math.pow(xe-oe,2))),Q=ne,oe=xe}var Ne=k.length-3;k[2]=1,Cn(k,0,Ne,L),k[Ne+2]=1,k.size=Math.abs(ue),k.start=0,k.end=k.size}function ur(H,k,L,W){for(var Q=0;Q<H.length;Q++){var oe=[];li(H[Q],oe,L,W),k.push(oe)}}function js(H){return H/360+.5}function jr(H){var k=Math.sin(H*Math.PI/180),L=.5-.25*Math.log((1+k)/(1-k))/Math.PI;return L<0?0:L>1?1:L}function sr(H,k,L,W,Q,oe,ue,ce){if(W/=k,oe>=(L/=k)&&ue<W)return H;if(ue<L||oe>=W)return null;for(var ne=[],xe=0;xe<H.length;xe++){var Ne=H[xe],je=Ne.geometry,Oe=Ne.type,dt=Q===0?Ne.minX:Ne.minY,gt=Q===0?Ne.maxX:Ne.maxY;if(dt>=L&&gt<W)ne.push(Ne);else if(!(gt<L||dt>=W)){var pt=[];if(Oe==="Point"||Oe==="MultiPoint")qo(je,pt,L,W,Q);else if(Oe==="LineString")ro(je,pt,L,W,Q,!1,ce.lineMetrics);else if(Oe==="MultiLineString")pn(je,pt,L,W,Q,!1);else if(Oe==="Polygon")pn(je,pt,L,W,Q,!0);else if(Oe==="MultiPolygon")for(var yt=0;yt<je.length;yt++){var It=[];pn(je[yt],It,L,W,Q,!0),It.length&&pt.push(It)}if(pt.length){if(ce.lineMetrics&&Oe==="LineString"){for(yt=0;yt<pt.length;yt++)ne.push(Mt(Ne.id,Oe,pt[yt],Ne.tags));continue}Oe!=="LineString"&&Oe!=="MultiLineString"||(pt.length===1?(Oe="LineString",pt=pt[0]):Oe="MultiLineString"),Oe!=="Point"&&Oe!=="MultiPoint"||(Oe=pt.length===3?"Point":"MultiPoint"),ne.push(Mt(Ne.id,Oe,pt,Ne.tags))}}}return ne.length?ne:null}function qo(H,k,L,W,Q){for(var oe=0;oe<H.length;oe+=3){var ue=H[oe+Q];ue>=L&&ue<=W&&(k.push(H[oe]),k.push(H[oe+1]),k.push(H[oe+2]))}}function ro(H,k,L,W,Q,oe,ue){for(var ce,ne,xe=Zo(H),Ne=Q===0?Vs:Gs,je=H.start,Oe=0;Oe<H.length-3;Oe+=3){var dt=H[Oe],gt=H[Oe+1],pt=H[Oe+2],yt=H[Oe+3],It=H[Oe+4],ci=Q===0?dt:gt,vi=Q===0?yt:It,Gi=!1;ue&&(ce=Math.sqrt(Math.pow(dt-yt,2)+Math.pow(gt-It,2))),ci<L?vi>L&&(ne=Ne(xe,dt,gt,yt,It,L),ue&&(xe.start=je+ce*ne)):ci>W?vi<W&&(ne=Ne(xe,dt,gt,yt,It,W),ue&&(xe.start=je+ce*ne)):no(xe,dt,gt,pt),vi<L&&ci>=L&&(ne=Ne(xe,dt,gt,yt,It,L),Gi=!0),vi>W&&ci<=W&&(ne=Ne(xe,dt,gt,yt,It,W),Gi=!0),!oe&&Gi&&(ue&&(xe.end=je+ce*ne),k.push(xe),xe=Zo(H)),ue&&(je+=ce)}var Ci=H.length-3;dt=H[Ci],gt=H[Ci+1],pt=H[Ci+2],(ci=Q===0?dt:gt)>=L&&ci<=W&&no(xe,dt,gt,pt),Ci=xe.length-3,oe&&Ci>=3&&(xe[Ci]!==xe[0]||xe[Ci+1]!==xe[1])&&no(xe,xe[0],xe[1],xe[2]),xe.length&&k.push(xe)}function Zo(H){var k=[];return k.size=H.size,k.start=H.start,k.end=H.end,k}function pn(H,k,L,W,Q,oe){for(var ue=0;ue<H.length;ue++)ro(H[ue],k,L,W,Q,oe,!1)}function no(H,k,L,W){H.push(k),H.push(L),H.push(W)}function Vs(H,k,L,W,Q,oe){var ue=(oe-k)/(W-k);return H.push(oe),H.push(L+(Q-L)*ue),H.push(1),ue}function Gs(H,k,L,W,Q,oe){var ue=(oe-L)/(Q-L);return H.push(k+(W-k)*ue),H.push(oe),H.push(1),ue}function hr(H,k){for(var L=[],W=0;W<H.length;W++){var Q,oe=H[W],ue=oe.type;if(ue==="Point"||ue==="MultiPoint"||ue==="LineString")Q=fn(oe.geometry,k);else if(ue==="MultiLineString"||ue==="Polygon"){Q=[];for(var ce=0;ce<oe.geometry.length;ce++)Q.push(fn(oe.geometry[ce],k))}else if(ue==="MultiPolygon")for(Q=[],ce=0;ce<oe.geometry.length;ce++){for(var ne=[],xe=0;xe<oe.geometry[ce].length;xe++)ne.push(fn(oe.geometry[ce][xe],k));Q.push(ne)}L.push(Mt(oe.id,ue,Q,oe.tags))}return L}function fn(H,k){var L=[];L.size=H.size,H.start!==void 0&&(L.start=H.start,L.end=H.end);for(var W=0;W<H.length;W+=3)L.push(H[W]+k,H[W+1],H[W+2]);return L}function Wo(H,k){if(H.transformed)return H;var L,W,Q,oe=1<<H.z,ue=H.x,ce=H.y;for(L=0;L<H.features.length;L++){var ne=H.features[L],xe=ne.geometry,Ne=ne.type;if(ne.geometry=[],Ne===1)for(W=0;W<xe.length;W+=2)ne.geometry.push(Pn(xe[W],xe[W+1],k,oe,ue,ce));else for(W=0;W<xe.length;W++){var je=[];for(Q=0;Q<xe[W].length;Q+=2)je.push(Pn(xe[W][Q],xe[W][Q+1],k,oe,ue,ce));ne.geometry.push(je)}}return H.transformed=!0,H}function Pn(H,k,L,W,Q,oe){return[Math.round(L*(H*W-Q)),Math.round(L*(k*W-oe))]}function oo(H,k,L,W,Q){for(var oe=k===Q.maxZoom?0:Q.tolerance/((1<<k)*Q.extent),ue={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:L,y:W,z:k,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},ce=0;ce<H.length;ce++){ue.numFeatures++,Xo(ue,H[ce],oe,Q);var ne=H[ce].minX,xe=H[ce].minY,Ne=H[ce].maxX,je=H[ce].maxY;ne<ue.minX&&(ue.minX=ne),xe<ue.minY&&(ue.minY=xe),Ne>ue.maxX&&(ue.maxX=Ne),je>ue.maxY&&(ue.maxY=je)}return ue}function Xo(H,k,L,W){var Q=k.geometry,oe=k.type,ue=[];if(oe==="Point"||oe==="MultiPoint")for(var ce=0;ce<Q.length;ce+=3)ue.push(Q[ce]),ue.push(Q[ce+1]),H.numPoints++,H.numSimplified++;else if(oe==="LineString")zn(ue,Q,H,L,!1,!1);else if(oe==="MultiLineString"||oe==="Polygon")for(ce=0;ce<Q.length;ce++)zn(ue,Q[ce],H,L,oe==="Polygon",ce===0);else if(oe==="MultiPolygon")for(var ne=0;ne<Q.length;ne++){var xe=Q[ne];for(ce=0;ce<xe.length;ce++)zn(ue,xe[ce],H,L,!0,ce===0)}if(ue.length){var Ne=k.tags||null;if(oe==="LineString"&&W.lineMetrics){for(var je in Ne={},k.tags)Ne[je]=k.tags[je];Ne.mapbox_clip_start=Q.start/Q.size,Ne.mapbox_clip_end=Q.end/Q.size}var Oe={geometry:ue,type:oe==="Polygon"||oe==="MultiPolygon"?3:oe==="LineString"||oe==="MultiLineString"?2:1,tags:Ne};k.id!==null&&(Oe.id=k.id),H.features.push(Oe)}}function zn(H,k,L,W,Q,oe){var ue=W*W;if(W>0&&k.size<(Q?ue:W))L.numPoints+=k.length/3;else{for(var ce=[],ne=0;ne<k.length;ne+=3)(W===0||k[ne+2]>ue)&&(L.numSimplified++,ce.push(k[ne]),ce.push(k[ne+1])),L.numPoints++;Q&&function(xe,Ne){for(var je=0,Oe=0,dt=xe.length,gt=dt-2;Oe<dt;gt=Oe,Oe+=2)je+=(xe[Oe]-xe[gt])*(xe[Oe+1]+xe[gt+1]);if(je>0===Ne)for(Oe=0,dt=xe.length;Oe<dt/2;Oe+=2){var pt=xe[Oe],yt=xe[Oe+1];xe[Oe]=xe[dt-2-Oe],xe[Oe+1]=xe[dt-1-Oe],xe[dt-2-Oe]=pt,xe[dt-1-Oe]=yt}}(ce,oe),H.push(ce)}}function mn(H,k){var L=(k=this.options=function(Q,oe){for(var ue in oe)Q[ue]=oe[ue];return Q}(Object.create(this.options),k)).debug;if(L&&console.time("preprocess data"),k.maxZoom<0||k.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(k.promoteId&&k.generateId)throw new Error("promoteId and generateId cannot be used together.");var W=function(Q,oe){var ue=[];if(Q.type==="FeatureCollection")for(var ce=0;ce<Q.features.length;ce++)or(ue,Q.features[ce],oe,ce);else or(ue,Q.type==="Feature"?Q:{geometry:Q},oe);return ue}(H,k);this.tiles={},this.tileCoords=[],L&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",k.indexMaxZoom,k.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),W=function(Q,oe){var ue=oe.buffer/oe.extent,ce=Q,ne=sr(Q,1,-1-ue,ue,0,-1,2,oe),xe=sr(Q,1,1-ue,2+ue,0,-1,2,oe);return(ne||xe)&&(ce=sr(Q,1,-ue,1+ue,0,-1,2,oe)||[],ne&&(ce=hr(ne,1).concat(ce)),xe&&(ce=ce.concat(hr(xe,-1)))),ce}(W,k),W.length&&this.splitTile(W,0,0,0),L&&(W.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)))}function kn(H,k,L){return 32*((1<<H)*L+k)+H}function Ln(H,k){const L=H.tileID.canonical;if(!this._geoJSONIndex)return k(null,null);const W=this._geoJSONIndex.getTile(L.z,L.x,L.y);if(!W)return k(null,null);const Q=new class{constructor(ue){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=s.EXTENT,this.length=ue.length,this._features=ue}feature(ue){return new class{constructor(ce){this._feature=ce,this.extent=s.EXTENT,this.type=ce.type,this.properties=ce.tags,"id"in ce&&!isNaN(ce.id)&&(this.id=parseInt(ce.id,10))}loadGeometry(){if(this._feature.type===1){const ce=[];for(const ne of this._feature.geometry)ce.push([new s.Point(ne[0],ne[1])]);return ce}{const ce=[];for(const ne of this._feature.geometry){const xe=[];for(const Ne of ne)xe.push(new s.Point(Ne[0],Ne[1]));ce.push(xe)}return ce}}toGeoJSON(ce,ne,xe){return ot.call(this,ce,ne,xe)}}(this._features[ue])}}(W.features);let oe=Go(Q);oe.byteOffset===0&&oe.byteLength===oe.buffer.byteLength||(oe=new Uint8Array(oe)),k(null,{vectorTile:Q,rawData:oe.buffer})}mn.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},mn.prototype.splitTile=function(H,k,L,W,Q,oe,ue){for(var ce=[H,k,L,W],ne=this.options,xe=ne.debug;ce.length;){W=ce.pop(),L=ce.pop(),k=ce.pop(),H=ce.pop();var Ne=1<<k,je=kn(k,L,W),Oe=this.tiles[je];if(!Oe&&(xe>1&&console.time("creation"),Oe=this.tiles[je]=oo(H,k,L,W,ne),this.tileCoords.push({z:k,x:L,y:W}),xe)){xe>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",k,L,W,Oe.numFeatures,Oe.numPoints,Oe.numSimplified),console.timeEnd("creation"));var dt="z"+k;this.stats[dt]=(this.stats[dt]||0)+1,this.total++}if(Oe.source=H,Q){if(k===ne.maxZoom||k===Q)continue;var gt=1<<Q-k;if(L!==Math.floor(oe/gt)||W!==Math.floor(ue/gt))continue}else if(k===ne.indexMaxZoom||Oe.numPoints<=ne.indexMaxPoints)continue;if(Oe.source=null,H.length!==0){xe>1&&console.time("clipping");var pt,yt,It,ci,vi,Gi,Ci=.5*ne.buffer/ne.extent,Cr=.5-Ci,Di=.5+Ci,Xi=1+Ci;pt=yt=It=ci=null,vi=sr(H,Ne,L-Ci,L+Di,0,Oe.minX,Oe.maxX,ne),Gi=sr(H,Ne,L+Cr,L+Xi,0,Oe.minX,Oe.maxX,ne),H=null,vi&&(pt=sr(vi,Ne,W-Ci,W+Di,1,Oe.minY,Oe.maxY,ne),yt=sr(vi,Ne,W+Cr,W+Xi,1,Oe.minY,Oe.maxY,ne),vi=null),Gi&&(It=sr(Gi,Ne,W-Ci,W+Di,1,Oe.minY,Oe.maxY,ne),ci=sr(Gi,Ne,W+Cr,W+Xi,1,Oe.minY,Oe.maxY,ne),Gi=null),xe>1&&console.timeEnd("clipping"),ce.push(pt||[],k+1,2*L,2*W),ce.push(yt||[],k+1,2*L,2*W+1),ce.push(It||[],k+1,2*L+1,2*W),ce.push(ci||[],k+1,2*L+1,2*W+1)}}},mn.prototype.getTile=function(H,k,L){var W=this.options,Q=W.extent,oe=W.debug;if(H<0||H>24)return null;var ue=1<<H,ce=kn(H,k=(k%ue+ue)%ue,L);if(this.tiles[ce])return Wo(this.tiles[ce],Q);oe>1&&console.log("drilling down to z%d-%d-%d",H,k,L);for(var ne,xe=H,Ne=k,je=L;!ne&&xe>0;)xe--,Ne=Math.floor(Ne/2),je=Math.floor(je/2),ne=this.tiles[kn(xe,Ne,je)];return ne&&ne.source?(oe>1&&console.log("found parent tile z%d-%d-%d",xe,Ne,je),oe>1&&console.time("drilling down"),this.splitTile(ne.source,xe,Ne,je,H,k,L),oe>1&&console.timeEnd("drilling down"),this.tiles[ce]?Wo(this.tiles[ce],Q):null):null};class so extends s.VectorTileWorkerSource{constructor(k,L,W,Q,oe){super(k,L,W,Q,Ln),oe&&(this.loadGeoJSON=oe)}loadData(k,L){const W=k&&k.request,Q=W&&W.collectResourceTiming;this.loadGeoJSON(k,(oe,ue)=>{if(oe||!ue)return L(oe);if(typeof ue!="object")return L(new Error(`Input data given to '${k.source}' is not a valid GeoJSON object.`));{_t(ue,!0);try{if(k.filter){const ne=s.createExpression(k.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(ne.result==="error")throw new Error(ne.value.map(Ne=>`${Ne.key}: ${Ne.message}`).join(", "));ue={type:"FeatureCollection",features:ue.features.filter(Ne=>ne.value.evaluate({zoom:0},Ne))}}this._geoJSONIndex=k.cluster?new xi(function({superclusterOptions:ne,clusterProperties:xe}){if(!xe||!ne)return ne;const Ne={},je={},Oe={accumulated:null,zoom:0},dt={properties:null},gt=Object.keys(xe);for(const pt of gt){const[yt,It]=xe[pt],ci=s.createExpression(It),vi=s.createExpression(typeof yt=="string"?[yt,["accumulated"],["get",pt]]:yt);Ne[pt]=ci.value,je[pt]=vi.value}return ne.map=pt=>{dt.properties=pt;const yt={};for(const It of gt)yt[It]=Ne[It].evaluate(Oe,dt);return yt},ne.reduce=(pt,yt)=>{dt.properties=yt;for(const It of gt)Oe.accumulated=pt[It],pt[It]=je[It].evaluate(Oe,dt)},ne}(k)).load(ue.features):function(ne,xe){return new mn(ne,xe)}(ue,k.geojsonVtOptions)}catch(ne){return L(ne)}this.loaded={};const ce={};if(Q){const ne=s.getPerformanceMeasurement(W);ne&&(ce.resourceTiming={},ce.resourceTiming[k.source]=JSON.parse(JSON.stringify(ne)))}L(null,ce)}})}reloadTile(k,L){const W=this.loaded;return W&&W[k.uid]?super.reloadTile(k,L):this.loadTile(k,L)}loadGeoJSON(k,L){if(k.request)s.getJSON(k.request,L);else{if(typeof k.data!="string")return L(new Error(`Input data given to '${k.source}' is not a valid GeoJSON object.`));try{return L(null,JSON.parse(k.data))}catch{return L(new Error(`Input data given to '${k.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(k,L){try{L(null,this._geoJSONIndex.getClusterExpansionZoom(k.clusterId))}catch(W){L(W)}}getClusterChildren(k,L){try{L(null,this._geoJSONIndex.getChildren(k.clusterId))}catch(W){L(W)}}getClusterLeaves(k,L){try{L(null,this._geoJSONIndex.getLeaves(k.clusterId,k.limit,k.offset))}catch(W){L(W)}}}class $s{constructor(k){this.self=k,this.actor=new s.Actor(k,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=s.getProjection({name:"mercator"}),this.workerSourceTypes={vector:s.VectorTileWorkerSource,geojson:so},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(L,W)=>{if(this.workerSourceTypes[L])throw new Error(`Worker source with name "${L}" already registered.`);this.workerSourceTypes[L]=W},this.self.registerRTLTextPlugin=L=>{if(s.plugin.isParsed())throw new Error("RTL text plugin already registered.");s.plugin.applyArabicShaping=L.applyArabicShaping,s.plugin.processBidirectionalText=L.processBidirectionalText,s.plugin.processStyledBidirectionalText=L.processStyledBidirectionalText}}clearCaches(k,L,W){delete this.layerIndexes[k],delete this.availableImages[k],delete this.workerSources[k],delete this.demWorkerSources[k],W()}checkIfReady(k,L,W){W()}setReferrer(k,L){this.referrer=L}spriteLoaded(k,L){this.isSpriteLoaded[k]=L;for(const W in this.workerSources[k]){const Q=this.workerSources[k][W];for(const oe in Q)Q[oe]instanceof s.VectorTileWorkerSource&&(Q[oe].isSpriteLoaded=L,Q[oe].fire(new s.Event("isSpriteLoaded")))}}setImages(k,L,W){this.availableImages[k]=L;for(const Q in this.workerSources[k]){const oe=this.workerSources[k][Q];for(const ue in oe)oe[ue].availableImages=L}W()}enableTerrain(k,L,W){this.terrain=L,W()}setProjection(k,L){this.projections[k]=s.getProjection(L)}setLayers(k,L,W){this.getLayerIndex(k).replace(L),W()}updateLayers(k,L,W){this.getLayerIndex(k).update(L.layers,L.removedIds),W()}loadTile(k,L,W){const Q=this.enableTerrain?s.extend({enableTerrain:this.terrain},L):L;Q.projection=this.projections[k]||this.defaultProjection,this.getWorkerSource(k,L.type,L.source).loadTile(Q,W)}loadDEMTile(k,L,W){const Q=this.enableTerrain?s.extend({buildQuadTree:this.terrain},L):L;this.getDEMWorkerSource(k,L.source).loadTile(Q,W)}reloadTile(k,L,W){const Q=this.enableTerrain?s.extend({enableTerrain:this.terrain},L):L;Q.projection=this.projections[k]||this.defaultProjection,this.getWorkerSource(k,L.type,L.source).reloadTile(Q,W)}abortTile(k,L,W){this.getWorkerSource(k,L.type,L.source).abortTile(L,W)}removeTile(k,L,W){this.getWorkerSource(k,L.type,L.source).removeTile(L,W)}removeSource(k,L,W){if(!this.workerSources[k]||!this.workerSources[k][L.type]||!this.workerSources[k][L.type][L.source])return;const Q=this.workerSources[k][L.type][L.source];delete this.workerSources[k][L.type][L.source],Q.removeSource!==void 0?Q.removeSource(L,W):W()}loadWorkerSource(k,L,W){try{this.self.importScripts(L.url),W()}catch(Q){W(Q.toString())}}syncRTLPluginState(k,L,W){try{s.plugin.setState(L);const Q=s.plugin.getPluginURL();if(s.plugin.isLoaded()&&!s.plugin.isParsed()&&Q!=null){this.self.importScripts(Q);const oe=s.plugin.isParsed();W(oe?void 0:new Error(`RTL Text Plugin failed to import scripts from ${Q}`),oe)}}catch(Q){W(Q.toString())}}getAvailableImages(k){let L=this.availableImages[k];return L||(L=[]),L}getLayerIndex(k){let L=this.layerIndexes[k];return L||(L=this.layerIndexes[k]=new et),L}getWorkerSource(k,L,W){if(this.workerSources[k]||(this.workerSources[k]={}),this.workerSources[k][L]||(this.workerSources[k][L]={}),!this.workerSources[k][L][W]){const Q={send:(oe,ue,ce,ne,xe,Ne)=>{this.actor.send(oe,ue,ce,k,xe,Ne)},scheduler:this.actor.scheduler};this.workerSources[k][L][W]=new this.workerSourceTypes[L](Q,this.getLayerIndex(k),this.getAvailableImages(k),this.isSpriteLoaded[k])}return this.workerSources[k][L][W]}getDEMWorkerSource(k,L){return this.demWorkerSources[k]||(this.demWorkerSources[k]={}),this.demWorkerSources[k][L]||(this.demWorkerSources[k][L]=new $e),this.demWorkerSources[k][L]}enforceCacheSizeLimit(k,L){s.enforceCacheSizeLimit(L)}getWorkerPerformanceMetrics(k,L,W){W(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new $s(self)),$s}),we(["./shared"],function(s){function le(l,r){if(Array.isArray(l)){if(!Array.isArray(r)||l.length!==r.length)return!1;for(let o=0;o<l.length;o++)if(!le(l[o],r[o]))return!1;return!0}if(typeof l=="object"&&l!==null&&r!==null){if(typeof r!="object"||Object.keys(l).length!==Object.keys(r).length)return!1;for(const o in l)if(!le(l[o],r[o]))return!1;return!0}return l===r}var Qe=et;function et(l){return!function(r){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var u,d,f=new Blob([""],{type:"text/javascript"}),g=URL.createObjectURL(f);try{d=new Worker(g),u=!0}catch{u=!1}return d&&d.terminate(),URL.revokeObjectURL(g),u}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var u=document.createElement("canvas");u.width=u.height=1;var d=u.getContext("2d");if(!d)return!1;var f=d.getImageData(0,0,1,1);return f&&f.width===u.width}()?($e[o=r&&r.failIfMajorPerformanceCaveat]===void 0&&($e[o]=function(u){var d,f=function(g){var y=document.createElement("canvas"),v=Object.create(et.webGLContextAttributes);return v.failIfMajorPerformanceCaveat=g,y.getContext("webgl",v)||y.getContext("experimental-webgl",v)}(u);if(!f)return!1;try{d=f.createShader(f.VERTEX_SHADER)}catch{return!1}return!(!d||f.isContextLost())&&(f.shaderSource(d,"void main() {}"),f.compileShader(d),f.getShaderParameter(d,f.COMPILE_STATUS)===!0)}(o)),$e[o]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var o}(l)}var $e={};function Je(l,r,o){const u=s.window.document.createElement(l);return r!==void 0&&(u.className=r),o&&o.appendChild(u),u}function Ye(l,r,o){const u=s.window.document.createElementNS("http://www.w3.org/2000/svg",l);for(const d of Object.keys(r))u.setAttributeNS(null,d,r[d]);return o&&o.appendChild(u),u}et.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const _t=s.window.document&&s.window.document.documentElement.style,ot=_t&&_t.userSelect!==void 0?"userSelect":"WebkitUserSelect";let St;function ei(){_t&&ot&&(St=_t[ot],_t[ot]="none")}function Ct(){_t&&ot&&(_t[ot]=St)}function pi(l){l.preventDefault(),l.stopPropagation(),s.window.removeEventListener("click",pi,!0)}function Nt(){s.window.addEventListener("click",pi,!0),s.window.setTimeout(()=>{s.window.removeEventListener("click",pi,!0)},0)}function Lt(l,r){const o=l.getBoundingClientRect();return ai(l,o,r)}function ti(l,r){const o=l.getBoundingClientRect(),u=[];for(let d=0;d<r.length;d++)u.push(ai(l,o,r[d]));return u}function _i(l){return s.window.InstallTrigger!==void 0&&l.button===2&&l.ctrlKey&&s.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:l.button}function ai(l,r,o){const u=l.offsetWidth===r.width?1:l.offsetWidth/r.width;return new s.Point((o.clientX-r.left)*u,(o.clientY-r.top)*u)}function Re(l,r){var o=r[0],u=r[1],d=r[2],f=r[3],g=o*f-d*u;return g?(l[0]=f*(g=1/g),l[1]=-u*g,l[2]=-d*g,l[3]=o*g,l):null}function In(l){const{userImage:r}=l;return!!(r&&r.render&&r.render())&&(l.data.replace(new Uint8Array(r.data.buffer)),!0)}class Vo extends s.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new s.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(r){if(this.loaded!==r&&(this.loaded=r,r)){for(const{ids:o,callback:u}of this.requestors)this._notify(o,u);this.requestors=[]}}hasImage(r){return!!this.getImage(r)}getImage(r){return this.images[r]}addImage(r,o){this._validate(r,o)&&(this.images[r]=o)}_validate(r,o){let u=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "stretchX" value`))),u=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "stretchY" value`))),u=!1),this._validateContent(o.content,o)||(this.fire(new s.ErrorEvent(new Error(`Image "${r}" has invalid "content" value`))),u=!1),u}_validateStretch(r,o){if(!r)return!0;let u=0;for(const d of r){if(d[0]<u||d[1]<d[0]||o<d[1])return!1;u=d[1]}return!0}_validateContent(r,o){return!(r&&(r.length!==4||r[0]<0||o.data.width<r[0]||r[1]<0||o.data.height<r[1]||r[2]<0||o.data.width<r[2]||r[3]<0||o.data.height<r[3]||r[2]<r[0]||r[3]<r[1]))}updateImage(r,o){o.version=this.images[r].version+1,this.images[r]=o,this.updatedImages[r]=!0}removeImage(r){const o=this.images[r];delete this.images[r],delete this.patterns[r],o.userImage&&o.userImage.onRemove&&o.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(r,o){let u=!0;if(!this.isLoaded())for(const d of r)this.images[d]||(u=!1);this.isLoaded()||u?this._notify(r,o):this.requestors.push({ids:r,callback:o})}_notify(r,o){const u={};for(const d of r){this.images[d]||this.fire(new s.Event("styleimagemissing",{id:d}));const f=this.images[d];f?u[d]={data:f.data.clone(),pixelRatio:f.pixelRatio,sdf:f.sdf,version:f.version,stretchX:f.stretchX,stretchY:f.stretchY,content:f.content,hasRenderCallback:!!(f.userImage&&f.userImage.render)}:s.warnOnce(`Image "${d}" 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.`)}o(null,u)}getPixelSize(){const{width:r,height:o}=this.atlasImage;return{width:r,height:o}}getPattern(r){const o=this.patterns[r],u=this.getImage(r);if(!u)return null;if(o&&o.position.version===u.version)return o.position;if(o)o.position.version=u.version;else{const d={w:u.data.width+2,h:u.data.height+2,x:0,y:0},f=new s.ImagePosition(d,u);this.patterns[r]={bin:d,position:f}}return this._updatePatternAtlas(),this.patterns[r].position}bind(r){const o=r.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new s.Texture(r,this.atlasImage,o.RGBA),this.atlasTexture&&this.atlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE)}_updatePatternAtlas(){const r=[];for(const f in this.patterns)r.push(this.patterns[f].bin);const{w:o,h:u}=s.potpack(r),d=this.atlasImage;d.resize({width:o||1,height:u||1});for(const f in this.patterns){const{bin:g}=this.patterns[f],y=g.x+1,v=g.y+1,S=this.images[f].data,E=S.width,C=S.height;s.RGBAImage.copy(S,d,{x:0,y:0},{x:y,y:v},{width:E,height:C}),s.RGBAImage.copy(S,d,{x:0,y:C-1},{x:y,y:v-1},{width:E,height:1}),s.RGBAImage.copy(S,d,{x:0,y:0},{x:y,y:v+C},{width:E,height:1}),s.RGBAImage.copy(S,d,{x:E-1,y:0},{x:y-1,y:v},{width:1,height:C}),s.RGBAImage.copy(S,d,{x:0,y:0},{x:y+E,y:v},{width:1,height:C})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(r){for(const o of r){if(this.callbackDispatchedThisFrame[o])continue;this.callbackDispatchedThisFrame[o]=!0;const u=this.images[o];In(u)&&this.updateImage(o,u)}}}const At=new s.Properties({anchor:new s.DataConstantProperty(s.spec.light.anchor),position:new class{constructor(){this.specification=s.spec.light.position}possiblyEvaluate(l,r){return function([o,u,d]){const f=s.degToRad(u+90),g=s.degToRad(d);return{x:o*Math.cos(f)*Math.sin(g),y:o*Math.sin(f)*Math.sin(g),z:o*Math.cos(g),azimuthal:u,polar:d}}(l.expression.evaluate(r))}interpolate(l,r,o){return{x:s.number(l.x,r.x,o),y:s.number(l.y,r.y,o),z:s.number(l.z,r.z,o),azimuthal:s.number(l.azimuthal,r.azimuthal,o),polar:s.number(l.polar,r.polar,o)}}},color:new s.DataConstantProperty(s.spec.light.color),intensity:new s.DataConstantProperty(s.spec.light.intensity)});class ki extends s.Evented{constructor(r){super(),this._transitionable=new s.Transitionable(At),this.setLight(r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(r,o={}){if(!this._validate(s.validateLight,r,o))for(const u in r){const d=r[u];s.endsWith(u,"-transition")?this._transitionable.setTransition(u.slice(0,-11),d):this._transitionable.setValue(u,d)}}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,o,u){return(!u||u.validate!==!1)&&s.emitValidationErrors(this,r.call(s.validateStyle,s.extend({value:o,style:{glyphs:!0,sprite:!0},styleSpec:s.spec})))}}const Za=new s.Properties({source:new s.DataConstantProperty(s.spec.terrain.source),exaggeration:new s.DataConstantProperty(s.spec.terrain.exaggeration)});let Fs=class extends s.Evented{constructor(l,r){super(),this._transitionable=new s.Transitionable(Za),this.set(l),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=r}get(){return this._transitionable.serialize()}set(l){for(const r in l){const o=l[r];s.endsWith(r,"-transition")?this._transitionable.setTransition(r.slice(0,-11),o):this._transitionable.setValue(r,o)}}updateTransitions(l){this._transitioning=this._transitionable.transitioned(l,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(l){this.properties=this._transitioning.possiblyEvaluate(l)}};function Go(l,r,o,u){const d=s.smoothstep(45,65,o),[f,g]=Us(l,u),y=s.length(r);let v=1-Math.min(1,Math.exp((y-f)/(g-f)*-6));return v*=v*v,v=Math.min(1,1.00747*v),v*d*l.alpha}function Us(l,r){const o=.5/Math.tan(.5*r);return[l.range[0]+o,l.range[1]+o]}const Tt=new s.Properties({range:new s.DataConstantProperty(s.spec.fog.range),color:new s.DataConstantProperty(s.spec.fog.color),"high-color":new s.DataConstantProperty(s.spec.fog["high-color"]),"space-color":new s.DataConstantProperty(s.spec.fog["space-color"]),"horizon-blend":new s.DataConstantProperty(s.spec.fog["horizon-blend"]),"star-intensity":new s.DataConstantProperty(s.spec.fog["star-intensity"])});class Qn extends s.Evented{constructor(r,o){super(),this._transitionable=new s.Transitionable(Tt),this.set(r),this._transitioning=this._transitionable.untransitioned(),this._transform=o}get state(){const r=this._transform,o=r.projection.name==="globe",u=s.globeToMercatorTransition(r.zoom),d=this.properties.get("range"),f=[.5,3];return{range:o?[s.number(f[0],d[0],u),s.number(f[1],d[1],u)]:d,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(r,o={}){if(!this._validate(s.validateFog,r,o)){for(const u of Object.keys(s.spec.fog))r&&r[u]===void 0&&(r[u]=s.spec.fog[u].default);for(const u in r){const d=r[u];s.endsWith(u,"-transition")?this._transitionable.setTransition(u.slice(0,-11),d):this._transitionable.setValue(u,d)}}}getOpacity(r){if(!this._transform.projection.supportsFog)return 0;const o=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:s.smoothstep(45,65,r))*o.a}getOpacityAtLatLng(r,o){return this._transform.projection.supportsFog?function(u,d,f){const g=s.MercatorCoordinate.fromLngLat(d),y=f.elevation?f.elevation.getAtPointOrZero(g):0,v=[g.x,g.y,y];return s.transformMat4(v,v,f.mercatorFogMatrix),Go(u,v,f.pitch,f._fov)}(this.state,r,o):0}getFovAdjustedRange(r){return this._transform.projection.supportsFog?Us(this.state,r):[0,1]}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,o,u){return(!u||u.validate!==!1)&&s.emitValidationErrors(this,r.call(s.validateStyle,s.extend({value:o,style:{glyphs:!0,sprite:!0},styleSpec:s.spec})))}}class zi{constructor(r,o){this.workerPool=r,this.actors=[],this.currentActor=0,this.id=s.uniqueId();const u=this.workerPool.acquire(this.id);for(let d=0;d<u.length;d++){const f=new zi.Actor(u[d],o,this.id);f.name=`Worker ${d}`,this.actors.push(f)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(r,o,u){s.asyncAll(this.actors,(d,f)=>{d.send(r,o,f)},u=u||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(r=>{r.remove()}),this.actors=[],this.workerPool.release(this.id)}}function Li(l,r,o){return r*(s.EXTENT/(l.tileSize*Math.pow(2,o-l.tileID.overscaledZ)))}zi.Actor=s.Actor;class un{constructor(r,o,u,d){this.screenBounds=r,this.cameraPoint=o,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=u,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,d)}static createFromScreenPoints(r,o){let u,d;if(r instanceof s.Point||typeof r[0]=="number"){const f=s.Point.convert(r);u=[f],d=o.isPointAboveHorizon(f)}else{const f=s.Point.convert(r[0]),g=s.Point.convert(r[1]);u=[f,g],d=s.polygonizeBounds(f,g).every(y=>o.isPointAboveHorizon(y))}return new un(u,o.getCameraPoint(),d,o)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(r){return s.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const o=this.screenBounds[0],u=this.screenBounds.length===1?this.screenBounds[0].add(new s.Point(1,1)):this.screenBounds[1],d=s.polygonizeBounds(o,u,0,!1);return this.cameraPoint.y>u.y&&(this.cameraPoint.x>o.x&&this.cameraPoint.x<u.x?d.splice(3,0,this.cameraPoint):this.cameraPoint.x>=u.x?d[2]=this.cameraPoint:this.cameraPoint.x<=o.x&&(d[3]=this.cameraPoint)),s.bufferConvexPolygon(d,r)}bufferedCameraGeometryGlobe(r){const o=this.screenBounds[0],u=this.screenBounds.length===1?this.screenBounds[0].add(new s.Point(1,1)):this.screenBounds[1],d=s.polygonizeBounds(o,u,r),f=this.cameraPoint.clone();switch(3*((f.y>o.y)+(f.y>u.y))+((f.x>o.x)+(f.x>u.x))){case 0:d[0]=f,d[4]=f.clone();break;case 1:d.splice(1,0,f);break;case 2:d[1]=f;break;case 3:d.splice(4,0,f);break;case 5:d.splice(2,0,f);break;case 6:d[3]=f;break;case 7:d.splice(3,0,f);break;case 8:d[2]=f}return d}containsTile(r,o,u,d=0){const f=r.queryPadding/o._pixelsPerMercatorPixel+1,g=u?this._bufferedCameraMercator(f,o):this._bufferedScreenMercator(f,o);let y=r.tileID.wrap+(g.unwrapped?d:0);const v=g.polygon.map(j=>s.getTilePoint(r.tileTransform,j,y));if(!s.polygonIntersectsBox(v,0,0,s.EXTENT,s.EXTENT))return;y=r.tileID.wrap+(this.screenGeometryMercator.unwrapped?d:0);const S=this.screenGeometryMercator.polygon.map(j=>s.getTileVec3(r.tileTransform,j,y)),E=S.map(j=>new s.Point(j[0],j[1])),C=o.getFreeCameraOptions().position||new s.MercatorCoordinate(0,0,0),D=s.getTileVec3(r.tileTransform,C,y),F=S.map(j=>{const P=s.sub(j,j,D);return s.normalize(P,P),new s.Ray(D,P)}),N=Li(r,1,o.zoom)*o._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:E,tilespaceRays:F,bufferedTilespaceGeometry:v,bufferedTilespaceBounds:(U=s.getBounds(v),U.min.x=s.clamp(U.min.x,0,s.EXTENT),U.min.y=s.clamp(U.min.y,0,s.EXTENT),U.max.x=s.clamp(U.max.x,0,s.EXTENT),U.max.y=s.clamp(U.max.y,0,s.EXTENT),U),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:N};var U}_bufferedScreenMercator(r,o){const u=eo(r);if(this._screenRaycastCache[u])return this._screenRaycastCache[u];{let d;return d=o.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(r),o):{polygon:this.bufferedScreenGeometry(r).map(f=>o.pointCoordinate3D(f)),unwrapped:!0},this._screenRaycastCache[u]=d,d}}_bufferedCameraMercator(r,o){const u=eo(r);if(this._cameraRaycastCache[u])return this._cameraRaycastCache[u];{let d;return d=o.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(r),o):{polygon:this.bufferedCameraGeometry(r).map(f=>o.pointCoordinate3D(f)),unwrapped:!0},this._cameraRaycastCache[u]=d,d}}_projectAndResample(r,o){const u=function(f,g){const y=s.multiply([],g.pixelMatrix,g.globeMatrix),v=[0,-s.GLOBE_RADIUS,0,1],S=[0,s.GLOBE_RADIUS,0,1],E=[0,0,0,1];s.transformMat4$1(v,v,y),s.transformMat4$1(S,S,y),s.transformMat4$1(E,E,y);const C=new s.Point(v[0]/v[3],v[1]/v[3]),D=new s.Point(S[0]/S[3],S[1]/S[3]),F=s.polygonContainsPoint(f,C)&&v[3]<E[3],N=s.polygonContainsPoint(f,D)&&S[3]<E[3];if(!F&&!N)return null;const U=function(te,ae,se){for(let fe=1;fe<te.length;fe++){const ke=hn(ae.pointCoordinate3D(te[fe-1]).x),he=hn(ae.pointCoordinate3D(te[fe]).x);if(se<0){if(ke<he)return{idx:fe,t:-ke/(he-1-ke)}}else if(he<ke)return{idx:fe,t:(1-ke)/(he+1-ke)}}return null}(f,g,F?-1:1);if(!U)return null;const{idx:j,t:P}=U;let O=j>1?xi(f.slice(0,j),g):[],$=j<f.length?xi(f.slice(j),g):[];O=O.map(te=>new s.Point(hn(te.x),te.y)),$=$.map(te=>new s.Point(hn(te.x),te.y));const q=[...O];q.length===0&&q.push($[$.length-1]);const ee=s.number(q[q.length-1].y,($.length===0?O[0]:$[0]).y,P);let ie;return ie=F?[new s.Point(0,ee),new s.Point(0,0),new s.Point(1,0),new s.Point(1,ee)]:[new s.Point(1,ee),new s.Point(1,1),new s.Point(0,1),new s.Point(0,ee)],q.push(...ie),$.length===0?q.push(O[0]):q.push(...$),{polygon:q.map(te=>new s.MercatorCoordinate(te.x,te.y)),unwrapped:!1}}(r,o);if(u)return u;const d=function(f,g){let y=!1,v=-1/0,S=0;for(let C=0;C<f.length-1;C++)f[C].x>v&&(v=f[C].x,S=C);for(let C=0;C<f.length-1;C++){const D=(S+C)%(f.length-1),F=f[D],N=f[D+1];Math.abs(F.x-N.x)>.5&&(F.x<N.x?(F.x+=1,D===0&&(f[f.length-1].x+=1)):(N.x+=1,D+1===f.length-1&&(f[0].x+=1)),y=!0)}const E=s.mercatorXfromLng(g.center.lng);return y&&E<Math.abs(E-1)&&f.forEach(C=>{C.x-=1}),{polygon:f,unwrapped:y}}(xi(r,o).map(f=>new s.Point(hn(f.x),f.y)),o);return{polygon:d.polygon.map(f=>new s.MercatorCoordinate(f.x,f.y)),unwrapped:d.unwrapped}}}function xi(l,r){return s.resample(l,o=>{const u=r.pointCoordinate3D(o);o.x=u.x,o.y=u.y},1/256)}function hn(l){return l<0?1+l%1:l%1}function eo(l){return 100*l|0}function dn(l,r,o,u,d){const f=function(g,y){if(g)return d(g);if(y){l.url&&y.tiles&&l.tiles&&delete l.tiles;const v=s.pick(s.extend(y,l),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);y.vector_layers&&(v.vectorLayers=y.vector_layers,v.vectorLayerIds=v.vectorLayers.map(S=>S.id)),v.tiles=r.canonicalizeTileset(v,l.url),d(null,v)}};return l.url?s.getJSON(r.transformRequest(r.normalizeSourceURL(l.url,null,o,u),s.ResourceType.Source),f):s.exported.frame(()=>f(null,l))}class Nr{constructor(r,o,u){this.bounds=s.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=o||0,this.maxzoom=u||24}validateBounds(r){return Array.isArray(r)&&r.length===4?[Math.max(-180,r[0]),Math.max(-90,r[1]),Math.min(180,r[2]),Math.min(90,r[3])]:[-180,-90,180,90]}contains(r){const o=Math.pow(2,r.z),u=Math.floor(s.mercatorXfromLng(this.bounds.getWest())*o),d=Math.floor(s.mercatorYfromLat(this.bounds.getNorth())*o),f=Math.ceil(s.mercatorXfromLng(this.bounds.getEast())*o),g=Math.ceil(s.mercatorYfromLat(this.bounds.getSouth())*o);return r.x>=u&&r.x<f&&r.y>=d&&r.y<g}}class Ns{constructor(r,o,u){this.context=r;const d=r.gl;this.buffer=d.createBuffer(),this.dynamicDraw=!!u,this.context.unbindVAO(),r.bindElementBuffer.set(this.buffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||o.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(r){const o=this.context.gl;this.context.unbindVAO(),this.bind(),o.bufferSubData(o.ELEMENT_ARRAY_BUFFER,0,r.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Cn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class to{constructor(r,o,u,d){this.length=o.length,this.attributes=u,this.itemSize=o.bytesPerElement,this.dynamicDraw=d,this.context=r;const f=r.gl;this.buffer=f.createBuffer(),r.bindVertexBuffer.set(this.buffer),f.bufferData(f.ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||o.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(r){const o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,r.arrayBuffer)}enableAttributes(r,o){for(let u=0;u<this.attributes.length;u++){const d=o.attributes[this.attributes[u].name];d!==void 0&&r.enableVertexAttribArray(d)}}setVertexAttribPointers(r,o,u){for(let d=0;d<this.attributes.length;d++){const f=this.attributes[d],g=o.attributes[f.name];g!==void 0&&r.vertexAttribPointer(g,f.components,r[Cn[f.type]],!1,this.itemSize,f.offset+this.itemSize*(u||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Mt{constructor(r){this.gl=r.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(r){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class io extends Mt{getDefault(){return s.Color.transparent}set(r){const o=this.current;(r.r!==o.r||r.g!==o.g||r.b!==o.b||r.a!==o.a||this.dirty)&&(this.gl.clearColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class or extends Mt{getDefault(){return 1}set(r){(r!==this.current||this.dirty)&&(this.gl.clearDepth(r),this.current=r,this.dirty=!1)}}class $o extends Mt{getDefault(){return 0}set(r){(r!==this.current||this.dirty)&&(this.gl.clearStencil(r),this.current=r,this.dirty=!1)}}class li extends Mt{getDefault(){return[!0,!0,!0,!0]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.colorMask(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class ur extends Mt{getDefault(){return!0}set(r){(r!==this.current||this.dirty)&&(this.gl.depthMask(r),this.current=r,this.dirty=!1)}}class js extends Mt{getDefault(){return 255}set(r){(r!==this.current||this.dirty)&&(this.gl.stencilMask(r),this.current=r,this.dirty=!1)}}class jr extends Mt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(r){const o=this.current;(r.func!==o.func||r.ref!==o.ref||r.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(r.func,r.ref,r.mask),this.current=r,this.dirty=!1)}}class sr extends Mt{getDefault(){const r=this.gl;return[r.KEEP,r.KEEP,r.KEEP]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(r[0],r[1],r[2]),this.current=r,this.dirty=!1)}}class qo extends Mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=r,this.dirty=!1}}class ro extends Mt{getDefault(){return[0,1]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||this.dirty)&&(this.gl.depthRange(r[0],r[1]),this.current=r,this.dirty=!1)}}class Zo extends Mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=r,this.dirty=!1}}class pn extends Mt{getDefault(){return this.gl.LESS}set(r){(r!==this.current||this.dirty)&&(this.gl.depthFunc(r),this.current=r,this.dirty=!1)}}class no extends Mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.BLEND):o.disable(o.BLEND),this.current=r,this.dirty=!1}}class Vs extends Mt{getDefault(){const r=this.gl;return[r.ONE,r.ZERO]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||this.dirty)&&(this.gl.blendFunc(r[0],r[1]),this.current=r,this.dirty=!1)}}class Gs extends Mt{getDefault(){return s.Color.transparent}set(r){const o=this.current;(r.r!==o.r||r.g!==o.g||r.b!==o.b||r.a!==o.a||this.dirty)&&(this.gl.blendColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class hr extends Mt{getDefault(){return this.gl.FUNC_ADD}set(r){(r!==this.current||this.dirty)&&(this.gl.blendEquation(r),this.current=r,this.dirty=!1)}}class fn extends Mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=r,this.dirty=!1}}class Wo extends Mt{getDefault(){return this.gl.BACK}set(r){(r!==this.current||this.dirty)&&(this.gl.cullFace(r),this.current=r,this.dirty=!1)}}class Pn extends Mt{getDefault(){return this.gl.CCW}set(r){(r!==this.current||this.dirty)&&(this.gl.frontFace(r),this.current=r,this.dirty=!1)}}let oo,Xo=class extends Mt{getDefault(){return null}set(l){(l!==this.current||this.dirty)&&(this.gl.useProgram(l),this.current=l,this.dirty=!1)}};class zn extends Mt{getDefault(){return this.gl.TEXTURE0}set(r){(r!==this.current||this.dirty)&&(this.gl.activeTexture(r),this.current=r,this.dirty=!1)}}class mn extends Mt{getDefault(){const r=this.gl;return[0,0,r.drawingBufferWidth,r.drawingBufferHeight]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.viewport(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class kn extends Mt{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,r),this.current=r,this.dirty=!1}}class Ln extends Mt{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class so extends Mt{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindTexture(o.TEXTURE_2D,r),this.current=r,this.dirty=!1}}class $s extends Mt{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class H extends Mt{getDefault(){return null}set(r){const o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class k extends Mt{constructor(r){super(r),this.vao=r.extVertexArrayObject}getDefault(){return null}set(r){this.vao&&(r!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(r),this.current=r,this.dirty=!1)}}class L extends Mt{getDefault(){return 4}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,r),this.current=r,this.dirty=!1}}class W extends Mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),this.current=r,this.dirty=!1}}class Q extends Mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,r),this.current=r,this.dirty=!1}}class oe extends Mt{constructor(r,o){super(r),this.context=r,this.parent=o}getDefault(){return null}}class ue extends oe{setDirty(){this.dirty=!0}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,r,0),this.current=r,this.dirty=!1}}class ce extends oe{attachment(){return this.gl.DEPTH_ATTACHMENT}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class ne extends ce{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class xe{constructor(r,o,u,d){this.context=r,this.width=o,this.height=u;const f=this.framebuffer=r.gl.createFramebuffer();this.colorAttachment=new ue(r,f),d&&(this.depthAttachment=new ce(r,f))}destroy(){const r=this.context.gl,o=this.colorAttachment.get();if(o&&r.deleteTexture(o),this.depthAttachment){const u=this.depthAttachment.get();u&&r.deleteRenderbuffer(u)}r.deleteFramebuffer(this.framebuffer)}}class Ne{constructor(r,o=!1){if(this.gl=r,this.isWebGL2=o,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),o){const u=r;this.extVertexArrayObject={createVertexArrayOES:u.createVertexArray.bind(r),deleteVertexArrayOES:u.deleteVertexArray.bind(r),bindVertexArrayOES:u.bindVertexArray.bind(r)}}this.clearColor=new io(this),this.clearDepth=new or(this),this.clearStencil=new $o(this),this.colorMask=new li(this),this.depthMask=new ur(this),this.stencilMask=new js(this),this.stencilFunc=new jr(this),this.stencilOp=new sr(this),this.stencilTest=new qo(this),this.depthRange=new ro(this),this.depthTest=new Zo(this),this.depthFunc=new pn(this),this.blend=new no(this),this.blendFunc=new Vs(this),this.blendColor=new Gs(this),this.blendEquation=new hr(this),this.cullFace=new fn(this),this.cullFaceSide=new Wo(this),this.frontFace=new Pn(this),this.program=new Xo(this),this.activeTexture=new zn(this),this.viewport=new mn(this),this.bindFramebuffer=new kn(this),this.bindRenderbuffer=new Ln(this),this.bindTexture=new so(this),this.bindVertexBuffer=new $s(this),this.bindElementBuffer=new H(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new k(this),this.pixelStoreUnpack=new L(this),this.pixelStoreUnpackPremultiplyAlpha=new W(this),this.pixelStoreUnpackFlipY=new Q(this),this.extTextureFilterAnisotropic=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=r.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extDebugRendererInfo=r.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=r.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=r.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),o||(this.extTextureHalfFloat=r.getExtension("OES_texture_half_float")),(o||this.extTextureHalfFloat&&r.getExtension("OES_texture_half_float_linear"))&&(this.extRenderToTextureHalfFloat=r.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=o||r.getExtension("OES_standard_derivatives"),this.extTimerQuery=r.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=r.getParameter(r.MAX_TEXTURE_SIZE)}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.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(r,o){return new Ns(this,r,o)}createVertexBuffer(r,o,u){return new to(this,r,o,u)}createRenderbuffer(r,o,u){const d=this.gl,f=d.createRenderbuffer();return this.bindRenderbuffer.set(f),d.renderbufferStorage(d.RENDERBUFFER,r,o,u),this.bindRenderbuffer.set(null),f}createFramebuffer(r,o,u){return new xe(this,r,o,u)}clear({color:r,depth:o,stencil:u}){const d=this.gl;let f=0;r&&(f|=d.COLOR_BUFFER_BIT,this.clearColor.set(r),this.colorMask.set([!0,!0,!0,!0])),o!==void 0&&(f|=d.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(o),this.depthMask.set(!0)),u!==void 0&&(f|=d.STENCIL_BUFFER_BIT,this.clearStencil.set(u),this.stencilMask.set(255)),d.clear(f)}setCullFace(r){r.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(r.mode),this.frontFace.set(r.frontFace))}setDepthMode(r){r.func!==this.gl.ALWAYS||r.mask?(this.depthTest.set(!0),this.depthFunc.set(r.func),this.depthMask.set(r.mask),this.depthRange.set(r.range)):this.depthTest.set(!1)}setStencilMode(r){r.test.func!==this.gl.ALWAYS||r.mask?(this.stencilTest.set(!0),this.stencilMask.set(r.mask),this.stencilOp.set([r.fail,r.depthFail,r.pass]),this.stencilFunc.set({func:r.test.func,ref:r.ref,mask:r.test.mask})):this.stencilTest.set(!1)}setColorMode(r){le(r.blendFunction,s.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(r.blendFunction),this.blendColor.set(r.blendColor)),this.colorMask.set(r.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class je extends s.Evented{constructor(r,o,u,d){if(super(),this.id=r,this.dispatcher=u,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,s.extend(this,s.pick(o,["url","scheme","tileSize","promoteId"])),this._options=s.extend({type:"vector"},o),this._collectResourceTiming=o.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(d),this._tileWorkers={},this._deduped=new s.DedupedRequest}load(r){this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"}));const o=Array.isArray(this.map._language)?this.map._language.join():this.map._language,u=this.map._worldview;this._tileJSONRequest=dn(this._options,this.map._requestManager,o,u,(d,f)=>{this._tileJSONRequest=null,this._loaded=!0,d?(o&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${o}`),u&&u.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${u}`),this.fire(new s.ErrorEvent(d))):f&&(s.extend(this,f),f.bounds&&(this.tileBounds=new Nr(f.bounds,this.minzoom,this.maxzoom)),s.postTurnstileEvent(f.tiles,this.map._requestManager._customAccessToken),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))),r&&r(d)})}loaded(){return this._loaded}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}onAdd(r){this.map=r,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(r){return this._options.tiles=r,this.reload(),this}setUrl(r){return this.url=r,this._options.url=r,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return s.extend({},this._options)}loadTile(r,o){const u=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),d={request:this.map._requestManager.transformRequest(u,s.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:s.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(d.request.collectResourceTiming=this._collectResourceTiming,r.actor&&r.state!=="expired")r.state==="loading"?r.reloadCallback=o:r.request=r.actor.send("reloadTile",d,f.bind(this));else if(r.actor=this._tileWorkers[u]=this._tileWorkers[u]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",d,f.bind(this),void 0,!0);else{const g=s.loadVectorTile.call({deduped:this._deduped},d,(y,v)=>{y||!v?f.call(this,y):(d.data={cacheControl:v.cacheControl,expires:v.expires,rawData:v.rawData.slice(0)},r.actor&&r.actor.send("loadTile",d,f.bind(this),void 0,!0))},!0);r.request={cancel:g}}function f(g,y){return delete r.request,r.aborted?o(null):g&&g.status!==404?o(g):(y&&y.resourceTiming&&(r.resourceTiming=y.resourceTiming),this.map._refreshExpiredTiles&&y&&r.setExpiryData(y),r.loadVectorData(y,this.map.painter),s.cacheEntryPossiblyAdded(this.dispatcher),o(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(r){r.request&&(r.request.cancel(),delete r.request),r.actor&&r.actor.send("abortTile",{uid:r.uid,type:this.type,source:this.id})}unloadTile(r){r.unloadVectorData(),r.actor&&r.actor.send("removeTile",{uid:r.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Oe extends s.Evented{constructor(r,o,u,d){super(),this.id=r,this.dispatcher=u,this.setEventedParent(d),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=s.extend({type:"raster"},o),s.extend(this,s.pick(o,["url","scheme","tileSize"]))}load(r){this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=dn(this._options,this.map._requestManager,null,null,(o,u)=>{this._tileJSONRequest=null,this._loaded=!0,o?this.fire(new s.ErrorEvent(o)):u&&(s.extend(this,u),u.bounds&&(this.tileBounds=new Nr(u.bounds,this.minzoom,this.maxzoom)),s.postTurnstileEvent(u.tiles),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))),r&&r(o)})}loaded(){return this._loaded}onAdd(r){this.map=r,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(r){return this._options.tiles=r,this.reload(),this}setUrl(r){return this.url=r,this._options.url=r,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return s.extend({},this._options)}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}loadTile(r,o){const u=s.exported.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),u,this.tileSize);r.request=s.getImage(this.map._requestManager.transformRequest(d,s.ResourceType.Tile),(f,g,y,v)=>(delete r.request,r.aborted?(r.state="unloaded",o(null)):f?(r.state="errored",o(f)):g?(this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:y,expires:v}),r.setTexture(g,this.map.painter),r.state="loaded",s.cacheEntryPossiblyAdded(this.dispatcher),void o(null)):o(null)))}static loadTileData(r,o,u){r.setTexture(o,u)}static unloadTileData(r,o){r.texture&&o.saveTileTexture(r.texture)}abortTile(r,o){r.request&&(r.request.cancel(),delete r.request),o()}unloadTile(r,o){r.texture&&this.map.painter.saveTileTexture(r.texture),o()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function dt(l,r,o,u,d,f,g,y){const v=[l,o,d,r,u,f,1,1,1],S=[g,y,1],E=s.adjoint([],v),[C,D,F]=s.transformMat3(S,S,s.transpose(E,E));return s.multiply$1(v,[C,0,0,0,D,0,0,0,F],v)}class gt extends s.Evented{constructor(r,o,u,d){super(),this.id=r,this.dispatcher=u,this.coordinates=o.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=o,this._dirty=!1}load(r,o){this._loaded=o||!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=s.getImage(this.map._requestManager.transformRequest(this.url,s.ResourceType.Image),(u,d)=>{if(this._imageRequest=null,this._loaded=!0,u)this.fire(new s.ErrorEvent(u));else if(d){const{HTMLImageElement:f}=s.window;this.image=d instanceof f?s.exported.getImageData(d):d,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),this._finishLoading()}})}loaded(){return this._loaded}updateImage(r){return this.image&&r.url?(this._imageRequest&&r.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=r.url,this.load(r.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(r){this.map=r,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(r){this.coordinates=r,this._boundsArray=void 0;const o=r.map(s.MercatorCoordinate.fromLngLat);return this.tileID=function(u){let d=1/0,f=1/0,g=-1/0,y=-1/0;for(const C of u)d=Math.min(d,C.x),f=Math.min(f,C.y),g=Math.max(g,C.x),y=Math.max(y,C.y);const v=Math.max(g-d,y-f),S=Math.max(0,Math.floor(-Math.log(v)/Math.LN2)),E=Math.pow(2,S);return new s.CanonicalTileID(S,Math.floor((d+g)/2*E),Math.floor((f+y)/2*E))}(o),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(r){for(const v in this.tiles){const S=this.tiles[v];S.state!=="loaded"&&(S.state="loaded",S.texture=this.texture)}if(this._boundsArray)return;const o=s.tileTransform(this.tileID,this.map.transform.projection),[u,d,f,g]=this.coordinates.map(v=>{const S=o.projection.project(v[0],v[1]);return s.getTilePoint(o,S)._round()});this.perspectiveTransform=function(v,S,E,C,D,F,N,U,j,P){const O=dt(0,0,v,0,0,S,v,S),$=dt(E,C,D,F,N,U,j,P);return s.multiply$1($,s.adjoint(O,O),$),[$[6]/$[8]*v/s.EXTENT,$[7]/$[8]*S/s.EXTENT]}(this.width,this.height,u.x,u.y,d.x,d.y,g.x,g.y,f.x,f.y);const y=this._boundsArray=new s.StructArrayLayout4i8;y.emplaceBack(u.x,u.y,0,0),y.emplaceBack(d.x,d.y,s.EXTENT,0),y.emplaceBack(g.x,g.y,0,s.EXTENT),y.emplaceBack(f.x,f.y,s.EXTENT,s.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=r.createVertexBuffer(y,s.boundsAttributes.members),this.boundsSegments=s.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const r=this.map.painter.context,o=r.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new s.Texture(r,this.image,o.RGBA),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(r)}loadTile(r,o){this.tileID&&this.tileID.equals(r.tileID.canonical)?(this.tiles[String(r.tileID.wrap)]=r,r.buckets={},o(null)):(r.state="errored",o(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const pt={vector:je,raster:Oe,"raster-dem":class extends Oe{constructor(l,r,o,u){super(l,r,o,u),this.type="raster-dem",this.maxzoom=22,this._options=s.extend({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}loadTile(l,r){const o=this.map._requestManager.normalizeTileURL(l.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function u(d,f){d&&(l.state="errored",r(d)),f&&(l.dem=f,l.dem.onDeserialize(),l.needsHillshadePrepare=!0,l.needsDEMTextureUpload=!0,l.state="loaded",r(null))}l.request=s.getImage(this.map._requestManager.transformRequest(o,s.ResourceType.Tile),(function(d,f,g,y){if(delete l.request,l.aborted)l.state="unloaded",r(null);else if(d)l.state="errored",r(d);else if(f){this.map._refreshExpiredTiles&&l.setExpiryData({cacheControl:g,expires:y});const v=s.window.ImageBitmap&&f instanceof s.window.ImageBitmap&&(oo==null&&(oo=s.window.OffscreenCanvas&&new s.window.OffscreenCanvas(1,1).getContext("2d")&&typeof s.window.createImageBitmap=="function"),oo),S=1-(f.width-s.prevPowerOfTwo(f.width))/2;S<1||l.neighboringTiles||(l.neighboringTiles=this._getNeighboringTiles(l.tileID));const E=v?f:s.exported.getImageData(f,S),C={uid:l.uid,coord:l.tileID,source:this.id,rawImageData:E,encoding:this.encoding,padding:S};l.actor&&l.state!=="expired"||(l.actor=this.dispatcher.getActor(),l.actor.send("loadDEMTile",C,u.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(l){const r=l.canonical,o=Math.pow(2,r.z),u=(r.x-1+o)%o,d=r.x===0?l.wrap-1:l.wrap,f=(r.x+1+o)%o,g=r.x+1===o?l.wrap+1:l.wrap,y={};return y[new s.OverscaledTileID(l.overscaledZ,d,r.z,u,r.y).key]={backfilled:!1},y[new s.OverscaledTileID(l.overscaledZ,g,r.z,f,r.y).key]={backfilled:!1},r.y>0&&(y[new s.OverscaledTileID(l.overscaledZ,d,r.z,u,r.y-1).key]={backfilled:!1},y[new s.OverscaledTileID(l.overscaledZ,l.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},y[new s.OverscaledTileID(l.overscaledZ,g,r.z,f,r.y-1).key]={backfilled:!1}),r.y+1<o&&(y[new s.OverscaledTileID(l.overscaledZ,d,r.z,u,r.y+1).key]={backfilled:!1},y[new s.OverscaledTileID(l.overscaledZ,l.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},y[new s.OverscaledTileID(l.overscaledZ,g,r.z,f,r.y+1).key]={backfilled:!1}),y}unloadTile(l){l.demTexture&&this.map.painter.saveTileTexture(l.demTexture),l.fbo&&(l.fbo.destroy(),delete l.fbo),l.dem&&delete l.dem,delete l.neighboringTiles,l.state="unloaded"}},geojson:class extends s.Evented{constructor(l,r,o,u){super(),this.id=l,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=o.getActor(),this.setEventedParent(u),this._data=r.data,this._options=s.extend({},r),this._collectResourceTiming=r.collectResourceTiming,r.maxzoom!==void 0&&(this.maxzoom=r.maxzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;const d=s.EXTENT/this.tileSize;this.workerOptions=s.extend({source:this.id,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(r.buffer!==void 0?r.buffer:128)*d,tolerance:(r.tolerance!==void 0?r.tolerance:.375)*d,extent:s.EXTENT,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:r.clusterMaxZoom!==void 0?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:s.EXTENT,radius:(r.clusterRadius!==void 0?r.clusterRadius:50)*d,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter},r.workerOptions)}onAdd(l){this.map=l,this.setData(this._data)}setData(l){return this._data=l,this._updateWorkerData(),this}getClusterExpansionZoom(l,r){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:l,source:this.id},r),this}getClusterChildren(l,r){return this.actor.send("geojson.getClusterChildren",{clusterId:l,source:this.id},r),this}getClusterLeaves(l,r,o,u){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:l,limit:r,offset:o},u),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new s.Event("dataloading",{dataType:"source"})),this._loaded=!1;const l=s.extend({},this.workerOptions),r=this._data;typeof r=="string"?(l.request=this.map._requestManager.transformRequest(s.exported.resolveURL(r),s.ResourceType.Source),l.request.collectResourceTiming=this._collectResourceTiming):l.data=JSON.stringify(r),this._pendingLoad=this.actor.send(`${this.type}.loadData`,l,(o,u)=>{if(this._loaded=!0,this._pendingLoad=null,o)this.fire(new s.ErrorEvent(o));else{const d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&u&&u.resourceTiming&&u.resourceTiming[this.id]&&(d.resourceTiming=u.resourceTiming[this.id]),this.fire(new s.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(l,r){const o=l.actor?"reloadTile":"loadTile";l.actor=this.actor,l.request=this.actor.send(o,{type:this.type,uid:l.uid,tileID:l.tileID,tileZoom:l.tileZoom,zoom:l.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:s.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(u,d)=>(delete l.request,l.unloadVectorData(),l.aborted?r(null):u?r(u):(l.loadVectorData(d,this.map.painter,o==="reloadTile"),r(null))),void 0,o==="loadTile")}abortTile(l){l.request&&(l.request.cancel(),delete l.request),l.aborted=!0}unloadTile(l){l.unloadVectorData(),this.actor.send("removeTile",{uid:l.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return s.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends gt{constructor(l,r,o,u){super(l,r,o,u),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const l=this.options;this.urls=[];for(const r of l.urls)this.urls.push(this.map._requestManager.transformRequest(r,s.ResourceType.Source).url);s.getVideo(this.urls,(r,o)=>{this._loaded=!0,r?this.fire(new s.ErrorEvent(r)):o&&(this.video=o,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(l){if(this.video){const r=this.video.seekable;l<r.start(0)||l>r.end(0)?this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=l}}getVideo(){return this.video}onAdd(l){this.map||(this.map=l,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 l=this.map.painter.context,r=l.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new s.Texture(l,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(l)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:gt,canvas:class extends gt{constructor(l,r,o,u){super(l,r,o,u),r.coordinates?Array.isArray(r.coordinates)&&r.coordinates.length===4&&!r.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(f=>typeof f!="number"))||this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${l}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${l}`,null,'missing required property "coordinates"'))),r.animate&&typeof r.animate!="boolean"&&this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${l}`,null,'optional "animate" property must be a boolean value'))),r.canvas?typeof r.canvas=="string"||r.canvas instanceof s.window.HTMLCanvasElement||this.fire(new s.ErrorEvent(new s.ValidationError(`sources.${l}`,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 s.ErrorEvent(new s.ValidationError(`sources.${l}`,null,'missing required property "canvas"'))),this.options=r,this.animate=r.animate===void 0||r.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof s.window.HTMLCanvasElement?this.options.canvas:s.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new s.ErrorEvent(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(l){this.map=l,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let l=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,l=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,l=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const r=this.map.painter.context;this.texture?(l||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new s.Texture(r,this.canvas,r.gl.RGBA,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const l of[this.canvas.width,this.canvas.height])if(isNaN(l)||l<=0)return!0;return!1}},custom:class extends s.Evented{constructor(l,r,o,u){super(),this.id=l,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=r,this.setEventedParent(u),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new s.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new s.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Nr(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.clearTiles=this._clearTiles.bind(this),r.coveringTiles=this._coveringTiles.bind(this),s.extend(this,s.pick(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return s.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new s.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(l){this._map=l,this._loaded=!1,this.fire(new s.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(l),this.load()}onRemove(l){this._implementation.onRemove&&this._implementation.onRemove(l)}hasTile(l){if(this._implementation.hasTile){const{x:r,y:o,z:u}=l.canonical;return this._implementation.hasTile({x:r,y:o,z:u})}return!this.tileBounds||this.tileBounds.contains(l.canonical)}loadTile(l,r){const{x:o,y:u,z:d}=l.tileID.canonical,f=new s.window.AbortController;l.request=Promise.resolve(this._implementation.loadTile({x:o,y:u,z:d},{signal:f.signal})).then((function(g){return delete l.request,l.aborted?(l.state="unloaded",r(null)):g===void 0?(l.state="errored",r(null)):g===null?(this.loadTileData(l,{width:this.tileSize,height:this.tileSize,data:null}),l.state="loaded",r(null)):function(y){return y instanceof s.window.ImageData||y instanceof s.window.HTMLCanvasElement||y instanceof s.window.ImageBitmap||y instanceof s.window.HTMLImageElement}(g)?(this.loadTileData(l,g),l.state="loaded",void r(null)):(l.state="errored",r(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(g=>{g.code!==20&&(l.state="errored",r(g))}),l.request.cancel=()=>f.abort()}loadTileData(l,r){Oe.loadTileData(l,r,this._map.painter)}unloadTileData(l){Oe.unloadTileData(l,this._map.painter)}unloadTile(l,r){if(this.unloadTileData(l),this._implementation.unloadTile){const{x:o,y:u,z:d}=l.tileID.canonical;this._implementation.unloadTile({x:o,y:u,z:d})}r()}abortTile(l,r){l.request&&l.request.cancel&&(l.request.cancel(),delete l.request),r()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(l=>({x:l.canonical.x,y:l.canonical.y,z:l.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new s.Event("data",{dataType:"source",sourceDataType:"content"}))}}},yt=function(l,r,o,u){const d=new pt[r.type](l,r,o,u);if(d.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${d.id}`);return s.bindAll(["load","abort","unload","serialize","prepare"],d),d};function It(l,r){const o=s.identity([]);return s.scale(o,o,[.5*l.width,.5*-l.height,1]),s.translate(o,o,[1,-1,0]),s.multiply(o,o,l.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(o)}function ci(l,r,o,u,d,f,g,y=!1){const v=l.tilesIn(u,g,y);v.sort(Gi);const S=[];for(const C of v)S.push({wrappedTileID:C.tile.tileID.wrapped().key,queryResults:C.tile.queryRenderedFeatures(r,o,l._state,C,d,f,It(l.transform,C.tile.tileID),y)});const E=function(C){const D={},F={};for(const N of C){const U=N.queryResults,j=N.wrappedTileID,P=F[j]=F[j]||{};for(const O in U){const $=U[O],q=P[O]=P[O]||{},ee=D[O]=D[O]||[];for(const ie of $)q[ie.featureIndex]||(q[ie.featureIndex]=!0,ee.push(ie))}}return D}(S);for(const C in E)E[C].forEach(D=>{const F=D.feature,N=F.layer;N&&N.type!=="background"&&N.type!=="sky"&&(F.source=N.source,N["source-layer"]&&(F.sourceLayer=N["source-layer"]),F.state=F.id!==void 0?l.getFeatureState(N["source-layer"],F.id):{})});return E}function vi(l,r){const o=l.getRenderableIds().map(f=>l.getTileByID(f)),u=[],d={};for(let f=0;f<o.length;f++){const g=o[f],y=g.tileID.canonical.key;d[y]||(d[y]=!0,g.querySourceFeatures(u,r))}return u}function Gi(l,r){const o=l.tileID,u=r.tileID;return o.overscaledZ-u.overscaledZ||o.canonical.y-u.canonical.y||o.wrap-u.wrap||o.canonical.x-u.canonical.x}function Ci(){return Ao.workerClass!=null?new Ao.workerClass:new s.window.Worker(Ao.workerUrl)}const Cr="mapboxgl_preloaded_worker_pool";class Di{constructor(){this.active={}}acquire(r){if(!this.workers)for(this.workers=[];this.workers.length<Di.workerCount;)this.workers.push(new Ci);return this.active[r]=!0,this.workers.slice()}release(r){delete this.active[r],this.numActive()===0&&(this.workers.forEach(o=>{o.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Cr]}numActive(){return Object.keys(this.active).length}}let Xi;function ao(){return Xi||(Xi=new Di),Xi}function sh(l,r){const o={};for(const u in l)u!=="ref"&&(o[u]=l[u]);return s.refProperties.forEach(u=>{u in r&&(o[u]=r[u])}),o}function Ac(l){l=l.slice();const r=Object.create(null);for(let o=0;o<l.length;o++)r[l[o].id]=l[o];for(let o=0;o<l.length;o++)"ref"in l[o]&&(l[o]=sh(l[o],r[l[o].ref]));return l}Di.workerCount=2;const Bt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function Wa(l,r,o){o.push({command:Bt.addSource,args:[l,r[l]]})}function Ho(l,r,o){r.push({command:Bt.removeSource,args:[l]}),o[l]=!0}function Xa(l,r,o,u){Ho(l,o,u),Wa(l,r,o)}function qs(l,r,o){let u;for(u in l[o])if(l[o].hasOwnProperty(u)&&u!=="data"&&!le(l[o][u],r[o][u]))return!1;for(u in r[o])if(r[o].hasOwnProperty(u)&&u!=="data"&&!le(l[o][u],r[o][u]))return!1;return!0}function Pr(l,r,o,u,d,f){let g;for(g in r=r||{},l=l||{})l.hasOwnProperty(g)&&(le(l[g],r[g])||o.push({command:f,args:[u,g,r[g],d]}));for(g in r)r.hasOwnProperty(g)&&!l.hasOwnProperty(g)&&(le(l[g],r[g])||o.push({command:f,args:[u,g,r[g],d]}))}function Vr(l){return l.id}function Ha(l,r){return l[r.id]=r,l}class Ka{constructor(r,o){this.reset(r,o)}reset(r,o){this.points=r||[],this._distances=[0];for(let u=1;u<this.points.length;u++)this._distances[u]=this._distances[u-1]+this.points[u].dist(this.points[u-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(o||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(r){if(this.points.length===1)return this.points[0];r=s.clamp(r,0,1);let o=1,u=this._distances[o];const d=r*this.paddedLength+this.padding;for(;u<d&&o<this._distances.length;)u=this._distances[++o];const f=o-1,g=this._distances[f],y=u-g,v=y>0?(d-g)/y:0;return this.points[f].mult(1-v).add(this.points[o].mult(v))}}class Dn{constructor(r,o,u){const d=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(r/u),this.yCellCount=Math.ceil(o/u);for(let g=0;g<this.xCellCount*this.yCellCount;g++)d.push([]),f.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=r,this.height=o,this.xScale=this.xCellCount/r,this.yScale=this.yCellCount/o,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(r,o,u,d,f){this._forEachCell(o,u,d,f,this._insertBoxCell,this.boxUid++),this.boxKeys.push(r),this.bboxes.push(o),this.bboxes.push(u),this.bboxes.push(d),this.bboxes.push(f)}insertCircle(r,o,u,d){this._forEachCell(o-d,u-d,o+d,u+d,this._insertCircleCell,this.circleUid++),this.circleKeys.push(r),this.circles.push(o),this.circles.push(u),this.circles.push(d)}_insertBoxCell(r,o,u,d,f,g){this.boxCells[f].push(g)}_insertCircleCell(r,o,u,d,f,g){this.circleCells[f].push(g)}_query(r,o,u,d,f,g){if(u<0||r>this.width||d<0||o>this.height)return!f&&[];const y=[];if(r<=0&&o<=0&&this.width<=u&&this.height<=d){if(f)return!0;for(let v=0;v<this.boxKeys.length;v++)y.push({key:this.boxKeys[v],x1:this.bboxes[4*v],y1:this.bboxes[4*v+1],x2:this.bboxes[4*v+2],y2:this.bboxes[4*v+3]});for(let v=0;v<this.circleKeys.length;v++){const S=this.circles[3*v],E=this.circles[3*v+1],C=this.circles[3*v+2];y.push({key:this.circleKeys[v],x1:S-C,y1:E-C,x2:S+C,y2:E+C})}return g?y.filter(g):y}return this._forEachCell(r,o,u,d,this._queryCell,y,{hitTest:f,seenUids:{box:{},circle:{}}},g),f?y.length>0:y}_queryCircle(r,o,u,d,f){const g=r-u,y=r+u,v=o-u,S=o+u;if(y<0||g>this.width||S<0||v>this.height)return!d&&[];const E=[];return this._forEachCell(g,v,y,S,this._queryCellCircle,E,{hitTest:d,circle:{x:r,y:o,radius:u},seenUids:{box:{},circle:{}}},f),d?E.length>0:E}query(r,o,u,d,f){return this._query(r,o,u,d,!1,f)}hitTest(r,o,u,d,f){return this._query(r,o,u,d,!0,f)}hitTestCircle(r,o,u,d){return this._queryCircle(r,o,u,!0,d)}_queryCell(r,o,u,d,f,g,y,v){const S=y.seenUids,E=this.boxCells[f];if(E!==null){const D=this.bboxes;for(const F of E)if(!S.box[F]){S.box[F]=!0;const N=4*F;if(r<=D[N+2]&&o<=D[N+3]&&u>=D[N+0]&&d>=D[N+1]&&(!v||v(this.boxKeys[F]))){if(y.hitTest)return g.push(!0),!0;g.push({key:this.boxKeys[F],x1:D[N],y1:D[N+1],x2:D[N+2],y2:D[N+3]})}}}const C=this.circleCells[f];if(C!==null){const D=this.circles;for(const F of C)if(!S.circle[F]){S.circle[F]=!0;const N=3*F;if(this._circleAndRectCollide(D[N],D[N+1],D[N+2],r,o,u,d)&&(!v||v(this.circleKeys[F]))){if(y.hitTest)return g.push(!0),!0;{const U=D[N],j=D[N+1],P=D[N+2];g.push({key:this.circleKeys[F],x1:U-P,y1:j-P,x2:U+P,y2:j+P})}}}}}_queryCellCircle(r,o,u,d,f,g,y,v){const S=y.circle,E=y.seenUids,C=this.boxCells[f];if(C!==null){const F=this.bboxes;for(const N of C)if(!E.box[N]){E.box[N]=!0;const U=4*N;if(this._circleAndRectCollide(S.x,S.y,S.radius,F[U+0],F[U+1],F[U+2],F[U+3])&&(!v||v(this.boxKeys[N])))return g.push(!0),!0}}const D=this.circleCells[f];if(D!==null){const F=this.circles;for(const N of D)if(!E.circle[N]){E.circle[N]=!0;const U=3*N;if(this._circlesCollide(F[U],F[U+1],F[U+2],S.x,S.y,S.radius)&&(!v||v(this.circleKeys[N])))return g.push(!0),!0}}}_forEachCell(r,o,u,d,f,g,y,v){const S=this._convertToXCellCoord(r),E=this._convertToYCellCoord(o),C=this._convertToXCellCoord(u),D=this._convertToYCellCoord(d);for(let F=S;F<=C;F++)for(let N=E;N<=D;N++)if(f.call(this,r,o,u,d,this.xCellCount*N+F,g,y,v))return}_convertToXCellCoord(r){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(r*this.xScale)))}_convertToYCellCoord(r){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(r*this.yScale)))}_circlesCollide(r,o,u,d,f,g){const y=d-r,v=f-o,S=u+g;return S*S>y*y+v*v}_circleAndRectCollide(r,o,u,d,f,g,y){const v=(g-d)/2,S=Math.abs(r-(d+v));if(S>v+u)return!1;const E=(y-f)/2,C=Math.abs(o-(f+E));if(C>E+u)return!1;if(S<=v||C<=E)return!0;const D=S-v,F=C-E;return D*D+F*F<=u*u}}const Gr={unknown:0,flipRequired:1,flipNotRequired:2},Ko=Math.tan(85*Math.PI/180);function be(l,r,o,u,d,f,g){const y=s.create();if(o)if(f.name==="globe"){const v=s.calculateGlobeLabelMatrix(d,r);s.multiply(y,y,v)}else{const v=Re([],g);y[0]=v[0],y[1]=v[1],y[4]=v[2],y[5]=v[3],u||s.rotateZ(y,y,d.angle)}else s.multiply(y,d.labelPlaneMatrix,l);return y}function $r(l,r,o,u,d,f,g){const y=be(l,r,o,u,d,f,g);return f.name==="globe"&&o||(y[2]=y[6]=y[10]=y[14]=0),y}function bi(l,r,o,u,d,f,g){if(o){if(f.name==="globe"){const y=be(l,r,o,u,d,f,g);return s.invert(y,y),s.multiply(y,l,y),y}{const y=s.clone(l),v=s.identity([]);return v[0]=g[0],v[1]=g[1],v[4]=g[2],v[5]=g[3],s.multiply(y,y,v),u||s.rotateZ(y,y,-d.angle),y}}return d.glCoordMatrix}function Ri(l,r,o,u){const d=[l,r,o,1];o?s.transformMat4$1(d,d,u):bt(d,d,u);const f=d[3];return d[0]/=f,d[1]/=f,d[2]/=f,d}function Mc(l,r){return Math.min(.5+l/r*.5,1.5)}function zr(l,r){const o=l[0]/l[3],u=l[1]/l[3];return o>=-r[0]&&o<=r[0]&&u>=-r[1]&&u<=r[1]}function Ja(l,r,o,u,d,f,g,y,v,S){const E=o.transform,C=u?l.textSizeData:l.iconSizeData,D=s.evaluateSizeForZoom(C,o.transform.zoom),F=E.projection.name==="globe",N=[256/o.width*2+1,256/o.height*2+1],U=u?l.text.dynamicLayoutVertexArray:l.icon.dynamicLayoutVertexArray;U.clear();let j=null;F&&(j=u?l.text.globeExtVertexArray:l.icon.globeExtVertexArray);const P=l.lineVertexArray,O=u?l.text.placedSymbolArray:l.icon.placedSymbolArray,$=o.transform.width/o.transform.height;let q,ee=!1;for(let ie=0;ie<O.length;ie++){const te=O.get(ie),{numGlyphs:ae,writingMode:se}=te;if(se!==s.WritingMode.vertical||ee||q===s.WritingMode.horizontal||(ee=!0),q=se,(te.hidden||se===s.WritingMode.vertical)&&!ee){Tr(ae,U);continue}ee=!1;const fe=new s.Point(te.tileAnchorX,te.tileAnchorY);let{x:ke,y:he,z:Se}=E.projection.projectTilePoint(fe.x,fe.y,S.canonical);if(v){const[lt,He,st]=v(fe);ke+=lt,he+=He,Se+=st}const ge=[ke,he,Se,1];if(s.transformMat4$1(ge,ge,r),!zr(ge,N)){Tr(ae,U);continue}const ze=Mc(o.transform.cameraToCenterDistance,ge[3]),pe=s.evaluateSizeForFeature(C,D,te),Ee=g?pe/ze:pe*ze,De=Ri(ke,he,Se,d);if(De[3]<=0){Tr(ae,U);continue}let Ie={};const Be=g?null:v,it=Ze(te,Ee,!1,y,r,d,f,l.glyphOffsetArray,P,U,j,De,fe,Ie,$,Be,E.projection,S,g);ee=it.useVertical,Be&&it.needsFlipping&&(Ie={}),(it.notEnoughRoom||ee||it.needsFlipping&&Ze(te,Ee,!0,y,r,d,f,l.glyphOffsetArray,P,U,j,De,fe,Ie,$,Be,E.projection,S,g).notEnoughRoom)&&Tr(ae,U)}u?(l.text.dynamicLayoutVertexBuffer.updateData(U),j&&l.text.globeExtVertexBuffer.updateData(j)):(l.icon.dynamicLayoutVertexBuffer.updateData(U),j&&l.icon.globeExtVertexBuffer.updateData(j))}function Ic(l,r,o,u,d,f,g,y,v,S,E,C,D,F,N,U){const{lineStartIndex:j,glyphStartIndex:P,segment:O}=y,$=P+y.numGlyphs,q=j+y.lineLength,ee=r.getoffsetX(P),ie=r.getoffsetX($-1),te=ar(l*ee,o,u,d,f,g,O,j,q,v,S,E,C,D,!0,F,N,U);if(!te)return null;const ae=ar(l*ie,o,u,d,f,g,O,j,q,v,S,E,C,D,!0,F,N,U);return ae?{first:te,last:ae}:null}function lo(l,r,o,u){return l===s.WritingMode.horizontal&&Math.abs(u)>Math.abs(o)?{useVertical:!0}:l===s.WritingMode.vertical?u>0?{needsFlipping:!0}:null:r!==Gr.unknown&&function(d,f){return d===0||Math.abs(f/d)>Ko}(o,u)?r===Gr.flipRequired?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Ze(l,r,o,u,d,f,g,y,v,S,E,C,D,F,N,U,j,P,O){const $=r/24,q=l.lineOffsetX*$,ee=l.lineOffsetY*$,{lineStartIndex:ie,glyphStartIndex:te,numGlyphs:ae,segment:se,writingMode:fe,flipState:ke}=l,he=ie+l.lineLength,Se=ge=>{if(E){const[De,Ie,Be]=ge.up,it=S.length;s.updateGlobeVertexNormal(E,it+0,De,Ie,Be),s.updateGlobeVertexNormal(E,it+1,De,Ie,Be),s.updateGlobeVertexNormal(E,it+2,De,Ie,Be),s.updateGlobeVertexNormal(E,it+3,De,Ie,Be)}const[ze,pe,Ee]=ge.point;s.addDynamicAttributes(S,ze,pe,Ee,ge.angle)};if(ae>1){const ge=Ic($,y,q,ee,o,C,D,l,v,f,F,U,!1,j,P,O);if(!ge)return{notEnoughRoom:!0};if(u&&!o){let[ze,pe,Ee]=ge.first.point,[De,Ie,Be]=ge.last.point;[ze,pe]=Ri(ze,pe,Ee,g),[De,Ie]=Ri(De,Ie,Be,g);const it=lo(fe,ke,(De-ze)*N,Ie-pe);if(l.flipState=it&&it.needsFlipping?Gr.flipRequired:Gr.flipNotRequired,it)return it}Se(ge.first);for(let ze=te+1;ze<te+ae-1;ze++){const pe=ar($*y.getoffsetX(ze),q,ee,o,C,D,se,ie,he,v,f,F,U,!1,!1,j,P,O);if(!pe)return S.length-=4*(ze-te),{notEnoughRoom:!0};Se(pe)}Se(ge.last)}else{if(u&&!o){const ze=Ri(D.x,D.y,0,d),pe=ie+se+1,Ee=new s.Point(v.getx(pe),v.gety(pe)),De=Ri(Ee.x,Ee.y,0,d),Ie=De[3]>0?De:vt(D,Ee,ze,1,d,void 0,j,P.canonical),Be=lo(fe,ke,(Ie[0]-ze[0])*N,Ie[1]-ze[1]);if(l.flipState=Be&&Be.needsFlipping?Gr.flipRequired:Gr.flipNotRequired,Be)return Be}const ge=ar($*y.getoffsetX(te),q,ee,o,C,D,se,ie,he,v,f,F,U,!1,!1,j,P,O);if(!ge)return{notEnoughRoom:!0};Se(ge)}return{}}function Et(l,r,o,u,d){const{x:f,y:g,z:y}=u.projectTilePoint(l.x,l.y,r);if(!d)return Ri(f,g,y,o);const[v,S,E]=d(l);return Ri(f+v,g+S,y+E,o)}function vt(l,r,o,u,d,f,g,y){const v=Et(l.sub(r)._unit()._add(l),y,d,g,f);return s.sub(v,o,v),s.normalize(v,v),s.scaleAndAdd(v,o,v,u)}function ar(l,r,o,u,d,f,g,y,v,S,E,C,D,F,N,U,j,P){const O=u?l-r:l+r;let $=O>0?1:-1,q=0;u&&($*=-1,q=Math.PI),$<0&&(q+=Math.PI);let ee=y+g+($>0?0:1)|0,ie=d,te=d,ae=0,se=0;const fe=Math.abs(O),ke=[],he=[];let Se=f,ge=Se;const ze=()=>vt(ge,Se,te,fe-ae+1,E,D,U,j.canonical);for(;ae+se<=fe;){if(ee+=$,ee<y||ee>=v)return null;if(te=ie,ge=Se,ke.push(te),F&&he.push(ge),Se=new s.Point(S.getx(ee),S.gety(ee)),ie=C[ee],!ie){const st=Et(Se,j.canonical,E,U,D);ie=st[3]>0?C[ee]=st:ze()}ae+=se,se=s.distance(te,ie)}N&&D&&(C[ee]&&(ie=ze(),se=s.distance(te,ie)),C[ee]=ie);const pe=(fe-ae)/se,Ee=Se.sub(ge)._mult(pe)._add(ge),De=s.sub([],ie,te),Ie=s.scaleAndAdd([],te,De,pe);let Be=[0,0,1],it=De[0],lt=De[1];if(P&&(Be=U.upVector(j.canonical,Ee.x,Ee.y),Be[0]!==0||Be[1]!==0||Be[2]!==1)){const st=[Be[2],0,-Be[0]],wt=s.cross([],Be,st);s.normalize(st,st),s.normalize(wt,wt),it=s.dot(De,st),lt=s.dot(De,wt)}if(o){const st=s.cross([],Be,De);s.normalize(st,st),s.scaleAndAdd(Ie,Ie,st,o*$)}const He=q+Math.atan2(lt,it);return ke.push(Ie),F&&he.push(Ee),{point:Ie,angle:He,path:ke,tilePath:he,up:Be}}function Tr(l,r){const o=r.length,u=o+4*l;r.resize(u),r.float32.fill(-1/0,4*o,4*u)}function bt(l,r,o){const u=r[0],d=r[1];return l[0]=o[0]*u+o[4]*d+o[12],l[1]=o[1]*u+o[5]*d+o[13],l[3]=o[3]*u+o[7]*d+o[15],l}const lr=100;class Jo{constructor(r,o,u=new Dn(r.width+200,r.height+200,25),d=new Dn(r.width+200,r.height+200,25)){this.transform=r,this.grid=u,this.ignoredGrid=d,this.pitchfactor=Math.cos(r._pitch)*r.cameraToCenterDistance,this.screenRightBoundary=r.width+lr,this.screenBottomBoundary=r.height+lr,this.gridRightBoundary=r.width+200,this.gridBottomBoundary=r.height+200,this.fogState=o}placeCollisionBox(r,o,u,d,f,g,y,v){let S=u.projectedAnchorX,E=u.projectedAnchorY,C=u.projectedAnchorZ;const D=u.elevation,F=u.tileID,N=r.getProjection();if(D&&F){const[ie,te,ae]=N.upVector(F.canonical,u.tileAnchorX,u.tileAnchorY),se=N.upVectorScale(F.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;S+=ie*D*se,E+=te*D*se,C+=ae*D*se}const U=this.projectAndGetPerspectiveRatio(y,S,E,C,u.tileID,N.name==="globe"||!!D||this.transform.pitch>0,N),j=g*U.perspectiveRatio,P=(u.x1*o+d.x-u.padding)*j+U.point.x,O=(u.y1*o+d.y-u.padding)*j+U.point.y,$=(u.x2*o+d.x+u.padding)*j+U.point.x,q=(u.y2*o+d.y+u.padding)*j+U.point.y,ee=U.perspectiveRatio<=.55||U.occluded;return!this.isInsideGrid(P,O,$,q)||!f&&this.grid.hitTest(P,O,$,q,v)||ee?{box:[],offscreen:!1,occluded:U.occluded}:{box:[P,O,$,q],offscreen:this.isOffscreen(P,O,$,q),occluded:!1}}placeCollisionCircles(r,o,u,d,f,g,y,v,S,E,C,D,F,N,U){const j=[],P=this.transform.elevation,O=r.getProjection(),$=P?P.getAtTileOffsetFunc(U,this.transform.center.lat,this.transform.worldSize,O):null,q=new s.Point(u.tileAnchorX,u.tileAnchorY);let{x:ee,y:ie,z:te}=O.projectTilePoint(q.x,q.y,U.canonical);if($){const[Ee,De,Ie]=$(q);ee+=Ee,ie+=De,te+=Ie}const ae=O.name==="globe",se=this.projectAndGetPerspectiveRatio(y,ee,ie,te,U,ae||!!P||this.transform.pitch>0,O),{perspectiveRatio:fe}=se,ke=(C?g/fe:g*fe)/s.ONE_EM,he=Ri(ee,ie,te,v),Se=se.signedDistanceFromCamera>0?Ic(ke,f,u.lineOffsetX*ke,u.lineOffsetY*ke,!1,he,q,u,d,v,{},P&&!C?$:null,C&&!!P,O,U,C):null;let ge=!1,ze=!1,pe=!0;if(Se&&!se.occluded){const Ee=.5*F*fe+N,De=new s.Point(-100,-100),Ie=new s.Point(this.screenRightBoundary,this.screenBottomBoundary),Be=new Ka,{first:it,last:lt}=Se,He=it.path.length;let st=[];for(let tt=He-1;tt>=1;tt--)st.push(it.path[tt]);for(let tt=1;tt<lt.path.length;tt++)st.push(lt.path[tt]);const wt=2.5*Ee;S&&(st=st.map(([tt,Ft,jt],Vt)=>($&&!ae&&(jt=$(Vt<He-1?it.tilePath[He-1-Vt]:lt.tilePath[Vt-He+2])[2]),Ri(tt,Ft,jt,S))),st.some(tt=>tt[3]<=0)&&(st=[]));let xt=[];if(st.length>0){let tt=1/0,Ft=-1/0,jt=1/0,Vt=-1/0;for(const Gt of st)tt=Math.min(tt,Gt[0]),jt=Math.min(jt,Gt[1]),Ft=Math.max(Ft,Gt[0]),Vt=Math.max(Vt,Gt[1]);Ft>=De.x&&tt<=Ie.x&&Vt>=De.y&&jt<=Ie.y&&(xt=[st.map(Gt=>new s.Point(Gt[0],Gt[1]))],(tt<De.x||Ft>Ie.x||jt<De.y||Vt>Ie.y)&&(xt=s.clipLine(xt,De.x,De.y,Ie.x,Ie.y)))}for(const tt of xt){Be.reset(tt,.25*Ee);let Ft=0;Ft=Be.length<=.5*Ee?1:Math.ceil(Be.paddedLength/wt)+1;for(let jt=0;jt<Ft;jt++){const Vt=jt/Math.max(Ft-1,1),Gt=Be.lerp(Vt),qi=Gt.x+lr,Oi=Gt.y+lr;j.push(qi,Oi,Ee,0);const _r=qi-Ee,Rr=Oi-Ee,oi=qi+Ee,$t=Oi+Ee;if(pe=pe&&this.isOffscreen(_r,Rr,oi,$t),ze=ze||this.isInsideGrid(_r,Rr,oi,$t),!o&&this.grid.hitTestCircle(qi,Oi,Ee,D)&&(ge=!0,!E))return{circles:[],offscreen:!1,collisionDetected:ge,occluded:!1}}}}return{circles:!E&&ge||!ze?[]:j,offscreen:pe,collisionDetected:ge,occluded:se.occluded}}queryRenderedSymbols(r){if(r.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const o=[];let u=1/0,d=1/0,f=-1/0,g=-1/0;for(const E of r){const C=new s.Point(E.x+lr,E.y+lr);u=Math.min(u,C.x),d=Math.min(d,C.y),f=Math.max(f,C.x),g=Math.max(g,C.y),o.push(C)}const y=this.grid.query(u,d,f,g).concat(this.ignoredGrid.query(u,d,f,g)),v={},S={};for(const E of y){const C=E.key;if(v[C.bucketInstanceId]===void 0&&(v[C.bucketInstanceId]={}),v[C.bucketInstanceId][C.featureIndex])continue;const D=[new s.Point(E.x1,E.y1),new s.Point(E.x2,E.y1),new s.Point(E.x2,E.y2),new s.Point(E.x1,E.y2)];s.polygonIntersectsPolygon(o,D)&&(v[C.bucketInstanceId][C.featureIndex]=!0,S[C.bucketInstanceId]===void 0&&(S[C.bucketInstanceId]=[]),S[C.bucketInstanceId].push(C.featureIndex))}return S}insertCollisionBox(r,o,u,d,f){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:u,featureIndex:d,collisionGroupID:f},r[0],r[1],r[2],r[3])}insertCollisionCircles(r,o,u,d,f){const g=o?this.ignoredGrid:this.grid,y={bucketInstanceId:u,featureIndex:d,collisionGroupID:f};for(let v=0;v<r.length;v+=4)g.insertCircle(y,r[v],r[v+1],r[v+2])}projectAndGetPerspectiveRatio(r,o,u,d,f,g,y){const v=[o,u,d,1];let S=!1;d||this.transform.pitch>0?(s.transformMat4$1(v,v,r),this.fogState&&f&&y.name!=="globe"&&(S=function(D,F,N,U,j,P){const O=P.calculateFogTileMatrix(j),$=[F,N,U];return s.transformMat4($,$,O),Go(D,$,P.pitch,P._fov)}(this.fogState,o,u,d,f.toUnwrapped(),this.transform)>.9)):bt(v,v,r);const E=v[3];return{point:new s.Point((v[0]/E+1)/2*this.transform.width+lr,(-v[1]/E+1)/2*this.transform.height+lr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(y)/E*.5,1.5),signedDistanceFromCamera:E,occluded:g&&v[2]>E||S}}isOffscreen(r,o,u,d){return u<lr||r>=this.screenRightBoundary||d<lr||o>this.screenBottomBoundary}isInsideGrid(r,o,u,d){return u>=0&&r<this.gridRightBoundary&&d>=0&&o<this.gridBottomBoundary}getViewportMatrix(){const r=s.identity([]);return s.translate(r,r,[-100,-100,0]),r}}function Rn(l,r,o){const u=r.createTileMatrix(l,l.worldSize,o.toUnwrapped());return s.multiply(new Float32Array(16),l.projMatrix,u)}function dr(l,r,o){if(r.projection.name===o.projection.name)return l.projMatrix;const u=o.clone();return u.setProjection(r.projection),Rn(u,r.getProjection(),l)}function ni(l,r,o){return r.name===o.projection.name?l.projMatrix:Rn(o,r,l)}class Cc{constructor(r,o,u,d){this.opacity=r?Math.max(0,Math.min(1,r.opacity+(r.placed?o:-o))):d&&u?1:0,this.placed=u}isHidden(){return this.opacity===0&&!this.placed}}class qr{constructor(r,o,u,d,f,g=!1){this.text=new Cc(r?r.text:null,o,u,f),this.icon=new Cc(r?r.icon:null,o,d,f),this.clipped=g}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Yo{constructor(r,o,u,d=!1){this.text=r,this.icon=o,this.skipFade=u,this.clipped=d}}class Qo{constructor(){this.invProjMatrix=s.create(),this.viewportMatrix=s.create(),this.circles=[]}}class Ya{constructor(r,o,u,d,f){this.bucketInstanceId=r,this.featureIndex=o,this.sourceLayerIndex=u,this.bucketIndex=d,this.tileID=f}}class Pc{constructor(r){this.crossSourceCollisions=r,this.maxGroupID=0,this.collisionGroups={}}get(r){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[r]){const o=++this.maxGroupID;this.collisionGroups[r]={ID:o,predicate:u=>u.collisionGroupID===o}}return this.collisionGroups[r]}}function es(l,r,o,u,d){const{horizontalAlign:f,verticalAlign:g}=s.getAnchorAlignment(l),y=-(f-.5)*r,v=-(g-.5)*o,S=s.evaluateVariableOffset(l,u);return new s.Point(y+S[0]*d,v+S[1]*d)}function ts(l,r,o,u,d){const f=new s.Point(l,r);return o&&f._rotate(u?d:-d),f}class Zs{constructor(r,o,u,d,f){this.transform=r.clone(),this.projection=r.projection.name,this.collisionIndex=new Jo(this.transform,f),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Pc(u),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,o,u,d){const f=u.getBucket(o),g=u.latestFeatureIndex;if(!f||!g||o.id!==f.layerIds[0])return;const y=f.layers[0].layout,v=u.collisionBoxArray,S=Math.pow(2,this.transform.zoom-u.tileID.overscaledZ),E=u.tileSize/s.EXTENT,C=u.tileID.toUnwrapped();this.transform.setProjection(f.projection);const D=(F=u.tileID,N=f.getProjection(),U=this.transform,N.name===this.projection?U.calculateProjMatrix(F.toUnwrapped()):Rn(U,N,F));var F,N,U;const j=y.get("text-pitch-alignment")==="map",P=y.get("text-rotation-alignment")==="map";o.compileFilter();const O=o.dynamicFilter(),$=o.dynamicFilterNeedsFeature(),q=this.transform.calculatePixelsToTileUnitsMatrix(u),ee=$r(D,u.tileID.canonical,j,P,this.transform,f.getProjection(),q);let ie=null;if(j){const se=bi(D,u.tileID.canonical,j,P,this.transform,f.getProjection(),q);ie=s.multiply([],this.transform.labelPlaneMatrix,se)}let te=null;O&&u.latestFeatureIndex&&(te={unwrappedTileID:C,dynamicFilter:O,dynamicFilterNeedsFeature:$,featureIndex:u.latestFeatureIndex}),this.retainedQueryData[f.bucketInstanceId]=new Ya(f.bucketInstanceId,g,f.sourceLayerIndex,f.index,u.tileID);const ae={bucket:f,layout:y,posMatrix:D,textLabelPlaneMatrix:ee,labelToScreenMatrix:ie,clippingData:te,scale:S,textPixelRatio:E,holdingForFade:u.holdingForFade(),collisionBoxArray:v,partiallyEvaluatedTextSize:s.evaluateSizeForZoom(f.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:s.evaluateSizeForZoom(f.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(f.sourceID)};if(d)for(const se of f.sortKeyRanges){const{sortKey:fe,symbolInstanceStart:ke,symbolInstanceEnd:he}=se;r.push({sortKey:fe,symbolInstanceStart:ke,symbolInstanceEnd:he,parameters:ae})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:f.symbolInstances.length,parameters:ae})}attemptAnchorPlacement(r,o,u,d,f,g,y,v,S,E,C,D,F,N,U,j,P,O){const{textOffset0:$,textOffset1:q,crossTileID:ee}=D,ie=[$,q],te=es(r,u,d,ie,f),ae=this.collisionIndex.placeCollisionBox(N,f,o,ts(te.x,te.y,g,y,this.transform.angle),C,v,S,E.predicate);if(j){const se=N.getSymbolInstanceIconSize(O,this.transform.zoom,D.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(N,se,j,ts(te.x,te.y,g,y,this.transform.angle),C,v,S,E.predicate).box.length===0)return}if(ae.box.length>0){let se;return this.prevPlacement&&this.prevPlacement.variableOffsets[ee]&&this.prevPlacement.placements[ee]&&this.prevPlacement.placements[ee].text&&(se=this.prevPlacement.variableOffsets[ee].anchor),this.variableOffsets[ee]={textOffset:ie,width:u,height:d,anchor:r,textScale:f,prevAnchor:se},this.markUsedJustification(N,r,D,U),N.allowVerticalPlacement&&(this.markUsedOrientation(N,U,D),this.placedOrientations[ee]=U),{shift:te,placedGlyphBoxes:ae}}}placeLayerBucketPart(r,o,u,d){const{bucket:f,layout:g,posMatrix:y,textLabelPlaneMatrix:v,labelToScreenMatrix:S,clippingData:E,textPixelRatio:C,holdingForFade:D,collisionBoxArray:F,partiallyEvaluatedTextSize:N,partiallyEvaluatedIconSize:U,collisionGroup:j}=r.parameters,P=g.get("text-optional"),O=g.get("icon-optional"),$=g.get("text-allow-overlap"),q=g.get("icon-allow-overlap"),ee=g.get("text-rotation-alignment")==="map",ie=g.get("text-pitch-alignment")==="map",te=g.get("icon-text-fit")!=="none",ae=g.get("symbol-z-order")==="viewport-y";this.transform.setProjection(f.projection);let se=$&&(q||!f.hasIconData()||O),fe=q&&($||!f.hasTextData()||P);!f.collisionArrays&&F&&f.deserializeCollisionBoxes(F),u&&d&&f.updateCollisionDebugBuffers(this.transform.zoom,F);const ke=(he,Se,ge)=>{const{crossTileID:ze,numVerticalGlyphVertices:pe}=he;if(E){const oi={zoom:this.transform.zoom,pitch:this.transform.pitch};let $t=null;if(E.dynamicFilterNeedsFeature){const Dt=this.retainedQueryData[f.bucketInstanceId];$t=E.featureIndex.loadFeature({featureIndex:he.featureIndex,bucketIndex:Dt.bucketIndex,sourceLayerIndex:Dt.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,E.dynamicFilter)(oi,$t,this.retainedQueryData[f.bucketInstanceId].tileID.canonical,new s.Point(he.tileAnchorX,he.tileAnchorY),this.transform.calculateDistanceTileData(E.unwrappedTileID)))return this.placements[ze]=new Yo(!1,!1,!1,!0),void o.add(ze)}if(o.has(ze))return;if(D)return void(this.placements[ze]=new Yo(!1,!1,!1));let Ee=!1,De=!1,Ie=!0,Be=!1,it=!1,lt=null,He={box:null,offscreen:null,occluded:null},st={box:null,offscreen:null,occluded:null},wt=null,xt=null,tt=null,Ft=0,jt=0,Vt=0;ge.textFeatureIndex?Ft=ge.textFeatureIndex:he.useRuntimeCollisionCircles&&(Ft=he.featureIndex),ge.verticalTextFeatureIndex&&(jt=ge.verticalTextFeatureIndex);const Gt=oi=>{oi.tileID=this.retainedQueryData[f.bucketInstanceId].tileID;const $t=this.transform.elevation;($t||oi.elevation)&&(oi.elevation=$t?$t.getAtTileOffset(oi.tileID,oi.tileAnchorX,oi.tileAnchorY):0)},qi=ge.textBox;if(qi){Gt(qi);const oi=Dt=>{let wi=s.WritingMode.horizontal;if(f.allowVerticalPlacement&&!Dt&&this.prevPlacement){const Hi=this.prevPlacement.placedOrientations[ze];Hi&&(this.placedOrientations[ze]=Hi,wi=Hi,this.markUsedOrientation(f,wi,he))}return wi},$t=(Dt,wi)=>{if(f.allowVerticalPlacement&&pe>0&&ge.verticalTextBox){for(const Hi of f.writingModes)if(Hi===s.WritingMode.vertical?(He=wi(),st=He):He=Dt(),He&&He.box&&He.box.length)break}else He=Dt()};if(g.get("text-variable-anchor")){let Dt=g.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[ze]){const ii=this.prevPlacement.variableOffsets[ze];Dt.indexOf(ii.anchor)>0&&(Dt=Dt.filter(Yi=>Yi!==ii.anchor),Dt.unshift(ii.anchor))}const wi=(ii,Yi,xa)=>{const Gn=f.getSymbolInstanceTextSize(N,he,this.transform.zoom,Se),bs=(ii.x2-ii.x1)*Gn+2*ii.padding,Yr=(ii.y2-ii.y1)*Gn+2*ii.padding,yn=te&&!q?Yi:null;yn&&Gt(yn);let $n={box:[],offscreen:!1,occluded:!1};const va=$?2*Dt.length:Dt.length;for(let ws=0;ws<va;++ws){const Vl=this.attemptAnchorPlacement(Dt[ws%Dt.length],ii,bs,Yr,Gn,ee,ie,C,y,j,ws>=Dt.length,he,Se,f,xa,yn,N,U);if(Vl&&($n=Vl.placedGlyphBoxes,$n&&$n.box&&$n.box.length)){Ee=!0,lt=Vl.shift;break}}return $n};$t(()=>wi(qi,ge.iconBox,s.WritingMode.horizontal),()=>{const ii=ge.verticalTextBox;return ii&&Gt(ii),f.allowVerticalPlacement&&!(He&&He.box&&He.box.length)&&pe>0&&ii?wi(ii,ge.verticalIconBox,s.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),He&&(Ee=He.box,Ie=He.offscreen,Be=He.occluded);const Hi=oi(!(!He||!He.box));if(!Ee&&this.prevPlacement){const ii=this.prevPlacement.variableOffsets[ze];ii&&(this.variableOffsets[ze]=ii,this.markUsedJustification(f,ii.anchor,he,Hi))}}else{const Dt=(wi,Hi)=>{const ii=f.getSymbolInstanceTextSize(N,he,this.transform.zoom,Se),Yi=this.collisionIndex.placeCollisionBox(f,ii,wi,new s.Point(0,0),$,C,y,j.predicate);return Yi&&Yi.box&&Yi.box.length&&(this.markUsedOrientation(f,Hi,he),this.placedOrientations[ze]=Hi),Yi};$t(()=>Dt(qi,s.WritingMode.horizontal),()=>{const wi=ge.verticalTextBox;return f.allowVerticalPlacement&&pe>0&&wi?(Gt(wi),Dt(wi,s.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),oi(!!(He&&He.box&&He.box.length))}}if(wt=He,Ee=wt&&wt.box&&wt.box.length>0,Ie=wt&&wt.offscreen,Be=wt&&wt.occluded,he.useRuntimeCollisionCircles){const oi=f.text.placedSymbolArray.get(he.centerJustifiedTextSymbolIndex>=0?he.centerJustifiedTextSymbolIndex:he.verticalPlacedTextSymbolIndex),$t=s.evaluateSizeForFeature(f.textSizeData,N,oi),Dt=g.get("text-padding");xt=this.collisionIndex.placeCollisionCircles(f,$,oi,f.lineVertexArray,f.glyphOffsetArray,$t,y,v,S,u,ie,j.predicate,he.collisionCircleDiameter*$t/s.ONE_EM,Dt,this.retainedQueryData[f.bucketInstanceId].tileID),Ee=$||xt.circles.length>0&&!xt.collisionDetected,Ie=Ie&&xt.offscreen,Be=xt.occluded}if(ge.iconFeatureIndex&&(Vt=ge.iconFeatureIndex),ge.iconBox){const oi=$t=>{Gt($t);const Dt=te&&lt?ts(lt.x,lt.y,ee,ie,this.transform.angle):new s.Point(0,0),wi=f.getSymbolInstanceIconSize(U,this.transform.zoom,he.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(f,wi,$t,Dt,q,C,y,j.predicate)};st&&st.box&&st.box.length&&ge.verticalIconBox?(tt=oi(ge.verticalIconBox),De=tt.box.length>0):(tt=oi(ge.iconBox),De=tt.box.length>0),Ie=Ie&&tt.offscreen,it=tt.occluded}const Oi=P||he.numHorizontalGlyphVertices===0&&pe===0,_r=O||he.numIconVertices===0;if(Oi||_r?_r?Oi||(De=De&&Ee):Ee=De&&Ee:De=Ee=De&&Ee,Ee&&wt&&wt.box&&this.collisionIndex.insertCollisionBox(wt.box,g.get("text-ignore-placement"),f.bucketInstanceId,st&&st.box&&jt?jt:Ft,j.ID),De&&tt&&this.collisionIndex.insertCollisionBox(tt.box,g.get("icon-ignore-placement"),f.bucketInstanceId,Vt,j.ID),xt&&(Ee&&this.collisionIndex.insertCollisionCircles(xt.circles,g.get("text-ignore-placement"),f.bucketInstanceId,Ft,j.ID),u)){const oi=f.bucketInstanceId;let $t=this.collisionCircleArrays[oi];$t===void 0&&($t=this.collisionCircleArrays[oi]=new Qo);for(let Dt=0;Dt<xt.circles.length;Dt+=4)$t.circles.push(xt.circles[Dt+0]),$t.circles.push(xt.circles[Dt+1]),$t.circles.push(xt.circles[Dt+2]),$t.circles.push(xt.collisionDetected?1:0)}const Rr=f.projection.name!=="globe";se=se&&(Rr||!Be),fe=fe&&(Rr||!it),this.placements[ze]=new Yo(Ee||se,De||fe,Ie||f.justReloaded),o.add(ze)};if(ae){const he=f.getSortedSymbolIndexes(this.transform.angle);for(let Se=he.length-1;Se>=0;--Se){const ge=he[Se];ke(f.symbolInstances.get(ge),ge,f.collisionArrays[ge])}}else for(let he=r.symbolInstanceStart;he<r.symbolInstanceEnd;he++)ke(f.symbolInstances.get(he),he,f.collisionArrays[he]);if(u&&f.bucketInstanceId in this.collisionCircleArrays){const he=this.collisionCircleArrays[f.bucketInstanceId];s.invert(he.invProjMatrix,y),he.viewportMatrix=this.collisionIndex.getViewportMatrix()}f.justReloaded=!1}markUsedJustification(r,o,u,d){const{leftJustifiedTextSymbolIndex:f,centerJustifiedTextSymbolIndex:g,rightJustifiedTextSymbolIndex:y,verticalPlacedTextSymbolIndex:v,crossTileID:S}=u,E=s.getAnchorJustification(o),C=d===s.WritingMode.vertical?v:E==="left"?f:E==="center"?g:E==="right"?y:-1;f>=0&&(r.text.placedSymbolArray.get(f).crossTileID=C>=0&&f!==C?0:S),g>=0&&(r.text.placedSymbolArray.get(g).crossTileID=C>=0&&g!==C?0:S),y>=0&&(r.text.placedSymbolArray.get(y).crossTileID=C>=0&&y!==C?0:S),v>=0&&(r.text.placedSymbolArray.get(v).crossTileID=C>=0&&v!==C?0:S)}markUsedOrientation(r,o,u){const d=o===s.WritingMode.horizontal||o===s.WritingMode.horizontalOnly?o:0,f=o===s.WritingMode.vertical?o:0,{leftJustifiedTextSymbolIndex:g,centerJustifiedTextSymbolIndex:y,rightJustifiedTextSymbolIndex:v,verticalPlacedTextSymbolIndex:S}=u,E=r.text.placedSymbolArray;g>=0&&(E.get(g).placedOrientation=d),y>=0&&(E.get(y).placedOrientation=d),v>=0&&(E.get(v).placedOrientation=d),S>=0&&(E.get(S).placedOrientation=f)}commit(r){this.commitTime=r,this.zoomAtLastRecencyCheck=this.transform.zoom;const o=this.prevPlacement;let u=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;const d=o?o.symbolFadeChange(r):1,f=o?o.opacities:{},g=o?o.variableOffsets:{},y=o?o.placedOrientations:{};for(const v in this.placements){const S=this.placements[v],E=f[v];E?(this.opacities[v]=new qr(E,d,S.text,S.icon,null,S.clipped),u=u||S.text!==E.text.placed||S.icon!==E.icon.placed):(this.opacities[v]=new qr(null,d,S.text,S.icon,S.skipFade,S.clipped),u=u||S.text||S.icon)}for(const v in f){const S=f[v];if(!this.opacities[v]){const E=new qr(S,d,!1,!1);E.isHidden()||(this.opacities[v]=E,u=u||S.text.placed||S.icon.placed)}}for(const v in g)this.variableOffsets[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.variableOffsets[v]=g[v]);for(const v in y)this.placedOrientations[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.placedOrientations[v]=y[v]);u?this.lastPlacementChangeTime=r:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:r)}updateLayerOpacities(r,o){const u=new Set;for(const d of o){const f=d.getBucket(r);f&&d.latestFeatureIndex&&r.id===f.layerIds[0]&&this.updateBucketOpacities(f,u,d.collisionBoxArray)}}updateBucketOpacities(r,o,u){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const d=r.layers[0].layout,f=!!r.layers[0].dynamicFilter(),g=new qr(null,0,!1,!1,!0),y=d.get("text-allow-overlap"),v=d.get("icon-allow-overlap"),S=d.get("text-variable-anchor"),E=d.get("text-rotation-alignment")==="map",C=d.get("text-pitch-alignment")==="map",D=d.get("icon-text-fit")!=="none",F=new qr(null,0,y&&(v||!r.hasIconData()||d.get("icon-optional")),v&&(y||!r.hasTextData()||d.get("text-optional")),!0);!r.collisionArrays&&u&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(u);const N=(j,P,O)=>{for(let $=0;$<P/4;$++)j.opacityVertexArray.emplaceBack(O)};let U=0;for(let j=0;j<r.symbolInstances.length;j++){const P=r.symbolInstances.get(j),{numHorizontalGlyphVertices:O,numVerticalGlyphVertices:$,crossTileID:q,numIconVertices:ee}=P,ie=o.has(q);let te=this.opacities[q];ie?te=g:te||(te=F,this.opacities[q]=te),o.add(q);const ae=O>0||$>0,se=ee>0,fe=this.placedOrientations[q],ke=fe===s.WritingMode.vertical,he=fe===s.WritingMode.horizontal||fe===s.WritingMode.horizontalOnly;if(!ae&&!se||te.isHidden()||U++,ae){const Se=is(te.text);N(r.text,O,ke?fi:Se),N(r.text,$,he?fi:Se);const ge=te.text.isHidden(),{leftJustifiedTextSymbolIndex:ze,centerJustifiedTextSymbolIndex:pe,rightJustifiedTextSymbolIndex:Ee,verticalPlacedTextSymbolIndex:De}=P,Ie=r.text.placedSymbolArray,Be=ge||ke?1:0;ze>=0&&(Ie.get(ze).hidden=Be),pe>=0&&(Ie.get(pe).hidden=Be),Ee>=0&&(Ie.get(Ee).hidden=Be),De>=0&&(Ie.get(De).hidden=ge||he?1:0);const it=this.variableOffsets[q];it&&this.markUsedJustification(r,it.anchor,P,fe);const lt=this.placedOrientations[q];lt&&(this.markUsedJustification(r,"left",P,lt),this.markUsedOrientation(r,lt,P))}if(se){const Se=is(te.icon),{placedIconSymbolIndex:ge,verticalPlacedIconSymbolIndex:ze}=P,pe=r.icon.placedSymbolArray,Ee=te.icon.isHidden()?1:0;ge>=0&&(N(r.icon,ee,ke?fi:Se),pe.get(ge).hidden=Ee),ze>=0&&(N(r.icon,P.numVerticalIconVertices,he?fi:Se),pe.get(ze).hidden=Ee)}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const Se=r.collisionArrays[j];if(Se){let ge=new s.Point(0,0),ze=!0;if(Se.textBox||Se.verticalTextBox){if(S){const Ee=this.variableOffsets[q];Ee?(ge=es(Ee.anchor,Ee.width,Ee.height,Ee.textOffset,Ee.textScale),E&&ge._rotate(C?this.transform.angle:-this.transform.angle)):ze=!1}f&&(ze=!te.clipped),Se.textBox&&co(r.textCollisionBox.collisionVertexArray,te.text.placed,!ze||ke,ge.x,ge.y),Se.verticalTextBox&&co(r.textCollisionBox.collisionVertexArray,te.text.placed,!ze||he,ge.x,ge.y)}const pe=ze&&!!(!he&&Se.verticalIconBox);Se.iconBox&&co(r.iconCollisionBox.collisionVertexArray,te.icon.placed,pe,D?ge.x:0,D?ge.y:0),Se.verticalIconBox&&co(r.iconCollisionBox.collisionVertexArray,te.icon.placed,!pe,D?ge.x:0,D?ge.y:0)}}}if(r.fullyClipped=U===0,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const j=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=j.invProjMatrix,r.placementViewportMatrix=j.viewportMatrix,r.collisionCircleArray=j.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(r){return this.fadeDuration===0?1:(r-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(r){return Math.max(0,(this.transform.zoom-r)/1.5)}hasTransitions(r){return this.stale||r-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(r,o){const u=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*u>r}setStale(){this.stale=!0}}function co(l,r,o,u,d){l.emplaceBack(r?1:0,o?1:0,u||0,d||0),l.emplaceBack(r?1:0,o?1:0,u||0,d||0),l.emplaceBack(r?1:0,o?1:0,u||0,d||0),l.emplaceBack(r?1:0,o?1:0,u||0,d||0)}const Ki=Math.pow(2,25),gi=Math.pow(2,24),Qa=Math.pow(2,17),el=Math.pow(2,16),Ji=Math.pow(2,9),pr=Math.pow(2,8),zc=Math.pow(2,1);function is(l){if(l.opacity===0&&!l.placed)return 0;if(l.opacity===1&&l.placed)return 4294967295;const r=l.placed?1:0,o=Math.floor(127*l.opacity);return o*Ki+r*gi+o*Qa+r*el+o*Ji+r*pr+o*zc+r}const fi=0;class rs{constructor(r){this._sortAcrossTiles=r.layout.get("symbol-z-order")!=="viewport-y"&&r.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(r,o,u,d,f){const g=this._bucketParts;for(;this._currentTileIndex<r.length;)if(o.getBucketParts(g,d,r[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,f())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort((y,v)=>y.sortKey-v.sortKey));this._currentPartIndex<g.length;){const y=g[this._currentPartIndex];if(o.placeLayerBucketPart(y,this._seenCrossTileIDs,u,y.symbolInstanceStart===0),this._currentPartIndex++,f())return!0}return!1}}class tl{constructor(r,o,u,d,f,g,y,v){this.placement=new Zs(r,f,g,y,v),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=u,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(r,o,u){const d=s.exported.now(),f=()=>{const g=s.exported.now()-d;return!this._forceFullPlacement&&g>2};for(;this._currentPlacementIndex>=0;){const g=o[r[this._currentPlacementIndex]],y=this.placement.collisionIndex.transform.zoom;if(g.type==="symbol"&&(!g.minzoom||g.minzoom<=y)&&(!g.maxzoom||g.maxzoom>y)){if(this._inProgressLayer||(this._inProgressLayer=new rs(g)),this._inProgressLayer.continuePlacement(u[g.source],this.placement,this._showCollisionBoxes,g,f))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(r){return this.placement.commit(r),this.placement}}const Bn=512/s.EXTENT/2;class Ni{constructor(r,o,u){this.tileID=r,this.bucketInstanceId=u,this.index=new s.KDBush(o.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const d=r.canonical.x*s.EXTENT,f=r.canonical.y*s.EXTENT;for(let g=0;g<o.length;g++){const{key:y,crossTileID:v,tileAnchorX:S,tileAnchorY:E}=o.get(g),C=Math.floor((d+S)*Bn),D=Math.floor((f+E)*Bn);this.index.add(C,D),this.keys.push(y),this.crossTileIDs.push(v)}this.index.finish()}findMatches(r,o,u){const d=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z),f=Bn/Math.pow(2,o.canonical.z-this.tileID.canonical.z),g=o.canonical.x*s.EXTENT,y=o.canonical.y*s.EXTENT;for(let v=0;v<r.length;v++){const S=r.get(v);if(S.crossTileID)continue;const{key:E,tileAnchorX:C,tileAnchorY:D}=S,F=Math.floor((g+C)*f),N=Math.floor((y+D)*f),U=this.index.range(F-d,N-d,F+d,N+d);for(const j of U){const P=this.crossTileIDs[j];if(this.keys[j]===E&&!u.has(P)){u.add(P),S.crossTileID=P;break}}}}}class il{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class rl{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(r){const o=Math.round((r-this.lng)/360);if(o!==0)for(const u in this.indexes){const d=this.indexes[u],f={};for(const g in d){const y=d[g];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+o),f[y.tileID.key]=y}this.indexes[u]=f}this.lng=r}addBucket(r,o,u){if(this.indexes[r.overscaledZ]&&this.indexes[r.overscaledZ][r.key]){if(this.indexes[r.overscaledZ][r.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(r.overscaledZ,this.indexes[r.overscaledZ][r.key])}for(let f=0;f<o.symbolInstances.length;f++)o.symbolInstances.get(f).crossTileID=0;this.usedCrossTileIDs[r.overscaledZ]||(this.usedCrossTileIDs[r.overscaledZ]=new Set);const d=this.usedCrossTileIDs[r.overscaledZ];for(const f in this.indexes){const g=this.indexes[f];if(Number(f)>r.overscaledZ)for(const y in g){const v=g[y];v.tileID.isChildOf(r)&&v.findMatches(o.symbolInstances,r,d)}else{const y=g[r.scaledTo(Number(f)).key];y&&y.findMatches(o.symbolInstances,r,d)}}for(let f=0;f<o.symbolInstances.length;f++){const g=o.symbolInstances.get(f);g.crossTileID||(g.crossTileID=u.generate(),d.add(g.crossTileID))}return this.indexes[r.overscaledZ]===void 0&&(this.indexes[r.overscaledZ]={}),this.indexes[r.overscaledZ][r.key]=new Ni(r,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(r,o){for(const u of o.crossTileIDs)this.usedCrossTileIDs[r].delete(u)}removeStaleBuckets(r){let o=!1;for(const u in this.indexes){const d=this.indexes[u];for(const f in d)r[d[f].bucketInstanceId]||(this.removeBucketCrossTileIDs(u,d[f]),delete d[f],o=!0)}return o}}class Zr{constructor(){this.layerIndexes={},this.crossTileIDs=new il,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(r,o,u,d){let f=this.layerIndexes[r.id];f===void 0&&(f=this.layerIndexes[r.id]=new rl);let g=!1;const y={};d.name!=="globe"&&f.handleWrapJump(u);for(const v of o){const S=v.getBucket(r);S&&r.id===S.layerIds[0]&&(S.bucketInstanceId||(S.bucketInstanceId=++this.maxBucketInstanceId),f.addBucket(v.tileID,S,this.crossTileIDs)&&(g=!0),y[S.bucketInstanceId]=!0)}return f.removeStaleBuckets(y)&&(g=!0),g}pruneUnusedLayers(r){const o={};r.forEach(u=>{o[u]=!0});for(const u in this.layerIndexes)o[u]||delete this.layerIndexes[u]}}const _n=(l,r)=>s.emitValidationErrors(l,r&&r.filter(o=>o.identifier!=="source.canvas")),Ws=s.pick(Bt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),ah=s.pick(Bt,["setCenter","setZoom","setBearing","setPitch"]),nl={version:8,layers:[],sources:{}},uo={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class kr extends s.Evented{constructor(r,o={}){super(),this.map=r,this.dispatcher=new zi(ao(),this),this.imageManager=new Vo,this.imageManager.setEventedParent(this),this.glyphManager=new s.GlyphManager(r._requestManager,o.localFontFamily?s.LocalGlyphMode.all:o.localIdeographFontFamily?s.LocalGlyphMode.ideographs:s.LocalGlyphMode.none,o.localFontFamily||o.localIdeographFontFamily),this.crossTileSymbolIndex=new Zr,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",s.getReferrer());const u=this;this._rtlTextPluginCallback=kr.registerForPluginStateChange(d=>{u.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:d.pluginStatus,pluginURL:d.pluginURL},(f,g)=>{if(s.triggerPluginCompletionEvent(f),g&&g.every(y=>y))for(const y in u._sourceCaches){const v=u._sourceCaches[y],S=v.getSource().type;S!=="vector"&&S!=="geojson"||v.reload()}})}),this.on("data",d=>{if(d.dataType!=="source"||d.sourceDataType!=="metadata")return;const f=this.getSource(d.sourceId);if(f&&f.vectorLayerIds)for(const g in this._layers){const y=this._layers[g];y.source===f.id&&this._validateLayer(y)}})}loadURL(r,o={}){this.fire(new s.Event("dataloading",{dataType:"style"}));const u=typeof o.validate=="boolean"?o.validate:!s.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,o.accessToken);const d=this.map._requestManager.transformRequest(r,s.ResourceType.Style);this._request=s.getJSON(d,(f,g)=>{this._request=null,f?this.fire(new s.ErrorEvent(f)):g&&this._load(g,u)})}loadJSON(r,o={}){this.fire(new s.Event("dataloading",{dataType:"style"})),this._request=s.exported.frame(()=>{this._request=null,this._load(r,o.validate!==!1)})}loadEmpty(){this.fire(new s.Event("dataloading",{dataType:"style"})),this._load(nl,!1)}_updateLayerCount(r,o){const u=o?1:-1;r.is3D()&&(this._num3DLayers+=u),r.type==="circle"&&(this._numCircleLayers+=u),r.type==="symbol"&&(this._numSymbolLayers+=u)}_load(r,o){if(o&&_n(this,s.validateStyle(r)))return;this._loaded=!0,this.stylesheet=s.clone$1(r),this._updateMapProjection();for(const d in r.sources)this.addSource(d,r.sources[d],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const u=Ac(this.stylesheet.layers);this._order=u.map(d=>d.id),this._layers={},this._serializedLayers={};for(const d of u){const f=s.createStyleLayer(d);f.setEventedParent(this,{layer:{id:f.id}}),this._layers[f.id]=f,this._serializedLayers[f.id]=f.serialize(),this._updateLayerCount(f,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new ki(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new s.Event("data",{dataType:"style"})),this.fire(new s.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(r){r?this.stylesheet.projection=r:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(r){this._spriteRequest=function(o,u,d){let f,g,y;const v=s.exported.devicePixelRatio>1?"@2x":"";let S=s.getJSON(u.transformRequest(u.normalizeSpriteURL(o,v,".json"),s.ResourceType.SpriteJSON),(D,F)=>{S=null,y||(y=D,f=F,C())}),E=s.getImage(u.transformRequest(u.normalizeSpriteURL(o,v,".png"),s.ResourceType.SpriteImage),(D,F)=>{E=null,y||(y=D,g=F,C())});function C(){if(y)d(y);else if(f&&g){const D=s.exported.getImageData(g),F={};for(const N in f){const{width:U,height:j,x:P,y:O,sdf:$,pixelRatio:q,stretchX:ee,stretchY:ie,content:te}=f[N],ae=new s.RGBAImage({width:U,height:j});s.RGBAImage.copy(D,ae,{x:P,y:O},{x:0,y:0},{width:U,height:j}),F[N]={data:ae,pixelRatio:q,sdf:$,stretchX:ee,stretchY:ie,content:te}}d(null,F)}}return{cancel(){S&&(S.cancel(),S=null),E&&(E.cancel(),E=null)}}}(r,this.map._requestManager,(o,u)=>{if(this._spriteRequest=null,o)this.fire(new s.ErrorEvent(o));else if(u)for(const d in u)this.imageManager.addImage(d,u[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new s.Event("data",{dataType:"style"}))})}_validateLayer(r){const o=this.getSource(r.source);if(!o)return;const u=r.sourceLayer;u&&(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(u)===-1)&&this.fire(new s.ErrorEvent(new Error(`Source layer "${u}" does not exist on source "${o.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const r in this._sourceCaches)if(!this._sourceCaches[r].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(r){const o=[];for(const u of r){const d=this._layers[u];d.type!=="custom"&&o.push(d.serialize())}return o}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const r in this._sourceCaches)if(this._sourceCaches[r].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(r){return!!this.terrain&&(typeof r.isLayerDraped=="function"?r.isLayerDraped():uo[r.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(r){if(!this._loaded)return;const o=this._changed;if(this._changed){const d=Object.keys(this._updatedLayers),f=Object.keys(this._removedLayers);(d.length||f.length)&&this._updateWorkerLayers(d,f);for(const g in this._updatedSources){const y=this._updatedSources[g];y==="reload"?this._reloadSource(g):y==="clear"&&this._clearSource(g)}this._updateTilesForChangedImages();for(const g in this._updatedPaintProps)this._layers[g].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const u={};for(const d in this._sourceCaches){const f=this._sourceCaches[d];u[d]=f.used,f.used=!1}for(const d of this._order){const f=this._layers[d];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const y=this._getLayerSourceCache(f);y&&(y.used=!0)}const g=this.map.painter;if(g){const y=f.getProgramIds();if(!y)continue;const v=f.getProgramConfiguration(r.zoom);for(const S of y)g.useProgram(S,v)}}for(const d in u){const f=this._sourceCaches[d];u[d]!==f.used&&f.getSource().fire(new s.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:f.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),o&&this.fire(new s.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const r=Object.keys(this._changedImages);if(r.length){for(const o in this._sourceCaches)this._sourceCaches[o].reloadTilesForDependencies(["icons","patterns"],r);this._changedImages={}}}_updateWorkerLayers(r,o){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(r),removedIds:o})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),_n(this,s.validateStyle(r)))return!1;(r=s.clone$1(r)).layers=Ac(r.layers);const o=function(d,f){if(!d)return[{command:Bt.setStyle,args:[f]}];let g=[];try{if(!le(d.version,f.version))return[{command:Bt.setStyle,args:[f]}];le(d.center,f.center)||g.push({command:Bt.setCenter,args:[f.center]}),le(d.zoom,f.zoom)||g.push({command:Bt.setZoom,args:[f.zoom]}),le(d.bearing,f.bearing)||g.push({command:Bt.setBearing,args:[f.bearing]}),le(d.pitch,f.pitch)||g.push({command:Bt.setPitch,args:[f.pitch]}),le(d.sprite,f.sprite)||g.push({command:Bt.setSprite,args:[f.sprite]}),le(d.glyphs,f.glyphs)||g.push({command:Bt.setGlyphs,args:[f.glyphs]}),le(d.transition,f.transition)||g.push({command:Bt.setTransition,args:[f.transition]}),le(d.light,f.light)||g.push({command:Bt.setLight,args:[f.light]}),le(d.fog,f.fog)||g.push({command:Bt.setFog,args:[f.fog]}),le(d.projection,f.projection)||g.push({command:Bt.setProjection,args:[f.projection]});const y={},v=[];(function(C,D,F,N){let U;for(U in D=D||{},C=C||{})C.hasOwnProperty(U)&&(D.hasOwnProperty(U)||Ho(U,F,N));for(U in D){if(!D.hasOwnProperty(U))continue;const j=D[U];C.hasOwnProperty(U)?le(C[U],j)||(C[U].type==="geojson"&&j.type==="geojson"&&qs(C,D,U)?F.push({command:Bt.setGeoJSONSourceData,args:[U,j.data]}):Xa(U,D,F,N)):Wa(U,D,F)}})(d.sources,f.sources,v,y);const S=[];d.layers&&d.layers.forEach(C=>{C.source&&y[C.source]?g.push({command:Bt.removeLayer,args:[C.id]}):S.push(C)});let E=d.terrain;E&&y[E.source]&&(g.push({command:Bt.setTerrain,args:[void 0]}),E=void 0),g=g.concat(v),le(E,f.terrain)||g.push({command:Bt.setTerrain,args:[f.terrain]}),function(C,D,F){D=D||[];const N=(C=C||[]).map(Vr),U=D.map(Vr),j=C.reduce(Ha,{}),P=D.reduce(Ha,{}),O=N.slice(),$=Object.create(null);let q,ee,ie,te,ae,se,fe;for(q=0,ee=0;q<N.length;q++)ie=N[q],P.hasOwnProperty(ie)?ee++:(F.push({command:Bt.removeLayer,args:[ie]}),O.splice(O.indexOf(ie,ee),1));for(q=0,ee=0;q<U.length;q++)ie=U[U.length-1-q],O[O.length-1-q]!==ie&&(j.hasOwnProperty(ie)?(F.push({command:Bt.removeLayer,args:[ie]}),O.splice(O.lastIndexOf(ie,O.length-ee),1)):ee++,se=O[O.length-q],F.push({command:Bt.addLayer,args:[P[ie],se]}),O.splice(O.length-q,0,ie),$[ie]=!0);for(q=0;q<U.length;q++)if(ie=U[q],te=j[ie],ae=P[ie],!$[ie]&&!le(te,ae))if(le(te.source,ae.source)&&le(te["source-layer"],ae["source-layer"])&&le(te.type,ae.type)){for(fe in Pr(te.layout,ae.layout,F,ie,null,Bt.setLayoutProperty),Pr(te.paint,ae.paint,F,ie,null,Bt.setPaintProperty),le(te.filter,ae.filter)||F.push({command:Bt.setFilter,args:[ie,ae.filter]}),le(te.minzoom,ae.minzoom)&&le(te.maxzoom,ae.maxzoom)||F.push({command:Bt.setLayerZoomRange,args:[ie,ae.minzoom,ae.maxzoom]}),te)te.hasOwnProperty(fe)&&fe!=="layout"&&fe!=="paint"&&fe!=="filter"&&fe!=="metadata"&&fe!=="minzoom"&&fe!=="maxzoom"&&(fe.indexOf("paint.")===0?Pr(te[fe],ae[fe],F,ie,fe.slice(6),Bt.setPaintProperty):le(te[fe],ae[fe])||F.push({command:Bt.setLayerProperty,args:[ie,fe,ae[fe]]}));for(fe in ae)ae.hasOwnProperty(fe)&&!te.hasOwnProperty(fe)&&fe!=="layout"&&fe!=="paint"&&fe!=="filter"&&fe!=="metadata"&&fe!=="minzoom"&&fe!=="maxzoom"&&(fe.indexOf("paint.")===0?Pr(te[fe],ae[fe],F,ie,fe.slice(6),Bt.setPaintProperty):le(te[fe],ae[fe])||F.push({command:Bt.setLayerProperty,args:[ie,fe,ae[fe]]}))}else F.push({command:Bt.removeLayer,args:[ie]}),se=O[O.lastIndexOf(ie)+1],F.push({command:Bt.addLayer,args:[ae,se]})}(S,f.layers,g)}catch(y){console.warn("Unable to compute style diff:",y),g=[{command:Bt.setStyle,args:[f]}]}return g}(this.serialize(),r).filter(d=>!(d.command in ah));if(o.length===0)return!1;const u=o.filter(d=>!(d.command in Ws));if(u.length>0)throw new Error(`Unimplemented: ${u.map(d=>d.command).join(", ")}.`);return o.forEach(d=>{d.command!=="setTransition"&&d.command!=="setProjection"&&this[d.command].apply(this,d.args)}),this.stylesheet=r,this._updateMapProjection(),!0}addImage(r,o){return this.getImage(r)?this.fire(new s.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(r,o),this._afterImageUpdated(r),this)}updateImage(r,o){this.imageManager.updateImage(r,o)}getImage(r){return this.imageManager.getImage(r)}removeImage(r){return this.getImage(r)?(this.imageManager.removeImage(r),this._afterImageUpdated(r),this):this.fire(new s.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,o,u={}){if(this._checkLoaded(),this.getSource(r)!==void 0)throw new Error("There is already a source with this ID");if(!o.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(o).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(o.type)>=0&&this._validate(s.validateSource,`sources.${r}`,o,null,u))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);const d=yt(r,o,this.dispatcher,this);d.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r),source:d.serialize(),sourceId:r}));const f=g=>{const y=(g?"symbol:":"other:")+r,v=this._sourceCaches[y]=new s.SourceCache(y,d,g);(g?this._symbolSourceCaches:this._otherSourceCaches)[r]=v,v.style=this,v.onAdd(this.map)};f(!1),o.type!=="vector"&&o.type!=="geojson"||f(!0),d.onAdd&&d.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const o=this.getSource(r);if(!o)throw new Error("There is no source with this ID");for(const d in this._layers)if(this._layers[d].source===r)return this.fire(new s.ErrorEvent(new Error(`Source "${r}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new s.ErrorEvent(new Error(`Source "${r}" cannot be removed while terrain is using it.`)));const u=this._getSourceCaches(r);for(const d of u)delete this._sourceCaches[d.id],delete this._updatedSources[d.id],d.fire(new s.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles();return delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(r,o){this._checkLoaded(),this.getSource(r).setData(o),this._changed=!0}getSource(r){const o=this._getSourceCache(r);return o&&o.getSource()}_getSources(){const r=[];for(const o in this._otherSourceCaches){const u=this._getSourceCache(o);u&&r.push(u.getSource())}return r}addLayer(r,o,u={}){this._checkLoaded();const d=r.id;if(this.getLayer(d))return void this.fire(new s.ErrorEvent(new Error(`Layer with id "${d}" already exists on this map`)));let f;if(r.type==="custom"){if(_n(this,s.validateCustomStyleLayer(r)))return;f=s.createStyleLayer(r)}else{if(typeof r.source=="object"&&(this.addSource(d,r.source),r=s.clone$1(r),r=s.extend(r,{source:d})),this._validate(s.validateLayer,`layers.${d}`,r,{arrayIndex:-1},u))return;f=s.createStyleLayer(r),this._validateLayer(f),f.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[f.id]=f.serialize(),this._updateLayerCount(f,!0)}const g=o?this._order.indexOf(o):this._order.length;if(o&&g===-1)return void this.fire(new s.ErrorEvent(new Error(`Layer with id "${o}" does not exist on this map.`)));this._order.splice(g,0,d),this._layerOrderChanged=!0,this._layers[d]=f;const y=this._getLayerSourceCache(f);if(this._removedLayers[d]&&f.source&&y&&f.type!=="custom"){const v=this._removedLayers[d];delete this._removedLayers[d],v.type!==f.type?this._updatedSources[f.source]="clear":(this._updatedSources[f.source]="reload",y.pause())}this._updateLayer(f),f.onAdd&&f.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,o){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===o)return;const u=this._order.indexOf(r);this._order.splice(u,1);const d=o?this._order.indexOf(o):this._order.length;o&&d===-1?this.fire(new s.ErrorEvent(new Error(`Layer with id "${o}" does not exist on this map.`))):(this._order.splice(d,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const o=this._layers[r];if(!o)return void this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));o.setEventedParent(null),this._updateLayerCount(o,!1);const u=this._order.indexOf(r);this._order.splice(u,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=o,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],o.onRemove&&o.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(r){return this._layers[r]}hasLayer(r){return r in this._layers}hasLayerType(r){for(const o in this._layers)if(this._layers[o].type===r)return!0;return!1}setLayerZoomRange(r,o,u){this._checkLoaded();const d=this.getLayer(r);d?d.minzoom===o&&d.maxzoom===u||(o!=null&&(d.minzoom=o),u!=null&&(d.maxzoom=u),this._updateLayer(d)):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,o,u={}){this._checkLoaded();const d=this.getLayer(r);if(d){if(!le(d.filter,o))return o==null?(d.filter=void 0,void this._updateLayer(d)):void(this._validate(s.validateFilter,`layers.${d.id}.filter`,o,{layerType:d.type},u)||(d.filter=s.clone$1(o),this._updateLayer(d)))}else this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){const o=this.getLayer(r);return o&&s.clone$1(o.filter)}setLayoutProperty(r,o,u,d={}){this._checkLoaded();const f=this.getLayer(r);f?le(f.getLayoutProperty(o),u)||(f.setLayoutProperty(o,u,d),this._updateLayer(f)):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,o){const u=this.getLayer(r);if(u)return u.getLayoutProperty(o);this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,o,u,d={}){this._checkLoaded();const f=this.getLayer(r);f?le(f.getPaintProperty(o),u)||(f.setPaintProperty(o,u,d)&&this._updateLayer(f),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new s.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(r,o){const u=this.getLayer(r);return u&&u.getPaintProperty(o)}setFeatureState(r,o){this._checkLoaded();const u=r.source,d=r.sourceLayer,f=this.getSource(u);if(!f)return void this.fire(new s.ErrorEvent(new Error(`The source '${u}' does not exist in the map's style.`)));const g=f.type;if(g==="geojson"&&d)return void this.fire(new s.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(g==="vector"&&!d)return void this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));r.id===void 0&&this.fire(new s.ErrorEvent(new Error("The feature id parameter must be provided.")));const y=this._getSourceCaches(u);for(const v of y)v.setFeatureState(d,r.id,o)}removeFeatureState(r,o){this._checkLoaded();const u=r.source,d=this.getSource(u);if(!d)return void this.fire(new s.ErrorEvent(new Error(`The source '${u}' does not exist in the map's style.`)));const f=d.type,g=f==="vector"?r.sourceLayer:void 0;if(f==="vector"&&!g)return void this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&typeof r.id!="string"&&typeof r.id!="number")return void this.fire(new s.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const y=this._getSourceCaches(u);for(const v of y)v.removeFeatureState(g,r.id,o)}getFeatureState(r){this._checkLoaded();const o=r.source,u=r.sourceLayer,d=this.getSource(o);if(d){if(d.type!=="vector"||u)return r.id===void 0&&this.fire(new s.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(o)[0].getFeatureState(u,r.id);this.fire(new s.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new s.ErrorEvent(new Error(`The source '${o}' does not exist in the map's style.`)))}getTransition(){return s.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const o in this._sourceCaches){const u=this._sourceCaches[o].getSource();r[u.id]||(r[u.id]=u.serialize())}return s.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:r,layers:this._serializeLayers(this._order)},o=>o!==void 0)}_updateLayer(r){this._updatedLayers[r.id]=!0;const o=this._getLayerSourceCache(r);r.source&&!this._updatedSources[r.source]&&o&&o.getSource().type!=="raster"&&(this._updatedSources[r.source]="reload",o.pause()),this._changed=!0,r.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(r){const o=g=>this._layers[g].type==="fill-extrusion",u={},d=[];for(let g=this._order.length-1;g>=0;g--){const y=this._order[g];if(o(y)){u[y]=g;for(const v of r){const S=v[y];if(S)for(const E of S)d.push(E)}}}d.sort((g,y)=>y.intersectionZ-g.intersectionZ);const f=[];for(let g=this._order.length-1;g>=0;g--){const y=this._order[g];if(o(y))for(let v=d.length-1;v>=0;v--){const S=d[v].feature;if(u[S.layer.id]<g)break;f.push(S),d.pop()}else for(const v of r){const S=v[y];if(S)for(const E of S)f.push(E.feature)}}return f}queryRenderedFeatures(r,o,u){o&&o.filter&&this._validate(s.validateFilter,"queryRenderedFeatures.filter",o.filter,null,o);const d={};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new s.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const v of o.layers){const S=this._layers[v];if(!S)return this.fire(new s.ErrorEvent(new Error(`The layer '${v}' does not exist in the map's style and cannot be queried for features.`))),[];d[S.source]=!0}}const f=[];o.availableImages=this._availableImages;const g=o&&o.layers?o.layers.some(v=>{const S=this.getLayer(v);return S&&S.is3D()}):this.has3DLayers(),y=un.createFromScreenPoints(r,u);for(const v in this._sourceCaches){const S=this._sourceCaches[v].getSource().id;o.layers&&!d[S]||f.push(ci(this._sourceCaches[v],this._layers,this._serializedLayers,y,o,u,g,!!this.map._showQueryGeometry))}return this.placement&&f.push(function(v,S,E,C,D,F,N){const U={},j=F.queryRenderedSymbols(C),P=[];for(const O of Object.keys(j).map(Number))P.push(N[O]);P.sort(Gi);for(const O of P){const $=O.featureIndex.lookupSymbolFeatures(j[O.bucketInstanceId],S,O.bucketIndex,O.sourceLayerIndex,D.filter,D.layers,D.availableImages,v);for(const q in $){const ee=U[q]=U[q]||[],ie=$[q];ie.sort((te,ae)=>{const se=O.featureSortOrder;if(se){const fe=se.indexOf(te.featureIndex);return se.indexOf(ae.featureIndex)-fe}return ae.featureIndex-te.featureIndex});for(const te of ie)ee.push(te)}}for(const O in U)U[O].forEach($=>{const q=$.feature,ee=E(v[O]);if(!ee)return;const ie=ee.getFeatureState(q.layer["source-layer"],q.id);q.source=q.layer.source,q.layer["source-layer"]&&(q.sourceLayer=q.layer["source-layer"]),q.state=ie});return U}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),y.screenGeometry,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(f)}querySourceFeatures(r,o){o&&o.filter&&this._validate(s.validateFilter,"querySourceFeatures.filter",o.filter,null,o);const u=this._getSourceCaches(r);let d=[];for(const f of u)d=d.concat(vi(f,o));return d}addSourceType(r,o,u){return kr.getSourceType(r)?u(new Error(`A source type called "${r}" already exists.`)):(kr.setSourceType(r,o),o.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:r,url:o.workerSourceURL},u):u(null,null))}getLight(){return this.light.getLight()}setLight(r,o={}){this._checkLoaded();const u=this.light.getLight();let d=!1;for(const g in r)if(!le(r[g],u[g])){d=!0;break}if(!d)return;const f=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(r,o),this.light.updateTransitions(f)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,o=1){if(this._checkLoaded(),!r)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let u=r;if(o===1){if(typeof u.source=="object"){const d="terrain-dem-src";this.addSource(d,u.source),u=s.clone$1(u),u=s.extend(u,{source:d})}if(this._validate(s.validateTerrain,"terrain",u))return}if(!this.terrain||this.terrain&&o!==this.terrain.drapeRenderMode){if(!u)return;this._createTerrain(u,o)}else{const d=this.terrain,f=d.get();for(const g of Object.keys(s.spec.terrain))!u.hasOwnProperty(g)&&s.spec.terrain[g].default&&(u[g]=s.spec.terrain[g].default);for(const g in u)if(!le(u[g],f[g])){d.set(u),this.stylesheet.terrain=u;const y=this._setTransitionParameters({duration:0});d.updateTransitions(y);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(r){const o=this.fog=new Qn(r,this.map.transform);this.stylesheet.fog=r;const u=this._setTransitionParameters({duration:0});o.updateTransitions(u)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const r of this.map._markers)r._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const o=this.fog,u=o.get();Object.keys(r).length===0&&o.set(r);for(const d in r)if(!le(r[d],u[d])){o.set(r),this.stylesheet.fog=r;const f=this._setTransitionParameters({duration:0});o.updateTransitions(f);break}}else this._createFog(r);this._markersNeedUpdate=!0}_setTransitionParameters(r){return{now:s.exported.now(),transition:s.extend(r,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const r=this._order.filter(u=>this.isLayerDraped(this._layers[u])),o=this._order.filter(u=>!this.isLayerDraped(this._layers[u]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...r),this._drapedFirstOrder.push(...o)}_createTerrain(r,o){const u=this.terrain=new Fs(r,o);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const d=this._setTransitionParameters({duration:0});u.updateTransitions(d)}_force3DLayerUpdate(){for(const r in this._layers){const o=this._layers[r];o.type==="fill-extrusion"&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(const r in this._layers){const o=this._layers[r];o.type==="symbol"&&this._updateLayer(o)}}_validate(r,o,u,d,f={}){return(!f||f.validate!==!1)&&_n(this,r.call(s.validateStyle,s.extend({key:o,style:this.serialize(),value:u,styleSpec:s.spec},d)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),s.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const r in this._layers)this._layers[r].setEventedParent(null);for(const r in this._sourceCaches)this._sourceCaches[r].clearTiles(),this._sourceCaches[r].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(r){const o=this._getSourceCaches(r);for(const u of o)u.clearTiles()}_reloadSource(r){const o=this._getSourceCaches(r);for(const u of o)u.resume(),u.reload()}_reloadSources(){for(const r of this._getSources())r.reload&&r.reload()}_updateSources(r){for(const o in this._sourceCaches)this._sourceCaches[o].update(r)}_generateCollisionBoxes(){for(const r in this._sourceCaches){const o=this._sourceCaches[r];o.resume(),o.reload()}}_updatePlacement(r,o,u,d,f=!1){let g=!1,y=!1;const v={};for(const S of this._order){const E=this._layers[S];if(E.type!=="symbol")continue;if(!v[E.source]){const D=this._getLayerSourceCache(E);if(!D)continue;v[E.source]=D.getRenderableIds(!0).map(F=>D.getTileByID(F)).sort((F,N)=>N.tileID.overscaledZ-F.tileID.overscaledZ||(F.tileID.isLessThan(N.tileID)?-1:1))}const C=this.crossTileSymbolIndex.addLayer(E,v[E.source],r.center.lng,r.projection);g=g||C}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),f=f||this._layerOrderChanged||u===0,this._layerOrderChanged&&this.fire(new s.Event("neworder")),(f||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.exported.now(),r.zoom))&&(this.pauseablePlacement=new tl(r,this._order,f,o,u,d,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,v),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.exported.now()),y=!0),g&&this.pauseablePlacement.placement.setStale()),y||g)for(const S of this._order){const E=this._layers[S];E.type==="symbol"&&this.placement.updateLayerOpacities(E,v[E.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.exported.now())}_releaseSymbolFadeTiles(){for(const r in this._sourceCaches)this._sourceCaches[r].releaseSymbolFadeTiles()}getImages(r,o,u){this.imageManager.getImages(o.icons,u),this._updateTilesForChangedImages();const d=f=>{f&&f.setDependencies(o.tileID.key,o.type,o.icons)};d(this._otherSourceCaches[o.source]),d(this._symbolSourceCaches[o.source])}getGlyphs(r,o,u){this.glyphManager.getGlyphs(o.stacks,u)}getResource(r,o,u){return s.makeRequest(o,u)}_getSourceCache(r){return this._otherSourceCaches[r]}_getLayerSourceCache(r){return r.type==="symbol"?this._symbolSourceCaches[r.source]:this._otherSourceCaches[r.source]}_getSourceCaches(r){const o=[];return this._otherSourceCaches[r]&&o.push(this._otherSourceCaches[r]),this._symbolSourceCaches[r]&&o.push(this._symbolSourceCaches[r]),o}_isSourceCacheLoaded(r){const o=this._getSourceCaches(r);return o.length===0?(this.fire(new s.ErrorEvent(new Error(`There is no source with ID '${r}'`))),!1):o.every(u=>u.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}kr.getSourceType=function(l){return pt[l]},kr.setSourceType=function(l,r){pt[l]=r},kr.registerForPluginStateChange=s.registerForPluginStateChange;var ol=`
#define EPSILON 0.0000001
#define PI 3.141592653589793
#define EXTENT 8192.0
#define HALF_PI PI/2.0
#define QUARTER_PI PI/4.0
#define RAD_TO_DEG 180.0/PI
#define DEG_TO_RAD PI/180.0
#define GLOBE_RADIUS EXTENT/PI/2.0`,On="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Wr=`
#define ELEVATION_SCALE 7.0
#define ELEVATION_OFFSET 450.0
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
#else
vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
#endif
const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)
{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
#ifdef TERRAIN
#ifdef TERRAIN_DEM_FLOAT_FORMAT
uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;
#else
uniform sampler2D u_dem;uniform sampler2D u_dem_prev;
#endif
uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;
#else
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));
#ifdef TERRAIN_DEM_NEAREST_FILTER
return u_exaggeration*tl;
#endif
float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
#endif
}float prevElevation(vec2 apos) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;
#else
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
#endif
}
#ifdef TERRAIN_VERTEX_MORPHING
float elevation(vec2 apos) {
#ifdef ZERO_EXAGGERATION
return 0.0;
#endif
float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
#else
float elevation(vec2 apos) {
#ifdef ZERO_EXAGGERATION
return 0.0;
#endif
return currentElevation(apos);}
#endif
highp float unpack_depth(highp vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(
unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))
);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;
#else
vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);
#endif
return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
#else
float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }
#endif`,ns=`#ifdef FOG
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
#endif`,Xr=`#ifdef FOG
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
#endif`;let Xs={},ho={};const os=[];po(ol,os),po(Wr,os),po(ns,os),po(Xr,os),Xs=Ot("",Wr),ho=Ot(Xr,ns);const kc=Ot(`
#if __VERSION__ >=300
#define varying in
#define gl_FragColor glFragColor
#define texture2D texture
#define textureCube texture
out vec4 glFragColor;
#endif
highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}`,`
#if __VERSION__ >=300
#define attribute in
#define varying out
#define texture2D texture
#endif
float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
#ifdef PROJECTION_GLOBE_VIEW
vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
#ifndef PROJECTED_POS_ON_VIEWPORT
float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
#else
return vec3(0.0);
#endif
}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
#endif
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(
unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),Hs=ol,sl=`
#ifdef GL_ES
precision mediump float;
#else

#if !defined(lowp)
#define lowp
#endif

#if !defined(mediump)
#define mediump
#endif

#if !defined(highp)
#define highp
#endif

#endif`;var al={background:Ot(`uniform vec4 u_color;uniform float u_opacity;
#ifdef LIGHTING_3D_MODE
varying vec4 v_color;
#endif
void main() {vec4 out_color;
#ifdef LIGHTING_3D_MODE
out_color=v_color;
#else
out_color=u_color;
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
#ifdef LIGHTING_3D_MODE
uniform vec4 u_color;varying vec4 v_color;
#endif
void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
#ifdef LIGHTING_3D_MODE
v_color=apply_lighting(u_color);
#endif
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),backgroundPattern:Ot(`uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),circle:Ot(`varying vec3 v_data;varying float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_apply_premultiplied(out_color,v_fog_pos);
#endif
gl_FragColor=out_color*(v_visibility*opacity_t);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`#define NUM_VISIBILITY_RINGS 2
#define INV_SQRT2 0.70710678
#define ELEVATION_BIAS 0.0001
#define NUM_SAMPLES_PER_RING 16
uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
#endif
varying vec3 v_data;varying float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
#if defined(TERRAIN)
return elevation(pos)+ELEVATION_BIAS;
#else
return 0.0;
#endif
}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
#ifdef PITCH_WITH_MAP
#ifdef PROJECTION_GLOBE_VIEW
return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
#else
return u_matrix*( world_center+vec4(sample_offset,0,0) );
#endif
#else
return projected_center+vec4(sample_offset,0,0);
#endif
}float get_sample_step() {
#ifdef PITCH_WITH_MAP
return 2.0*PI/float(NUM_SAMPLES_PER_RING);
#else
return PI/float(NUM_SAMPLES_PER_RING);
#endif
}void main(void) {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;
#ifdef PROJECTION_GLOBE_VIEW
vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);
#else 
surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);
#endif
vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
#ifdef PITCH_WITH_MAP
#ifdef SCALE_WITH_MAP
view_scale=1.0;
#else
view_scale=projected_center.w/u_camera_to_center_distance;
#endif
#else
#ifdef SCALE_WITH_MAP
view_scale=u_camera_to_center_distance;
#else
view_scale=projected_center.w;
#endif
#endif
gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
#ifdef TERRAIN
float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
#ifdef PITCH_WITH_MAP
float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;
#else
occlusion_world_center=world_center;occlusion_projected_center=projected_center;
#endif
for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
#else
visibility=1.0;
#endif
#ifdef PROJECTION_GLOBE_VIEW
visibility=1.0;
#endif
v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
#ifdef FOG
v_fog_pos=fog_position(world_center.xyz);
#endif
}`),clippingMask:Ot("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Ot(`uniform highp float u_intensity;varying vec2 v_extrude;
#pragma mapbox: define highp float weight
#define GAUSS_COEF 0.3989422804014327
void main() {
#pragma mapbox: initialize highp float weight
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
#ifdef FOG
if (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
#endif
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
#endif
varying vec2 v_extrude;
#pragma mapbox: define highp float weight
#pragma mapbox: define mediump float radius
const highp float ZERO=1.0/255.0/16.0;
#define GAUSS_COEF 0.3989422804014327
void main(void) {
#pragma mapbox: initialize highp float weight
#pragma mapbox: initialize mediump float radius
vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#else
pos=vec3(tilePos+extrude,elevation(tilePos));
#endif
gl_Position=u_matrix*vec4(pos,1);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),heatmapTexture:Ot(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(0.0);
#endif
}`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Ot("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Ot("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",`attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd  =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz  /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Ot("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",`attribute vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;
#endif
varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;
#ifdef PROJECTION_GLOBE_VIEW
gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
#else
gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
#endif
}`),fill:Ot(`#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
vec4 out_color=color;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
gl_Position=u_matrix*vec4(a_pos,0,1);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillOutline:Ot(`varying vec2 v_pos;
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillOutlinePattern:Ot(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillPattern:Ot(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillExtrusion:Ot(`varying vec4 v_color;
#ifdef RENDER_SHADOWS
varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;varying vec3 v_ao;
#endif
#ifdef ZERO_ROOF_RADIUS
varying vec4 v_roof_color;
#endif
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
varying highp vec3 v_normal;
#endif
void main() {
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
vec3 normal=v_normal;
#endif
float z;vec4 color;
#ifdef ZERO_ROOF_RADIUS
z=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);
#else
color=v_color;
#endif
#ifdef FAUX_AO
float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;
#ifdef ZERO_ROOF_RADIUS
concave*=(1.0-z);
#endif
float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;
#endif
#ifdef RENDER_SHADOWS
#ifdef ZERO_ROOF_RADIUS
normal=mix(normal,vec3(0.0,0.0,1.0),z);
#endif
color.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
gl_FragColor=color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
#endif
varying vec4 v_color;
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;
#endif
#ifdef ZERO_ROOF_RADIUS
varying vec4 v_roof_color;
#endif
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
varying highp vec3 v_normal;
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;varying vec3 v_ao;
#endif
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp vec4 color
void main() {
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp vec4 color
vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
v_normal=normal;
#endif
base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=a_centroid_pos;
#endif
float ele=0.0;float h=0.0;float c_ele;vec3 pos;
#ifdef TERRAIN
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);
#else
h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);
#endif
#ifdef PROJECTION_GLOBE_VIEW
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#endif
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);
#ifdef RENDER_SHADOWS
v_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;
#endif
float NdotL=0.0;float colorvalue=0.0;
#ifdef LIGHTING_3D_MODE
NdotL=calculate_NdotL(normal);
#else
colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);
#endif
if (normal.y !=0.0) {float r=0.84;
#ifndef LIGHTING_3D_MODE
r=mix(0.7,0.98,1.0-u_lightintensity);
#endif
NdotL*=(
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);
#ifdef FAUX_AO
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
#ifdef TERRAIN
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
#endif
v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
#ifdef PROJECTION_GLOBE_VIEW
top_height+=u_height_lift;
#endif
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
#endif
#ifdef LIGHTING_3D_MODE
v_color=apply_lighting(color,NdotL);
#else
v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));
#endif
v_color*=u_opacity;
#ifdef ZERO_ROOF_RADIUS
v_roof_color=vec4(0.0,0.0,0.0,1.0);
#ifdef LIGHTING_3D_MODE
v_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));
#else
float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));
#endif
v_roof_color*=u_opacity;
#endif
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),fillExtrusionPattern:Ot(`uniform vec2 u_texsize;uniform sampler2D u_image;
#ifdef FAUX_AO
uniform lowp vec2 u_ao;varying vec3 v_ao;
#endif
#ifdef LIGHTING_3D_MODE
varying float v_NdotL;
#endif
varying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;
#pragma mapbox: define lowp float base
#pragma mapbox: define lowp float height
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float base
#pragma mapbox: initialize lowp float height
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color,v_NdotL)*u_opacity;
#else
out_color=out_color*v_lighting;
#endif
#ifdef FAUX_AO
float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
#endif
varying vec2 v_pos;varying vec4 v_lighting;
#ifdef FAUX_AO
uniform lowp vec2 u_ao;varying vec3 v_ao;
#endif
#ifdef LIGHTING_3D_MODE
varying float v_NdotL;
#endif
#pragma mapbox: define lowp float base
#pragma mapbox: define lowp float height
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float base
#pragma mapbox: initialize lowp float height
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=a_centroid_pos;
#endif
float ele=0.0;float h=z;vec3 p;float c_ele;
#ifdef TERRAIN
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);
#else
p=vec3(pos_nx.xy,z);
#endif
#ifdef PROJECTION_GLOBE_VIEW
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#endif
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
? pos_nx.xy
: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;
#ifdef LIGHTING_3D_MODE
NdotL=calculate_NdotL(normal);
#else
NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
#endif
if (normal.y !=0.0) {float r=0.84;
#ifndef LIGHTING_3D_MODE
r=mix(0.7,0.98,1.0-u_lightintensity);
#endif
NdotL*=(
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
#ifdef FAUX_AO
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
#ifdef TERRAIN
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
#endif
v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
#ifdef PROJECTION_GLOBE_VIEW
top_height+=u_height_lift;
#endif
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
#endif
#ifdef LIGHTING_3D_MODE
v_NdotL=NdotL;
#else
v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
#endif 
#ifdef FOG
v_fog_pos=fog_position(p);
#endif
}`),hillshadePrepare:Ot(`#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
return texture2D(u_image,coord).a/4.0;
#else
vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;
#endif
}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(
(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(
deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Ot(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
#ifdef LIGHTING_3D_MODE
gl_FragColor=apply_lighting(gl_FragColor);
#endif
#ifdef FOG
gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));
#endif
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),line:Ot(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;
#ifdef RENDER_LINE_DASH
uniform sampler2D u_dash_image;varying vec2 v_tex;
#endif
#ifdef RENDER_LINE_GRADIENT
uniform sampler2D u_gradient_image;
#endif
uniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 dash
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
float linearstep(float edge0,float edge1,float x) {return  clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize lowp vec4 dash
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);
#ifdef RENDER_LINE_DASH
float sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);
#endif
highp vec4 out_color;
#ifdef RENDER_LINE_GRADIENT
out_color=texture2D(u_gradient_image,v_uv.xy);
#else
out_color=color;
#endif
float trimmed=1.0;
#ifdef RENDER_LINE_TRIM_OFFSET
highp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
#ifdef RENDER_LINE_ALPHA_DISCARD
if (alpha < u_alpha_discard_threshold) {discard;}
#endif
#ifdef RENDER_LINE_BORDER
float edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);
#ifdef RENDER_LINE_BORDER_AUTO
float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}
#else
out_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);
#endif
}
#endif
gl_FragColor=out_color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`
#define EXTRUDE_SCALE 0.015873016
attribute vec2 a_pos_normal;attribute vec4 a_data;
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
attribute highp vec4 a_packed;
#endif
#ifdef RENDER_LINE_DASH
attribute float a_linesofar;
#endif
uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;
#ifdef RENDER_LINE_DASH
uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;
#endif
#ifdef RENDER_LINE_GRADIENT
uniform float u_image_height;
#endif
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 dash
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float width
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize lowp vec4 dash
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float width
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
#ifndef RENDER_TO_TEXTURE
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#else
v_gamma_scale=1.0;
#endif
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];
#ifdef RENDER_LINE_GRADIENT
highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);
#else
v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);
#endif
#endif
#ifdef RENDER_LINE_DASH
float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);
#endif
v_width2=vec2(outset,inset);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),linePattern:Ot(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
color=apply_lighting(color);
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
gl_FragColor=color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define mediump float width
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
#ifndef RENDER_TO_TEXTURE
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#else
v_gamma_scale=1.0;
#endif
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),raster:Ot(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(
dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply(out_color,v_fog_pos));
#endif
gl_FragColor=vec4(out_color*color.a,color.a);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),symbolIcon:Ot(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize lowp float opacity
lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
#endif
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
#endif
varying vec2 v_tex;varying float v_fade_opacity;
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize lowp float opacity
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
#ifdef PROJECTION_GLOBE_VIEW
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
#else
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;
#ifdef PROJECTION_GLOBE_VIEW
vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);
#else
offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);
#endif
vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
#else
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
#endif
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
#ifdef TERRAIN
#ifdef PITCH_WITH_MAP_TERRAIN
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
#endif
#endif
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
#ifdef PROJECTION_GLOBE_VIEW
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#else
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#endif
float projection_transition_fade=1.0;
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
#endif
v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:Ot(`#define SDF_PX 8.0
uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
#endif
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
#endif
varying vec2 v_data0;varying vec3 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
#ifdef PROJECTION_GLOBE_VIEW
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
#else
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;
#ifdef PROJECTION_GLOBE_VIEW
vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);
#else
offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);
#endif
vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
#else
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
#endif
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);
#ifdef TERRAIN
#ifdef PITCH_WITH_MAP_TERRAIN
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
#endif
#endif
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
#ifdef PROJECTION_GLOBE_VIEW
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#else
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#endif
float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
#endif
vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:Ot(`#define SDF_PX 8.0
#define SDF 1.0
#define ICON 0.0
uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
#endif
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
#endif
varying vec4 v_data0;varying vec4 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
#ifdef PROJECTION_GLOBE_VIEW
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
#else
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
#else
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
#endif
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);
#ifdef TERRAIN
#ifdef PITCH_WITH_MAP_TERRAIN
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
#endif
#endif
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
#ifdef PROJECTION_GLOBE_VIEW
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#else
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#endif
float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
#endif
v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:Ot(`uniform sampler2D u_image0;varying vec2 v_pos0;
#ifdef FOG
varying float v_fog_opacity;
#endif
#ifdef RENDER_SHADOWS
varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;
#endif
void main() {vec4 color=texture2D(u_image0,v_pos0);
#ifdef RENDER_SHADOWS
color.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);
#endif
#ifdef FOG
#ifdef ZERO_EXAGGERATION
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#else
color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
#endif
#endif
gl_FragColor=color;
#ifdef TERRAIN_WIREFRAME
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
#endif
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0;
#ifdef FOG
varying float v_fog_opacity;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;
#endif
const float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;
#ifdef TERRAIN_WIREFRAME
elevation+=wireframeOffset;
#endif
v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
#ifdef FOG
#ifdef ZERO_EXAGGERATION
v_fog_pos=fog_position(decodedPos);
#else
v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
#endif
#endif
#ifdef RENDER_SHADOWS
vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;
#endif
}`),terrainDepth:Ot(`#ifdef GL_ES
precision highp float;
#endif
varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Ot(`
varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;
#ifdef FOG
sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
#endif
sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,On),skyboxGradient:Ot(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));
#ifdef FOG
color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
#endif
color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,On),skyboxCapture:Ot(`
varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;
#ifdef GL_ES
precision highp float;
#endif
#define BETA_R                  vec3(5.5e-6,13.0e-6,22.4e-6)
#define BETA_M                  vec3(21e-6,21e-6,21e-6)
#define MIE_G                   0.76
#define DENSITY_HEIGHT_SCALE_R  8000.0
#define DENSITY_HEIGHT_SCALE_M  1200.0
#define PLANET_RADIUS           6360e3
#define ATMOSPHERE_RADIUS       6420e3
#define SAMPLE_STEPS            10
#define DENSITY_STEPS           4
float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Ot(`uniform sampler2D u_image0;varying vec2 v_pos0;
#ifndef FOG
uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;
#endif
void main() {vec4 color;
#ifdef CUSTOM_ANTIALIASING
vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);
#else
color=texture2D(u_image0,v_pos0);
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
gl_FragColor=color;
#ifdef TERRAIN_WIREFRAME
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
#endif
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;
#ifdef GLOBE_POLES
attribute vec3 a_globe_pos;attribute vec2 a_uv;
#else
attribute vec2 a_pos;
#endif
varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {
#ifdef GLOBE_POLES
vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
#else
float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
#endif
v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
#ifdef GLOBE_POLES
vec3 up_vector=globe_derived_up_vector;
#else
vec3 up_vector=elevationVector(tile_pos);
#endif
float height=elevation(tile_pos);
#ifdef TERRAIN_WIREFRAME
height+=wireframeOffset;
#endif
globe_pos+=up_vector*height;
#ifndef GLOBE_POLES
globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
#endif
#ifdef GLOBE_POLES
vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
#else
vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
#endif
gl_Position=u_proj_matrix*interpolated_pos;
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
#endif
}`),globeAtmosphere:Ot(`uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;
#ifdef PROJECTION_GLOBE_VIEW
globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}
#endif
highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;
#ifdef PROJECTION_GLOBE_VIEW
highp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?
PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);
#else
horizon_angle=horizon_angle_mercator;
#endif
horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:
(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:
uv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}`,`attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(
mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`)};function po(l,r){const o=l.replace(/\s*\/\/[^\n]*\n/g,`
`).split(`
`);for(let u of o)if(u=u.trim(),u[0]==="#"&&u.includes("if")&&!u.includes("endif")){u=u.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const d=u.split(" ");for(const f of d)r.includes(f)||r.push(f)}}function Ot(l,r){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,u=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),d={},f=[...os];return po(l,f),po(r,f),{fragmentSource:l=l.replace(o,(g,y,v,S,E)=>(d[E]=!0,y==="define"?`
#ifndef HAS_UNIFORM_u_${E}
varying ${v} ${S} ${E};
#else
uniform ${v} ${S} u_${E};
#endif
`:`
#ifdef HAS_UNIFORM_u_${E}
    ${v} ${S} ${E} = u_${E};
#endif
`)),vertexSource:r=r.replace(o,(g,y,v,S,E)=>{const C=S==="float"?"vec2":"vec4",D=E.match(/color/)?"color":C;return d[E]?y==="define"?`
#ifndef HAS_UNIFORM_u_${E}
uniform lowp float u_${E}_t;
attribute ${v} ${C} a_${E};
varying ${v} ${S} ${E};
#else
uniform ${v} ${S} u_${E};
#endif
`:D==="vec4"?`
#ifndef HAS_UNIFORM_u_${E}
    ${E} = a_${E};
#else
    ${v} ${S} ${E} = u_${E};
#endif
`:`
#ifndef HAS_UNIFORM_u_${E}
    ${E} = unpack_mix_${D}(a_${E}, u_${E}_t);
#else
    ${v} ${S} ${E} = u_${E};
#endif
`:y==="define"?`
#ifndef HAS_UNIFORM_u_${E}
uniform lowp float u_${E}_t;
attribute ${v} ${C} a_${E};
#else
uniform ${v} ${S} u_${E};
#endif
`:D==="vec4"?`
#ifndef HAS_UNIFORM_u_${E}
    ${v} ${S} ${E} = a_${E};
#else
    ${v} ${S} ${E} = u_${E};
#endif
`:`
#ifndef HAS_UNIFORM_u_${E}
    ${v} ${S} ${E} = unpack_mix_${D}(a_${E}, u_${E}_t);
#else
    ${v} ${S} ${E} = u_${E};
#endif
`}),staticAttributes:u,usedDefines:f}}class lh{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(r,o,u,d,f,g,y){this.context=r;let v=this.boundPaintVertexBuffers.length!==d.length;for(let E=0;!v&&E<d.length;E++)this.boundPaintVertexBuffers[E]!==d[E]&&(v=!0);let S=this.boundDynamicVertexBuffers.length!==y.length;for(let E=0;!S&&E<y.length;E++)this.boundDynamicVertexBuffers[E]!==y[E]&&(S=!0);if(!r.extVertexArrayObject||!this.vao||this.boundProgram!==o||this.boundLayoutVertexBuffer!==u||v||S||this.boundIndexBuffer!==f||this.boundVertexOffset!==g)this.freshBind(o,u,d,f,g,y);else{r.bindVertexArrayOES.set(this.vao);for(const E of y)E&&E.bind();f&&f.dynamicDraw&&f.bind()}}freshBind(r,o,u,d,f,g){let y;const v=r.numAttributes,S=this.context,E=S.gl;if(S.extVertexArrayObject)this.vao&&this.destroy(),this.vao=S.extVertexArrayObject.createVertexArrayOES(),S.bindVertexArrayOES.set(this.vao),y=0,this.boundProgram=r,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=u,this.boundIndexBuffer=d,this.boundVertexOffset=f,this.boundDynamicVertexBuffers=g;else{y=S.currentNumAttributes||0;for(let C=v;C<y;C++)E.disableVertexAttribArray(C)}o.enableAttributes(E,r),o.bind(),o.setVertexAttribPointers(E,r,f);for(const C of u)C.enableAttributes(E,r),C.bind(),C.setVertexAttribPointers(E,r,f);for(const C of g)C&&(C.enableAttributes(E,r),C.bind(),C.setVertexAttribPointers(E,r,f));d&&d.bind(),S.currentNumAttributes=v}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function ll(l,r){const o=Math.pow(2,r.canonical.z),u=r.canonical.y;return[new s.MercatorCoordinate(0,u/o).toLngLat().lat,new s.MercatorCoordinate(0,(u+1)/o).toLngLat().lat]}function Lc(l,r,o,u,d,f,g){const y=l.context,v=y.gl,S=o.fbo;if(!S)return;l.prepareDrawTile();const E=l.useProgram("hillshade");y.activeTexture.set(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,S.colorAttachment.get());const C=((U,j,P,O)=>{const $=P.paint.get("hillshade-shadow-color"),q=P.paint.get("hillshade-highlight-color"),ee=P.paint.get("hillshade-accent-color");let ie=P.paint.get("hillshade-illumination-direction")*(Math.PI/180);P.paint.get("hillshade-illumination-anchor")==="viewport"&&(ie-=U.transform.angle);const te=!U.options.moving;return{u_matrix:O||U.transform.calculateProjMatrix(j.tileID.toUnwrapped(),te),u_image:0,u_latrange:ll(0,j.tileID),u_light:[P.paint.get("hillshade-exaggeration"),ie],u_shadow:$,u_highlight:q,u_accent:ee}})(l,o,u,l.terrain?r.projMatrix:null);l.prepareDrawProgram(y,E,r.toUnwrapped());const{tileBoundsBuffer:D,tileBoundsIndexBuffer:F,tileBoundsSegments:N}=l.getTileBoundsBuffers(o);E.draw(y,v.TRIANGLES,d,f,g,s.CullFaceMode.disabled,C,u.id,D,F,N)}function cl(l,r,o){if(!r.needsDEMTextureUpload)return;const u=l.context,d=u.gl;u.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||l.getTileTexture(o.stride);const f=o.getPixels();r.demTexture?r.demTexture.update(f,{premultiply:!1}):r.demTexture=new s.Texture(u,f,d.RGBA,{premultiply:!1}),r.needsDEMTextureUpload=!1}function Dc(l,r,o,u,d,f){const g=l.context,y=g.gl;if(!r.dem)return;const v=r.dem;if(g.activeTexture.set(y.TEXTURE1),cl(l,r,v),!r.demTexture)return;r.demTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE);const S=v.dim;g.activeTexture.set(y.TEXTURE0);let E=r.fbo;if(!E){const N=new s.Texture(g,{width:S,height:S,data:null},y.RGBA);N.bind(y.LINEAR,y.CLAMP_TO_EDGE),E=r.fbo=g.createFramebuffer(S,S,!0),E.colorAttachment.set(N.texture)}g.bindFramebuffer.set(E.framebuffer),g.viewport.set([0,0,S,S]);const{tileBoundsBuffer:C,tileBoundsIndexBuffer:D,tileBoundsSegments:F}=l.getMercatorTileBoundsBuffers();l.useProgram("hillshadePrepare").draw(g,y.TRIANGLES,u,d,f,s.CullFaceMode.disabled,((N,U)=>{const j=U.stride,P=s.create();return s.ortho(P,0,s.EXTENT,-s.EXTENT,0,0,1),s.translate(P,P,[0,-s.EXTENT,0]),{u_matrix:P,u_image:1,u_dimension:[j,j],u_zoom:N.overscaledZ,u_unpack:U.unpackVector}})(r.tileID,v),o.id,C,D,F),r.needsHillshadePrepare=!1}const ul=l=>({u_matrix:new s.UniformMatrix4f(l),u_image0:new s.Uniform1i(l),u_skirt_height:new s.Uniform1f(l)}),fo=(l,r)=>({u_matrix:l,u_image0:0,u_skirt_height:r}),Ks=(l,r,o,u,d,f,g,y,v,S,E,C,D,F,N)=>({u_proj_matrix:Float32Array.from(l),u_globe_matrix:r,u_normalize_matrix:Float32Array.from(u),u_merc_matrix:o,u_zoom_transition:d,u_merc_center:f,u_image0:0,u_frustum_tl:g,u_frustum_tr:y,u_frustum_br:v,u_frustum_bl:S,u_globe_pos:E,u_globe_radius:C,u_viewport:D,u_grid_matrix:N?Float32Array.from(N):new Float32Array(9),u_skirt_height:F});function mo(l,r){return l!=null&&r!=null&&!(!l.hasData()||!r.hasData())&&l.demTexture!=null&&r.demTexture!=null&&l.tileID.key!==r.tileID.key}const Hr=new class{constructor(){this.operations={}}newMorphing(l,r,o,u,d){if(l in this.operations){const f=this.operations[l];f.to.tileID.key!==o.tileID.key&&(f.queued=o)}else this.operations[l]={startTime:u,phase:0,duration:d,from:r,to:o,queued:null}}getMorphValuesForProxy(l){if(!(l in this.operations))return null;const r=this.operations[l];return{from:r.from,to:r.to,phase:r.phase}}update(l){for(const r in this.operations){const o=this.operations[r];for(o.phase=(l-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,l)){delete this.operations[r];break}}}_nextOp(l,r){return!!l.queued&&(l.from=l.to,l.to=l.queued,l.queued=null,l.phase=0,l.startTime=r,!0)}_validOp(l){return l.from.hasData()&&l.to.hasData()}},Fn={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Js(l){return 6*Math.pow(1.5,22-l)}function Rc(l,r){const o=1<<l.z;return!r&&(l.x===0||l.x===o-1)||l.y===0||l.y===o-1}const ss=l=>({u_matrix:l});function hl(l,r,o,u,d){if(d>0){const f=s.exported.now(),g=(f-l.timeAdded)/d,y=r?(f-r.timeAdded)/d:-1,v=o.getSource(),S=u.coveringZoomLevel({tileSize:v.tileSize,roundZoom:v.roundZoom}),E=!r||Math.abs(r.tileID.overscaledZ-S)>Math.abs(l.tileID.overscaledZ-S),C=E&&l.refreshedUponExpiration?1:s.clamp(E?g:1-y,0,1);return l.refreshedUponExpiration&&g>=1&&(l.refreshedUponExpiration=!1),r?{opacity:1,mix:1-C}:{opacity:C,mix:0}}return{opacity:1,mix:0}}class dl extends s.SourceCache{constructor(r){const o={type:"raster-dem",maxzoom:r.transform.maxZoom},u=new zi(ao(),null),d=yt("mock-dem",o,u,r.style);super("mock-dem",d,!1),d.setEventedParent(this),this._sourceLoaded=!0}_loadTile(r,o){r.state="loaded",o(null)}}class Ys extends s.SourceCache{constructor(r){const o=yt("proxy",{type:"geojson",maxzoom:r.transform.maxZoom},new zi(ao(),null),r.style);super("proxy",o,!1),o.setEventedParent(this),this.map=this.getSource().map=r,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(r,o,u){if(r.freezeTileCoverage)return;this.transform=r;const d=r.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((f,g)=>{if(f[g.key]="",!this._tiles[g.key]){const y=new s.Tile(g,this._source.tileSize*g.overscaleFactor(),r.tileZoom);y.state="loaded",this._tiles[g.key]=y}return f},{});for(const f in this._tiles)f in d||(this.freeFBO(f),this._tiles[f].unloadVectorData(),delete this._tiles[f])}freeFBO(r){const o=this.proxyCachedFBO[r];if(o!==void 0){const u=Object.values(o);this.renderCachePool.push(...u),delete this.proxyCachedFBO[r]}}deallocRenderCache(){this.renderCache.forEach(r=>r.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Qs extends s.OverscaledTileID{constructor(r,o,u){super(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y),this.proxyTileKey=o,this.projMatrix=u}}class pl extends s.Elevation{constructor(r,o){super(),this.painter=r,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[u,d,f]=function(v){const S=new s.StructArrayLayout2i4,E=new s.StructArrayLayout3ui6,C=131;S.reserve(17161),E.reserve(33800);const D=s.EXTENT/128,F=s.EXTENT+D/2,N=F+D;for(let j=-D;j<N;j+=D)for(let P=-D;P<N;P+=D){const O=P<0||P>F||j<0||j>F?24575:0,$=s.clamp(Math.round(P),0,s.EXTENT),q=s.clamp(Math.round(j),0,s.EXTENT);S.emplaceBack($+O,q)}const U=(j,P)=>{const O=P*C+j;E.emplaceBack(O+1,O,O+C),E.emplaceBack(O+C,O+C+1,O+1)};for(let j=1;j<129;j++)for(let P=1;P<129;P++)U(P,j);return[0,129].forEach(j=>{for(let P=0;P<130;P++)U(P,j),U(j,P)}),[S,E,32768]}(),g=r.context;this.gridBuffer=g.createVertexBuffer(u,s.posAttributes.members),this.gridIndexBuffer=g.createIndexBuffer(d),this.gridSegments=s.SegmentVector.simpleSegment(0,0,u.length,d.length),this.gridNoSkirtSegments=s.SegmentVector.simpleSegment(0,0,u.length,f),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ys(o.map),this.orthoMatrix=s.create(),s.ortho(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,s.EXTENT,0,s.EXTENT,0,1);const y=g.gl;this._overlapStencilMode=new s.StencilMode({func:y.GEQUAL,mask:255},0,255,y.KEEP,y.KEEP,y.REPLACE),this._previousZoom=r.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new dl(o.map)}set style(r){r.on("data",this._onStyleDataEvent.bind(this)),r.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=r,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(r,o,u){if(r&&r.terrain){this._style!==r&&(this.style=r),this.enabled=!0;const d=r.terrain.properties;this.sourceCache=r.terrain.drapeRenderMode===0?this._mockSourceCache:r._getSourceCache(d.get("source")),this._exaggeration=d.get("exaggeration");const f=()=>{this.sourceCache.used&&s.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const g=this.getScaledDemTileSize();this.sourceCache.update(o,g,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,f(),this._initializing=!0),f(),o.updateElevation(!0,u),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(r){this._findCoveringTileCache[r]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const r=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||r.efficiency!==100&&s.warnOnce(`Terrain render cache efficiency is not optimal (${r.efficiency}%) and performance
                may be affected negatively, consider placing all background, fill and line layers before layer
                with id '${r.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(r){r.coord&&r.dataType==="source"?this._clearRenderCacheForTile(r.sourceCacheId,r.coord):r.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const r in this._style._sourceCaches)this._style._sourceCaches[r].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(r=>r.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const r=2*this.proxySourceCache.getSource().tileSize;return[r,r]}set useVertexMorphing(r){this._useVertexMorphing=r}updateTileBinding(r){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const o=this.proxySourceCache,u=this.painter.transform;this._initializing&&(this._initializing=u._centerAltitude===0&&this.getAtPointOrZero(s.MercatorCoordinate.fromLngLat(u.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const d=this.proxyCoords=o.getIds().map(v=>{const S=o.getTileByID(v).tileID;return S.projMatrix=u.calculateProjMatrix(S.toUnwrapped()),S});(function(v,S){const E=S.transform.pointCoordinate(S.transform.getCameraPoint()),C=new s.Point(E.x,E.y);v.sort((D,F)=>{if(F.overscaledZ-D.overscaledZ)return F.overscaledZ-D.overscaledZ;const N=new s.Point(D.canonical.x+(1<<D.canonical.z)*D.wrap,D.canonical.y),U=new s.Point(F.canonical.x+(1<<F.canonical.z)*F.wrap,F.canonical.y),j=C.mult(1<<D.canonical.z);return j.x-=.5,j.y-=.5,j.distSqr(N)-j.distSqr(U)})})(d,this.painter),this._previousZoom=u.zoom;const f=this.proxyToSource||{};this.proxyToSource={},d.forEach(v=>{this.proxyToSource[v.key]={}}),this.terrainTileForTile={};const g=this._style._sourceCaches;for(const v in g){const S=g[v];if(!S.used||(S!==this.sourceCache&&this.resetTileLookupCache(S.id),this._setupProxiedCoordsForOrtho(S,r[v],f),S.usedForTerrain))continue;const E=r[v];S.getSource().reparseOverscaled&&this._assignTerrainTiles(E)}this.proxiedCoords[o.id]=d.map(v=>new Qs(v,v.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(f),this.renderingToTexture=!1,this._updateTimestamp=s.exported.now();const y={};this._visibleDemTiles=[];for(const v of this.proxyCoords){const S=this.terrainTileForTile[v.key];if(!S)continue;const E=S.tileID.key;E in y||(this._visibleDemTiles.push(S),y[E]=E)}}_assignTerrainTiles(r){this._initializing||r.forEach(o=>{if(this.terrainTileForTile[o.key])return;const u=this._findTileCoveringTileID(o,this.sourceCache);u&&(this.terrainTileForTile[o.key]=u)})}_prepareDEMTextures(){const r=this.painter.context,o=r.gl;for(const u in this.terrainTileForTile){const d=this.terrainTileForTile[u],f=d.dem;!f||d.demTexture&&!d.needsDEMTextureUpload||(r.activeTexture.set(o.TEXTURE1),cl(this.painter,d,f))}}_prepareDemTileUniforms(r,o,u,d){if(!o||o.demTexture==null)return!1;const f=r.tileID.canonical,g=Math.pow(2,o.tileID.canonical.z-f.z),y=d||"";return u[`u_dem_tl${y}`]=[f.x*g%1,f.y*g%1],u[`u_dem_scale${y}`]=g,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const r=this.painter.context,o=r.gl;if(!this._emptyDepthBufferTexture){const u=new s.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new s.Texture(r,u,o.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let r=0;const o=this._visibleDemTiles.reduce((u,d)=>{if(!d.dem)return u;const f=d.dem.tree.minimums[0];return f>0&&r++,u+f},0);return r?o/r:0}_updateEmptyDEMTexture(){const r=this.painter.context,o=r.gl;r.activeTexture.set(o.TEXTURE2);const u=this._getLoadedAreaMinimum(),d=new s.RGBAImage({width:1,height:1},new Uint8Array(s.DEMData.pack(u,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let f=this._emptyDEMTexture;return f?f.update(d,{premultiply:!1}):f=this._emptyDEMTexture=new s.Texture(r,d,o.RGBA,{premultiply:!1}),f}setupElevationDraw(r,o,u){const d=this.painter.context,f=d.gl,g=(y=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:s.DEMData.getUnpackVector(y),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var y;g.u_dem_size=this.sourceCache.getSource().tileSize,g.u_exaggeration=this.exaggeration();let v=null,S=null,E=1;if(u&&u.morphing&&this._useVertexMorphing){const C=u.morphing.srcDemTile,D=u.morphing.dstDemTile;E=u.morphing.phase,C&&D&&(this._prepareDemTileUniforms(r,C,g,"_prev")&&(S=C),this._prepareDemTileUniforms(r,D,g)&&(v=D))}if(S&&v?(d.activeTexture.set(f.TEXTURE2),v.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE,f.NEAREST),d.activeTexture.set(f.TEXTURE4),S.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE,f.NEAREST),g.u_dem_lerp=E):(v=this.terrainTileForTile[r.tileID.key],d.activeTexture.set(f.TEXTURE2),(this._prepareDemTileUniforms(r,v,g)?v.demTexture:this.emptyDEMTexture).bind(f.NEAREST,f.CLAMP_TO_EDGE)),d.activeTexture.set(f.TEXTURE3),u&&u.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),this._depthFBO&&(g.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),g.u_depth_size_inv=[1,1]),u&&u.useMeterToDem&&v){const C=(1<<v.tileID.canonical.z)*s.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;g.u_meter_to_dem=C}if(u&&u.labelPlaneMatrixInv&&(g.u_label_plane_matrix_inv=u.labelPlaneMatrixInv),o.setTerrainUniformValues(d,g),this.painter.transform.projection.name==="globe"){const C=this.globeUniformValues(this.painter.transform,r.tileID.canonical,u&&u.useDenormalizedUpVectorScale);o.setGlobeUniformValues(d,C)}}globeUniformValues(r,o,u){const d=r.projection;return{u_tile_tl_up:d.upVector(o,0,0),u_tile_tr_up:d.upVector(o,s.EXTENT,0),u_tile_br_up:d.upVector(o,s.EXTENT,s.EXTENT),u_tile_bl_up:d.upVector(o,0,s.EXTENT),u_tile_up_scale:u?s.globeMetersToEcef(1):d.upVectorScale(o,r.center.lat,r.worldSize).metersToTile}}renderToBackBuffer(r){const o=this.painter,u=this.painter.context;r.length!==0&&(u.bindFramebuffer.set(null),u.viewport.set([0,0,o.width,o.height]),o.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(d,f,g,y,v){if(d.transform.projection.name==="globe")(function(S,E,C,D,F){const N=S.context,U=N.gl;let j,P;const O=S.options.showTerrainWireframe?2:0,$=S.transform,q=s.globeUseCustomAntiAliasing(S,N,$),ee=(ze,pe)=>{if(P===ze)return;const Ee=[Fn[ze],"PROJECTION_GLOBE_VIEW"];q&&Ee.push("CUSTOM_ANTIALIASING"),pe&&Ee.push(Fn[O]),j=S.useProgram("globeRaster",null,Ee),P=ze},ie=S.colorModeForRenderPass(),te=new s.DepthMode(U.LEQUAL,s.DepthMode.ReadWrite,S.depthRangeFor3D);Hr.update(F);const ae=s.calculateGlobeMercatorMatrix($),se=[s.mercatorXfromLng($.center.lng),s.mercatorYfromLat($.center.lat)],fe=O?[!1,!0]:[!1],ke=S.globeSharedBuffers,he=[$.width*s.exported.devicePixelRatio,$.height*s.exported.devicePixelRatio],Se=Float32Array.from($.globeMatrix),ge={useDenormalizedUpVectorScale:!0};if(fe.forEach(ze=>{const pe=S.transform,Ee=Js(pe.zoom)*E.exaggeration();P=-1;const De=ze?U.LINES:U.TRIANGLES;for(const Ie of D){const Be=C.getTile(Ie),it=s.StencilMode.disabled,lt=E.prevTerrainTileForTile[Ie.key],He=E.terrainTileForTile[Ie.key];mo(lt,He)&&Hr.newMorphing(Ie.key,lt,He,F,250),N.activeTexture.set(U.TEXTURE0),Be.texture.bind(U.LINEAR,U.CLAMP_TO_EDGE);const st=Hr.getMorphValuesForProxy(Ie.key),wt=st?1:0;st&&s.extend$1(ge,{morphing:{srcDemTile:st.from,dstDemTile:st.to,phase:s.easeCubicInOut(st.phase)}});const xt=s.tileCornersToBounds(Ie.canonical),tt=s.getLatitudinalLod(xt.getCenter().lat),Ft=s.getGridMatrix(Ie.canonical,xt,tt,pe.worldSize/pe._pixelsPerMercatorPixel),jt=s.globeNormalizeECEF(s.globeTileBounds(Ie.canonical)),Vt=Ks(pe.projMatrix,Se,ae,jt,s.globeToMercatorTransition(pe.zoom),se,pe.frustumCorners.TL,pe.frustumCorners.TR,pe.frustumCorners.BR,pe.frustumCorners.BL,pe.globeCenterInViewSpace,pe.globeRadius,he,Ee,Ft);if(ee(wt,ze),E.setupElevationDraw(Be,j,ge),S.prepareDrawProgram(N,j,Ie.toUnwrapped()),ke){const[Gt,qi,Oi]=ze?ke.getWirefameBuffers(S.context,tt):ke.getGridBuffers(tt,Ee!==0);j.draw(N,De,te,it,ie,s.CullFaceMode.backCCW,Vt,"globe_raster",Gt,qi,Oi)}}}),ke){const ze=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];q&&ze.push("CUSTOM_ANTIALIASING"),j=S.useProgram("globeRaster",null,ze);for(const pe of D){const{x:Ee,y:De,z:Ie}=pe.canonical,Be=De===0,it=De===(1<<Ie)-1,[lt,He,st,wt]=ke.getPoleBuffers(Ie);if(wt&&(Be||it)){const xt=C.getTile(pe);N.activeTexture.set(U.TEXTURE0),xt.texture.bind(U.LINEAR,U.CLAMP_TO_EDGE);let tt=s.globePoleMatrixForTile(Ie,Ee,$);const Ft=s.globeNormalizeECEF(s.globeTileBounds(pe.canonical)),jt=(Vt,Gt)=>Vt.draw(N,U.TRIANGLES,te,s.StencilMode.disabled,ie,s.CullFaceMode.disabled,Ks($.projMatrix,tt,tt,Ft,0,se,$.frustumCorners.TL,$.frustumCorners.TR,$.frustumCorners.BR,$.frustumCorners.BL,$.globeCenterInViewSpace,$.globeRadius,he,0),"globe_pole_raster",Gt,st,wt);E.setupElevationDraw(xt,j,ge),S.prepareDrawProgram(N,j,pe.toUnwrapped()),Be&&jt(j,lt),it&&(tt=s.scale(s.create(),tt,[1,-1,1]),jt(j,He))}}}})(d,f,g,y,v);else{const S=d.context,E=S.gl;let C,D;const F=d.options.showTerrainWireframe?2:0,N=($,q)=>{if(D===$)return;const ee=[Fn[$]];q&&ee.push(Fn[F]),C=d.useProgram("terrainRaster",null,ee),D=$},U=d.colorModeForRenderPass(),j=new s.DepthMode(E.LEQUAL,s.DepthMode.ReadWrite,d.depthRangeFor3D);Hr.update(v);const P=d.transform,O=Js(P.zoom)*f.exaggeration();(F?[!1,!0]:[!1]).forEach($=>{D=-1;const q=$?E.LINES:E.TRIANGLES,[ee,ie]=$?f.getWirefameBuffer():[f.gridIndexBuffer,f.gridSegments];for(const te of y){const ae=g.getTile(te),se=s.StencilMode.disabled,fe=f.prevTerrainTileForTile[te.key],ke=f.terrainTileForTile[te.key];mo(fe,ke)&&Hr.newMorphing(te.key,fe,ke,v,250),S.activeTexture.set(E.TEXTURE0),ae.texture.bind(E.LINEAR,E.CLAMP_TO_EDGE,E.LINEAR_MIPMAP_NEAREST);const he=Hr.getMorphValuesForProxy(te.key),Se=he?1:0;let ge;he&&(ge={morphing:{srcDemTile:he.from,dstDemTile:he.to,phase:s.easeCubicInOut(he.phase)}});const ze=fo(te.projMatrix,Rc(te.canonical,P.renderWorldCopies)?O/10:O);N(Se,$),f.setupElevationDraw(ae,C,ge),d.prepareDrawProgram(S,C,te.toUnwrapped()),C.draw(S,q,j,se,U,s.CullFaceMode.backCCW,ze,"terrain_raster",f.gridBuffer,ee,ie)}})}}(o,this,this.proxySourceCache,r,this._updateTimestamp),this.renderingToTexture=!0,o.gpuTimingDeferredRenderEnd(),r.splice(0,r.length))}renderBatch(r){if(this._drapedRenderBatches.length===0)return r+1;this.renderingToTexture=!0;const o=this.painter,u=this.painter.context,d=this.proxySourceCache,f=this.proxiedCoords[d.id],g=this._drapedRenderBatches.shift(),y=[],v=o.style.order;let S=0;for(const E of f){const C=d.getTileByID(E.proxyTileKey),D=d.proxyCachedFBO[E.key]?d.proxyCachedFBO[E.key][r]:void 0,F=D!==void 0?d.renderCache[D]:this.pool[S++],N=D!==void 0;if(C.texture=F.tex,N&&!F.dirty){y.push(C.tileID);continue}let U;u.bindFramebuffer.set(F.fb.framebuffer),this.renderedToTile=!1,F.dirty&&(u.clear({color:s.Color.transparent,stencil:0}),F.dirty=!1);for(let j=g.start;j<=g.end;++j){const P=o.style._layers[v[j]];if(P.isHidden(o.transform.zoom))continue;const O=o.style._getLayerSourceCache(P),$=O?this.proxyToSource[E.key][O.id]:[E];if(!$)continue;const q=$;u.viewport.set([0,0,F.fb.width,F.fb.height]),U!==(O?O.id:null)&&(this._setupStencil(F,$,P,O),U=O?O.id:null),o.renderLayer(o,O,P,q)}this.renderedToTile?(F.dirty=!0,y.push(C.tileID)):N||--S,S===5&&(S=0,this.renderToBackBuffer(y))}return this.renderToBackBuffer(y),this.renderingToTexture=!1,u.bindFramebuffer.set(null),u.viewport.set([0,0,o.width,o.height]),g.end+1}postRender(){}renderCacheEfficiency(r){const o=r.order.length;if(o===0)return{efficiency:100};let u,d=0,f=0,g=!1;for(let y=0;y<o;++y){const v=r._layers[r.order[y]];this._style.isLayerDraped(v)?(g&&++d,++f):g||(g=!0,u=v.id)}return f===0?{efficiency:100}:{efficiency:100*(1-d/f),firstUndrapedLayer:u}}getMinElevationBelowMSL(){let r=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{r=Math.min(r,o.dem.tree.minimums[0])}),r===0?r:(r-30)*this._exaggeration}raycast(r,o,u){if(!this._visibleDemTiles)return null;const d=this._visibleDemTiles.filter(f=>f.dem).map(f=>{const g=f.tileID,y=1<<g.overscaledZ,{x:v,y:S}=g.canonical,E=v/y,C=(v+1)/y,D=S/y,F=(S+1)/y;return{minx:E,miny:D,maxx:C,maxy:F,t:f.dem.tree.raycastRoot(E,D,C,F,r,o,u),tile:f}});d.sort((f,g)=>(f.t!==null?f.t:Number.MAX_VALUE)-(g.t!==null?g.t:Number.MAX_VALUE));for(const f of d){if(f.t==null)return null;const g=f.tile.dem.tree.raycast(f.minx,f.miny,f.maxx,f.maxy,r,o,u);if(g!=null)return g}return null}_createFBO(){const r=this.painter.context,o=r.gl,u=this.drapeBufferSize;r.activeTexture.set(o.TEXTURE0);const d=new s.Texture(r,{width:u[0],height:u[1],data:null},o.RGBA);d.bind(o.LINEAR,o.CLAMP_TO_EDGE);const f=r.createFramebuffer(u[0],u[1],!1);return f.colorAttachment.set(d.texture),f.depthAttachment=new ne(r,f.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=r.createRenderbuffer(r.gl.DEPTH_STENCIL,u[0],u[1]),this._stencilRef=0,f.depthAttachment.set(this._sharedDepthStencil),r.clear({stencil:0})):f.depthAttachment.set(this._sharedDepthStencil),r.extTextureFilterAnisotropic&&!r.extTextureFilterAnisotropicForceOff&&o.texParameterf(o.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax),{fb:f,tex:d,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const r in this._style._sourceCaches)if(this._style._sourceCaches[r].hasTransition())return!0;return this._style.order.some(r=>{const o=this._style._layers[r],u=o.isHidden(this.painter.transform.zoom);return o.type==="custom"?!u&&o.shouldRedrape():!u&&o.hasTransition()})}_clearLineLayersFromRenderCache(){let r=!1;for(const u of this._style._getSources())if(u instanceof je){r=!0;break}if(!r)return;const o={};for(let u=0;u<this._style.order.length;++u){const d=this._style._layers[this._style.order[u]],f=this._style._getLayerSourceCache(d);if(f&&!o[f.id]&&!d.isHidden(this.painter.transform.zoom)&&d.type==="line"&&d.widthExpression()instanceof s.ZoomDependentExpression){o[f.id]=!0;for(const g of this.proxyCoords){const y=this.proxyToSource[g.key][f.id];if(y)for(const v of y)this._clearRenderCacheForTile(f.id,v)}}}}_clearRasterLayersFromRenderCache(){let r=!1;for(const u in this._style._sourceCaches)if(this._style._sourceCaches[u]._source instanceof Oe){r=!0;break}if(!r)return;const o={};for(let u=0;u<this._style.order.length;++u){const d=this._style._layers[this._style.order[u]],f=this._style._getLayerSourceCache(d);if(!f||o[f.id]||d.isHidden(this.painter.transform.zoom)||d.type!=="raster")continue;const g=d.paint.get("raster-fade-duration");for(const y of this.proxyCoords){const v=this.proxyToSource[y.key][f.id];if(v)for(const S of v){const E=hl(f.getTile(S),f.findLoadedParent(S,0),f,this.painter.transform,g);(E.opacity!==1||E.mix!==0)&&this._clearRenderCacheForTile(f.id,S)}}}}_setupDrapedRenderBatches(){const r=this._style.order,o=r.length;if(o===0)return;const u=[];let d,f=0,g=this._style._layers[r[f]];for(;!this._style.isLayerDraped(g)&&g.isHidden(this.painter.transform.zoom)&&++f<o;)g=this._style._layers[r[f]];for(;f<o;++f){const y=this._style._layers[r[f]];y.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(y)?d===void 0&&(d=f):d!==void 0&&(u.push({start:d,end:f-1}),d=void 0))}d!==void 0&&u.push({start:d,end:f-1}),this._drapedRenderBatches=u}_setupRenderCache(r){const o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){const g=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let y=0;y<g.length;++y){const v=Object.values(g[y]);o.renderCachePool.push(...v)}}return}this._clearRasterLayersFromRenderCache();const u=this.proxyCoords,d=this._tilesDirty;for(let g=u.length-1;g>=0;g--){const y=u[g];if(o.getTileByID(y.key),o.proxyCachedFBO[y.key]!==void 0){const v=r[y.key],S=this.proxyToSource[y.key];let E=0;for(const C in S){const D=S[C],F=v[C];if(!F||F.length!==D.length||D.some((N,U)=>N!==F[U]||d[C]&&d[C].hasOwnProperty(N.key))){E=-1;break}++E}for(const C in o.proxyCachedFBO[y.key])o.renderCache[o.proxyCachedFBO[y.key][C]].dirty=E<0||E!==Object.values(v).length}}const f=[...this._drapedRenderBatches];f.sort((g,y)=>y.end-y.start-(g.end-g.start));for(const g of f)for(const y of u){if(o.proxyCachedFBO[y.key])continue;let v=o.renderCachePool.pop();v===void 0&&o.renderCache.length<50&&(v=o.renderCache.length,o.renderCache.push(this._createFBO())),v!==void 0&&(o.proxyCachedFBO[y.key]={},o.proxyCachedFBO[y.key][g.start]=v,o.renderCache[v].dirty=!0)}this._tilesDirty={}}_setupStencil(r,o,u,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const f=this.painter.context,g=f.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let y;if(u.isTileClipped())y=o.length,this._overlapStencilMode.test={func:g.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(o[0].overscaledZ>o[o.length-1].overscaledZ))return void(this._overlapStencilType=!1);y=1,this._overlapStencilMode.test={func:g.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+y>255&&(f.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=y,this._overlapStencilMode.ref=this._stencilRef,u.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(r){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[r.key]),this._overlapStencilMode):s.StencilMode.disabled}_renderTileClippingMasks(r,o){const u=this.painter,d=this.painter.context,f=d.gl;u._tileClippingMaskIDs={},d.setColorMode(s.ColorMode.disabled),d.setDepthMode(s.DepthMode.disabled);const g=u.useProgram("clippingMask");for(const y of r){const v=u._tileClippingMaskIDs[y.key]=--o;g.draw(d,f.TRIANGLES,s.DepthMode.disabled,new s.StencilMode({func:f.ALWAYS,mask:0},v,255,f.KEEP,f.KEEP,f.REPLACE),s.ColorMode.disabled,s.CullFaceMode.disabled,ss(y.projMatrix),"$clipping",u.tileExtentBuffer,u.quadTriangleIndexBuffer,u.tileExtentSegments)}}pointCoordinate(r){const o=this.painter.transform;if(r.x<0||r.x>o.width||r.y<0||r.y>o.height)return null;const u=[r.x,r.y,1,1];s.transformMat4$1(u,u,o.pixelMatrixInverse),s.scale$1(u,u,1/u[3]),u[0]/=o.worldSize,u[1]/=o.worldSize;const d=o._camera.position,f=s.mercatorZfromAltitude(1,o.center.lat),g=[d[0],d[1],d[2]/f,0],y=s.subtract([],u.slice(0,3),g);s.normalize(y,y);const v=this.raycast(g,y,this._exaggeration);return v!==null&&v?(s.scaleAndAdd(g,g,y,v),g[3]=g[2],g[2]*=f,g):null}drawDepth(){const r=this.painter,o=r.context,u=this.proxySourceCache,d=Math.ceil(r.width),f=Math.ceil(r.height);if(!this._depthFBO||this._depthFBO.width===d&&this._depthFBO.height===f||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const g=o.gl,y=o.createFramebuffer(d,f,!0);o.activeTexture.set(g.TEXTURE0);const v=new s.Texture(o,{width:d,height:f,data:null},g.RGBA);v.bind(g.NEAREST,g.CLAMP_TO_EDGE),y.colorAttachment.set(v.texture);const S=o.createRenderbuffer(o.gl.DEPTH_COMPONENT16,d,f);y.depthAttachment.set(S),this._depthFBO=y,this._depthTexture=v}o.bindFramebuffer.set(this._depthFBO.framebuffer),o.viewport.set([0,0,d,f]),function(g,y,v,S){if(g.transform.projection.name==="globe")return;const E=g.context,C=E.gl;E.clear({depth:1});const D=g.useProgram("terrainDepth"),F=new s.DepthMode(C.LESS,s.DepthMode.ReadWrite,g.depthRangeFor3D);for(const N of S){const U=v.getTile(N),j=fo(N.projMatrix,0);y.setupElevationDraw(U,D),D.draw(E,C.TRIANGLES,F,s.StencilMode.disabled,s.ColorMode.unblended,s.CullFaceMode.backCCW,j,"terrain_depth",y.gridBuffer,y.gridIndexBuffer,y.gridNoSkirtSegments)}}(r,this,u,this.proxyCoords)}_setupProxiedCoordsForOrtho(r,o,u){if(r.getSource()instanceof gt)return this._setupProxiedCoordsForImageSource(r,o,u);this._findCoveringTileCache[r.id]=this._findCoveringTileCache[r.id]||{};const d=this.proxiedCoords[r.id]=[],f=this.proxyCoords;for(let y=0;y<f.length;y++){const v=f[y],S=this._findTileCoveringTileID(v,r);if(S){const E=this._createProxiedId(v,S,u[v.key]&&u[v.key][r.id]);d.push(E),this.proxyToSource[v.key][r.id]=[E]}}let g=!1;for(let y=0;y<o.length;y++){const v=r.getTile(o[y]);if(!v||!v.hasData())continue;const S=this._findTileCoveringTileID(v.tileID,this.proxySourceCache);if(S&&S.tileID.canonical.z!==v.tileID.canonical.z){const E=this.proxyToSource[S.tileID.key][r.id],C=this._createProxiedId(S.tileID,v,u[S.tileID.key]&&u[S.tileID.key][r.id]);E?E.splice(E.length-1,0,C):this.proxyToSource[S.tileID.key][r.id]=[C],d.push(C),g=!0}}this._sourceTilesOverlap[r.id]=g}_setupProxiedCoordsForImageSource(r,o,u){if(!r.getSource().loaded())return;const d=this.proxiedCoords[r.id]=[],f=this.proxyCoords,g=r.getSource(),y=new s.Point(g.tileID.x,g.tileID.y)._div(1<<g.tileID.z),v=g.coordinates.map(s.MercatorCoordinate.fromLngLat).reduce((E,C)=>(E.min.x=Math.min(E.min.x,C.x-y.x),E.min.y=Math.min(E.min.y,C.y-y.y),E.max.x=Math.max(E.max.x,C.x-y.x),E.max.y=Math.max(E.max.y,C.y-y.y),E),{min:new s.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new s.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),S=(E,C)=>{const D=E.wrap+E.canonical.x/(1<<E.canonical.z),F=E.canonical.y/(1<<E.canonical.z),N=s.EXTENT/(1<<E.canonical.z),U=C.wrap+C.canonical.x/(1<<C.canonical.z),j=C.canonical.y/(1<<C.canonical.z);return D+N<U+v.min.x||D>U+v.max.x||F+N<j+v.min.y||F>j+v.max.y};for(let E=0;E<f.length;E++){const C=f[E];for(let D=0;D<o.length;D++){const F=r.getTile(o[D]);if(!F||!F.hasData()||S(C,F.tileID))continue;const N=this._createProxiedId(C,F,u[C.key]&&u[C.key][r.id]),U=this.proxyToSource[C.key][r.id];U?U.push(N):this.proxyToSource[C.key][r.id]=[N],d.push(N)}}}_createProxiedId(r,o,u){let d=this.orthoMatrix;if(u){const f=u.find(g=>g.key===o.tileID.key);if(f)return f}if(o.tileID.key!==r.key){const f=r.canonical.z-o.tileID.canonical.z;let g,y,v;d=s.create();const S=o.tileID.wrap-r.wrap<<r.overscaledZ;f>0?(g=s.EXTENT>>f,y=g*((o.tileID.canonical.x<<f)-r.canonical.x+S),v=g*((o.tileID.canonical.y<<f)-r.canonical.y)):(g=s.EXTENT<<-f,y=s.EXTENT*(o.tileID.canonical.x-(r.canonical.x+S<<-f)),v=s.EXTENT*(o.tileID.canonical.y-(r.canonical.y<<-f))),s.ortho(d,0,g,0,g,0,1),s.translate(d,d,[y,v,0])}return new Qs(o.tileID,r.key,d)}_findTileCoveringTileID(r,o){let u=o.getTile(r);if(u&&u.hasData())return u;const d=this._findCoveringTileCache[o.id],f=d[r.key];if(u=f?o.getTileByID(f):null,u&&u.hasData()||f===null)return u;let g=u?u.tileID:r,y=g.overscaledZ;const v=o.getSource().minzoom,S=[];if(!f){const C=o.getSource().maxzoom;if(r.canonical.z>=C){const D=r.canonical.z-C;o.getSource().reparseOverscaled?(y=Math.max(r.canonical.z+2,o.transform.tileZoom),g=new s.OverscaledTileID(y,r.wrap,C,r.canonical.x>>D,r.canonical.y>>D)):D!==0&&(y=C,g=new s.OverscaledTileID(y,r.wrap,C,r.canonical.x>>D,r.canonical.y>>D))}g.key!==r.key&&(S.push(g.key),u=o.getTile(g))}const E=C=>{S.forEach(D=>{d[D]=C}),S.length=0};for(y-=1;y>=v&&(!u||!u.hasData());y--){u&&E(u.tileID.key);const C=g.calculateScaledKey(y);if(u=o.getTileByID(C),u&&u.hasData())break;const D=d[C];if(D===null)break;D===void 0?S.push(C):u=o.getTileByID(D)}return E(u?u.tileID.key:null),u&&u.hasData()?u:null}findDEMTileFor(r){return this.enabled?this._findTileCoveringTileID(r,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(r,o){let u=this._tilesDirty[r];u||(u=this._tilesDirty[r]={}),u[o.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const r=function(o){let u=0;const d=new s.StructArrayLayout2ui4,f=131;for(let g=1;g<129;g++){for(let y=1;y<129;y++)u=g*f+y,d.emplaceBack(u,u+1),d.emplaceBack(u,u+f),d.emplaceBack(u+1,u+f),g===128&&d.emplaceBack(u+f,u+f+1);d.emplaceBack(u+1,u+1+f)}return d}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(r),this.wireframeSegments=s.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Pt{static cacheKey(r,o,u,d){let f=`${o}${d?d.cacheKey:""}`;for(const g of u)r.usedDefines.includes(g)&&(f+=`/${g}`);return f}constructor(r,o,u,d,f,g){const y=r.gl;this.program=y.createProgram();const v=function(P){const O=[];for(let $=0;$<P.length;$++){if(P[$]===null)continue;const q=P[$].split(" ");O.push(q.pop())}return O}(u.staticAttributes),S=d?d.getBinderAttributes():[],E=v.concat(S);let C=d?d.defines():[];C=C.concat(g.map(P=>`#define ${P}`));const D=r.isWebGL2?`#version 300 es
`:"",F=D+C.concat(r.extStandardDerivatives&&D.length===0?`#extension GL_OES_standard_derivatives : enable
`.concat(sl):sl,sl,Hs,kc.fragmentSource,ho.fragmentSource,u.fragmentSource).join(`
`),N=D+C.concat(`
#ifdef GL_ES
precision highp float;
#else

#if !defined(lowp)
#define lowp
#endif

#if !defined(mediump)
#define mediump
#endif

#if !defined(highp)
#define highp
#endif

#endif`,Hs,kc.vertexSource,ho.vertexSource,Xs.vertexSource,u.vertexSource).join(`
`),U=y.createShader(y.FRAGMENT_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(U,F),y.compileShader(U),y.attachShader(this.program,U);const j=y.createShader(y.VERTEX_SHADER);if(y.isContextLost())this.failedToCreate=!0;else{y.shaderSource(j,N),y.compileShader(j),y.attachShader(this.program,j),this.attributes={},this.numAttributes=E.length;for(let P=0;P<this.numAttributes;P++)E[P]&&(y.bindAttribLocation(this.program,P,E[P]),this.attributes[E[P]]=P);y.linkProgram(this.program),y.deleteShader(j),y.deleteShader(U),this.fixedUniforms=f(r),this.binderUniforms=d?d.getUniforms(r):[],g.includes("TERRAIN")&&(this.terrainUniforms=(P=>({u_dem:new s.Uniform1i(P),u_dem_prev:new s.Uniform1i(P),u_dem_unpack:new s.Uniform4f(P),u_dem_tl:new s.Uniform2f(P),u_dem_scale:new s.Uniform1f(P),u_dem_tl_prev:new s.Uniform2f(P),u_dem_scale_prev:new s.Uniform1f(P),u_dem_size:new s.Uniform1f(P),u_dem_lerp:new s.Uniform1f(P),u_exaggeration:new s.Uniform1f(P),u_depth:new s.Uniform1i(P),u_depth_size_inv:new s.Uniform2f(P),u_meter_to_dem:new s.Uniform1f(P),u_label_plane_matrix_inv:new s.UniformMatrix4f(P)}))(r)),g.includes("GLOBE")&&(this.globeUniforms=(P=>({u_tile_tl_up:new s.Uniform3f(P),u_tile_tr_up:new s.Uniform3f(P),u_tile_br_up:new s.Uniform3f(P),u_tile_bl_up:new s.Uniform3f(P),u_tile_up_scale:new s.Uniform1f(P)}))(r)),g.includes("FOG")&&(this.fogUniforms=(P=>({u_fog_matrix:new s.UniformMatrix4f(P),u_fog_range:new s.Uniform2f(P),u_fog_color:new s.Uniform4f(P),u_fog_horizon_blend:new s.Uniform1f(P),u_fog_temporal_offset:new s.Uniform1f(P),u_frustum_tl:new s.Uniform3f(P),u_frustum_tr:new s.Uniform3f(P),u_frustum_br:new s.Uniform3f(P),u_frustum_bl:new s.Uniform3f(P),u_globe_pos:new s.Uniform3f(P),u_globe_radius:new s.Uniform1f(P),u_globe_transition:new s.Uniform1f(P),u_is_globe:new s.Uniform1i(P),u_viewport:new s.Uniform2f(P)}))(r))}}setTerrainUniformValues(r,o){if(!this.terrainUniforms)return;const u=this.terrainUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)u[d]&&u[d].set(this.program,d,o[d])}}setGlobeUniformValues(r,o){if(!this.globeUniforms)return;const u=this.globeUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)u[d]&&u[d].set(this.program,d,o[d])}}setFogUniformValues(r,o){if(!this.fogUniforms)return;const u=this.fogUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)u[d].set(this.program,d,o[d])}}draw(r,o,u,d,f,g,y,v,S,E,C,D,F,N,U){const j=r.gl;if(this.failedToCreate)return;r.program.set(this.program),r.setDepthMode(u),r.setStencilMode(d),r.setColorMode(f),r.setCullFace(g);for(const O of Object.keys(this.fixedUniforms))this.fixedUniforms[O].set(this.program,O,y[O]);N&&N.setUniforms(this.program,r,this.binderUniforms,D,{zoom:F});const P={[j.LINES]:2,[j.TRIANGLES]:3,[j.LINE_STRIP]:1}[o];for(const O of C.get()){const $=O.vaos||(O.vaos={});($[v]||($[v]=new lh)).bind(r,this,S,N?N.getPaintVertexBuffers():[],E,O.vertexOffset,U||[]),j.drawElements(o,O.primitiveLength*P,j.UNSIGNED_SHORT,O.primitiveOffset*P*2)}}}function as(l,r){const o=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,l.transform.tileZoom)/o,d=u*(r.tileID.canonical.x+r.tileID.wrap*o),f=u*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_tile_units_to_pixels:1/Li(r,1,l.transform.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[65535&d,65535&f]}}const Bc=s.create(),fl=(l,r,o,u,d,f,g,y,v,S,E)=>{const C=r.style.light,D=C.properties.get("position"),F=[D.x,D.y,D.z],N=s.create$1();C.properties.get("anchor")==="viewport"&&(s.fromRotation(N,-r.transform.angle),s.transformMat3(F,F,N));const U=C.properties.get("color"),j=r.transform,P={u_matrix:l,u_lightpos:F,u_lightintensity:C.properties.get("intensity"),u_lightcolor:[U.r,U.g,U.b],u_vertical_gradient:+o,u_opacity:u,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Bc,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:d,u_edge_radius:f};return j.projection.name==="globe"&&(P.u_tile_id=[g.canonical.x,g.canonical.y,1<<g.canonical.z],P.u_zoom_transition=v,P.u_inv_rot_matrix=E,P.u_merc_center=S,P.u_up_dir=j.projection.upVector(new s.CanonicalTileID(0,0,0),S[0]*s.EXTENT,S[1]*s.EXTENT),P.u_height_lift=y),P},Oc=(l,r,o,u,d,f,g,y,v,S,E,C)=>{const D=fl(l,r,o,u,d,f,g,v,S,E,C),F={u_height_factor:-Math.pow(2,g.overscaledZ)/y.tileSize/8};return s.extend(D,as(r,y),F)},Un=l=>({u_matrix:l}),ml=(l,r,o)=>s.extend(Un(l),as(r,o)),ch=(l,r)=>({u_matrix:l,u_world:r}),uh=(l,r,o,u)=>s.extend(ml(l,r,o),{u_world:u}),hh=s.create(),_l=(l,r,o,u,d,f)=>{const g=l.transform,y=g.projection.name==="globe";let v;if(f.paint.get("circle-pitch-alignment")==="map")if(y){const E=s.globePixelsToTileUnits(g.zoom,r.canonical)*g._pixelsPerMercatorPixel;v=Float32Array.from([E,0,0,E])}else v=g.calculatePixelsToTileUnitsMatrix(o);else v=new Float32Array([g.pixelsToGLUnits[0],0,0,g.pixelsToGLUnits[1]]);const S={u_camera_to_center_distance:g.cameraToCenterDistance,u_matrix:l.translatePosMatrix(r.projMatrix,o,f.paint.get("circle-translate"),f.paint.get("circle-translate-anchor")),u_device_pixel_ratio:s.exported.devicePixelRatio,u_extrude_scale:v,u_inv_rot_matrix:hh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(y){S.u_inv_rot_matrix=u,S.u_merc_center=d,S.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],S.u_zoom_transition=s.globeToMercatorTransition(g.zoom);const E=d[0]*s.EXTENT,C=d[1]*s.EXTENT;S.u_up_dir=g.projection.upVector(new s.CanonicalTileID(0,0,0),E,C)}return S},gl=l=>{const r=[];return l.paint.get("circle-pitch-alignment")==="map"&&r.push("PITCH_WITH_MAP"),l.paint.get("circle-pitch-scale")==="map"&&r.push("SCALE_WITH_MAP"),r},yl=(l,r,o,u)=>{const d=s.EXTENT/o.tileSize;return{u_matrix:l,u_camera_to_center_distance:r.getCameraToCenterDistance(u),u_extrude_scale:[r.pixelsToGLUnits[0]/d,r.pixelsToGLUnits[1]/d]}},ea=(l,r,o=1)=>({u_matrix:l,u_color:r,u_overlay:0,u_overlay_scale:o}),Fc=s.create(),Uc=(l,r,o,u,d,f,g)=>{const y=l.transform,v=y.projection.name==="globe",S=v?s.globePixelsToTileUnits(y.zoom,r.canonical)*y._pixelsPerMercatorPixel:Li(o,1,f),E={u_matrix:r.projMatrix,u_extrude_scale:S,u_intensity:g,u_inv_rot_matrix:Fc,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(v){E.u_inv_rot_matrix=u,E.u_merc_center=d,E.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],E.u_zoom_transition=s.globeToMercatorTransition(y.zoom);const C=d[0]*s.EXTENT,D=d[1]*s.EXTENT;E.u_up_dir=y.projection.upVector(new s.CanonicalTileID(0,0,0),C,D)}return E},dh=(l,r,o,u,d,f,g)=>{const y=l.transform,v=y.calculatePixelsToTileUnitsMatrix(r);return{u_matrix:xl(l,r,o,u),u_pixels_to_tile_units:v,u_device_pixel_ratio:f,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:d,u_texsize:cs(o)?r.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:_o(r,l.transform),u_alpha_discard_threshold:0,u_trim_offset:g}},ls=(l,r,o,u,d)=>{const f=l.transform;return{u_matrix:xl(l,r,o,u),u_texsize:r.imageAtlasTexture.size,u_pixels_to_tile_units:f.calculatePixelsToTileUnitsMatrix(r),u_device_pixel_ratio:d,u_image:0,u_tile_units_to_pixels:_o(r,f),u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function _o(l,r){return 1/Li(l,1,r.tileZoom)}function xl(l,r,o,u){return l.translatePosMatrix(u||r.tileID.projMatrix,r,o.paint.get("line-translate"),o.paint.get("line-translate-anchor"))}function cs(l){const r=l.paint.get("line-dasharray").value;return r.value||r.kind!=="constant"}const vl=(l,r,o,u,d,f)=>{return{u_matrix:l,u_tl_parent:r,u_scale_parent:o,u_fade_t:u.mix,u_opacity:u.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:(y=d.paint.get("raster-saturation"),y>0?1-1/(1.001-y):-y),u_contrast_factor:(g=d.paint.get("raster-contrast"),g>0?1/(1-g):1+g),u_spin_weights:Lr(d.paint.get("raster-hue-rotate")),u_perspective_transform:f};var g,y};function Lr(l){l*=Math.PI/180;const r=Math.sin(l),o=Math.cos(l);return[(2*o+1)/3,(-Math.sqrt(3)*r-o+1)/3,(Math.sqrt(3)*r-o+1)/3]}const ta=s.create(),bl=(l,r,o,u,d,f,g,y,v,S,E,C,D,F,N,U)=>{const j=d.transform,P={u_is_size_zoom_constant:+(l==="constant"||l==="source"),u_is_size_feature_constant:+(l==="constant"||l==="camera"),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:j.cameraToCenterDistance,u_rotate_symbol:+o,u_aspect_ratio:j.width/j.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:f,u_label_plane_matrix:g,u_coord_matrix:y,u_is_text:+v,u_pitch_with_map:+u,u_texsize:S,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ta,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:ta,u_up_vector:[0,-1,0]};return U.name==="globe"&&(P.u_tile_id=[E.canonical.x,E.canonical.y,1<<E.canonical.z],P.u_zoom_transition=C,P.u_inv_rot_matrix=F,P.u_merc_center=D,P.u_camera_forward=j._camera.forward(),P.u_ecef_origin=s.globeECEFOrigin(j.globeMatrix,E.toUnwrapped()),P.u_tile_matrix=Float32Array.from(j.globeMatrix),P.u_up_vector=N),P},ia=(l,r,o,u,d,f,g,y,v,S,E,C,D,F,N,U,j)=>s.extend(bl(l,r,o,u,d,f,g,y,v,S,C,D,F,N,U,j),{u_gamma_scale:u?d.transform.cameraToCenterDistance*Math.cos(d.terrain?0:d.transform._pitch):1,u_device_pixel_ratio:s.exported.devicePixelRatio,u_is_halo:+E}),Nc=(l,r,o,u,d,f,g,y,v,S,E,C,D,F,N,U)=>s.extend(ia(l,r,o,u,d,f,g,y,!0,v,!0,E,C,D,F,N,U),{u_texsize_icon:S,u_texture_icon:1}),wl=(l,r,o)=>({u_matrix:l,u_opacity:r,u_color:o}),ph=(l,r,o,u,d)=>s.extend(function(f,g,y){const v=g.imageManager.getPattern(f.toString()),{width:S,height:E}=g.imageManager.getPixelSize(),C=Math.pow(2,y.tileID.overscaledZ),D=y.tileSize*Math.pow(2,g.transform.tileZoom)/C,F=D*(y.tileID.canonical.x+y.tileID.wrap*C),N=D*y.tileID.canonical.y;return{u_image:0,u_pattern_tl:v.tl,u_pattern_br:v.br,u_texsize:[S,E],u_pattern_size:v.displaySize,u_tile_units_to_pixels:1/Li(y,1,g.transform.tileZoom),u_pixel_coord_upper:[F>>16,N>>16],u_pixel_coord_lower:[65535&F,65535&N]}}(u,o,d),{u_matrix:l,u_opacity:r}),Tl={fillExtrusion:l=>({u_matrix:new s.UniformMatrix4f(l),u_lightpos:new s.Uniform3f(l),u_lightintensity:new s.Uniform1f(l),u_lightcolor:new s.Uniform3f(l),u_vertical_gradient:new s.Uniform1f(l),u_opacity:new s.Uniform1f(l),u_edge_radius:new s.Uniform1f(l),u_ao:new s.Uniform2f(l),u_tile_id:new s.Uniform3f(l),u_zoom_transition:new s.Uniform1f(l),u_inv_rot_matrix:new s.UniformMatrix4f(l),u_merc_center:new s.Uniform2f(l),u_up_dir:new s.Uniform3f(l),u_height_lift:new s.Uniform1f(l)}),fillExtrusionPattern:l=>({u_matrix:new s.UniformMatrix4f(l),u_lightpos:new s.Uniform3f(l),u_lightintensity:new s.Uniform1f(l),u_lightcolor:new s.Uniform3f(l),u_vertical_gradient:new s.Uniform1f(l),u_height_factor:new s.Uniform1f(l),u_edge_radius:new s.Uniform1f(l),u_ao:new s.Uniform2f(l),u_tile_id:new s.Uniform3f(l),u_zoom_transition:new s.Uniform1f(l),u_inv_rot_matrix:new s.UniformMatrix4f(l),u_merc_center:new s.Uniform2f(l),u_up_dir:new s.Uniform3f(l),u_height_lift:new s.Uniform1f(l),u_image:new s.Uniform1i(l),u_texsize:new s.Uniform2f(l),u_pixel_coord_upper:new s.Uniform2f(l),u_pixel_coord_lower:new s.Uniform2f(l),u_tile_units_to_pixels:new s.Uniform1f(l),u_opacity:new s.Uniform1f(l)}),fill:l=>({u_matrix:new s.UniformMatrix4f(l)}),fillPattern:l=>({u_matrix:new s.UniformMatrix4f(l),u_image:new s.Uniform1i(l),u_texsize:new s.Uniform2f(l),u_pixel_coord_upper:new s.Uniform2f(l),u_pixel_coord_lower:new s.Uniform2f(l),u_tile_units_to_pixels:new s.Uniform1f(l)}),fillOutline:l=>({u_matrix:new s.UniformMatrix4f(l),u_world:new s.Uniform2f(l)}),fillOutlinePattern:l=>({u_matrix:new s.UniformMatrix4f(l),u_world:new s.Uniform2f(l),u_image:new s.Uniform1i(l),u_texsize:new s.Uniform2f(l),u_pixel_coord_upper:new s.Uniform2f(l),u_pixel_coord_lower:new s.Uniform2f(l),u_tile_units_to_pixels:new s.Uniform1f(l)}),circle:l=>({u_camera_to_center_distance:new s.Uniform1f(l),u_extrude_scale:new s.UniformMatrix2f(l),u_device_pixel_ratio:new s.Uniform1f(l),u_matrix:new s.UniformMatrix4f(l),u_inv_rot_matrix:new s.UniformMatrix4f(l),u_merc_center:new s.Uniform2f(l),u_tile_id:new s.Uniform3f(l),u_zoom_transition:new s.Uniform1f(l),u_up_dir:new s.Uniform3f(l)}),collisionBox:l=>({u_matrix:new s.UniformMatrix4f(l),u_camera_to_center_distance:new s.Uniform1f(l),u_extrude_scale:new s.Uniform2f(l)}),collisionCircle:l=>({u_matrix:new s.UniformMatrix4f(l),u_inv_matrix:new s.UniformMatrix4f(l),u_camera_to_center_distance:new s.Uniform1f(l),u_viewport_size:new s.Uniform2f(l)}),debug:l=>({u_color:new s.UniformColor(l),u_matrix:new s.UniformMatrix4f(l),u_overlay:new s.Uniform1i(l),u_overlay_scale:new s.Uniform1f(l)}),clippingMask:l=>({u_matrix:new s.UniformMatrix4f(l)}),heatmap:l=>({u_extrude_scale:new s.Uniform1f(l),u_intensity:new s.Uniform1f(l),u_matrix:new s.UniformMatrix4f(l),u_inv_rot_matrix:new s.UniformMatrix4f(l),u_merc_center:new s.Uniform2f(l),u_tile_id:new s.Uniform3f(l),u_zoom_transition:new s.Uniform1f(l),u_up_dir:new s.Uniform3f(l)}),heatmapTexture:l=>({u_image:new s.Uniform1i(l),u_color_ramp:new s.Uniform1i(l),u_opacity:new s.Uniform1f(l)}),hillshade:l=>({u_matrix:new s.UniformMatrix4f(l),u_image:new s.Uniform1i(l),u_latrange:new s.Uniform2f(l),u_light:new s.Uniform2f(l),u_shadow:new s.UniformColor(l),u_highlight:new s.UniformColor(l),u_accent:new s.UniformColor(l)}),hillshadePrepare:l=>({u_matrix:new s.UniformMatrix4f(l),u_image:new s.Uniform1i(l),u_dimension:new s.Uniform2f(l),u_zoom:new s.Uniform1f(l),u_unpack:new s.Uniform4f(l)}),line:l=>({u_matrix:new s.UniformMatrix4f(l),u_pixels_to_tile_units:new s.UniformMatrix2f(l),u_device_pixel_ratio:new s.Uniform1f(l),u_units_to_pixels:new s.Uniform2f(l),u_dash_image:new s.Uniform1i(l),u_gradient_image:new s.Uniform1i(l),u_image_height:new s.Uniform1f(l),u_texsize:new s.Uniform2f(l),u_tile_units_to_pixels:new s.Uniform1f(l),u_alpha_discard_threshold:new s.Uniform1f(l),u_trim_offset:new s.Uniform2f(l)}),linePattern:l=>({u_matrix:new s.UniformMatrix4f(l),u_texsize:new s.Uniform2f(l),u_pixels_to_tile_units:new s.UniformMatrix2f(l),u_device_pixel_ratio:new s.Uniform1f(l),u_image:new s.Uniform1i(l),u_units_to_pixels:new s.Uniform2f(l),u_tile_units_to_pixels:new s.Uniform1f(l),u_alpha_discard_threshold:new s.Uniform1f(l)}),raster:l=>({u_matrix:new s.UniformMatrix4f(l),u_tl_parent:new s.Uniform2f(l),u_scale_parent:new s.Uniform1f(l),u_fade_t:new s.Uniform1f(l),u_opacity:new s.Uniform1f(l),u_image0:new s.Uniform1i(l),u_image1:new s.Uniform1i(l),u_brightness_low:new s.Uniform1f(l),u_brightness_high:new s.Uniform1f(l),u_saturation_factor:new s.Uniform1f(l),u_contrast_factor:new s.Uniform1f(l),u_spin_weights:new s.Uniform3f(l),u_perspective_transform:new s.Uniform2f(l)}),symbolIcon:l=>({u_is_size_zoom_constant:new s.Uniform1i(l),u_is_size_feature_constant:new s.Uniform1i(l),u_size_t:new s.Uniform1f(l),u_size:new s.Uniform1f(l),u_camera_to_center_distance:new s.Uniform1f(l),u_rotate_symbol:new s.Uniform1i(l),u_aspect_ratio:new s.Uniform1f(l),u_fade_change:new s.Uniform1f(l),u_matrix:new s.UniformMatrix4f(l),u_label_plane_matrix:new s.UniformMatrix4f(l),u_coord_matrix:new s.UniformMatrix4f(l),u_is_text:new s.Uniform1i(l),u_pitch_with_map:new s.Uniform1i(l),u_texsize:new s.Uniform2f(l),u_tile_id:new s.Uniform3f(l),u_zoom_transition:new s.Uniform1f(l),u_inv_rot_matrix:new s.UniformMatrix4f(l),u_merc_center:new s.Uniform2f(l),u_camera_forward:new s.Uniform3f(l),u_tile_matrix:new s.UniformMatrix4f(l),u_up_vector:new s.Uniform3f(l),u_ecef_origin:new s.Uniform3f(l),u_texture:new s.Uniform1i(l)}),symbolSDF:l=>({u_is_size_zoom_constant:new s.Uniform1i(l),u_is_size_feature_constant:new s.Uniform1i(l),u_size_t:new s.Uniform1f(l),u_size:new s.Uniform1f(l),u_camera_to_center_distance:new s.Uniform1f(l),u_rotate_symbol:new s.Uniform1i(l),u_aspect_ratio:new s.Uniform1f(l),u_fade_change:new s.Uniform1f(l),u_matrix:new s.UniformMatrix4f(l),u_label_plane_matrix:new s.UniformMatrix4f(l),u_coord_matrix:new s.UniformMatrix4f(l),u_is_text:new s.Uniform1i(l),u_pitch_with_map:new s.Uniform1i(l),u_texsize:new s.Uniform2f(l),u_texture:new s.Uniform1i(l),u_gamma_scale:new s.Uniform1f(l),u_device_pixel_ratio:new s.Uniform1f(l),u_tile_id:new s.Uniform3f(l),u_zoom_transition:new s.Uniform1f(l),u_inv_rot_matrix:new s.UniformMatrix4f(l),u_merc_center:new s.Uniform2f(l),u_camera_forward:new s.Uniform3f(l),u_tile_matrix:new s.UniformMatrix4f(l),u_up_vector:new s.Uniform3f(l),u_ecef_origin:new s.Uniform3f(l),u_is_halo:new s.Uniform1i(l)}),symbolTextAndIcon:l=>({u_is_size_zoom_constant:new s.Uniform1i(l),u_is_size_feature_constant:new s.Uniform1i(l),u_size_t:new s.Uniform1f(l),u_size:new s.Uniform1f(l),u_camera_to_center_distance:new s.Uniform1f(l),u_rotate_symbol:new s.Uniform1i(l),u_aspect_ratio:new s.Uniform1f(l),u_fade_change:new s.Uniform1f(l),u_matrix:new s.UniformMatrix4f(l),u_label_plane_matrix:new s.UniformMatrix4f(l),u_coord_matrix:new s.UniformMatrix4f(l),u_is_text:new s.Uniform1i(l),u_pitch_with_map:new s.Uniform1i(l),u_texsize:new s.Uniform2f(l),u_texsize_icon:new s.Uniform2f(l),u_texture:new s.Uniform1i(l),u_texture_icon:new s.Uniform1i(l),u_gamma_scale:new s.Uniform1f(l),u_device_pixel_ratio:new s.Uniform1f(l),u_is_halo:new s.Uniform1i(l)}),background:l=>({u_matrix:new s.UniformMatrix4f(l),u_opacity:new s.Uniform1f(l),u_color:new s.UniformColor(l)}),backgroundPattern:l=>({u_matrix:new s.UniformMatrix4f(l),u_opacity:new s.Uniform1f(l),u_image:new s.Uniform1i(l),u_pattern_tl:new s.Uniform2f(l),u_pattern_br:new s.Uniform2f(l),u_texsize:new s.Uniform2f(l),u_pattern_size:new s.Uniform2f(l),u_pixel_coord_upper:new s.Uniform2f(l),u_pixel_coord_lower:new s.Uniform2f(l),u_tile_units_to_pixels:new s.Uniform1f(l)}),terrainRaster:ul,terrainDepth:ul,skybox:l=>({u_matrix:new s.UniformMatrix4f(l),u_sun_direction:new s.Uniform3f(l),u_cubemap:new s.Uniform1i(l),u_opacity:new s.Uniform1f(l),u_temporal_offset:new s.Uniform1f(l)}),skyboxGradient:l=>({u_matrix:new s.UniformMatrix4f(l),u_color_ramp:new s.Uniform1i(l),u_center_direction:new s.Uniform3f(l),u_radius:new s.Uniform1f(l),u_opacity:new s.Uniform1f(l),u_temporal_offset:new s.Uniform1f(l)}),skyboxCapture:l=>({u_matrix_3f:new s.UniformMatrix3f(l),u_sun_direction:new s.Uniform3f(l),u_sun_intensity:new s.Uniform1f(l),u_color_tint_r:new s.Uniform4f(l),u_color_tint_m:new s.Uniform4f(l),u_luminance:new s.Uniform1f(l)}),globeRaster:l=>({u_proj_matrix:new s.UniformMatrix4f(l),u_globe_matrix:new s.UniformMatrix4f(l),u_normalize_matrix:new s.UniformMatrix4f(l),u_merc_matrix:new s.UniformMatrix4f(l),u_zoom_transition:new s.Uniform1f(l),u_merc_center:new s.Uniform2f(l),u_image0:new s.Uniform1i(l),u_grid_matrix:new s.UniformMatrix3f(l),u_skirt_height:new s.Uniform1f(l),u_frustum_tl:new s.Uniform3f(l),u_frustum_tr:new s.Uniform3f(l),u_frustum_br:new s.Uniform3f(l),u_frustum_bl:new s.Uniform3f(l),u_globe_pos:new s.Uniform3f(l),u_globe_radius:new s.Uniform1f(l),u_viewport:new s.Uniform2f(l)}),globeAtmosphere:l=>({u_frustum_tl:new s.Uniform3f(l),u_frustum_tr:new s.Uniform3f(l),u_frustum_br:new s.Uniform3f(l),u_frustum_bl:new s.Uniform3f(l),u_horizon:new s.Uniform1f(l),u_transition:new s.Uniform1f(l),u_fadeout_range:new s.Uniform1f(l),u_color:new s.Uniform4f(l),u_high_color:new s.Uniform4f(l),u_space_color:new s.Uniform4f(l),u_star_intensity:new s.Uniform1f(l),u_star_density:new s.Uniform1f(l),u_star_size:new s.Uniform1f(l),u_temporal_offset:new s.Uniform1f(l),u_horizon_angle:new s.Uniform1f(l),u_rotation_matrix:new s.UniformMatrix4f(l)})};let ra;function us(l,r,o,u,d,f,g){const y=l.context,v=y.gl,S=l.transform,E=l.useProgram("collisionBox"),C=[];let D=0,F=0;for(let q=0;q<u.length;q++){const ee=u[q],ie=r.getTile(ee),te=ie.getBucket(o);if(!te)continue;const ae=dr(ee,te,S);let se=ae;d[0]===0&&d[1]===0||(se=l.translatePosMatrix(ae,ie,d,f));const fe=g?te.textCollisionBox:te.iconCollisionBox,ke=te.collisionCircleArray;if(ke.length>0){const he=s.create(),Se=se;s.mul(he,te.placementInvProjMatrix,S.glCoordMatrix),s.mul(he,he,te.placementViewportMatrix),C.push({circleArray:ke,circleOffset:F,transform:Se,invTransform:he,projection:te.getProjection()}),D+=ke.length/4,F=D}fe&&(l.terrain&&l.terrain.setupElevationDraw(ie,E),E.draw(y,v.LINES,s.DepthMode.disabled,s.StencilMode.disabled,l.colorModeForRenderPass(),s.CullFaceMode.disabled,yl(se,S,ie,te.getProjection()),o.id,fe.layoutVertexBuffer,fe.indexBuffer,fe.segments,null,S.zoom,null,[fe.collisionVertexBuffer,fe.collisionVertexBufferExt]))}if(!g||!C.length)return;const N=l.useProgram("collisionCircle"),U=new s.StructArrayLayout2f1f2i16;U.resize(4*D),U._trim();let j=0;for(const q of C)for(let ee=0;ee<q.circleArray.length/4;ee++){const ie=4*ee,te=q.circleArray[ie+0],ae=q.circleArray[ie+1],se=q.circleArray[ie+2],fe=q.circleArray[ie+3];U.emplace(j++,te,ae,se,fe,0),U.emplace(j++,te,ae,se,fe,1),U.emplace(j++,te,ae,se,fe,2),U.emplace(j++,te,ae,se,fe,3)}(!ra||ra.length<2*D)&&(ra=function(q){const ee=2*q,ie=new s.StructArrayLayout3ui6;ie.resize(ee),ie._trim();for(let te=0;te<ee;te++){const ae=6*te;ie.uint16[ae+0]=4*te+0,ie.uint16[ae+1]=4*te+1,ie.uint16[ae+2]=4*te+2,ie.uint16[ae+3]=4*te+2,ie.uint16[ae+4]=4*te+3,ie.uint16[ae+5]=4*te+0}return ie}(D));const P=y.createIndexBuffer(ra,!0),O=y.createVertexBuffer(U,s.collisionCircleLayout.members,!0);for(const q of C){const ee={u_matrix:q.transform,u_inv_matrix:q.invTransform,u_camera_to_center_distance:($=S).getCameraToCenterDistance(q.projection),u_viewport_size:[$.width,$.height]};N.draw(y,v.TRIANGLES,s.DepthMode.disabled,s.StencilMode.disabled,l.colorModeForRenderPass(),s.CullFaceMode.disabled,ee,o.id,O,P,s.SegmentVector.simpleSegment(0,2*q.circleOffset,q.circleArray.length,q.circleArray.length/2),null,S.zoom)}var $;O.destroy(),P.destroy()}const jc=s.create();function El({width:l,height:r,anchor:o,textOffset:u,textScale:d},f){const{horizontalAlign:g,verticalAlign:y}=s.getAnchorAlignment(o),v=-(g-.5)*l,S=-(y-.5)*r,E=s.evaluateVariableOffset(o,u);return new s.Point((v/d+E[0])*f,(S/d+E[1])*f)}function fh(l,r,o,u,d,f,g,y,v,S,E){const C=l.text.placedSymbolArray,D=l.text.dynamicLayoutVertexArray,F=l.icon.dynamicLayoutVertexArray,N={},U=l.getProjection(),j=ni(y,U,f),P=f.elevation,O=U.upVectorScale(y.canonical,f.center.lat,f.worldSize).metersToTile;D.clear();for(let $=0;$<C.length;$++){const q=C.get($),{tileAnchorX:ee,tileAnchorY:ie,numGlyphs:te}=q,ae=q.hidden||!q.crossTileID||l.allowVerticalPlacement&&!q.placedOrientation?null:u[q.crossTileID];if(ae){let se=0,fe=0,ke=0;if(P){const Be=P?P.getAtTileOffset(y,ee,ie):0,[it,lt,He]=U.upVector(y.canonical,ee,ie);se=Be*it*O,fe=Be*lt*O,ke=Be*He*O}let[he,Se,ge,ze]=Ri(q.projectedAnchorX+se,q.projectedAnchorY+fe,q.projectedAnchorZ+ke,o?j:g);const pe=Mc(f.getCameraToCenterDistance(U),ze);let Ee=d.evaluateSizeForFeature(l.textSizeData,S,q)*pe/s.ONE_EM;o&&(Ee*=l.tilePixelRatio/v);const De=El(ae,Ee);o?({x:he,y:Se,z:ge}=U.projectTilePoint(ee+De.x,ie+De.y,y.canonical),[he,Se,ge]=Ri(he+se,Se+fe,ge+ke,g)):(r&&De._rotate(-f.angle),he+=De.x,Se+=De.y,ge=0);const Ie=l.allowVerticalPlacement&&q.placedOrientation===s.WritingMode.vertical?Math.PI/2:0;for(let Be=0;Be<te;Be++)s.addDynamicAttributes(D,he,Se,ge,Ie);E&&q.associatedIconIndex>=0&&(N[q.associatedIconIndex]={x:he,y:Se,z:ge,angle:Ie})}else Tr(te,D)}if(E){F.clear();const $=l.icon.placedSymbolArray;for(let q=0;q<$.length;q++){const ee=$.get(q),{numGlyphs:ie}=ee,te=N[q];if(ee.hidden||!te)Tr(ie,F);else{const{x:ae,y:se,z:fe,angle:ke}=te;for(let he=0;he<ie;he++)s.addDynamicAttributes(F,ae,se,fe,ke)}}l.icon.dynamicLayoutVertexBuffer.updateData(F)}l.text.dynamicLayoutVertexBuffer.updateData(D)}function Sl(l,r,o){return o.iconsInText&&r?"symbolTextAndIcon":l?"symbolSDF":"symbolIcon"}function Vc(l,r,o,u,d,f,g,y,v,S,E,C){const D=l.context,F=D.gl,N=l.transform,U=y==="map",j=v==="map",P=U&&o.layout.get("symbol-placement")!=="point",O=U&&!j&&!P,$=o.layout.get("symbol-sort-key").constantOr(1)!==void 0;let q=!1;const ee=l.depthModeForSublayer(0,s.DepthMode.ReadOnly),ie=[s.mercatorXfromLng(N.center.lng),s.mercatorYfromLat(N.center.lat)],te=o.layout.get("text-variable-anchor"),ae=N.projection.name==="globe",se=[],fe=[0,-1,0];let ke=fe;!ae&&!N.mercatorFromTransition||U||(ke=function(he){const Se=he._camera.getWorldToCamera(he.worldSize,1),ge=s.multiply([],Se,he.globeMatrix);s.invert(ge,ge);const ze=[0,0,0],pe=[0,1,0,0];return s.transformMat4$1(pe,pe,ge),ze[0]=pe[0],ze[1]=pe[1],ze[2]=pe[2],s.normalize(ze,ze),ze}(N));for(const he of u){const Se=r.getTile(he),ge=Se.getBucket(o);if(!ge||ge.projection.name==="mercator"&&ae)continue;const ze=d?ge.text:ge.icon;if(!ze||ge.fullyClipped||!ze.segments.get().length)continue;const pe=ze.programConfigurations.get(o.id),Ee=d||ge.sdfIcons,De=d?ge.textSizeData:ge.iconSizeData,Ie=j||N.pitch!==0,Be=s.evaluateSizeForZoom(De,N.zoom);let it,lt,He,st,wt=[0,0],xt=null;if(d)lt=Se.glyphAtlasTexture,He=F.LINEAR,it=Se.glyphAtlasTexture.size,ge.iconsInText&&(wt=Se.imageAtlasTexture.size,xt=Se.imageAtlasTexture,st=Ie||l.options.rotating||l.options.zooming||De.kind==="composite"||De.kind==="camera"?F.LINEAR:F.NEAREST);else{const Yr=o.layout.get("icon-size").constantOr(0)!==1||ge.iconsNeedLinear;lt=Se.imageAtlasTexture,He=Ee||l.options.rotating||l.options.zooming||Yr||Ie?F.LINEAR:F.NEAREST,it=Se.imageAtlasTexture.size}const tt=ge.projection.name==="globe",Ft=tt?ke:fe,jt=tt?s.globeToMercatorTransition(N.zoom):0,Vt=ni(he,ge.getProjection(),N),Gt=N.calculatePixelsToTileUnitsMatrix(Se),qi=be(Vt,Se.tileID.canonical,j,U,N,ge.getProjection(),Gt),Oi=l.terrain&&j&&P?s.invert(s.create(),qi):jc,_r=bi(Vt,Se.tileID.canonical,j,U,N,ge.getProjection(),Gt),Rr=te&&ge.hasTextData(),oi=o.layout.get("icon-text-fit")!=="none"&&Rr&&ge.hasIconData();if(P){const Yr=N.elevation,yn=Yr?Yr.getAtTileOffsetFunc(he,N.center.lat,N.worldSize,ge.getProjection()):null,$n=$r(Vt,Se.tileID.canonical,j,U,N,ge.getProjection(),Gt);Ja(ge,Vt,l,d,$n,_r,j,S,yn,he)}const $t=P||d&&te||oi,Dt=l.translatePosMatrix(Vt,Se,f,g),wi=$t?jc:qi,Hi=l.translatePosMatrix(_r,Se,f,g,!0),ii=ge.getProjection().createInversionMatrix(N,he.canonical),Yi=[];l.terrainRenderModeElevated()&&j&&Yi.push("PITCH_WITH_MAP_TERRAIN"),tt&&Yi.push("PROJECTION_GLOBE_VIEW"),$t&&Yi.push("PROJECTED_POS_ON_VIEWPORT");const xa=Ee&&o.paint.get(d?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Gn;Gn=Ee?ge.iconsInText?Nc(De.kind,Be,O,j,l,Dt,wi,Hi,it,wt,he,jt,ie,ii,Ft,ge.getProjection()):ia(De.kind,Be,O,j,l,Dt,wi,Hi,d,it,!0,he,jt,ie,ii,Ft,ge.getProjection()):bl(De.kind,Be,O,j,l,Dt,wi,Hi,d,it,he,jt,ie,ii,Ft,ge.getProjection());const bs={program:l.useProgram(Sl(Ee,d,ge),pe,Yi),buffers:ze,uniformValues:Gn,atlasTexture:lt,atlasTextureIcon:xt,atlasInterpolation:He,atlasInterpolationIcon:st,isSDF:Ee,hasHalo:xa,tile:Se,labelPlaneMatrixInv:Oi};if($&&ge.canOverlap){q=!0;const Yr=ze.segments.get();for(const yn of Yr)se.push({segments:new s.SegmentVector([yn]),sortKey:yn.sortKey,state:bs})}else se.push({segments:ze.segments,sortKey:0,state:bs})}q&&se.sort((he,Se)=>he.sortKey-Se.sortKey);for(const he of se){const Se=he.state;if(l.terrain&&l.terrain.setupElevationDraw(Se.tile,Se.program,{useDepthForOcclusion:!ae,labelPlaneMatrixInv:Se.labelPlaneMatrixInv}),D.activeTexture.set(F.TEXTURE0),Se.atlasTexture.bind(Se.atlasInterpolation,F.CLAMP_TO_EDGE),Se.atlasTextureIcon&&(D.activeTexture.set(F.TEXTURE1),Se.atlasTextureIcon&&Se.atlasTextureIcon.bind(Se.atlasInterpolationIcon,F.CLAMP_TO_EDGE)),Se.isSDF){const ge=Se.uniformValues;Se.hasHalo&&(ge.u_is_halo=1,hs(Se.buffers,he.segments,o,l,Se.program,ee,E,C,ge)),ge.u_is_halo=0}hs(Se.buffers,he.segments,o,l,Se.program,ee,E,C,Se.uniformValues)}}function hs(l,r,o,u,d,f,g,y,v){const S=u.context,E=[l.dynamicLayoutVertexBuffer,l.opacityVertexBuffer,l.globeExtVertexBuffer];d.draw(S,S.gl.TRIANGLES,f,g,y,s.CullFaceMode.disabled,v,o.id,l.layoutVertexBuffer,l.indexBuffer,r,o.paint,u.transform.zoom,l.programConfigurations.get(o.id),E)}function Gc(l,r,o,u,d,f,g){const y=l.context.gl,v=o.paint.get("fill-pattern"),S=v&&v.constantOr(1);let E,C,D,F,N;g?(C=S&&!o.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",E=y.LINES):(C=S?"fillPattern":"fill",E=y.TRIANGLES);for(const U of u){const j=r.getTile(U);if(S&&!j.patternsLoaded())continue;const P=j.getBucket(o);if(!P)continue;l.prepareDrawTile();const O=P.programConfigurations.get(o.id),$=l.useProgram(C,O);S&&(l.context.activeTexture.set(y.TEXTURE0),j.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),O.updatePaintBuffers());const q=v.constantOr(null);if(q&&j.imageAtlas){const ie=j.imageAtlas.patternPositions[q.toString()];ie&&O.setConstantPatternPositions(ie)}const ee=l.translatePosMatrix(U.projMatrix,j,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));if(g){F=P.indexBuffer2,N=P.segments2;const ie=l.terrain&&l.terrain.renderingToTexture?l.terrain.drapeBufferSize:[y.drawingBufferWidth,y.drawingBufferHeight];D=C==="fillOutlinePattern"&&S?uh(ee,l,j,ie):ch(ee,ie)}else F=P.indexBuffer,N=P.segments,D=S?ml(ee,l,j):Un(ee);l.prepareDrawProgram(l.context,$,U.toUnwrapped()),$.draw(l.context,E,d,l.stencilModeForClipping(U),f,s.CullFaceMode.disabled,D,o.id,P.layoutVertexBuffer,F,N,o.paint,l.transform.zoom,O)}}function na(l,r,o,u,d,f,g){const y=l.context,v=y.gl,S=l.transform,E=o.paint.get("fill-extrusion-pattern"),C=E.constantOr(1),D=o.paint.get("fill-extrusion-opacity"),F=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),o.paint.get("fill-extrusion-ambient-occlusion-radius")],N=o.layout.get("fill-extrusion-edge-radius"),U=N>0&&!o.paint.get("fill-extrusion-rounded-roof"),j=U?0:N,P=S.projection.name==="globe"?s.fillExtrusionHeightLift():0,O=S.projection.name==="globe",$=O?s.globeToMercatorTransition(S.zoom):0,q=[s.mercatorXfromLng(S.center.lng),s.mercatorYfromLat(S.center.lat)],ee=[];O&&ee.push("PROJECTION_GLOBE_VIEW"),F[0]>0&&ee.push("FAUX_AO"),U&&ee.push("ZERO_ROOF_RADIUS");for(const ie of u){const te=r.getTile(ie),ae=te.getBucket(o);if(!ae||ae.projection.name!==S.projection.name)continue;const se=ae.programConfigurations.get(o.id),fe=l.useProgram(C?"fillExtrusionPattern":"fillExtrusion",se,ee);if(l.terrain){const Ee=l.terrain;if(l.style.terrainSetForDrapingOnly())Ee.setupElevationDraw(te,fe,{useMeterToDem:!0});else{if(!ae.enableTerrain)continue;if(Ee.setupElevationDraw(te,fe,{useMeterToDem:!0}),$c(y,r,ie,ae,o,Ee),!ae.centroidVertexBuffer){const De=fe.attributes.a_centroid_pos;De!==void 0&&v.vertexAttrib2f(De,0,0)}}}C&&(l.context.activeTexture.set(v.TEXTURE0),te.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),se.updatePaintBuffers());const ke=E.constantOr(null);if(ke&&te.imageAtlas){const Ee=te.imageAtlas.patternPositions[ke.toString()];Ee&&se.setConstantPatternPositions(Ee)}const he=l.translatePosMatrix(ie.projMatrix,te,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),Se=S.projection.createInversionMatrix(S,ie.canonical),ge=o.paint.get("fill-extrusion-vertical-gradient"),ze=C?Oc(he,l,ge,D,F,j,ie,te,P,$,q,Se):fl(he,l,ge,D,F,j,ie,P,$,q,Se);l.prepareDrawProgram(y,fe,ie.toUnwrapped());const pe=[];l.terrain&&pe.push(ae.centroidVertexBuffer),O&&pe.push(ae.layoutVertexExtBuffer),fe.draw(y,y.gl.TRIANGLES,d,f,g,s.CullFaceMode.backCCW,ze,o.id,ae.layoutVertexBuffer,ae.indexBuffer,ae.segments,o.paint,l.transform.zoom,se,pe)}}function $c(l,r,o,u,d,f){const g=[P=>{let O=P.canonical.x-1,$=P.wrap;return O<0&&(O=(1<<P.canonical.z)-1,$--),new s.OverscaledTileID(P.overscaledZ,$,P.canonical.z,O,P.canonical.y)},P=>{let O=P.canonical.x+1,$=P.wrap;return O===1<<P.canonical.z&&(O=0,$++),new s.OverscaledTileID(P.overscaledZ,$,P.canonical.z,O,P.canonical.y)},P=>new s.OverscaledTileID(P.overscaledZ,P.wrap,P.canonical.z,P.canonical.x,(P.canonical.y===0?1<<P.canonical.z:P.canonical.y)-1),P=>new s.OverscaledTileID(P.overscaledZ,P.wrap,P.canonical.z,P.canonical.x,P.canonical.y===(1<<P.canonical.z)-1?0:P.canonical.y+1)],y=P=>{const O=r.getSource().minzoom,$=ee=>{const ie=r.getTileByID(ee);if(ie&&ie.hasData())return ie.getBucket(d)},q=[0,-1,1];for(const ee of q){if(P.overscaledZ+ee<O)continue;const ie=$(P.calculateScaledKey(P.overscaledZ+ee));if(ie)return ie}},v=[0,0,0],S=(P,O)=>(v[0]=Math.min(P.min.y,O.min.y),v[1]=Math.max(P.max.y,O.max.y),v[2]=s.EXTENT-O.min.x>P.max.x?O.min.x-s.EXTENT:P.max.x,v),E=(P,O)=>(v[0]=Math.min(P.min.x,O.min.x),v[1]=Math.max(P.max.x,O.max.x),v[2]=s.EXTENT-O.min.y>P.max.y?O.min.y-s.EXTENT:P.max.y,v),C=[(P,O)=>S(P,O),(P,O)=>S(O,P),(P,O)=>E(P,O),(P,O)=>E(O,P)],D=new s.Point(0,0);let F,N,U;const j=(P,O,$,q,ee)=>{const ie=[[q?$:P,q?P:$,0],[q?$:O,q?O:$,0]],te=ee<0?s.EXTENT+ee:ee,ae=[q?te:(P+O)/2,q?(P+O)/2:te,0];return $===0&&ee<0||$!==0&&ee>0?f.getForTilePoints(U,[ae],!0,N):ie.push(ae),f.getForTilePoints(o,ie,!0,F),Math.max(ie[0][2],ie[1][2],ae[2])/f.exaggeration()};for(let P=0;P<4;P++){const O=(P<2?1:5)-P,$=u.borders[P];if($.length===0)continue;const q=U=g[P](o),ee=y(q);if(!(ee&&ee instanceof s.FillExtrusionBucket&&ee.enableTerrain)||u.borderDoneWithNeighborZ[P]===ee.canonical.z&&ee.borderDoneWithNeighborZ[O]===u.canonical.z||(N=f.findDEMTileFor(q),!N||!N.dem))continue;if(!F){const se=f.findDEMTileFor(o);if(!se||!se.dem)return;F=se}const ie=ee.borders[O];let te=0;const ae=ee.borderDoneWithNeighborZ[O]!==u.canonical.z;if(u.canonical.z===ee.canonical.z){for(let se=0;se<$.length;se++){const fe=u.featuresOnBorder[$[se]],ke=fe.borders[P];let he;for(;te<ie.length&&(he=ee.featuresOnBorder[ie[te]],!(he.borders[O][1]>ke[0]+3));)ae&&ee.encodeCentroid(void 0,he,!1),te++;if(he&&te<ie.length){const Se=te;let ge=0;for(;!(he.borders[O][0]>ke[1]-3)&&(ge++,++te!==ie.length);)he=ee.featuresOnBorder[ie[te]];if(he=ee.featuresOnBorder[ie[Se]],fe.intersectsCount()>1||he.intersectsCount()>1||ge!==1){ge!==1&&(te=Se),u.encodeCentroid(void 0,fe,!1),ae&&ee.encodeCentroid(void 0,he,!1);continue}const ze=C[P](fe,he),pe=P%2?s.EXTENT-1:0;D.x=j(ze[0],Math.min(s.EXTENT-1,ze[1]),pe,P<2,ze[2]),D.y=0,u.encodeCentroid(D,fe,!1),ae&&ee.encodeCentroid(D,he,!1)}else u.encodeCentroid(void 0,fe,!1)}u.borderDoneWithNeighborZ[P]=ee.canonical.z,u.needsCentroidUpdate=!0,ae&&(ee.borderDoneWithNeighborZ[O]=u.canonical.z,ee.needsCentroidUpdate=!0)}else{for(const se of $)u.encodeCentroid(void 0,u.featuresOnBorder[se],!1);if(ae){for(const se of ie)ee.encodeCentroid(void 0,ee.featuresOnBorder[se],!1);ee.borderDoneWithNeighborZ[O]=u.canonical.z,ee.needsCentroidUpdate=!0}u.borderDoneWithNeighborZ[P]=ee.canonical.z,u.needsCentroidUpdate=!0}}(u.needsCentroidUpdate||!u.centroidVertexBuffer&&u.centroidVertexArray.length!==0)&&u.uploadCentroid(l)}const go=new s.Color(1,0,0,1),mh=new s.Color(0,1,0,1),_h=new s.Color(0,0,1,1),gh=new s.Color(1,0,1,1),yh=new s.Color(0,1,1,1);function xh(l,r,o){const u=l.context,d=l.transform,f=u.gl,g=d.projection.name==="globe",y=g?["PROJECTION_GLOBE_VIEW"]:null;let v=o.projMatrix;if(g&&s.globeToMercatorTransition(d.zoom)>0){const fe=s.transitionTileAABBinECEF(o.canonical,d),ke=s.globeDenormalizeECEF(fe);v=s.multiply(new Float32Array(16),d.globeMatrix,ke),s.multiply(v,d.projMatrix,v)}const S=l.useProgram("debug",null,y),E=r.getTileByID(o.key);l.terrain&&l.terrain.setupElevationDraw(E,S);const C=s.DepthMode.disabled,D=s.StencilMode.disabled,F=l.colorModeForRenderPass(),N="$debug";u.activeTexture.set(f.TEXTURE0),l.emptyTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE),g?E._makeGlobeTileDebugBuffers(l.context,d):E._makeDebugTileBoundsBuffers(l.context,d.projection);const U=E._tileDebugBuffer||l.debugBuffer,j=E._tileDebugIndexBuffer||l.debugIndexBuffer,P=E._tileDebugSegments||l.debugSegments;S.draw(u,f.LINE_STRIP,C,D,F,s.CullFaceMode.disabled,ea(v,s.Color.red),N,U,j,P,null,null,null,[E._globeTileDebugBorderBuffer]);const O=E.latestRawTileData,$=Math.floor((O&&O.byteLength||0)/1024),q=r.getTile(o).tileSize,ee=512/Math.min(q,512)*(o.overscaledZ/d.zoom)*.5;let ie=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(ie+=` => ${o.overscaledZ}`),ie+=` ${$}kb`,function(fe,ke){fe.initDebugOverlayCanvas();const he=fe.debugOverlayCanvas,Se=fe.context.gl,ge=fe.debugOverlayCanvas.getContext("2d");ge.clearRect(0,0,he.width,he.height),ge.shadowColor="white",ge.shadowBlur=2,ge.lineWidth=1.5,ge.strokeStyle="white",ge.textBaseline="top",ge.font="bold 36px Open Sans, sans-serif",ge.fillText(ke,5,5),ge.strokeText(ke,5,5),fe.debugOverlayTexture.update(he),fe.debugOverlayTexture.bind(Se.LINEAR,Se.CLAMP_TO_EDGE)}(l,ie);const te=E._tileDebugTextBuffer||l.debugBuffer,ae=E._tileDebugTextIndexBuffer||l.quadTriangleIndexBuffer,se=E._tileDebugTextSegments||l.debugSegments;S.draw(u,f.TRIANGLES,C,D,s.ColorMode.alphaBlended,s.CullFaceMode.disabled,ea(v,s.Color.transparent,ee),N,te,ae,se,null,null,null,[E._globeTileDebugTextBuffer])}function qc(l,r,o,u){yo(l,0,r+o/2,l.transform.width,o,u)}function oa(l,r,o,u){yo(l,r-o/2,0,o,l.transform.height,u)}function yo(l,r,o,u,d,f){const g=l.context,y=g.gl;y.enable(y.SCISSOR_TEST),y.scissor(r*s.exported.devicePixelRatio,o*s.exported.devicePixelRatio,u*s.exported.devicePixelRatio,d*s.exported.devicePixelRatio),g.clear({color:f}),y.disable(y.SCISSOR_TEST)}const Zc=s.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Wc}=Zc;function Kr(l,r,o,u){l.emplaceBack(r,o,u)}class sa{constructor(r){this.vertexArray=new s.StructArrayLayout3f12,this.indices=new s.StructArrayLayout3ui6,Kr(this.vertexArray,-1,-1,1),Kr(this.vertexArray,1,-1,1),Kr(this.vertexArray,-1,1,1),Kr(this.vertexArray,1,1,1),Kr(this.vertexArray,-1,-1,-1),Kr(this.vertexArray,1,-1,-1),Kr(this.vertexArray,-1,1,-1),Kr(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=r.createVertexBuffer(this.vertexArray,Wc),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=s.SegmentVector.simpleSegment(0,0,36,12)}}function fr(l,r,o,u,d,f){const g=l.gl,y=r.paint.get("sky-atmosphere-color"),v=r.paint.get("sky-atmosphere-halo-color"),S=r.paint.get("sky-atmosphere-sun-intensity"),E=((C,D,F,N,U)=>({u_matrix_3f:C,u_sun_direction:D,u_sun_intensity:F,u_color_tint_r:[N.r,N.g,N.b,N.a],u_color_tint_m:[U.r,U.g,U.b,U.a],u_luminance:5e-5}))(s.fromMat4(s.create$1(),u),d,S,y,v);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_CUBE_MAP_POSITIVE_X+f,r.skyboxTexture,0),o.draw(l,g.TRIANGLES,s.DepthMode.disabled,s.StencilMode.disabled,s.ColorMode.unblended,s.CullFaceMode.frontCW,E,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}const ds=s.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Xc{constructor(r){const o=new s.StructArrayLayout5f20;o.emplaceBack(-1,1,1,0,0),o.emplaceBack(1,1,1,1,0),o.emplaceBack(1,-1,1,1,1),o.emplaceBack(-1,-1,1,0,1);const u=new s.StructArrayLayout3ui6;u.emplaceBack(0,1,2),u.emplaceBack(2,3,0),this.vertexBuffer=r.createVertexBuffer(o,ds.members),this.indexBuffer=r.createIndexBuffer(u),this.segments=s.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Nn={symbol:function(l,r,o,u,d){if(l.renderPass!=="translucent")return;const f=s.StencilMode.disabled,g=l.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(y,v,S,E,C,D,F){const N=v.transform,U=C==="map",j=D==="map";for(const P of y){const O=E.getTile(P),$=O.getBucket(S);if(!$||!$.text||!$.text.segments.get().length)continue;const q=s.evaluateSizeForZoom($.textSizeData,N.zoom),ee=ni(P,$.getProjection(),N),ie=N.calculatePixelsToTileUnitsMatrix(O),te=be(ee,O.tileID.canonical,j,U,N,$.getProjection(),ie),ae=S.layout.get("icon-text-fit")!=="none"&&$.hasIconData();if(q){const se=Math.pow(2,N.zoom-O.tileID.overscaledZ);fh($,U,j,F,s.symbolSize,N,te,P,se,q,ae)}}}(u,l,o,r,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),d),o.paint.get("icon-opacity").constantOr(1)!==0&&Vc(l,r,o,u,!1,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),o.layout.get("icon-rotation-alignment"),o.layout.get("icon-pitch-alignment"),o.layout.get("icon-keep-upright"),f,g),o.paint.get("text-opacity").constantOr(1)!==0&&Vc(l,r,o,u,!0,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),o.layout.get("text-keep-upright"),f,g),r.map.showCollisionBoxes&&(us(l,r,o,u,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),us(l,r,o,u,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(l,r,o,u){if(l.renderPass!=="translucent")return;const d=o.paint.get("circle-opacity"),f=o.paint.get("circle-stroke-width"),g=o.paint.get("circle-stroke-opacity"),y=o.layout.get("circle-sort-key").constantOr(1)!==void 0;if(d.constantOr(1)===0&&(f.constantOr(1)===0||g.constantOr(1)===0))return;const v=l.context,S=v.gl,E=l.transform,C=l.depthModeForSublayer(0,s.DepthMode.ReadOnly),D=s.StencilMode.disabled,F=l.colorModeForRenderPass(),N=E.projection.name==="globe",U=[s.mercatorXfromLng(E.center.lng),s.mercatorYfromLat(E.center.lat)],j=[];for(let O=0;O<u.length;O++){const $=u[O],q=r.getTile($),ee=q.getBucket(o);if(!ee||ee.projection.name!==E.projection.name)continue;const ie=ee.programConfigurations.get(o.id),te=gl(o);N&&te.push("PROJECTION_GLOBE_VIEW");const ae=l.useProgram("circle",ie,te),se=ee.layoutVertexBuffer,fe=ee.globeExtVertexBuffer,ke=ee.indexBuffer,he=E.projection.createInversionMatrix(E,$.canonical),Se={programConfiguration:ie,program:ae,layoutVertexBuffer:se,globeExtVertexBuffer:fe,indexBuffer:ke,uniformValues:_l(l,$,q,he,U,o),tile:q};if(y){const ge=ee.segments.get();for(const ze of ge)j.push({segments:new s.SegmentVector([ze]),sortKey:ze.sortKey,state:Se})}else j.push({segments:ee.segments,sortKey:0,state:Se})}y&&j.sort((O,$)=>O.sortKey-$.sortKey);const P={useDepthForOcclusion:!N};for(const O of j){const{programConfiguration:$,program:q,layoutVertexBuffer:ee,globeExtVertexBuffer:ie,indexBuffer:te,uniformValues:ae,tile:se}=O.state,fe=O.segments;l.terrain&&l.terrain.setupElevationDraw(se,q,P),l.prepareDrawProgram(v,q,se.tileID.toUnwrapped()),q.draw(v,S.TRIANGLES,C,D,F,s.CullFaceMode.disabled,ae,o.id,ee,te,fe,o.paint,E.zoom,$,[ie])}},heatmap:function(l,r,o,u){if(o.paint.get("heatmap-opacity")!==0)if(l.renderPass==="offscreen"){const d=l.context,f=d.gl,g=s.StencilMode.disabled,y=new s.ColorMode([f.ONE,f.ONE],s.Color.transparent,[!0,!0,!0,!0]);(function(F,N,U,j){const P=F.gl,O=N.width*j,$=N.height*j;F.activeTexture.set(P.TEXTURE1),F.viewport.set([0,0,O,$]);let q=U.heatmapFbo;if(!q||q&&(q.width!==O||q.height!==$)){q&&q.destroy();const ee=P.createTexture();P.bindTexture(P.TEXTURE_2D,ee),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_S,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_T,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MIN_FILTER,P.LINEAR),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MAG_FILTER,P.LINEAR),q=U.heatmapFbo=F.createFramebuffer(O,$,!1),function(ie,te,ae,se,fe,ke){const he=ie.gl;he.texImage2D(he.TEXTURE_2D,0,ie.isWebGL2&&ie.extRenderToTextureHalfFloat?he.RGBA16F:he.RGBA,fe,ke,0,he.RGBA,ie.extRenderToTextureHalfFloat?ie.isWebGL2?he.HALF_FLOAT:ie.extTextureHalfFloat.HALF_FLOAT_OES:he.UNSIGNED_BYTE,null),se.colorAttachment.set(ae)}(F,0,ee,q,O,$)}else P.bindTexture(P.TEXTURE_2D,q.colorAttachment.get()),F.bindFramebuffer.set(q.framebuffer)})(d,l,o,l.transform.projection.name==="globe"?.5:.25),d.clear({color:s.Color.transparent});const v=l.transform,S=v.projection.name==="globe",E=S?["PROJECTION_GLOBE_VIEW"]:null,C=S?s.CullFaceMode.frontCCW:s.CullFaceMode.disabled,D=[s.mercatorXfromLng(v.center.lng),s.mercatorYfromLat(v.center.lat)];for(let F=0;F<u.length;F++){const N=u[F];if(r.hasRenderableParent(N))continue;const U=r.getTile(N),j=U.getBucket(o);if(!j||j.projection.name!==v.projection.name)continue;const P=j.programConfigurations.get(o.id),O=l.useProgram("heatmap",P,E),{zoom:$}=l.transform;l.terrain&&l.terrain.setupElevationDraw(U,O),l.prepareDrawProgram(d,O,N.toUnwrapped());const q=v.projection.createInversionMatrix(v,N.canonical);O.draw(d,f.TRIANGLES,s.DepthMode.disabled,g,y,C,Uc(l,N,U,q,D,$,o.paint.get("heatmap-intensity")),o.id,j.layoutVertexBuffer,j.indexBuffer,j.segments,o.paint,l.transform.zoom,P,S?[j.globeExtVertexBuffer]:null)}d.viewport.set([0,0,l.width,l.height])}else l.renderPass==="translucent"&&(l.context.setColorMode(l.colorModeForRenderPass()),function(d,f){const g=d.context,y=g.gl,v=f.heatmapFbo;if(!v)return;g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,v.colorAttachment.get()),g.activeTexture.set(y.TEXTURE1);let S=f.colorRampTexture;S||(S=f.colorRampTexture=new s.Texture(g,f.colorRamp,y.RGBA)),S.bind(y.LINEAR,y.CLAMP_TO_EDGE),d.useProgram("heatmapTexture").draw(g,y.TRIANGLES,s.DepthMode.disabled,s.StencilMode.disabled,d.colorModeForRenderPass(),s.CullFaceMode.disabled,((E,C,D,F)=>({u_image:0,u_color_ramp:1,u_opacity:C.paint.get("heatmap-opacity")}))(0,f),f.id,d.viewportBuffer,d.quadTriangleIndexBuffer,d.viewportSegments,f.paint,d.transform.zoom)}(l,o))},line:function(l,r,o,u){if(l.renderPass!=="translucent")return;const d=o.paint.get("line-opacity"),f=o.paint.get("line-width");if(d.constantOr(1)===0||f.constantOr(1)===0)return;const g=l.depthModeForSublayer(0,s.DepthMode.ReadOnly),y=l.colorModeForRenderPass(),v=l.terrain&&l.terrain.renderingToTexture?1:s.exported.devicePixelRatio,S=o.paint.get("line-dasharray"),E=S.constantOr(1),C=o.layout.get("line-cap"),D=o.paint.get("line-pattern"),F=D.constantOr(1),N=o.paint.get("line-gradient"),U=F?"linePattern":"line",j=l.context,P=j.gl,O=(q=>{const ee=[];cs(q)&&ee.push("RENDER_LINE_DASH"),q.paint.get("line-gradient")&&ee.push("RENDER_LINE_GRADIENT");const ie=q.paint.get("line-trim-offset");ie[0]===0&&ie[1]===0||ee.push("RENDER_LINE_TRIM_OFFSET");const te=q.paint.get("line-pattern").constantOr(1),ae=q.paint.get("line-opacity").constantOr(1)!==1;return!te&&ae&&ee.push("RENDER_LINE_ALPHA_DISCARD"),ee})(o);let $=O.includes("RENDER_LINE_ALPHA_DISCARD");l.terrain&&l.terrain.clipOrMaskOverlapStencilType()&&($=!1);for(const q of u){const ee=r.getTile(q);if(F&&!ee.patternsLoaded())continue;const ie=ee.getBucket(o);if(!ie)continue;l.prepareDrawTile();const te=ie.programConfigurations.get(o.id),ae=l.useProgram(U,te,O),se=D.constantOr(null);if(se&&ee.imageAtlas){const Ee=ee.imageAtlas.patternPositions[se.toString()];Ee&&te.setConstantPatternPositions(Ee)}const fe=S.constantOr(null),ke=C.constantOr(null);if(!F&&fe&&ke&&ee.lineAtlas){const Ee=ee.lineAtlas.getDash(fe,ke);Ee&&te.setConstantPatternPositions(Ee)}let[he,Se]=o.paint.get("line-trim-offset");(ke==="round"||ke==="square")&&he!==Se&&(he===0&&(he-=1),Se===1&&(Se+=1));const ge=l.terrain?q.projMatrix:null,ze=F?ls(l,ee,o,ge,v):dh(l,ee,o,ge,ie.lineClipsArray.length,v,[he,Se]);if(N){const Ee=ie.gradients[o.id];let De=Ee.texture;if(o.gradientVersion!==Ee.version){let Ie=256;if(o.stepInterpolant){const Be=r.getSource().maxzoom,it=q.canonical.z===Be?Math.ceil(1<<l.transform.maxZoom-q.canonical.z):1;Ie=s.clamp(s.nextPowerOfTwo(ie.maxLineLength/s.EXTENT*1024*it),256,j.maxTextureSize)}Ee.gradient=s.renderColorRamp({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:Ie,image:Ee.gradient||void 0,clips:ie.lineClipsArray}),Ee.texture?Ee.texture.update(Ee.gradient):Ee.texture=new s.Texture(j,Ee.gradient,P.RGBA),Ee.version=o.gradientVersion,De=Ee.texture}j.activeTexture.set(P.TEXTURE1),De.bind(o.stepInterpolant?P.NEAREST:P.LINEAR,P.CLAMP_TO_EDGE)}E&&(j.activeTexture.set(P.TEXTURE0),ee.lineAtlasTexture.bind(P.LINEAR,P.REPEAT),te.updatePaintBuffers()),F&&(j.activeTexture.set(P.TEXTURE0),ee.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),te.updatePaintBuffers()),l.prepareDrawProgram(j,ae,q.toUnwrapped());const pe=Ee=>{ae.draw(j,P.TRIANGLES,g,Ee,y,s.CullFaceMode.disabled,ze,o.id,ie.layoutVertexBuffer,ie.indexBuffer,ie.segments,o.paint,l.transform.zoom,te,[ie.layoutVertexBuffer2])};if($){const Ee=l.stencilModeForClipping(q).ref;Ee===0&&l.terrain&&j.clear({stencil:0});const De={func:P.EQUAL,mask:255};ze.u_alpha_discard_threshold=.8,pe(new s.StencilMode(De,Ee,255,P.KEEP,P.KEEP,P.INVERT)),ze.u_alpha_discard_threshold=0,pe(new s.StencilMode(De,Ee,255,P.KEEP,P.KEEP,P.KEEP))}else pe(l.stencilModeForClipping(q))}$&&(l.resetStencilClippingMasks(),l.terrain&&j.clear({stencil:0}))},fill:function(l,r,o,u){const d=o.paint.get("fill-color"),f=o.paint.get("fill-opacity");if(f.constantOr(1)===0)return;const g=l.colorModeForRenderPass(),y=o.paint.get("fill-pattern"),v=l.opaquePassEnabledForLayer()&&!y.constantOr(1)&&d.constantOr(s.Color.transparent).a===1&&f.constantOr(0)===1?"opaque":"translucent";if(l.renderPass===v){const S=l.depthModeForSublayer(1,l.renderPass==="opaque"?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly);Gc(l,r,o,u,S,g,!1)}if(l.renderPass==="translucent"&&o.paint.get("fill-antialias")){const S=l.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,s.DepthMode.ReadOnly);Gc(l,r,o,u,S,g,!0)}},"fill-extrusion":function(l,r,o,u){const d=o.paint.get("fill-extrusion-opacity");if(d!==0&&l.renderPass==="translucent"){const f=new s.DepthMode(l.context.gl.LEQUAL,s.DepthMode.ReadWrite,l.depthRangeFor3D);if(d!==1||o.paint.get("fill-extrusion-pattern").constantOr(1))na(l,r,o,u,f,s.StencilMode.disabled,s.ColorMode.disabled),na(l,r,o,u,f,l.stencilModeFor3D(),l.colorModeForRenderPass()),l.resetStencilClippingMasks();else{const g=l.colorModeForRenderPass();na(l,r,o,u,f,s.StencilMode.disabled,g)}}},hillshade:function(l,r,o,u){if(l.renderPass!=="offscreen"&&l.renderPass!=="translucent")return;const d=l.context,f=l.depthModeForSublayer(0,s.DepthMode.ReadOnly),g=l.colorModeForRenderPass(),y=l.terrain&&l.terrain.renderingToTexture,[v,S]=l.renderPass!=="translucent"||y?[{},u]:l.stencilConfigForOverlap(u);for(const E of S){const C=r.getTile(E);if(C.needsHillshadePrepare&&l.renderPass==="offscreen")Dc(l,C,o,f,s.StencilMode.disabled,g);else if(l.renderPass==="translucent"){const D=y&&l.terrain?l.terrain.stencilModeForRTTOverlap(E):v[E.overscaledZ];Lc(l,E,C,o,f,D,g)}}d.viewport.set([0,0,l.width,l.height]),l.resetStencilClippingMasks()},raster:function(l,r,o,u,d,f){if(l.renderPass!=="translucent"||o.paint.get("raster-opacity")===0||!u.length)return;const g=l.context,y=g.gl,v=r.getSource(),S=l.useProgram("raster"),E=l.colorModeForRenderPass(),C=l.terrain&&l.terrain.renderingToTexture,[D,F]=v instanceof gt||C?[{},u]:l.stencilConfigForOverlap(u),N=F[F.length-1].overscaledZ,U=!l.options.moving;for(const j of F){const P=C?s.DepthMode.disabled:l.depthModeForSublayer(j.overscaledZ-N,o.paint.get("raster-opacity")===1?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly,y.LESS),O=j.toUnwrapped(),$=r.getTile(j);if(C&&(!$||!$.hasData()))continue;const q=C?j.projMatrix:l.transform.calculateProjMatrix(O,U),ee=l.terrain&&C?l.terrain.stencilModeForRTTOverlap(j):D[j.overscaledZ],ie=f?0:o.paint.get("raster-fade-duration");$.registerFadeDuration(ie);const te=r.findLoadedParent(j,0),ae=hl($,te,r,l.transform,ie);let se,fe;l.terrain&&l.terrain.prepareDrawTile();const ke=o.paint.get("raster-resampling")==="nearest"?y.NEAREST:y.LINEAR;g.activeTexture.set(y.TEXTURE0),$.texture.bind(ke,y.CLAMP_TO_EDGE),g.activeTexture.set(y.TEXTURE1),te?(te.texture.bind(ke,y.CLAMP_TO_EDGE),se=Math.pow(2,te.tileID.overscaledZ-$.tileID.overscaledZ),fe=[$.tileID.canonical.x*se%1,$.tileID.canonical.y*se%1]):$.texture.bind(ke,y.CLAMP_TO_EDGE),$.texture.useMipmap&&g.extTextureFilterAnisotropic&&l.transform.pitch>20&&y.texParameterf(y.TEXTURE_2D,g.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,g.extTextureFilterAnisotropicMax);const he=vl(q,fe||[0,0],se||1,ae,o,v instanceof gt?v.perspectiveTransform:[0,0]);if(l.prepareDrawProgram(g,S,O),v instanceof gt)v.boundsBuffer&&v.boundsSegments&&S.draw(g,y.TRIANGLES,P,s.StencilMode.disabled,E,s.CullFaceMode.disabled,he,o.id,v.boundsBuffer,l.quadTriangleIndexBuffer,v.boundsSegments);else{const{tileBoundsBuffer:Se,tileBoundsIndexBuffer:ge,tileBoundsSegments:ze}=l.getTileBoundsBuffers($);S.draw(g,y.TRIANGLES,P,ee,E,s.CullFaceMode.disabled,he,o.id,Se,ge,ze)}}l.resetStencilClippingMasks()},background:function(l,r,o,u){const d=o.paint.get("background-color"),f=o.paint.get("background-opacity");if(f===0)return;const g=l.context,y=g.gl,v=l.transform,S=v.tileSize,E=o.paint.get("background-pattern");if(l.isPatternMissing(E))return;const C=!E&&d.a===1&&f===1&&l.opaquePassEnabledForLayer()?"opaque":"translucent";if(l.renderPass!==C)return;const D=s.StencilMode.disabled,F=l.depthModeForSublayer(0,C==="opaque"?s.DepthMode.ReadWrite:s.DepthMode.ReadOnly),N=l.colorModeForRenderPass(),U=l.useProgram(E?"backgroundPattern":"background");let j,P=u;P||(j=l.getBackgroundTiles(),P=Object.values(j).map(O=>O.tileID)),E&&(g.activeTexture.set(y.TEXTURE0),l.imageManager.bind(l.context));for(const O of P){const $=O.toUnwrapped(),q=u?O.projMatrix:l.transform.calculateProjMatrix($);l.prepareDrawTile();const ee=r?r.getTile(O):j?j[O.key]:new s.Tile(O,S,v.zoom,l),ie=E?ph(q,f,l,E,{tileID:O,tileSize:S}):wl(q,f,d);l.prepareDrawProgram(g,U,$);const{tileBoundsBuffer:te,tileBoundsIndexBuffer:ae,tileBoundsSegments:se}=l.getTileBoundsBuffers(ee);U.draw(g,y.TRIANGLES,F,D,N,s.CullFaceMode.disabled,ie,o.id,te,ae,se)}},sky:function(l,r,o){const u=l.transform,d=u.projection.name==="mercator"||u.projection.name==="globe"?1:s.smoothstep(7,8,u.zoom),f=o.paint.get("sky-opacity")*d;if(f===0)return;const g=l.context,y=o.paint.get("sky-type"),v=new s.DepthMode(g.gl.LEQUAL,s.DepthMode.ReadOnly,[0,1]),S=l.frameCounter/1e3%1;y==="atmosphere"?l.renderPass==="offscreen"?o.needsSkyboxCapture(l)&&(function(E,C,D,F){const N=E.context,U=N.gl;let j=C.skyboxFbo;if(!j){j=C.skyboxFbo=N.createFramebuffer(32,32,!1),C.skyboxGeometry=new sa(N),C.skyboxTexture=N.gl.createTexture(),U.bindTexture(U.TEXTURE_CUBE_MAP,C.skyboxTexture),U.texParameteri(U.TEXTURE_CUBE_MAP,U.TEXTURE_WRAP_S,U.CLAMP_TO_EDGE),U.texParameteri(U.TEXTURE_CUBE_MAP,U.TEXTURE_WRAP_T,U.CLAMP_TO_EDGE),U.texParameteri(U.TEXTURE_CUBE_MAP,U.TEXTURE_MIN_FILTER,U.LINEAR),U.texParameteri(U.TEXTURE_CUBE_MAP,U.TEXTURE_MAG_FILTER,U.LINEAR);for(let q=0;q<6;++q)U.texImage2D(U.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,U.RGBA,32,32,0,U.RGBA,U.UNSIGNED_BYTE,null)}N.bindFramebuffer.set(j.framebuffer),N.viewport.set([0,0,32,32]);const P=C.getCenter(E,!0),O=E.useProgram("skyboxCapture"),$=new Float64Array(16);s.identity($),s.rotateY($,$,.5*-Math.PI),fr(N,C,O,$,P,0),s.identity($),s.rotateY($,$,.5*Math.PI),fr(N,C,O,$,P,1),s.identity($),s.rotateX($,$,.5*-Math.PI),fr(N,C,O,$,P,2),s.identity($),s.rotateX($,$,.5*Math.PI),fr(N,C,O,$,P,3),s.identity($),fr(N,C,O,$,P,4),s.identity($),s.rotateY($,$,Math.PI),fr(N,C,O,$,P,5),N.viewport.set([0,0,E.width,E.height])}(l,o),o.markSkyboxValid(l)):l.renderPass==="sky"&&function(E,C,D,F,N){const U=E.context,j=U.gl,P=E.transform,O=E.useProgram("skybox");U.activeTexture.set(j.TEXTURE0),j.bindTexture(j.TEXTURE_CUBE_MAP,C.skyboxTexture);const $=((q,ee,ie,te,ae)=>({u_matrix:q,u_sun_direction:ee,u_cubemap:0,u_opacity:te,u_temporal_offset:ae}))(P.skyboxMatrix,C.getCenter(E,!1),0,F,N);E.prepareDrawProgram(U,O),O.draw(U,j.TRIANGLES,D,s.StencilMode.disabled,E.colorModeForRenderPass(),s.CullFaceMode.backCW,$,"skybox",C.skyboxGeometry.vertexBuffer,C.skyboxGeometry.indexBuffer,C.skyboxGeometry.segment)}(l,o,v,f,S):y==="gradient"&&l.renderPass==="sky"&&function(E,C,D,F,N){const U=E.context,j=U.gl,P=E.transform,O=E.useProgram("skyboxGradient");C.skyboxGeometry||(C.skyboxGeometry=new sa(U)),U.activeTexture.set(j.TEXTURE0);let $=C.colorRampTexture;$||($=C.colorRampTexture=new s.Texture(U,C.colorRamp,j.RGBA)),$.bind(j.LINEAR,j.CLAMP_TO_EDGE);const q=((ee,ie,te,ae,se)=>({u_matrix:ee,u_color_ramp:0,u_center_direction:ie,u_radius:s.degToRad(te),u_opacity:ae,u_temporal_offset:se}))(P.skyboxMatrix,C.getCenter(E,!1),C.paint.get("sky-gradient-radius"),F,N);E.prepareDrawProgram(U,O),O.draw(U,j.TRIANGLES,D,s.StencilMode.disabled,E.colorModeForRenderPass(),s.CullFaceMode.backCW,q,"skyboxGradient",C.skyboxGeometry.vertexBuffer,C.skyboxGeometry.indexBuffer,C.skyboxGeometry.segment)}(l,o,v,f,S)},debug:function(l,r,o){for(let u=0;u<o.length;u++)xh(l,r,o[u])},custom:function(l,r,o,u){const d=l.context,f=o.implementation;if(!l.transform.projection.unsupportedLayers||!l.transform.projection.unsupportedLayers.includes("custom")||l.terrain&&(l.terrain.renderingToTexture||l.renderPass==="offscreen")&&o.isLayerDraped()){if(l.renderPass==="offscreen"){const g=f.prerender;if(g){if(l.setCustomLayerDefaults(),d.setColorMode(l.colorModeForRenderPass()),l.transform.projection.name==="globe"){const y=l.transform.pointMerc;g.call(f,d.gl,l.transform.customLayerMatrix(),l.transform.getProjection(),l.transform.globeToMercatorMatrix(),s.globeToMercatorTransition(l.transform.zoom),[y.x,y.y],l.transform.pixelsPerMeterRatio)}else g.call(f,d.gl,l.transform.customLayerMatrix());d.setDirty(),l.setBaseState()}}else if(l.renderPass==="translucent"){if(l.terrain&&l.terrain.renderingToTexture){const y=f.renderToTile;if(y){const v=u[0].canonical,S=new s.MercatorCoordinate(v.x+u[0].wrap*(1<<v.z),v.y,v.z);d.setDepthMode(s.DepthMode.disabled),d.setStencilMode(s.StencilMode.disabled),d.setColorMode(l.colorModeForRenderPass()),l.setCustomLayerDefaults(),y.call(f,d.gl,S),d.setDirty(),l.setBaseState()}return}l.setCustomLayerDefaults(),d.setColorMode(l.colorModeForRenderPass()),d.setStencilMode(s.StencilMode.disabled);const g=f.renderingMode==="3d"?new s.DepthMode(l.context.gl.LEQUAL,s.DepthMode.ReadWrite,l.depthRangeFor3D):l.depthModeForSublayer(0,s.DepthMode.ReadOnly);if(d.setDepthMode(g),l.transform.projection.name==="globe"){const y=l.transform.pointMerc;f.render(d.gl,l.transform.customLayerMatrix(),l.transform.getProjection(),l.transform.globeToMercatorMatrix(),s.globeToMercatorTransition(l.transform.zoom),[y.x,y.y],l.transform.pixelsPerMeterRatio)}else f.render(d.gl,l.transform.customLayerMatrix());d.setDirty(),l.setBaseState(),d.bindFramebuffer.set(null)}}else s.warnOnce("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")}};class xo{constructor(r,o,u=!1){this.context=new Ne(r,u),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=s.SourceCache.maxUnderzooming+s.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(r,o){const u=!!r&&!!r.terrain&&this.transform.projection.supportsTerrain;if(!(u||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new pl(this,r));const d=this._terrain;this.transform.elevation=u?d:null,d.update(r,this.transform,o)}_updateFog(r){const o=r.fog;if(!o||this.transform.projection.name==="globe"||o.getOpacity(this.transform.pitch)<1||o.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[u,d]=o.getFovAdjustedRange(this.transform._fov);if(u>d)return void(this.transform.fogCullDistSq=null);const f=u+.78*(d-u);this.transform.fogCullDistSq=f*f}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(r,o){if(this.width=r*s.exported.devicePixelRatio,this.height=o*s.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const u of this.style.order)this.style._layers[u].resize()}setup(){const r=this.context,o=new s.StructArrayLayout2i4;o.emplaceBack(0,0),o.emplaceBack(s.EXTENT,0),o.emplaceBack(0,s.EXTENT),o.emplaceBack(s.EXTENT,s.EXTENT),this.tileExtentBuffer=r.createVertexBuffer(o,s.posAttributes.members),this.tileExtentSegments=s.SegmentVector.simpleSegment(0,0,4,2);const u=new s.StructArrayLayout2i4;u.emplaceBack(0,0),u.emplaceBack(s.EXTENT,0),u.emplaceBack(0,s.EXTENT),u.emplaceBack(s.EXTENT,s.EXTENT),this.debugBuffer=r.createVertexBuffer(u,s.posAttributes.members),this.debugSegments=s.SegmentVector.simpleSegment(0,0,4,5);const d=new s.StructArrayLayout2i4;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(d,s.posAttributes.members),this.viewportSegments=s.SegmentVector.simpleSegment(0,0,4,2);const f=new s.StructArrayLayout4i8;f.emplaceBack(0,0,0,0),f.emplaceBack(s.EXTENT,0,s.EXTENT,0),f.emplaceBack(0,s.EXTENT,0,s.EXTENT),f.emplaceBack(s.EXTENT,s.EXTENT,s.EXTENT,s.EXTENT),this.mercatorBoundsBuffer=r.createVertexBuffer(f,s.boundsAttributes.members),this.mercatorBoundsSegments=s.SegmentVector.simpleSegment(0,0,4,2);const g=new s.StructArrayLayout3ui6;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(g);const y=new s.StructArrayLayout1ui2;for(const S of[0,1,3,2,0])y.emplaceBack(S);this.debugIndexBuffer=r.createIndexBuffer(y),this.emptyTexture=new s.Texture(r,new s.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),r.gl.RGBA),this.identityMat=s.create();const v=this.context.gl;this.stencilClearMode=new s.StencilMode({func:v.ALWAYS,mask:0},0,255,v.ZERO,v.ZERO,v.ZERO),this.loadTimeStamps.push(s.window.performance.now()),this.atmosphereBuffer=new Xc(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(r){return r._makeTileBoundsBuffers(this.context,this.transform.projection),r._tileBoundsBuffer?{tileBoundsBuffer:r._tileBoundsBuffer,tileBoundsIndexBuffer:r._tileBoundsIndexBuffer,tileBoundsSegments:r._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const r=this.context,o=r.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(r,o.TRIANGLES,s.DepthMode.disabled,this.stencilClearMode,s.ColorMode.disabled,s.CullFaceMode.disabled,ss(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(r,o,u){if(!o||this.currentStencilSource===o.id||!r.isTileClipped()||!u||u.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let y=!1;for(const v of u)if(this._tileClippingMaskIDs[v.key]===void 0){y=!0;break}if(!y)return}this.currentStencilSource=o.id;const d=this.context,f=d.gl;this.nextStencilID+u.length>256&&this.clearStencil(),d.setColorMode(s.ColorMode.disabled),d.setDepthMode(s.DepthMode.disabled);const g=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const y of u){const v=o.getTile(y),S=this._tileClippingMaskIDs[y.key]=this.nextStencilID++,{tileBoundsBuffer:E,tileBoundsIndexBuffer:C,tileBoundsSegments:D}=this.getTileBoundsBuffers(v);g.draw(d,f.TRIANGLES,s.DepthMode.disabled,new s.StencilMode({func:f.ALWAYS,mask:0},S,255,f.KEEP,f.KEEP,f.REPLACE),s.ColorMode.disabled,s.CullFaceMode.disabled,ss(y.projMatrix),"$clipping",E,C,D)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,o=this.context.gl;return new s.StencilMode({func:o.NOTEQUAL,mask:255},r,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(r){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(r);const o=this.context.gl;return new s.StencilMode({func:o.EQUAL,mask:255},this._tileClippingMaskIDs[r.key],0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(r){const o=this.context.gl,u=r.sort((g,y)=>y.overscaledZ-g.overscaledZ),d=u[u.length-1].overscaledZ,f=u[0].overscaledZ-d+1;if(f>1){this.currentStencilSource=void 0,this.nextStencilID+f>256&&this.clearStencil();const g={};for(let y=0;y<f;y++)g[y+d]=new s.StencilMode({func:o.GEQUAL,mask:255},y+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=f,[g,u]}return[{[d]:s.StencilMode.disabled},u]}colorModeForRenderPass(){const r=this.context.gl;return this._showOverdrawInspector?new s.ColorMode([r.CONSTANT_COLOR,r.ONE],new s.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?s.ColorMode.unblended:s.ColorMode.alphaBlended}depthModeForSublayer(r,o,u){if(!this.opaquePassEnabledForLayer())return s.DepthMode.disabled;const d=1-((1+this.currentLayer)*this.numSublayers+r)*this.depthEpsilon;return new s.DepthMode(u||this.context.gl.LEQUAL,o,[d,d])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(r,o){this.style=r,this.options=o,this.imageManager=r.imageManager,this.glyphManager=r.glyphManager,this.symbolFadeChange=r.placement.symbolFadeChange(s.exported.now()),this.imageManager.beginFrame();const u=this.style.order,d=this.style._sourceCaches;for(const S in d){const E=d[S];E.used&&E.prepare(this.context)}const f={},g={},y={};for(const S in d){const E=d[S];f[S]=E.getVisibleCoordinates(),g[S]=f[S].slice().reverse(),y[S]=E.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let S=0;S<u.length;S++)if(this.style._layers[u[S]].is3D()){this.opaquePassCutoff=S;break}if(this.terrain&&(this.terrain.updateTileBinding(y),this.opaquePassCutoff=0),this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new s.GlobeSharedBuffers(this.context)),!s.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const S of u){const E=this.style._layers[S],C=r._getLayerSourceCache(E);if(!E.hasOffscreenPass()||E.isHidden(this.transform.zoom))continue;const D=C?g[C.id]:void 0;(E.type==="custom"||E.isSky()||D&&D.length)&&this.renderLayer(this,C,E,D)}this.depthRangeFor3D=[0,1-(r.order.length+2)*this.numSublayers*this.depthEpsilon];const v=this.terrain;if(v&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&v.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:o.showOverdrawInspector?s.Color.black:s.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=u.length-1;this.currentLayer>=0;this.currentLayer--){const S=this.style._layers[u[this.currentLayer]],E=r._getLayerSourceCache(S);if(S.isSky())continue;const C=E?g[E.id]:void 0;this._renderTileClippingMasks(S,E,C),this.renderLayer(this,E,S,C)}if(this.style.fog&&this.transform.projection.supportsFog&&function(S,E){const C=S.context,D=C.gl,F=S.transform,N=new s.DepthMode(D.LEQUAL,s.DepthMode.ReadOnly,[0,1]),U=S.useProgram("globeAtmosphere",null,F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),j=s.globeToMercatorTransition(F.zoom),P=E.properties.get("color").toArray01(),O=E.properties.get("high-color").toArray01(),$=E.properties.get("space-color").toArray01PremultipliedAlpha(),q=s.identity$1([]);s.rotateY$1(q,q,-s.degToRad(F._center.lng)),s.rotateX$1(q,q,s.degToRad(F._center.lat)),s.rotateZ$1(q,q,F.angle),s.rotateX$1(q,q,-F._pitch);const ee=s.fromQuat(new Float32Array(16),q),ie=s.mapValue(E.properties.get("star-intensity"),0,1,0,.25),te=5e-4,ae=s.mapValue(E.properties.get("horizon-blend"),0,1,te,.25),se=s.globeUseCustomAntiAliasing(S,C,F)&&ae===te?F.worldSize/(2*Math.PI*1.025)-1:F.globeRadius,fe=S.frameCounter/1e3%1,ke=s.length(F.globeCenterInViewSpace),he=Math.sqrt(Math.pow(ke,2)-Math.pow(se,2)),Se=Math.acos(he/ke),ge=((pe,Ee,De,Ie,Be,it,lt,He,st,wt,xt,tt,Ft,jt)=>({u_frustum_tl:pe,u_frustum_tr:Ee,u_frustum_br:De,u_frustum_bl:Ie,u_horizon:Be,u_transition:it,u_fadeout_range:lt,u_color:He,u_high_color:st,u_space_color:wt,u_star_intensity:xt,u_star_size:5*s.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:tt,u_horizon_angle:Ft,u_rotation_matrix:jt}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,j,ae,P,O,$,ie,fe,Se,ee);S.prepareDrawProgram(C,U);const ze=S.atmosphereBuffer;ze&&U.draw(C,D.TRIANGLES,N,s.StencilMode.disabled,s.ColorMode.alphaBlended,s.CullFaceMode.backCW,ge,"skybox",ze.vertexBuffer,ze.indexBuffer,ze.segments)}(this,this.style.fog),this.renderPass="sky",(s.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const S=this.style._layers[u[this.currentLayer]],E=r._getLayerSourceCache(S);S.isSky()&&this.renderLayer(this,E,S,E?g[E.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<u.length;){const S=this.style._layers[u[this.currentLayer]],E=r._getLayerSourceCache(S);if(S.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(S)){if(S.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const C=E?(S.type==="symbol"?y:g)[E.id]:void 0;this._renderTileClippingMasks(S,E,E?f[E.id]:void 0),this.renderLayer(this,E,S,C),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let S=null;s.values(this.style._layers).forEach(E=>{const C=r._getLayerSourceCache(E);C&&!E.isHidden(this.transform.zoom)&&(!S||S.getSource().maxzoom<C.getSource().maxzoom)&&(S=C)}),S&&this.options.showTileBoundaries&&Nn.debug(this,S,S.getVisibleCoordinates())}this.options.showPadding&&function(S){const E=S.transform.padding;qc(S,S.transform.height-(E.top||0),3,go),qc(S,E.bottom||0,3,mh),oa(S,E.left||0,3,_h),oa(S,S.transform.width-(E.right||0),3,gh);const C=S.transform.centerPoint;(function(D,F,N,U){yo(D,F-1,N-10,2,20,U),yo(D,F-10,N-1,20,2,U)})(S,C.x,S.transform.height-C.y,yh)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(s.window.performance.now()),this.saveCanvasCopy())}renderLayer(r,o,u,d){u.isHidden(this.transform.zoom)||(u.type==="background"||u.type==="sky"||u.type==="custom"||d&&d.length)&&(this.id=u.id,this.gpuTimingStart(u),(!r.transform.projection.unsupportedLayers||!r.transform.projection.unsupportedLayers.includes(u.type)||r.terrain&&u.type==="custom")&&Nn[u.type](r,o,u,d,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(r){if(!this.options.gpuTiming)return;const o=this.context.extTimerQuery;let u=this.gpuTimers[r.id];u||(u=this.gpuTimers[r.id]={calls:0,cpuTime:0,query:o.createQueryEXT()}),u.calls++,o.beginQueryEXT(o.TIME_ELAPSED_EXT,u.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const r=this.context.extTimerQuery,o=r.createQueryEXT();this.deferredRenderGpuTimeQueries.push(o),r.beginQueryEXT(r.TIME_ELAPSED_EXT,o)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const r=this.context.extTimerQuery;r.endQueryEXT(r.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const r=this.context.extTimerQuery;r.endQueryEXT(r.TIME_ELAPSED_EXT)}collectGpuTimers(){const r=this.gpuTimers;return this.gpuTimers={},r}collectDeferredRenderGpuQueries(){const r=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],r}queryGpuTimers(r){const o={};for(const u in r){const d=r[u],f=this.context.extTimerQuery,g=f.getQueryObjectEXT(d.query,f.QUERY_RESULT_EXT)/1e6;f.deleteQueryEXT(d.query),o[u]=g}return o}queryGpuTimeDeferredRender(r){if(!this.options.gpuTimingDeferredRender)return 0;const o=this.context.extTimerQuery;let u=0;for(const d of r)u+=o.getQueryObjectEXT(d,o.QUERY_RESULT_EXT)/1e6,o.deleteQueryEXT(d);return u}translatePosMatrix(r,o,u,d,f){if(!u[0]&&!u[1])return r;const g=f?d==="map"?this.transform.angle:0:d==="viewport"?-this.transform.angle:0;if(g){const S=Math.sin(g),E=Math.cos(g);u=[u[0]*E-u[1]*S,u[0]*S+u[1]*E]}const y=[f?u[0]:Li(o,u[0],this.transform.zoom),f?u[1]:Li(o,u[1],this.transform.zoom),0],v=new Float32Array(16);return s.translate(v,r,y),v}saveTileTexture(r){const o=this._tileTextures[r.size[0]];o?o.push(r):this._tileTextures[r.size[0]]=[r]}getTileTexture(r){const o=this._tileTextures[r];return o&&o.length>0?o.pop():null}isPatternMissing(r){return r===null||r!==void 0&&!this.imageManager.getPattern(r.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const r=this.terrain&&this.terrain.renderingToTexture,o=this.terrain&&this.terrain.exaggeration()===0,u=this.style&&this.style.fog,d=[];return this.terrainRenderModeElevated()&&d.push("TERRAIN"),this.transform.projection.name==="globe"&&d.push("GLOBE"),o&&d.push("ZERO_EXAGGERATION"),u&&!r&&u.getOpacity(this.transform.pitch)!==0&&d.push("FOG"),r&&d.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&d.push("OVERDRAW_INSPECTOR"),d}useProgram(r,o,u){this.cache=this.cache||{};const d=u||[],f=this.currentGlobalDefines().concat(d),g=Pt.cacheKey(al[r],r,f,o);return this.cache[g]||(this.cache[g]=new Pt(this.context,r,al[r],o,Tl[r],f)),this.cache[g]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const r=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(r.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=s.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new s.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(r,o,u){if(this.terrain&&this.terrain.renderingToTexture)return;const d=this.style.fog;if(d){const f=d.getOpacity(this.transform.pitch),g=((y,v,S,E,C,D,F,N,U,j,P)=>{const O=y.transform,$=v.properties.get("color").toArray01();$[3]=E;const q=y.frameCounter/1e3%1;return{u_fog_matrix:S?O.calculateFogTileMatrix(S):y.identityMat,u_fog_range:v.getFovAdjustedRange(O._fov),u_fog_color:$,u_fog_horizon_blend:v.properties.get("horizon-blend"),u_fog_temporal_offset:q,u_frustum_tl:C,u_frustum_tr:D,u_frustum_br:F,u_frustum_bl:N,u_globe_pos:U,u_globe_radius:j,u_viewport:P,u_globe_transition:s.globeToMercatorTransition(O.zoom),u_is_globe:+(O.projection.name==="globe")}})(this,d,u,f,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*s.exported.devicePixelRatio,this.transform.height*s.exported.devicePixelRatio]);o.setFogUniformValues(r,g)}}setTileLoadedFlag(r){this.tileLoaded=r}saveCanvasCopy(){const r=this.canvasCopy();r&&(this.frameCopies.push(r),this.tileLoaded=!1)}canvasCopy(){const r=this.context.gl,o=r.createTexture();return r.bindTexture(r.TEXTURE_2D,o),r.copyTexImage2D(r.TEXTURE_2D,0,r.RGBA,0,0,r.drawingBufferWidth,r.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const r=this.style&&this.style.fog;return!!r&&r.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const r=this._backgroundTiles,o=this._backgroundTiles={},u=this.transform.coveringTiles({tileSize:512});for(const d of u)o[d.key]=r[d.key]||new s.Tile(d,512,this.transform.tileZoom,this);return o}clearBackgroundTiles(){this._backgroundTiles={}}}class aa{constructor(r=0,o=0,u=0,d=0){if(isNaN(r)||r<0||isNaN(o)||o<0||isNaN(u)||u<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=r,this.bottom=o,this.left=u,this.right=d}interpolate(r,o,u){return o.top!=null&&r.top!=null&&(this.top=s.number(r.top,o.top,u)),o.bottom!=null&&r.bottom!=null&&(this.bottom=s.number(r.bottom,o.bottom,u)),o.left!=null&&r.left!=null&&(this.left=s.number(r.left,o.left,u)),o.right!=null&&r.right!=null&&(this.right=s.number(r.right,o.right,u)),this}getCenter(r,o){const u=s.clamp((this.left+r-this.right)/2,0,r),d=s.clamp((this.top+o-this.bottom)/2,0,o);return new s.Point(u,d)}equals(r){return this.top===r.top&&this.bottom===r.bottom&&this.left===r.left&&this.right===r.right}clone(){return new aa(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function la(l,r){const o=s.getColumn(l,3);s.fromQuat(l,r),s.setColumn(l,3,o)}function zt(l,r){const o=s.identity$1([]);return s.rotateZ$1(o,o,-r),s.rotateX$1(o,o,-l),o}function ps(l,r){const o=[l[0],l[1],0],u=[r[0],r[1],0];if(s.length(o)>=1e-15){const g=s.normalize([],o);s.scale$2(u,g,s.dot(u,g)),r[0]=u[0],r[1]=u[1]}const d=s.cross([],r,l);if(s.len(d)<1e-15)return null;const f=Math.atan2(-d[1],d[0]);return zt(Math.atan2(Math.sqrt(l[0]*l[0]+l[1]*l[1]),-l[2]),f)}class Hc{constructor(r,o){this.position=r,this.orientation=o}get position(){return this._position}set position(r){if(r){const o=r instanceof s.MercatorCoordinate?r:new s.MercatorCoordinate(r[0],r[1],r[2]);this._renderWorldCopies&&(o.x=s.wrap(o.x,0,1)),this._position=o}else this._position=null}lookAtPoint(r,o){if(this.orientation=null,!this.position)return;const u=this.position,d=this._elevation?this._elevation.getAtPointOrZero(s.MercatorCoordinate.fromLngLat(r)):0,f=s.MercatorCoordinate.fromLngLat(r,d),g=[f.x-u.x,f.y-u.y,f.z-u.z];o||(o=[0,0,1]),o[2]=Math.abs(o[2]),this.orientation=ps(g,o)}setPitchBearing(r,o){this.orientation=zt(s.degToRad(r),s.degToRad(-o))}}class ca{constructor(r,o){this._transform=s.identity([]),this.orientation=o,this.position=r}get mercatorPosition(){const r=this.position;return new s.MercatorCoordinate(r[0],r[1],r[2])}get position(){const r=s.getColumn(this._transform,3);return[r[0],r[1],r[2]]}set position(r){var o;r&&s.setColumn(this._transform,3,[(o=r)[0],o[1],o[2],1])}get orientation(){return this._orientation}set orientation(r){this._orientation=r||s.identity$1([]),r&&la(this._transform,this._orientation)}getPitchBearing(){const r=this.forward(),o=this.right();return{bearing:Math.atan2(-o[1],o[0]),pitch:Math.atan2(Math.sqrt(r[0]*r[0]+r[1]*r[1]),-r[2])}}setPitchBearing(r,o){this._orientation=zt(r,o),la(this._transform,this._orientation)}forward(){const r=s.getColumn(this._transform,2);return[-r[0],-r[1],-r[2]]}up(){const r=s.getColumn(this._transform,1);return[-r[0],-r[1],-r[2]]}right(){const r=s.getColumn(this._transform,0);return[r[0],r[1],r[2]]}getCameraToWorld(r,o){const u=new Float64Array(16);return s.invert(u,this.getWorldToCamera(r,o)),u}getWorldToCameraPosition(r,o,u){const d=this.position;s.scale$2(d,d,-r);const f=new Float64Array(16);return s.fromScaling(f,[u,u,u]),s.translate(f,f,d),f[10]*=o,f}getWorldToCamera(r,o){const u=new Float64Array(16),d=new Float64Array(4),f=this.position;return s.conjugate(d,this._orientation),s.scale$2(f,f,-r),s.fromQuat(u,d),s.translate(u,u,f),u[1]*=-1,u[5]*=-1,u[9]*=-1,u[13]*=-1,u[8]*=o,u[9]*=o,u[10]*=o,u[11]*=o,u}getCameraToClipPerspective(r,o,u,d){const f=new Float64Array(16);return s.perspective(f,r,o,u,d),f}getDistanceToElevation(r,o=!1){const u=r===0?0:s.mercatorZfromAltitude(r,o?s.latFromMercatorY(this.position[1]):this.position[1]),d=this.forward();return(u-this.position[2])/d[2]}clone(){return new ca([...this.position],[...this.orientation])}}function vo(l,r){const o=ua(l.projection,l.zoom,l.width,l.height),u=function(f,g,y,v,S){const E=new s.LngLat(y.lng-180*Jr,y.lat),C=new s.LngLat(y.lng+180*Jr,y.lat),D=f.project(E.lng,E.lat),F=f.project(C.lng,C.lat),N=-Math.atan2(F.y-D.y,F.x-D.x),U=s.MercatorCoordinate.fromLngLat(y);U.y=s.clamp(U.y,-1+Jr,1-Jr);const j=U.toLngLat(),P=f.project(j.lng,j.lat),O=s.MercatorCoordinate.fromLngLat(j);O.x+=Jr;const $=O.toLngLat(),q=f.project($.lng,$.lat),ee=ha(q.x-P.x,q.y-P.y,N),ie=s.MercatorCoordinate.fromLngLat(j);ie.y+=Jr;const te=ie.toLngLat(),ae=f.project(te.lng,te.lat),se=ha(ae.x-P.x,ae.y-P.y,N),fe=Math.abs(ee.x)/Math.abs(se.y),ke=s.identity([]);s.rotateZ(ke,ke,-N*(1-(S?0:v)));const he=s.identity([]);return s.scale(he,he,[1,1-(1-fe)*v,1]),he[4]=-se.x/se.y*v,s.rotateZ(he,he,N),s.multiply(he,ke,he),he}(l.projection,0,l.center,o,r),d=Kc(l);return s.scale(u,u,[d,d,1]),u}function Kc(l){const r=l.projection,o=ua(l.projection,l.zoom,l.width,l.height),u=Jc(r,l.center),d=Jc(r,s.LngLat.convert(r.center));return Math.pow(2,u*o+(1-o)*d)}function ua(l,r,o,u,d=1/0){const f=l.range;if(!f)return 0;const g=Math.min(d,Math.max(o,u)),y=Math.log(g/1024)/Math.LN2;return s.smoothstep(f[0]+y,f[1]+y,r)}const Jr=1/4e4;function Jc(l,r){const o=s.clamp(r.lat,-s.MAX_MERCATOR_LATITUDE,s.MAX_MERCATOR_LATITUDE),u=new s.LngLat(r.lng-180*Jr,o),d=new s.LngLat(r.lng+180*Jr,o),f=l.project(u.lng,o),g=l.project(d.lng,o),y=s.MercatorCoordinate.fromLngLat(u),v=s.MercatorCoordinate.fromLngLat(d),S=g.x-f.x,E=g.y-f.y,C=v.x-y.x,D=v.y-y.y,F=Math.sqrt((C*C+D*D)/(S*S+E*E));return Math.log(F)/Math.LN2}function ha(l,r,o){const u=Math.cos(o),d=Math.sin(o);return{x:l*u-r*d,y:l*d+r*u}}class bo{constructor(r,o,u,d,f,g,y){this.tileSize=512,this._renderWorldCopies=f===void 0||f,this._minZoom=r||0,this._maxZoom=o||22,this._minPitch=u??0,this._maxPitch=d??60,this.setProjection(g),this.setMaxBounds(y),this.width=0,this.height=0,this._center=new s.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new aa,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new ca,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const r=new bo(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return r._elevation=this._elevation,r._centerAltitude=this._centerAltitude,r._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,r.tileSize=this.tileSize,r.mercatorFromTransition=this.mercatorFromTransition,r.width=this.width,r.height=this.height,r.cameraElevationReference=this.cameraElevationReference,r._center=this._center,r._setZoom(this.zoom),r._seaLevelZoom=this._seaLevelZoom,r.angle=this.angle,r._fov=this._fov,r._pitch=this._pitch,r._nearZ=this._nearZ,r._farZ=this._farZ,r._averageElevation=this._averageElevation,r._unmodified=this._unmodified,r._edgeInsets=this._edgeInsets.clone(),r._camera=this._camera.clone(),r._calcMatrices(),r.freezeTileCoverage=this.freezeTileCoverage,r.frustumCorners=this.frustumCorners,r}get elevation(){return this._elevation}set elevation(r){this._elevation!==r&&(this._elevation=r,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(r,o=!1){const u=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||u)&&this._updateCameraOnTerrain(),(r||u)&&this._constrainCamera(o),this._calcMatrices()}getProjection(){return s.pick(this.projection,["name","center","parallels"])}setProjection(r){this.projectionOptions=r||{name:"mercator"};const o=this.projection?this.getProjection():void 0;this.projection=s.getProjection(this.projectionOptions);const u=!le(o,this.getProjection());return u&&this._calcMatrices(),this.mercatorFromTransition=!1,u}setMercatorFromTransition(){const r=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=s.getProjection({name:"mercator"});const o=r!==this.projection.name;return o&&this._calcMatrices(),o}get minZoom(){return this._minZoom}set minZoom(r){this._minZoom!==r&&(this._minZoom=r,this.zoom=Math.max(this.zoom,r))}get maxZoom(){return this._maxZoom}set maxZoom(r){this._maxZoom!==r&&(this._maxZoom=r,this.zoom=Math.min(this.zoom,r))}get minPitch(){return this._minPitch}set minPitch(r){this._minPitch!==r&&(this._minPitch=r,this.pitch=Math.max(this.pitch,r))}get maxPitch(){return this._maxPitch}set maxPitch(r){this._maxPitch!==r&&(this._maxPitch=r,this.pitch=Math.min(this.pitch,r))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(r){r===void 0?r=!0:r===null&&(r=!1),this._renderWorldCopies=r}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const r=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(r))}get cameraWorldSize(){const r=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(r))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return s.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new s.Point(this.width,this.height)}get bearing(){return s.wrap(this.rotation,-180,180)}set bearing(r){this.rotation=r}get rotation(){return-this.angle/Math.PI*180}set rotation(r){const o=-r*Math.PI/180;var u;this.angle!==o&&(this._unmodified=!1,this.angle=o,this._calcMatrices(),this.rotationMatrix=(u=new s.ARRAY_TYPE(4),s.ARRAY_TYPE!=Float32Array&&(u[1]=0,u[2]=0),u[0]=1,u[3]=1,u),function(d,f,g){var y=f[0],v=f[1],S=f[2],E=f[3],C=Math.sin(g),D=Math.cos(g);d[0]=y*D+S*C,d[1]=v*D+E*C,d[2]=y*-C+S*D,d[3]=v*-C+E*D}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(r){const o=s.clamp(r,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==o&&(this._unmodified=!1,this._pitch=o,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const r=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/r)}set fov(r){r=Math.max(.01,Math.min(60,r)),this._fov!==r&&(this._unmodified=!1,this._fov=s.degToRad(r),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(r){this._averageElevation=r,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(r){const o=Math.min(Math.max(r,this.minZoom),this.maxZoom);this._zoom!==o&&(this._unmodified=!1,this._setZoom(o),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(r){this._zoom=r,this.scale=this.zoomScale(r),this.tileZoom=Math.floor(r),this.zoomFraction=r-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const r=this._elevation;this._centerAltitude=r.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=r.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==void 0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const r=this._elevation,o=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],u=this.horizonLineFromTop();let d=0,f=0;for(let g=0;g<o.length;g++){const y=new s.Point(o[g][0]*this.width,u+o[g][1]*(this.height-u)),v=r.pointCoordinate(y);if(!v)continue;const S=1/Math.hypot(v[0]-this._camera.position[0],v[1]-this._camera.position[1]);d+=v[3]*S,f+=S}return f===0?NaN:d/f}get center(){return this._center}set center(r){r.lat===this._center.lat&&r.lng===this._center.lng||(this._unmodified=!1,this._center=r,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const r=this._seaLevelZoom,o=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),u=this.pixelsPerMeter/this.worldSize*o,d=this._mercatorZfromZoom(r),f=this._mercatorZfromZoom(this._maxZoom),g=Math.max(d-u,f);this._setZoom(this._zoomFromMercatorZ(g))}get padding(){return this._edgeInsets.toJSON()}set padding(r){this._edgeInsets.equals(r)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,r,1),this._calcMatrices())}computeZoomRelativeTo(r){const o=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,r.toAltitude()));let u;u=r.z<this._camera.position[2]?[o.x,o.y,o.z]:[r.x,r.y,r.z];const d=s.length(s.sub([],this._camera.position,u));return s.clamp(this._zoomFromMercatorZ(d),this._minZoom,this._maxZoom)}setFreeCameraOptions(r){if(!this.height||!r.position&&!r.orientation)return;this._updateCameraState();let o=!1;if(r.orientation&&!s.exactEquals(r.orientation,this._camera.orientation)&&(o=this._setCameraOrientation(r.orientation)),r.position){const u=[r.position.x,r.position.y,r.position.z];s.exactEquals$1(u,this._camera.position)||(this._setCameraPosition(u),o=!0)}o&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const r=this._camera.position,o=new Hc;return o.position=new s.MercatorCoordinate(r[0],r[1],r[2]),o.orientation=this._camera.orientation,o._elevation=this.elevation,o._renderWorldCopies=this.renderWorldCopies,o}_setCameraOrientation(r){if(!s.length$1(r))return!1;s.normalize$1(r,r);const o=s.transformQuat([],[0,0,-1],r),u=s.transformQuat([],[0,-1,0],r);if(u[2]<0)return!1;const d=ps(o,u);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(r){const o=this.zoomScale(this.minZoom)*this.tileSize,u=this.zoomScale(this.maxZoom)*this.tileSize,d=this.cameraToCenterDistance;r[2]=s.clamp(r[2],d/u,d/o),this._camera.position=r}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(r){return this._edgeInsets.equals(r)}interpolatePadding(r,o,u){this._unmodified=!1,this._edgeInsets.interpolate(r,o,u),this._constrain(),this._calcMatrices()}coveringZoomLevel(r){const o=(r.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/r.tileSize));return Math.max(0,o)}getVisibleUnwrappedCoordinates(r){const o=[new s.UnwrappedTileID(0,r)];if(this.renderWorldCopies){const u=this.pointCoordinate(new s.Point(0,0)),d=this.pointCoordinate(new s.Point(this.width,0)),f=this.pointCoordinate(new s.Point(this.width,this.height)),g=this.pointCoordinate(new s.Point(0,this.height)),y=Math.floor(Math.min(u.x,d.x,f.x,g.x)),v=Math.floor(Math.max(u.x,d.x,f.x,g.x)),S=1;for(let E=y-S;E<=v+S;E++)E!==0&&o.push(new s.UnwrappedTileID(E,r))}return o}coveringTiles(r){let o=this.coveringZoomLevel(r);const u=o,d=this.elevation&&!r.isTerrainDEM,f=this.projection.name==="mercator";if(r.minzoom!==void 0&&o<r.minzoom)return[];r.maxzoom!==void 0&&o>r.maxzoom&&(o=r.maxzoom);const g=this.locationCoordinate(this.center),y=this.center.lat,v=1<<o,S=[v*g.x,v*g.y,0],E=this.projection.name==="globe",C=!E,D=s.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,o,C),F=E?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),N=v*s.mercatorZfromAltitude(1,this.center.lat),U=this._camera.position[2]/s.mercatorZfromAltitude(1,this.center.lat),j=[v*F.x,v*F.y,U*(C?1:N)],P=this.cameraToCenterDistance/r.tileSize*(r.roundZoom?1:.502),O=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?o:0,$=r.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,q=r.isTerrainDEM?-$:this._elevation?this._elevation.getMinElevationBelowMSL():0,ee=this.projection.isReprojectedInTileSpace?Kc(this):1,ie=pe=>{const De=new s.MercatorCoordinate(pe.x+25e-6,pe.y,pe.z),Ie=new s.MercatorCoordinate(pe.x,pe.y+25e-6,pe.z),Be=pe.toLngLat(),it=De.toLngLat(),lt=Ie.toLngLat(),He=this.locationCoordinate(Be),st=this.locationCoordinate(it),wt=this.locationCoordinate(lt),xt=Math.hypot(st.x-He.x,st.y-He.y),tt=Math.hypot(wt.x-He.x,wt.y-He.y);return Math.sqrt(xt*tt)*ee/25e-6},te=pe=>{const Ee=$,De=q;return{aabb:s.tileAABB(this,v,0,0,0,pe,De,Ee,this.projection),zoom:0,x:0,y:0,minZ:De,maxZ:Ee,wrap:pe,fullyVisible:!1}},ae=[];let se=[];const fe=o,ke=r.reparseOverscaled?u:o,he=pe=>pe*pe,Se=he((U-this._centerAltitude)*N),ge=pe=>{if(!this._elevation||!pe.tileID||!f)return;const Ee=this._elevation.getMinMaxForTile(pe.tileID),De=pe.aabb;Ee?(De.min[2]=Ee.min,De.max[2]=Ee.max,De.center[2]=(De.min[2]+De.max[2])/2):(pe.shouldSplit=ze(pe),pe.shouldSplit||(De.min[2]=De.max[2]=De.center[2]=this._centerAltitude))},ze=pe=>{if(pe.zoom<O)return!0;if(pe.zoom===fe)return!1;if(pe.shouldSplit!=null)return pe.shouldSplit;const Ee=pe.aabb.distanceX(j),De=pe.aabb.distanceY(j);let Ie=Se,Be=1;if(E){Ie=he(pe.aabb.distanceZ(j));const He=Math.pow(2,pe.zoom),st=s.latFromMercatorY((pe.y+1)/He),wt=s.latFromMercatorY(pe.y/He),xt=Math.min(Math.max(y,st),wt),tt=s.circumferenceAtLatitude(xt)/s.circumferenceAtLatitude(y);if(Be=xt===y?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,tt/this._mercatorScaleRatio),this.zoom<=s.GLOBE_ZOOM_THRESHOLD_MIN&&pe.zoom===fe-1&&tt>=.9)return!0}else if(d&&(Ie=he(pe.aabb.distanceZ(j)*N)),this.projection.isReprojectedInTileSpace&&u<=5){const He=Math.pow(2,pe.zoom),st=ie(new s.MercatorCoordinate((pe.x+.5)/He,(pe.y+.5)/He));Be=st>.85?1:st}const it=Ee*Ee+De*De+Ie,lt=he((1<<fe-pe.zoom)*P*Be*((He,st)=>{if(st*he(.707)<He)return 1;const wt=Math.sqrt(st/He);return wt/(1.4144271570014144+(Math.pow(1.1,wt-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(Ie,Se),it));return it<lt};if(this.renderWorldCopies)for(let pe=1;pe<=3;pe++)ae.push(te(-pe)),ae.push(te(pe));for(ae.push(te(0));ae.length>0;){const pe=ae.pop(),Ee=pe.x,De=pe.y;let Ie=pe.fullyVisible;if(!Ie){const Be=pe.aabb.intersects(D);if(Be===0)continue;Ie=Be===2}if(pe.zoom!==fe&&ze(pe))for(let Be=0;Be<4;Be++){const it=(Ee<<1)+Be%2,lt=(De<<1)+(Be>>1),He={aabb:f?pe.aabb.quadrant(Be):s.tileAABB(this,v,pe.zoom+1,it,lt,pe.wrap,pe.minZ,pe.maxZ,this.projection),zoom:pe.zoom+1,x:it,y:lt,wrap:pe.wrap,fullyVisible:Ie,tileID:void 0,shouldSplit:void 0,minZ:pe.minZ,maxZ:pe.maxZ};d&&!E&&(He.tileID=new s.OverscaledTileID(pe.zoom+1===fe?ke:pe.zoom+1,pe.wrap,pe.zoom+1,it,lt),ge(He)),ae.push(He)}else{const Be=pe.zoom===fe?ke:pe.zoom;if(r.minzoom&&r.minzoom>Be)continue;const it=S[0]-(.5+Ee+(pe.wrap<<pe.zoom))*(1<<o-pe.zoom),lt=S[1]-.5-De,He=pe.tileID?pe.tileID:new s.OverscaledTileID(Be,pe.wrap,pe.zoom,Ee,De);se.push({tileID:He,distanceSq:it*it+lt*lt})}}if(this.fogCullDistSq){const pe=this.fogCullDistSq,Ee=this.horizonLineFromTop();se=se.filter(De=>{const Ie=[0,0,0,1],Be=[s.EXTENT,s.EXTENT,0,1],it=this.calculateFogTileMatrix(De.tileID.toUnwrapped());s.transformMat4$1(Ie,Ie,it),s.transformMat4$1(Be,Be,it);const lt=s.getAABBPointSquareDist(Ie,Be);if(lt===0)return!0;let He=!1;const st=this._elevation;if(st&&lt>pe&&Ee!==0){const wt=this.calculateProjMatrix(De.tileID.toUnwrapped());let xt;r.isTerrainDEM||(xt=st.getMinMaxForTile(De.tileID)),xt||(xt={min:q,max:$});const tt=s.furthestTileCorner(this.rotation),Ft=[tt[0]*s.EXTENT,tt[1]*s.EXTENT,xt.max];s.transformMat4(Ft,Ft,wt),He=(1-Ft[1])*this.height*.5<Ee}return lt<pe||He})}return se.sort((pe,Ee)=>pe.distanceSq-Ee.distanceSq).map(pe=>pe.tileID)}resize(r,o){this.width=r,this.height=o,this.pixelsToGLUnits=[2/r,-2/o],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(r){return Math.pow(2,r)}scaleZoom(r){return Math.log(r)/Math.LN2}project(r){const o=s.clamp(r.lat,-s.MAX_MERCATOR_LATITUDE,s.MAX_MERCATOR_LATITUDE),u=this.projection.project(r.lng,o);return new s.Point(u.x*this.worldSize,u.y*this.worldSize)}unproject(r){return this.projection.unproject(r.x/this.worldSize,r.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/s.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(r,o){let u,d;const f=this.centerPoint;if(this.projection.name==="globe"){const y=this.worldSize;u=(o.x-f.x)/y,d=(o.y-f.y)/y}else{const y=this.pointCoordinate(o),v=this.pointCoordinate(f);u=y.x-v.x,d=y.y-v.y}const g=this.locationCoordinate(r);this.setLocation(new s.MercatorCoordinate(g.x-u,g.y-d))}setLocation(r){this.center=this.coordinateLocation(r),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(r){return this.projection.locationPoint(this,r)}locationPoint3D(r){return this.projection.locationPoint(this,r,!0)}pointLocation(r){return this.coordinateLocation(this.pointCoordinate(r))}pointLocation3D(r){return this.coordinateLocation(this.pointCoordinate3D(r))}locationCoordinate(r,o){const u=o?s.mercatorZfromAltitude(o,r.lat):void 0,d=this.projection.project(r.lng,r.lat);return new s.MercatorCoordinate(d.x,d.y,u)}coordinateLocation(r){return this.projection.unproject(r.x,r.y)}pointRayIntersection(r,o){const u=o??this._centerAltitude,d=[r.x,r.y,0,1],f=[r.x,r.y,1,1];s.transformMat4$1(d,d,this.pixelMatrixInverse),s.transformMat4$1(f,f,this.pixelMatrixInverse);const g=f[3];s.scale$1(d,d,1/d[3]),s.scale$1(f,f,1/g);const y=d[2],v=f[2];return{p0:d,p1:f,t:y===v?0:(u-y)/(v-y)}}screenPointToMercatorRay(r){const o=[r.x,r.y,0,1],u=[r.x,r.y,1,1];return s.transformMat4$1(o,o,this.pixelMatrixInverse),s.transformMat4$1(u,u,this.pixelMatrixInverse),s.scale$1(o,o,1/o[3]),s.scale$1(u,u,1/u[3]),o[2]=s.mercatorZfromAltitude(o[2],this._center.lat)*this.worldSize,u[2]=s.mercatorZfromAltitude(u[2],this._center.lat)*this.worldSize,s.scale$1(o,o,1/this.worldSize),s.scale$1(u,u,1/this.worldSize),new s.Ray([o[0],o[1],o[2]],s.normalize([],s.sub([],u,o)))}rayIntersectionCoordinate(r){const{p0:o,p1:u,t:d}=r,f=s.mercatorZfromAltitude(o[2],this._center.lat),g=s.mercatorZfromAltitude(u[2],this._center.lat);return new s.MercatorCoordinate(s.number(o[0],u[0],d)/this.worldSize,s.number(o[1],u[1],d)/this.worldSize,s.number(f,g,d))}pointCoordinate(r,o=this._centerAltitude){return this.projection.pointCoordinate(this,r.x,r.y,o)}pointCoordinate3D(r){if(!this.elevation)return this.pointCoordinate(r);let o=this.projection.pointCoordinate3D(this,r.x,r.y);if(o)return new s.MercatorCoordinate(o[0],o[1],o[2]);let u=0,d=this.horizonLineFromTop();if(r.y>d)return this.pointCoordinate(r);const f=.02*d,g=r.clone();for(let y=0;y<10&&d-u>f;y++){g.y=s.number(u,d,.66);const v=this.projection.pointCoordinate3D(this,g.x,g.y);v?(d=g.y,o=v):u=g.y}return o?new s.MercatorCoordinate(o[0],o[1],o[2]):this.pointCoordinate(r)}isPointAboveHorizon(r){return this.projection.isPointAboveHorizon(this,r)}isPointOnSurface(r){if(r.y<0||r.y>this.height||r.x<0||r.x>this.width)return!1;if(this.elevation||this.zoom>=s.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(r);const o=this.pointCoordinate(r);return o.y>=0&&o.y<=1}_coordinatePoint(r,o){const u=o&&this.elevation?this.elevation.getAtPointOrZero(r,this._centerAltitude):this._centerAltitude,d=[r.x*this.worldSize,r.y*this.worldSize,u+r.toAltitude(),1];return s.transformMat4$1(d,d,this.pixelMatrix),d[3]>0?new s.Point(d[0]/d[3],d[1]/d[3]):new s.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:r,left:o}=this._edgeInsets,u=this.height-this._edgeInsets.bottom,d=this.width-this._edgeInsets.right,f=this.pointLocation3D(new s.Point(o,r)),g=this.pointLocation3D(new s.Point(d,r)),y=this.pointLocation3D(new s.Point(d,u)),v=this.pointLocation3D(new s.Point(o,u));let S=Math.min(f.lng,g.lng,y.lng,v.lng),E=Math.max(f.lng,g.lng,y.lng,v.lng),C=Math.min(f.lat,g.lat,y.lat,v.lat),D=Math.max(f.lat,g.lat,y.lat,v.lat);const F=Math.pow(2,-this.zoom)/16*270,N=this.projection.name==="globe"?1:4,U=(j,P,O,$,q)=>{const ee=(j+O)/2,ie=(P+$)/2,te=new s.Point(ee,ie),{lng:ae,lat:se}=this.pointLocation3D(te),fe=Math.max(0,S-ae,C-se,ae-E,se-D);S=Math.min(S,ae),E=Math.max(E,ae),C=Math.min(C,se),D=Math.max(D,se),(q<N||fe>F)&&(U(j,P,ee,ie,q+1),U(ee,ie,O,$,q+1))};if(U(o,r,d,r,1),U(d,r,d,u,1),U(d,u,o,u,1),U(o,u,o,r,1),this.projection.name==="globe"){const[j,P]=s.polesInViewport(this);j?(D=90,E=180,S=-180):P&&(C=-90,E=180,S=-180)}return new s.LngLatBounds(new s.LngLat(S,C),new s.LngLat(E,D))}_getBoundsRectangular(r,o){const{top:u,left:d}=this._edgeInsets,f=this.height-this._edgeInsets.bottom,g=this.width-this._edgeInsets.right,y=new s.Point(d,u),v=new s.Point(g,u),S=new s.Point(g,f),E=new s.Point(d,f);let C=this.pointCoordinate(y,r),D=this.pointCoordinate(v,r);const F=this.pointCoordinate(S,o),N=this.pointCoordinate(E,o),U=(j,P)=>(P.y-j.y)/(P.x-j.x);return C.y>1&&D.y>=0?C=new s.MercatorCoordinate((1-N.y)/U(N,C)+N.x,1):C.y<0&&D.y<=1&&(C=new s.MercatorCoordinate(-N.y/U(N,C)+N.x,0)),D.y>1&&C.y>=0?D=new s.MercatorCoordinate((1-F.y)/U(F,D)+F.x,1):D.y<0&&C.y<=1&&(D=new s.MercatorCoordinate(-F.y/U(F,D)+F.x,0)),new s.LngLatBounds().extend(this.coordinateLocation(C)).extend(this.coordinateLocation(D)).extend(this.coordinateLocation(N)).extend(this.coordinateLocation(F))}_getBoundsRectangularTerrain(){const r=this.elevation;if(!r.visibleDemTiles.length||r.isUsingMockSource())return this._getBoundsRectangular(0,0);const o=r.visibleDemTiles.reduce((u,d)=>{if(d.dem){const f=d.dem.tree;u.min=Math.min(u.min,f.minimums[0]),u.max=Math.max(u.max,f.maximums[0])}return u},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(o.min*r.exaggeration(),o.max*r.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(r=!0){const o=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,u=this.height/2-o*(1-this._horizonShift);return r?Math.max(0,u):u}getMaxBounds(){return this.maxBounds}setMaxBounds(r){this.maxBounds=r,this.minLat=-s.MAX_MERCATOR_LATITUDE,this.maxLat=s.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,r&&(this.minLat=r.getSouth(),this.maxLat=r.getNorth(),this.minLng=r.getWest(),this.maxLng=r.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=s.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=s.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=s.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=s.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(r,o){return this.projection.createTileMatrix(this,o,r)}calculateDistanceTileData(r){const o=r.key,u=this._distanceTileDataCache;if(u[o])return u[o];const d=r.canonical,f=1/this.height,g=this.cameraWorldSize,y=g/this.zoomScale(d.z),v=(d.x+Math.pow(2,d.z)*r.wrap)*y,S=d.y*y,E=this.point;E.x*=g/this.worldSize,E.y*=g/this.worldSize;const C=this.angle,D=Math.sin(-C),F=-Math.cos(-C);return u[o]={bearing:[D,F],center:[(E.x-v)*f,(E.y-S)*f],scale:y/s.EXTENT*f},u[o]}calculateFogTileMatrix(r){const o=r.key,u=this._fogTileMatrixCache;if(u[o])return u[o];const d=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,r);return s.multiply(d,this.worldToFogMatrix,d),u[o]=new Float32Array(d),u[o]}calculateProjMatrix(r,o=!1){const u=r.key,d=o?this._alignedProjMatrixCache:this._projMatrixCache;if(d[u])return d[u];const f=this.calculatePosMatrix(r,this.worldSize);return s.multiply(f,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:o?this.alignedProjMatrix:this.projMatrix,f),d[u]=new Float32Array(f),d[u]}calculatePixelsToTileUnitsMatrix(r){const o=r.tileID.key,u=this._pixelsToTileUnitsCache;if(u[o])return u[o];const d=function(f,g){const{scale:y}=f.tileTransform,v=y*s.EXTENT/(f.tileSize*Math.pow(2,g.zoom-f.tileID.overscaledZ+f.tileID.canonical.z));return S=new Float32Array(4),D=(E=g.inverseAdjustmentMatrix)[1],F=E[2],N=E[3],j=(C=[v,v])[1],S[0]=E[0]*(U=C[0]),S[1]=D*U,S[2]=F*j,S[3]=N*j,S;var S,E,C,D,F,N,U,j}(r,this);return u[o]=d,u[o]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const r=1/this.worldSize,o=s.fromScaling([],[r,r,r]);return s.multiply(o,o,this.globeMatrix),o}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const r=this._elevation;this._updateCameraState();const o=s.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,u=this._computeCameraPosition(o),d=this._camera.forward(),f=s.mercatorZfromAltitude(1,this._center.lat);u[2]/=f,d[2]/=f,s.normalize(d,d);const g=r.raycast(u,d,r.exaggeration());if(g){const y=s.scaleAndAdd([],u,d,g),v=new s.MercatorCoordinate(y[0],y[1],s.mercatorZfromAltitude(y[2],s.latFromMercatorY(y[1]))),S=(v.z+s.length([v.x-u[0],v.y-u[1],v.z-u[2]*f]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(S),this._centerAltitude=v.toAltitude(),this._center=this.coordinateLocation(v),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(r=!1){if(!this._elevation)return;const o=this._elevation,u=s.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(u),f=o.getAtPointOrZero(new s.MercatorCoordinate(...d)),g=this.pixelsPerMeter/this.worldSize*f,y=this._minimumHeightOverTerrain(),v=d[2]-g;if(v<=y)if(v<0||r){const S=this.locationCoordinate(this._center,this._centerAltitude),E=[d[0],d[1],S.z-d[2]],C=s.length(E);E[2]-=(y-v)/this._pixelsPerMercatorPixel;const D=s.length(E);if(D===0)return;s.scale$2(E,E,C/D*this._pixelsPerMercatorPixel),this._camera.position=[d[0],d[1],S.z*this._pixelsPerMercatorPixel-E[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const r=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||r){const D=this.center;return D.lat=s.clamp(D.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!r)&&(D.lng=s.clamp(D.lng,this.minLng,this.maxLng)),this.center=D,void(this._constraining=!1)}const o=this._unmodified,{x:u,y:d}=this.point;let f=0,g=u,y=d;const v=this.width/2,S=this.height/2,E=this.worldMinY*this.scale,C=this.worldMaxY*this.scale;if(d-S<E&&(y=E+S),d+S>C&&(y=C-S),C-E<this.height&&(f=Math.max(f,this.height/(C-E)),y=(C+E)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const D=this.worldMinX*this.scale,F=this.worldMaxX*this.scale,N=this.worldSize/2-(D+F)/2;g=(u+N+this.worldSize)%this.worldSize-N,g-v<D&&(g=D+v),g+v>F&&(g=F-v),F-D<this.width&&(f=Math.max(f,this.width/(F-D)),g=(F+D)/2)}g===u&&y===d||(this.center=this.unproject(new s.Point(g,y))),f&&(this.zoom+=this.scaleZoom(f)),this._constrainCamera(),this._unmodified=o,this._constraining=!1}_minZoomForBounds(){let r=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(r=Math.max(r,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),r}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const r=this.centerOffset,o=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=s.mercatorZfromAltitude(1,this.center.lat)/s.mercatorZfromAltitude(1,s.GLOBE_SCALE_MATCH_LATITUDE));const u=ua(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,u),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const d=this.projection.zAxisUnit==="meters"?o:1,f=this._camera.getWorldToCamera(this.worldSize,d),g=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);g[8]=2*-r.x/this.width,g[9]=2*r.y/this.height;let y=s.mul([],g,f);if(this.projection.isReprojectedInTileSpace){const ie=this.locationCoordinate(this.center),te=s.identity([]);s.translate(te,te,[ie.x*this.worldSize,ie.y*this.worldSize,0]),s.multiply(te,te,vo(this)),s.translate(te,te,[-ie.x*this.worldSize,-ie.y*this.worldSize,0]),s.multiply(y,y,te),this.inverseAdjustmentMatrix=function(ae){const se=vo(ae,!0);return Re([],[se[0],se[1],se[4],se[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=s.scale([],y,[this.worldSize,this.worldSize,this.worldSize/d,1]),this.projMatrix=y,this.invProjMatrix=s.invert(new Float64Array(16),this.projMatrix);const v=s.invert([],g);this.frustumCorners=s.FrustumCorners.fromInvProjectionMatrix(v,this.horizonLineFromTop(),this.height);const S=new Float32Array(16);s.identity(S),s.scale(S,S,[1,-1,1]),s.rotateX(S,S,this._pitch),s.rotateZ(S,S,this.angle);const E=s.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),C=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;E[8]=2*-r.x/this.width,E[9]=2*(r.y+C)/this.height,this.skyboxMatrix=s.multiply(S,E,S);const D=this.point,F=D.x,N=D.y,U=this.width%2/2,j=this.height%2/2,P=Math.cos(this.angle),O=Math.sin(this.angle),$=F-Math.round(F)+P*U+O*j,q=N-Math.round(N)+P*j+O*U,ee=new Float64Array(y);if(s.translate(ee,ee,[$>.5?$-1:$,q>.5?q-1:q,0]),this.alignedProjMatrix=ee,y=s.create(),s.scale(y,y,[this.width/2,-this.height/2,1]),s.translate(y,y,[1,-1,0]),this.labelPlaneMatrix=y,y=s.create(),s.scale(y,y,[1,-1,1]),s.translate(y,y,[-1,-1,0]),s.scale(y,y,[2/this.width,2/this.height,1]),this.glCoordMatrix=y,this.pixelMatrix=s.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},y=s.invert(new Float64Array(16),this.pixelMatrix),!y)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=y,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=s.calculateGlobeMatrix(this);const ie=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=s.transformMat4(ie,ie,f),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=y;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const r=this.cameraWorldSizeForFog,o=this.cameraPixelsPerMeter,u=this._camera.position,d=1/this.height/this._pixelsPerMercatorPixel,f=[r,r,o];s.scale$2(f,f,d),s.scale$2(u,u,-1),s.multiply$2(u,u,f);const g=s.create();s.translate(g,g,u),s.scale(g,g,f),this.mercatorFogMatrix=g,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(r,o,d)}_computeCameraPosition(r){const o=(r=r||this.pixelsPerMeter)/this.pixelsPerMeter,u=this._camera.forward(),d=this.point,f=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*o-r/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-u[0]*f,d.y/this.worldSize-u[1]*f,r/this.worldSize*this._centerAltitude-u[2]*f]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(r){const o=this._maxCameraBoundsDistance()*Math.cos(this._pitch),u=this._camera.position[2],d=r[2];let f=1;this.projection.wrap&&(this.center=this.center.wrap()),d>0&&(f=Math.min((o-u)/d,1)),this._camera.position=s.scaleAndAdd([],this._camera.position,r,f),this._updateStateFromCamera()}_updateStateFromCamera(){const r=this._camera.position,o=this._camera.forward(),{pitch:u,bearing:d}=this._camera.getPitchBearing(),f=s.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,g=this._mercatorZfromZoom(this._maxZoom)*Math.cos(s.degToRad(this._maxPitch)),y=Math.max((r[2]-f)/Math.cos(u),g),v=this._zoomFromMercatorZ(y);s.scaleAndAdd(r,r,o,y),this._pitch=s.clamp(u,s.degToRad(this.minPitch),s.degToRad(this.maxPitch)),this.angle=s.wrap(d,-Math.PI,Math.PI),this._setZoom(s.clamp(v,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new s.MercatorCoordinate(r[0],r[1],r[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(r){return Math.pow(2,r)*this.tileSize}_mercatorZfromZoom(r){return this.cameraToCenterDistance/this._worldSizeFromZoom(r)}_minimumHeightOverTerrain(){const r=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(r)}_zoomFromMercatorZ(r){return this.scaleZoom(this.cameraToCenterDistance/(r*this.tileSize))}zoomFromMercatorZAdjusted(r){let o=0,u=s.GLOBE_ZOOM_THRESHOLD_MAX,d=0,f=1/0;for(;u-o>1e-6&&u>o;){const g=o+.5*(u-o),y=this.tileSize*Math.pow(2,g),v=this.getCameraToCenterDistance(this.projection,g,y),S=this.scaleZoom(v/(r*this.tileSize)),E=Math.abs(g-S);E<f&&(f=E,d=g),g<S?o=g:u=g}return d}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(s.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(r,o){const u=Math.min(r.x,o.x),d=Math.max(r.x,o.x),f=Math.min(r.y,o.y),g=Math.max(r.y,o.y);if(f<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const y=[new s.Point(u,f),new s.Point(d,g),new s.Point(u,g),new s.Point(d,f)],v=this.renderWorldCopies?-3:0,S=this.renderWorldCopies?4:1;for(const E of y){const C=this.pointRayIntersection(E);if(C.t<0)return!0;const D=this.rayIntersectionCoordinate(C);if(D.x<v||D.y<0||D.x>S||D.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+s.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new s.Point(0,0),new s.Point(this.width,this.height))}zoomDeltaToMovement(r,o){const u=s.length(s.sub([],this._camera.position,r)),d=this._zoomFromMercatorZ(u)+o;return u-this._mercatorZfromZoom(d)}getCameraPoint(){if(this.projection.name==="globe"){const r=function([o,u,d],f){const g=[o,u,d,1];s.transformMat4$1(g,g,f);const y=g[3]=Math.max(g[3],1e-6);return g[0]/=y,g[1]/=y,g[2]/=y,g}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new s.Point(r[0],r[1])}{const r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.Point(0,r))}}getCameraToCenterDistance(r,o=this.zoom,u=this.worldSize){const d=ua(r,o,this.width,this.height,1024),f=r.pixelSpaceConversion(this.center.lat,u,d);return .5/Math.tan(.5*this._fov)*this.height*f}getWorldToCameraMatrix(){const r=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&s.multiply(r,r,this.globeMatrix),r}}function wo(l,r){let o=!1,u=null;const d=()=>{u=null,o&&(l(),u=setTimeout(d,r),o=!1)};return()=>(o=!0,u||d(),u)}class Al{constructor(r){this._hashName=r&&encodeURIComponent(r),s.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=wo(this._updateHashUnthrottled.bind(this),300)}addTo(r){return this._map=r,s.window.addEventListener("hashchange",this._onHashChange,!1),r.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),s.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const r=this._map;if(!r)return"";const o=fs(r);if(this._hashName){const u=this._hashName;let d=!1;const f=s.window.location.hash.slice(1).split("&").map(g=>{const y=g.split("=")[0];return y===u?(d=!0,`${y}=${o}`):g}).filter(g=>g);return d||f.push(`${u}=${o}`),`#${f.join("&")}`}return`#${o}`}_getCurrentHash(){const r=s.window.location.hash.replace("#","");if(this._hashName){let o;return r.split("&").map(u=>u.split("=")).forEach(u=>{u[0]===this._hashName&&(o=u)}),(o&&o[1]||"").split("/")}return r.split("/")}_onHashChange(){const r=this._map;if(!r)return!1;const o=this._getCurrentHash();if(o.length>=3&&!o.some(u=>isNaN(u))){const u=r.dragRotate.isEnabled()&&r.touchZoomRotate.isEnabled()?+(o[3]||0):r.getBearing();return r.jumpTo({center:[+o[2],+o[1]],zoom:+o[0],bearing:u,pitch:+(o[4]||0)}),!0}return!1}_updateHashUnthrottled(){const r=s.window.location.href.replace(/(#.+)?$/,this.getHashString());s.window.history.replaceState(s.window.history.state,null,r)}}function fs(l,r){const o=l.getCenter(),u=Math.round(100*l.getZoom())/100,d=Math.ceil((u*Math.LN2+Math.log(512/360/.5))/Math.LN10),f=Math.pow(10,d),g=Math.round(o.lng*f)/f,y=Math.round(o.lat*f)/f,v=l.getBearing(),S=l.getPitch();let E=r?`/${g}/${y}/${u}`:`${u}/${y}/${g}`;return(v||S)&&(E+="/"+Math.round(10*v)/10),S&&(E+=`/${Math.round(S)}`),E}const ms={linearity:.3,easing:s.bezier(0,0,.3,1)},da=s.extend({deceleration:2500,maxSpeed:1400},ms),pa=s.extend({deceleration:20,maxSpeed:1400},ms),We=s.extend({deceleration:1e3,maxSpeed:360},ms),Er=s.extend({deceleration:1e3,maxSpeed:90},ms);class Yc{constructor(r){this._map=r,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.exported.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,o=s.exported.now();for(;r.length>0&&o-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const o={zoom:0,bearing:0,pitch:0,pan:new s.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:f}of this._inertiaBuffer)o.zoom+=f.zoomDelta||0,o.bearing+=f.bearingDelta||0,o.pitch+=f.pitchDelta||0,f.panDelta&&o.pan._add(f.panDelta),f.around&&(o.around=f.around),f.pinchAround&&(o.pinchAround=f.pinchAround);const u=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,d={};if(o.pan.mag()){const f=gs(o.pan.mag(),u,s.extend({},da,r||{}));d.offset=o.pan.mult(f.amount/o.pan.mag()),d.center=this._map.transform.center,_s(d,f)}if(o.zoom){const f=gs(o.zoom,u,pa);d.zoom=this._map.transform.zoom+f.amount,_s(d,f)}if(o.bearing){const f=gs(o.bearing,u,We);d.bearing=this._map.transform.bearing+s.clamp(f.amount,-179,179),_s(d,f)}if(o.pitch){const f=gs(o.pitch,u,Er);d.pitch=this._map.transform.pitch+f.amount,_s(d,f)}if(d.zoom||d.bearing){const f=o.pinchAround===void 0?o.around:o.pinchAround;d.around=f?this._map.unproject(f):this._map.getCenter()}return this.clear(),d.noMoveStart=!0,d}}function _s(l,r){(!l.duration||l.duration<r.duration)&&(l.duration=r.duration,l.easing=r.easing)}function gs(l,r,o){const{maxSpeed:u,linearity:d,deceleration:f}=o,g=s.clamp(l*d/(r/1e3),-u,u),y=Math.abs(g)/(f*d);return{easing:o.easing,duration:1e3*y,amount:g*(y/2)}}class Bi extends s.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,u,d={}){const f=Lt(o.getCanvasContainer(),u),g=o.unproject(f);super(r,s.extend({point:f,lngLat:g,originalEvent:u},d)),this._defaultPrevented=!1,this.target=o}}class ys extends s.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,u){const d=r==="touchend"?u.changedTouches:u.touches,f=ti(o.getCanvasContainer(),d),g=f.map(v=>o.unproject(v)),y=f.reduce((v,S,E,C)=>v.add(S.div(C.length)),new s.Point(0,0));super(r,{points:f,point:y,lngLats:g,lngLat:o.unproject(y),originalEvent:u}),this._defaultPrevented=!1}}class fa extends s.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,u){super(r,{originalEvent:u}),this._defaultPrevented=!1}}class Ml{constructor(r,o){this._map=r,this._clickTolerance=o.clickTolerance}reset(){this._mousedownPos=void 0}wheel(r){return this._firePreventable(new fa(r.type,this._map,r))}mousedown(r,o){return this._mousedownPos=o,this._firePreventable(new Bi(r.type,this._map,r))}mouseup(r){this._map.fire(new Bi(r.type,this._map,r))}preclick(r){const o=s.extend({},r);o.type="preclick",this._map.fire(new Bi(o.type,this._map,o))}click(r,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(r),this._map.fire(new Bi(r.type,this._map,r)))}dblclick(r){return this._firePreventable(new Bi(r.type,this._map,r))}mouseover(r){this._map.fire(new Bi(r.type,this._map,r))}mouseout(r){this._map.fire(new Bi(r.type,this._map,r))}touchstart(r){return this._firePreventable(new ys(r.type,this._map,r))}touchmove(r){this._map.fire(new ys(r.type,this._map,r))}touchend(r){this._map.fire(new ys(r.type,this._map,r))}touchcancel(r){this._map.fire(new ys(r.type,this._map,r))}_firePreventable(r){if(this._map.fire(r),r.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ma{constructor(r){this._map=r}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(r){this._map.fire(new Bi(r.type,this._map,r))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Bi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(r){this._delayContextMenu?this._contextMenuEvent=r:this._map.fire(new Bi(r.type,this._map,r)),this._map.listens("contextmenu")&&r.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Qc{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._container=r.getContainer(),this._clickTolerance=o.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(r,o){this.isEnabled()&&r.shiftKey&&r.button===0&&(ei(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(r,o){if(!this._active)return;const u=o,d=this._startPos,f=this._lastPos;if(!d||!f||f.equals(u)||!this._box&&u.dist(d)<this._clickTolerance)return;this._lastPos=u,this._box||(this._box=Je("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",r));const g=Math.min(d.x,u.x),y=Math.max(d.x,u.x),v=Math.min(d.y,u.y),S=Math.max(d.y,u.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${g}px,${v}px)`,this._box.style.width=y-g+"px",this._box.style.height=S-v+"px")})}mouseupWindow(r,o){if(!this._active)return;const u=this._startPos,d=o;if(u&&r.button===0){if(this.reset(),Nt(),u.x!==d.x||u.y!==d.y)return this._map.fire(new s.Event("boxzoomend",{originalEvent:r})),{cameraAnimation:f=>f.fitScreenCoordinates(u,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",r)}}keydown(r){this._active&&r.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",r))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),Ct(),delete this._startPos,delete this._lastPos}_fireEvent(r,o){return this._map.fire(new s.Event(r,{originalEvent:o}))}}function _a(l,r){const o={};for(let u=0;u<l.length;u++)o[l[u].identifier]=r[u];return o}class To{constructor(r){this.reset(),this.numTouches=r.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(r,o,u){(this.centroid||u.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=r.timeStamp),u.length===this.numTouches&&(this.centroid=function(d){const f=new s.Point(0,0);for(const g of d)f._add(g);return f.div(d.length)}(o),this.touches=_a(u,o)))}touchmove(r,o,u){if(this.aborted||!this.centroid)return;const d=_a(u,o);for(const f in this.touches){const g=d[f];(!g||g.dist(this.touches[f])>30)&&(this.aborted=!0)}}touchend(r,o,u){if((!this.centroid||r.timeStamp-this.startTime>500)&&(this.aborted=!0),u.length===0){const d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class Il{constructor(r){this.singleTap=new To(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(r,o,u){this.singleTap.touchstart(r,o,u)}touchmove(r,o,u){this.singleTap.touchmove(r,o,u)}touchend(r,o,u){const d=this.singleTap.touchend(r,o,u);if(d){const f=r.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(d)<30;if(f&&g||this.reset(),this.count++,this.lastTime=r.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class vh{constructor(){this._zoomIn=new Il({numTouches:1,numTaps:2}),this._zoomOut=new Il({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(r,o,u){this._zoomIn.touchstart(r,o,u),this._zoomOut.touchstart(r,o,u)}touchmove(r,o,u){this._zoomIn.touchmove(r,o,u),this._zoomOut.touchmove(r,o,u)}touchend(r,o,u){const d=this._zoomIn.touchend(r,o,u),f=this._zoomOut.touchend(r,o,u);return d?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:g.getZoom()+1,around:g.unproject(d)},{originalEvent:r})}):f?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:g.getZoom()-1,around:g.unproject(f)},{originalEvent:r})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const eu={0:1,2:2};class Eo{constructor(r){this.reset(),this._clickTolerance=r.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(r,o){return!1}_move(r,o){return{}}mousedown(r,o){if(this._lastPoint)return;const u=_i(r);this._correctButton(r,u)&&(this._lastPoint=o,this._eventButton=u)}mousemoveWindow(r,o){const u=this._lastPoint;if(u){if(r.preventDefault(),this._eventButton!=null&&function(d,f){const g=eu[f];return d.buttons===void 0||(d.buttons&g)!==g}(r,this._eventButton))this.reset();else if(this._moved||!(o.dist(u)<this._clickTolerance))return this._moved=!0,this._lastPoint=o,this._move(u,o)}}mouseupWindow(r){this._lastPoint&&_i(r)===this._eventButton&&(this._moved&&Nt(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Cl extends Eo{mousedown(r,o){super.mousedown(r,o),this._lastPoint&&(this._active=!0)}_correctButton(r,o){return o===0&&!r.ctrlKey}_move(r,o){return{around:o,panDelta:o.sub(r)}}}class Pl extends Eo{_correctButton(r,o){return o===0&&r.ctrlKey||o===2}_move(r,o){const u=.8*(o.x-r.x);if(u)return this._active=!0,{bearingDelta:u}}contextmenu(r){r.preventDefault()}}class zl extends Eo{_correctButton(r,o){return o===0&&r.ctrlKey||o===2}_move(r,o){const u=-.5*(o.y-r.y);if(u)return this._active=!0,{pitchDelta:u}}contextmenu(r){r.preventDefault()}}class ga{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),s.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new s.Point(0,0)}touchstart(r,o,u){return this._calculateTransform(r,o,u)}touchmove(r,o,u){if(this._active&&!(u.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(u.length===1&&!s.isFullscreen())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return r.cancelable&&r.preventDefault(),this._calculateTransform(r,o,u)}}touchend(r,o,u){this._calculateTransform(r,o,u),this._active&&u.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(r,o,u){u.length>0&&(this._active=!0);const d=_a(u,o),f=new s.Point(0,0),g=new s.Point(0,0);let y=0;for(const S in d){const E=d[S],C=this._touches[S];C&&(f._add(E),g._add(E.sub(C)),y++,d[S]=E)}if(this._touches=d,y<this._minTouches||!g.mag())return;const v=g.div(y);return this._sum._add(v),this._sum.mag()<this._clickTolerance?void 0:{around:f.div(y),panDelta:v}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Je("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class xs{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(r){}_move(r,o,u){return{}}touchstart(r,o,u){this._firstTwoTouches||u.length<2||(this._firstTwoTouches=[u[0].identifier,u[1].identifier],this._start([o[0],o[1]]))}touchmove(r,o,u){const d=this._firstTwoTouches;if(!d)return;r.preventDefault();const[f,g]=d,y=vs(u,o,f),v=vs(u,o,g);if(!y||!v)return;const S=this._aroundCenter?null:y.add(v).div(2);return this._move([y,v],S,r)}touchend(r,o,u){if(!this._firstTwoTouches)return;const[d,f]=this._firstTwoTouches,g=vs(u,o,d),y=vs(u,o,f);g&&y||(this._active&&Nt(),this.reset())}touchcancel(){this.reset()}enable(r){this._enabled=!0,this._aroundCenter=!!r&&r.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function vs(l,r,o){for(let u=0;u<l.length;u++)if(l[u].identifier===o)return r[u]}function kl(l,r){return Math.log(l/r)/Math.LN2}class tu extends xs{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(r){this._startDistance=this._distance=r[0].dist(r[1])}_move(r,o){const u=this._distance;if(this._distance=r[0].dist(r[1]),this._active||!(Math.abs(kl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:kl(this._distance,u),pinchAround:o}}}function Ll(l,r){return 180*l.angleWith(r)/Math.PI}class iu extends xs{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(r){this._startVector=this._vector=r[0].sub(r[1]),this._minDiameter=r[0].dist(r[1])}_move(r,o){const u=this._vector;if(this._vector=r[0].sub(r[1]),u&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Ll(this._vector,u),pinchAround:o}}_isBelowThreshold(r){this._minDiameter=Math.min(this._minDiameter,r.mag());const o=25/(Math.PI*this._minDiameter)*360,u=this._startVector;if(!u)return!1;const d=Ll(r,u);return Math.abs(d)<o}}function gn(l){return Math.abs(l.y)>Math.abs(l.x)}class ru extends xs{constructor(r){super(),this._map=r}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(r){this._lastPoints=r,gn(r[0].sub(r[1]))&&(this._valid=!1)}_move(r,o,u){const d=this._lastPoints;if(!d)return;const f=r[0].sub(d[0]),g=r[1].sub(d[1]);return this._map._cooperativeGestures&&!s.isFullscreen()&&u.touches.length<3||(this._valid=this.gestureBeginsVertically(f,g,u.timeStamp),!this._valid)?void 0:(this._lastPoints=r,this._active=!0,{pitchDelta:(f.y+g.y)/2*-.5})}gestureBeginsVertically(r,o,u){if(this._valid!==void 0)return this._valid;const d=r.mag()>=2,f=o.mag()>=2;if(!d&&!f)return;if(!d||!f)return this._firstMove==null&&(this._firstMove=u),u-this._firstMove<100&&void 0;const g=r.y>0==o.y>0;return gn(r)&&gn(o)&&g}}const nu={panStep:100,bearingStep:15,pitchStep:10};class bh{constructor(){const r=nu;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(r){if(r.altKey||r.ctrlKey||r.metaKey)return;let o=0,u=0,d=0,f=0,g=0;switch(r.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:r.shiftKey?u=-1:(r.preventDefault(),f=-1);break;case 39:r.shiftKey?u=1:(r.preventDefault(),f=1);break;case 38:r.shiftKey?d=1:(r.preventDefault(),g=-1);break;case 40:r.shiftKey?d=-1:(r.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(u=0,d=0),{cameraAnimation:y=>{const v=y.getZoom();y.easeTo({duration:300,easeId:"keyboardHandler",easing:ou,zoom:o?Math.round(v)+o*(r.shiftKey?2:1):v,bearing:y.getBearing()+u*this._bearingStep,pitch:y.getPitch()+d*this._pitchStep,offset:[-f*this._panStep,-g*this._panStep],center:y.getCenter()},{originalEvent:r})}}}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 ou(l){return l*(2-l)}const Dl=4.000244140625;class su{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._handler=o,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,s.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(r){this._defaultZoomRate=r}setWheelZoomRate(r){this._wheelZoomRate=r}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(r){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!r&&r.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(r){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(r.ctrlKey||r.metaKey||this.isZooming()||s.isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=r.deltaMode===s.window.WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const u=s.exported.now(),d=u-(this._lastWheelEventTime||0);this._lastWheelEventTime=u,o!==0&&o%Dl==0?this._type="wheel":o!==0&&Math.abs(o)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=o,this._timeout=setTimeout(this._onTimeout,40,r)):this._type||(this._type=Math.abs(d*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),r.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=r,this._delta-=o,this._active||this._start(r)),r.preventDefault()}_onTimeout(r){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)}_start(r){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 o=Lt(this._el,r);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:o,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const r=this._map.transform;this._type==="wheel"&&r.projection.wrap&&(r._center.lng>=180||r._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const o=()=>r._terrainEnabled()&&this._aroundCoord?r.computeZoomRelativeTo(this._aroundCoord):r.zoom;if(this._delta!==0){const v=this._type==="wheel"&&Math.abs(this._delta)>Dl?this._wheelZoomRate:this._defaultZoomRate;let S=2/(1+Math.exp(-Math.abs(this._delta*v)));this._delta<0&&S!==0&&(S=1/S);const E=o(),C=Math.pow(2,E),D=typeof this._targetZoom=="number"?r.zoomScale(this._targetZoom):C;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(D*S))),this._type==="wheel"&&(this._startZoom=E,this._easing=this._smoothOutEasing(200)),this._delta=0}const u=typeof this._targetZoom=="number"?this._targetZoom:o(),d=this._startZoom,f=this._easing;let g,y=!1;if(this._type==="wheel"&&d&&f){const v=Math.min((s.exported.now()-this._lastWheelEventTime)/200,1),S=f(v);g=s.number(d,u,S),v<1?this._frameId||(this._frameId=!0):y=!0}else g=u,y=!0;return this._active=!0,y&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!y,zoomDelta:g-o(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let o=s.ease;if(this._prevEase){const u=this._prevEase,d=(s.exported.now()-u.start)/u.duration,f=u.easing(d+.01)-u.easing(d),g=.27/Math.sqrt(f*f+1e-4)*.01,y=Math.sqrt(.0729-g*g);o=s.bezier(g,y,.25,1)}return this._prevEase={start:s.exported.now(),duration:r,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Je("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(s.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class au{constructor(r,o){this._clickZoom=r,this._tapZoom=o}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 $i{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(r,o){return r.preventDefault(),{cameraAnimation:u=>{u.easeTo({duration:300,zoom:u.getZoom()+(r.shiftKey?-1:1),around:u.unproject(o)},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wh{constructor(){this._tap=new Il({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(r,o,u){this._swipePoint||(this._tapTime&&r.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?u.length>0&&(this._swipePoint=o[0],this._swipeTouch=u[0].identifier):this._tap.touchstart(r,o,u))}touchmove(r,o,u){if(this._tapTime){if(this._swipePoint){if(u[0].identifier!==this._swipeTouch)return;const d=o[0],f=d.y-this._swipePoint.y;return this._swipePoint=d,r.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(r,o,u)}touchend(r,o,u){this._tapTime?this._swipePoint&&u.length===0&&this.reset():this._tap.touchend(r,o,u)&&(this._tapTime=r.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class lu{constructor(r,o,u){this._el=r,this._mousePan=o,this._touchPan=u}enable(r){this._inertiaOptions=r||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Th{constructor(r,o,u){this._pitchWithRotate=r.pitchWithRotate,this._mouseRotate=o,this._mousePitch=u}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Eh{constructor(r,o,u,d){this._el=r,this._touchZoom=o,this._touchRotate=u,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(r){this._touchZoom.enable(r),this._rotationDisabled||this._touchRotate.enable(r),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-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()}}const mr=l=>l.zoom||l.drag||l.pitch||l.rotate;class cu extends s.Event{}class Sh{constructor(){this.constants=[1,1,.01],this.radius=0}setup(r,o){const u=s.sub([],o,r);this.radius=s.length(u[2]<0?s.div([],u,this.constants):[u[0],u[1],0])}projectRay(r){s.div(r,r,this.constants),s.normalize(r,r),s.mul$1(r,r,this.constants);const o=s.scale$2([],r,this.radius);if(o[2]>0){const u=s.scale$2([],[0,0,1],s.dot(o,[0,0,1])),d=s.scale$2([],s.normalize([],[o[0],o[1],0]),this.radius),f=s.add([],o,s.scale$2([],s.sub([],s.add([],d,u),o),2));o[0]=f[0],o[1]=f[1]}return o}}function Sr(l){return l.panDelta&&l.panDelta.mag()||l.zoomDelta||l.bearingDelta||l.pitchDelta}class Dr{constructor(r,o){this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Yc(r),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Sh,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(o),s.bindAll(["handleEvent","handleWindowEvent"],this);const u=this._el;this._listeners=[[u,"touchstart",{passive:!0}],[u,"touchmove",{passive:!1}],[u,"touchend",void 0],[u,"touchcancel",void 0],[u,"mousedown",void 0],[u,"mousemove",void 0],[u,"mouseup",void 0],[s.window.document,"mousemove",{capture:!0}],[s.window.document,"mouseup",void 0],[u,"mouseover",void 0],[u,"mouseout",void 0],[u,"dblclick",void 0],[u,"click",void 0],[u,"keydown",{capture:!1}],[u,"keyup",void 0],[u,"wheel",{passive:!1}],[u,"contextmenu",void 0],[s.window,"blur",void 0]];for(const[d,f,g]of this._listeners)d.addEventListener(f,d===s.window.document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[r,o,u]of this._listeners)r.removeEventListener(o,r===s.window.document?this.handleWindowEvent:this.handleEvent,u)}_addDefaultHandlers(r){const o=this._map,u=o.getCanvasContainer();this._add("mapEvent",new Ml(o,r));const d=o.boxZoom=new Qc(o,r);this._add("boxZoom",d);const f=new vh,g=new $i;o.doubleClickZoom=new au(g,f),this._add("tapZoom",f),this._add("clickZoom",g);const y=new wh;this._add("tapDragZoom",y);const v=o.touchPitch=new ru(o);this._add("touchPitch",v);const S=new Pl(r),E=new zl(r);o.dragRotate=new Th(r,S,E),this._add("mouseRotate",S,["mousePitch"]),this._add("mousePitch",E,["mouseRotate"]);const C=new Cl(r),D=new ga(o,r);o.dragPan=new lu(u,C,D),this._add("mousePan",C),this._add("touchPan",D,["touchZoom","touchRotate"]);const F=new iu,N=new tu;o.touchZoomRotate=new Eh(u,N,F,y),this._add("touchRotate",F,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ma(o));const U=o.scrollZoom=new su(o,this);this._add("scrollZoom",U,["mousePan"]);const j=o.keyboard=new bh;this._add("keyboard",j);for(const P of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])r.interactive&&r[P]&&o[P].enable(r[P])}_add(r,o,u){this._handlers.push({handlerName:r,handler:o,allowed:u}),this._handlersById[r]=o}stop(r){if(!this._updatingCamera){for(const{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},r),this._changes=[]}}isActive(){for(const{handler:r}of this._handlers)if(r.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!mr(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(r,o,u){for(const d in r)if(d!==u&&(!o||o.indexOf(d)<0))return!0;return!1}handleWindowEvent(r){this.handleEvent(r,`${r.type}Window`)}_getMapTouches(r){const o=[];for(const u of r)this._el.contains(u.target)&&o.push(u);return o}handleEvent(r,o){this._updatingCamera=!0;const u=r.type==="renderFrame",d=u?void 0:r,f={needsRenderFrame:!1},g={},y={},v=r.touches?this._getMapTouches(r.touches):void 0,S=v?ti(this._el,v):u?void 0:Lt(this._el,r);for(const{handlerName:D,handler:F,allowed:N}of this._handlers){if(!F.isEnabled())continue;let U;this._blockedByActive(y,N,D)?F.reset():F[o||r.type]&&(U=F[o||r.type](r,S,v),this.mergeHandlerResult(f,g,U,D,d),U&&U.needsRenderFrame&&this._triggerRenderFrame()),(U||F.isActive())&&(y[D]=F)}const E={};for(const D in this._previousActiveHandlers)y[D]||(E[D]=d);this._previousActiveHandlers=y,(Object.keys(E).length||Sr(f))&&(this._changes.push([f,g,E]),this._triggerRenderFrame()),(Object.keys(y).length||Sr(f))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:C}=f;C&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],C(this._map))}mergeHandlerResult(r,o,u,d,f){if(!u)return;s.extend(r,u);const g={handlerName:d,originalEvent:u.originalEvent||f};u.zoomDelta!==void 0&&(o.zoom=g),u.panDelta!==void 0&&(o.drag=g),u.pitchDelta!==void 0&&(o.pitch=g),u.bearingDelta!==void 0&&(o.rotate=g)}_applyChanges(){const r={},o={},u={};for(const[d,f,g]of this._changes)d.panDelta&&(r.panDelta=(r.panDelta||new s.Point(0,0))._add(d.panDelta)),d.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+d.pitchDelta),d.around!==void 0&&(r.around=d.around),d.aroundCoord!==void 0&&(r.aroundCoord=d.aroundCoord),d.pinchAround!==void 0&&(r.pinchAround=d.pinchAround),d.noInertia&&(r.noInertia=d.noInertia),s.extend(o,f),s.extend(u,g);this._updateMapTransform(r,o,u),this._changes=[]}_updateMapTransform(r,o,u){const d=this._map,f=d.transform,g=O=>[O.x,O.y,O.z];if((O=>{const $=this._eventsInProgress.drag;return $&&!this._handlersById[$.handlerName].isActive()})()&&!Sr(r)){const O=f.zoom;f.cameraElevationReference="sea",f.recenterOnTerrain(),f.cameraElevationReference="ground",O!==f.zoom&&this._map._update(!0)}if(f._isCameraConstrained&&d._stop(!0),!Sr(r))return void this._fireEvents(o,u,!0);let{panDelta:y,zoomDelta:v,bearingDelta:S,pitchDelta:E,around:C,aroundCoord:D,pinchAround:F}=r;f._isCameraConstrained&&(v>0&&(v=0),f._isCameraConstrained=!1),F!==void 0&&(C=F),(v||(O=>o[O]&&!this._eventsInProgress[O])("drag"))&&C&&(this._dragOrigin=g(f.pointCoordinate3D(C)),this._trackingEllipsoid.setup(f._camera.position,this._dragOrigin)),f.cameraElevationReference="sea",d._stop(!0),C=C||d.transform.centerPoint,S&&(f.bearing+=S),E&&(f.pitch+=E),f._updateCameraState();const N=[0,0,0];if(y)if(f.projection.name==="mercator"){const O=this._trackingEllipsoid.projectRay(f.screenPointToMercatorRay(C).dir),$=this._trackingEllipsoid.projectRay(f.screenPointToMercatorRay(C.sub(y)).dir);N[0]=$[0]-O[0],N[1]=$[1]-O[1]}else{const O=f.pointCoordinate(C);if(f.projection.name==="globe"){y=y.rotate(-f.angle);const $=f._pixelsPerMercatorPixel/f.worldSize;N[0]=-y.x*s.mercatorScale(s.latFromMercatorY(O.y))*$,N[1]=-y.y*s.mercatorScale(f.center.lat)*$}else{const $=f.pointCoordinate(C.sub(y));O&&$&&(N[0]=$.x-O.x,N[1]=$.y-O.y)}}const U=f.zoom,j=[0,0,0];if(v){const O=g(D||f.pointCoordinate3D(C)),$={dir:s.normalize([],s.sub([],O,f._camera.position))};if($.dir[2]<0){const q=f.zoomDeltaToMovement(O,v);s.scale$2(j,$.dir,q)}}const P=s.add(N,N,j);f._translateCameraConstrained(P),v&&Math.abs(f.zoom-U)>1e-4&&f.recenterOnTerrain(),f.cameraElevationReference="ground",this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(o,u,!0)}_fireEvents(r,o,u){const d=mr(this._eventsInProgress),f=mr(r),g={};for(const E in r){const{originalEvent:C}=r[E];this._eventsInProgress[E]||(g[`${E}start`]=C),this._eventsInProgress[E]=r[E]}!d&&f&&this._fireEvent("movestart",f.originalEvent);for(const E in g)this._fireEvent(E,g[E]);f&&this._fireEvent("move",f.originalEvent);for(const E in r){const{originalEvent:C}=r[E];this._fireEvent(E,C)}const y={};let v;for(const E in this._eventsInProgress){const{handlerName:C,originalEvent:D}=this._eventsInProgress[E];this._handlersById[C].isActive()||(delete this._eventsInProgress[E],v=o[C]||D,y[`${E}end`]=v)}for(const E in y)this._fireEvent(E,y[E]);const S=mr(this._eventsInProgress);if(u&&(d||f)&&!S){this._updatingCamera=!0;const E=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),C=D=>D!==0&&-this._bearingSnap<D&&D<this._bearingSnap;E?(C(E.bearing||this._map.getBearing())&&(E.bearing=0),this._map.easeTo(E,{originalEvent:v})):(this._map.fire(new s.Event("moveend",{originalEvent:v})),C(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(r,o){this._map.fire(new s.Event(r,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(r=>{this._frameId=void 0,this.handleEvent(new cu("renderFrame",{timeStamp:r})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const jn="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ya extends s.Evented{constructor(r,o){super(),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=o.bearingSnap,this._respectPrefersReducedMotion=o.respectPrefersReducedMotion!==!1,s.bindAll(["_renderFrameCallback"],this)}getCenter(){return new s.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(r,o){return this.jumpTo({center:r},o)}panBy(r,o,u){return r=s.Point.convert(r).mult(-1),this.panTo(this.transform.center,s.extend({offset:r},o),u)}panTo(r,o,u){return this.easeTo(s.extend({center:r},o),u)}getZoom(){return this.transform.zoom}setZoom(r,o){return this.jumpTo({zoom:r},o),this}zoomTo(r,o,u){return this.easeTo(s.extend({zoom:r},o),u)}zoomIn(r,o){return this.zoomTo(this.getZoom()+1,r,o),this}zoomOut(r,o){return this.zoomTo(this.getZoom()-1,r,o),this}getBearing(){return this.transform.bearing}setBearing(r,o){return this.jumpTo({bearing:r},o),this}getPadding(){return this.transform.padding}setPadding(r,o){return this.jumpTo({padding:r},o),this}rotateTo(r,o,u){return this.easeTo(s.extend({bearing:r},o),u)}resetNorth(r,o){return this.rotateTo(0,s.extend({duration:1e3},r),o),this}resetNorthPitch(r,o){return this.easeTo(s.extend({bearing:0,pitch:0,duration:1e3},r),o),this}snapToNorth(r,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(r,o):this}getPitch(){return this.transform.pitch}setPitch(r,o){return this.jumpTo({pitch:r},o),this}cameraForBounds(r,o){r=s.LngLatBounds.convert(r);const u=o&&o.bearing||0,d=o&&o.pitch||0,f=r.getNorthWest(),g=r.getSouthEast();return this._cameraForBounds(this.transform,f,g,u,d,o)}_extendCameraOptions(r){const o={top:0,bottom:0,right:0,left:0};if(typeof(r=s.extend({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding=="number"){const u=r.padding;r.padding={top:u,bottom:u,right:u,left:u}}return r.padding=s.extend(o,r.padding),r}_minimumAABBFrustumDistance(r,o){const u=o.max[0]-o.min[0],d=o.max[1]-o.min[1];return u/d>r.aspect?u/(2*Math.tan(.5*r.fovX)*r.aspect):d/(2*Math.tan(.5*r.fovY)*r.aspect)}_cameraForBoundsOnGlobe(r,o,u,d,f,g){const y=r.clone(),v=this._extendCameraOptions(g);y.bearing=d,y.pitch=f;const S=s.LngLat.convert(o),E=s.LngLat.convert(u),C=.5*(S.lat+E.lat),D=.5*(S.lng+E.lng),F=s.latLngToECEF(C,D),N=s.normalize([],F),U=s.normalize([],s.cross([],N,[0,1,0])),j=s.cross([],U,N),P=[U[0],U[1],U[2],0,j[0],j[1],j[2],0,N[0],N[1],N[2],0,0,0,0,1],O=[F,s.latLngToECEF(S.lat,S.lng),s.latLngToECEF(E.lat,S.lng),s.latLngToECEF(E.lat,E.lng),s.latLngToECEF(S.lat,E.lng),s.latLngToECEF(C,S.lng),s.latLngToECEF(C,E.lng),s.latLngToECEF(S.lat,D),s.latLngToECEF(E.lat,D)];let $=s.Aabb.fromPoints(O.map(Ie=>[s.dot(U,Ie),s.dot(j,Ie),s.dot(N,Ie)]));const q=s.transformMat4([],$.center,P);s.squaredLength(q)===0&&s.set(q,0,0,1),s.normalize(q,q),s.scale$2(q,q,s.GLOBE_RADIUS),y.center=s.ecefToLatLng(q);const ee=y.getWorldToCameraMatrix(),ie=s.invert(new Float64Array(16),ee);$=s.Aabb.applyTransform($,s.multiply([],ee,P)),s.transformMat4(q,q,ee);const te=.5*($.max[2]-$.min[2]),ae=this._minimumAABBFrustumDistance(y,$),se=s.scale$2([],[0,0,1],te),fe=s.add(se,q,se),ke=ae+(y.pitch===0?0:s.distance(q,fe)),he=y.globeCenterInViewSpace,Se=s.sub([],q,[he[0],he[1],he[2]]);s.normalize(Se,Se),s.scale$2(Se,Se,ke);const ge=s.add([],q,Se);s.transformMat4(ge,ge,ie);const ze=s.earthRadius/s.GLOBE_RADIUS,pe=s.length(ge),Ee=s.mercatorZfromAltitude(Math.max(pe*ze-s.earthRadius,Number.EPSILON),0),De=Math.min(y.zoomFromMercatorZAdjusted(Ee),v.maxZoom);return De>.5*(s.GLOBE_ZOOM_THRESHOLD_MIN+s.GLOBE_ZOOM_THRESHOLD_MAX)?(y.setProjection({name:"mercator"}),y.zoom=De,this._cameraForBounds(y,o,u,d,f,g)):{center:y.center,zoom:De,bearing:d,pitch:f}}queryTerrainElevation(r,o){const u=this.transform.elevation;return u?(o=s.extend({},{exaggerated:!0},o),u.getAtPoint(s.MercatorCoordinate.fromLngLat(r),null,o.exaggerated)):null}_cameraForBounds(r,o,u,d,f,g){if(r.projection.name==="globe")return this._cameraForBoundsOnGlobe(r,o,u,d,f,g);const y=r.clone(),v=this._extendCameraOptions(g),S=y.padding;y.bearing=d,y.pitch=f;const E=s.LngLat.convert(o),C=s.LngLat.convert(u),D=new s.LngLat(E.lng,C.lat),F=new s.LngLat(C.lng,E.lat),N=y.project(E),U=y.project(C),j=this.queryTerrainElevation(E),P=this.queryTerrainElevation(C),O=this.queryTerrainElevation(D),$=this.queryTerrainElevation(F),q=[[N.x,N.y,Math.min(j||0,P||0,O||0,$||0)],[U.x,U.y,Math.max(j||0,P||0,O||0,$||0)]];let ee=s.Aabb.fromPoints(q);const ie=y.getWorldToCameraMatrix(),te=s.invert(new Float64Array(16),ie);ee=s.Aabb.applyTransform(ee,ie);const ae=s.sub([],ee.max,ee.min),se=S.left||0,fe=S.right||0,ke=S.bottom||0,he=S.top||0,{left:Se,right:ge,top:ze,bottom:pe}=v.padding,Ee=.5*(se+fe),De=.5*(he+ke),Ie=Math.min(y.scaleZoom(y.scale*Math.min((y.width-(se+fe+Se+ge))/ae[0],(y.height-(ke+he+pe+ze))/ae[1])),v.maxZoom),Be=y.scale/y.zoomScale(Ie);ee=new s.Aabb([ee.min[0]-(Se+Ee)*Be,ee.min[1]-(pe+De)*Be,ee.min[2]],[ee.max[0]+(ge+Ee)*Be,ee.max[1]+(ze+De)*Be,ee.max[2]]);const it=.5*ae[2],lt=this._minimumAABBFrustumDistance(y,ee),He=[0,0,1,0];s.transformMat4$1(He,He,ie),s.normalize$2(He,He);const st=s.scale$2([],He,lt+it),wt=s.add([],ee.center,st),xt=(typeof v.offset.x=="number"&&typeof v.offset.y=="number"?new s.Point(v.offset.x,v.offset.y):s.Point.convert(v.offset)).rotate(-s.degToRad(d));ee.center[0]-=xt.x*Be,ee.center[1]+=xt.y*Be,s.transformMat4(ee.center,ee.center,te),s.transformMat4(wt,wt,te);const tt=[ee.center[0],ee.center[1],wt[2]*y.pixelsPerMeter];s.scale$2(tt,tt,1/y.worldSize);const Ft=s.lngFromMercatorX(tt[0]),jt=s.latFromMercatorY(tt[1]),Vt=Math.min(y._zoomFromMercatorZ(tt[2]),v.maxZoom),Gt=new s.LngLat(Ft,jt);return y.mercatorFromTransition&&Vt<.5*(s.GLOBE_ZOOM_THRESHOLD_MIN+s.GLOBE_ZOOM_THRESHOLD_MAX)?(y.setProjection({name:"globe"}),y.zoom=Vt,this._cameraForBounds(y,o,u,d,f,g)):{center:Gt,zoom:Vt,bearing:d,pitch:f}}fitBounds(r,o,u){const d=this.cameraForBounds(r,o);return this._fitInternal(d,o,u)}fitScreenCoordinates(r,o,u,d,f){const g=s.Point.convert(r),y=s.Point.convert(o),v=new s.Point(Math.min(g.x,y.x),Math.min(g.y,y.y)),S=new s.Point(Math.max(g.x,y.x),Math.max(g.y,y.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(g,y))return this;const E=this.transform.pointLocation3D(v),C=this.transform.pointLocation3D(S),D=this.transform.pointLocation3D(new s.Point(v.x,S.y)),F=this.transform.pointLocation3D(new s.Point(S.x,v.y)),N=[Math.min(E.lng,C.lng,D.lng,F.lng),Math.min(E.lat,C.lat,D.lat,F.lat)],U=[Math.max(E.lng,C.lng,D.lng,F.lng),Math.max(E.lat,C.lat,D.lat,F.lat)],j=d&&d.pitch?d.pitch:this.getPitch(),P=this._cameraForBounds(this.transform,N,U,u,j,d);return this._fitInternal(P,d,f)}_fitInternal(r,o,u){return r?(delete(o=s.extend(r,o)).padding,o.linear?this.easeTo(o,u):this.flyTo(o,u)):this}jumpTo(r,o){this.stop();const u=r.preloadOnly?this.transform.clone():this.transform;let d=!1,f=!1,g=!1;return"zoom"in r&&u.zoom!==+r.zoom&&(d=!0,u.zoom=+r.zoom),r.center!==void 0&&(u.center=s.LngLat.convert(r.center)),"bearing"in r&&u.bearing!==+r.bearing&&(f=!0,u.bearing=+r.bearing),"pitch"in r&&u.pitch!==+r.pitch&&(g=!0,u.pitch=+r.pitch),r.padding==null||u.isPaddingEqual(r.padding)||(u.padding=r.padding),r.preloadOnly?(this._preloadTiles(u),this):(this.fire(new s.Event("movestart",o)).fire(new s.Event("move",o)),d&&this.fire(new s.Event("zoomstart",o)).fire(new s.Event("zoom",o)).fire(new s.Event("zoomend",o)),f&&this.fire(new s.Event("rotatestart",o)).fire(new s.Event("rotate",o)).fire(new s.Event("rotateend",o)),g&&this.fire(new s.Event("pitchstart",o)).fire(new s.Event("pitch",o)).fire(new s.Event("pitchend",o)),this.fire(new s.Event("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||s.warnOnce(jn),this.transform.getFreeCameraOptions()}setFreeCameraOptions(r,o){const u=this.transform;if(!u.projection.supportsFreeCamera)return s.warnOnce(jn),this;this.stop();const d=u.zoom,f=u.pitch,g=u.bearing;u.setFreeCameraOptions(r);const y=d!==u.zoom,v=f!==u.pitch,S=g!==u.bearing;return this.fire(new s.Event("movestart",o)).fire(new s.Event("move",o)),y&&this.fire(new s.Event("zoomstart",o)).fire(new s.Event("zoom",o)).fire(new s.Event("zoomend",o)),S&&this.fire(new s.Event("rotatestart",o)).fire(new s.Event("rotate",o)).fire(new s.Event("rotateend",o)),v&&this.fire(new s.Event("pitchstart",o)).fire(new s.Event("pitch",o)).fire(new s.Event("pitchend",o)),this.fire(new s.Event("moveend",o)),this}easeTo(r,o){this._stop(!1,r.easeId),((r=s.extend({offset:[0,0],duration:500,easing:s.ease},r)).animate===!1||this._prefersReducedMotion(r))&&(r.duration=0);const u=this.transform,d=this.getZoom(),f=this.getBearing(),g=this.getPitch(),y=this.getPadding(),v="zoom"in r?+r.zoom:d,S="bearing"in r?this._normalizeBearing(r.bearing,f):f,E="pitch"in r?+r.pitch:g,C="padding"in r?r.padding:u.padding,D=s.Point.convert(r.offset);let F,N,U;if(u.projection.name==="globe"){const se=s.MercatorCoordinate.fromLngLat(u.center),fe=D.rotate(-u.angle);se.x+=fe.x/u.worldSize,se.y+=fe.y/u.worldSize;const ke=se.toLngLat(),he=s.LngLat.convert(r.center||ke);this._normalizeCenter(he),F=u.centerPoint.add(fe),N=new s.Point(se.x,se.y).mult(u.worldSize),U=new s.Point(s.mercatorXfromLng(he.lng),s.mercatorYfromLat(he.lat)).mult(u.worldSize).sub(N)}else{F=u.centerPoint.add(D);const se=u.pointLocation(F),fe=s.LngLat.convert(r.center||se);this._normalizeCenter(fe),N=u.project(se),U=u.project(fe).sub(N)}const j=u.zoomScale(v-d);let P,O;r.around&&(P=s.LngLat.convert(r.around),O=u.locationPoint(P));const $=this._zooming||v!==d,q=this._rotating||f!==S,ee=this._pitching||E!==g,ie=!u.isPaddingEqual(C),te=se=>fe=>{if($&&(se.zoom=s.number(d,v,fe)),q&&(se.bearing=s.number(f,S,fe)),ee&&(se.pitch=s.number(g,E,fe)),ie&&(se.interpolatePadding(y,C,fe),F=se.centerPoint.add(D)),P)se.setLocationAtPoint(P,O);else{const ke=se.zoomScale(se.zoom-d),he=v>d?Math.min(2,j):Math.max(.5,j),Se=Math.pow(he,1-fe),ge=se.unproject(N.add(U.mult(fe*Se)).mult(ke));se.setLocationAtPoint(se.renderWorldCopies?ge.wrap():ge,F)}return r.preloadOnly||this._fireMoveEvents(o),se};if(r.preloadOnly){const se=this._emulate(te,r.duration,u);return this._preloadTiles(se),this}const ae={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=$,this._rotating=q,this._pitching=ee,this._padding=ie,this._easeId=r.easeId,this._prepareEase(o,r.noMoveStart,ae),this._ease(te(u),se=>{u.recenterOnTerrain(),this._afterEase(o,se)},r),this}_prepareEase(r,o,u={}){this._moving=!0,this.transform.cameraElevationReference="sea",o||u.moving||this.fire(new s.Event("movestart",r)),this._zooming&&!u.zooming&&this.fire(new s.Event("zoomstart",r)),this._rotating&&!u.rotating&&this.fire(new s.Event("rotatestart",r)),this._pitching&&!u.pitching&&this.fire(new s.Event("pitchstart",r))}_fireMoveEvents(r){this.fire(new s.Event("move",r)),this._zooming&&this.fire(new s.Event("zoom",r)),this._rotating&&this.fire(new s.Event("rotate",r)),this._pitching&&this.fire(new s.Event("pitch",r))}_afterEase(r,o){if(this._easeId&&o&&this._easeId===o)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const u=this._zooming,d=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,u&&this.fire(new s.Event("zoomend",r)),d&&this.fire(new s.Event("rotateend",r)),f&&this.fire(new s.Event("pitchend",r)),this.fire(new s.Event("moveend",r))}flyTo(r,o){if(this._prefersReducedMotion(r)){const Ie=s.pick(r,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ie,o)}this.stop(),r=s.extend({offset:[0,0],speed:1.2,curve:1.42,easing:s.ease},r);const u=this.transform,d=this.getZoom(),f=this.getBearing(),g=this.getPitch(),y=this.getPadding(),v="zoom"in r?s.clamp(+r.zoom,u.minZoom,u.maxZoom):d,S="bearing"in r?this._normalizeBearing(r.bearing,f):f,E="pitch"in r?+r.pitch:g,C="padding"in r?r.padding:u.padding,D=u.zoomScale(v-d),F=s.Point.convert(r.offset);let N=u.centerPoint.add(F);const U=u.pointLocation(N),j=s.LngLat.convert(r.center||U);this._normalizeCenter(j);const P=u.project(U),O=u.project(j).sub(P);let $=r.curve;const q=Math.max(u.width,u.height),ee=q/D,ie=O.mag();if("minZoom"in r){const Ie=s.clamp(Math.min(r.minZoom,d,v),u.minZoom,u.maxZoom),Be=q/u.zoomScale(Ie-d);$=Math.sqrt(Be/ie*2)}const te=$*$;function ae(Ie){const Be=(ee*ee-q*q+(Ie?-1:1)*te*te*ie*ie)/(2*(Ie?ee:q)*te*ie);return Math.log(Math.sqrt(Be*Be+1)-Be)}function se(Ie){return(Math.exp(Ie)-Math.exp(-Ie))/2}function fe(Ie){return(Math.exp(Ie)+Math.exp(-Ie))/2}const ke=ae(0);let he=function(Ie){return fe(ke)/fe(ke+$*Ie)},Se=function(Ie){return q*((fe(ke)*(se(Be=ke+$*Ie)/fe(Be))-se(ke))/te)/ie;var Be},ge=(ae(1)-ke)/$;if(Math.abs(ie)<1e-6||!isFinite(ge)){if(Math.abs(q-ee)<1e-6)return this.easeTo(r,o);const Ie=ee<q?-1:1;ge=Math.abs(Math.log(ee/q))/$,Se=function(){return 0},he=function(Be){return Math.exp(Ie*$*Be)}}r.duration="duration"in r?+r.duration:1e3*ge/("screenSpeed"in r?+r.screenSpeed/$:+r.speed),r.maxDuration&&r.duration>r.maxDuration&&(r.duration=0);const ze=f!==S,pe=E!==g,Ee=!u.isPaddingEqual(C),De=Ie=>Be=>{const it=Be*ge,lt=1/he(it);Ie.zoom=Be===1?v:d+Ie.scaleZoom(lt),ze&&(Ie.bearing=s.number(f,S,Be)),pe&&(Ie.pitch=s.number(g,E,Be)),Ee&&(Ie.interpolatePadding(y,C,Be),N=Ie.centerPoint.add(F));const He=Be===1?j:Ie.unproject(P.add(O.mult(Se(it))).mult(lt));return Ie.setLocationAtPoint(Ie.renderWorldCopies?He.wrap():He,N),Ie._updateCameraOnTerrain(),r.preloadOnly||this._fireMoveEvents(o),Ie};if(r.preloadOnly){const Ie=this._emulate(De,r.duration,u);return this._preloadTiles(Ie),this}return this._zooming=!0,this._rotating=ze,this._pitching=pe,this._padding=Ee,this._prepareEase(o,!1),this._ease(De(u),()=>this._afterEase(o),r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(r,o){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const u=this._onEaseEnd;this._onEaseEnd=void 0,u.call(this,o)}if(!r){const u=this.handlers;u&&u.stop(!1)}return this}_ease(r,o,u){u.animate===!1||u.duration===0?(r(1),o()):(this._easeStart=s.exported.now(),this._easeOptions=u,this._onEaseFrame=r,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const r=Math.min((s.exported.now()-this._easeStart)/this._easeOptions.duration,1),o=this._onEaseFrame;o&&o(this._easeOptions.easing(r)),r<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(r,o){r=s.wrap(r,-180,180);const u=Math.abs(r-o);return Math.abs(r-360-o)<u&&(r-=360),Math.abs(r+360-o)<u&&(r+=360),r}_normalizeCenter(r){const o=this.transform;if(!o.renderWorldCopies||o.maxBounds)return;const u=r.lng-o.center.lng;r.lng+=u>180?-360:u<-180?360:0}_prefersReducedMotion(r){return this._respectPrefersReducedMotion&&s.exported.prefersReducedMotion&&!(r&&r.essential)}_emulate(r,o,u){const d=Math.ceil(15*o/1e3),f=[],g=r(u.clone());for(let y=0;y<=d;y++){const v=g(y/d);f.push(v.clone())}return f}}class Xe{constructor(r={}){this.options=r,s.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(r){const o=this.options&&this.options.compact;return this._map=r,this._container=Je("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=Je("button","mapboxgl-ctrl-attrib-button",this._container),Je("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=Je("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),o&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),o===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(r,o){const u=this._map._getUIString(`AttributionControl.${o}`);r.setAttribute("aria-label",u),r.removeAttribute("title"),r.firstElementChild&&r.firstElementChild.setAttribute("title",u)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let r=this._editLink;r||(r=this._editLink=this._container.querySelector(".mapbox-improve-map"));const o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||s.config.ACCESS_TOKEN}];if(r){const u=o.reduce((d,f,g)=>(f.value&&(d+=`${f.key}=${f.value}${g<o.length-1?"&":""}`),d),"?");r.href=`${s.config.FEEDBACK_URL}/${u}#${fs(this._map,!0)}`,r.rel="noopener nofollow",this._setElementTitle(r,"MapFeedback")}}_updateData(r){!r||r.sourceDataType!=="metadata"&&r.sourceDataType!=="visibility"&&r.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let r=[];if(this._map.style.stylesheet){const d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}const o=this._map.style._sourceCaches;for(const d in o){const f=o[d];if(f.used){const g=f.getSource();g.attribution&&r.indexOf(g.attribution)<0&&r.push(g.attribution)}}r.sort((d,f)=>d.length-f.length),r=r.filter((d,f)=>{for(let g=f+1;g<r.length;g++)if(r[g].indexOf(d)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?r=[...this.options.customAttribution,...r]:r.unshift(this.options.customAttribution));const u=r.join(" | ");u!==this._attribHTML&&(this._attribHTML=u,r.length?(this._innerContainer.innerHTML=u,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Rl{constructor(){s.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(r){this._map=r,this._container=Je("div","mapboxgl-ctrl");const o=Je("a","mapboxgl-ctrl-logo");return o.target="_blank",o.rel="noopener nofollow",o.href="https://www.mapbox.com/",o.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),o.setAttribute("rel","noopener nofollow"),this._container.appendChild(o),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(r){r&&r.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const r=this._map.style._sourceCaches;if(Object.entries(r).length===0)return!0;for(const o in r){const u=r[o].getSource();if(u.hasOwnProperty("mapbox_logo")&&!u.mapbox_logo)return!1}return!0}_updateCompact(){const r=this._container.children;if(r.length){const o=r[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class Bl{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(r){const o=++this._id;return this._queue.push({callback:r,id:o,cancelled:!1}),o}remove(r){const o=this._currentlyRunning,u=o?this._queue.concat(o):this._queue;for(const d of u)if(d.id===r)return void(d.cancelled=!0)}run(r=0){const o=this._currentlyRunning=this._queue;this._queue=[];for(const u of o)if(!u.cancelled&&(u.callback(r),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function So(l,r,o){if(l=new s.LngLat(l.lng,l.lat),r){const u=new s.LngLat(l.lng-360,l.lat),d=new s.LngLat(l.lng+360,l.lat),f=360*Math.ceil(Math.abs(l.lng-o.center.lng)/360),g=o.locationPoint(l).distSqr(r),y=r.x<0||r.y<0||r.x>o.width||r.y>o.height;o.locationPoint(u).distSqr(r)<g&&(y||Math.abs(u.lng-o.center.lng)<f)?l=u:o.locationPoint(d).distSqr(r)<g&&(y||Math.abs(d.lng-o.center.lng)<f)&&(l=d)}for(;Math.abs(l.lng-o.center.lng)>180;){const u=o.locationPoint(l);if(u.x>=0&&u.y>=0&&u.x<=o.width&&u.y<=o.height)break;l.lng>o.center.lng?l.lng-=360:l.lng+=360}return l}const Vn={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%)"};class qe extends s.Evented{constructor(r,o){if(super(),(r instanceof s.window.HTMLElement||o)&&(r=s.extend({element:r},o)),s.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&r.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=r&&r.occludedOpacity||.2,r&&r.element)this._element=r.element,this._offset=s.Point.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=Je("div");const d=41,f=27,g=Ye("svg",{display:"block",height:d*this._scale+"px",width:f*this._scale+"px",viewBox:`0 0 ${f} ${d}`},this._element),y=Ye("radialGradient",{id:"shadowGradient"},Ye("defs",{},g));Ye("stop",{offset:"10%","stop-opacity":.4},y),Ye("stop",{offset:"100%","stop-opacity":.05},y),Ye("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},g),Ye("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},g),Ye("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},g),Ye("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},g),this._offset=s.Point.convert(r&&r.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",d=>{d.preventDefault()}),this._element.addEventListener("mousedown",d=>{d.preventDefault()});const u=this._element.classList;for(const d in Vn)u.remove(`mapboxgl-marker-anchor-${d}`);u.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(r){return r===this._map||(this.remove(),this._map=r,r.getCanvasContainer().appendChild(this._element),r.on("move",this._updateMoving),r.on("moveend",this._update),r.on("remove",this._clearFadeTimer),r._addMarker(this),this.setDraggable(this._draggable),this._update(),r.on("click",this._onMapClick)),this}remove(){const r=this._map;return r&&(r.off("click",this._onMapClick),r.off("move",this._updateMoving),r.off("moveend",this._update),r.off("mousedown",this._addDragHandler),r.off("touchstart",this._addDragHandler),r.off("mouseup",this._onUp),r.off("touchend",this._onUp),r.off("mousemove",this._onMove),r.off("touchmove",this._onMove),r.off("remove",this._clearFadeTimer),r._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=s.LngLat.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(r){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),r){if(!("offset"in r.options)){const d=Math.sqrt(Math.pow(13.5,2)/2);r.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[d,-1*(38.1-13.5+d)],"bottom-right":[-d,-1*(38.1-13.5+d)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=r,r._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(r){const o=r.code,u=r.charCode||r.keyCode;o!=="Space"&&o!=="Enter"&&u!==32&&u!==13||this.togglePopup()}_onMapClick(r){const o=r.originalEvent.target,u=this._element;this._popup&&(o===u||u.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const r=this._popup;return r?(r.isOpen()?(r.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(r.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const r=this._map,o=this._pos;if(!r||!o)return!1;const u=r.unproject(o),d=r.getFreeCameraOptions();if(!d.position)return!1;const f=d.position.toLngLat();return f.distanceTo(u)<.9*f.distanceTo(this._lngLat)}_evaluateOpacity(){const r=this._map;if(!r)return;const o=this._pos;if(!o||o.x<0||o.x>r.transform.width||o.y<0||o.y>r.transform.height)return void this._clearFadeTimer();const u=r.unproject(o);let d;r._showingGlobe()&&s.isLngLatBehindGlobe(r.transform,this._lngLat)?d=0:(d=1-r._queryFogOpacity(u),r.transform._terrainEnabled()&&r.getTerrain()&&this._behindTerrain()&&(d*=this._occludedOpacity)),this._element.style.opacity=`${d}`,this._element.style.pointerEvents=d>0?"auto":"none",this._popup&&this._popup._setOpacity(d),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const r=this._pos;if(!r||!this._map)return;const o=this._offset.mult(this._scale);this._element.style.transform=`
            translate(${r.x}px,${r.y}px)
            ${Vn[this._anchor]}
            ${this._calculateXYTransform()} ${this._calculateZTransform()}
            translate(${o.x}px,${o.y}px)
        `}_calculateXYTransform(){const r=this._pos,o=this._map,u=this.getPitchAlignment();if(!o||!r||u!=="map")return"";if(!o._showingGlobe()){const v=o.getPitch();return v?`rotateX(${v}deg)`:""}const d=s.radToDeg(s.globeTiltAtLngLat(o.transform,this._lngLat)),f=r.sub(s.globeCenterToScreenPoint(o.transform)),g=Math.abs(f.x)+Math.abs(f.y);if(g===0)return"";const y=d/g;return`rotateX(${-f.y*y}deg) rotateY(${f.x*y}deg)`}_calculateZTransform(){const r=this._pos,o=this._map;if(!o||!r)return"";let u=0;const d=this.getRotationAlignment();if(d==="map")if(o._showingGlobe()){const f=o.project(new s.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),g=o.project(new s.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(f);u=s.radToDeg(Math.atan2(g.y,g.x))-90}else u=-o.getBearing();else if(d==="horizon"){const f=s.smoothstep(4,6,o.getZoom()),g=s.globeCenterToScreenPoint(o.transform);g.y+=f*o.transform.height;const y=r.sub(g),v=s.radToDeg(Math.atan2(y.y,y.x));u=(v>90?v-270:v+90)*(1-f)}return u+=this._rotation,u?`rotateZ(${u}deg)`:""}_update(r){s.window.cancelAnimationFrame(this._updateFrameId);const o=this._map;o&&(o.transform.renderWorldCopies&&(this._lngLat=So(this._lngLat,this._pos,o.transform)),this._pos=o.project(this._lngLat),r===!0?this._updateFrameId=s.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),o._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(o._showingGlobe()||o.getTerrain()||o.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(r){return this._offset=s.Point.convert(r),this._update(),this}_onMove(r){const o=this._map;if(!o)return;const u=this._pointerdownPos,d=this._positionDelta;if(u&&d){if(!this._isDragging){const f=this._clickTolerance||o._clickTolerance;if(r.point.dist(u)<f)return;this._isDragging=!0}this._pos=r.point.sub(d),this._lngLat=o.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new s.Event("dragstart"))),this.fire(new s.Event("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const r=this._map;r&&(r.off("mousemove",this._onMove),r.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new s.Event("dragend")),this._state="inactive"}_addDragHandler(r){const o=this._map,u=this._pos;o&&u&&this._element.contains(r.originalEvent.target)&&(r.preventDefault(),this._positionDelta=r.point.sub(u),this._pointerdownPos=r.point,this._state="pending",o.on("mousemove",this._onMove),o.on("touchmove",this._onMove),o.once("mouseup",this._onUp),o.once("touchend",this._onUp))}setDraggable(r){this._draggable=!!r;const o=this._map;return o&&(r?(o.on("mousedown",this._addDragHandler),o.on("touchstart",this._addDragHandler)):(o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(r){return this._rotation=r||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(r){return this._rotationAlignment=r||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(r){return this._pitchAlignment=r||"auto",this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(r){return this._occludedOpacity=r||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const Ol={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Ah=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function uu(l=new s.Point(0,0),r="bottom"){if(typeof l=="number"){const o=Math.round(Math.sqrt(.5*Math.pow(l,2)));switch(r){case"top":return new s.Point(0,l);case"top-left":return new s.Point(o,o);case"top-right":return new s.Point(-o,o);case"bottom":return new s.Point(0,-l);case"bottom-left":return new s.Point(o,-o);case"bottom-right":return new s.Point(-o,-o);case"left":return new s.Point(l,0);case"right":return new s.Point(-l,0)}return new s.Point(0,0)}return l instanceof s.Point||Array.isArray(l)?s.Point.convert(l):s.Point.convert(l[r]||[0,0])}class Fl{constructor(r){this.jumpTo(r)}getValue(r){if(r<=this._startTime)return this._start;if(r>=this._endTime)return this._end;const o=s.easeCubicInOut((r-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(r){return r>=this._startTime&&r<=this._endTime}jumpTo(r){this._startTime=-1/0,this._endTime=-1/0,this._start=r,this._end=r}easeTo(r,o,u){this._start=this.getValue(o),this._end=r,this._startTime=o,this._endTime=o+u}}const hu={"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":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},du={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},Mh={showCompass:!0,showZoom:!0,visualizePitch:!1};class Ih{constructor(r,o,u=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new Pl({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,u&&(this.mousePitch=new zl({clickTolerance:r.dragRotate._mousePitch._clickTolerance})),s.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),o.addEventListener("mousedown",this.mousedown),o.addEventListener("touchstart",this.touchstart,{passive:!1}),o.addEventListener("touchmove",this.touchmove),o.addEventListener("touchend",this.touchend),o.addEventListener("touchcancel",this.reset)}down(r,o){this.mouseRotate.mousedown(r,o),this.mousePitch&&this.mousePitch.mousedown(r,o),ei()}move(r,o){const u=this.map,d=this.mouseRotate.mousemoveWindow(r,o),f=d&&d.bearingDelta;if(f&&u.setBearing(u.getBearing()+f),this.mousePitch){const g=this.mousePitch.mousemoveWindow(r,o),y=g&&g.pitchDelta;y&&u.setPitch(u.getPitch()+y)}}off(){const r=this.element;r.removeEventListener("mousedown",this.mousedown),r.removeEventListener("touchstart",this.touchstart,{passive:!1}),r.removeEventListener("touchmove",this.touchmove),r.removeEventListener("touchend",this.touchend),r.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){Ct(),s.window.removeEventListener("mousemove",this.mousemove),s.window.removeEventListener("mouseup",this.mouseup)}mousedown(r){this.down(s.extend({},r,{ctrlKey:!0,preventDefault:()=>r.preventDefault()}),Lt(this.element,r)),s.window.addEventListener("mousemove",this.mousemove),s.window.addEventListener("mouseup",this.mouseup)}mousemove(r){this.move(r,Lt(this.element,r))}mouseup(r){this.mouseRotate.mouseupWindow(r),this.mousePitch&&this.mousePitch.mouseupWindow(r),this.offTemp()}touchstart(r){r.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=ti(this.element,r.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>r.preventDefault()},this._startPos))}touchmove(r){r.targetTouches.length!==1?this.reset():(this._lastPos=ti(this.element,r.targetTouches)[0],this.move({preventDefault:()=>r.preventDefault()},this._lastPos))}touchend(r){r.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const Ul={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},Nl={maxWidth:100,unit:"metric"},jl={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},Ao={version:s.version,supported:Qe,setRTLTextPlugin:s.setRTLTextPlugin,getRTLTextPluginStatus:s.getRTLTextPluginStatus,Map:class extends ya{constructor(l){if(s.LivePerformanceUtils.mark(s.PerformanceMarkers.create),(l=s.extend({},du,l)).minZoom!=null&&l.maxZoom!=null&&l.minZoom>l.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(l.minPitch!=null&&l.maxPitch!=null&&l.minPitch>l.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(l.minPitch!=null&&l.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(l.maxPitch!=null&&l.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(l.antialias&&s.isSafariWithAntialiasingBug(s.window)&&(l.antialias=!1,s.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new bo(l.minZoom,l.maxZoom,l.minPitch,l.maxPitch,l.renderWorldCopies),l),this._interactive=l.interactive,this._minTileCacheSize=l.minTileCacheSize,this._maxTileCacheSize=l.maxTileCacheSize,this._failIfMajorPerformanceCaveat=l.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=l.preserveDrawingBuffer,this._antialias=l.antialias,this._useWebGL2=l.useWebGL2,this._trackResize=l.trackResize,this._bearingSnap=l.bearingSnap,this._refreshExpiredTiles=l.refreshExpiredTiles,this._fadeDuration=l.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=l.crossSourceCollisions,this._collectResourceTiming=l.collectResourceTiming,this._optimizeForTerrain=l.optimizeForTerrain,this._language=this._parseLanguage(l.language),this._worldview=l.worldview,this._renderTaskQueue=new Bl,this._domRenderTaskQueue=new Bl,this._controls=[],this._markers=[],this._popups=[],this._mapId=s.uniqueId(),this._locale=s.extend({},hu,l.locale),this._clickTolerance=l.clickTolerance,this._cooperativeGestures=l.cooperativeGestures,this._performanceMetricsCollection=l.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Fl(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new s.RequestManager(l.transformRequest,l.accessToken,l.testMode),this._silenceAuthErrors=!!l.testMode,typeof l.container=="string"){if(this._container=s.window.document.getElementById(l.container),!this._container)throw new Error(`Container '${l.container}' not found.`)}else{if(!(l.container instanceof s.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=l.container}if(this._container.childNodes.length>0&&s.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),l.maxBounds&&this.setMaxBounds(l.maxBounds),s.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),s.window!==void 0&&(s.window.addEventListener("online",this._onWindowOnline,!1),s.window.addEventListener("resize",this._onWindowResize,!1),s.window.addEventListener("orientationchange",this._onWindowResize,!1),s.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),s.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Dr(this,l),this._localFontFamily=l.localFontFamily,this._localIdeographFontFamily=l.localIdeographFontFamily,l.style&&this.setStyle(l.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),l.projection&&this.setProjection(l.projection),this._hash=l.hash&&new Al(typeof l.hash=="string"&&l.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch}),l.bounds&&(this.resize(),this.fitBounds(l.bounds,s.extend({},l.fitBoundsOptions,{duration:0})))),this.resize(),l.attributionControl&&this.addControl(new Xe({customAttribution:l.customAttribution})),this._logoControl=new Rl,this.addControl(this._logoControl,l.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",r=>{this._update(r.dataType==="style"),this.fire(new s.Event(`${r.dataType}data`,r))}),this.on("dataloading",r=>{this.fire(new s.Event(`${r.dataType}dataloading`,r))})}_getMapId(){return this._mapId}addControl(l,r){if(r===void 0&&(r=l.getDefaultPosition?l.getDefaultPosition():"top-right"),!l||!l.onAdd)return this.fire(new s.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=l.onAdd(this);this._controls.push(l);const u=this._controlPositions[r];return r.indexOf("bottom")!==-1?u.insertBefore(o,u.firstChild):u.appendChild(o),this}removeControl(l){if(!l||!l.onRemove)return this.fire(new s.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(l);return r>-1&&this._controls.splice(r,1),l.onRemove(this),this}hasControl(l){return this._controls.indexOf(l)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(l){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const r=!this._moving;return r&&this.fire(new s.Event("movestart",l)).fire(new s.Event("move",l)),this.fire(new s.Event("resize",l)),r&&this.fire(new s.Event("moveend",l)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(l){return this.transform.setMaxBounds(s.LngLatBounds.convert(l)),this._update()}setMinZoom(l){if((l=l??-2)>=-2&&l<=this.transform.maxZoom)return this.transform.minZoom=l,this._update(),this.getZoom()<l?this.setZoom(l):this.fire(new s.Event("zoomstart")).fire(new s.Event("zoom")).fire(new s.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(l){if((l=l??22)>=this.transform.minZoom)return this.transform.maxZoom=l,this._update(),this.getZoom()>l?this.setZoom(l):this.fire(new s.Event("zoomstart")).fire(new s.Event("zoom")).fire(new s.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(l){if((l=l??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(l>=0&&l<=this.transform.maxPitch)return this.transform.minPitch=l,this._update(),this.getPitch()<l?this.setPitch(l):this.fire(new s.Event("pitchstart")).fire(new s.Event("pitch")).fire(new s.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(l){if((l=l??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(l>=this.transform.minPitch)return this.transform.maxPitch=l,this._update(),this.getPitch()>l?this.setPitch(l):this.fire(new s.Event("pitchstart")).fire(new s.Event("pitch")).fire(new s.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(l){return this.transform.renderWorldCopies=l,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(l){return l==="auto"?s.window.navigator.language:Array.isArray(l)?l.length===0?void 0:l.map(r=>r==="auto"?s.window.navigator.language:r):l}setLanguage(l){const r=this._parseLanguage(l);if(!this.style||r===this._language)return this;this._language=r,this.style._reloadSources();for(const o of this._controls)o._setLanguage&&o._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(l){return this.style&&l!==this._worldview?(this._worldview=l,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(l){return this._lazyInitEmptyStyle(),l?typeof l=="string"&&(l={name:l}):l=null,this._useExplicitProjection=!!l,this._prioritizeAndUpdateProjection(l,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const l=this.transform,r=l.projection.name;let o;r==="globe"&&l.zoom>=s.GLOBE_ZOOM_THRESHOLD_MAX?(l.setMercatorFromTransition(),o=!0):r==="mercator"&&l.zoom<s.GLOBE_ZOOM_THRESHOLD_MAX&&(l.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(l,r){return this._updateProjection(l||r||{name:"mercator"})}_updateProjection(l){let r;if(r=l.name==="globe"&&this.transform.zoom>=s.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(l),this.style.applyProjectionUpdate(),r){this.painter.clearBackgroundTiles();for(const o in this.style._sourceCaches)this.style._sourceCaches[o].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(l){return this.transform.locationPoint3D(s.LngLat.convert(l))}unproject(l){return this.transform.pointLocation3D(s.Point.convert(l))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(l,r,o){if(l==="mouseenter"||l==="mouseover"){let u=!1;const d=g=>{const y=r.filter(S=>this.getLayer(S)),v=y.length?this.queryRenderedFeatures(g.point,{layers:y}):[];v.length?u||(u=!0,o.call(this,new Bi(l,this,g.originalEvent,{features:v}))):u=!1},f=()=>{u=!1};return{layers:new Set(r),listener:o,delegates:{mousemove:d,mouseout:f}}}if(l==="mouseleave"||l==="mouseout"){let u=!1;const d=g=>{const y=r.filter(v=>this.getLayer(v));(y.length?this.queryRenderedFeatures(g.point,{layers:y}):[]).length?u=!0:u&&(u=!1,o.call(this,new Bi(l,this,g.originalEvent)))},f=g=>{u&&(u=!1,o.call(this,new Bi(l,this,g.originalEvent)))};return{layers:new Set(r),listener:o,delegates:{mousemove:d,mouseout:f}}}{const u=d=>{const f=r.filter(y=>this.getLayer(y)),g=f.length?this.queryRenderedFeatures(d.point,{layers:f}):[];g.length&&(d.features=g,o.call(this,d),delete d.features)};return{layers:new Set(r),listener:o,delegates:{[l]:u}}}}on(l,r,o){if(o===void 0)return super.on(l,r);Array.isArray(r)||(r=[r]);const u=this._createDelegatedListener(l,r,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[l]=this._delegatedListeners[l]||[],this._delegatedListeners[l].push(u);for(const d in u.delegates)this.on(d,u.delegates[d]);return this}once(l,r,o){if(o===void 0)return super.once(l,r);Array.isArray(r)||(r=[r]);const u=this._createDelegatedListener(l,r,o);for(const d in u.delegates)this.once(d,u.delegates[d]);return this}off(l,r,o){if(o===void 0)return super.off(l,r);r=new Set(Array.isArray(r)?r:[r]);const u=(f,g)=>{if(f.size!==g.size)return!1;for(const y of f)if(!g.has(y))return!1;return!0},d=this._delegatedListeners?this._delegatedListeners[l]:void 0;return d&&(f=>{for(let g=0;g<f.length;g++){const y=f[g];if(y.listener===o&&u(y.layers,r)){for(const v in y.delegates)this.off(v,y.delegates[v]);return f.splice(g,1),this}}})(d),this}queryRenderedFeatures(l,r){return this.style?(r!==void 0||l===void 0||l instanceof s.Point||Array.isArray(l)||(r=l,l=void 0),this.style.queryRenderedFeatures(l=l||[[0,0],[this.transform.width,this.transform.height]],r=r||{},this.transform)):[]}querySourceFeatures(l,r){return this.style.querySourceFeatures(l,r)}isPointOnSurface(l){const{name:r}=this.transform.projection;return r!=="globe"&&r!=="mercator"&&s.warnOnce(`${r} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(s.Point.convert(l))}setStyle(l,r){return(r=s.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},r)).diff!==!1&&r.localIdeographFontFamily===this._localIdeographFontFamily&&r.localFontFamily===this._localFontFamily&&this.style&&l?(this._diffStyle(l,r),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._updateStyle(l,r))}_getUIString(l){const r=this._locale[l];if(r==null)throw new Error(`Missing UI string '${l}'`);return r}_updateStyle(l,r){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),l&&(this.style=new kr(this,r||{}),this.style.setEventedParent(this,{style:this.style}),typeof l=="string"?this.style.loadURL(l):this.style.loadJSON(l)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new kr(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(l,r){if(typeof l=="string"){const o=this._requestManager.normalizeStyleURL(l),u=this._requestManager.transformRequest(o,s.ResourceType.Style);s.getJSON(u,(d,f)=>{d?this.fire(new s.ErrorEvent(d)):f&&this._updateDiff(f,r)})}else typeof l=="object"&&this._updateDiff(l,r)}_updateDiff(l,r){try{this.style.setState(l)&&this._update(!0)}catch(o){s.warnOnce(`Unable to perform style diff: ${o.message||o.error||o}.  Rebuilding the style from scratch.`),this._updateStyle(l,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(s.warnOnce("There is no style added to the map."),!1)}addSource(l,r){return this._lazyInitEmptyStyle(),this.style.addSource(l,r),this._update(!0)}isSourceLoaded(l){return!!this.style&&this.style._isSourceCacheLoaded(l)}areTilesLoaded(){const l=this.style&&this.style._sourceCaches;for(const r in l){const o=l[r]._tiles;for(const u in o){const d=o[u];if(d.state!=="loaded"&&d.state!=="errored")return!1}}return!0}addSourceType(l,r,o){this._lazyInitEmptyStyle(),this.style.addSourceType(l,r,o)}removeSource(l){return this.style.removeSource(l),this._updateTerrain(),this._update(!0)}getSource(l){return this.style.getSource(l)}addImage(l,r,{pixelRatio:o=1,sdf:u=!1,stretchX:d,stretchY:f,content:g}={}){if(this._lazyInitEmptyStyle(),r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap){const{width:y,height:v,data:S}=s.exported.getImageData(r);this.style.addImage(l,{data:new s.RGBAImage({width:y,height:v},S),pixelRatio:o,stretchX:d,stretchY:f,content:g,sdf:u,version:0})}else if(r.width===void 0||r.height===void 0)this.fire(new s.ErrorEvent(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`")));else{const{width:y,height:v}=r,S=r;this.style.addImage(l,{data:new s.RGBAImage({width:y,height:v},new Uint8Array(S.data)),pixelRatio:o,stretchX:d,stretchY:f,content:g,sdf:u,version:0,userImage:S}),S.onAdd&&S.onAdd(this,l)}}updateImage(l,r){const o=this.style.getImage(l);if(!o)return void this.fire(new s.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const u=r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap?s.exported.getImageData(r):r,{width:d,height:f}=u;d!==void 0&&f!==void 0?d===o.data.width&&f===o.data.height?(o.data.replace(u.data,!(r instanceof s.window.HTMLImageElement||s.window.ImageBitmap&&r instanceof s.window.ImageBitmap)),this.style.updateImage(l,o)):this.fire(new s.ErrorEvent(new Error(`The width and height of the updated image (${d}, ${f})
                must be that same as the previous version of the image
                (${o.data.width}, ${o.data.height})`))):this.fire(new s.ErrorEvent(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`")))}hasImage(l){return l?!!this.style.getImage(l):(this.fire(new s.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(l){this.style.removeImage(l)}loadImage(l,r){s.getImage(this._requestManager.transformRequest(l,s.ResourceType.Image),(o,u)=>{r(o,u instanceof s.window.HTMLImageElement?s.exported.getImageData(u):u)})}listImages(){return this.style.listImages()}addLayer(l,r){return this._lazyInitEmptyStyle(),this.style.addLayer(l,r),this._update(!0)}moveLayer(l,r){return this.style.moveLayer(l,r),this._update(!0)}removeLayer(l){return this.style.removeLayer(l),this._update(!0)}getLayer(l){return this.style.getLayer(l)}setLayerZoomRange(l,r,o){return this.style.setLayerZoomRange(l,r,o),this._update(!0)}setFilter(l,r,o={}){return this.style.setFilter(l,r,o),this._update(!0)}getFilter(l){return this.style.getFilter(l)}setPaintProperty(l,r,o,u={}){return this.style.setPaintProperty(l,r,o,u),this._update(!0)}getPaintProperty(l,r){return this.style.getPaintProperty(l,r)}setLayoutProperty(l,r,o,u={}){return this.style.setLayoutProperty(l,r,o,u),this._update(!0)}getLayoutProperty(l,r){return this.style.getLayoutProperty(l,r)}setLight(l,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(l,r),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(l){return this._lazyInitEmptyStyle(),!l&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(l),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(l){return this._lazyInitEmptyStyle(),this.style.setFog(l),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(l){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(s.LngLat.convert(l),this.transform):0}setFeatureState(l,r){return this.style.setFeatureState(l,r),this._update()}removeFeatureState(l,r){return this.style.removeFeatureState(l,r),this._update()}getFeatureState(l){return this.style.getFeatureState(l)}_updateContainerDimensions(){if(!this._container)return;const l=this._container.getBoundingClientRect().width||400,r=this._container.getBoundingClientRect().height||300;let o,u,d,f=this._container;for(;f&&(!u||!d);){const g=s.window.getComputedStyle(f).transform;g&&g!=="none"&&(o=g.match(/matrix.*\((.+)\)/)[1].split(", "),o[0]&&o[0]!=="0"&&o[0]!=="1"&&(u=o[0]),o[3]&&o[3]!=="0"&&o[3]!=="1"&&(d=o[3])),f=f.parentElement}this._containerWidth=u?Math.abs(l/u):l,this._containerHeight=d?Math.abs(r/d):r}_detectMissingCSS(){s.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&s.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const l=this._container;l.classList.add("mapboxgl-map"),(this._missingCSSCanary=Je("div","mapboxgl-canary",l)).style.visibility="hidden",this._detectMissingCSS();const r=this._canvasContainer=Je("div","mapboxgl-canvas-container",l);this._interactive&&r.classList.add("mapboxgl-interactive"),this._canvas=Je("canvas","mapboxgl-canvas",r),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const o=this._controlContainer=Je("div","mapboxgl-control-container",l),u=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(d=>{u[d]=Je("div",`mapboxgl-ctrl-${d}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(l,r){const o=s.exported.devicePixelRatio||1;this._canvas.width=o*Math.ceil(l),this._canvas.height=o*Math.ceil(r),this._canvas.style.width=`${l}px`,this._canvas.style.height=`${r}px`}_addMarker(l){this._markers.push(l)}_removeMarker(l){const r=this._markers.indexOf(l);r!==-1&&this._markers.splice(r,1)}_addPopup(l){this._popups.push(l)}_removePopup(l){const r=this._popups.indexOf(l);r!==-1&&this._popups.splice(r,1)}_setupPainter(){const l=s.extend({},Qe.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._useWebGL2&&this._canvas.getContext("webgl2",l),o=r||this._canvas.getContext("webgl",l)||this._canvas.getContext("experimental-webgl",l);o?(this._useWebGL2&&!r&&s.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),s.storeAuthState(o,!0),this.painter=new xo(o,this.transform,!!r),this.on("data",u=>{u.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),s.exported$1.testSupport(o)):this.fire(new s.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(l){l.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new s.Event("webglcontextlost",{originalEvent:l}))}_contextRestored(l){this._setupPainter(),this.resize(),this._update(),this.fire(new s.Event("webglcontextrestored",{originalEvent:l}))}_onMapScroll(l){if(l.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(l){return this.style?(this._styleDirty=this._styleDirty||l,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(l){return this._update(),this._renderTaskQueue.add(l)}_cancelRenderFrame(l){this._renderTaskQueue.remove(l)}_requestDomTask(l){!this.loaded()||this.loaded()&&!this.isMoving()?l():this._domRenderTaskQueue.add(l)}_render(l){let r;const o=this.painter.context.extTimerQuery,u=s.exported.now();if(this.listens("gpu-timing-frame")&&(r=o.createQueryEXT(),o.beginQueryEXT(o.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],s.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],s.window.performance.now())),this._renderTaskQueue.run(l),this._domRenderTaskQueue.run(l),this._removed)return;this._updateProjectionTransition();const d=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const y=this.transform.zoom,v=this.transform.pitch,S=s.exported.now(),E=new s.EvaluationParameters(y,{now:S,fadeDuration:d,pitch:v,transition:this.style.getTransition()});this.style.update(E)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let f=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),f=this._updateAverageElevation(u),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):f=this._updateAverageElevation(u),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,d,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:d,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new s.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new s.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const y=s.exported.now()-u;o.endQueryEXT(o.TIME_ELAPSED_EXT,r),setTimeout(()=>{const v=o.getQueryObjectEXT(r,o.QUERY_RESULT_EXT)/1e6;o.deleteQueryEXT(r),this.fire(new s.Event("gpu-timing-frame",{cpuTime:y,gpuTime:v})),s.window.performance.mark("frame-gpu",{startTime:u,detail:{gpuTime:v}})},50)}if(this.listens("gpu-timing-layer")){const y=this.painter.collectGpuTimers();setTimeout(()=>{const v=this.painter.queryGpuTimers(y);this.fire(new s.Event("gpu-timing-layer",{layerTimes:v}))},50)}if(this.listens("gpu-timing-deferred-render")){const y=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const v=this.painter.queryGpuTimeDeferredRender(y);this.fire(new s.Event("gpu-timing-deferred-render",{gpuTime:v}))},50)}const g=this._sourcesDirty||this._styleDirty||this._placementDirty||f;if(g||this._repaint)this.triggerRepaint();else{const y=!this.isMoving()&&this.loaded();if(y&&(f=this._updateAverageElevation(u,!0)),f)this.triggerRepaint();else if(this._triggerFrame(!1),y&&(this.fire(new s.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const v=this._calculateSpeedIndex();this.fire(new s.Event("speedindexcompleted",{speedIndex:v})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||g||(this._fullyLoaded=!0,s.LivePerformanceUtils.mark(s.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&s.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(l){for(const r of this._markers)l&&!this.getRenderWorldCopies()&&(r._lngLat=r._lngLat.wrap()),r._update();for(const r of this._popups)!l||this.getRenderWorldCopies()||r._trackPointer||(r._lngLat=r._lngLat.wrap()),r._update()}_updateAverageElevation(l,r=!1){const o=u=>(this.transform.averageElevation=u,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&o(0);if((r||l-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(l)){const u=this.transform.averageElevation;let d=this.transform.sampleAverageElevation(),f=!1;this.transform.elevation&&(f=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(d)?d=0:this._averageElevationLastSampledAt=l;const g=Math.abs(u-d);if(g>1){if(this._isInitialLoad||f)return this._averageElevation.jumpTo(d),o(d);this._averageElevation.easeTo(d,l,300)}else if(g>1e-4)return this._averageElevation.jumpTo(d),o(d)}return!!this._averageElevation.isEasing(l)&&o(this._averageElevation.getValue(l))}_authenticate(){s.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,l=>{if(l&&(l.message===s.AUTH_ERR_MSG||l.status===401)){const r=this.painter.context.gl;s.storeAuthState(r,!1),this._logoControl instanceof Rl&&this._logoControl._updateLogo(),r&&r.clear(r.DEPTH_BUFFER_BIT|r.COLOR_BUFFER_BIT|r.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new s.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),s.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const l=this._isDragging();this.painter.updateTerrain(this.style,l)}_calculateSpeedIndex(){const l=this.painter.canvasCopy(),r=this.painter.getCanvasCopiesAndTimestamps();r.timeStamps.push(performance.now());const o=this.painter.context.gl,u=o.createFramebuffer();function d(f){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0);const g=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,g),g}return o.bindFramebuffer(o.FRAMEBUFFER,u),this._canvasPixelComparison(d(l),r.canvasCopies.map(d),r.timeStamps)}_canvasPixelComparison(l,r,o){let u=o[1]-o[0];const d=l.length/4;for(let f=0;f<r.length;f++){const g=r[f];let y=0;for(let v=0;v<g.length;v+=4)g[v]===l[v]&&g[v+1]===l[v+1]&&g[v+2]===l[v+2]&&g[v+3]===l[v+3]&&(y+=1);u+=(o[f+2]-o[f+1])*(1-y/d)}return u}remove(){this._hash&&this._hash.remove();for(const r of this._controls)r.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),s.window!==void 0&&(s.window.removeEventListener("resize",this._onWindowResize,!1),s.window.removeEventListener("orientationchange",this._onWindowResize,!1),s.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),s.window.removeEventListener("online",this._onWindowOnline,!1),s.window.removeEventListener("visibilitychange",this._onVisibilityChange,!1));const l=this.painter.context.gl.getExtension("WEBGL_lose_context");l&&l.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),s.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new s.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(l){this._renderNextFrame=this._renderNextFrame||l,this.style&&!this._frame&&(this._frame=s.exported.frame(r=>{const o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(r)}))}_preloadTiles(l){const r=this.style?Object.values(this.style._sourceCaches):[];return s.asyncAll(r,(o,u)=>o._preloadTiles(l,u),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(l){this._trackResize&&this.resize({originalEvent:l})._update()}_onVisibilityChange(){s.window.document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(l){this._showTileBoundaries!==l&&(this._showTileBoundaries=l,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(l){this._showTerrainWireframe!==l&&(this._showTerrainWireframe=l,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(l){this._speedIndexTiming!==l&&(this._speedIndexTiming=l,this._update())}get showPadding(){return!!this._showPadding}set showPadding(l){this._showPadding!==l&&(this._showPadding=l,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(l){this._showCollisionBoxes!==l&&(this._showCollisionBoxes=l,l?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(l){this._showOverdrawInspector!==l&&(this._showOverdrawInspector=l,this._update())}get repaint(){return!!this._repaint}set repaint(l){this._repaint!==l&&(this._repaint=l,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(l){this._vertices=l,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(l){this._showTileAABBs!==l&&(this._showTileAABBs=l,l&&this._update())}_setCacheLimits(l,r){s.setCacheLimits(l,r)}get version(){return s.version}},NavigationControl:class{constructor(l){this.options=s.extend({},Mh,l),this._container=Je("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",r=>r.preventDefault()),this.options.showZoom&&(s.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",r=>{this._map&&this._map.zoomIn({},{originalEvent:r})}),Je("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",r=>{this._map&&this._map.zoomOut({},{originalEvent:r})}),Je("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(s.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",r=>{const o=this._map;o&&(this.options.visualizePitch?o.resetNorthPitch({},{originalEvent:r}):o.resetNorth({},{originalEvent:r}))}),this._compassIcon=Je("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const l=this._map;if(!l)return;const r=l.getZoom(),o=r===l.getMaxZoom(),u=r===l.getMinZoom();this._zoomInButton.disabled=o,this._zoomOutButton.disabled=u,this._zoomInButton.setAttribute("aria-disabled",o.toString()),this._zoomOutButton.setAttribute("aria-disabled",u.toString())}_rotateCompassArrow(){const l=this._map;if(!l)return;const r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(l.transform.pitch*(Math.PI/180)),.5)}) rotateX(${l.transform.pitch}deg) rotateZ(${l.transform.angle*(180/Math.PI)}deg)`:`rotate(${l.transform.angle*(180/Math.PI)}deg)`;l._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=r)})}onAdd(l){return this._map=l,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),l.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&l.on("pitch",this._rotateCompassArrow),l.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ih(l,this._compass,this.options.visualizePitch)),this._container}onRemove(){const l=this._map;l&&(this._container.remove(),this.options.showZoom&&l.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&l.off("pitch",this._rotateCompassArrow),l.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(l,r){const o=Je("button",l,this._container);return o.type="button",o.addEventListener("click",r),o}_setButtonTitle(l,r){if(!this._map)return;const o=this._map._getUIString(`NavigationControl.${r}`);l.setAttribute("aria-label",o),l.firstElementChild&&l.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends s.Evented{constructor(l){super(),this.options=s.extend({geolocation:s.window.navigator.geolocation},Ul,l),s.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=wo(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(l){return this._map=l,this._container=Je("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(l){const r=(o=!!this.options.geolocation)=>{this._supportsGeolocation=o,l(o)};this._supportsGeolocation!==void 0?l(this._supportsGeolocation):s.window.navigator.permissions!==void 0?s.window.navigator.permissions.query({name:"geolocation"}).then(o=>r(o.state!=="denied")).catch(()=>r()):r()}_isOutOfMapMaxBounds(l){const r=this._map.getMaxBounds(),o=l.coords;return!!r&&(o.longitude<r.getWest()||o.longitude>r.getEast()||o.latitude<r.getSouth()||o.latitude>r.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(l){if(this._map){if(this._isOutOfMapMaxBounds(l))return this._setErrorState(),this.fire(new s.Event("outofmaxbounds",l)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=l,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(l),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(l),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new s.Event("geolocate",l)),this._finish()}}_updateCamera(l){const r=new s.LngLat(l.coords.longitude,l.coords.latitude),o=l.coords.accuracy,u=this._map.getBearing(),d=s.extend({bearing:u},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(o),d,{geolocateSource:!0})}_updateMarker(l){if(l){const r=new s.LngLat(l.coords.longitude,l.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=l.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const l=this._map.transform,r=s.mercatorZfromAltitude(1,l._center.lat)*l.worldSize,o=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(l){if(this._map){if(this.options.trackUserLocation)if(l.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(l.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new s.Event("error",l)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(l){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",r=>r.preventDefault()),this._geolocateButton=Je("button","mapboxgl-ctrl-geolocate",this._container),Je("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",l===!1){s.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}else{const r=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Je("div","mapboxgl-user-location"),this._dotElement.appendChild(Je("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(Je("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new qe({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Je("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new qe({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",r=>{r.geolocateSource||this._watchState!=="ACTIVE_LOCK"||r.originalEvent&&r.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new s.Event("trackuserlocationend")))})}}_onDeviceOrientation(l){this._userLocationDotMarker&&(l.webkitCompassHeading?this._heading=l.webkitCompassHeading:l.absolute===!0&&(this._heading=-1*l.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return s.warnOnce("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 s.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new s.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new s.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let l;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(l={maximumAge:6e5,timeout:0},this._noTimeout=!0):(l=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,l),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const l=()=>{s.window.addEventListener("ondeviceorientationabsolute"in s.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};s.window.DeviceMotionEvent!==void 0&&typeof s.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(r=>{r==="granted"&&l()}).catch(console.error):l()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),s.window.removeEventListener("deviceorientation",this._onDeviceOrientation),s.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Xe,ScaleControl:class{constructor(l){this.options=s.extend({},Nl,l),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch{return!1}}(),s.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const l=this.options.maxWidth||100,r=this._map,o=r._containerHeight/2,u=r._containerWidth/2-l/2,d=r.unproject([u,o]),f=r.unproject([u+l,o]),g=d.distanceTo(f);if(this.options.unit==="imperial"){const y=3.2808*g;y>5280?this._setScale(l,y/5280,"mile"):this._setScale(l,y,"foot")}else this.options.unit==="nautical"?this._setScale(l,g/1852,"nautical-mile"):g>=1e3?this._setScale(l,g/1e3,"kilometer"):this._setScale(l,g,"meter")}_setScale(l,r,o){this._map._requestDomTask(()=>{const u=function(f){const g=Math.pow(10,`${Math.floor(f)}`.length-1);let y=f/g;return y=y>=10?10:y>=5?5:y>=3?3:y>=2?2:y>=1?1:function(v){const S=Math.pow(10,Math.ceil(-Math.log(v)/Math.LN10));return Math.round(v*S)/S}(y),g*y}(r),d=u/r;this._container.innerHTML=this._isNumberFormatSupported&&o!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:o}).format(u):`${u}&nbsp;${jl[o]}`,this._container.style.width=l*d+"px"})}onAdd(l){return this._map=l,this._language=l.getLanguage(),this._container=Je("div","mapboxgl-ctrl mapboxgl-ctrl-scale",l.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(l){this._language=l,this._update()}setUnit(l){this.options.unit=l,this._update()}},FullscreenControl:class{constructor(l){this._fullscreen=!1,l&&l.container&&(l.container instanceof s.window.HTMLElement?this._container=l.container:s.warnOnce("Full screen control 'container' must be a DOM element.")),s.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in s.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in s.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(l){return this._map=l,this._container||(this._container=this._map.getContainer()),this._controlContainer=Je("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",s.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,s.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!s.window.document.fullscreenEnabled&&!s.window.document.webkitFullscreenEnabled)}_setupUI(){const l=this._fullscreenButton=Je("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Je("span","mapboxgl-ctrl-icon",l).setAttribute("aria-hidden","true"),l.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),s.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const l=this._getTitle();this._fullscreenButton.setAttribute("aria-label",l),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",l)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(s.window.document.fullscreenElement||s.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?s.window.document.exitFullscreen?s.window.document.exitFullscreen():s.window.document.webkitCancelFullScreen&&s.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends s.Evented{constructor(l){super(),this.options=s.extend(Object.create(Ol),l),s.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(l&&l.className?l.className.trim().split(/\s+/):[])}addTo(l){return this._map&&this.remove(),this._map=l,this.options.closeOnClick&&l.on("preclick",this._onClose),this.options.closeOnMove&&l.on("move",this._onClose),l.on("remove",this.remove),this._update(),l._addPopup(this),this._focusFirstElement(),this._trackPointer?(l.on("mousemove",this._onMouseEvent),l.on("mouseup",this._onMouseEvent),l._canvasContainer.classList.add("mapboxgl-track-pointer")):l.on("move",this._update),this.fire(new s.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const l=this._map;return l&&(l.off("move",this._update),l.off("move",this._onClose),l.off("preclick",this._onClose),l.off("click",this._onClose),l.off("remove",this.remove),l.off("mousemove",this._onMouseEvent),l.off("mouseup",this._onMouseEvent),l.off("drag",this._onMouseEvent),l._canvasContainer&&l._canvasContainer.classList.remove("mapboxgl-track-pointer"),l._removePopup(this),this._map=void 0),this.fire(new s.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(l){this._lngLat=s.LngLat.convert(l),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const l=this._map;return l&&(l.off("move",this._update),l.on("mousemove",this._onMouseEvent),l.on("drag",this._onMouseEvent),l._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(l){return this.setDOMContent(s.window.document.createTextNode(l))}setHTML(l){const r=s.window.document.createDocumentFragment(),o=s.window.document.createElement("body");let u;for(o.innerHTML=l;u=o.firstChild,u;)r.appendChild(u);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(l){return this.options.maxWidth=l,this._update(),this}setDOMContent(l){let r=this._content;if(r)for(;r.hasChildNodes();)r.firstChild&&r.removeChild(r.firstChild);else r=this._content=Je("div","mapboxgl-popup-content",this._container||void 0);if(r.appendChild(l),this.options.closeButton){const o=this._closeButton=Je("button","mapboxgl-popup-close-button",r);o.type="button",o.setAttribute("aria-label","Close popup"),o.setAttribute("aria-hidden","true"),o.innerHTML="&#215;",o.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(l){return this._classList.add(l),this._updateClassList(),this}removeClassName(l){return this._classList.delete(l),this._updateClassList(),this}setOffset(l){return this.options.offset=l,this._update(),this}toggleClassName(l){let r;return this._classList.delete(l)?r=!1:(this._classList.add(l),r=!0),this._updateClassList(),r}_onMouseEvent(l){this._update(l.point)}_getAnchor(l){if(this.options.anchor)return this.options.anchor;const r=this._map,o=this._container,u=this._pos;if(!r||!o||!u)return"bottom";const d=o.offsetWidth,f=o.offsetHeight,g=u.x<d/2,y=u.x>r.transform.width-d/2;if(u.y+l<f)return g?"top-left":y?"top-right":"top";if(u.y>r.transform.height-f){if(g)return"bottom-left";if(y)return"bottom-right"}return g?"left":y?"right":"bottom"}_updateClassList(){const l=this._container;if(!l)return;const r=[...this._classList];r.push("mapboxgl-popup"),this._anchor&&r.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&r.push("mapboxgl-popup-track-pointer"),l.className=r.join(" ")}_update(l){const r=this._map,o=this._content;if(!r||!this._lngLat&&!this._trackPointer||!o)return;let u=this._container;if(u||(u=this._container=Je("div","mapboxgl-popup",r.getContainer()),this._tip=Je("div","mapboxgl-popup-tip",u),u.appendChild(o)),this.options.maxWidth&&u.style.maxWidth!==this.options.maxWidth&&(u.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=So(this._lngLat,this._pos,r.transform)),!this._trackPointer||l){const d=this._pos=this._trackPointer&&l?l:r.project(this._lngLat),f=uu(this.options.offset),g=this._anchor=this._getAnchor(f.y),y=uu(this.options.offset,g),v=d.add(y).round();r._requestDomTask(()=>{this._container&&g&&(this._container.style.transform=`${Vn[g]} translate(${v.x}px,${v.y}px)`)})}if(!this._marker&&r._showingGlobe()){const d=s.isLngLatBehindGlobe(r.transform,this._lngLat)?0:1;this._setOpacity(d)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const l=this._container.querySelector(Ah);l&&l.focus()}_onClose(){this.remove()}_setOpacity(l){this._container&&(this._container.style.opacity=`${l}`),this._content&&(this._content.style.pointerEvents=l?"auto":"none")}},Marker:qe,Style:kr,LngLat:s.LngLat,LngLatBounds:s.LngLatBounds,Point:s.Point,MercatorCoordinate:s.MercatorCoordinate,FreeCameraOptions:Hc,Evented:s.Evented,config:s.config,prewarm:function(){ao().acquire(Cr)},clearPrewarmedResources:function(){const l=Xi;l&&(l.isPreloaded()&&l.numActive()===1?(l.release(Cr),Xi=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()"))},get accessToken(){return s.config.ACCESS_TOKEN},set accessToken(l){s.config.ACCESS_TOKEN=l},get baseApiUrl(){return s.config.API_URL},set baseApiUrl(l){s.config.API_URL=l},get workerCount(){return Di.workerCount},set workerCount(l){Di.workerCount=l},get maxParallelImageRequests(){return s.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(l){s.config.MAX_PARALLEL_IMAGE_REQUESTS=l},clearStorage(l){s.clearTileCache(l)},workerUrl:"",workerClass:null,setNow:s.exported.setNow,restoreNow:s.exported.restoreNow};return Ao});var Pe=_e;return Pe})})(Hm);var Cx=Hm.exports;const Mn=Xm(Cx);var br=63710088e-1,Px={centimeters:br*100,centimetres:br*100,degrees:br/111325,feet:br*3.28084,inches:br*39.37,kilometers:br/1e3,kilometres:br/1e3,meters:br,metres:br,miles:br/1609.344,millimeters:br*1e3,millimetres:br*1e3,nauticalmiles:br/1852,radians:1,yards:br*1.0936};function zx(w,I){I===void 0&&(I="kilometers");var R=Px[I];if(!R)throw new Error(I+" units is invalid");return w*R}function Ju(w){var I=w%360;return I*Math.PI/180}function Bm(w){if(!w)throw new Error("coord is required");if(!Array.isArray(w)){if(w.type==="Feature"&&w.geometry!==null&&w.geometry.type==="Point")return w.geometry.coordinates;if(w.type==="Point")return w.coordinates}if(Array.isArray(w)&&w.length>=2&&!Array.isArray(w[0])&&!Array.isArray(w[1]))return w;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function kx(w,I,R){R===void 0&&(R={});var Z=Bm(w),re=Bm(I),_e=Ju(re[1]-Z[1]),we=Ju(re[0]-Z[0]),Pe=Ju(Z[1]),s=Ju(re[1]),le=Math.pow(Math.sin(_e/2),2)+Math.pow(Math.sin(we/2),2)*Math.cos(Pe)*Math.cos(s);return zx(2*Math.atan2(Math.sqrt(le),Math.sqrt(1-le)),R.units)}var qa=Dx,Lx=Object.prototype.hasOwnProperty;function Dx(){for(var w={},I=0;I<arguments.length;I++){var R=arguments[I];for(var Z in R)Lx.call(R,Z)&&(w[Z]=R[Z])}return w}var Jm={exports:{}};(function(w,I){(function(){var R={};w.exports=R,R.simpleFilter=function(Z,re){return re.filter(function(_e){return R.test(Z,_e)})},R.test=function(Z,re){return R.match(Z,re)!==null},R.match=function(Z,re,_e){_e=_e||{};var we=0,Pe=[],s=re.length,le=0,Qe=0,et=_e.pre||"",$e=_e.post||"",Je=_e.caseSensitive&&re||re.toLowerCase(),Ye;Z=_e.caseSensitive&&Z||Z.toLowerCase();for(var _t=0;_t<s;_t++)Ye=re[_t],Je[_t]===Z[we]?(Ye=et+Ye+$e,we+=1,Qe+=1+Qe):Qe=0,le+=Qe,Pe[Pe.length]=Ye;return we===Z.length?(le=Je===Z?1/0:le,{rendered:Pe.join(""),score:le}):null},R.filter=function(Z,re,_e){return!re||re.length===0?[]:typeof Z!="string"?re:(_e=_e||{},re.reduce(function(we,Pe,s,le){var Qe=Pe;_e.extract&&(Qe=_e.extract(Pe));var et=R.match(Z,Qe,_e);return et!=null&&(we[we.length]={string:et.rendered,score:et.score,index:s,original:Pe}),we},[]).sort(function(we,Pe){var s=Pe.score-we.score;return s||we.index-Pe.index}))}})()})(Jm);var Rx=Jm.exports,wr=function(w){return this.component=w,this.items=[],this.active=0,this.wrapper=document.createElement("div"),this.wrapper.className="suggestions-wrapper",this.element=document.createElement("ul"),this.element.className="suggestions",this.wrapper.appendChild(this.element),this.selectingListItem=!1,w.el.parentNode.insertBefore(this.wrapper,w.el.nextSibling),this};wr.prototype.show=function(){this.element.style.display="block"};wr.prototype.hide=function(){this.element.style.display="none"};wr.prototype.add=function(w){this.items.push(w)};wr.prototype.clear=function(){this.items=[],this.active=0};wr.prototype.isEmpty=function(){return!this.items.length};wr.prototype.isVisible=function(){return this.element.style.display==="block"};wr.prototype.draw=function(){if(this.element.innerHTML="",this.items.length===0){this.hide();return}for(var w=0;w<this.items.length;w++)this.drawItem(this.items[w],this.active===w);this.show()};wr.prototype.drawItem=function(w,I){var R=document.createElement("li"),Z=document.createElement("a");I&&(R.className+=" active"),Z.innerHTML=w.string,R.appendChild(Z),this.element.appendChild(R),R.addEventListener("mousedown",(function(){this.selectingListItem=!0}).bind(this)),R.addEventListener("mouseup",(function(){this.handleMouseUp.call(this,w)}).bind(this))};wr.prototype.handleMouseUp=function(w){this.selectingListItem=!1,this.component.value(w.original),this.clear(),this.draw()};wr.prototype.move=function(w){this.active=w,this.draw()};wr.prototype.previous=function(){this.move(this.active===0?this.items.length-1:this.active-1)};wr.prototype.next=function(){this.move(this.active===this.items.length-1?0:this.active+1)};wr.prototype.drawError=function(w){var I=document.createElement("li");I.innerHTML=w,this.element.appendChild(I),this.show()};var Bx=wr,Ox=qa,Fx=Rx,Ux=Bx,nr=function(w,I,R){return R=R||{},this.options=Ox({minLength:2,limit:5,filter:!0,hideOnBlur:!0},R),this.el=w,this.data=I||[],this.list=new Ux(this),this.query="",this.selected=null,this.list.draw(),this.el.addEventListener("keyup",(function(Z){this.handleKeyUp(Z.keyCode)}).bind(this),!1),this.el.addEventListener("keydown",(function(Z){this.handleKeyDown(Z)}).bind(this)),this.el.addEventListener("focus",(function(){this.handleFocus()}).bind(this)),this.el.addEventListener("blur",(function(){this.handleBlur()}).bind(this)),this.el.addEventListener("paste",(function(Z){this.handlePaste(Z)}).bind(this)),this.render=this.options.render?this.options.render.bind(this):this.render.bind(this),this.getItemValue=this.options.getItemValue?this.options.getItemValue.bind(this):this.getItemValue.bind(this),this};nr.prototype.handleKeyUp=function(w){w===40||w===38||w===27||w===13||w===9||this.handleInputChange(this.el.value)};nr.prototype.handleKeyDown=function(w){switch(w.keyCode){case 13:case 9:this.list.isEmpty()||(this.list.isVisible()&&w.preventDefault(),this.value(this.list.items[this.list.active].original),this.list.hide());break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next();break}};nr.prototype.handleBlur=function(){!this.list.selectingListItem&&this.options.hideOnBlur&&this.list.hide()};nr.prototype.handlePaste=function(w){if(w.clipboardData)this.handleInputChange(w.clipboardData.getData("Text"));else{var I=this;setTimeout(function(){I.handleInputChange(w.target.value)},100)}};nr.prototype.handleInputChange=function(w){if(this.query=this.normalize(w),this.list.clear(),this.query.length<this.options.minLength){this.list.draw();return}this.getCandidates((function(I){for(var R=0;R<I.length&&(this.list.add(I[R]),R!==this.options.limit-1);R++);this.list.draw()}).bind(this))};nr.prototype.handleFocus=function(){this.list.isEmpty()||this.list.show(),this.list.selectingListItem=!1};nr.prototype.update=function(w){this.data=w,this.handleKeyUp()};nr.prototype.clear=function(){this.data=[],this.list.clear()};nr.prototype.normalize=function(w){return w=w.toLowerCase(),w};nr.prototype.match=function(w,I){return w.indexOf(I)>-1};nr.prototype.value=function(w){if(this.selected=w,this.el.value=this.getItemValue(w),document.createEvent){var I=document.createEvent("HTMLEvents");I.initEvent("change",!0,!1),this.el.dispatchEvent(I)}else this.el.fireEvent("onchange")};nr.prototype.getCandidates=function(w){var I={pre:"<strong>",post:"</strong>",extract:(function(Z){return this.getItemValue(Z)}).bind(this)},R;this.options.filter?(R=Fx.filter(this.query,this.data,I),R=R.map((function(Z){return{original:Z.original,string:this.render(Z.original,Z.string)}}).bind(this))):R=this.data.map((function(Z){var re=this.render(Z);return{original:Z,string:re}}).bind(this)),w(R)};nr.prototype.getItemValue=function(w){return w};nr.prototype.render=function(w,I){if(I)return I;for(var R=w.original?this.getItemValue(w.original):this.getItemValue(w),Z=this.normalize(R),re=Z.lastIndexOf(this.query);re>-1;){var _e=re+this.query.length;R=R.slice(0,re)+"<strong>"+R.slice(re,_e)+"</strong>"+R.slice(_e),re=Z.slice(0,re).lastIndexOf(this.query)}return R};nr.prototype.renderError=function(w){this.list.drawError(w)};var Nx=nr,Ym=Nx,jx=Ym;typeof window<"u"&&(window.Suggestions=Ym);var Vx="Expected a function",Om=NaN,Gx="[object Symbol]",$x=/^\s+|\s+$/g,qx=/^[-+]0x[0-9a-f]+$/i,Zx=/^0b[01]+$/i,Wx=/^0o[0-7]+$/i,Xx=parseInt,Hx=typeof Yn=="object"&&Yn&&Yn.Object===Object&&Yn,Kx=typeof self=="object"&&self&&self.Object===Object&&self,Jx=Hx||Kx||Function("return this")(),Yx=Object.prototype,Qx=Yx.toString,ev=Math.max,tv=Math.min,jd=function(){return Jx.Date.now()};function iv(w,I,R){var Z,re,_e,we,Pe,s,le=0,Qe=!1,et=!1,$e=!0;if(typeof w!="function")throw new TypeError(Vx);I=Fm(I)||0,Wd(R)&&(Qe=!!R.leading,et="maxWait"in R,_e=et?ev(Fm(R.maxWait)||0,I):_e,$e="trailing"in R?!!R.trailing:$e);function Je(Lt){var ti=Z,_i=re;return Z=re=void 0,le=Lt,we=w.apply(_i,ti),we}function Ye(Lt){return le=Lt,Pe=setTimeout(St,I),Qe?Je(Lt):we}function _t(Lt){var ti=Lt-s,_i=Lt-le,ai=I-ti;return et?tv(ai,_e-_i):ai}function ot(Lt){var ti=Lt-s,_i=Lt-le;return s===void 0||ti>=I||ti<0||et&&_i>=_e}function St(){var Lt=jd();if(ot(Lt))return ei(Lt);Pe=setTimeout(St,_t(Lt))}function ei(Lt){return Pe=void 0,$e&&Z?Je(Lt):(Z=re=void 0,we)}function Ct(){Pe!==void 0&&clearTimeout(Pe),le=0,Z=s=re=Pe=void 0}function pi(){return Pe===void 0?we:ei(jd())}function Nt(){var Lt=jd(),ti=ot(Lt);if(Z=arguments,re=this,s=Lt,ti){if(Pe===void 0)return Ye(s);if(et)return Pe=setTimeout(St,I),Je(s)}return Pe===void 0&&(Pe=setTimeout(St,I)),we}return Nt.cancel=Ct,Nt.flush=pi,Nt}function Wd(w){var I=typeof w;return!!w&&(I=="object"||I=="function")}function rv(w){return!!w&&typeof w=="object"}function nv(w){return typeof w=="symbol"||rv(w)&&Qx.call(w)==Gx}function Fm(w){if(typeof w=="number")return w;if(nv(w))return Om;if(Wd(w)){var I=typeof w.valueOf=="function"?w.valueOf():w;w=Wd(I)?I+"":I}if(typeof w!="string")return w===0?w:+w;w=w.replace($x,"");var R=Zx.test(w);return R||Wx.test(w)?Xx(w.slice(2),R?2:8):qx.test(w)?Om:+w}var ov=iv,Xd={exports:{}},Va=typeof Reflect=="object"?Reflect:null,Um=Va&&typeof Va.apply=="function"?Va.apply:function(I,R,Z){return Function.prototype.apply.call(I,R,Z)},Qu;Va&&typeof Va.ownKeys=="function"?Qu=Va.ownKeys:Object.getOwnPropertySymbols?Qu=function(I){return Object.getOwnPropertyNames(I).concat(Object.getOwnPropertySymbols(I))}:Qu=function(I){return Object.getOwnPropertyNames(I)};function sv(w){console&&console.warn&&console.warn(w)}var Qm=Number.isNaN||function(I){return I!==I};function si(){si.init.call(this)}Xd.exports=si;Xd.exports.once=uv;si.EventEmitter=si;si.prototype._events=void 0;si.prototype._eventsCount=0;si.prototype._maxListeners=void 0;var Nm=10;function nh(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(si,"defaultMaxListeners",{enumerable:!0,get:function(){return Nm},set:function(w){if(typeof w!="number"||w<0||Qm(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");Nm=w}});si.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};si.prototype.setMaxListeners=function(I){if(typeof I!="number"||I<0||Qm(I))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+I+".");return this._maxListeners=I,this};function e_(w){return w._maxListeners===void 0?si.defaultMaxListeners:w._maxListeners}si.prototype.getMaxListeners=function(){return e_(this)};si.prototype.emit=function(I){for(var R=[],Z=1;Z<arguments.length;Z++)R.push(arguments[Z]);var re=I==="error",_e=this._events;if(_e!==void 0)re=re&&_e.error===void 0;else if(!re)return!1;if(re){var we;if(R.length>0&&(we=R[0]),we instanceof Error)throw we;var Pe=new Error("Unhandled error."+(we?" ("+we.message+")":""));throw Pe.context=we,Pe}var s=_e[I];if(s===void 0)return!1;if(typeof s=="function")Um(s,this,R);else for(var le=s.length,Qe=o_(s,le),Z=0;Z<le;++Z)Um(Qe[Z],this,R);return!0};function t_(w,I,R,Z){var re,_e,we;if(nh(R),_e=w._events,_e===void 0?(_e=w._events=Object.create(null),w._eventsCount=0):(_e.newListener!==void 0&&(w.emit("newListener",I,R.listener?R.listener:R),_e=w._events),we=_e[I]),we===void 0)we=_e[I]=R,++w._eventsCount;else if(typeof we=="function"?we=_e[I]=Z?[R,we]:[we,R]:Z?we.unshift(R):we.push(R),re=e_(w),re>0&&we.length>re&&!we.warned){we.warned=!0;var Pe=new Error("Possible EventEmitter memory leak detected. "+we.length+" "+String(I)+" listeners added. Use emitter.setMaxListeners() to increase limit");Pe.name="MaxListenersExceededWarning",Pe.emitter=w,Pe.type=I,Pe.count=we.length,sv(Pe)}return w}si.prototype.addListener=function(I,R){return t_(this,I,R,!1)};si.prototype.on=si.prototype.addListener;si.prototype.prependListener=function(I,R){return t_(this,I,R,!0)};function av(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function i_(w,I,R){var Z={fired:!1,wrapFn:void 0,target:w,type:I,listener:R},re=av.bind(Z);return re.listener=R,Z.wrapFn=re,re}si.prototype.once=function(I,R){return nh(R),this.on(I,i_(this,I,R)),this};si.prototype.prependOnceListener=function(I,R){return nh(R),this.prependListener(I,i_(this,I,R)),this};si.prototype.removeListener=function(I,R){var Z,re,_e,we,Pe;if(nh(R),re=this._events,re===void 0)return this;if(Z=re[I],Z===void 0)return this;if(Z===R||Z.listener===R)--this._eventsCount===0?this._events=Object.create(null):(delete re[I],re.removeListener&&this.emit("removeListener",I,Z.listener||R));else if(typeof Z!="function"){for(_e=-1,we=Z.length-1;we>=0;we--)if(Z[we]===R||Z[we].listener===R){Pe=Z[we].listener,_e=we;break}if(_e<0)return this;_e===0?Z.shift():lv(Z,_e),Z.length===1&&(re[I]=Z[0]),re.removeListener!==void 0&&this.emit("removeListener",I,Pe||R)}return this};si.prototype.off=si.prototype.removeListener;si.prototype.removeAllListeners=function(I){var R,Z,re;if(Z=this._events,Z===void 0)return this;if(Z.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):Z[I]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete Z[I]),this;if(arguments.length===0){var _e=Object.keys(Z),we;for(re=0;re<_e.length;++re)we=_e[re],we!=="removeListener"&&this.removeAllListeners(we);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(R=Z[I],typeof R=="function")this.removeListener(I,R);else if(R!==void 0)for(re=R.length-1;re>=0;re--)this.removeListener(I,R[re]);return this};function r_(w,I,R){var Z=w._events;if(Z===void 0)return[];var re=Z[I];return re===void 0?[]:typeof re=="function"?R?[re.listener||re]:[re]:R?cv(re):o_(re,re.length)}si.prototype.listeners=function(I){return r_(this,I,!0)};si.prototype.rawListeners=function(I){return r_(this,I,!1)};si.listenerCount=function(w,I){return typeof w.listenerCount=="function"?w.listenerCount(I):n_.call(w,I)};si.prototype.listenerCount=n_;function n_(w){var I=this._events;if(I!==void 0){var R=I[w];if(typeof R=="function")return 1;if(R!==void 0)return R.length}return 0}si.prototype.eventNames=function(){return this._eventsCount>0?Qu(this._events):[]};function o_(w,I){for(var R=new Array(I),Z=0;Z<I;++Z)R[Z]=w[Z];return R}function lv(w,I){for(;I+1<w.length;I++)w[I]=w[I+1];w.pop()}function cv(w){for(var I=new Array(w.length),R=0;R<I.length;++R)I[R]=w[R].listener||w[R];return I}function uv(w,I){return new Promise(function(R,Z){function re(we){w.removeListener(I,_e),Z(we)}function _e(){typeof w.removeListener=="function"&&w.removeListener("error",re),R([].slice.call(arguments))}s_(w,I,_e,{once:!0}),I!=="error"&&hv(w,re,{once:!0})})}function hv(w,I,R){typeof w.on=="function"&&s_(w,"error",I,R)}function s_(w,I,R,Z){if(typeof w.on=="function")Z.once?w.once(I,R):w.on(I,R);else if(typeof w.addEventListener=="function")w.addEventListener(I,function re(_e){Z.once&&w.removeEventListener(I,re),R(_e)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}var dv=Xd.exports,pv={fr:{name:"France",bbox:[[-4.59235,41.380007],[9.560016,51.148506]]},us:{name:"United States",bbox:[[-171.791111,18.91619],[-66.96466,71.357764]]},ru:{name:"Russia",bbox:[[19.66064,41.151416],[190.10042,81.2504]]},ca:{name:"Canada",bbox:[[-140.99778,41.675105],[-52.648099,83.23324]]}};function fv(w){var I=w.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return I?{key:I[1],value:I[2]}:null}function mv(w){var I=w.match(/<?([^>]*)>(.*)/);if(!I)return null;var R=I[1],Z=I[2].split(";"),re=null,_e=Z.reduce(function(we,Pe){var s=fv(Pe);return s?s.key==="rel"?(re||(re=s.value),we):(we[s.key]=s.value,we):we},{});return re?{url:R,rel:re,params:_e}:null}function _v(w){return w?w.split(/,\s*</).reduce(function(I,R){var Z=mv(R);if(!Z)return I;var re=Z.rel.split(/\s+/);return re.forEach(function(_e){I[_e]||(I[_e]={url:Z.url,params:Z.params})}),I},{}):{}}var gv=_v,yv=gv;function Hd(w,I){this.request=w,this.headers=I.headers,this.rawBody=I.body,this.statusCode=I.statusCode;try{this.body=JSON.parse(I.body||"{}")}catch{this.body=I.body}this.links=yv(this.headers.link)}Hd.prototype.hasNextPage=function(){return!!this.links.next};Hd.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null};var xv=Hd,oh={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"},jm=oh;function vv(w){var I=w.type||jm.ERROR_HTTP,R;if(w.body)try{R=JSON.parse(w.body)}catch{R=w.body}else R=null;var Z=w.message||null;Z||(typeof R=="string"?Z=R:R&&typeof R.message=="string"?Z=R.message:I===jm.ERROR_REQUEST_ABORTED&&(Z="Request aborted")),this.message=Z,this.type=I,this.statusCode=w.statusCode||null,this.request=w.request,this.body=R}var bv=vv;function wv(w){var I=w.indexOf(":"),R=w.substring(0,I).trim().toLowerCase(),Z=w.substring(I+1).trim();return{name:R,value:Z}}function Tv(w){var I={};return w&&w.trim().split(/[\r|\n]+/).forEach(function(R){var Z=wv(R);I[Z.name]=Z.value}),I}var Ev=Tv,Sv=xv,Vm=bv,Vd=oh,Av=Ev,th={};function Mv(w){var I=th[w.id];I&&(I.abort(),delete th[w.id])}function Iv(w,I){return new Sv(w,{body:I.response,headers:Av(I.getAllResponseHeaders()),statusCode:I.status})}function Gm(w){var I=w.total,R=w.loaded,Z=100*R/I;return{total:I,transferred:R,percent:Z}}function a_(w,I){return new Promise(function(R,Z){I.onprogress=function(we){w.emitter.emit(Vd.EVENT_PROGRESS_DOWNLOAD,Gm(we))};var re=w.file;re&&(I.upload.onprogress=function(we){w.emitter.emit(Vd.EVENT_PROGRESS_UPLOAD,Gm(we))}),I.onerror=function(we){Z(we)},I.onabort=function(){var we=new Vm({request:w,type:Vd.ERROR_REQUEST_ABORTED});Z(we)},I.onload=function(){if(delete th[w.id],I.status<200||I.status>=400){var we=new Vm({request:w,body:I.response,statusCode:I.status});Z(we);return}R(I)};var _e=w.body;typeof _e=="string"?I.send(_e):_e?I.send(JSON.stringify(_e)):re?I.send(re):I.send(),th[w.id]=I}).then(function(R){return Iv(w,R)})}function l_(w,I){var R=w.url(I),Z=new window.XMLHttpRequest;return Z.open(w.method,R),Object.keys(w.headers).forEach(function(re){Z.setRequestHeader(re,w.headers[re])}),Z}function Cv(w){return Promise.resolve().then(function(){var I=l_(w,w.client.accessToken);return a_(w,I)})}var Pv={browserAbort:Mv,sendRequestXhr:a_,browserSend:Cv,createRequestXhr:l_},ih={exports:{}};/*! http://mths.be/base64 v0.1.0 by @mathias | MIT license */ih.exports;(function(w,I){(function(R){var Z=I,re=w&&w.exports==Z&&w,_e=typeof Yn=="object"&&Yn;(_e.global===_e||_e.window===_e)&&(R=_e);var we=function(Ye){this.message=Ye};we.prototype=new Error,we.prototype.name="InvalidCharacterError";var Pe=function(Ye){throw new we(Ye)},s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",le=/[\t\n\f\r ]/g,Qe=function(Ye){Ye=String(Ye).replace(le,"");var _t=Ye.length;_t%4==0&&(Ye=Ye.replace(/==?$/,""),_t=Ye.length),(_t%4==1||/[^+a-zA-Z0-9/]/.test(Ye))&&Pe("Invalid character: the string to be decoded is not correctly encoded.");for(var ot=0,St,ei,Ct="",pi=-1;++pi<_t;)ei=s.indexOf(Ye.charAt(pi)),St=ot%4?St*64+ei:ei,ot++%4&&(Ct+=String.fromCharCode(255&St>>(-2*ot&6)));return Ct},et=function(Ye){Ye=String(Ye),/[^\0-\xFF]/.test(Ye)&&Pe("The string to be encoded contains characters outside of the Latin1 range.");for(var _t=Ye.length%3,ot="",St=-1,ei,Ct,pi,Nt,Lt=Ye.length-_t;++St<Lt;)ei=Ye.charCodeAt(St)<<16,Ct=Ye.charCodeAt(++St)<<8,pi=Ye.charCodeAt(++St),Nt=ei+Ct+pi,ot+=s.charAt(Nt>>18&63)+s.charAt(Nt>>12&63)+s.charAt(Nt>>6&63)+s.charAt(Nt&63);return _t==2?(ei=Ye.charCodeAt(St)<<8,Ct=Ye.charCodeAt(++St),Nt=ei+Ct,ot+=s.charAt(Nt>>10)+s.charAt(Nt>>4&63)+s.charAt(Nt<<2&63)+"="):_t==1&&(Nt=Ye.charCodeAt(St),ot+=s.charAt(Nt>>2)+s.charAt(Nt<<4&63)+"=="),ot},$e={encode:et,decode:Qe,version:"0.1.0"};if(Z&&!Z.nodeType)if(re)re.exports=$e;else for(var Je in $e)$e.hasOwnProperty(Je)&&(Z[Je]=$e[Je]);else R.base64=$e})(Yn)})(ih,ih.exports);var zv=ih.exports,kv=zv,Gd={};function Lv(w){if(Gd[w])return Gd[w];var I=w.split("."),R=I[0],Z=I[1];if(!Z)throw new Error("Invalid token");var re=Dv(Z),_e={usage:R,user:re.u};return Bs(re,"a")&&(_e.authorization=re.a),Bs(re,"exp")&&(_e.expires=re.exp*1e3),Bs(re,"iat")&&(_e.created=re.iat*1e3),Bs(re,"scopes")&&(_e.scopes=re.scopes),Bs(re,"client")&&(_e.client=re.client),Bs(re,"ll")&&(_e.lastLogin=re.ll),Bs(re,"iu")&&(_e.impersonator=re.iu),Gd[w]=_e,_e}function Dv(w){try{return JSON.parse(kv.decode(w))}catch{throw new Error("Invalid token")}}function Bs(w,I){return Object.prototype.hasOwnProperty.call(w,I)}var c_=Lv,u_={exports:{}};(function(w){var I=Object.prototype.hasOwnProperty,R="~";function Z(){}Object.create&&(Z.prototype=Object.create(null),new Z().__proto__||(R=!1));function re(s,le,Qe){this.fn=s,this.context=le,this.once=Qe||!1}function _e(s,le,Qe,et,$e){if(typeof Qe!="function")throw new TypeError("The listener must be a function");var Je=new re(Qe,et||s,$e),Ye=R?R+le:le;return s._events[Ye]?s._events[Ye].fn?s._events[Ye]=[s._events[Ye],Je]:s._events[Ye].push(Je):(s._events[Ye]=Je,s._eventsCount++),s}function we(s,le){--s._eventsCount===0?s._events=new Z:delete s._events[le]}function Pe(){this._events=new Z,this._eventsCount=0}Pe.prototype.eventNames=function(){var le=[],Qe,et;if(this._eventsCount===0)return le;for(et in Qe=this._events)I.call(Qe,et)&&le.push(R?et.slice(1):et);return Object.getOwnPropertySymbols?le.concat(Object.getOwnPropertySymbols(Qe)):le},Pe.prototype.listeners=function(le){var Qe=R?R+le:le,et=this._events[Qe];if(!et)return[];if(et.fn)return[et.fn];for(var $e=0,Je=et.length,Ye=new Array(Je);$e<Je;$e++)Ye[$e]=et[$e].fn;return Ye},Pe.prototype.listenerCount=function(le){var Qe=R?R+le:le,et=this._events[Qe];return et?et.fn?1:et.length:0},Pe.prototype.emit=function(le,Qe,et,$e,Je,Ye){var _t=R?R+le:le;if(!this._events[_t])return!1;var ot=this._events[_t],St=arguments.length,ei,Ct;if(ot.fn){switch(ot.once&&this.removeListener(le,ot.fn,void 0,!0),St){case 1:return ot.fn.call(ot.context),!0;case 2:return ot.fn.call(ot.context,Qe),!0;case 3:return ot.fn.call(ot.context,Qe,et),!0;case 4:return ot.fn.call(ot.context,Qe,et,$e),!0;case 5:return ot.fn.call(ot.context,Qe,et,$e,Je),!0;case 6:return ot.fn.call(ot.context,Qe,et,$e,Je,Ye),!0}for(Ct=1,ei=new Array(St-1);Ct<St;Ct++)ei[Ct-1]=arguments[Ct];ot.fn.apply(ot.context,ei)}else{var pi=ot.length,Nt;for(Ct=0;Ct<pi;Ct++)switch(ot[Ct].once&&this.removeListener(le,ot[Ct].fn,void 0,!0),St){case 1:ot[Ct].fn.call(ot[Ct].context);break;case 2:ot[Ct].fn.call(ot[Ct].context,Qe);break;case 3:ot[Ct].fn.call(ot[Ct].context,Qe,et);break;case 4:ot[Ct].fn.call(ot[Ct].context,Qe,et,$e);break;default:if(!ei)for(Nt=1,ei=new Array(St-1);Nt<St;Nt++)ei[Nt-1]=arguments[Nt];ot[Ct].fn.apply(ot[Ct].context,ei)}}return!0},Pe.prototype.on=function(le,Qe,et){return _e(this,le,Qe,et,!1)},Pe.prototype.once=function(le,Qe,et){return _e(this,le,Qe,et,!0)},Pe.prototype.removeListener=function(le,Qe,et,$e){var Je=R?R+le:le;if(!this._events[Je])return this;if(!Qe)return we(this,Je),this;var Ye=this._events[Je];if(Ye.fn)Ye.fn===Qe&&(!$e||Ye.once)&&(!et||Ye.context===et)&&we(this,Je);else{for(var _t=0,ot=[],St=Ye.length;_t<St;_t++)(Ye[_t].fn!==Qe||$e&&!Ye[_t].once||et&&Ye[_t].context!==et)&&ot.push(Ye[_t]);ot.length?this._events[Je]=ot.length===1?ot[0]:ot:we(this,Je)}return this},Pe.prototype.removeAllListeners=function(le){var Qe;return le?(Qe=R?R+le:le,this._events[Qe]&&we(this,Qe)):(this._events=new Z,this._eventsCount=0),this},Pe.prototype.off=Pe.prototype.removeListener,Pe.prototype.addListener=Pe.prototype.on,Pe.prefixed=R,Pe.EventEmitter=Pe,w.exports=Pe})(u_);var Rv=u_.exports;function Bv(w){return w.map(encodeURIComponent).join(",")}function h_(w){return Array.isArray(w)?Bv(w):encodeURIComponent(String(w))}function d_(w,I,R){if(R===!1||R===null)return w;var Z=/\?/.test(w)?"&":"?",re=encodeURIComponent(I);return R!==void 0&&R!==""&&R!==!0&&(re+="="+h_(R)),""+w+Z+re}function Ov(w,I){if(!I)return w;var R=w;return Object.keys(I).forEach(function(Z){var re=I[Z];re!==void 0&&(Array.isArray(re)&&(re=re.filter(function(_e){return _e!=null}).join(",")),R=d_(R,Z,re))}),R}function Fv(w,I){if(!I||w.slice(0,4)==="http")return w;var R=w[0]==="/"?"":"/";return""+I.replace(/\/$/,"")+R+w}function Uv(w,I){return I?w.replace(/\/:([a-zA-Z0-9]+)/g,function(R,Z){var re=I[Z];if(re===void 0)throw new Error("Unspecified route parameter "+Z);var _e=h_(re);return"/"+_e}):w}var Nv={appendQueryObject:Ov,appendQueryParam:d_,prependOrigin:Fv,interpolateRouteParams:Uv},jv=c_,Kd=qa,Vv=Rv,Yu=Nv,$m=oh,Gv=1;function No(w,I){if(!w)throw new Error("MapiRequest requires a client");if(!I||!I.path||!I.method)throw new Error("MapiRequest requires an options object with path and method properties");var R={};I.body&&(R["content-type"]="application/json");var Z=Kd(R,I.headers),re=Object.keys(Z).reduce(function(_e,we){return _e[we.toLowerCase()]=Z[we],_e},{});this.id=Gv++,this._options=I,this.emitter=new Vv,this.client=w,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=I.path,this.method=I.method,this.origin=I.origin||w.origin,this.query=I.query||{},this.params=I.params||{},this.body=I.body||null,this.file=I.file||null,this.encoding=I.encoding||"utf8",this.sendFileAs=I.sendFileAs||null,this.headers=re}No.prototype.url=function(I){var R=Yu.prependOrigin(this.path,this.origin);R=Yu.appendQueryObject(R,this.query);var Z=this.params,re=I??this.client.accessToken;if(re){R=Yu.appendQueryParam(R,"access_token",re);var _e=jv(re).user;Z=Kd({ownerId:_e},Z)}return R=Yu.interpolateRouteParams(R,Z),R};No.prototype.send=function(){var I=this;if(I.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return I.sent=!0,I.client.sendRequest(I).then(function(R){return I.response=R,I.emitter.emit($m.EVENT_RESPONSE,R),R},function(R){throw I.error=R,I.emitter.emit($m.EVENT_ERROR,R),R})};No.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),!(this.response||this.error||this.aborted)&&(this.aborted=!0,this.client.abortRequest(this))};No.prototype.eachPage=function(I){var R=this;function Z(we){function Pe(){delete R._nextPageRequest;var s=we.nextPage();s&&(R._nextPageRequest=s,_e(s))}I(null,we,Pe)}function re(we){I(we,null,function(){})}function _e(we){we.send().then(Z,re)}_e(this)};No.prototype.clone=function(){return this._extend()};No.prototype._extend=function(I){var R=Kd(this._options,I);return new No(this.client,R)};var $v=No,qv=c_,Zv=$v,Wv=oh;function p_(w){if(!w||!w.accessToken)throw new Error("Cannot create a client without an access token");qv(w.accessToken),this.accessToken=w.accessToken,this.origin=w.origin||Wv.API_ORIGIN}p_.prototype.createRequest=function(I){return new Zv(this,I)};var f_=p_,m_=Pv,__=f_;function $a(w){__.call(this,w)}$a.prototype=Object.create(__.prototype);$a.prototype.constructor=$a;$a.prototype.sendRequest=m_.browserSend;$a.prototype.abortRequest=m_.browserAbort;function Xv(w){return new $a(w)}var g_=Xv,Hv=g_,Kv=Hv,Jv=Object.prototype.toString,Yv=function(w){var I;return Jv.call(w)==="[object Object]"&&(I=Object.getPrototypeOf(w),I===null||I===Object.getPrototypeOf({}))},Qv=Yv,e0=qa,y_="value",$d=`
  `,di={};di.assert=function(w,I){return I=I||{},function(R){var Z=jo(w,R);if(Z){var re=Jd(Z,I);throw I.apiName&&(re=I.apiName+": "+re),new Error(re)}}};di.shape=function(I){var R=n0(I);return function(re){var _e=jo(di.plainObject,re);if(_e)return _e;for(var we,Pe,s=[],le=0;le<R.length;le++)we=R[le].key,Pe=R[le].value,_e=jo(Pe,re[we]),_e&&s.push([we].concat(_e));return s.length<2?s[0]:function(Qe){s=s.map(function(Je){var Ye=Je[0],_t=Jd(Je,Qe).split(`
`).join($d);return"- "+Ye+": "+_t});var et=Qe.path.join("."),$e=et===y_?"":" of "+et;return"The following properties"+$e+" have invalid values:"+$d+s.join($d)}}};di.strictShape=function(I){var R=di.shape(I);return function(re){var _e=R(re);if(_e)return _e;var we=Object.keys(re).reduce(function(Pe,s){return I[s]===void 0&&Pe.push(s),Pe},[]);if(we.length!==0)return function(){return"The following keys are invalid: "+we.join(", ")}}};di.arrayOf=function(I){return x_(I)};di.tuple=function(){var I=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return x_(I)};function x_(w){var I=Array.isArray(w),R=function(Z){return I?w[Z]:w};return function(re){var _e=jo(di.plainArray,re);if(_e)return _e;if(I&&re.length!==w.length)return"an array with "+w.length+" items";for(var we=0;we<re.length;we++)if(_e=jo(R(we),re[we]),_e)return[we].concat(_e)}}di.required=function(I){function R(Z){return Z==null?function(re){return v_(re,b_(re.path)?"cannot be undefined/null.":"is required.")}:I.apply(this,arguments)}return R.__required=!0,R};di.oneOfType=function(){var I=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return function(Z){var re=I.map(function(_e){return jo(_e,Z)}).filter(Boolean);if(re.length===I.length)return re.every(function(_e){return _e.length===1&&typeof _e[0]=="string"})?t0(re.map(function(_e){return _e[0]})):re.reduce(function(_e,we){return we.length>_e.length?we:_e})}};di.equal=function(I){return function(Z){if(Z!==I)return JSON.stringify(I)}};di.oneOf=function(){var I=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments),R=I.map(function(Z){return di.equal(Z)});return di.oneOfType.apply(this,R)};di.range=function(I){var R=I[0],Z=I[1];return function(_e){var we=jo(di.number,_e);if(we||_e<R||_e>Z)return"number between "+R+" & "+Z+" (inclusive)"}};di.any=function(){};di.boolean=function(I){if(typeof I!="boolean")return"boolean"};di.number=function(I){if(typeof I!="number")return"number"};di.plainArray=function(I){if(!Array.isArray(I))return"array"};di.plainObject=function(I){if(!Qv(I))return"object"};di.string=function(I){if(typeof I!="string")return"string"};di.func=function(I){if(typeof I!="function")return"function"};function jo(w,I){if(!(I==null&&!w.hasOwnProperty("__required"))){var R=w(I);if(R)return Array.isArray(R)?R:[R]}}function Jd(w,I){var R=w.length,Z=w[R-1],re=w.slice(0,R-1);return re.length===0&&(re=[y_]),I=e0(I,{path:re}),typeof Z=="function"?Z(I):v_(I,i0(Z))}function t0(w){return w.length<2?w[0]:w.length===2?w.join(" or "):w.slice(0,-1).join(", ")+", or "+w.slice(-1)}function i0(w){return"must be "+r0(w)+"."}function r0(w){return/^an? /.test(w)?w:/^[aeiou]/i.test(w)?"an "+w:/^[a-z]/i.test(w)?"a "+w:w}function v_(w,I){var R=b_(w.path),Z=w.path.join(".")+" "+I,re=R?"Item at position ":"";return re+Z}function b_(w){return typeof w[w.length-1]=="number"||typeof w[0]=="number"}function n0(w){return Object.keys(w||{}).map(function(I){return{key:I,value:w[I]}})}di.validate=jo;di.processMessage=Jd;var o0=di,s0=qa,Ga=o0;function a0(w){if(typeof window<"u")return w instanceof globalThis.Blob||w instanceof globalThis.ArrayBuffer?void 0:"Blob or ArrayBuffer";if(!(typeof w=="string"||w.pipe!==void 0))return"Filename or Readable stream"}function l0(w,I){return Ga.assert(Ga.strictShape(w),I)}function c0(w){var I="date";if(typeof w=="boolean")return I;try{var R=new Date(w);if(R.getTime&&isNaN(R.getTime()))return I}catch{return I}}function u0(w){return Ga.tuple(Ga.number,Ga.number)(w)}var h0=s0(Ga,{file:a0,date:c0,coordinates:u0,assertShape:l0});function d0(w,I){var R=function(Z,re){return I.indexOf(Z)!==-1&&re!==void 0};return typeof I=="function"&&(R=I),Object.keys(w).filter(function(Z){return R(Z,w[Z])}).reduce(function(Z,re){return Z[re]=w[re],Z},{})}var p0=d0;function f0(w,I){return Object.keys(w).reduce(function(R,Z){return R[Z]=I(Z,w[Z]),R},{})}var m0=f0,_0=m0;function g0(w){return _0(w,function(I,R){return typeof R=="boolean"?JSON.stringify(R):R})}var y0=g0,x0=f_,v0=g_;function b0(w){return function(I){var R;x0.prototype.isPrototypeOf(I)?R=I:R=v0(I);var Z=Object.create(w);return Z.client=R,Z}}var w0=b0,w_=qa,Ut=h0,rh=p0,T_=y0,T0=w0,Yd={},E_=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];Yd.forwardGeocode=function(w){Ut.assertShape({query:Ut.required(Ut.string),mode:Ut.oneOf("mapbox.places","mapbox.places-permanent"),countries:Ut.arrayOf(Ut.string),proximity:Ut.oneOf(Ut.coordinates,"ip"),types:Ut.arrayOf(Ut.oneOf(E_)),autocomplete:Ut.boolean,bbox:Ut.arrayOf(Ut.number),limit:Ut.number,language:Ut.arrayOf(Ut.string),routing:Ut.boolean,fuzzyMatch:Ut.boolean,worldview:Ut.string})(w),w.mode=w.mode||"mapbox.places";var I=T_(w_({country:w.countries},rh(w,["proximity","types","autocomplete","bbox","limit","language","routing","fuzzyMatch","worldview"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:rh(w,["mode","query"]),query:I})};Yd.reverseGeocode=function(w){Ut.assertShape({query:Ut.required(Ut.coordinates),mode:Ut.oneOf("mapbox.places","mapbox.places-permanent"),countries:Ut.arrayOf(Ut.string),types:Ut.arrayOf(Ut.oneOf(E_)),bbox:Ut.arrayOf(Ut.number),limit:Ut.number,language:Ut.arrayOf(Ut.string),reverseMode:Ut.oneOf("distance","score"),routing:Ut.boolean,worldview:Ut.string})(w),w.mode=w.mode||"mapbox.places";var I=T_(w_({country:w.countries},rh(w,["country","types","bbox","limit","language","reverseMode","routing","worldview"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:rh(w,["mode","query"]),query:I})};var E0=T0(Yd);let S0="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",S_=w=>crypto.getRandomValues(new Uint8Array(w)),A_=(w,I,R)=>{let Z=(2<<Math.log(w.length-1)/Math.LN2)-1,re=-~(1.6*Z*I/w.length);return(_e=I)=>{let we="";for(;;){let Pe=R(re),s=re;for(;s--;)if(we+=w[Pe[s]&Z]||"",we.length===_e)return we}}},A0=(w,I=21)=>A_(w,I,S_),M0=(w=21)=>crypto.getRandomValues(new Uint8Array(w)).reduce((I,R)=>(R&=63,R<36?I+=R.toString(36):R<62?I+=(R-26).toString(36).toUpperCase():R>62?I+="-":I+="_",I),"");const I0=Object.freeze(Object.defineProperty({__proto__:null,customAlphabet:A0,customRandom:A_,nanoid:M0,random:S_,urlAlphabet:S0},Symbol.toStringTag,{value:"Module"})),C0=Ix(I0);var P0=C0.nanoid;function M_(w){this.origin=w.origin||"https://api.mapbox.com",this.endpoint="events/v2",this.access_token=w.accessToken,this.version="0.2.0",this.sessionID=this.generateSessionID(),this.userAgent=this.getUserAgent(),this.options=w,this.send=this.send.bind(this),this.countries=w.countries?w.countries.split(","):null,this.types=w.types?w.types.split(","):null,this.bbox=w.bbox?w.bbox:null,this.language=w.language?w.language.split(","):null,this.limit=w.limit?+w.limit:null,this.locale=navigator.language||null,this.enableEventLogging=this.shouldEnableLogging(w),this.eventQueue=new Array,this.flushInterval=w.flushInterval||1e3,this.maxQueueSize=w.maxQueueSize||100,this.timer=this.flushInterval?setTimeout(this.flush.bind(this),this.flushInterval):null,this.lastSentInput="",this.lastSentIndex=0}M_.prototype={select:function(w,I){var R=this.getSelectedIndex(w,I),Z=this.getEventPayload("search.select",I);if(Z.resultIndex=R,Z.resultPlaceName=w.place_name,Z.resultId=w.id,!(R===this.lastSentIndex&&Z.queryString===this.lastSentInput||R==-1)&&(this.lastSentIndex=R,this.lastSentInput=Z.queryString,!!Z.queryString))return this.push(Z)},start:function(w){var I=this.getEventPayload("search.start",w);if(I.queryString)return this.push(I)},keyevent:function(w,I){if(w.key&&!(w.metaKey||[9,27,37,39,13,38,40].indexOf(w.keyCode)!==-1)){var R=this.getEventPayload("search.keystroke",I);if(R.lastAction=w.key,!!R.queryString)return this.push(R)}},send:function(w,I){if(!this.enableEventLogging)return I?I():void 0;var R=this.getRequestOptions(w);this.request(R,(function(Z){if(Z)return this.handleError(Z,I);if(I)return I()}).bind(this))},getRequestOptions:function(w){Array.isArray(w)||(w=[w]);var I={method:"POST",host:this.origin,path:this.endpoint+"?access_token="+this.access_token,headers:{"Content-Type":"application/json"},body:JSON.stringify(w)};return I},getEventPayload:function(w,I){var R;I.options.proximity?typeof I.options.proximity=="object"?R=[I.options.proximity.longitude,I.options.proximity.latitude]:I.options.proximity==="ip"?R=[999,999]:R=I.options.proximity:R=null;var Z=I._map?I._map.getZoom():void 0,re={event:w,created:+new Date,sessionIdentifier:this.sessionID,country:this.countries,userAgent:this.userAgent,language:this.language,bbox:this.bbox,types:this.types,endpoint:"mapbox.places",autocomplete:I.options.autocomplete,fuzzyMatch:I.options.fuzzyMatch,proximity:R,limit:I.options.limit,routing:I.options.routing,worldview:I.options.worldview,mapZoom:Z,keyboardLocale:this.locale};return w==="search.select"?re.queryString=I.inputString:w!="search.select"&&I._inputEl?re.queryString=I._inputEl.value:re.queryString=I.inputString,re},request:function(w,I){var R=new XMLHttpRequest;R.onreadystatechange=function(){if(this.readyState==4)return this.status==204?I(null):I(this.statusText)},R.open(w.method,w.host+"/"+w.path,!0);for(var Z in w.headers){var re=w.headers[Z];R.setRequestHeader(Z,re)}R.send(w.body)},handleError:function(w,I){if(I)return I(w)},generateSessionID:function(){return P0()},getUserAgent:function(){return"mapbox-gl-geocoder."+this.version+"."+navigator.userAgent},getSelectedIndex:function(w,I){if(I._typeahead){var R=I._typeahead.data,Z=w.id,re=R.map(function(we){return we.id}),_e=re.indexOf(Z);return _e}},shouldEnableLogging:function(w){return!(w.enableEventLogging===!1||w.origin&&w.origin!=="https://api.mapbox.com"||w.localGeocoder||w.filter)},flush:function(){this.eventQueue.length>0&&(this.send(this.eventQueue),this.eventQueue=new Array),this.timer&&clearTimeout(this.timer),this.flushInterval&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval))},push:function(w,I){this.eventQueue.push(w),(this.eventQueue.length>=this.maxQueueSize||I)&&this.flush()},remove:function(){this.flush()}};var z0=M_,k0={de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"לחפש",ja:"サーチ",lv:"Meklēt",pt:"Procurar",sr:"Претрага",zh:"搜索",cs:"Vyhledávání",hu:"Keresés",ka:"ძიება",nb:"Søke",sk:"Vyhľadávanie",th:"ค้นหา",fi:"Hae",is:"Leita",ko:"수색",pl:"Szukaj",sl:"Iskanje",fa:"جستجو",ru:"Поиск"},L0={placeholder:k0},I_={exports:{}};(function(w){(function(I,R,Z){w.exports?w.exports=Z():I[R]=Z()})(Yn,"subtag",function(){var I="",R=/^([a-zA-Z]{2,3})(?:[_-]+([a-zA-Z]{3})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{4})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{2}|[0-9]{3})(?=$|[_-]+))?/;function Z(s){return s.match(R)||[]}function re(s){return Z(s).filter(function(le,Qe){return le&&Qe})}function _e(s){return s=Z(s),{language:s[1]||I,extlang:s[2]||I,script:s[3]||I,region:s[4]||I}}function we(s,le,Qe){Object.defineProperty(s,le,{value:Qe,enumerable:!0})}function Pe(s,le,Qe){function et($e){return Z($e)[s]||I}we(et,"pattern",le),we(_e,Qe,et)}return Pe(1,/^[a-zA-Z]{2,3}$/,"language"),Pe(2,/^[a-zA-Z]{3}$/,"extlang"),Pe(3,/^[a-zA-Z]{4}$/,"script"),Pe(4,/^[a-zA-Z]{2}$|^[0-9]{3}$/,"region"),we(_e,"split",re),_e})})(I_);var D0=I_.exports;function C_(){}C_.prototype={isSupport:function(){return!!window.navigator.geolocation},getCurrentPosition:function(){const w={enableHighAccuracy:!0};return new Promise(function(I,R){window.navigator.geolocation.getCurrentPosition(I,R,w)})}};var R0=C_;function B0(w,I){const R=P_(w),Z=["address","street","place","country"];var re;if(typeof I=="function")return I(R);const _e=Z.indexOf(I);return _e===-1?re=Z:re=Z.slice(_e),re.reduce(function(we,Pe){return R[Pe]?(we!==""&&(we=we+", "),we+R[Pe]):we},"")}function P_(w){const I=w.address||"",R=w.text||"",Z=w.place_name||"",_e={address:Z.split(",")[0],houseNumber:I,street:R,placeName:Z};return w.context.forEach(function(we){const Pe=we.id.split(".")[0];_e[Pe]=we.text}),_e}const O0=/^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/;var F0={transformFeatureToGeolocationText:B0,getAddressInfo:P_,REVERSE_GEOCODE_COORD_RGX:O0},U0=jx,N0=ov,Os=qa,j0=dv.EventEmitter,qm=pv,qd=Kv,Zd=E0,V0=z0,G0=L0,$0=D0,q0=R0,Zm=F0;const Fo={FORWARD:0,LOCAL:1,REVERSE:2};function Z0(){var w=document.createElement("div");return w.className="mapboxgl-ctrl-geocoder--powered-by",w.innerHTML='<a href="https://www.mapbox.com/search-service" target="_blank">Powered by Mapbox</a>',w}function z_(w){this._eventEmitter=new j0,this.options=Os({},this.options,w),this.inputString="",this.fresh=!0,this.lastSelected=null,this.geolocation=new q0}z_.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,minLength:2,reverseGeocode:!1,flipCoordinates:!1,limit:5,origin:"https://api.mapbox.com",enableEventLogging:!0,marker:!0,mapboxgl:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,enableGeolocation:!1,addressAccuracy:"street",getItemValue:function(w){return w.place_name},render:function(w){var I=w.place_name.split(",");return'<div class="mapboxgl-ctrl-geocoder--suggestion"><div class="mapboxgl-ctrl-geocoder--suggestion-title">'+I[0]+'</div><div class="mapboxgl-ctrl-geocoder--suggestion-address">'+I.splice(1,I.length).join(",")+"</div></div>"}},addTo:function(w){function I(R,Z){if(!document.body.contains(Z))throw new Error("Element provided to #addTo() exists, but is not in the DOM");const re=R.onAdd();Z.appendChild(re)}if(w._controlContainer)w.addControl(this);else if(w instanceof HTMLElement)I(this,w);else if(typeof w=="string"){const R=document.querySelectorAll(w);if(R.length===0)throw new Error("Element ",w,"not found.");if(R.length>1)throw new Error("Geocoder can only be added to a single html element");I(this,R[0])}else throw new Error("Error: addTo must be a mapbox-gl-js map, an html element, or a CSS selector query for a single html element")},onAdd:function(w){if(w&&typeof w!="string"&&(this._map=w),this.setLanguage(),this.options.localGeocoderOnly||(this.geocoderService=Zd(qd({accessToken:this.options.accessToken,origin:this.options.origin}))),this.options.localGeocoderOnly&&!this.options.localGeocoder)throw new Error("A localGeocoder function must be specified to use localGeocoderOnly mode");this.eventManager=new V0(this.options),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPaste=this._onPaste.bind(this),this._onBlur=this._onBlur.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this),this._geolocateUser=this._geolocateUser.bind(this);var I=this.container=document.createElement("div");I.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var R=this.createIcon("search",'<path d="M7.4 2.5c-2.7 0-4.9 2.2-4.9 4.9s2.2 4.9 4.9 4.9c1 0 1.8-.2 2.5-.8l3.7 3.7c.2.2.4.3.8.3.7 0 1.1-.4 1.1-1.1 0-.3-.1-.5-.3-.8L11.4 10c.4-.8.8-1.6.8-2.5.1-2.8-2.1-5-4.8-5zm0 1.6c1.8 0 3.2 1.4 3.2 3.2s-1.4 3.2-3.2 3.2-3.3-1.3-3.3-3.1 1.4-3.3 3.3-3.3z"/>');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-ctrl-geocoder--input",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse)),(this.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",N0(this._onKeyDown,200)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton),this._inputEl.addEventListener("keyup",(function(le){this.eventManager.keyevent(le,this)}).bind(this));var Z=document.createElement("div");Z.classList.add("mapboxgl-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="mapboxgl-ctrl-geocoder--button";var re=this.createIcon("close",'<path d="M3.8 2.5c-.6 0-1.3.7-1.3 1.3 0 .3.2.7.5.8L7.2 9 3 13.2c-.3.3-.5.7-.5 1 0 .6.7 1.3 1.3 1.3.3 0 .7-.2 1-.5L9 10.8l4.2 4.2c.2.3.7.3 1 .3.6 0 1.3-.7 1.3-1.3 0-.3-.2-.7-.3-1l-4.4-4L15 4.6c.3-.2.5-.5.5-.8 0-.7-.7-1.3-1.3-1.3-.3 0-.7.2-1 .3L9 7.1 4.8 2.8c-.3-.1-.7-.3-1-.3z"/>');if(this._clearEl.appendChild(re),this._loadingEl=this.createIcon("loading",'<path fill="#333" d="M4.4 4.4l.8.8c2.1-2.1 5.5-2.1 7.6 0l.8-.8c-2.5-2.5-6.7-2.5-9.2 0z"/><path opacity=".1" d="M12.8 12.9c-2.1 2.1-5.5 2.1-7.6 0-2.1-2.1-2.1-5.5 0-7.7l-.8-.8c-2.5 2.5-2.5 6.7 0 9.2s6.6 2.5 9.2 0 2.5-6.6 0-9.2l-.8.8c2.2 2.1 2.2 5.6 0 7.7z"/>'),Z.appendChild(this._clearEl),Z.appendChild(this._loadingEl),I.appendChild(R),I.appendChild(this._inputEl),I.appendChild(Z),this.options.enableGeolocation&&this.geolocation.isSupport()){this._geolocateEl=document.createElement("button"),this._geolocateEl.setAttribute("aria-label","Geolocate"),this._geolocateEl.addEventListener("click",this._geolocateUser),this._geolocateEl.className="mapboxgl-ctrl-geocoder--button";var _e=this.createIcon("geolocate",'<path d="M12.999 3.677L2.042 8.269c-.962.403-.747 1.823.29 1.912l5.032.431.431 5.033c.089 1.037 1.509 1.252 1.912.29l4.592-10.957c.345-.822-.477-1.644-1.299-1.299z" fill="#4264fb"/>');this._geolocateEl.appendChild(_e),Z.appendChild(this._geolocateEl),this._showGeolocateButton()}var we=this._typeahead=new U0(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit});this.setRenderFunction(this.options.render),we.getItemValue=this.options.getItemValue;var Pe=we.list.draw,s=this._footerNode=Z0();return we.list.draw=function(){Pe.call(this),s.addEventListener("mousedown",(function(){this.selectingListItem=!0}).bind(this)),s.addEventListener("mouseup",(function(){this.selectingListItem=!1}).bind(this)),this.element.appendChild(s)},this.mapMarker=null,this._handleMarker=this._handleMarker.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._mapboxgl=this.options.mapboxgl,!this._mapboxgl&&this.options.marker&&(console.error("No mapboxgl detected in options. Map markers are disabled. Please set options.mapboxgl."),this.options.marker=!1)),I},_geolocateUser:function(){this._hideGeolocateButton(),this._showLoadingIcon(),this.geolocation.getCurrentPosition().then((function(w){this._hideLoadingIcon();const I={geometry:{type:"Point",coordinates:[w.coords.longitude,w.coords.latitude]}};this._handleMarker(I),this._fly(I),this._typeahead.clear(),this._typeahead.selected=!0,this.lastSelected=JSON.stringify(I),this._showClearButton(),this.fresh=!1;const R={limit:1,language:[this.options.language],query:I.geometry.coordinates,types:["address"]};if(this.options.localGeocoderOnly){const Z=I.geometry.coordinates[0]+","+I.geometry.coordinates[1];this._setInputValue(Z),this._eventEmitter.emit("result",{result:I})}else this.geocoderService.reverseGeocode(R).send().then((function(Z){const re=Z.body.features[0];if(re){const _e=Zm.transformFeatureToGeolocationText(re,this.options.addressAccuracy);this._setInputValue(_e),re.user_coordinates=I.geometry.coordinates,this._eventEmitter.emit("result",{result:re})}else this._eventEmitter.emit("result",{result:{user_coordinates:I.geometry.coordinates}})}).bind(this))}).bind(this)).catch((function(w){w.code===1?this._renderUserDeniedGeolocationError():this._renderLocationError(),this._hideLoadingIcon(),this._showGeolocateButton(),this._hideAttribution()}).bind(this))},createIcon:function(w,I){var R=document.createElementNS("http://www.w3.org/2000/svg","svg");return R.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+w),R.setAttribute("viewBox","0 0 18 18"),R.setAttribute("xml:space","preserve"),R.setAttribute("width",18),R.setAttribute("height",18),R.innerHTML=I,R},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_setInputValue:function(w){this._inputEl.value=w,setTimeout((function(){this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0)}).bind(this),1)},_onPaste:function(w){var I=(w.clipboardData||window.clipboardData).getData("text");I.length>=this.options.minLength&&this._geocode(I)},_onKeyDown:function(w){var I=27,R=9;if(w.keyCode===I&&this.options.clearAndBlurOnEsc)return this._clear(w),this._inputEl.blur();var Z=w.target&&w.target.shadowRoot?w.target.shadowRoot.activeElement:w.target,re=Z?Z.value:"";if(!re)return this.fresh=!0,w.keyCode!==R&&this.clear(w),this._showGeolocateButton(),this._hideClearButton();this._hideGeolocateButton(),!(w.metaKey||[R,I,37,39,13,38,40].indexOf(w.keyCode)!==-1)&&Z.value.length>=this.options.minLength&&this._geocode(Z.value)},_showButton:function(){this._typeahead.selected&&this._showClearButton()},_hideButton:function(){this._typeahead.selected&&this._hideClearButton()},_showClearButton:function(){this._clearEl.style.display="block"},_hideClearButton:function(){this._clearEl.style.display="none"},_showGeolocateButton:function(){this._geolocateEl&&this.geolocation.isSupport()&&(this._geolocateEl.style.display="block")},_hideGeolocateButton:function(){this._geolocateEl&&(this._geolocateEl.style.display="none")},_showLoadingIcon:function(){this._loadingEl.style.display="block"},_hideLoadingIcon:function(){this._loadingEl.style.display="none"},_showAttribution:function(){this._footerNode.style.display="block"},_hideAttribution:function(){this._footerNode.style.display="none"},_onBlur:function(w){this.options.clearOnBlur&&this._clearOnBlur(w),this.options.collapsed&&this._collapse()},_onChange:function(){var w=this._typeahead.selected;w&&JSON.stringify(w)!==this.lastSelected&&(this._hideClearButton(),this.options.flyTo&&this._fly(w),this.options.marker&&this._mapboxgl&&this._handleMarker(w),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(w),this._eventEmitter.emit("result",{result:w}),this.eventManager.select(w,this))},_fly:function(w){var I;if(w.properties&&qm[w.properties.short_code])I=Os({},this.options.flyTo),this._map&&this._map.fitBounds(qm[w.properties.short_code].bbox,I);else if(w.bbox){var R=w.bbox;I=Os({},this.options.flyTo),this._map&&this._map.fitBounds([[R[0],R[1]],[R[2],R[3]]],I)}else{var Z={zoom:this.options.zoom};I=Os({},Z,this.options.flyTo),w.center?I.center=w.center:w.geometry&&w.geometry.type&&w.geometry.type==="Point"&&w.geometry.coordinates&&(I.center=w.geometry.coordinates),this._map&&this._map.flyTo(I)}},_requestType:function(w,I){var R;return w.localGeocoderOnly?R=Fo.LOCAL:w.reverseGeocode&&Zm.REVERSE_GEOCODE_COORD_RGX.test(I)?R=Fo.REVERSE:R=Fo.FORWARD,R},_setupConfig:function(w,I){const R=["bbox","limit","proximity","countries","types","language","reverseMode","mode","autocomplete","fuzzyMatch","routing","worldview"],Z=/[\s,]+/;var re=this,_e=R.reduce(function(Pe,s){if(re.options[s]===void 0||re.options[s]===null)return Pe;["countries","types","language"].indexOf(s)>-1?Pe[s]=re.options[s].split(Z):Pe[s]=re.options[s];const le=typeof re.options[s].longitude=="number"&&typeof re.options[s].latitude=="number";if(s==="proximity"&&le){const Qe=re.options[s].longitude,et=re.options[s].latitude;Pe[s]=[Qe,et]}return Pe},{});switch(w){case Fo.REVERSE:{var we=I.split(Z).map(function(Pe){return parseFloat(Pe,10)});re.options.flipCoordinates||we.reverse(),_e.types&&_e.types[0],_e=Os(_e,{query:we,limit:1}),["proximity","autocomplete","fuzzyMatch","bbox"].forEach(function(Pe){Pe in _e&&delete _e[Pe]})}break;case Fo.FORWARD:{const Pe=I.trim();/^(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)?$/.test(Pe)&&(I=I.replace(/,/g," ")),_e=Os(_e,{query:I})}break}return _e},_geocode:function(w){this.inputString=w,this._showLoadingIcon(),this._eventEmitter.emit("loading",{query:w});const I=this._requestType(this.options,w),R=this._setupConfig(I,w);var Z;switch(I){case Fo.LOCAL:Z=Promise.resolve();break;case Fo.FORWARD:Z=this.geocoderService.forwardGeocode(R).send();break;case Fo.REVERSE:Z=this.geocoderService.reverseGeocode(R).send();break}var re=this.options.localGeocoder?this.options.localGeocoder(w)||[]:[],_e=[],we=null;return Z.catch((function(Pe){we=Pe}).bind(this)).then((function(Pe){this._hideLoadingIcon();var s={};return Pe?Pe.statusCode=="200"&&(s=Pe.body,s.request=Pe.request,s.headers=Pe.headers):s={type:"FeatureCollection",features:[]},s.config=R,this.fresh&&(this.eventManager.start(this),this.fresh=!1),s.features=s.features?re.concat(s.features):re,this.options.externalGeocoder?(_e=this.options.externalGeocoder(w,s.features)||Promise.resolve([]),_e.then(function(le){return s.features=s.features?le.concat(s.features):le,s},function(){return s})):s}).bind(this)).then((function(Pe){if(we)throw we;this.options.filter&&Pe.features.length&&(Pe.features=Pe.features.filter(this.options.filter)),Pe.features.length?(this._showClearButton(),this._hideGeolocateButton(),this._showAttribution(),this._eventEmitter.emit("results",Pe),this._typeahead.update(Pe.features)):(this._hideClearButton(),this._hideAttribution(),this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",Pe))}).bind(this)).catch((function(Pe){this._hideLoadingIcon(),this._hideAttribution(),re.length&&this.options.localGeocoder||_e.length&&this.options.externalGeocoder?(this._showClearButton(),this._hideGeolocateButton(),this._typeahead.update(re)):(this._hideClearButton(),this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:re}),this._eventEmitter.emit("error",{error:Pe})}).bind(this)),Z},_clear:function(w){w&&w.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this._hideClearButton(),this._showGeolocateButton(),this._removeMarker(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(w){this._clear(w),this._inputEl.focus()},_clearOnBlur:function(w){var I=this;w.relatedTarget&&I._clear(w)},_onQueryResult:function(w){var I=w.body;if(I.features.length){var R=I.features[0];this._typeahead.selected=R,this._inputEl.value=R.place_name,this._onChange()}},_updateProximity:function(){if(!(!this._map||!this.options.trackProximity))if(this._map.getZoom()>9){var w=this._map.getCenter().wrap();this.setProximity({longitude:w.lng,latitude:w.lat},!1)}else this.setProximity(null,!1)},_collapse:function(){!this._inputEl.value&&this._inputEl!==document.activeElement&&this.container.classList.add("mapboxgl-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("mapboxgl-ctrl-geocoder--collapsed")},query:function(w){return this._geocode(w).then(this._onQueryResult),this},_renderError:function(){var w="<div class='mapbox-gl-geocoder--error'>There was an error reaching the server</div>";this._renderMessage(w)},_renderLocationError:function(){var w="<div class='mapbox-gl-geocoder--error'>A location error has occurred</div>";this._renderMessage(w)},_renderNoResults:function(){var w="<div class='mapbox-gl-geocoder--error mapbox-gl-geocoder--no-results'>No results found</div>";this._renderMessage(w)},_renderUserDeniedGeolocationError:function(){var w="<div class='mapbox-gl-geocoder--error'>Geolocation permission denied</div>";this._renderMessage(w)},_renderMessage:function(w){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(w)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var w=this.options.language.split(",")[0],I=$0.language(w),R=G0.placeholder[I];if(R)return R}return"Search"},setInput:function(w,I){return I===void 0&&(I=!1),this._inputEl.value=w,this._typeahead.selected=null,this._typeahead.clear(),w.length>=this.options.minLength&&(I?this._geocode(w):this._onChange()),this},setProximity:function(w,I=!0){return this.options.proximity=w,I&&(this.options.trackProximity=!1),this},getProximity:function(){return this.options.proximity},setRenderFunction:function(w){return w&&typeof w=="function"&&(this._typeahead.render=w),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(w){var I=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=w||this.options.language||I,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(w){return this.options.zoom=w,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(w){return this.options.flyTo=w,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(w){return this.options.placeholder=w||this._getPlaceholderText(),this._inputEl.placeholder=this.options.placeholder,this._inputEl.setAttribute("aria-label",this.options.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(w){return this.options.bbox=w,this},getCountries:function(){return this.options.countries},setCountries:function(w){return this.options.countries=w,this},getTypes:function(){return this.options.types},setTypes:function(w){return this.options.types=w,this},getMinLength:function(){return this.options.minLength},setMinLength:function(w){return this.options.minLength=w,this._typeahead&&(this._typeahead.options.minLength=w),this},getLimit:function(){return this.options.limit},setLimit:function(w){return this.options.limit=w,this._typeahead&&(this._typeahead.options.limit=w),this},getFilter:function(){return this.options.filter},setFilter:function(w){return this.options.filter=w,this},setOrigin:function(w){return this.options.origin=w,this.geocoderService=Zd(qd({accessToken:this.options.accessToken,origin:this.options.origin})),this},getOrigin:function(){return this.options.origin},setAccessToken:function(w){return this.options.accessToken=w,this.geocoderService=Zd(qd({accessToken:this.options.accessToken,origin:this.options.origin})),this},setAutocomplete:function(w){return this.options.autocomplete=w,this},getAutocomplete:function(){return this.options.autocomplete},setFuzzyMatch:function(w){return this.options.fuzzyMatch=w,this},getFuzzyMatch:function(){return this.options.fuzzyMatch},setRouting:function(w){return this.options.routing=w,this},getRouting:function(){return this.options.routing},setWorldview:function(w){return this.options.worldview=w,this},getWorldview:function(){return this.options.worldview},_handleMarker:function(w){if(this._map){this._removeMarker();var I={color:"#4668F2"},R=Os({},I,this.options.marker);return this.mapMarker=new this._mapboxgl.Marker(R),w.center?this.mapMarker.setLngLat(w.center).addTo(this._map):w.geometry&&w.geometry.type&&w.geometry.type==="Point"&&w.geometry.coordinates&&this.mapMarker.setLngLat(w.geometry.coordinates).addTo(this._map),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(w,I){return this._eventEmitter.on(w,I),this},off:function(w,I){return this._eventEmitter.removeListener(w,I),this.eventManager.remove(),this}};var W0=z_;const Wm=Xm(W0),X0={class:"mb-8"},H0={class:"grid grid-cols-12 lg:gap-10"},K0={class:"col-span-full hidden lg:col-span-8 lg:block"},J0={class:"col-span-full lg:col-span-4"},Y0={class:"relative mb-4 h-14"},Q0=ri("option",{value:"5"},"5 km",-1),e1=ri("option",{value:"10"},"10 km",-1),t1=ri("option",{value:"15"},"15 km",-1),i1=ri("option",{value:"20"},"20 km",-1),r1=ri("option",{value:"25"},"25 km",-1),n1=[Q0,e1,t1,i1,r1],o1={class:"grid grid-cols-12 lg:gap-10"},s1={class:"col-span-full lg:col-span-8"},a1={key:0,class:"dealer-scroll col-span-full hidden h-full overflow-y-scroll lg:col-span-4 lg:block lg:h-[700px] lg:pr-2"},l1={key:1,class:"dealer-scroll col-span-full h-full overflow-y-scroll lg:col-span-4 lg:h-[700px] lg:pr-2"},d1={__name:"dealers",async setup(w){let I,R;const Z=mx(),{data:re}=([I,R]=Pm(()=>Dm(`${Z.public.directusUrl}/items/Dealer_Pagina`,{params:{fields:["Algemene_Informatie.item.*","Titel"],limit:1}},"$y7DLHbpdw9")),I=await I,R(),I),{data:_e}=([I,R]=Pm(()=>Dm(`${Z.public.directusUrl}/items/Dealer`,{params:{filter:{status:{_eq:"published"}},fields:["*.*.*"],limit:500}},"$M4SijaUTzS")),I=await I,R(),I),{transitionState:we}=_x();ax(()=>we.transitionComplete,ti=>{ti&&$e.value.resize()});const Pe=cn(void 0),s=cn(null),le=cn(null),Qe=cn(!1),et=cn([]),$e=cn(null),Je=cn(5),Ye=cn(null),_t=cn(null),ot=cn(null),St=cn(null),ei=()=>{Qe.value=!Qe.value,St.value.clear()},Ct=()=>{et.value=[],_e.value.data.forEach(ti=>{const _i=[le.value,s.value],ai=[ti.Longitude,ti.Lattitude],Re=kx(ai,_i,{units:"kilometers"});Re<Je.value&&et.value.push({dealer:{...ti,distance:Re.toFixed(2).replace(".",",")},distance:Re.toFixed(2)})}),et.value.sort((ti,_i)=>ti.distance-_i.distance),et.value=et.value.slice(0,20),Qe.value=!0},pi=()=>{ot.value.querySelector("input").value.length<=2||(Ct(),$e.value.flyTo({center:[le.value,s.value],zoom:12}))};lx(()=>{Mn.accessToken="pk.eyJ1IjoibGltaXRsZXNzLWRpZ2l0YWwiLCJhIjoiY2xjdnI1M202MW1jcDNvbGhiOTFydTNldCJ9.6AC9S32iPPhYqeD5SStWOw",$e.value=new Mn.Map({container:Pe.value,style:"mapbox://styles/mapbox/light-v10",center:[5.291266,52.132633],zoom:9,projection:"globe",maxBounds:[[1.559275,50.401965],[9.06496,53.552418]],scrollZoom:!1});const ti=new Wm({accessToken:Mn.accessToken,marker:!1,countries:"nl, be",placeholder:"Voer je locatie in ...",mapboxgl:Mn});_t.value.appendChild(ti.onAdd($e.value)),St.value=new Wm({accessToken:Mn.accessToken,marker:!1,countries:"nl, be",flyTo:!1,placeholder:"Zoeken op locatie ...",mapboxgl:Mn}),St.value.on("result",Re=>{le.value=Re.result.center[0],s.value=Re.result.center[1]}),ot.value.appendChild(St.value.onAdd($e.value)),$e.value.addControl(new Mn.NavigationControl);const _i=new Mn.GeolocateControl({trackUserLocation:!0});$e.value.addControl(_i),$e.value.on("load",()=>{ai()}),Ye.value.classList.remove("hidden");const ai=()=>{_e.value.data.forEach(Re=>{const In=document.createElement("div");In.className="dealer-marker",In.addEventListener("click",()=>{$e.value.flyTo({center:[Re.Longitude,Re.Lattitude],essential:!0,zoom:14})});const Vo=new Mn.Popup({offset:25}).setHTML(`
          <div>
            <div>
            <div class="font-medium mb-4">${Re.Naam}</div>
            <div class="text-5xs mb-2">${Re.Adres}</div>
            <div class="text-5xs"><a target="_blank" href="${Re.Website}">${Re.Website}</a></div>
            </div>
          </div>`);new Mn.Marker(In).setLngLat([Re.Longitude,Re.Lattitude]).addTo($e.value).setPopup(Vo)})}});const Nt=re.value.data.Algemene_Informatie[0].item,{$seo:Lt}=cx();return Lt(Nt),(ti,_i)=>(Uo(),Nd(Ec(fx),{"dealer-block":!1},{default:zm(()=>[eh(px,{class:"custom-container mx-auto pt-32 lg:pt-52"},{default:zm(()=>[ri("h1",X0,[eh(ux,{text:Ec(re).data.Titel},null,8,["text"])]),ri("div",H0,[ri("div",K0,[ri("div",{ref_key:"searchbarRef",ref:_t,class:"mb-4"},null,512)]),ri("div",J0,[ri("div",Y0,[ri("div",{ref_key:"locationInput",ref:ot,class:"absolute w-full"},null,512),ri("div",{ref_key:"radiusInput",ref:Ye,class:"absolute right-0 top-1/2 z-10 flex hidden h-full -translate-y-1/2 rounded-full rounded-full bg-[#F5F5F5] pl-5 pr-28 text-2xs outline-none lg:pr-32"},[hx(ri("select",{"onUpdate:modelValue":_i[0]||(_i[0]=ai=>Je.value=ai),class:"rounded-full bg-[#f5f5f5] font-medium outline-none"},n1,512),[[dx,Je.value]]),ri("button",{class:"absolute right-0 top-1/2 z-10 mr-1 flex h-12 -translate-y-1/2 items-center rounded-full bg-dark px-6 font-medium text-white transition-colors hover:bg-primary lg:px-8",onClick:pi}," Zoeken ")],512)])])]),ri("div",o1,[ri("div",s1,[ri("div",{id:"dealer-mapbox",ref_key:"mapboxContainer",ref:Pe,class:"mb-5 h-[400px] rounded-2xl lg:h-[700px]"},null,512)]),Qe.value?(Uo(),Sc("div",l1,[(Uo(!0),Sc(km,null,Lm(et.value,(ai,Re)=>(Uo(),Nd(Ec(Rm),{key:Re,dealer:ai.dealer,distance:ai.distance},null,8,["dealer","distance"]))),128)),ri("div",{class:"mt-5 hidden cursor-pointer text-center text-primary hover:underline lg:block",onClick:ei}," Toon alle dealers ")])):(Uo(),Sc("div",a1,[(Uo(!0),Sc(km,null,Lm(Ec(_e).data,(ai,Re)=>(Uo(),Nd(Ec(Rm),{key:Re,dealer:ai},null,8,["dealer"]))),128))]))])]),_:1})]),_:1}))}};export{d1 as default};
