naksha-components-react 4.4.9 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -8
- package/dist/esm/chunk-U5OMNIOK.js +0 -1
- package/dist/esm/index.js +0 -255
- package/dist/esm/mapbox-gl-Q3G2EFTE.js +0 -1020
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -1274
|
@@ -1,1020 +0,0 @@
|
|
|
1
|
-
import{d as Xm}from"./chunk-U5OMNIOK.js";var Wm=Xm((mu,_u)=>{(function(xn,oo){typeof mu=="object"&&typeof _u<"u"?_u.exports=oo():typeof define=="function"&&define.amd?define(oo):(xn=typeof globalThis<"u"?globalThis:xn||self,xn.mapboxgl=oo())})(mu,function(){"use strict";var xn,oo,Zc;function $c(a,Ri){if(!xn)xn=Ri;else if(!oo)oo=Ri;else{var mr="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 = {}; ("+xn+")(sharedChunk); ("+oo+")(sharedChunk); self.onerror = null;",ui={};xn(ui),Zc=Ri(ui),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(Zc.workerUrl=window.URL.createObjectURL(new Blob([mr],{type:"text/javascript"})))}}$c(["exports"],function(a){"use strict";var Ri="2.8.2",mr=ui;function ui(i,e,r,n){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=n,this.p2x=r,this.p2y=n}ui.prototype.sampleCurveX=function(i){return((this.ax*i+this.bx)*i+this.cx)*i},ui.prototype.sampleCurveY=function(i){return((this.ay*i+this.by)*i+this.cy)*i},ui.prototype.sampleCurveDerivativeX=function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},ui.prototype.solveCurveX=function(i,e){var r,n,s,c,u;for(e===void 0&&(e=1e-6),s=i,u=0;u<8;u++){if(c=this.sampleCurveX(s)-i,Math.abs(c)<e)return s;var p=this.sampleCurveDerivativeX(s);if(Math.abs(p)<1e-6)break;s-=c/p}if((s=i)<(r=0))return r;if(s>(n=1))return n;for(;r<n;){if(c=this.sampleCurveX(s),Math.abs(c-i)<e)return s;i>c?r=s:n=s,s=.5*(n-r)+r}return s},ui.prototype.solve=function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))};var _e=et;function et(i,e){this.x=i,this.y=e}et.prototype={clone:function(){return new et(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,e){return this.clone()._rotateAround(i,e)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult:function(i){var e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var e=Math.cos(i),r=Math.sin(i),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(i,e){var r=Math.cos(i),n=Math.sin(i),s=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},et.convert=function(i){return i instanceof et?i:Array.isArray(i)?new et(i[0],i[1]):i};var Ne=typeof self<"u"?self:{};let Wi=Math.PI/180,jr=180/Math.PI;function lt(i){return i*Wi}function ri(i){return i*jr}let Yo=[[0,0],[1,0],[1,1],[0,1]];function Nr(i){if(i<=0)return 0;if(i>=1)return 1;let e=i*i,r=e*i;return 4*(i<.5?r:3*(i-e)+r-.75)}function Gr(i,e,r,n){let s=new mr(i,e,r,n);return function(c){return s.solve(c)}}let Hi=Gr(.25,.1,.25,1);function at(i,e,r){return Math.min(r,Math.max(e,i))}function so(i,e,r){return(r=at((r-i)/(e-i),0,1))*r*(3-2*r)}function Yi(i,e,r){let n=r-e,s=((i-e)%n+n)%n+e;return s===e?r:s}function vn(i,e,r){if(!i.length)return r(null,[]);let n=i.length,s=new Array(i.length),c=null;i.forEach((u,p)=>{e(u,(m,g)=>{m&&(c=m),s[p]=g,--n==0&&r(c,s)})})}function ao(i){let e=[];for(let r in i)e.push(i[r]);return e}function Gt(i,...e){for(let r of e)for(let n in r)i[n]=r[n];return i}let lo=1;function bn(){return lo++}function Ko(){return function i(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,i)}()}function Jo(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Zr(i){return!!i&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(i)}function wn(i,e){i.forEach(r=>{e[r]&&(e[r]=e[r].bind(e))})}function Ki(i,e){return i.indexOf(e,i.length-e.length)!==-1}function _r(i,e,r){let n={};for(let s in i)n[s]=e.call(r||this,i[s],s,i);return n}function co(i,e,r){let n={};for(let s in i)e.call(r||this,i[s],s,i)&&(n[s]=i[s]);return n}function wi(i){return Array.isArray(i)?i.map(wi):typeof i=="object"&&i?_r(i,wi):i}let Qo={};function bt(i){Qo[i]||(typeof console<"u"&&console.warn(i),Qo[i]=!0)}function Yt(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function gr(i){let e=0;for(let r,n,s=0,c=i.length,u=c-1;s<c;u=s++)r=i[s],n=i[u],e+=(n.x-r.x)*(r.y+n.y);return e}function Fi(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function Tn(i){let e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,n,s,c)=>{let u=s||c;return e[n]=!u||u.toLowerCase(),""}),e["max-age"]){let r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e}let yr,ho,$r,Ji,ot=null;function xr(i){if(ot==null){let e=i.navigator?i.navigator.userAgent:null;ot=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return ot}function es(i){try{let e=Ne[i];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}let ni={now:()=>$r!==void 0?$r:Ne.performance.now(),setNow(i){$r=i},restoreNow(){$r=void 0},frame(i){let e=Ne.requestAnimationFrame(i);return{cancel:()=>Ne.cancelAnimationFrame(e)}},getImageData(i,e=0){let{width:r,height:n}=i;Ji||(Ji=Ne.document.createElement("canvas"));let s=Ji.getContext("2d");if(!s)throw new Error("failed to create canvas 2d context");return(r>Ji.width||n>Ji.height)&&(Ji.width=r,Ji.height=n),s.clearRect(-e,-e,r+2*e,n+2*e),s.drawImage(i,0,0,r,n),s.getImageData(-e,-e,r+2*e,n+2*e)},resolveURL:i=>(yr||(yr=Ne.document.createElement("a")),yr.href=i,yr.href),get devicePixelRatio(){return Ne.devicePixelRatio},get prefersReducedMotion(){return!!Ne.matchMedia&&(ho==null&&(ho=Ne.matchMedia("(prefers-reduced-motion: reduce)")),ho.matches)}},qr,ut={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(qr==null){let i=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{qr=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):i}catch{qr=i}}return qr},get EVENTS_URL(){return this.API_URL?this.API_URL.indexOf("https://api.mapbox.cn")===0?"https://events.mapbox.cn/events/v2":this.API_URL.indexOf("https://api.mapbox.com")===0?"https://events.mapbox.com/events/v2":null: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},vr={supported:!1,testSupport:function(i){!Wr&&Ti&&(En?uo(i):Xr=i)}},Xr,Ti,Wr=!1,En=!1;function uo(i){let e=i.createTexture();i.bindTexture(i.TEXTURE_2D,e);try{if(i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,Ti),i.isContextLost())return;vr.supported=!0}catch{}i.deleteTexture(e),Wr=!0}Ne.document&&(Ti=Ne.document.createElement("img"),Ti.onload=function(){Xr&&uo(Xr),Xr=null,En=!0},Ti.onerror=function(){Wr=!0,Xr=null},Ti.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");let Sn="01",Hr="NO_ACCESS_TOKEN";function Oi(i){return i.indexOf("mapbox:")===0}function Yr(i){return ut.API_URL_REGEX.test(i)}let Ui=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Vi(i){let e=i.match(Ui);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 br(i){let e=i.params.length?`?${i.params.join("&")}`:"";return`${i.protocol}://${i.authority}${i.path}${e}`}function po(i){if(!i)return null;let e=i.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent(Ne.atob(e[1]).split("").map(r=>"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class Kr{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){let r=po(ut.ACCESS_TOKEN),n="";return n=r&&r.u?Ne.btoa(encodeURIComponent(r.u).replace(/%([0-9A-F]{2})/g,(s,c)=>String.fromCharCode(Number("0x"+c)))):ut.ACCESS_TOKEN||"",e?`mapbox.eventData.${e}:${n}`:`mapbox.eventData:${n}`}fetchEventData(){let e=es("localStorage"),r=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{let s=Ne.localStorage.getItem(r);s&&(this.eventData=JSON.parse(s));let c=Ne.localStorage.getItem(n);c&&(this.anonId=c)}catch{bt("Unable to read from LocalStorage")}}saveEventData(){let e=es("localStorage"),r=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{Ne.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&Ne.localStorage.setItem(r,JSON.stringify(this.eventData))}catch{bt("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,r,n,s){if(!ut.EVENTS_URL)return;let c=Vi(ut.EVENTS_URL);c.params.push(`access_token=${s||ut.ACCESS_TOKEN||""}`);let u={event:this.type,created:new Date(e).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:Ri,skuId:Sn,userId:this.anonId},p=r?Gt(u,r):u,m={url:br(c),headers:{"Content-Type":"text/plain"},body:JSON.stringify([p])};this.pendingRequest=W(m,g=>{this.pendingRequest=null,n(g),this.saveEventData(),this.processRequests(s)})}queueRequest(e,r){this.queue.push(e),this.processRequests(r)}}let In=new class extends Kr{constructor(i){super("appUserTurnstile"),this._customAccessToken=i}postTurnstileEvent(i,e){ut.EVENTS_URL&&ut.ACCESS_TOKEN&&Array.isArray(i)&&i.some(r=>Oi(r)||Yr(r))&&this.queueRequest(Date.now(),e)}processRequests(i){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();let e=po(ut.ACCESS_TOKEN),r=e?e.u:ut.ACCESS_TOKEN,n=r!==this.eventData.tokenU;Zr(this.anonId)||(this.anonId=Ko(),n=!0);let s=this.queue.shift();if(this.eventData.lastSuccess){let c=new Date(this.eventData.lastSuccess),u=new Date(s),p=(s-this.eventData.lastSuccess)/864e5;n=n||p>=1||p<-1||c.getDate()!==u.getDate()}else n=!0;n?this.postEvent(s,{"enabled.telemetry":!1},c=>{c||(this.eventData.lastSuccess=s,this.eventData.tokenU=r)},i):this.processRequests()}},ia=In.postTurnstileEvent.bind(In),ts=new class extends Kr{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(i,e,r,n){this.skuToken=e,this.errorCb=n,ut.EVENTS_URL&&(r||ut.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},r):this.errorCb(new Error(Hr)))}processRequests(i){if(this.pendingRequest||this.queue.length===0)return;let{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),Zr(this.anonId)||(this.anonId=Ko()),this.postEvent(r,{skuToken:this.skuToken},n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},i))}},is=ts.postMapLoadEvent.bind(ts),Mn=new class extends Kr{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(i,e,r,n){if(!ut.API_URL||!ut.SESSION_PATH)return;let s=Vi(ut.API_URL+ut.SESSION_PATH);s.params.push(`sku=${e||""}`),s.params.push(`access_token=${n||ut.ACCESS_TOKEN||""}`);let c={url:br(s),headers:{"Content-Type":"text/plain"}};this.pendingRequest=te(c,u=>{this.pendingRequest=null,r(u),this.saveEventData(),this.processRequests(n)})}getSessionAPI(i,e,r,n){this.skuToken=e,this.errorCb=n,ut.SESSION_PATH&&ut.API_URL&&(r||ut.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},r):this.errorCb(new Error(Hr)))}processRequests(i){if(this.pendingRequest||this.queue.length===0)return;let{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||this.getSession(r,this.skuToken,n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},i)}},rs=Mn.getSessionAPI.bind(Mn),Jr=new Set,ns="mapbox-tiles",ji,wr,Qr=500,en=50;function An(){Ne.caches&&!ji&&(ji=Ne.caches.open(ns))}function fo(i){let e=i.indexOf("?");return e<0?i:i.slice(0,e)}let Cn=1/0,U={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(U);class I extends Error{constructor(e,r,n){r===401&&Yr(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=r,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}let C=Fi()?()=>self.worker&&self.worker.referrer:()=>(Ne.location.protocol==="blob:"?Ne.parent:Ne).location.href,R=function(i,e){if(!(/^file:/.test(r=i.url)||/^file:/.test(C())&&!/^\w+:/.test(r))){if(Ne.fetch&&Ne.Request&&Ne.AbortController&&Ne.Request.prototype.hasOwnProperty("signal"))return function(n,s){let c=new Ne.AbortController,u=new Ne.Request(n.url,{method:n.method||"GET",body:n.body,credentials:n.credentials,headers:n.headers,referrer:C(),signal:c.signal}),p=!1,m=!1,g=(x=u.url).indexOf("sku=")>0&&Yr(x);var x;n.type==="json"&&u.headers.set("Accept","application/json");let v=(S,A,k)=>{if(m)return;if(S&&S.message!=="SecurityError"&&bt(S),A&&k)return w(A);let L=Date.now();Ne.fetch(u).then(O=>{if(O.ok){let q=g?O.clone():null;return w(O,q,L)}return s(new I(O.statusText,O.status,n.url))}).catch(O=>{O.code!==20&&s(new Error(O.message))})},w=(S,A,k)=>{(n.type==="arrayBuffer"?S.arrayBuffer():n.type==="json"?S.json():S.text()).then(L=>{m||(A&&k&&function(O,q,H){if(An(),!ji)return;let K={status:q.status,statusText:q.statusText,headers:new Ne.Headers};q.headers.forEach((le,he)=>K.headers.set(he,le));let J=Tn(q.headers.get("Cache-Control")||"");if(J["no-store"])return;J["max-age"]&&K.headers.set("Expires",new Date(H+1e3*J["max-age"]).toUTCString());let Q=K.headers.get("Expires");Q&&(new Date(Q).getTime()-H<42e4||function(le,he){if(wr===void 0)try{new Response(new ReadableStream),wr=!0}catch{wr=!1}wr?he(le.body):le.blob().then(he)}(q,le=>{let he=new Ne.Response(le,K);An(),ji&&ji.then(fe=>fe.put(fo(O.url),he)).catch(fe=>bt(fe.message))}))}(u,A,k),p=!0,s(null,L,S.headers.get("Cache-Control"),S.headers.get("Expires")))}).catch(L=>{m||s(new Error(L.message))})};return g?function(S,A){if(An(),!ji)return A(null);let k=fo(S.url);ji.then(L=>{L.match(k).then(O=>{let q=function(H){if(!H)return!1;let K=new Date(H.headers.get("Expires")||0),J=Tn(H.headers.get("Cache-Control")||"");return K>Date.now()&&!J["no-cache"]}(O);L.delete(k),q&&L.put(k,O.clone()),A(null,O,q)}).catch(A)}).catch(A)}(u,v):v(null,null),{cancel:()=>{m=!0,p||c.abort()}}}(i,e);if(Fi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e,void 0,!0)}var r;return function(n,s){let c=new Ne.XMLHttpRequest;c.open(n.method||"GET",n.url,!0),n.type==="arrayBuffer"&&(c.responseType="arraybuffer");for(let u in n.headers)c.setRequestHeader(u,n.headers[u]);return n.type==="json"&&(c.responseType="text",c.setRequestHeader("Accept","application/json")),c.withCredentials=n.credentials==="include",c.onerror=()=>{s(new Error(c.statusText))},c.onload=()=>{if((c.status>=200&&c.status<300||c.status===0)&&c.response!==null){let u=c.response;if(n.type==="json")try{u=JSON.parse(c.response)}catch(p){return s(p)}s(null,u,c.getResponseHeader("Cache-Control"),c.getResponseHeader("Expires"))}else s(new I(c.statusText,c.status,n.url))},c.send(n.body),{cancel:()=>c.abort()}}(i,e)},Z=function(i,e){return R(Gt(i,{type:"arrayBuffer"}),e)},W=function(i,e){return R(Gt(i,{method:"POST"}),e)},te=function(i,e){return R(Gt(i,{method:"GET"}),e)};function ee(i){let e=Ne.document.createElement("a");return e.href=i,e.protocol===Ne.document.location.protocol&&e.host===Ne.document.location.host}let Y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=",ne,me;ne=[],me=0;let Me=function(i,e){if(vr.supported&&(i.headers||(i.headers={}),i.headers.accept="image/webp,*/*"),me>=ut.MAX_PARALLEL_IMAGE_REQUESTS){let c={requestParameters:i,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return ne.push(c),c}me++;let r=!1,n=()=>{if(!r)for(r=!0,me--;ne.length&&me<ut.MAX_PARALLEL_IMAGE_REQUESTS;){let c=ne.shift(),{requestParameters:u,callback:p,cancelled:m}=c;m||(c.cancel=Me(u,p).cancel)}},s=Z(i,(c,u,p,m)=>{n(),c?e(c):u&&(Ne.createImageBitmap?function(g,x){let v=new Ne.Blob([new Uint8Array(g)],{type:"image/png"});Ne.createImageBitmap(v).then(w=>{x(null,w)}).catch(w=>{x(new Error(`Could not load image because of ${w.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(u,(g,x)=>e(g,x,p,m)):function(g,x){let v=new Ne.Image,w=Ne.URL;v.onload=()=>{x(null,v),w.revokeObjectURL(v.src),v.onload=null,Ne.requestAnimationFrame(()=>{v.src=Y})},v.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."));let S=new Ne.Blob([new Uint8Array(g)],{type:"image/png"});v.src=g.byteLength?w.createObjectURL(S):Y}(u,(g,x)=>e(g,x,p,m)))});return{cancel:()=>{s.cancel(),n()}}};function ye(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function Ge(i,e,r){if(r&&r[i]){let n=r[i].indexOf(e);n!==-1&&r[i].splice(n,1)}}class Oe{constructor(e,r={}){Gt(this,r),this.type=e}}class Ue extends Oe{constructor(e,r={}){super("error",Gt({error:e},r))}}class $e{on(e,r){return this._listeners=this._listeners||{},ye(e,r,this._listeners),this}off(e,r){return Ge(e,r,this._listeners),Ge(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},ye(e,r,this._oneTimeListeners),this):new Promise(n=>this.once(e,n))}fire(e,r){typeof e=="string"&&(e=new Oe(e,r||{}));let n=e.type;if(this.listens(n)){e.target=this;let s=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(let p of s)p.call(this,e);let c=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(let p of c)Ge(n,p,this._oneTimeListeners),p.call(this,e);let u=this._eventedParent;u&&(Gt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),u.fire(e))}else e instanceof Ue&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,r){return this._eventedParent=e,this._eventedParentData=r,this}}var oe=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"}},"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},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"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":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","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}},"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":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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"}},"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":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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"}},"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":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"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"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function pt(i,...e){for(let r of e)for(let n in r)i[n]=r[n];return i}function Be(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function ct(i){if(Array.isArray(i))return i.map(ct);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){let e={};for(let r in i)e[r]=ct(i[r]);return e}return Be(i)}class dt extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}class tn{constructor(e,r=[]){this.parent=e,this.bindings={};for(let[n,s]of r)this.bindings[n]=s}concat(e){return new tn(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)}}let nr={kind:"null"},Ie={kind:"number"},rt={kind:"string"},Je={kind:"boolean"},Qi={kind:"color"},rn={kind:"object"},tt={kind:"value"},nn={kind:"collator"},zn={kind:"formatted"},ti={kind:"resolvedImage"};function Ei(i,e){return{kind:"array",itemType:i,N:e}}function Mt(i){if(i.kind==="array"){let e=Mt(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}let qc=[nr,Ie,rt,Je,Qi,zn,rn,Ei(tt),ti];function mo(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!mo(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(let r of qc)if(!mo(r,e))return null}}return`Expected ${Mt(i)} but found ${Mt(e)} instead.`}function os(i,e){return e.some(r=>r.kind===i.kind)}function kn(i,e){return e.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}function ss(i){var e={exports:{}};return i(e,e.exports),e.exports}var ra=ss(function(i,e){var r={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 n(p){return(p=Math.round(p))<0?0:p>255?255:p}function s(p){return n(p[p.length-1]==="%"?parseFloat(p)/100*255:parseInt(p))}function c(p){return(m=p[p.length-1]==="%"?parseFloat(p)/100:parseFloat(p))<0?0:m>1?1:m;var m}function u(p,m,g){return g<0?g+=1:g>1&&(g-=1),6*g<1?p+(m-p)*g*6:2*g<1?m:3*g<2?p+(m-p)*(2/3-g)*6:p}try{e.parseCSSColor=function(p){var m,g=p.replace(/ /g,"").toLowerCase();if(g in r)return r[g].slice();if(g[0]==="#")return g.length===4?(m=parseInt(g.substr(1),16))>=0&&m<=4095?[(3840&m)>>4|(3840&m)>>8,240&m|(240&m)>>4,15&m|(15&m)<<4,1]:null:g.length===7&&(m=parseInt(g.substr(1),16))>=0&&m<=16777215?[(16711680&m)>>16,(65280&m)>>8,255&m,1]:null;var x=g.indexOf("("),v=g.indexOf(")");if(x!==-1&&v+1===g.length){var w=g.substr(0,x),S=g.substr(x+1,v-(x+1)).split(","),A=1;switch(w){case"rgba":if(S.length!==4)return null;A=c(S.pop());case"rgb":return S.length!==3?null:[s(S[0]),s(S[1]),s(S[2]),A];case"hsla":if(S.length!==4)return null;A=c(S.pop());case"hsl":if(S.length!==3)return null;var k=(parseFloat(S[0])%360+360)%360/360,L=c(S[1]),O=c(S[2]),q=O<=.5?O*(L+1):O+L-O*L,H=2*O-q;return[n(255*u(H,q,k+1/3)),n(255*u(H,q,k)),n(255*u(H,q,k-1/3)),A];default:return null}}return null}}catch{}});class ht{constructor(e,r,n,s=1){this.r=e,this.g=r,this.b=n,this.a=s}static parse(e){if(!e)return;if(e instanceof ht)return e;if(typeof e!="string")return;let r=ra.parseCSSColor(e);return r?new ht(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){let[e,r,n,s]=this.toArray();return`rgba(${Math.round(e)},${Math.round(r)},${Math.round(n)},${s})`}toArray(){let{r:e,g:r,b:n,a:s}=this;return s===0?[0,0,0,0]:[255*e/s,255*r/s,255*n/s,s]}}ht.black=new ht(0,0,0,1),ht.white=new ht(1,1,1,1),ht.transparent=new ht(0,0,0,0),ht.red=new ht(1,0,0,1),ht.blue=new ht(0,0,1,1);class Dn{constructor(e,r,n){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class na{constructor(e,r,n,s,c){this.text=e.normalize?e.normalize():e,this.image=r,this.scale=n,this.fontStack=s,this.textColor=c}}class Ut{constructor(e){this.sections=e}static fromString(e){return new Ut([new na(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 Ut?e:Ut.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){let e=["format"];for(let r of this.sections){if(r.image){e.push(["image",r.image.name]);continue}e.push(r.text);let n={};r.fontStack&&(n["text-font"]=["literal",r.fontStack.split(",")]),r.scale&&(n["font-scale"]=r.scale),r.textColor&&(n["text-color"]=["rgba"].concat(r.textColor.toArray())),e.push(n)}return e}}class pi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new pi({name:e,available:!1}):null}serialize(){return["image",this.name]}}function Ni(i,e,r,n){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?n===void 0||typeof n=="number"&&n>=0&&n<=1?null:`Invalid rgba value [${[i,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof n=="number"?[i,e,r,n]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function as(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof ht||i instanceof Dn||i instanceof Ut||i instanceof pi)return!0;if(Array.isArray(i)){for(let e of i)if(!as(e))return!1;return!0}if(typeof i=="object"){for(let e in i)if(!as(i[e]))return!1;return!0}return!1}function Bt(i){if(i===null)return nr;if(typeof i=="string")return rt;if(typeof i=="boolean")return Je;if(typeof i=="number")return Ie;if(i instanceof ht)return Qi;if(i instanceof Dn)return nn;if(i instanceof Ut)return zn;if(i instanceof pi)return ti;if(Array.isArray(i)){let e=i.length,r;for(let n of i){let s=Bt(n);if(r){if(r===s)continue;r=tt;break}r=s}return Ei(r||tt,e)}return rn}function or(i){let e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof ht||i instanceof Ut||i instanceof pi?i.toString():JSON.stringify(i)}class sr{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!as(e[1]))return r.error("invalid value");let n=e[1],s=Bt(n),c=r.expectedType;return s.kind!=="array"||s.N!==0||!c||c.kind!=="array"||typeof c.N=="number"&&c.N!==0||(s=c),new sr(s,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 ht?["rgba"].concat(this.value.toArray()):this.value instanceof Ut?this.value.serialize():this.value}}class Wt{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}let oa={string:rt,number:Ie,boolean:Je,object:rn};class Gi{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let n,s=1,c=e[0];if(c==="array"){let p,m;if(e.length>2){let g=e[1];if(typeof g!="string"||!(g in oa)||g==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);p=oa[g],s++}else p=tt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);m=e[2],s++}n=Ei(p,m)}else n=oa[c];let u=[];for(;s<e.length;s++){let p=r.parse(e[s],s,tt);if(!p)return null;u.push(p)}return new Gi(n,u)}evaluate(e){for(let r=0;r<this.args.length;r++){let n=this.args[r].evaluate(e);if(!mo(this.type,Bt(n)))return n;if(r===this.args.length-1)throw new Wt(`Expected value to be of type ${Mt(this.type)}, but found ${Mt(Bt(n))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){let e=this.type,r=[e.kind];if(e.kind==="array"){let n=e.itemType;if(n.kind==="string"||n.kind==="number"||n.kind==="boolean"){r.push(n.kind);let s=e.N;(typeof s=="number"||this.args.length>1)&&r.push(s)}}return r.concat(this.args.map(n=>n.serialize()))}}class Pn{constructor(e){this.type=zn,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let n=e[1];if(!Array.isArray(n)&&typeof n=="object")return r.error("First argument must be an image or text section.");let s=[],c=!1;for(let u=1;u<=e.length-1;++u){let p=e[u];if(c&&typeof p=="object"&&!Array.isArray(p)){c=!1;let m=null;if(p["font-scale"]&&(m=r.parse(p["font-scale"],1,Ie),!m))return null;let g=null;if(p["text-font"]&&(g=r.parse(p["text-font"],1,Ei(rt)),!g))return null;let x=null;if(p["text-color"]&&(x=r.parse(p["text-color"],1,Qi),!x))return null;let v=s[s.length-1];v.scale=m,v.font=g,v.textColor=x}else{let m=r.parse(e[u],1,tt);if(!m)return null;let g=m.type.kind;if(g!=="string"&&g!=="value"&&g!=="null"&&g!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,s.push({content:m,scale:null,font:null,textColor:null})}}return new Pn(s)}evaluate(e){return new Ut(this.sections.map(r=>{let n=r.content.evaluate(e);return Bt(n)===ti?new na("",n,null,null,null):new na(or(n),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(let r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}serialize(){let e=["format"];for(let r of this.sections){e.push(r.content.serialize());let n={};r.scale&&(n["font-scale"]=r.scale.serialize()),r.font&&(n["text-font"]=r.font.serialize()),r.textColor&&(n["text-color"]=r.textColor.serialize()),e.push(n)}return e}}class Ln{constructor(e){this.type=ti,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");let n=r.parse(e[1],1,rt);return n?new Ln(n):r.error("No image name provided.")}evaluate(e){let r=this.input.evaluate(e),n=pi.fromString(r);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(r)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}let Xc={"to-boolean":Je,"to-color":Qi,"to-number":Ie,"to-string":rt};class Zi{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let n=e[0];if((n==="to-boolean"||n==="to-string")&&e.length!==2)return r.error("Expected one argument.");let s=Xc[n],c=[];for(let u=1;u<e.length;u++){let p=r.parse(e[u],u,tt);if(!p)return null;c.push(p)}return new Zi(s,c)}evaluate(e){if(this.type.kind==="boolean")return Boolean(this.args[0].evaluate(e));if(this.type.kind==="color"){let r,n;for(let s of this.args){if(r=s.evaluate(e),n=null,r instanceof ht)return r;if(typeof r=="string"){let c=e.parseColor(r);if(c)return c}else if(Array.isArray(r)&&(n=r.length<3||r.length>4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:Ni(r[0],r[1],r[2],r[3]),!n))return new ht(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Wt(n||`Could not parse color from value '${typeof r=="string"?r:String(JSON.stringify(r))}'`)}if(this.type.kind==="number"){let r=null;for(let n of this.args){if(r=n.evaluate(e),r===null)return 0;let s=Number(r);if(!isNaN(s))return s}throw new Wt(`Could not convert ${JSON.stringify(r)} to number.`)}return this.type.kind==="formatted"?Ut.fromString(or(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?pi.fromString(or(this.args[0].evaluate(e))):or(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 Pn([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Ln(this.args[0]).serialize();let e=[`to-${this.type.kind}`];return this.eachChild(r=>{e.push(r.serialize())}),e}}let Wc=["Unknown","Point","LineString","Polygon"];class vl{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&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Wc[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){let e=this.featureDistanceData.center,r=this.featureDistanceData.scale,{x:n,y:s}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*r-e[0])+this.featureDistanceData.bearing[1]*(s*r-e[1])}return 0}parseColor(e){let r=this._parseColorCache[e];return r||(r=this._parseColorCache[e]=ht.parse(e)),r}}class di{constructor(e,r,n,s){this.name=e,this.type=r,this._evaluate=n,this.args=s}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,r){let n=e[0],s=di.definitions[n];if(!s)return r.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);let c=Array.isArray(s)?s[0]:s.type,u=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,p=u.filter(([g])=>!Array.isArray(g)||g.length===e.length-1),m=null;for(let[g,x]of p){m=new Er(r.registry,r.path,null,r.scope);let v=[],w=!1;for(let S=1;S<e.length;S++){let A=e[S],k=Array.isArray(g)?g[S-1]:g.type,L=m.parse(A,1+v.length,k);if(!L){w=!0;break}v.push(L)}if(!w)if(Array.isArray(g)&&g.length!==v.length)m.error(`Expected ${g.length} arguments, but found ${v.length} instead.`);else{for(let S=0;S<v.length;S++){let A=Array.isArray(g)?g[S]:g.type,k=v[S];m.concat(S+1).checkSubtype(A,k.type)}if(m.errors.length===0)return new di(n,c,x,v)}}if(p.length===1)r.errors.push(...m.errors);else{let g=(p.length?p:u).map(([v])=>{return w=v,Array.isArray(w)?`(${w.map(Mt).join(", ")})`:`(${Mt(w.type)}...)`;var w}).join(" | "),x=[];for(let v=1;v<e.length;v++){let w=r.parse(e[v],1+x.length);if(!w)return null;x.push(Mt(w.type))}r.error(`Expected arguments of type ${g}, but found (${x.join(", ")}) instead.`)}return null}static register(e,r){di.definitions=r;for(let n in r)e[n]=di}}class ls{constructor(e,r,n){this.type=nn,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");let n=e[1];if(typeof n!="object"||Array.isArray(n))return r.error("Collator options argument must be an object.");let s=r.parse(n["case-sensitive"]!==void 0&&n["case-sensitive"],1,Je);if(!s)return null;let c=r.parse(n["diacritic-sensitive"]!==void 0&&n["diacritic-sensitive"],1,Je);if(!c)return null;let u=null;return n.locale&&(u=r.parse(n.locale,1,rt),!u)?null:new ls(s,c,u)}evaluate(e){return new Dn(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(){let e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}let Tr=8192;function sa(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function cs(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function bl(i,e){let r=(180+i[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(r*s*Tr),Math.round(n*s*Tr)]}function hs(i,e,r){let n=i[0]-e[0],s=i[1]-e[1],c=i[0]-r[0],u=i[1]-r[1];return n*u-c*s==0&&n*c<=0&&s*u<=0}function aa(i,e){let r=!1;for(let u=0,p=e.length;u<p;u++){let m=e[u];for(let g=0,x=m.length;g<x-1;g++){if(hs(i,m[g],m[g+1]))return!1;(s=m[g])[1]>(n=i)[1]!=(c=m[g+1])[1]>n[1]&&n[0]<(c[0]-s[0])*(n[1]-s[1])/(c[1]-s[1])+s[0]&&(r=!r)}}var n,s,c;return r}function Hc(i,e){for(let r=0;r<e.length;r++)if(aa(i,e[r]))return!0;return!1}function wl(i,e,r,n){let s=n[0]-r[0],c=n[1]-r[1],u=(i[0]-r[0])*c-s*(i[1]-r[1]),p=(e[0]-r[0])*c-s*(e[1]-r[1]);return u>0&&p<0||u<0&&p>0}function Yc(i,e,r){for(let g of r)for(let x=0;x<g.length-1;++x)if((p=[(u=g[x+1])[0]-(c=g[x])[0],u[1]-c[1]])[0]*(m=[(s=e)[0]-(n=i)[0],s[1]-n[1]])[1]-p[1]*m[0]!=0&&wl(n,s,c,u)&&wl(c,u,n,s))return!0;var n,s,c,u,p,m;return!1}function Tl(i,e){for(let r=0;r<i.length;++r)if(!aa(i[r],e))return!1;for(let r=0;r<i.length-1;++r)if(Yc(i[r],i[r+1],e))return!1;return!0}function Kc(i,e){for(let r=0;r<e.length;r++)if(Tl(i,e[r]))return!0;return!1}function us(i,e,r){let n=[];for(let s=0;s<i.length;s++){let c=[];for(let u=0;u<i[s].length;u++){let p=bl(i[s][u],r);sa(e,p),c.push(p)}n.push(c)}return n}function _o(i,e,r){let n=[];for(let s=0;s<i.length;s++){let c=us(i[s],e,r);n.push(c)}return n}function El(i,e,r,n){if(i[0]<r[0]||i[0]>r[2]){let s=.5*n,c=i[0]-r[0]>s?-n:r[0]-i[0]>s?n:0;c===0&&(c=i[0]-r[2]>s?-n:r[2]-i[0]>s?n:0),i[0]+=c}sa(e,i)}function Sl(i,e,r,n){let s=Math.pow(2,n.z)*Tr,c=[n.x*Tr,n.y*Tr],u=[];if(!i)return u;for(let p of i)for(let m of p){let g=[m.x+c[0],m.y+c[1]];El(g,e,r,s),u.push(g)}return u}function Il(i,e,r,n){let s=Math.pow(2,n.z)*Tr,c=[n.x*Tr,n.y*Tr],u=[];if(!i)return u;for(let m of i){let g=[];for(let x of m){let v=[x.x+c[0],x.y+c[1]];sa(e,v),g.push(v)}u.push(g)}if(e[2]-e[0]<=s/2){(p=e)[0]=p[1]=1/0,p[2]=p[3]=-1/0;for(let m of u)for(let g of m)El(g,e,r,s)}var p;return u}class on{constructor(e,r){this.type=Je,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(as(e[1])){let n=e[1];if(n.type==="FeatureCollection")for(let s=0;s<n.features.length;++s){let c=n.features[s].geometry.type;if(c==="Polygon"||c==="MultiPolygon")return new on(n,n.features[s].geometry)}else if(n.type==="Feature"){let s=n.geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new on(n,n.geometry)}else if(n.type==="Polygon"||n.type==="MultiPolygon")return new on(n,n)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,n){let s=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],u=r.canonicalID();if(!u)return!1;if(n.type==="Polygon"){let p=us(n.coordinates,c,u),m=Sl(r.geometry(),s,c,u);if(!cs(s,c))return!1;for(let g of m)if(!aa(g,p))return!1}if(n.type==="MultiPolygon"){let p=_o(n.coordinates,c,u),m=Sl(r.geometry(),s,c,u);if(!cs(s,c))return!1;for(let g of m)if(!Hc(g,p))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,n){let s=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],u=r.canonicalID();if(!u)return!1;if(n.type==="Polygon"){let p=us(n.coordinates,c,u),m=Il(r.geometry(),s,c,u);if(!cs(s,c))return!1;for(let g of m)if(!Tl(g,p))return!1}if(n.type==="MultiPolygon"){let p=_o(n.coordinates,c,u),m=Il(r.geometry(),s,c,u);if(!cs(s,c))return!1;for(let g of m)if(!Kc(g,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function oi(i){if(i instanceof di&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof on)return!1;let e=!0;return i.eachChild(r=>{e&&!oi(r)&&(e=!1)}),e}function go(i){if(i instanceof di&&i.name==="feature-state")return!1;let e=!0;return i.eachChild(r=>{e&&!go(r)&&(e=!1)}),e}function yo(i,e){if(i instanceof di&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(n=>{r&&!yo(n,e)&&(r=!1)}),r}class sn{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");let n=e[1];return r.scope.has(n)?new sn(n,r.scope.get(n)):r.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]}}class Er{constructor(e,r=[],n,s=new tn,c=[]){this.registry=e,this.path=r,this.key=r.map(u=>`[${u}]`).join(""),this.scope=s,this.errors=c,this.expectedType=n}parse(e,r,n,s,c={}){return r?this.concat(r,n,s)._parse(e,c):this._parse(e,c)}_parse(e,r){function n(s,c,u){return u==="assert"?new Gi(c,[s]):u==="coerce"?new Zi(c,[s]):s}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", []].');let s=e[0];if(typeof s!="string")return this.error(`Expression name must be a string, but found ${typeof s} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let c=this.registry[s];if(c){let u=c.parse(e,this);if(!u)return null;if(this.expectedType){let p=this.expectedType,m=u.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 u=n(u,p,r.typeAnnotation||"coerce");else u=n(u,p,r.typeAnnotation||"assert")}if(!(u instanceof sr)&&u.type.kind!=="resolvedImage"&&ps(u)){let p=new vl;try{u=new sr(u.type,u.evaluate(p))}catch(m){return this.error(m.message),null}}return u}return this.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,n){let s=typeof e=="number"?this.path.concat(e):this.path,c=n?this.scope.concat(n):this.scope;return new Er(this.registry,s,r||null,c,this.errors)}error(e,...r){let n=`${this.key}${r.map(s=>`[${s}]`).join("")}`;this.errors.push(new dt(n,e))}checkSubtype(e,r){let n=mo(e,r);return n&&this.error(n),n}}function ps(i){if(i instanceof sn)return ps(i.boundExpression);if(i instanceof di&&i.name==="error"||i instanceof ls||i instanceof on)return!1;let e=i instanceof Zi||i instanceof Gi,r=!0;return i.eachChild(n=>{r=e?r&&ps(n):r&&n instanceof sr}),!!r&&oi(i)&&yo(i,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function xo(i,e){let r=i.length-1,n,s,c=0,u=r,p=0;for(;c<=u;)if(p=Math.floor((c+u)/2),n=i[p],s=i[p+1],n<=e){if(p===r||e<s)return p;c=p+1}else{if(!(n>e))throw new Wt("Input is not a number.");u=p-1}return 0}class vo{constructor(e,r,n){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(let[s,c]of n)this.labels.push(s),this.outputs.push(c)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");let n=r.parse(e[1],1,Ie);if(!n)return null;let s=[],c=null;r.expectedType&&r.expectedType.kind!=="value"&&(c=r.expectedType);for(let u=1;u<e.length;u+=2){let p=u===1?-1/0:e[u],m=e[u+1],g=u,x=u+1;if(typeof p!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',g);if(s.length&&s[s.length-1][0]>=p)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',g);let v=r.parse(m,x,c);if(!v)return null;c=c||v.type,s.push([p,v])}return new vo(c,n,s)}evaluate(e){let r=this.labels,n=this.outputs;if(r.length===1)return n[0].evaluate(e);let s=this.input.evaluate(e);if(s<=r[0])return n[0].evaluate(e);let c=r.length;return s>=r[c-1]?n[c-1].evaluate(e):n[xo(r,s)].evaluate(e)}eachChild(e){e(this.input);for(let r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e=["step",this.input.serialize()];for(let r=0;r<this.labels.length;r++)r>0&&e.push(this.labels[r]),e.push(this.outputs[r].serialize());return e}}function je(i,e,r){return i*(1-r)+e*r}var ds=Object.freeze({__proto__:null,number:je,color:function(i,e,r){return new ht(je(i.r,e.r,r),je(i.g,e.g,r),je(i.b,e.b,r),je(i.a,e.a,r))},array:function(i,e,r){return i.map((n,s)=>je(n,e[s],r))}});let Ml=.95047,Al=1.08883,la=4/29,ca=6/29,ha=3*ca*ca,Cl=Math.PI/180,zl=180/Math.PI;function fs(i){return i>.008856451679035631?Math.pow(i,1/3):i/ha+la}function Sr(i){return i>ca?i*i*i:ha*(i-la)}function Bn(i){return 255*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055)}function ua(i){return(i/=255)<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function ms(i){let e=ua(i.r),r=ua(i.g),n=ua(i.b),s=fs((.4124564*e+.3575761*r+.1804375*n)/Ml),c=fs((.2126729*e+.7151522*r+.072175*n)/1);return{l:116*c-16,a:500*(s-c),b:200*(c-fs((.0193339*e+.119192*r+.9503041*n)/Al)),alpha:i.a}}function pa(i){let e=(i.l+16)/116,r=isNaN(i.a)?e:e+i.a/500,n=isNaN(i.b)?e:e-i.b/200;return e=1*Sr(e),r=Ml*Sr(r),n=Al*Sr(n),new ht(Bn(3.2404542*r-1.5371385*e-.4985314*n),Bn(-.969266*r+1.8760108*e+.041556*n),Bn(.0556434*r-.2040259*e+1.0572252*n),i.alpha)}function Jc(i,e,r){let n=e-i;return i+r*(n>180||n<-180?n-360*Math.round(n/360):n)}let bo={forward:ms,reverse:pa,interpolate:function(i,e,r){return{l:je(i.l,e.l,r),a:je(i.a,e.a,r),b:je(i.b,e.b,r),alpha:je(i.alpha,e.alpha,r)}}},wo={forward:function(i){let{l:e,a:r,b:n}=ms(i),s=Math.atan2(n,r)*zl;return{h:s<0?s+360:s,c:Math.sqrt(r*r+n*n),l:e,alpha:i.a}},reverse:function(i){let e=i.h*Cl,r=i.c;return pa({l:i.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:i.alpha})},interpolate:function(i,e,r){return{h:Jc(i.h,e.h,r),c:je(i.c,e.c,r),l:je(i.l,e.l,r),alpha:je(i.alpha,e.alpha,r)}}};var da=Object.freeze({__proto__:null,lab:bo,hcl:wo});class fi{constructor(e,r,n,s,c){this.type=e,this.operator=r,this.interpolation=n,this.input=s,this.labels=[],this.outputs=[];for(let[u,p]of c)this.labels.push(u),this.outputs.push(p)}static interpolationFactor(e,r,n,s){let c=0;if(e.name==="exponential")c=_s(r,e.base,n,s);else if(e.name==="linear")c=_s(r,1,n,s);else if(e.name==="cubic-bezier"){let u=e.controlPoints;c=new mr(u[0],u[1],u[2],u[3]).solve(_s(r,1,n,s))}return c}static parse(e,r){let[n,s,c,...u]=e;if(!Array.isArray(s)||s.length===0)return r.error("Expected an interpolation type expression.",1);if(s[0]==="linear")s={name:"linear"};else if(s[0]==="exponential"){let g=s[1];if(typeof g!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:g}}else{if(s[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(s[0])}`,1,0);{let g=s.slice(1);if(g.length!==4||g.some(x=>typeof x!="number"||x<0||x>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:g}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(c=r.parse(c,2,Ie),!c)return null;let p=[],m=null;n==="interpolate-hcl"||n==="interpolate-lab"?m=Qi:r.expectedType&&r.expectedType.kind!=="value"&&(m=r.expectedType);for(let g=0;g<u.length;g+=2){let x=u[g],v=u[g+1],w=g+3,S=g+4;if(typeof x!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',w);if(p.length&&p[p.length-1][0]>=x)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',w);let A=r.parse(v,S,m);if(!A)return null;m=m||A.type,p.push([x,A])}return m.kind==="number"||m.kind==="color"||m.kind==="array"&&m.itemType.kind==="number"&&typeof m.N=="number"?new fi(m,n,s,c,p):r.error(`Type ${Mt(m)} is not interpolatable.`)}evaluate(e){let r=this.labels,n=this.outputs;if(r.length===1)return n[0].evaluate(e);let s=this.input.evaluate(e);if(s<=r[0])return n[0].evaluate(e);let c=r.length;if(s>=r[c-1])return n[c-1].evaluate(e);let u=xo(r,s),p=fi.interpolationFactor(this.interpolation,s,r[u],r[u+1]),m=n[u].evaluate(e),g=n[u+1].evaluate(e);return this.operator==="interpolate"?ds[this.type.kind.toLowerCase()](m,g,p):this.operator==="interpolate-hcl"?wo.reverse(wo.interpolate(wo.forward(m),wo.forward(g),p)):bo.reverse(bo.interpolate(bo.forward(m),bo.forward(g),p))}eachChild(e){e(this.input);for(let r of this.outputs)e(r)}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);let r=[this.operator,e,this.input.serialize()];for(let n=0;n<this.labels.length;n++)r.push(this.labels[n],this.outputs[n].serialize());return r}}function _s(i,e,r,n){let s=n-r,c=i-r;return s===0?0:e===1?c/s:(Math.pow(e,c)-1)/(Math.pow(e,s)-1)}class To{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let n=null,s=r.expectedType;s&&s.kind!=="value"&&(n=s);let c=[];for(let p of e.slice(1)){let m=r.parse(p,1+c.length,n,void 0,{typeAnnotation:"omit"});if(!m)return null;n=n||m.type,c.push(m)}let u=s&&c.some(p=>mo(s,p.type));return new To(u?tt:n,c)}evaluate(e){let r,n=null,s=0;for(let c of this.args){if(s++,n=c.evaluate(e),n&&n instanceof pi&&!n.available&&(r||(r=n),n=null,s===this.args.length))return r;if(n!==null)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){let e=["coalesce"];return this.eachChild(r=>{e.push(r.serialize())}),e}}class Eo{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let n=[];for(let c=1;c<e.length-1;c+=2){let u=e[c];if(typeof u!="string")return r.error(`Expected string, but found ${typeof u} instead.`,c);if(/[^a-zA-Z0-9_]/.test(u))return r.error("Variable names must contain only alphanumeric characters or '_'.",c);let p=r.parse(e[c+1],c+1);if(!p)return null;n.push([u,p])}let s=r.parse(e[e.length-1],e.length-1,r.expectedType,n);return s?new Eo(n,s):null}outputDefined(){return this.result.outputDefined()}serialize(){let e=["let"];for(let[r,n]of this.bindings)e.push(r,n.serialize());return e.push(this.result.serialize()),e}}class fa{constructor(e,r,n){this.type=e,this.index=r,this.input=n}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=r.parse(e[1],1,Ie),s=r.parse(e[2],2,Ei(r.expectedType||tt));return n&&s?new fa(s.type.itemType,n,s):null}evaluate(e){let r=this.index.evaluate(e),n=this.input.evaluate(e);if(r<0)throw new Wt(`Array index out of bounds: ${r} < 0.`);if(r>=n.length)throw new Wt(`Array index out of bounds: ${r} > ${n.length-1}.`);if(r!==Math.floor(r))throw new Wt(`Array index must be an integer, but found ${r} instead.`);return n[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class gs{constructor(e,r){this.type=Je,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let n=r.parse(e[1],1,tt),s=r.parse(e[2],2,tt);return n&&s?os(n.type,[Je,rt,Ie,nr,tt])?new gs(n,s):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Mt(n.type)} instead`):null}evaluate(e){let r=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(n==null)return!1;if(!kn(r,["boolean","string","number","null"]))throw new Wt(`Expected first argument to be of type boolean, string, number or null, but found ${Mt(Bt(r))} instead.`);if(!kn(n,["string","array"]))throw new Wt(`Expected second argument to be of type array or string, but found ${Mt(Bt(n))} instead.`);return n.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ys{constructor(e,r,n){this.type=Ie,this.needle=e,this.haystack=r,this.fromIndex=n}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let n=r.parse(e[1],1,tt),s=r.parse(e[2],2,tt);if(!n||!s)return null;if(!os(n.type,[Je,rt,Ie,nr,tt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Mt(n.type)} instead`);if(e.length===4){let c=r.parse(e[3],3,Ie);return c?new ys(n,s,c):null}return new ys(n,s)}evaluate(e){let r=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!kn(r,["boolean","string","number","null"]))throw new Wt(`Expected first argument to be of type boolean, string, number or null, but found ${Mt(Bt(r))} instead.`);if(!kn(n,["string","array"]))throw new Wt(`Expected second argument to be of type array or string, but found ${Mt(Bt(n))} instead.`);if(this.fromIndex){let s=this.fromIndex.evaluate(e);return n.indexOf(r,s)}return n.indexOf(r)}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){let e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class xs{constructor(e,r,n,s,c,u){this.inputType=e,this.type=r,this.input=n,this.cases=s,this.outputs=c,this.otherwise=u}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let n,s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);let c={},u=[];for(let g=2;g<e.length-1;g+=2){let x=e[g],v=e[g+1];Array.isArray(x)||(x=[x]);let w=r.concat(g);if(x.length===0)return w.error("Expected at least one branch label.");for(let A of x){if(typeof A!="number"&&typeof A!="string")return w.error("Branch labels must be numbers or strings.");if(typeof A=="number"&&Math.abs(A)>Number.MAX_SAFE_INTEGER)return w.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof A=="number"&&Math.floor(A)!==A)return w.error("Numeric branch labels must be integer values.");if(n){if(w.checkSubtype(n,Bt(A)))return null}else n=Bt(A);if(c[String(A)]!==void 0)return w.error("Branch labels must be unique.");c[String(A)]=u.length}let S=r.parse(v,g,s);if(!S)return null;s=s||S.type,u.push(S)}let p=r.parse(e[1],1,tt);if(!p)return null;let m=r.parse(e[e.length-1],e.length-1,s);return m?p.type.kind!=="value"&&r.concat(1).checkSubtype(n,p.type)?null:new xs(n,s,p,c,u,m):null}evaluate(e){let r=this.input.evaluate(e);return(Bt(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){let e=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),n=[],s={};for(let u of r){let p=s[this.cases[u]];p===void 0?(s[this.cases[u]]=n.length,n.push([this.cases[u],[u]])):n[p][1].push(u)}let c=u=>this.inputType.kind==="number"?Number(u):u;for(let[u,p]of n)e.push(p.length===1?c(p[0]):p.map(c)),e.push(this.outputs[u].serialize());return e.push(this.otherwise.serialize()),e}}class vs{constructor(e,r,n){this.type=e,this.branches=r,this.otherwise=n}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let n;r.expectedType&&r.expectedType.kind!=="value"&&(n=r.expectedType);let s=[];for(let u=1;u<e.length-1;u+=2){let p=r.parse(e[u],u,Je);if(!p)return null;let m=r.parse(e[u+1],u+1,n);if(!m)return null;s.push([p,m]),n=n||m.type}let c=r.parse(e[e.length-1],e.length-1,n);return c?new vs(n,s,c):null}evaluate(e){for(let[r,n]of this.branches)if(r.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[r,n]of this.branches)e(r),e(n);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.outputDefined())&&this.otherwise.outputDefined()}serialize(){let e=["case"];return this.eachChild(r=>{e.push(r.serialize())}),e}}class bs{constructor(e,r,n,s){this.type=e,this.input=r,this.beginIndex=n,this.endIndex=s}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);let n=r.parse(e[1],1,tt),s=r.parse(e[2],2,Ie);if(!n||!s)return null;if(!os(n.type,[Ei(tt),rt,tt]))return r.error(`Expected first argument to be of type array or string, but found ${Mt(n.type)} instead`);if(e.length===4){let c=r.parse(e[3],3,Ie);return c?new bs(n.type,n,s,c):null}return new bs(n.type,n,s)}evaluate(e){let r=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!kn(r,["string","array"]))throw new Wt(`Expected first argument to be of type array or string, but found ${Mt(Bt(r))} instead.`);if(this.endIndex){let s=this.endIndex.evaluate(e);return r.slice(n,s)}return r.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){let e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function kl(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Dl(i,e,r,n){return n.compare(e,r)===0}function Rn(i,e,r){let n=i!=="=="&&i!=="!=";return class wd{constructor(c,u,p){this.type=Je,this.lhs=c,this.rhs=u,this.collator=p,this.hasUntypedArgument=c.type.kind==="value"||u.type.kind==="value"}static parse(c,u){if(c.length!==3&&c.length!==4)return u.error("Expected two or three arguments.");let p=c[0],m=u.parse(c[1],1,tt);if(!m)return null;if(!kl(p,m.type))return u.concat(1).error(`"${p}" comparisons are not supported for type '${Mt(m.type)}'.`);let g=u.parse(c[2],2,tt);if(!g)return null;if(!kl(p,g.type))return u.concat(2).error(`"${p}" comparisons are not supported for type '${Mt(g.type)}'.`);if(m.type.kind!==g.type.kind&&m.type.kind!=="value"&&g.type.kind!=="value")return u.error(`Cannot compare types '${Mt(m.type)}' and '${Mt(g.type)}'.`);n&&(m.type.kind==="value"&&g.type.kind!=="value"?m=new Gi(g.type,[m]):m.type.kind!=="value"&&g.type.kind==="value"&&(g=new Gi(m.type,[g])));let x=null;if(c.length===4){if(m.type.kind!=="string"&&g.type.kind!=="string"&&m.type.kind!=="value"&&g.type.kind!=="value")return u.error("Cannot use collator to compare non-string types.");if(x=u.parse(c[3],3,nn),!x)return null}return new wd(m,g,x)}evaluate(c){let u=this.lhs.evaluate(c),p=this.rhs.evaluate(c);if(n&&this.hasUntypedArgument){let m=Bt(u),g=Bt(p);if(m.kind!==g.kind||m.kind!=="string"&&m.kind!=="number")throw new Wt(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${m.kind}, ${g.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){let m=Bt(u),g=Bt(p);if(m.kind!=="string"||g.kind!=="string")return e(c,u,p)}return this.collator?r(c,u,p,this.collator.evaluate(c)):e(c,u,p)}eachChild(c){c(this.lhs),c(this.rhs),this.collator&&c(this.collator)}outputDefined(){return!0}serialize(){let c=[i];return this.eachChild(u=>{c.push(u.serialize())}),c}}}let Qc=Rn("==",function(i,e,r){return e===r},Dl),eh=Rn("!=",function(i,e,r){return e!==r},function(i,e,r,n){return!Dl(0,e,r,n)}),Pl=Rn("<",function(i,e,r){return e<r},function(i,e,r,n){return n.compare(e,r)<0}),th=Rn(">",function(i,e,r){return e>r},function(i,e,r,n){return n.compare(e,r)>0}),ih=Rn("<=",function(i,e,r){return e<=r},function(i,e,r,n){return n.compare(e,r)<=0}),rh=Rn(">=",function(i,e,r){return e>=r},function(i,e,r,n){return n.compare(e,r)>=0});class ma{constructor(e,r,n,s,c){this.type=rt,this.number=e,this.locale=r,this.currency=n,this.minFractionDigits=s,this.maxFractionDigits=c}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");let n=r.parse(e[1],1,Ie);if(!n)return null;let s=e[2];if(typeof s!="object"||Array.isArray(s))return r.error("NumberFormat options argument must be an object.");let c=null;if(s.locale&&(c=r.parse(s.locale,1,rt),!c))return null;let u=null;if(s.currency&&(u=r.parse(s.currency,1,rt),!u))return null;let p=null;if(s["min-fraction-digits"]&&(p=r.parse(s["min-fraction-digits"],1,Ie),!p))return null;let m=null;return s["max-fraction-digits"]&&(m=r.parse(s["max-fraction-digits"],1,Ie),!m)?null:new ma(n,c,u,p,m)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){let e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.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 ws{constructor(e){this.type=Ie,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);let n=r.parse(e[1],1);return n?n.type.kind!=="array"&&n.type.kind!=="string"&&n.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${Mt(n.type)} instead.`):new ws(n):null}evaluate(e){let r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new Wt(`Expected value to be of type string or array, but found ${Mt(Bt(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){let e=["length"];return this.eachChild(r=>{e.push(r.serialize())}),e}}let an={"==":Qc,"!=":eh,">":th,"<":Pl,">=":rh,"<=":ih,array:Gi,at:fa,boolean:Gi,case:vs,coalesce:To,collator:ls,format:Pn,image:Ln,in:gs,"index-of":ys,interpolate:fi,"interpolate-hcl":fi,"interpolate-lab":fi,length:ws,let:Eo,literal:sr,match:xs,number:Gi,"number-format":ma,object:Gi,slice:bs,step:vo,string:Gi,"to-boolean":Zi,"to-color":Zi,"to-number":Zi,"to-string":Zi,var:sn,within:on};function _a(i,[e,r,n,s]){e=e.evaluate(i),r=r.evaluate(i),n=n.evaluate(i);let c=s?s.evaluate(i):1,u=Ni(e,r,n,c);if(u)throw new Wt(u);return new ht(e/255*c,r/255*c,n/255*c,c)}function Ll(i,e){return i in e}function ga(i,e){let r=e[i];return r===void 0?null:r}function Ir(i){return{type:i}}function ya(i){return{result:"success",value:i}}function ln(i){return{result:"error",value:i}}function Fn(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function Bl(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function xa(i){return!!i.expression&&i.expression.interpolated}function gt(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function cn(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Rl(i){return i}function va(i,e){let r=e.type==="color",n=i.stops&&typeof i.stops[0][0]=="object",s=n||!(n||i.property!==void 0),c=i.type||(xa(e)?"exponential":"interval");if(r&&((i=pt({},i)).stops&&(i.stops=i.stops.map(g=>[g[0],ht.parse(g[1])])),i.default=ht.parse(i.default?i.default:e.default)),i.colorSpace&&i.colorSpace!=="rgb"&&!da[i.colorSpace])throw new Error(`Unknown color space: ${i.colorSpace}`);let u,p,m;if(c==="exponential")u=ba;else if(c==="interval")u=oh;else if(c==="categorical"){u=nh,p=Object.create(null);for(let g of i.stops)p[g[0]]=g[1];m=typeof i.stops[0][0]}else{if(c!=="identity")throw new Error(`Unknown function type "${c}"`);u=Fl}if(n){let g={},x=[];for(let S=0;S<i.stops.length;S++){let A=i.stops[S],k=A[0].zoom;g[k]===void 0&&(g[k]={zoom:k,type:i.type,property:i.property,default:i.default,stops:[]},x.push(k)),g[k].stops.push([A[0].value,A[1]])}let v=[];for(let S of x)v.push([g[S].zoom,va(g[S],e)]);let w={name:"linear"};return{kind:"composite",interpolationType:w,interpolationFactor:fi.interpolationFactor.bind(void 0,w),zoomStops:v.map(S=>S[0]),evaluate:({zoom:S},A)=>ba({stops:v,base:i.base},e,S).evaluate(S,A)}}if(s){let g=c==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:g,interpolationFactor:fi.interpolationFactor.bind(void 0,g),zoomStops:i.stops.map(x=>x[0]),evaluate:({zoom:x})=>u(i,e,x,p,m)}}return{kind:"source",evaluate(g,x){let v=x&&x.properties?x.properties[i.property]:void 0;return v===void 0?So(i.default,e.default):u(i,e,v,p,m)}}}function So(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function nh(i,e,r,n,s){return So(typeof r===s?n[r]:void 0,i.default,e.default)}function oh(i,e,r){if(gt(r)!=="number")return So(i.default,e.default);let n=i.stops.length;if(n===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[n-1][0])return i.stops[n-1][1];let s=xo(i.stops.map(c=>c[0]),r);return i.stops[s][1]}function ba(i,e,r){let n=i.base!==void 0?i.base:1;if(gt(r)!=="number")return So(i.default,e.default);let s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];let c=xo(i.stops.map(x=>x[0]),r),u=function(x,v,w,S){let A=S-w,k=x-w;return A===0?0:v===1?k/A:(Math.pow(v,k)-1)/(Math.pow(v,A)-1)}(r,n,i.stops[c][0],i.stops[c+1][0]),p=i.stops[c][1],m=i.stops[c+1][1],g=ds[e.type]||Rl;if(i.colorSpace&&i.colorSpace!=="rgb"){let x=da[i.colorSpace];g=(v,w)=>x.reverse(x.interpolate(x.forward(v),x.forward(w),u))}return typeof p.evaluate=="function"?{evaluate(...x){let v=p.evaluate.apply(void 0,x),w=m.evaluate.apply(void 0,x);if(v!==void 0&&w!==void 0)return g(v,w,u)}}:g(p,m,u)}function Fl(i,e,r){return e.type==="color"?r=ht.parse(r):e.type==="formatted"?r=Ut.fromString(r.toString()):e.type==="resolvedImage"?r=pi.fromString(r.toString()):gt(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0),So(r,i.default,e.default)}di.register(an,{error:[{kind:"error"},[rt],(i,[e])=>{throw new Wt(e.evaluate(i))}],typeof:[rt,[tt],(i,[e])=>Mt(Bt(e.evaluate(i)))],"to-rgba":[Ei(Ie,4),[Qi],(i,[e])=>e.evaluate(i).toArray()],rgb:[Qi,[Ie,Ie,Ie],_a],rgba:[Qi,[Ie,Ie,Ie,Ie],_a],has:{type:Je,overloads:[[[rt],(i,[e])=>Ll(e.evaluate(i),i.properties())],[[rt,rn],(i,[e,r])=>Ll(e.evaluate(i),r.evaluate(i))]]},get:{type:tt,overloads:[[[rt],(i,[e])=>ga(e.evaluate(i),i.properties())],[[rt,rn],(i,[e,r])=>ga(e.evaluate(i),r.evaluate(i))]]},"feature-state":[tt,[rt],(i,[e])=>ga(e.evaluate(i),i.featureState||{})],properties:[rn,[],i=>i.properties()],"geometry-type":[rt,[],i=>i.geometryType()],id:[tt,[],i=>i.id()],zoom:[Ie,[],i=>i.globals.zoom],pitch:[Ie,[],i=>i.globals.pitch||0],"distance-from-center":[Ie,[],i=>i.distanceFromCenter()],"heatmap-density":[Ie,[],i=>i.globals.heatmapDensity||0],"line-progress":[Ie,[],i=>i.globals.lineProgress||0],"sky-radial-progress":[Ie,[],i=>i.globals.skyRadialProgress||0],accumulated:[tt,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Ie,Ir(Ie),(i,e)=>{let r=0;for(let n of e)r+=n.evaluate(i);return r}],"*":[Ie,Ir(Ie),(i,e)=>{let r=1;for(let n of e)r*=n.evaluate(i);return r}],"-":{type:Ie,overloads:[[[Ie,Ie],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[Ie],(i,[e])=>-e.evaluate(i)]]},"/":[Ie,[Ie,Ie],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[Ie,[Ie,Ie],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[Ie,[],()=>Math.LN2],pi:[Ie,[],()=>Math.PI],e:[Ie,[],()=>Math.E],"^":[Ie,[Ie,Ie],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[Ie,[Ie],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[Ie,[Ie],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[Ie,[Ie],(i,[e])=>Math.log(e.evaluate(i))],log2:[Ie,[Ie],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[Ie,[Ie],(i,[e])=>Math.sin(e.evaluate(i))],cos:[Ie,[Ie],(i,[e])=>Math.cos(e.evaluate(i))],tan:[Ie,[Ie],(i,[e])=>Math.tan(e.evaluate(i))],asin:[Ie,[Ie],(i,[e])=>Math.asin(e.evaluate(i))],acos:[Ie,[Ie],(i,[e])=>Math.acos(e.evaluate(i))],atan:[Ie,[Ie],(i,[e])=>Math.atan(e.evaluate(i))],min:[Ie,Ir(Ie),(i,e)=>Math.min(...e.map(r=>r.evaluate(i)))],max:[Ie,Ir(Ie),(i,e)=>Math.max(...e.map(r=>r.evaluate(i)))],abs:[Ie,[Ie],(i,[e])=>Math.abs(e.evaluate(i))],round:[Ie,[Ie],(i,[e])=>{let r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Ie,[Ie],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[Ie,[Ie],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Je,[rt,tt],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Je,[tt],(i,[e])=>i.id()===e.value],"filter-type-==":[Je,[rt],(i,[e])=>i.geometryType()===e.value],"filter-<":[Je,[rt,tt],(i,[e,r])=>{let n=i.properties()[e.value],s=r.value;return typeof n==typeof s&&n<s}],"filter-id-<":[Je,[tt],(i,[e])=>{let r=i.id(),n=e.value;return typeof r==typeof n&&r<n}],"filter->":[Je,[rt,tt],(i,[e,r])=>{let n=i.properties()[e.value],s=r.value;return typeof n==typeof s&&n>s}],"filter-id->":[Je,[tt],(i,[e])=>{let r=i.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Je,[rt,tt],(i,[e,r])=>{let n=i.properties()[e.value],s=r.value;return typeof n==typeof s&&n<=s}],"filter-id-<=":[Je,[tt],(i,[e])=>{let r=i.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Je,[rt,tt],(i,[e,r])=>{let n=i.properties()[e.value],s=r.value;return typeof n==typeof s&&n>=s}],"filter-id->=":[Je,[tt],(i,[e])=>{let r=i.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Je,[tt],(i,[e])=>e.value in i.properties()],"filter-has-id":[Je,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Je,[Ei(rt)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Je,[Ei(tt)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Je,[rt,Ei(tt)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Je,[rt,Ei(tt)],(i,[e,r])=>function(n,s,c,u){for(;c<=u;){let p=c+u>>1;if(s[p]===n)return!0;s[p]>n?u=p-1:c=p+1}return!1}(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Je,overloads:[[[Je,Je],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[Ir(Je),(i,e)=>{for(let r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Je,overloads:[[[Je,Je],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[Ir(Je),(i,e)=>{for(let r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Je,[Je],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Je,[rt],(i,[e])=>{let r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[rt,[rt],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[rt,[rt],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[rt,Ir(tt),(i,e)=>e.map(r=>or(r.evaluate(i))).join("")],"resolved-locale":[rt,[nn],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Ts{constructor(e,r){this.expression=e,this._warningHistory={},this._evaluator=new vl,this._defaultValue=r?function(n){return n.type==="color"&&cn(n.default)?new ht(0,0,0,0):n.type==="color"?ht.parse(n.default)||null:n.default===void 0?null:n.default}(r):null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,n,s,c,u,p,m){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=n,this._evaluator.canonical=s||null,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null,this.expression.evaluate(this._evaluator)}evaluate(e,r,n,s,c,u,p,m){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=n||null,this._evaluator.canonical=s||null,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u||null,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null;try{let g=this.expression.evaluate(this._evaluator);if(g==null||typeof g=="number"&&g!=g)return this._defaultValue;if(this._enumValues&&!(g in this._enumValues))throw new Wt(`Expected value to be one of ${Object.keys(this._enumValues).map(x=>JSON.stringify(x)).join(", ")}, but found ${JSON.stringify(g)} instead.`);return g}catch(g){return this._warningHistory[g.message]||(this._warningHistory[g.message]=!0,typeof console<"u"&&console.warn(g.message)),this._defaultValue}}}function On(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in an}function Io(i,e){let r=new Er(an,[],e?function(s){let c={color:Qi,string:rt,number:Ie,enum:rt,boolean:Je,formatted:zn,resolvedImage:ti};return s.type==="array"?Ei(c[s.value]||tt,s.length):c[s.type]}(e):void 0),n=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?ya(new Ts(n,e)):ln(r.errors)}class wa{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!go(r.expression)}evaluateWithoutErrorHandling(e,r,n,s,c,u){return this._styleExpression.evaluateWithoutErrorHandling(e,r,n,s,c,u)}evaluate(e,r,n,s,c,u){return this._styleExpression.evaluate(e,r,n,s,c,u)}}class Ta{constructor(e,r,n,s){this.kind=e,this.zoomStops=n,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!go(r.expression),this.interpolationType=s}evaluateWithoutErrorHandling(e,r,n,s,c,u){return this._styleExpression.evaluateWithoutErrorHandling(e,r,n,s,c,u)}evaluate(e,r,n,s,c,u){return this._styleExpression.evaluate(e,r,n,s,c,u)}interpolationFactor(e,r,n){return this.interpolationType?fi.interpolationFactor(this.interpolationType,e,r,n):0}}function Ol(i,e){if((i=Io(i,e)).result==="error")return i;let r=i.value.expression,n=oi(r);if(!n&&!Fn(e))return ln([new dt("","data expressions not supported")]);let s=yo(r,["zoom","pitch","distance-from-center"]);if(!s&&!Bl(e))return ln([new dt("","zoom expressions not supported")]);let c=Ss(r);return c||s?c instanceof dt?ln([c]):c instanceof fi&&!xa(e)?ln([new dt("",'"interpolate" expressions cannot be used with this property')]):ya(c?new Ta(n?"camera":"composite",i.value,c.labels,c instanceof fi?c.interpolation:void 0):new wa(n?"constant":"source",i.value)):ln([new dt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Es{constructor(e,r){this._parameters=e,this._specification=r,pt(this,va(this._parameters,this._specification))}static deserialize(e){return new Es(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Ss(i){let e=null;if(i instanceof Eo)e=Ss(i.result);else if(i instanceof To){for(let r of i.args)if(e=Ss(r),e)break}else(i instanceof vo||i instanceof fi)&&i.input instanceof di&&i.input.name==="zoom"&&(e=i);return e instanceof dt||i.eachChild(r=>{let n=Ss(r);n instanceof dt?e=n:!e&&n?e=new dt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new dt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class Ae{constructor(e,r,n,s){this.message=(e?`${e}: `:"")+n,s&&(this.identifier=s),r!=null&&r.__line__&&(this.line=r.__line__)}}function Si(i){let e=i.key,r=i.value,n=i.valueSpec||{},s=i.objectElementValidators||{},c=i.style,u=i.styleSpec,p=[],m=gt(r);if(m!=="object")return[new Ae(e,r,`object expected, ${m} found`)];for(let g in r){let x=g.split(".")[0],v=n[x]||n["*"],w;s[x]?w=s[x]:n[x]?w=Zt:s["*"]?w=s["*"]:n["*"]&&(w=Zt),w?p=p.concat(w({key:(e&&`${e}.`)+g,value:r[g],valueSpec:v,style:c,styleSpec:u,object:r,objectKey:g},r)):p.push(new Ae(e,r[g],`unknown property "${g}"`))}for(let g in n)s[g]||n[g].required&&n[g].default===void 0&&r[g]===void 0&&p.push(new Ae(e,r,`missing required property "${g}"`));return p}function Mo(i){let e=i.value,r=i.valueSpec,n=i.style,s=i.styleSpec,c=i.key,u=i.arrayElementValidator||Zt;if(gt(e)!=="array")return[new Ae(c,e,`array expected, ${gt(e)} found`)];if(r.length&&e.length!==r.length)return[new Ae(c,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.length<r["min-length"])return[new Ae(c,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let p={type:r.value,values:r.values,minimum:r.minimum,maximum:r.maximum,function:void 0};s.$version<7&&(p.function=r.function),gt(r.value)==="object"&&(p=r.value);let m=[];for(let g=0;g<e.length;g++)m=m.concat(u({array:e,arrayIndex:g,value:e[g],valueSpec:p,style:n,styleSpec:s,key:`${c}[${g}]`}));return m}function Ul(i){let e=i.key,r=i.value,n=i.valueSpec,s=gt(r);if(s==="number"&&r!=r&&(s="NaN"),s!=="number")return[new Ae(e,r,`number expected, ${s} found`)];if("minimum"in n){let c=n.minimum;if(gt(n.minimum)==="array"&&(c=n.minimum[i.arrayIndex]),r<c)return[new Ae(e,r,`${r} is less than the minimum value ${c}`)]}if("maximum"in n){let c=n.maximum;if(gt(n.maximum)==="array"&&(c=n.maximum[i.arrayIndex]),r>c)return[new Ae(e,r,`${r} is greater than the maximum value ${c}`)]}return[]}function Vl(i){let e=i.valueSpec,r=Be(i.value.type),n,s,c,u={},p=r!=="categorical"&&i.value.property===void 0,m=!p,g=gt(i.value.stops)==="array"&>(i.value.stops[0])==="array"&>(i.value.stops[0][0])==="object",x=Si({key:i.key,value:i.value,valueSpec:i.styleSpec.function,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(S){if(r==="identity")return[new Ae(S.key,S.value,'identity function may not have a "stops" property')];let A=[],k=S.value;return A=A.concat(Mo({key:S.key,value:k,valueSpec:S.valueSpec,style:S.style,styleSpec:S.styleSpec,arrayElementValidator:v})),gt(k)==="array"&&k.length===0&&A.push(new Ae(S.key,k,"array must have at least one stop")),A},default:function(S){return Zt({key:S.key,value:S.value,valueSpec:e,style:S.style,styleSpec:S.styleSpec})}}});return r==="identity"&&p&&x.push(new Ae(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||x.push(new Ae(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!xa(i.valueSpec)&&x.push(new Ae(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(m&&!Fn(i.valueSpec)?x.push(new Ae(i.key,i.value,"property functions not supported")):p&&!Bl(i.valueSpec)&&x.push(new Ae(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!g||i.value.property!==void 0||x.push(new Ae(i.key,i.value,'"property" property is required')),x;function v(S){let A=[],k=S.value,L=S.key;if(gt(k)!=="array")return[new Ae(L,k,`array expected, ${gt(k)} found`)];if(k.length!==2)return[new Ae(L,k,`array length 2 expected, length ${k.length} found`)];if(g){if(gt(k[0])!=="object")return[new Ae(L,k,`object expected, ${gt(k[0])} found`)];if(k[0].zoom===void 0)return[new Ae(L,k,"object stop key must have zoom")];if(k[0].value===void 0)return[new Ae(L,k,"object stop key must have value")];let O=Be(k[0].zoom);if(typeof O!="number")return[new Ae(L,k[0].zoom,"stop zoom values must be numbers")];if(c&&c>O)return[new Ae(L,k[0].zoom,"stop zoom values must appear in ascending order")];O!==c&&(c=O,s=void 0,u={}),A=A.concat(Si({key:`${L}[0]`,value:k[0],valueSpec:{zoom:{}},style:S.style,styleSpec:S.styleSpec,objectElementValidators:{zoom:Ul,value:w}}))}else A=A.concat(w({key:`${L}[0]`,value:k[0],valueSpec:{},style:S.style,styleSpec:S.styleSpec},k));return On(ct(k[1]))?A.concat([new Ae(`${L}[1]`,k[1],"expressions are not allowed in function stops.")]):A.concat(Zt({key:`${L}[1]`,value:k[1],valueSpec:e,style:S.style,styleSpec:S.styleSpec}))}function w(S,A){let k=gt(S.value),L=Be(S.value),O=S.value!==null?S.value:A;if(n){if(k!==n)return[new Ae(S.key,O,`${k} stop domain type must match previous stop domain type ${n}`)]}else n=k;if(k!=="number"&&k!=="string"&&k!=="boolean"&&typeof L!="number"&&typeof L!="string"&&typeof L!="boolean")return[new Ae(S.key,O,"stop domain value must be a number, string, or boolean")];if(k!=="number"&&r!=="categorical"){let q=`number expected, ${k} found`;return Fn(e)&&r===void 0&&(q+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ae(S.key,O,q)]}return r!=="categorical"||k!=="number"||typeof L=="number"&&isFinite(L)&&Math.floor(L)===L?r!=="categorical"&&k==="number"&&typeof L=="number"&&typeof s=="number"&&s!==void 0&&L<s?[new Ae(S.key,O,"stop domain values must appear in ascending order")]:(s=L,r==="categorical"&&L in u?[new Ae(S.key,O,"stop domain values must be unique")]:(u[L]=!0,[])):[new Ae(S.key,O,`integer expected, found ${String(L)}`)]}}function Un(i){let e=(i.expressionContext==="property"?Ol:Io)(ct(i.value),i.valueSpec);if(e.result==="error")return e.value.map(n=>new Ae(`${i.key}${n.key}`,i.value,n.message));let r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new Ae(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!go(r))return[new Ae(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter")return ar(r,i);if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!yo(r,["zoom","feature-state"]))return[new Ae(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!oi(r))return[new Ae(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ar(i,e){let r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(let s of e.valueSpec.expression.parameters)r.delete(s);if(r.size===0)return[];let n=[];return i instanceof di&&r.has(i.name)?[new Ae(e.key,e.value,`["${i.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(i.eachChild(s=>{n.push(...ar(s,e))}),n)}function Ao(i){let e=i.key,r=i.value,n=i.valueSpec,s=[];return Array.isArray(n.values)?n.values.indexOf(Be(r))===-1&&s.push(new Ae(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(n.values).indexOf(Be(r))===-1&&s.push(new Ae(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),s}function Mr(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(let e of i.slice(1))if(!Mr(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function Ar(i,e="fill"){if(i==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Mr(i)||(i=Co(i));let r=i,n=!0;try{n=function(g){if(!Cr(g))return g;let x=ct(g);return jl(x),x=Ea(x),x}(r)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
|
|
2
|
-
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
|
|
3
|
-
and paste the contents of this message in the report.
|
|
4
|
-
Thank you!
|
|
5
|
-
Filter Expression:
|
|
6
|
-
${JSON.stringify(r,null,2)}
|
|
7
|
-
`)}let s=oe[`filter_${e}`],c=Io(n,s),u=null;if(c.result==="error")throw new Error(c.value.map(g=>`${g.key}: ${g.message}`).join(", "));u=(g,x,v)=>c.value.evaluate(g,x,{},v);let p=null,m=null;if(n!==r){let g=Io(r,s);if(g.result==="error")throw new Error(g.value.map(x=>`${x.key}: ${x.message}`).join(", "));p=(x,v,w,S,A)=>g.value.evaluate(x,v,{},w,void 0,void 0,S,A),m=!oi(g.value.expression)}return u=u,{filter:u,dynamicFilter:p||void 0,needGeometry:Is(n),needFeature:!!m}}function Ea(i){if(!Array.isArray(i))return i;let e=function(r){if(Nl.has(r[0])){for(let n=1;n<r.length;n++)if(Cr(r[n]))return!0}return r}(i);return e===!0?e:e.map(r=>Ea(r))}function jl(i){let e=!1,r=[];if(i[0]==="case"){for(let n=1;n<i.length-1;n+=2)e=e||Cr(i[n]),r.push(i[n+1]);r.push(i[i.length-1])}else if(i[0]==="match"){e=e||Cr(i[1]);for(let n=2;n<i.length-1;n+=2)r.push(i[n+1]);r.push(i[i.length-1])}else if(i[0]==="step"){e=e||Cr(i[1]);for(let n=1;n<i.length-1;n+=2)r.push(i[n+1])}e&&(i.length=0,i.push("any",...r));for(let n=1;n<i.length;n++)jl(i[n])}function Cr(i){if(!Array.isArray(i))return!1;if((e=i[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let r=1;r<i.length;r++)if(Cr(i[r]))return!0;return!1}let Nl=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Sa(i,e){return i<e?-1:i>e?1:0}function Is(i){if(!Array.isArray(i))return!1;if(i[0]==="within")return!0;for(let e=1;e<i.length;e++)if(Is(i[e]))return!0;return!1}function Co(i){if(!i)return!0;let e=i[0];return i.length<=1?e!=="any":e==="=="?zo(i[1],i[2],"=="):e==="!="?ko(zo(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?zo(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(Co))):e==="all"?["all"].concat(i.slice(1).map(Co)):e==="none"?["all"].concat(i.slice(1).map(Co).map(ko)):e==="in"?Ia(i[1],i.slice(2)):e==="!in"?ko(Ia(i[1],i.slice(2))):e==="has"?Ma(i[1]):e==="!has"?ko(Ma(i[1])):e!=="within"||i;var r}function zo(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function Ia(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",i,["literal",e.sort(Sa)]]:["filter-in-small",i,["literal",e]]}}function Ma(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function ko(i){return["!",i]}function zr(i){return Mr(ct(i.value))?Un(pt({},i,{expressionContext:"filter",valueSpec:i.styleSpec[`filter_${i.layerType||"fill"}`]})):Aa(i)}function Aa(i){let e=i.value,r=i.key;if(gt(e)!=="array")return[new Ae(r,e,`array expected, ${gt(e)} found`)];let n=i.styleSpec,s,c=[];if(e.length<1)return[new Ae(r,e,"filter array must have at least 1 element")];switch(c=c.concat(Ao({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:i.style,styleSpec:i.styleSpec})),Be(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Be(e[1])==="$type"&&c.push(new Ae(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&c.push(new Ae(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=gt(e[1]),s!=="string"&&c.push(new Ae(`${r}[1]`,e[1],`string expected, ${s} found`)));for(let u=2;u<e.length;u++)s=gt(e[u]),Be(e[1])==="$type"?c=c.concat(Ao({key:`${r}[${u}]`,value:e[u],valueSpec:n.geometry_type,style:i.style,styleSpec:i.styleSpec})):s!=="string"&&s!=="number"&&s!=="boolean"&&c.push(new Ae(`${r}[${u}]`,e[u],`string, number, or boolean expected, ${s} found`));break;case"any":case"all":case"none":for(let u=1;u<e.length;u++)c=c.concat(Aa({key:`${r}[${u}]`,value:e[u],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":s=gt(e[1]),e.length!==2?c.push(new Ae(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):s!=="string"&&c.push(new Ae(`${r}[1]`,e[1],`string expected, ${s} found`));break;case"within":s=gt(e[1]),e.length!==2?c.push(new Ae(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):s!=="object"&&c.push(new Ae(`${r}[1]`,e[1],`object expected, ${s} found`))}return c}function Ca(i,e){let r=i.key,n=i.style,s=i.styleSpec,c=i.value,u=i.objectKey,p=s[`${e}_${i.layerType}`];if(!p)return[];let m=u.match(/^(.*)-transition$/);if(e==="paint"&&m&&p[m[1]]&&p[m[1]].transition)return Zt({key:r,value:c,valueSpec:s.transition,style:n,styleSpec:s});let g=i.valueSpec||p[u];if(!g)return[new Ae(r,c,`unknown property "${u}"`)];let x;if(gt(c)==="string"&&Fn(g)&&!g.tokens&&(x=/^{([^}]+)}$/.exec(c)))return[new Ae(r,c,`"${u}" does not support interpolation syntax
|
|
8
|
-
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(x[1])} }\`.`)];let v=[];return i.layerType==="symbol"&&(u==="text-field"&&n&&!n.glyphs&&v.push(new Ae(r,c,'use of "text-field" requires a style "glyphs" property')),u==="text-font"&&cn(ct(c))&&Be(c.type)==="identity"&&v.push(new Ae(r,c,'"text-font" does not support identity functions'))),v.concat(Zt({key:i.key,value:c,valueSpec:g,style:n,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:u}))}function Ms(i){return Ca(i,"paint")}function za(i){return Ca(i,"layout")}function Gl(i){let e=[],r=i.value,n=i.key,s=i.style,c=i.styleSpec;r.type||r.ref||e.push(new Ae(n,r,'either "type" or "ref" is required'));let u=Be(r.type),p=Be(r.ref);if(r.id){let m=Be(r.id);for(let g=0;g<i.arrayIndex;g++){let x=s.layers[g];Be(x.id)===m&&e.push(new Ae(n,r.id,`duplicate layer id "${r.id}", previously used at line ${x.id.__line__}`))}}if("ref"in r){let m;["type","source","source-layer","filter","layout"].forEach(g=>{g in r&&e.push(new Ae(n,r[g],`"${g}" is prohibited for ref layers`))}),s.layers.forEach(g=>{Be(g.id)===p&&(m=g)}),m?m.ref?e.push(new Ae(n,r.ref,"ref cannot reference another ref layer")):u=Be(m.type):typeof p=="string"&&e.push(new Ae(n,r.ref,`ref layer "${p}" not found`))}else if(u!=="background"&&u!=="sky")if(r.source){let m=s.sources&&s.sources[r.source],g=m&&Be(m.type);m?g==="vector"&&u==="raster"?e.push(new Ae(n,r.source,`layer "${r.id}" requires a raster source`)):g==="raster"&&u!=="raster"?e.push(new Ae(n,r.source,`layer "${r.id}" requires a vector source`)):g!=="vector"||r["source-layer"]?g==="raster-dem"&&u!=="hillshade"?e.push(new Ae(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):u!=="line"||!r.paint||!r.paint["line-gradient"]||g==="geojson"&&m.lineMetrics||e.push(new Ae(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ae(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Ae(n,r.source,`source "${r.source}" not found`))}else e.push(new Ae(n,r,'missing required property "source"'));return e=e.concat(Si({key:n,value:r,valueSpec:c.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Zt({key:`${n}.type`,value:r.type,valueSpec:c.layer.type,style:i.style,styleSpec:i.styleSpec,object:r,objectKey:"type"}),filter:m=>zr(pt({layerType:u},m)),layout:m=>Si({layer:r,key:m.key,value:m.value,valueSpec:{},style:m.style,styleSpec:m.styleSpec,objectElementValidators:{"*":g=>za(pt({layerType:u},g))}}),paint:m=>Si({layer:r,key:m.key,value:m.value,valueSpec:{},style:m.style,styleSpec:m.styleSpec,objectElementValidators:{"*":g=>Ms(pt({layerType:u},g))}})}})),e}function lr(i){let e=i.value,r=i.key,n=gt(e);return n!=="string"?[new Ae(r,e,`string expected, ${n} found`)]:[]}let Zl={promoteId:function({key:i,value:e}){if(gt(e)==="string")return lr({key:i,value:e});{let r=[];for(let n in e)r.push(...lr({key:`${i}.${n}`,value:e[n]}));return r}}};function $l(i){let e=i.value,r=i.key,n=i.styleSpec,s=i.style;if(!e.type)return[new Ae(r,e,'"type" is required')];let c=Be(e.type),u;switch(c){case"vector":case"raster":case"raster-dem":return u=Si({key:r,value:e,valueSpec:n[`source_${c.replace("-","_")}`],style:i.style,styleSpec:n,objectElementValidators:Zl}),u;case"geojson":if(u=Si({key:r,value:e,valueSpec:n.source_geojson,style:s,styleSpec:n,objectElementValidators:Zl}),e.cluster)for(let p in e.clusterProperties){let[m,g]=e.clusterProperties[p],x=typeof m=="string"?[m,["accumulated"],["get",p]]:m;u.push(...Un({key:`${r}.${p}.map`,value:g,expressionContext:"cluster-map"})),u.push(...Un({key:`${r}.${p}.reduce`,value:x,expressionContext:"cluster-reduce"}))}return u;case"video":return Si({key:r,value:e,valueSpec:n.source_video,style:s,styleSpec:n});case"image":return Si({key:r,value:e,valueSpec:n.source_image,style:s,styleSpec:n});case"canvas":return[new Ae(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Ao({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:s,styleSpec:n})}}function ql(i){let e=i.value,r=i.styleSpec,n=r.light,s=i.style,c=[],u=gt(e);if(e===void 0)return c;if(u!=="object")return c=c.concat([new Ae("light",e,`object expected, ${u} found`)]),c;for(let p in e){let m=p.match(/^(.*)-transition$/);c=c.concat(m&&n[m[1]]&&n[m[1]].transition?Zt({key:p,value:e[p],valueSpec:r.transition,style:s,styleSpec:r}):n[p]?Zt({key:p,value:e[p],valueSpec:n[p],style:s,styleSpec:r}):[new Ae(p,e[p],`unknown property "${p}"`)])}return c}function Xl(i){let e=i.value,r=i.key,n=i.style,s=i.styleSpec,c=s.terrain,u=[],p=gt(e);if(e===void 0)return u;if(p!=="object")return u=u.concat([new Ae("terrain",e,`object expected, ${p} found`)]),u;for(let m in e){let g=m.match(/^(.*)-transition$/);u=u.concat(g&&c[g[1]]&&c[g[1]].transition?Zt({key:m,value:e[m],valueSpec:s.transition,style:n,styleSpec:s}):c[m]?Zt({key:m,value:e[m],valueSpec:c[m],style:n,styleSpec:s}):[new Ae(m,e[m],`unknown property "${m}"`)])}if(e.source){let m=n.sources&&n.sources[e.source],g=m&&Be(m.type);m?g!=="raster-dem"&&u.push(new Ae(r,e.source,`terrain cannot be used with a source of type ${String(g)}, it only be used with a "raster-dem" source type`)):u.push(new Ae(r,e.source,`source "${e.source}" not found`))}else u.push(new Ae(r,e,'terrain is missing required property "source"'));return u}function Wl(i){let e=i.value,r=i.style,n=i.styleSpec,s=n.fog,c=[],u=gt(e);if(e===void 0)return c;if(u!=="object")return c=c.concat([new Ae("fog",e,`object expected, ${u} found`)]),c;for(let p in e){let m=p.match(/^(.*)-transition$/);c=c.concat(m&&s[m[1]]&&s[m[1]].transition?Zt({key:p,value:e[p],valueSpec:n.transition,style:r,styleSpec:n}):s[p]?Zt({key:p,value:e[p],valueSpec:s[p],style:r,styleSpec:n}):[new Ae(p,e[p],`unknown property "${p}"`)])}return c}let Do={"*":()=>[],array:Mo,boolean:function(i){let e=i.value,r=i.key,n=gt(e);return n!=="boolean"?[new Ae(r,e,`boolean expected, ${n} found`)]:[]},number:Ul,color:function(i){let e=i.key,r=i.value,n=gt(r);return n!=="string"?[new Ae(e,r,`color expected, ${n} found`)]:ra.parseCSSColor(r)===null?[new Ae(e,r,`color expected, "${r}" found`)]:[]},enum:Ao,filter:zr,function:Vl,layer:Gl,object:Si,source:$l,light:ql,terrain:Xl,fog:Wl,string:lr,formatted:function(i){return lr(i).length===0?[]:Un(i)},resolvedImage:function(i){return lr(i).length===0?[]:Un(i)},projection:function(i){let e=i.value,r=i.styleSpec,n=r.projection,s=i.style,c=[],u=gt(e);if(u==="object")for(let p in e)c=c.concat(Zt({key:p,value:e[p],valueSpec:n[p],style:s,styleSpec:r}));else u!=="string"&&(c=c.concat([new Ae("projection",e,`object or string expected, ${u} found`)]));return c}};function Zt(i){let e=i.value,r=i.valueSpec,n=i.styleSpec;return r.expression&&cn(Be(e))?Vl(i):r.expression&&On(ct(e))?Un(i):r.type&&Do[r.type]?Do[r.type](i):Si(pt({},i,{valueSpec:r.type?n[r.type]:r}))}function mi(i){let e=i.value,r=i.key,n=lr(i);return n.length||(e.indexOf("{fontstack}")===-1&&n.push(new Ae(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&n.push(new Ae(r,e,'"glyphs" url must include a "{range}" token'))),n}function Po(i,e=oe){return cr(Zt({key:"",value:i,valueSpec:e.$root,styleSpec:e,style:i,objectElementValidators:{glyphs:mi,"*":()=>[]}}))}let sh=i=>cr(Ms(i)),ah=i=>cr(za(i));function cr(i){return i.slice().sort((e,r)=>e.line&&r.line?e.line-r.line:0)}function Hl(i,e){let r=!1;if(e&&e.length)for(let n of e)i.fire(new Ue(new Error(n.message))),r=!0;return r}var kr=er;function er(i,e,r){var n=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(e=s[1])+2*(r=s[2]);for(var c=0;c<this.d*this.d;c++){var u=s[3+c],p=s[3+c+1];n.push(u===p?null:s.subarray(u,p))}var m=s[3+n.length+1];this.keys=s.subarray(s[3+n.length],m),this.bboxes=s.subarray(m),this.insert=this._insertReadonly}else{this.d=e+2*r;for(var g=0;g<this.d*this.d;g++)n.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=i,this.padding=r,this.scale=e/i,this.uid=0;var x=r/e*i;this.min=-x,this.max=i+x}er.prototype.insert=function(i,e,r,n,s){this._forEachCell(e,r,n,s,this._insertCell,this.uid++),this.keys.push(i),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(n),this.bboxes.push(s)},er.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},er.prototype._insertCell=function(i,e,r,n,s,c){this.cells[s].push(c)},er.prototype.query=function(i,e,r,n,s){var c=this.min,u=this.max;if(i<=c&&e<=c&&u<=r&&u<=n&&!s)return Array.prototype.slice.call(this.keys);var p=[];return this._forEachCell(i,e,r,n,this._queryCell,p,{},s),p},er.prototype._queryCell=function(i,e,r,n,s,c,u,p){var m=this.cells[s];if(m!==null)for(var g=this.keys,x=this.bboxes,v=0;v<m.length;v++){var w=m[v];if(u[w]===void 0){var S=4*w;(p?p(x[S+0],x[S+1],x[S+2],x[S+3]):i<=x[S+2]&&e<=x[S+3]&&r>=x[S+0]&&n>=x[S+1])?(u[w]=!0,c.push(g[w])):u[w]=!1}}},er.prototype._forEachCell=function(i,e,r,n,s,c,u,p){for(var m=this._convertToCellCoord(i),g=this._convertToCellCoord(e),x=this._convertToCellCoord(r),v=this._convertToCellCoord(n),w=m;w<=x;w++)for(var S=g;S<=v;S++){var A=this.d*S+w;if((!p||p(this._convertFromCellCoord(w),this._convertFromCellCoord(S),this._convertFromCellCoord(w+1),this._convertFromCellCoord(S+1)))&&s.call(this,i,e,r,n,A,c,u,p))return}},er.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},er.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},er.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,e=3+this.cells.length+1+1,r=0,n=0;n<this.cells.length;n++)r+=this.cells[n].length;var s=new Int32Array(e+r+this.keys.length+this.bboxes.length);s[0]=this.extent,s[1]=this.n,s[2]=this.padding;for(var c=e,u=0;u<i.length;u++){var p=i[u];s[3+u]=c,s.set(p,c),c+=p.length}return s[3+i.length]=c,s.set(this.keys,c),s[3+i.length+1]=c+=this.keys.length,s.set(this.bboxes,c),c+=this.bboxes.length,s.buffer};let Vn={};function ze(i,e,r={}){Object.defineProperty(i,"_classRegistryKey",{value:e,writeable:!1}),Vn[e]={klass:i,omit:r.omit||[]}}ze(Object,"Object"),kr.serialize=function(i,e){let r=i.toArrayBuffer();return e&&e.push(r),{buffer:r}},kr.deserialize=function(i){return new kr(i.buffer)},Object.defineProperty(kr,"name",{value:"Grid"}),ze(kr,"Grid"),ze(ht,"Color"),ze(Error,"Error"),ze(I,"AJAXError"),ze(pi,"ResolvedImage"),ze(Es,"StylePropertyFunction"),ze(Ts,"StyleExpression",{omit:["_evaluator"]}),ze(Ta,"ZoomDependentExpression"),ze(wa,"ZoomConstantExpression"),ze(di,"CompoundExpression",{omit:["_evaluate"]});for(let i in an)Vn[an[i]._classRegistryKey]||ze(an[i],`Expression${i}`);function Yl(i){return i&&typeof ArrayBuffer<"u"&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}function As(i){return Ne.ImageBitmap&&i instanceof Ne.ImageBitmap}function Lo(i,e){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp)return i;if(Yl(i)||As(i))return e&&e.push(i),i;if(ArrayBuffer.isView(i)){let r=i;return e&&e.push(r.buffer),r}if(i instanceof Ne.ImageData)return e&&e.push(i.data.buffer),i;if(Array.isArray(i)){let r=[];for(let n of i)r.push(Lo(n,e));return r}if(typeof i=="object"){let r=i.constructor,n=r._classRegistryKey;if(!n)throw new Error(`can't serialize object of unregistered class ${n}`);let s=r.serialize?r.serialize(i,e):{};if(!r.serialize){for(let c in i)i.hasOwnProperty(c)&&(Vn[n].omit.indexOf(c)>=0||(s[c]=Lo(i[c],e)));i instanceof Error&&(s.message=i.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return n!=="Object"&&(s.$name=n),s}throw new Error("can't serialize object of type "+typeof i)}function jn(i){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||Yl(i)||As(i)||ArrayBuffer.isView(i)||i instanceof Ne.ImageData)return i;if(Array.isArray(i))return i.map(jn);if(typeof i=="object"){let e=i.$name||"Object",{klass:r}=Vn[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);let n=Object.create(r.prototype);for(let s of Object.keys(i))s!=="$name"&&(n[s]=jn(i[s]));return n}throw new Error("can't deserialize object of type "+typeof i)}class ka{constructor(){this.first=!0}update(e,r){let n=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoom<n&&(this.lastIntegerZoom=n,this.lastIntegerZoomTime=r),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=n,!0))}}let Kl=i=>i>=1536&&i<=1791,Cs=i=>i>=1872&&i<=1919,Bo=i=>i>=2208&&i<=2303,Da=i=>i>=11904&&i<=12031,Jl=i=>i>=12032&&i<=12255,Pa=i=>i>=12272&&i<=12287,zs=i=>i>=12288&&i<=12351,Ro=i=>i>=12352&&i<=12447,ks=i=>i>=12448&&i<=12543,Ql=i=>i>=12544&&i<=12591,ec=i=>i>=12704&&i<=12735,tc=i=>i>=12736&&i<=12783,La=i=>i>=12784&&i<=12799,ic=i=>i>=12800&&i<=13055,rc=i=>i>=13056&&i<=13311,nc=i=>i>=13312&&i<=19903,Ba=i=>i>=19968&&i<=40959,oc=i=>i>=40960&&i<=42127,sc=i=>i>=42128&&i<=42191,ac=i=>i>=44032&&i<=55215,Fo=i=>i>=63744&&i<=64255,Ra=i=>i>=64336&&i<=65023,lc=i=>i>=65040&&i<=65055,Nn=i=>i>=65072&&i<=65103,cc=i=>i>=65104&&i<=65135,Ds=i=>i>=65136&&i<=65279,Fa=i=>i>=65280&&i<=65519;function Ps(i){for(let e of i)if(Ls(e.charCodeAt(0)))return!0;return!1}function hc(i){for(let e of i)if(!uc(e.charCodeAt(0)))return!1;return!0}function uc(i){return!(Kl(i)||Cs(i)||Bo(i)||Ra(i)||Ds(i))}function Ls(i){return!(i!==746&&i!==747&&(i<4352||!(ec(i)||Ql(i)||Nn(i)&&!(i>=65097&&i<=65103)||Fo(i)||rc(i)||Da(i)||tc(i)||!(!zs(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||nc(i)||Ba(i)||ic(i)||(e=>e>=12592&&e<=12687)(i)||(e=>e>=43360&&e<=43391)(i)||(e=>e>=55216&&e<=55295)(i)||(e=>e>=4352&&e<=4607)(i)||ac(i)||Ro(i)||Pa(i)||(e=>e>=12688&&e<=12703)(i)||Jl(i)||La(i)||ks(i)&&i!==12540||!(!Fa(i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!cc(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||(e=>e>=5120&&e<=5759)(i)||(e=>e>=6320&&e<=6399)(i)||lc(i)||(e=>e>=19904&&e<=19967)(i)||oc(i)||sc(i))))}function Bs(i){return!(Ls(i)||function(e){return!!((r=>r>=128&&r<=255)(e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||(r=>r>=8192&&r<=8303)(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)||(r=>r>=8448&&r<=8527)(e)||(r=>r>=8528&&r<=8591)(e)||(r=>r>=8960&&r<=9215)(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)||(r=>r>=9216&&r<=9279)(e)&&e!==9251||(r=>r>=9280&&r<=9311)(e)||(r=>r>=9312&&r<=9471)(e)||(r=>r>=9632&&r<=9727)(e)||(r=>r>=9728&&r<=9983)(e)&&!(e>=9754&&e<=9759)||(r=>r>=11008&&r<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||zs(e)||ks(e)||(r=>r>=57344&&r<=63743)(e)||Nn(e)||cc(e)||Fa(e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(i))}function Rs(i){return i>=1424&&i<=2303||Ra(i)||Ds(i)}function lh(i,e){return!(!e&&Rs(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||(r=>r>=6016&&r<=6143)(i))}function ch(i){for(let e of i)if(Rs(e.charCodeAt(0)))return!0;return!1}let Oa="deferred",Oo="loading",Ua="loaded",Va=null,si="unavailable",_i=null,Uo=function(i){i&&typeof i=="string"&&i.indexOf("NetworkError")>-1&&(si="error"),Va&&Va(i)};function hn(){ja.fire(new Oe("pluginStateChange",{pluginStatus:si,pluginURL:_i}))}let ja=new $e,Fs=function(){return si},Gn=function(){if(si!==Oa||!_i)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");si=Oo,hn(),_i&&Z({url:_i},i=>{i?Uo(i):(si=Ua,hn())})},Ii={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>si===Ua||Ii.applyArabicShaping!=null,isLoading:()=>si===Oo,setState(i){si=i.pluginStatus,_i=i.pluginURL},isParsed:()=>Ii.applyArabicShaping!=null&&Ii.processBidirectionalText!=null&&Ii.processStyledBidirectionalText!=null,getPluginURL:()=>_i};class Tt{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ka,this.transition={},this.pitch=0)}isSupportedScript(e){return function(r,n){for(let s of r)if(!lh(s.charCodeAt(0),n))return!1;return!0}(e,Ii.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let e=this.zoom,r=e-Math.floor(e),n=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class Vo{constructor(e,r){this.property=e,this.value=r,this.expression=function(n,s){if(cn(n))return new Es(n,s);if(On(n)){let c=Ol(n,s);if(c.result==="error")throw new Error(c.value.map(u=>`${u.key}: ${u.message}`).join(", "));return c.value}{let c=n;return typeof n=="string"&&s.type==="color"&&(c=ht.parse(n)),{kind:"constant",evaluate:()=>c}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,n){return this.property.possiblyEvaluate(this,e,r,n)}}class Zn{constructor(e){this.property=e,this.value=new Vo(e,void 0)}transitioned(e,r){return new t(this.property,this.value,r,Gt({},e.transition,this.transition),e.now)}untransitioned(){return new t(this.property,this.value,null,{},0)}}class l{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return wi(this._values[e].value.value)}setValue(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new Zn(this._values[e].property)),this._values[e].value=new Vo(this._values[e].property,r===null?void 0:wi(r))}getTransition(e){return wi(this._values[e].transition)}setTransition(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new Zn(this._values[e].property)),this._values[e].transition=wi(r)||void 0}serialize(){let e={};for(let r of Object.keys(this._values)){let n=this.getValue(r);n!==void 0&&(e[r]=n);let s=this.getTransition(r);s!==void 0&&(e[`${r}-transition`]=s)}return e}transitioned(e,r){let n=new o(this._properties);for(let s of Object.keys(this._values))n._values[s]=this._values[s].transitioned(e,r._values[s]);return n}untransitioned(){let e=new o(this._properties);for(let r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class t{constructor(e,r,n,s,c){let u=s.delay||0,p=s.duration||0;c=c||0,this.property=e,this.value=r,this.begin=c+u,this.end=this.begin+p,e.specification.transition&&(s.delay||s.duration)&&(this.prior=n)}possiblyEvaluate(e,r,n){let s=e.now||0,c=this.value.possiblyEvaluate(e,r,n),u=this.prior;if(u){if(s>this.end)return this.prior=null,c;if(this.value.isDataDriven())return this.prior=null,c;if(s<this.begin)return u.possiblyEvaluate(e,r,n);{let p=(s-this.begin)/(this.end-this.begin);return this.property.interpolate(u.possiblyEvaluate(e,r,n),c,Nr(p))}}return c}}class o{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,n){let s=new f(this._properties);for(let c of Object.keys(this._values))s._values[c]=this._values[c].possiblyEvaluate(e,r,n);return s}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class h{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return wi(this._values[e].value)}setValue(e,r){this._values[e]=new Vo(this._values[e].property,r===null?void 0:wi(r))}serialize(){let e={};for(let r of Object.keys(this._values)){let n=this.getValue(r);n!==void 0&&(e[r]=n)}return e}possiblyEvaluate(e,r,n){let s=new f(this._properties);for(let c of Object.keys(this._values))s._values[c]=this._values[c].possiblyEvaluate(e,r,n);return s}}class d{constructor(e,r,n){this.property=e,this.value=r,this.parameters=n}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,n,s){return this.property.evaluate(this.value,this.parameters,e,r,n,s)}}class f{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class _{constructor(e){this.specification=e}possiblyEvaluate(e,r){return e.expression.evaluate(r)}interpolate(e,r,n){let s=ds[this.specification.type];return s?s(e,r,n):e}}class y{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,n,s){return new d(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},n,s)}:e.expression,r)}interpolate(e,r,n){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new d(this,{kind:"constant",value:void 0},e.parameters);let s=ds[this.specification.type];return s?new d(this,{kind:"constant",value:s(e.value.value,r.value.value,n)},e.parameters):e}evaluate(e,r,n,s,c,u){return e.kind==="constant"?e.value:e.evaluate(r,n,s,c,u)}}class b extends y{possiblyEvaluate(e,r,n,s){if(e.value===void 0)return new d(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){let c=e.expression.evaluate(r,null,{},n,s),u=e.property.specification.type==="resolvedImage"&&typeof c!="string"?c.name:c,p=this._calculate(u,u,u,r);return new d(this,{kind:"constant",value:p},r)}if(e.expression.kind==="camera"){let c=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new d(this,{kind:"constant",value:c},r)}return new d(this,e.expression,r)}evaluate(e,r,n,s,c,u){if(e.kind==="source"){let p=e.evaluate(r,n,s,c,u);return this._calculate(p,p,p,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},n,s),e.evaluate({zoom:Math.floor(r.zoom)},n,s),e.evaluate({zoom:Math.floor(r.zoom)+1},n,s),r):e.value}_calculate(e,r,n,s){return s.zoom>s.zoomHistory.lastIntegerZoom?{from:e,to:r,other:n}:{from:n,to:r,other:e}}interpolate(e){return e}}class T{constructor(e){this.specification=e}possiblyEvaluate(e,r,n,s){if(e.value!==void 0){if(e.expression.kind==="constant"){let c=e.expression.evaluate(r,null,{},n,s);return this._calculate(c,c,c,r)}return this._calculate(e.expression.evaluate(new Tt(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Tt(Math.floor(r.zoom),r)),e.expression.evaluate(new Tt(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,n,s){return s.zoom>s.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:n,to:r}}interpolate(e){return e}}class E{constructor(e){this.specification=e}possiblyEvaluate(e,r,n,s){return!!e.expression.evaluate(r,null,{},n,s)}interpolate(){return!1}}class M{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let r in e){let n=e[r];n.specification.overridable&&this.overridableProperties.push(r);let s=this.defaultPropertyValues[r]=new Vo(n,void 0),c=this.defaultTransitionablePropertyValues[r]=new Zn(n);this.defaultTransitioningPropertyValues[r]=c.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=s.possiblyEvaluate({})}}}function D(i,e){return 256*(i=at(Math.floor(i),0,255))+at(Math.floor(e),0,255)}ze(y,"DataDrivenProperty"),ze(_,"DataConstantProperty"),ze(b,"CrossFadedDataDrivenProperty"),ze(T,"CrossFadedProperty"),ze(E,"ColorRampProperty");let B={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class P{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class z{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_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 G(i,e=1){let r=0,n=0;return{members:i.map(s=>{let c=B[s.type].BYTES_PER_ELEMENT,u=r=F(r,Math.max(e,c)),p=s.components||1;return n=Math.max(n,c),r+=c*p,{name:s.name,type:s.type,components:p,offset:u}}),size:F(r,Math.max(n,e)),alignment:e}}function F(i,e){return Math.ceil(i/e)*e}class j extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){let n=this.length;return this.resize(n+1),this.emplace(n,e,r)}emplace(e,r,n){let s=2*e;return this.int16[s+0]=r,this.int16[s+1]=n,e}}j.prototype.bytesPerElement=4,ze(j,"StructArrayLayout2i4");class N extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,r,n)}emplace(e,r,n,s){let c=3*e;return this.int16[c+0]=r,this.int16[c+1]=n,this.int16[c+2]=s,e}}N.prototype.bytesPerElement=6,ze(N,"StructArrayLayout3i6");class $ extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,r,n,s)}emplace(e,r,n,s,c){let u=4*e;return this.int16[u+0]=r,this.int16[u+1]=n,this.int16[u+2]=s,this.int16[u+3]=c,e}}$.prototype.bytesPerElement=8,ze($,"StructArrayLayout4i8");class V extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c,u,p){let m=this.length;return this.resize(m+1),this.emplace(m,e,r,n,s,c,u,p)}emplace(e,r,n,s,c,u,p,m){let g=6*e,x=12*e,v=3*e;return this.int16[g+0]=r,this.int16[g+1]=n,this.uint8[x+4]=s,this.uint8[x+5]=c,this.uint8[x+6]=u,this.uint8[x+7]=p,this.float32[v+2]=m,e}}V.prototype.bytesPerElement=12,ze(V,"StructArrayLayout2i4ub1f12");class X extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,r,n,s)}emplace(e,r,n,s,c){let u=4*e;return this.float32[u+0]=r,this.float32[u+1]=n,this.float32[u+2]=s,this.float32[u+3]=c,e}}X.prototype.bytesPerElement=16,ze(X,"StructArrayLayout4f16");class ie extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c,u,p,m,g,x){let v=this.length;return this.resize(v+1),this.emplace(v,e,r,n,s,c,u,p,m,g,x)}emplace(e,r,n,s,c,u,p,m,g,x,v){let w=10*e;return this.uint16[w+0]=r,this.uint16[w+1]=n,this.uint16[w+2]=s,this.uint16[w+3]=c,this.uint16[w+4]=u,this.uint16[w+5]=p,this.uint16[w+6]=m,this.uint16[w+7]=g,this.uint16[w+8]=x,this.uint16[w+9]=v,e}}ie.prototype.bytesPerElement=20,ze(ie,"StructArrayLayout10ui20");class ae extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c,u,p,m){let g=this.length;return this.resize(g+1),this.emplace(g,e,r,n,s,c,u,p,m)}emplace(e,r,n,s,c,u,p,m,g){let x=8*e;return this.uint16[x+0]=r,this.uint16[x+1]=n,this.uint16[x+2]=s,this.uint16[x+3]=c,this.uint16[x+4]=u,this.uint16[x+5]=p,this.uint16[x+6]=m,this.uint16[x+7]=g,e}}ae.prototype.bytesPerElement=16,ze(ae,"StructArrayLayout8ui16");class ue extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,r,n,s,c,u)}emplace(e,r,n,s,c,u,p){let m=6*e;return this.int16[m+0]=r,this.int16[m+1]=n,this.int16[m+2]=s,this.int16[m+3]=c,this.int16[m+4]=u,this.int16[m+5]=p,e}}ue.prototype.bytesPerElement=12,ze(ue,"StructArrayLayout6i12");class ce extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L){let O=this.length;return this.resize(O+1),this.emplace(O,e,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L)}emplace(e,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L,O){let q=16*e;return this.int16[q+0]=r,this.int16[q+1]=n,this.int16[q+2]=s,this.int16[q+3]=c,this.uint16[q+4]=u,this.uint16[q+5]=p,this.uint16[q+6]=m,this.uint16[q+7]=g,this.int16[q+8]=x,this.int16[q+9]=v,this.int16[q+10]=w,this.int16[q+11]=S,this.int16[q+12]=A,this.int16[q+13]=k,this.int16[q+14]=L,this.int16[q+15]=O,e}}ce.prototype.bytesPerElement=32,ze(ce,"StructArrayLayout4i4ui4i4i32");class we extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,r,n)}emplace(e,r,n,s){let c=3*e;return this.float32[c+0]=r,this.float32[c+1]=n,this.float32[c+2]=s,e}}we.prototype.bytesPerElement=12,ze(we,"StructArrayLayout3f12");class re extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}re.prototype.bytesPerElement=4,ze(re,"StructArrayLayout1ul4");class Te extends z{_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,r,n,s,c,u,p,m,g,x,v,w,S){let A=this.length;return this.resize(A+1),this.emplace(A,e,r,n,s,c,u,p,m,g,x,v,w,S)}emplace(e,r,n,s,c,u,p,m,g,x,v,w,S,A){let k=20*e,L=10*e;return this.int16[k+0]=r,this.int16[k+1]=n,this.int16[k+2]=s,this.int16[k+3]=c,this.int16[k+4]=u,this.float32[L+3]=p,this.float32[L+4]=m,this.float32[L+5]=g,this.float32[L+6]=x,this.int16[k+14]=v,this.uint32[L+8]=w,this.uint16[k+18]=S,this.uint16[k+19]=A,e}}Te.prototype.bytesPerElement=40,ze(Te,"StructArrayLayout5i4f1i1ul2ui40");class ve extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c,u,p){let m=this.length;return this.resize(m+1),this.emplace(m,e,r,n,s,c,u,p)}emplace(e,r,n,s,c,u,p,m){let g=8*e;return this.int16[g+0]=r,this.int16[g+1]=n,this.int16[g+2]=s,this.int16[g+4]=c,this.int16[g+5]=u,this.int16[g+6]=p,this.int16[g+7]=m,e}}ve.prototype.bytesPerElement=16,ze(ve,"StructArrayLayout3i2i2i16");class Le extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c){let u=this.length;return this.resize(u+1),this.emplace(u,e,r,n,s,c)}emplace(e,r,n,s,c,u){let p=4*e,m=8*e;return this.float32[p+0]=r,this.float32[p+1]=n,this.float32[p+2]=s,this.int16[m+6]=c,this.int16[m+7]=u,e}}Le.prototype.bytesPerElement=16,ze(Le,"StructArrayLayout2f1f2i16");class pe extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,r,n,s)}emplace(e,r,n,s,c){let u=12*e,p=3*e;return this.uint8[u+0]=r,this.uint8[u+1]=n,this.float32[p+1]=s,this.float32[p+2]=c,e}}pe.prototype.bytesPerElement=12,ze(pe,"StructArrayLayout2ub2f12");class ke extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n){let s=this.length;return this.resize(s+1),this.emplace(s,e,r,n)}emplace(e,r,n,s){let c=3*e;return this.uint16[c+0]=r,this.uint16[c+1]=n,this.uint16[c+2]=s,e}}ke.prototype.bytesPerElement=6,ze(ke,"StructArrayLayout3ui6");class Ve extends z{_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,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L,O,q,H,K,J){let Q=this.length;return this.resize(Q+1),this.emplace(Q,e,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L,O,q,H,K,J)}emplace(e,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L,O,q,H,K,J,Q){let le=30*e,he=15*e,fe=60*e;return this.int16[le+0]=r,this.int16[le+1]=n,this.int16[le+2]=s,this.float32[he+2]=c,this.float32[he+3]=u,this.uint16[le+8]=p,this.uint16[le+9]=m,this.uint32[he+5]=g,this.uint32[he+6]=x,this.uint32[he+7]=v,this.uint16[le+16]=w,this.uint16[le+17]=S,this.uint16[le+18]=A,this.float32[he+10]=k,this.float32[he+11]=L,this.uint8[fe+48]=O,this.uint8[fe+49]=q,this.uint8[fe+50]=H,this.uint32[he+13]=K,this.int16[le+28]=J,this.uint8[fe+58]=Q,e}}Ve.prototype.bytesPerElement=60,ze(Ve,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class De extends z{_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,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L,O,q,H,K,J,Q,le,he,fe,ge,se,de,xe,Se){let be=this.length;return this.resize(be+1),this.emplace(be,e,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L,O,q,H,K,J,Q,le,he,fe,ge,se,de,xe,Se)}emplace(e,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L,O,q,H,K,J,Q,le,he,fe,ge,se,de,xe,Se,be){let Ee=38*e,Xe=19*e;return this.int16[Ee+0]=r,this.int16[Ee+1]=n,this.int16[Ee+2]=s,this.float32[Xe+2]=c,this.float32[Xe+3]=u,this.int16[Ee+8]=p,this.int16[Ee+9]=m,this.int16[Ee+10]=g,this.int16[Ee+11]=x,this.int16[Ee+12]=v,this.int16[Ee+13]=w,this.uint16[Ee+14]=S,this.uint16[Ee+15]=A,this.uint16[Ee+16]=k,this.uint16[Ee+17]=L,this.uint16[Ee+18]=O,this.uint16[Ee+19]=q,this.uint16[Ee+20]=H,this.uint16[Ee+21]=K,this.uint16[Ee+22]=J,this.uint16[Ee+23]=Q,this.uint16[Ee+24]=le,this.uint16[Ee+25]=he,this.uint16[Ee+26]=fe,this.uint16[Ee+27]=ge,this.uint16[Ee+28]=se,this.uint32[Xe+15]=de,this.float32[Xe+16]=xe,this.float32[Xe+17]=Se,this.float32[Xe+18]=be,e}}De.prototype.bytesPerElement=76,ze(De,"StructArrayLayout3i2f6i15ui1ul3f76");class Pe extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}Pe.prototype.bytesPerElement=4,ze(Pe,"StructArrayLayout1f4");class Ze extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c,u,p){let m=this.length;return this.resize(m+1),this.emplace(m,e,r,n,s,c,u,p)}emplace(e,r,n,s,c,u,p,m){let g=7*e;return this.float32[g+0]=r,this.float32[g+1]=n,this.float32[g+2]=s,this.float32[g+3]=c,this.float32[g+4]=u,this.float32[g+5]=p,this.float32[g+6]=m,e}}Ze.prototype.bytesPerElement=28,ze(Ze,"StructArrayLayout7f28");class Ye extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c){let u=this.length;return this.resize(u+1),this.emplace(u,e,r,n,s,c)}emplace(e,r,n,s,c,u){let p=5*e;return this.float32[p+0]=r,this.float32[p+1]=n,this.float32[p+2]=s,this.float32[p+3]=c,this.float32[p+4]=u,e}}Ye.prototype.bytesPerElement=20,ze(Ye,"StructArrayLayout5f20");class Fe extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,n,s){let c=this.length;return this.resize(c+1),this.emplace(c,e,r,n,s)}emplace(e,r,n,s,c){let u=6*e;return this.uint32[3*e+0]=r,this.uint16[u+2]=n,this.uint16[u+3]=s,this.uint16[u+4]=c,e}}Fe.prototype.bytesPerElement=12,ze(Fe,"StructArrayLayout1ul3ui12");class qe extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){let n=this.length;return this.resize(n+1),this.emplace(n,e,r)}emplace(e,r,n){let s=2*e;return this.uint16[s+0]=r,this.uint16[s+1]=n,e}}qe.prototype.bytesPerElement=4,ze(qe,"StructArrayLayout2ui4");class st extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}st.prototype.bytesPerElement=2,ze(st,"StructArrayLayout1ui2");class At extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){let n=this.length;return this.resize(n+1),this.emplace(n,e,r)}emplace(e,r,n){let s=2*e;return this.float32[s+0]=r,this.float32[s+1]=n,e}}At.prototype.bytesPerElement=8,ze(At,"StructArrayLayout2f8");class Kt extends z{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,n,s,c,u,p){let m=this.length;return this.resize(m+1),this.emplace(m,e,r,n,s,c,u,p)}emplace(e,r,n,s,c,u,p,m){let g=8*e,x=4*e;return this.int16[g+0]=r,this.int16[g+1]=n,this.int16[g+2]=s,this.int16[g+3]=c,this.int16[g+4]=u,this.int16[g+5]=p,this.float32[x+3]=m,e}}Kt.prototype.bytesPerElement=16,ze(Kt,"StructArrayLayout6i1f16");class Jt extends P{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Jt.prototype.size=12;class gi extends ue{get(e){return new Jt(this,e)}}ze(gi,"FillExtrusionExtArray");class $i extends P{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]}}$i.prototype.size=40;class hr extends Te{get(e){return new $i(this,e)}}ze(hr,"CollisionBoxArray");class Dr extends P{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}}Dr.prototype.size=60;class ur extends Ve{get(e){return new Dr(this,e)}}ze(ur,"PlacedSymbolArray");class zt extends P{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]}}zt.prototype.size=76;class Dt extends De{get(e){return new zt(this,e)}}ze(Dt,"SymbolInstanceArray");class ft extends Pe{getoffsetX(e){return this.float32[1*e+0]}}ze(ft,"GlyphOffsetArray");class Rt extends N{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}ze(Rt,"SymbolLineVertexArray");class yi extends P{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]}}yi.prototype.size=12;class Ct extends Fe{get(e){return new yi(this,e)}}ze(Ct,"FeatureIndexArray");class Mi extends P{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Mi.prototype.size=4;class jo extends qe{get(e){return new Mi(this,e)}}ze(jo,"FillExtrusionCentroidArray");class xi extends P{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}get a_scale(){return this._structArray.float32[this._pos4+3]}}xi.prototype.size=16;class un extends Kt{get(e){return new xi(this,e)}}ze(un,"CircleGlobeExtArray");let pc=G([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),Na=G([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var $n=ss(function(i){i.exports=function(e,r){var n,s,c,u,p,m,g,x;for(s=e.length-(n=3&e.length),c=r,p=3432918353,m=461845907,x=0;x<s;)g=255&e.charCodeAt(x)|(255&e.charCodeAt(++x))<<8|(255&e.charCodeAt(++x))<<16|(255&e.charCodeAt(++x))<<24,++x,c=27492+(65535&(u=5*(65535&(c=(c^=g=(65535&(g=(g=(65535&g)*p+(((g>>>16)*p&65535)<<16)&4294967295)<<15|g>>>17))*m+(((g>>>16)*m&65535)<<16)&4294967295)<<13|c>>>19))+((5*(c>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(g=0,n){case 3:g^=(255&e.charCodeAt(x+2))<<16;case 2:g^=(255&e.charCodeAt(x+1))<<8;case 1:c^=g=(65535&(g=(g=(65535&(g^=255&e.charCodeAt(x)))*p+(((g>>>16)*p&65535)<<16)&4294967295)<<15|g>>>17))*m+(((g>>>16)*m&65535)<<16)&4294967295}return c^=e.length,c=2246822507*(65535&(c^=c>>>16))+((2246822507*(c>>>16)&65535)<<16)&4294967295,c=3266489909*(65535&(c^=c>>>13))+((3266489909*(c>>>16)&65535)<<16)&4294967295,(c^=c>>>16)>>>0}}),hh=ss(function(i){i.exports=function(e,r){for(var n,s=e.length,c=r^s,u=0;s>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24))+((1540483477*(n>>>16)&65535)<<16),c=1540483477*(65535&c)+((1540483477*(c>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),s-=4,++u;switch(s){case 3:c^=(255&e.charCodeAt(u+2))<<16;case 2:c^=(255&e.charCodeAt(u+1))<<8;case 1:c=1540483477*(65535&(c^=255&e.charCodeAt(u)))+((1540483477*(c>>>16)&65535)<<16)}return c=1540483477*(65535&(c^=c>>>13))+((1540483477*(c>>>16)&65535)<<16),(c^=c>>>15)>>>0}}),Pr=$n,Ga=hh;Pr.murmur3=$n,Pr.murmur2=Ga;class dc{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,n,s){this.ids.push(gu(e)),this.positions.push(r,n,s)}getPositions(e){let r=gu(e),n=0,s=this.ids.length-1;for(;n<s;){let u=n+s>>1;this.ids[u]>=r?s=u:n=u+1}let c=[];for(;this.ids[n]===r;)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,r){let n=new Float64Array(e.ids),s=new Uint32Array(e.positions);return uh(n,s,0,n.length-1),r&&r.push(n.buffer,s.buffer),{ids:n,positions:s}}static deserialize(e){let r=new dc;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function gu(i){let e=+i;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Pr(String(i))}function uh(i,e,r,n){for(;r<n;){let s=i[r+n>>1],c=r-1,u=n+1;for(;;){do c++;while(i[c]<s);do u--;while(i[u]>s);if(c>=u)break;fc(i,c,u),fc(e,3*c,3*u),fc(e,3*c+1,3*u+1),fc(e,3*c+2,3*u+2)}u-r<n-u?(uh(i,e,r,u),r=u+1):(uh(i,e,u+1,n),n=u)}}function fc(i,e,r){let n=i[e];i[e]=i[r],i[r]=n}ze(dc,"FeaturePositionMap");class pn{constructor(e,r){this.gl=e.gl,this.location=r}}class mc extends pn{constructor(e,r){super(e,r),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class yu extends pn{constructor(e,r){super(e,r),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class xu extends pn{constructor(e,r){super(e,r),this.current=ht.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}let Ed=new Float32Array(16),Sd=new Float32Array(9),Id=new Float32Array(4);function ph(i){return[D(255*i.r,255*i.g),D(255*i.b,255*i.a)]}class Za{constructor(e,r,n){this.value=e,this.uniformNames=r.map(s=>`u_${s}`),this.type=n}setUniform(e,r,n){e.set(n.constantOr(this.value))}getBinding(e,r,n){return this.type==="color"?new xu(e,r):new mc(e,r)}}class Os{constructor(e,r){this.uniformNames=r.map(n=>`u_${n}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio||1,this.pixelRatioTo=e.pixelRatio||1,this.patternFrom=r.tl.concat(r.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,r,n,s){let c=s==="u_pattern_to"||s==="u_dash_to"?this.patternTo:s==="u_pattern_from"||s==="u_dash_from"?this.patternFrom:s==="u_pixel_ratio_to"?this.pixelRatioTo:s==="u_pixel_ratio_from"?this.pixelRatioFrom:null;c&&e.set(c)}getBinding(e,r,n){return n==="u_pattern_from"||n==="u_pattern_to"||n==="u_dash_from"||n==="u_dash_to"?new yu(e,r):new mc(e,r)}}class dn{constructor(e,r,n,s){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(c=>({name:`a_${c}`,type:"Float32",components:n==="color"?2:1,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,r,n,s,c,u){let p=this.paintVertexArray.length,m=this.expression.evaluate(new Tt(0),r,{},c,s,u);this.paintVertexArray.resize(e),this._setPaintValue(p,e,m)}updatePaintArray(e,r,n,s,c){let u=this.expression.evaluate({zoom:0},n,s,void 0,c);this._setPaintValue(e,r,u)}_setPaintValue(e,r,n){if(this.type==="color"){let s=ph(n);for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,s[0],s[1])}else{for(let s=e;s<r;s++)this.paintVertexArray.emplace(s,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 pr{constructor(e,r,n,s,c,u){this.expression=e,this.uniformNames=r.map(p=>`u_${p}_t`),this.type=n,this.useIntegerZoom=s,this.zoom=c,this.maxValue=0,this.paintVertexAttributes=r.map(p=>({name:`a_${p}`,type:"Float32",components:n==="color"?4:2,offset:0})),this.paintVertexArray=new u}populatePaintArray(e,r,n,s,c,u){let p=this.expression.evaluate(new Tt(this.zoom),r,{},c,s,u),m=this.expression.evaluate(new Tt(this.zoom+1),r,{},c,s,u),g=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(g,e,p,m)}updatePaintArray(e,r,n,s,c){let u=this.expression.evaluate({zoom:this.zoom},n,s,void 0,c),p=this.expression.evaluate({zoom:this.zoom+1},n,s,void 0,c);this._setPaintValue(e,r,u,p)}_setPaintValue(e,r,n,s){if(this.type==="color"){let c=ph(n),u=ph(s);for(let p=e;p<r;p++)this.paintVertexArray.emplace(p,c[0],c[1],u[0],u[1])}else{for(let c=e;c<r;c++)this.paintVertexArray.emplace(c,n,s);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r){let n=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,s=at(this.expression.interpolationFactor(n,this.zoom,this.zoom+1),0,1);e.set(s)}getBinding(e,r,n){return new mc(e,r)}}class qn{constructor(e,r,n,s,c,u,p){this.expression=e,this.type=n,this.useIntegerZoom=s,this.zoom=c,this.layerId=p,this.paintVertexAttributes=(n==="array"?Na:pc).members;for(let m=0;m<r.length;++m);this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(e,r,n){let s=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(s,e,r.patterns&&r.patterns[this.layerId],n)}updatePaintArray(e,r,n,s,c,u){this._setPaintValues(e,r,n.patterns&&n.patterns[this.layerId],u)}_setPaintValues(e,r,n,s){if(!s||!n)return;let{min:c,mid:u,max:p}=n,m=s[c],g=s[u],x=s[p];if(m&&g&&x)for(let v=e;v<r;v++)this._setPaintValue(this.zoomInPaintVertexArray,v,g,m),this._setPaintValue(this.zoomOutPaintVertexArray,v,g,x)}_setPaintValue(e,r,n,s){e.emplace(r,n.tl[0],n.tl[1],n.br[0],n.br[1],s.tl[0],s.tl[1],s.br[0],s.br[1],n.pixelRatio,s.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Xn{constructor(e,r,n=()=>!0){this.binders={},this._buffers=[];let s=[];for(let c in e.paint._values){if(!n(c))continue;let u=e.paint.get(c);if(!(u instanceof d&&Fn(u.property.specification)))continue;let p=Ad(c,e.type),m=u.value,g=u.property.specification.type,x=u.property.useIntegerZoom,v=u.property.specification["property-type"],w=v==="cross-faded"||v==="cross-faded-data-driven",S=String(c)==="line-dasharray"&&e.layout.get("line-cap").value.kind!=="constant";if(m.kind!=="constant"||S)if(m.kind==="source"||S||w){let A=vu(c,g,"source");this.binders[c]=w?new qn(m,p,g,x,r,A,e.id):new dn(m,p,g,A),s.push(`/a_${c}`)}else{let A=vu(c,g,"composite");this.binders[c]=new pr(m,p,g,x,r,A),s.push(`/z_${c}`)}else this.binders[c]=w?new Os(m.value,p):new Za(m.value,p,g),s.push(`/u_${c}`)}this.cacheKey=s.sort().join("")}getMaxValue(e){let r=this.binders[e];return r instanceof dn||r instanceof pr?r.maxValue:0}populatePaintArrays(e,r,n,s,c,u){for(let p in this.binders){let m=this.binders[p];(m instanceof dn||m instanceof pr||m instanceof qn)&&m.populatePaintArray(e,r,n,s,c,u)}}setConstantPatternPositions(e,r){for(let n in this.binders){let s=this.binders[n];s instanceof Os&&s.setConstantPatternPositions(e,r)}}updatePaintArrays(e,r,n,s,c,u){let p=!1;for(let m in e){let g=r.getPositions(m);for(let x of g){let v=n.feature(x.index);for(let w in this.binders){let S=this.binders[w];if((S instanceof dn||S instanceof pr||S instanceof qn)&&S.expression.isStateDependent===!0){let A=s.paint.get(w);S.expression=A.value,S.updatePaintArray(x.start,x.end,v,e[m],c,u),p=!0}}}}return p}defines(){let e=[];for(let r in this.binders){let n=this.binders[r];(n instanceof Za||n instanceof Os)&&e.push(...n.uniformNames.map(s=>`#define HAS_UNIFORM_${s}`))}return e}getBinderAttributes(){let e=[];for(let r in this.binders){let n=this.binders[r];if(n instanceof dn||n instanceof pr||n instanceof qn)for(let s=0;s<n.paintVertexAttributes.length;s++)e.push(n.paintVertexAttributes[s].name)}return e}getBinderUniforms(){let e=[];for(let r in this.binders){let n=this.binders[r];if(n instanceof Za||n instanceof Os||n instanceof pr)for(let s of n.uniformNames)e.push(s)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,r){let n=[];for(let s in this.binders){let c=this.binders[s];if(c instanceof Za||c instanceof Os||c instanceof pr){for(let u of c.uniformNames)if(r[u]){let p=c.getBinding(e,r[u],u);n.push({name:u,property:s,binding:p})}}}return n}setUniforms(e,r,n,s){for(let{name:c,property:u,binding:p}of r)this.binders[u].setUniform(p,s,n.get(u),c)}updatePaintBuffers(e){this._buffers=[];for(let r in this.binders){let n=this.binders[r];if(e&&n instanceof qn){let s=e.fromScale===2?n.zoomInPaintVertexBuffer:n.zoomOutPaintVertexBuffer;s&&this._buffers.push(s)}else(n instanceof dn||n instanceof pr)&&n.paintVertexBuffer&&this._buffers.push(n.paintVertexBuffer)}}upload(e){for(let r in this.binders){let n=this.binders[r];(n instanceof dn||n instanceof pr||n instanceof qn)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let r=this.binders[e];(r instanceof dn||r instanceof pr||r instanceof qn)&&r.destroy()}}}class No{constructor(e,r,n=()=>!0){this.programConfigurations={};for(let s of e)this.programConfigurations[s.id]=new Xn(s,r,n);this.needsUpload=!1,this._featureMap=new dc,this._bufferOffset=0}populatePaintArrays(e,r,n,s,c,u,p){for(let m in this.programConfigurations)this.programConfigurations[m].populatePaintArrays(e,r,s,c,u,p);r.id!==void 0&&this._featureMap.add(r.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,n,s,c){for(let u of n)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(e,this._featureMap,r,u,s,c)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}}let Md={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function Ad(i,e){return Md[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}let Cd={"line-pattern":{source:ie,composite:ie},"fill-pattern":{source:ie,composite:ie},"fill-extrusion-pattern":{source:ie,composite:ie},"line-dasharray":{source:ae,composite:ae}},zd={color:{source:At,composite:X},number:{source:Pe,composite:At}};function vu(i,e,r){let n=Cd[i];return n&&n[r]||zd[e][r]}ze(Za,"ConstantBinder"),ze(Os,"CrossFadedConstantBinder"),ze(dn,"SourceExpressionBinder"),ze(qn,"CrossFadedCompositeBinder"),ze(pr,"CompositeExpressionBinder"),ze(Xn,"ProgramConfiguration",{omit:["_buffers"]}),ze(No,"ProgramConfigurationSet");let _c="-transition";class dr extends $e{constructor(e,r){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=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),r.layout&&(this._unevaluatedLayout=new h(r.layout)),r.paint)){this._transitionablePaint=new l(r.paint);for(let n in e.paint)this.setPaintProperty(n,e.paint[n],{validate:!1});for(let n in e.layout)this.setLayoutProperty(n,e.layout[n],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new f(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,n={}){r!=null&&this._validate(ah,`layers.${this.id}.layout.${e}`,e,r,n)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return Ki(e,_c)?this._transitionablePaint.getTransition(e.slice(0,-_c.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,n={}){if(r!=null&&this._validate(sh,`layers.${this.id}.paint.${e}`,e,r,n))return!1;if(Ki(e,_c))return this._transitionablePaint.setTransition(e.slice(0,-_c.length),r||void 0),!1;{let s=this._transitionablePaint._values[e],c=s.property.specification["property-type"]==="cross-faded-data-driven",u=s.value.isDataDriven(),p=s.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);let m=this._transitionablePaint._values[e].value;return m.isDataDriven()||u||c||this._handleOverridablePaintPropertyUpdate(e,p,m)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,r,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,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){let 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),co(e,(r,n)=>!(r===void 0||n==="layout"&&!Object.keys(r).length||n==="paint"&&!Object.keys(r).length))}_validate(e,r,n,s,c={}){return(!c||c.validate!==!1)&&Hl(this,e.call(Po,{key:r,layerType:this.type,objectKey:n,value:s,styleSpec:oe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let e in this.paint._values){let r=this.paint.get(e);if(r instanceof d&&Fn(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Ar(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}let kd=G([{name:"a_pos",components:2,type:"Int16"}],4),Dd=G([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"},{name:"a_scale",components:1,type:"Float32"}]);class Pt{constructor(e=[]){this.segments=e}prepareSegment(e,r,n,s){let c=this.segments[this.segments.length-1];return e>Pt.MAX_VERTEX_ARRAY_LENGTH&&bt(`Max vertices per segment is ${Pt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!c||c.vertexLength+e>Pt.MAX_VERTEX_ARRAY_LENGTH||c.sortKey!==s)&&(c={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},s!==void 0&&(c.sortKey=s),this.segments.push(c)),c}get(){return this.segments}destroy(){for(let e of this.segments)for(let r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,n,s){return new Pt([{vertexOffset:e,primitiveOffset:r,vertexLength:n,primitiveLength:s,vaos:{},sortKey:0}])}}Pt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ze(Pt,"SegmentVector");var He=8192;class Wn{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):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 yt?new yt(e.lng,e.lat):yt.convert(e),this}setSouthWest(e){return this._sw=e instanceof yt?new yt(e.lng,e.lat):yt.convert(e),this}extend(e){let r=this._sw,n=this._ne,s,c;if(e instanceof yt)s=e,c=e;else{if(!(e instanceof Wn))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Wn.convert(e)):this.extend(yt.convert(e)):this;if(s=e._sw,c=e._ne,!s||!c)return this}return r||n?(r.lng=Math.min(s.lng,r.lng),r.lat=Math.min(s.lat,r.lat),n.lng=Math.max(c.lng,n.lng),n.lat=Math.max(c.lat,n.lat)):(this._sw=new yt(s.lng,s.lat),this._ne=new yt(c.lng,c.lat)),this}getCenter(){return new yt((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 yt(this.getWest(),this.getNorth())}getSouthEast(){return new yt(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:r,lat:n}=yt.convert(e),s=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&s}static convert(e){return!e||e instanceof Wn?e:new Wn(e)}}let dh=63710088e-1;class yt{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new yt(Yi(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let r=Math.PI/180,n=this.lat*r,s=e.lat*r,c=Math.sin(n)*Math.sin(s)+Math.cos(n)*Math.cos(s)*Math.cos((e.lng-this.lng)*r);return dh*Math.acos(Math.min(c,1))}toBounds(e=0){let r=360*e/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new Wn(new yt(this.lng-n,this.lat-r),new yt(this.lng+n,this.lat+r))}static convert(e){if(e instanceof yt)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new yt(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new yt(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>]")}}let bu=2*Math.PI*dh;function fh(i){return bu*Math.cos(i*Math.PI/180)}function $a(i){return(180+i)/360}function Us(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Vs(i,e){return i/fh(e)}function tr(i){return 360*i-180}function Qt(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}function wu(i,e){return i*fh(Qt(e))}let Lr=85.051129;class gc{constructor(e,r,n=0){this.x=+e,this.y=+r,this.z=+n}static fromLngLat(e,r=0){let n=yt.convert(e);return new gc($a(n.lng),Us(n.lat),Vs(r,n.lat))}toLngLat(){return new yt(tr(this.x),Qt(this.y))}toAltitude(){return wu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/bu*(e=Qt(this.y),1/Math.cos(e*Math.PI/180));var e}}function mh(i,e,r,n,s,c,u,p,m){let g=(e+n)/2,x=(r+s)/2,v=new _e(g,x);p(v),function(w,S,A,k,L,O){let q=A-L,H=k-O;return Math.abs((k-S)*q-(A-w)*H)/Math.hypot(q,H)}(v.x,v.y,c.x,c.y,u.x,u.y)>=m?(mh(i,e,r,g,x,c,v,p,m),mh(i,g,x,n,s,v,u,p,m)):i.push(u)}function Pd(i,e,r){let n=i[0],s=n.x,c=n.y;e(n);let u=[n];for(let p=1;p<i.length;p++){let m=i[p],{x:g,y:x}=m;e(m),mh(u,s,c,g,x,n,m,e,r),s=g,c=x,n=m}return u}let _h=Math.pow(2,14)-1,Tu=-_h-1;function Ld(i,e){let r=Math.round(i.x*e),n=Math.round(i.y*e);return i.x=at(r,Tu,_h),i.y=at(n,Tu,_h),(r<i.x||r>i.x+1||n<i.y||n>i.y+1)&&bt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),i}function fn(i,e,r){let n=i.loadGeometry(),s=i.extent,c=He/s;if(e&&r&&r.projection.isReprojectedInTileSpace){let u=1<<e.z,{scale:p,x:m,y:g,projection:x}=r,v=w=>{let S=tr((e.x+w.x/s)/u),A=Qt((e.y+w.y/s)/u),k=x.project(S,A);w.x=(k.x*p-m)*s,w.y=(k.y*p-g)*s};for(let w=0;w<n.length;w++)if(i.type!==1)n[w]=Pd(n[w],v,1);else{let S=[];for(let A of n[w])A.x<0||A.x>=s||A.y<0||A.y>=s||(v(A),S.push(A));n[w]=S}}for(let u of n)for(let p of u)Ld(p,c);return n}function Go(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?fn(i):[]}}function yc(i,e,r,n,s){i.emplaceBack(2*e+(n+1)/2,2*r+(s+1)/2)}function xc(i,e,r,n){i.emplaceBack(e.x,e.y,e.z,r[0]*16384,r[1]*16384,r[2]*16384,n)}class gh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new j,this.indexArray=new ke,this.segments=new Pt,this.programConfigurations=new No(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,n,s){let c=this.layers[0],u=[],p=null;c.type==="circle"&&(p=c.layout.get("circle-sort-key"));for(let{feature:g,id:x,index:v,sourceLayerIndex:w}of e){let S=this.layers[0]._featureFilter.needGeometry,A=Go(g,S);if(!this.layers[0]._featureFilter.filter(new Tt(this.zoom),A,n))continue;let k=p?p.evaluate(A,{},n):void 0,L={id:x,properties:g.properties,type:g.type,sourceLayerIndex:w,index:v,geometry:S?A.geometry:fn(g,n,s),patterns:{},sortKey:k};u.push(L)}p&&u.sort((g,x)=>g.sortKey-x.sortKey);let m=null;s.projection.name==="globe"&&(this.globeExtVertexArray=new un,m=s.projection);for(let g of u){let{geometry:x,index:v,sourceLayerIndex:w}=g,S=e[v].feature;this.addFeature(g,x,v,r.availableImages,n,m),r.featureIndex.insert(S,x,v,w,this.index)}}update(e,r,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,kd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Dd.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,r,n,s,c,u){for(let p of r)for(let m of p){let g=m.x,x=m.y;if(g<0||g>=He||x<0||x>=He)continue;if(u){let S=u.projectTilePoint(g,x,c),A=u.upVector(c,g,x),k=Qt((x/He+c.y)/(1<<c.z)),L=u.pixelsPerMeter(k,1)/Vs(1,k),O=this.globeExtVertexArray;xc(O,S,A,L),xc(O,S,A,L),xc(O,S,A,L),xc(O,S,A,L)}let v=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),w=v.vertexLength;yc(this.layoutVertexArray,g,x,-1,-1),yc(this.layoutVertexArray,g,x,1,-1),yc(this.layoutVertexArray,g,x,1,1),yc(this.layoutVertexArray,g,x,-1,1),this.indexArray.emplaceBack(w,w+1,w+2),this.indexArray.emplaceBack(w,w+3,w+2),v.vertexLength+=4,v.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},s,c)}}function Eu(i,e){for(let r=0;r<i.length;r++)if(js(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(js(i,e[r]))return!0;return!!yh(i,e)}function Bd(i,e,r){return!!js(i,e)||!!xh(e,i,r)}function Su(i,e){if(i.length===1)return Mu(e,i[0]);for(let r=0;r<e.length;r++){let n=e[r];for(let s=0;s<n.length;s++)if(js(i,n[s]))return!0}for(let r=0;r<i.length;r++)if(Mu(e,i[r]))return!0;for(let r=0;r<e.length;r++)if(yh(i,e[r]))return!0;return!1}function Rd(i,e,r){if(i.length>1){if(yh(i,e))return!0;for(let n=0;n<e.length;n++)if(xh(e[n],i,r))return!0}for(let n=0;n<i.length;n++)if(xh(i[n],e,r))return!0;return!1}function yh(i,e){if(i.length===0||e.length===0)return!1;for(let r=0;r<i.length-1;r++){let n=i[r],s=i[r+1];for(let c=0;c<e.length-1;c++)if(Fd(n,s,e[c],e[c+1]))return!0}return!1}function Fd(i,e,r,n){return Yt(i,r,n)!==Yt(e,r,n)&&Yt(i,e,r)!==Yt(i,e,n)}function xh(i,e,r){let n=r*r;if(e.length===1)return i.distSqr(e[0])<n;for(let s=1;s<e.length;s++)if(Iu(i,e[s-1],e[s])<n)return!0;return!1}function Iu(i,e,r){let n=e.distSqr(r);if(n===0)return i.distSqr(e);let s=((i.x-e.x)*(r.x-e.x)+(i.y-e.y)*(r.y-e.y))/n;return i.distSqr(s<0?e:s>1?r:r.sub(e)._mult(s)._add(e))}function Mu(i,e){let r,n,s,c=!1;for(let u=0;u<i.length;u++){r=i[u];for(let p=0,m=r.length-1;p<r.length;m=p++)n=r[p],s=r[m],n.y>e.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(c=!c)}return c}function js(i,e){let r=!1;for(let n=0,s=i.length-1;n<i.length;s=n++){let c=i[n],u=i[s];c.y>e.y!=u.y>e.y&&e.x<(u.x-c.x)*(e.y-c.y)/(u.y-c.y)+c.x&&(r=!r)}return r}function Au(i,e,r,n,s){for(let u of i)if(e<=u.x&&r<=u.y&&n>=u.x&&s>=u.y)return!0;let c=[new _e(e,r),new _e(e,s),new _e(n,s),new _e(n,r)];if(i.length>2){for(let u of c)if(js(i,u))return!0}for(let u=0;u<i.length-1;u++)if(Od(i[u],i[u+1],c))return!0;return!1}function Od(i,e,r){let n=r[0],s=r[2];if(i.x<n.x&&e.x<n.x||i.x>s.x&&e.x>s.x||i.y<n.y&&e.y<n.y||i.y>s.y&&e.y>s.y)return!1;let c=Yt(i,e,r[0]);return c!==Yt(i,e,r[1])||c!==Yt(i,e,r[2])||c!==Yt(i,e,r[3])}function Ns(i,e,r){let n=e.paint.get(i).value;return n.kind==="constant"?n.value:r.programConfigurations.get(e.id).getMaxValue(i)}function vc(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Cu(i,e,r,n,s){if(!e[0]&&!e[1])return i;let c=_e.convert(e)._mult(s);r==="viewport"&&c._rotate(-n);let u=[];for(let p=0;p<i.length;p++)u.push(i[p].sub(c));return u}function zu(i,e,r,n){let s=_e.convert(i)._mult(n);return e==="viewport"&&s._rotate(-r),s}ze(gh,"CircleBucket",{omit:["layers"]});let Ud=new M({"circle-sort-key":new y(oe.layout_circle["circle-sort-key"])});var Vd={paint:new M({"circle-radius":new y(oe.paint_circle["circle-radius"]),"circle-color":new y(oe.paint_circle["circle-color"]),"circle-blur":new y(oe.paint_circle["circle-blur"]),"circle-opacity":new y(oe.paint_circle["circle-opacity"]),"circle-translate":new _(oe.paint_circle["circle-translate"]),"circle-translate-anchor":new _(oe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new _(oe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new _(oe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new y(oe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new y(oe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new y(oe.paint_circle["circle-stroke-opacity"])}),layout:Ud},vh=1e-6,Ai=typeof Float32Array<"u"?Float32Array:Array;function ku(){var i=new Ai(9);return Ai!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[5]=0,i[6]=0,i[7]=0),i[0]=1,i[4]=1,i[8]=1,i}function Br(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function bh(i,e,r){var n=e[0],s=e[1],c=e[2],u=e[3],p=e[4],m=e[5],g=e[6],x=e[7],v=e[8],w=e[9],S=e[10],A=e[11],k=e[12],L=e[13],O=e[14],q=e[15],H=r[0],K=r[1],J=r[2],Q=r[3];return i[0]=H*n+K*p+J*v+Q*k,i[1]=H*s+K*m+J*w+Q*L,i[2]=H*c+K*g+J*S+Q*O,i[3]=H*u+K*x+J*A+Q*q,i[4]=(H=r[4])*n+(K=r[5])*p+(J=r[6])*v+(Q=r[7])*k,i[5]=H*s+K*m+J*w+Q*L,i[6]=H*c+K*g+J*S+Q*O,i[7]=H*u+K*x+J*A+Q*q,i[8]=(H=r[8])*n+(K=r[9])*p+(J=r[10])*v+(Q=r[11])*k,i[9]=H*s+K*m+J*w+Q*L,i[10]=H*c+K*g+J*S+Q*O,i[11]=H*u+K*x+J*A+Q*q,i[12]=(H=r[12])*n+(K=r[13])*p+(J=r[14])*v+(Q=r[15])*k,i[13]=H*s+K*m+J*w+Q*L,i[14]=H*c+K*g+J*S+Q*O,i[15]=H*u+K*x+J*A+Q*q,i}function Zo(i,e,r){var n,s,c,u,p,m,g,x,v,w,S,A,k=r[0],L=r[1],O=r[2];return e===i?(i[12]=e[0]*k+e[4]*L+e[8]*O+e[12],i[13]=e[1]*k+e[5]*L+e[9]*O+e[13],i[14]=e[2]*k+e[6]*L+e[10]*O+e[14],i[15]=e[3]*k+e[7]*L+e[11]*O+e[15]):(s=e[1],c=e[2],u=e[3],p=e[4],m=e[5],g=e[6],x=e[7],v=e[8],w=e[9],S=e[10],A=e[11],i[0]=n=e[0],i[1]=s,i[2]=c,i[3]=u,i[4]=p,i[5]=m,i[6]=g,i[7]=x,i[8]=v,i[9]=w,i[10]=S,i[11]=A,i[12]=n*k+p*L+v*O+e[12],i[13]=s*k+m*L+w*O+e[13],i[14]=c*k+g*L+S*O+e[14],i[15]=u*k+x*L+A*O+e[15]),i}function Hn(i,e,r){var n=r[0],s=r[1],c=r[2];return i[0]=e[0]*n,i[1]=e[1]*n,i[2]=e[2]*n,i[3]=e[3]*n,i[4]=e[4]*s,i[5]=e[5]*s,i[6]=e[6]*s,i[7]=e[7]*s,i[8]=e[8]*c,i[9]=e[9]*c,i[10]=e[10]*c,i[11]=e[11]*c,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i}function wh(i,e,r){var n=Math.sin(r),s=Math.cos(r),c=e[4],u=e[5],p=e[6],m=e[7],g=e[8],x=e[9],v=e[10],w=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=c*s+g*n,i[5]=u*s+x*n,i[6]=p*s+v*n,i[7]=m*s+w*n,i[8]=g*s-c*n,i[9]=x*s-u*n,i[10]=v*s-p*n,i[11]=w*s-m*n,i}function Th(i,e,r){var n=Math.sin(r),s=Math.cos(r),c=e[0],u=e[1],p=e[2],m=e[3],g=e[8],x=e[9],v=e[10],w=e[11];return e!==i&&(i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=c*s-g*n,i[1]=u*s-x*n,i[2]=p*s-v*n,i[3]=m*s-w*n,i[8]=c*n+g*s,i[9]=u*n+x*s,i[10]=p*n+v*s,i[11]=m*n+w*s,i}Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});var jd=bh;function Eh(){var i=new Ai(3);return Ai!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function Du(i){var e=new Ai(3);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e}function Pu(i){return Math.hypot(i[0],i[1],i[2])}function qa(i,e,r){var n=new Ai(3);return n[0]=i,n[1]=e,n[2]=r,n}function Lu(i,e,r){return i[0]=e[0]+r[0],i[1]=e[1]+r[1],i[2]=e[2]+r[2],i}function Bu(i,e,r){return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],i}function Ru(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i}function Sh(i,e,r){return i[0]=Math.min(e[0],r[0]),i[1]=Math.min(e[1],r[1]),i[2]=Math.min(e[2],r[2]),i}function Ih(i,e,r){return i[0]=Math.max(e[0],r[0]),i[1]=Math.max(e[1],r[1]),i[2]=Math.max(e[2],r[2]),i}function Xa(i,e,r){return i[0]=e[0]*r,i[1]=e[1]*r,i[2]=e[2]*r,i}function Mh(i,e,r,n){return i[0]=e[0]+r[0]*n,i[1]=e[1]+r[1]*n,i[2]=e[2]+r[2]*n,i}function Wa(i,e){var r=e[0],n=e[1],s=e[2],c=r*r+n*n+s*s;return c>0&&(c=1/Math.sqrt(c)),i[0]=e[0]*c,i[1]=e[1]*c,i[2]=e[2]*c,i}function Ha(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function Fu(i,e,r){var n=e[0],s=e[1],c=e[2],u=r[0],p=r[1],m=r[2];return i[0]=s*m-c*p,i[1]=c*u-n*m,i[2]=n*p-s*u,i}function $o(i,e,r){var n=e[0],s=e[1],c=e[2],u=r[3]*n+r[7]*s+r[11]*c+r[15];return i[0]=(r[0]*n+r[4]*s+r[8]*c+r[12])/(u=u||1),i[1]=(r[1]*n+r[5]*s+r[9]*c+r[13])/u,i[2]=(r[2]*n+r[6]*s+r[10]*c+r[14])/u,i}function Ou(i,e,r){var n=r[0],s=r[1],c=r[2],u=e[0],p=e[1],m=e[2],g=s*m-c*p,x=c*u-n*m,v=n*p-s*u,w=s*v-c*x,S=c*g-n*v,A=n*x-s*g,k=2*r[3];return x*=k,v*=k,S*=2,A*=2,i[0]=u+(g*=k)+(w*=2),i[1]=p+x+S,i[2]=m+v+A,i}var Ya,Gs=Bu,Nd=Ru,Gd=Pu;function Zs(i,e,r){var n=e[0],s=e[1],c=e[2],u=e[3];return i[0]=r[0]*n+r[4]*s+r[8]*c+r[12]*u,i[1]=r[1]*n+r[5]*s+r[9]*c+r[13]*u,i[2]=r[2]*n+r[6]*s+r[10]*c+r[14]*u,i[3]=r[3]*n+r[7]*s+r[11]*c+r[15]*u,i}function Uu(){var i=new Ai(4);return Ai!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i[3]=1,i}function Vu(i){return i[0]=0,i[1]=0,i[2]=0,i[3]=1,i}function ju(i,e,r){r*=.5;var n=e[0],s=e[1],c=e[2],u=e[3],p=Math.sin(r),m=Math.cos(r);return i[0]=n*m+u*p,i[1]=s*m+c*p,i[2]=c*m-s*p,i[3]=u*m-n*p,i}Eh(),Ya=new Ai(4),Ai!=Float32Array&&(Ya[0]=0,Ya[1]=0,Ya[2]=0,Ya[3]=0),Eh(),qa(1,0,0),qa(0,1,0),Uu(),Uu(),ku();class Ah{constructor(e,r){this.points=e,this.planes=r}static fromInvProjectionMatrix(e,r,n,s){let c=Math.pow(2,n),u=[[-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=>{let g=Zs([],m,e),x=1/g[3]/r*c;return function(v,w,S){return v[0]=w[0]*S[0],v[1]=w[1]*S[1],v[2]=w[2]*S[2],v[3]=w[3]*S[3],v}(g,g,[x,x,s?1/g[3]:x,x])}),p=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(m=>{let g=Wa([],Fu([],Gs([],u[m[0]],u[m[1]]),Gs([],u[m[2]],u[m[1]]))),x=-Ha(g,u[m[1]]);return g.concat(x)});return new Ah(u,p)}}class qi{constructor(e,r){this.min=e,this.max=r,this.center=Xa([],Lu([],this.min,this.max),.5)}quadrant(e){let r=[e%2==0,e<2],n=Du(this.min),s=Du(this.max);for(let c=0;c<r.length;c++)n[c]=r[c]?this.min[c]:this.center[c],s[c]=r[c]?this.center[c]:this.max[c];return s[2]=this.max[2],new qi(n,s)}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(){let e=this.min,r=this.max;return[[e[0],e[1],e[2]],[r[0],e[1],e[2]],[r[0],r[1],e[2]],[e[0],r[1],e[2]],[e[0],e[1],r[2]],[r[0],e[1],r[2]],[r[0],r[1],r[2]],[e[0],r[1],r[2]]]}intersects(e){let r=this.getCorners(),n=!0;for(let s=0;s<e.planes.length;s++){let c=e.planes[s],u=0;for(let p=0;p<r.length;p++)u+=Ha(c,r[p])+c[3]>=0;if(u===0)return 0;u!==r.length&&(n=!1)}if(n)return 2;for(let s=0;s<3;s++){let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let p=0;p<e.points.length;p++){let m=e.points[p][s]-this.min[s];c=Math.min(c,m),u=Math.max(u,m)}if(u<0||c>this.max[s]-this.min[s])return 0}return 1}}function Nu(i,e,r,n,s,c,u,p,m){if(c&&i.queryGeometry.isAboveHorizon)return!1;c&&(m*=i.pixelToTileUnitsFactor);for(let g of e)for(let x of g){let v=x.add(p),w=s&&r.elevation?r.elevation.exaggeration()*s.getElevationAt(v.x,v.y,!0):0,S=c?v:Zd(v,w,n),A=c?i.tilespaceRays.map(L=>qd(L,w)):i.queryGeometry.screenGeometry,k=Zs([],[x.x,x.y,w,1],n);if(!u&&c?m*=k[3]/r.cameraToCenterDistance:u&&!c&&(m*=r.cameraToCenterDistance/k[3]),Bd(A,S,m))return!0}return!1}function Zd(i,e,r){let n=Zs([],[i.x,i.y,e,1],r);return new _e(n[0]/n[3],n[1]/n[3])}let Gu=qa(0,0,0),$d=qa(0,0,1);function qd(i,e){let r=Eh();return Gu[2]=e,i.intersectsPlane(Gu,$d,r),new _e(r[0],r[1])}class Zu extends gh{}function $u(i,{width:e,height:r},n,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*r*n)throw new RangeError("mismatched image size")}else s=new Uint8Array(e*r*n);return i.width=e,i.height=r,i.data=s,i}function qu(i,e,r){let{width:n,height:s}=e;n===i.width&&s===i.height||(Ch(i,e,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,n),height:Math.min(i.height,s)},r),i.width=n,i.height=s,i.data=e.data)}function Ch(i,e,r,n,s,c){if(s.width===0||s.height===0)return e;if(s.width>i.width||s.height>i.height||r.x>i.width-s.width||r.y>i.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||n.x>e.width-s.width||n.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");let u=i.data,p=e.data;for(let m=0;m<s.height;m++){let g=((r.y+m)*i.width+r.x)*c,x=((n.y+m)*e.width+n.x)*c;for(let v=0;v<s.width*c;v++)p[x+v]=u[g+v]}return e}ze(Zu,"HeatmapBucket",{omit:["layers"]});class mn{constructor(e,r){$u(this,e,1,r)}resize(e){qu(this,new mn(e),1)}clone(){return new mn({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,n,s,c){Ch(e,r,n,s,c,1)}}class Ci{constructor(e,r){$u(this,e,4,r)}resize(e){qu(this,new Ci(e),4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Ci({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,n,s,c){Ch(e,r,n,s,c,4)}}ze(mn,"AlphaImage"),ze(Ci,"RGBAImage");var Xd={paint:new M({"heatmap-radius":new y(oe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new y(oe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new _(oe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new E(oe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new _(oe.paint_heatmap["heatmap-opacity"])})};function zh(i){let e={},r=i.resolution||256,n=i.clips?i.clips.length:1,s=i.image||new Ci({width:r,height:n}),c=(u,p,m)=>{e[i.evaluationKey]=m;let g=i.expression.evaluate(e);s.data[u+p+0]=Math.floor(255*g.r/g.a),s.data[u+p+1]=Math.floor(255*g.g/g.a),s.data[u+p+2]=Math.floor(255*g.b/g.a),s.data[u+p+3]=Math.floor(255*g.a)};if(i.clips)for(let u=0,p=0;u<n;++u,p+=4*r)for(let m=0,g=0;m<r;m++,g+=4){let x=m/(r-1),{start:v,end:w}=i.clips[u];c(p,g,v*(1-x)+w*x)}else for(let u=0,p=0;u<r;u++,p+=4)c(0,p,u/(r-1));return s}var Wd={paint:new M({"hillshade-illumination-direction":new _(oe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new _(oe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new _(oe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new _(oe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new _(oe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new _(oe.paint_hillshade["hillshade-accent-color"])})};let Hd=G([{name:"a_pos",components:2,type:"Int16"}],4),{members:Yd}=Hd;var bc=wc,Kd=wc;function wc(i,e,r){r=r||2;var n,s,c,u,p,m,g,x=e&&e.length,v=x?e[0]*r:i.length,w=Xu(i,0,v,r,!0),S=[];if(!w||w.next===w.prev)return S;if(x&&(w=function(k,L,O,q){var H,K,J,Q=[];for(H=0,K=L.length;H<K;H++)(J=Xu(k,L[H]*q,H<K-1?L[H+1]*q:k.length,q,!1))===J.next&&(J.steiner=!0),Q.push(sf(J));for(Q.sort(rf),H=0;H<Q.length;H++)O=Yn(O=nf(Q[H],O),O.next);return O}(i,e,w,r)),i.length>80*r){n=c=i[0],s=u=i[1];for(var A=r;A<v;A+=r)(p=i[A])<n&&(n=p),(m=i[A+1])<s&&(s=m),p>c&&(c=p),m>u&&(u=m);g=(g=Math.max(c-n,u-s))!==0?1/g:0}return Ka(w,S,r,n,s,g),S}function Xu(i,e,r,n,s){var c,u;if(s===Ph(i,e,r,n)>0)for(c=e;c<r;c+=n)u=Yu(c,i[c],i[c+1],u);else for(c=r-n;c>=e;c-=n)u=Yu(c,i[c],i[c+1],u);return u&&Tc(u,u.next)&&(Qa(u),u=u.next),u}function Yn(i,e){if(!i)return i;e||(e=i);var r,n=i;do if(r=!1,n.steiner||!Tc(n,n.next)&&Ft(n.prev,n,n.next)!==0)n=n.next;else{if(Qa(n),(n=e=n.prev)===n.next)break;r=!0}while(r||n!==e);return e}function Ka(i,e,r,n,s,c,u){if(i){!u&&c&&function(x,v,w,S){var A=x;do A.z===null&&(A.z=kh(A.x,A.y,v,w,S)),A.prevZ=A.prev,A.nextZ=A.next,A=A.next;while(A!==x);A.prevZ.nextZ=null,A.prevZ=null,function(k){var L,O,q,H,K,J,Q,le,he=1;do{for(O=k,k=null,K=null,J=0;O;){for(J++,q=O,Q=0,L=0;L<he&&(Q++,q=q.nextZ);L++);for(le=he;Q>0||le>0&&q;)Q!==0&&(le===0||!q||O.z<=q.z)?(H=O,O=O.nextZ,Q--):(H=q,q=q.nextZ,le--),K?K.nextZ=H:k=H,H.prevZ=K,K=H;O=q}K.nextZ=null,he*=2}while(J>1)}(A)}(i,n,s,c);for(var p,m,g=i;i.prev!==i.next;)if(p=i.prev,m=i.next,c?Qd(i,n,s,c):Jd(i))e.push(p.i/r),e.push(i.i/r),e.push(m.i/r),Qa(i),i=m.next,g=m.next;else if((i=m)===g){u?u===1?Ka(i=ef(Yn(i),e,r),e,r,n,s,c,2):u===2&&tf(i,e,r,n,s,c):Ka(Yn(i),e,r,n,s,c,1);break}}}function Jd(i){var e=i.prev,r=i,n=i.next;if(Ft(e,r,n)>=0)return!1;for(var s=i.next.next;s!==i.prev;){if($s(e.x,e.y,r.x,r.y,n.x,n.y,s.x,s.y)&&Ft(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function Qd(i,e,r,n){var s=i.prev,c=i,u=i.next;if(Ft(s,c,u)>=0)return!1;for(var p=s.x>c.x?s.x>u.x?s.x:u.x:c.x>u.x?c.x:u.x,m=s.y>c.y?s.y>u.y?s.y:u.y:c.y>u.y?c.y:u.y,g=kh(s.x<c.x?s.x<u.x?s.x:u.x:c.x<u.x?c.x:u.x,s.y<c.y?s.y<u.y?s.y:u.y:c.y<u.y?c.y:u.y,e,r,n),x=kh(p,m,e,r,n),v=i.prevZ,w=i.nextZ;v&&v.z>=g&&w&&w.z<=x;){if(v!==i.prev&&v!==i.next&&$s(s.x,s.y,c.x,c.y,u.x,u.y,v.x,v.y)&&Ft(v.prev,v,v.next)>=0||(v=v.prevZ,w!==i.prev&&w!==i.next&&$s(s.x,s.y,c.x,c.y,u.x,u.y,w.x,w.y)&&Ft(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;v&&v.z>=g;){if(v!==i.prev&&v!==i.next&&$s(s.x,s.y,c.x,c.y,u.x,u.y,v.x,v.y)&&Ft(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;w&&w.z<=x;){if(w!==i.prev&&w!==i.next&&$s(s.x,s.y,c.x,c.y,u.x,u.y,w.x,w.y)&&Ft(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function ef(i,e,r){var n=i;do{var s=n.prev,c=n.next.next;!Tc(s,c)&&Wu(s,n,n.next,c)&&Ja(s,c)&&Ja(c,s)&&(e.push(s.i/r),e.push(n.i/r),e.push(c.i/r),Qa(n),Qa(n.next),n=i=c),n=n.next}while(n!==i);return Yn(n)}function tf(i,e,r,n,s,c){var u=i;do{for(var p=u.next.next;p!==u.prev;){if(u.i!==p.i&&af(u,p)){var m=Hu(u,p);return u=Yn(u,u.next),m=Yn(m,m.next),Ka(u,e,r,n,s,c),void Ka(m,e,r,n,s,c)}p=p.next}u=u.next}while(u!==i)}function rf(i,e){return i.x-e.x}function nf(i,e){var r=function(c,u){var p,m=u,g=c.x,x=c.y,v=-1/0;do{if(x<=m.y&&x>=m.next.y&&m.next.y!==m.y){var w=m.x+(x-m.y)*(m.next.x-m.x)/(m.next.y-m.y);if(w<=g&&w>v){if(v=w,w===g){if(x===m.y)return m;if(x===m.next.y)return m.next}p=m.x<m.next.x?m:m.next}}m=m.next}while(m!==u);if(!p)return null;if(g===v)return p;var S,A=p,k=p.x,L=p.y,O=1/0;m=p;do g>=m.x&&m.x>=k&&g!==m.x&&$s(x<L?g:v,x,k,L,x<L?v:g,x,m.x,m.y)&&(S=Math.abs(x-m.y)/(g-m.x),Ja(m,c)&&(S<O||S===O&&(m.x>p.x||m.x===p.x&&of(p,m)))&&(p=m,O=S)),m=m.next;while(m!==A);return p}(i,e);if(!r)return e;var n=Hu(r,i),s=Yn(r,r.next);return Yn(n,n.next),e===r?s:e}function of(i,e){return Ft(i.prev,i,e.prev)<0&&Ft(e.next,i,i.next)<0}function kh(i,e,r,n,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-r)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function sf(i){var e=i,r=i;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==i);return r}function $s(i,e,r,n,s,c,u,p){return(s-u)*(e-p)-(i-u)*(c-p)>=0&&(i-u)*(n-p)-(r-u)*(e-p)>=0&&(r-u)*(c-p)-(s-u)*(n-p)>=0}function af(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!function(r,n){var s=r;do{if(s.i!==r.i&&s.next.i!==r.i&&s.i!==n.i&&s.next.i!==n.i&&Wu(s,s.next,r,n))return!0;s=s.next}while(s!==r);return!1}(i,e)&&(Ja(i,e)&&Ja(e,i)&&function(r,n){var s=r,c=!1,u=(r.x+n.x)/2,p=(r.y+n.y)/2;do s.y>p!=s.next.y>p&&s.next.y!==s.y&&u<(s.next.x-s.x)*(p-s.y)/(s.next.y-s.y)+s.x&&(c=!c),s=s.next;while(s!==r);return c}(i,e)&&(Ft(i.prev,i,e.prev)||Ft(i,e.prev,e))||Tc(i,e)&&Ft(i.prev,i,i.next)>0&&Ft(e.prev,e,e.next)>0)}function Ft(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function Tc(i,e){return i.x===e.x&&i.y===e.y}function Wu(i,e,r,n){var s=Sc(Ft(i,e,r)),c=Sc(Ft(i,e,n)),u=Sc(Ft(r,n,i)),p=Sc(Ft(r,n,e));return s!==c&&u!==p||!(s!==0||!Ec(i,r,e))||!(c!==0||!Ec(i,n,e))||!(u!==0||!Ec(r,i,n))||!(p!==0||!Ec(r,e,n))}function Ec(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function Sc(i){return i>0?1:i<0?-1:0}function Ja(i,e){return Ft(i.prev,i,i.next)<0?Ft(i,e,i.next)>=0&&Ft(i,i.prev,e)>=0:Ft(i,e,i.prev)<0||Ft(i,i.next,e)<0}function Hu(i,e){var r=new Dh(i.i,i.x,i.y),n=new Dh(e.i,e.x,e.y),s=i.next,c=e.prev;return i.next=e,e.prev=i,r.next=s,s.prev=r,n.next=r,r.prev=n,c.next=n,n.prev=c,n}function Yu(i,e,r,n){var s=new Dh(i,e,r);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Qa(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Dh(i,e,r){this.i=i,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ph(i,e,r,n){for(var s=0,c=e,u=r-n;c<r;c+=n)s+=(i[u]-i[c])*(i[c+1]+i[u+1]),u=c;return s}function lf(i,e,r,n,s){Ku(i,e,r||0,n||i.length-1,s||cf)}function Ku(i,e,r,n,s){for(;n>r;){if(n-r>600){var c=n-r+1,u=e-r+1,p=Math.log(c),m=.5*Math.exp(2*p/3),g=.5*Math.sqrt(p*m*(c-m)/c)*(u-c/2<0?-1:1);Ku(i,e,Math.max(r,Math.floor(e-u*m/c+g)),Math.min(n,Math.floor(e+(c-u)*m/c+g)),s)}var x=i[e],v=r,w=n;for(el(i,r,e),s(i[n],x)>0&&el(i,r,n);v<w;){for(el(i,v,w),v++,w--;s(i[v],x)<0;)v++;for(;s(i[w],x)>0;)w--}s(i[r],x)===0?el(i,r,w):el(i,++w,n),w<=e&&(r=w+1),e<=w&&(n=w-1)}}function el(i,e,r){var n=i[e];i[e]=i[r],i[r]=n}function cf(i,e){return i<e?-1:i>e?1:0}function Lh(i,e){let r=i.length;if(r<=1)return[i];let n=[],s,c;for(let u=0;u<r;u++){let p=gr(i[u]);p!==0&&(i[u].area=Math.abs(p),c===void 0&&(c=p<0),c===p<0?(s&&n.push(s),s=[i[u]]):s.push(i[u]))}if(s&&n.push(s),e>1)for(let u=0;u<n.length;u++)n[u].length<=e||(lf(n[u],e,1,n[u].length-1,hf),n[u]=n[u].slice(0,e));return n}function hf(i,e){return e.area-i.area}function Bh(i,e,r){let n=r.patternDependencies,s=!1;for(let c of e){let u=c.paint.get(`${i}-pattern`);u.isConstant()||(s=!0);let p=u.constantOr(null);p&&(s=!0,n[p.to]=!0,n[p.from]=!0)}return s}function Rh(i,e,r,n,s){let c=s.patternDependencies;for(let u of e){let p=u.paint.get(`${i}-pattern`).value;if(p.kind!=="constant"){let m=p.evaluate({zoom:n-1},r,{},s.availableImages),g=p.evaluate({zoom:n},r,{},s.availableImages),x=p.evaluate({zoom:n+1},r,{},s.availableImages);m=m&&m.name?m.name:m,g=g&&g.name?g.name:g,x=x&&x.name?x.name:x,c[m]=!0,c[g]=!0,c[x]=!0,r.patterns[u.id]={min:m,mid:g,max:x}}}return r}wc.deviation=function(i,e,r,n){var s=e&&e.length,c=Math.abs(Ph(i,0,s?e[0]*r:i.length,r));if(s)for(var u=0,p=e.length;u<p;u++)c-=Math.abs(Ph(i,e[u]*r,u<p-1?e[u+1]*r:i.length,r));var m=0;for(u=0;u<n.length;u+=3){var g=n[u]*r,x=n[u+1]*r,v=n[u+2]*r;m+=Math.abs((i[g]-i[v])*(i[x+1]-i[g+1])-(i[g]-i[x])*(i[v+1]-i[g+1]))}return c===0&&m===0?0:Math.abs((m-c)/c)},wc.flatten=function(i){for(var e=i[0][0].length,r={vertices:[],holes:[],dimensions:e},n=0,s=0;s<i.length;s++){for(var c=0;c<i[s].length;c++)for(var u=0;u<e;u++)r.vertices.push(i[s][c][u]);s>0&&r.holes.push(n+=i[s-1].length)}return r},bc.default=Kd;class Ic{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new j,this.indexArray=new ke,this.indexArray2=new qe,this.programConfigurations=new No(e.layers,e.zoom),this.segments=new Pt,this.segments2=new Pt,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.projection=e.projection}populate(e,r,n,s){this.hasPattern=Bh("fill",this.layers,r);let c=this.layers[0].layout.get("fill-sort-key"),u=[];for(let{feature:p,id:m,index:g,sourceLayerIndex:x}of e){let v=this.layers[0]._featureFilter.needGeometry,w=Go(p,v);if(!this.layers[0]._featureFilter.filter(new Tt(this.zoom),w,n))continue;let S=c?c.evaluate(w,{},n,r.availableImages):void 0,A={id:m,properties:p.properties,type:p.type,sourceLayerIndex:x,index:g,geometry:v?w.geometry:fn(p,n,s),patterns:{},sortKey:S};u.push(A)}c&&u.sort((p,m)=>p.sortKey-m.sortKey);for(let p of u){let{geometry:m,index:g,sourceLayerIndex:x}=p;if(this.hasPattern){let v=Rh("fill",this.layers,p,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(p,m,g,n,{},r.availableImages);r.featureIndex.insert(e[g].feature,m,g,x,this.index)}}update(e,r,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,n,s)}addFeatures(e,r,n,s,c){for(let u of this.patternFeatures)this.addFeature(u,u.geometry,u.index,r,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,r,n,s,c,u=[]){for(let p of Lh(r,500)){let m=0;for(let A of p)m+=A.length;let g=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray),x=g.vertexLength,v=[],w=[];for(let A of p){if(A.length===0)continue;A!==p[0]&&w.push(v.length/2);let k=this.segments2.prepareSegment(A.length,this.layoutVertexArray,this.indexArray2),L=k.vertexLength;this.layoutVertexArray.emplaceBack(A[0].x,A[0].y),this.indexArray2.emplaceBack(L+A.length-1,L),v.push(A[0].x),v.push(A[0].y);for(let O=1;O<A.length;O++)this.layoutVertexArray.emplaceBack(A[O].x,A[O].y),this.indexArray2.emplaceBack(L+O-1,L+O),v.push(A[O].x),v.push(A[O].y);k.vertexLength+=A.length,k.primitiveLength+=A.length}let S=bc(v,w);for(let A=0;A<S.length;A+=3)this.indexArray.emplaceBack(x+S[A],x+S[A+1],x+S[A+2]);g.vertexLength+=m,g.primitiveLength+=S.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,u,s)}}ze(Ic,"FillBucket",{omit:["layers","patternFeatures"]});let uf=new M({"fill-sort-key":new y(oe.layout_fill["fill-sort-key"])});var pf={paint:new M({"fill-antialias":new _(oe.paint_fill["fill-antialias"]),"fill-opacity":new y(oe.paint_fill["fill-opacity"]),"fill-color":new y(oe.paint_fill["fill-color"]),"fill-outline-color":new y(oe.paint_fill["fill-outline-color"]),"fill-translate":new _(oe.paint_fill["fill-translate"]),"fill-translate-anchor":new _(oe.paint_fill["fill-translate-anchor"]),"fill-pattern":new b(oe.paint_fill["fill-pattern"])}),layout:uf};let df=G([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),ff=G([{name:"a_centroid_pos",components:2,type:"Uint16"}]),mf=G([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:_f}=df;var Ju=qs;function qs(i,e,r,n,s){this.properties={},this.extent=r,this.type=0,this._pbf=i,this._geometry=-1,this._keys=n,this._values=s,i.readFields(gf,this,e)}function gf(i,e,r){i==1?e.id=r.readVarint():i==2?function(n,s){for(var c=n.readVarint()+n.pos;n.pos<c;){var u=s._keys[n.readVarint()],p=s._values[n.readVarint()];s.properties[u]=p}}(r,e):i==3?e.type=r.readVarint():i==4&&(e._geometry=r.pos)}function yf(i){for(var e,r,n=0,s=0,c=i.length,u=c-1;s<c;u=s++)n+=((r=i[u]).x-(e=i[s]).x)*(e.y+r.y);return n}qs.types=["Unknown","Point","LineString","Polygon"],qs.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var e,r=i.readVarint()+i.pos,n=1,s=0,c=0,u=0,p=[];i.pos<r;){if(s<=0){var m=i.readVarint();n=7&m,s=m>>3}if(s--,n===1||n===2)c+=i.readSVarint(),u+=i.readSVarint(),n===1&&(e&&p.push(e),e=[]),e.push(new _e(c,u));else{if(n!==7)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&p.push(e),p},qs.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,n=0,s=0,c=0,u=1/0,p=-1/0,m=1/0,g=-1/0;i.pos<e;){if(n<=0){var x=i.readVarint();r=7&x,n=x>>3}if(n--,r===1||r===2)(s+=i.readSVarint())<u&&(u=s),s>p&&(p=s),(c+=i.readSVarint())<m&&(m=c),c>g&&(g=c);else if(r!==7)throw new Error("unknown command "+r)}return[u,m,p,g]},qs.prototype.toGeoJSON=function(i,e,r){var n,s,c=this.extent*Math.pow(2,r),u=this.extent*i,p=this.extent*e,m=this.loadGeometry(),g=qs.types[this.type];function x(S){for(var A=0;A<S.length;A++){var k=S[A];S[A]=[360*(k.x+u)/c-180,360/Math.PI*Math.atan(Math.exp((180-360*(k.y+p)/c)*Math.PI/180))-90]}}switch(this.type){case 1:var v=[];for(n=0;n<m.length;n++)v[n]=m[n][0];x(m=v);break;case 2:for(n=0;n<m.length;n++)x(m[n]);break;case 3:for(m=function(S){var A=S.length;if(A<=1)return[S];for(var k,L,O=[],q=0;q<A;q++){var H=yf(S[q]);H!==0&&(L===void 0&&(L=H<0),L===H<0?(k&&O.push(k),k=[S[q]]):k.push(S[q]))}return k&&O.push(k),O}(m),n=0;n<m.length;n++)for(s=0;s<m[n].length;s++)x(m[n][s])}m.length===1?m=m[0]:g="Multi"+g;var w={type:"Feature",geometry:{type:g,coordinates:m},properties:this.properties};return"id"in this&&(w.id=this.id),w};var Qu=ep;function ep(i,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=i,this._keys=[],this._values=[],this._features=[],i.readFields(xf,this,e),this.length=this._features.length}function xf(i,e,r){i===15?e.version=r.readVarint():i===1?e.name=r.readString():i===5?e.extent=r.readVarint():i===2?e._features.push(r.pos):i===3?e._keys.push(r.readString()):i===4&&e._values.push(function(n){for(var s=null,c=n.readVarint()+n.pos;n.pos<c;){var u=n.readVarint()>>3;s=u===1?n.readString():u===2?n.readFloat():u===3?n.readDouble():u===4?n.readVarint64():u===5?n.readVarint():u===6?n.readSVarint():u===7?n.readBoolean():null}return s}(r))}function vf(i,e,r){if(i===3){var n=new Qu(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}ep.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var e=this._pbf.readVarint()+this._pbf.pos;return new Ju(this._pbf,e,this.extent,this._keys,this._values)};var qo={VectorTile:function(i,e){this.layers=i.readFields(vf,{},e)},VectorTileFeature:Ju,VectorTileLayer:Qu};function Mc(i,e,r,n){let s=[],c=n===0?(u,p,m,g,x,v)=>{u.push(new _e(v,m+(v-p)/(g-p)*(x-m)))}:(u,p,m,g,x,v)=>{u.push(new _e(p+(v-m)/(x-m)*(g-p),v))};for(let u of i){let p=[];for(let m of u){if(m.length<=2)continue;let g=[];for(let w=0;w<m.length-1;w++){let S=m[w].x,A=m[w].y,k=m[w+1].x,L=m[w+1].y,O=n===0?S:A,q=n===0?k:L;O<e?q>e&&c(g,S,A,k,L,e):O>r?q<r&&c(g,S,A,k,L,r):g.push(m[w]),q<e&&O>=e&&c(g,S,A,k,L,e),q>r&&O<=r&&c(g,S,A,k,L,r)}let x=m[m.length-1],v=n===0?x.x:x.y;v>=e&&v<=r&&g.push(x),g.length&&(x=g[g.length-1],g[0].x===x.x&&g[0].y===x.y||g.push(g[0]),p.push(g))}p.length&&s.push(p)}return s}let bf=qo.VectorTileFeature.types,wf=Math.pow(2,13);function tl(i,e,r,n,s,c,u,p){i.emplaceBack((e<<1)+u,(r<<1)+c,(Math.floor(n*wf)<<1)+s,Math.round(p))}function il(i,e,r){i.emplaceBack(e.x,e.y,e.z,r[0]*16384,r[1]*16384,r[2]*16384)}class tp{constructor(){this.acc=new _e(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new _e(e.x,e.y),this.max=new _e(e.x,e.y))}append(e,r){this.currentPolyCount.edges++,this.acc._add(e);let n=this.min,s=this.max;e.x<n.x?n.x=e.x:e.x>s.x&&(s.x=e.x),e.y<n.y?n.y=e.y:e.y>s.y&&(s.y=e.y),((e.x===0||e.x===He)&&e.x===r.x)!=((e.y===0||e.y===He)&&e.y===r.y)&&this.processBorderOverlap(e,r),r.x<0!=e.x<0&&this.addBorderIntersection(0,je(r.y,e.y,(0-r.x)/(e.x-r.x))),r.x>He!=e.x>He&&this.addBorderIntersection(1,je(r.y,e.y,(He-r.x)/(e.x-r.x))),r.y<0!=e.y<0&&this.addBorderIntersection(2,je(r.x,e.x,(0-r.y)/(e.y-r.y))),r.y>He!=e.y>He&&this.addBorderIntersection(3,je(r.x,e.x,(He-r.y)/(e.y-r.y)))}addBorderIntersection(e,r){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]]);let n=this.borders[e];r<n[0]&&(n[0]=r),r>n[1]&&(n[1]=r)}processBorderOverlap(e,r){if(e.x===r.x){if(e.y===r.y)return;let n=e.x===0?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,e.y)}else{let n=e.y===0?2:3;this.addBorderIntersection(n,r.x),this.addBorderIntersection(n,e.x)}}centroid(){let e=this.polyCount.reduce((r,n)=>r+n.edges,0);return e!==0?this.acc.div(e)._round():new _e(0,0)}span(){return new _e(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,r)=>e+ +(r[0]!==Number.MAX_VALUE),0)}}class rl{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new $,this.centroidVertexArray=new jo,this.indexArray=new ke,this.programConfigurations=new No(e.layers,e.zoom),this.segments=new Pt,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.enableTerrain=e.enableTerrain}populate(e,r,n,s){this.features=[],this.hasPattern=Bh("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(c){let u=Math.exp(Math.PI*(1-c.y/(1<<c.z)*2));return 80150034*u/(u*u+1)/He/(1<<c.z)}(n);for(let{feature:c,id:u,index:p,sourceLayerIndex:m}of e){let g=this.layers[0]._featureFilter.needGeometry,x=Go(c,g);if(!this.layers[0]._featureFilter.filter(new Tt(this.zoom),x,n))continue;let v={id:u,sourceLayerIndex:m,index:p,geometry:g?x.geometry:fn(c,n,s),properties:c.properties,type:c.type,patterns:{}},w=this.layoutVertexArray.length;this.hasPattern?this.features.push(Rh("fill-extrusion",this.layers,v,this.zoom,r)):this.addFeature(v,v.geometry,p,n,{},r.availableImages,s),r.featureIndex.insert(c,v.geometry,p,m,this.index,w)}this.sortBorders()}addFeatures(e,r,n,s,c){for(let u of this.features){let{geometry:p}=u;this.addFeature(u,p,u.index,r,n,s,c)}this.sortBorders()}update(e,r,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,_f),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,mf.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,ff.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,r,n,s,c,u,p){let m=[new _e(0,0),new _e(He,He)],g=p.projection,x=g.name==="globe",v=this.enableTerrain&&!x?new tp:null;x&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new gi);let w=Lh(r,500);for(let k=w.length-1;k>=0;k--){let L=w[k];(L.length===0||(S=L[0]).every(O=>O.x<=0)||S.every(O=>O.x>=He)||S.every(O=>O.y<=0)||S.every(O=>O.y>=He))&&w.splice(k,1)}var S;let A;if(x){let L=1<<s.z,O=tr(s.x/L),q=tr((s.x+1)/L),H=Qt(s.y/L),K=Qt((s.y+1)/L);A=function(J,Q,le,he,fe=0,ge){let se=[];if(!J.length||!le||!he)return se;let de=(We,Ke)=>{for(let Re of We)se.push({polygon:Re,bounds:Ke})},xe=Math.ceil(Math.log2(le)),Se=Math.ceil(Math.log2(he)),be=xe-Se,Ee=[];for(let We=0;We<Math.abs(be);We++)Ee.push(be>0?0:1);for(let We=0;We<Math.min(xe,Se);We++)Ee.push(0),Ee.push(1);let Xe=J;if(Xe=Mc(Xe,Q[0].y-fe,Q[1].y+fe,1),Xe=Mc(Xe,Q[0].x-fe,Q[1].x+fe,0),!Xe.length)return se;let Qe=[];for(Ee.length?Qe.push({polygons:Xe,bounds:Q,depth:0}):de(Xe,Q);Qe.length;){let We=Qe.pop(),Ke=We.depth,Re=Ee[Ke],Ce=We.bounds[0],it=We.bounds[1],mt=Re===0?Ce.x:Ce.y,Vt=Re===0?it.x:it.y,Et=ge?ge(Re,mt,Vt):.5*(mt+Vt),jt=Mc(We.polygons,mt-fe,Et+fe,Re),_t=Mc(We.polygons,Et-fe,Vt+fe,Re);if(jt.length){let nt=[Ce,new _e(Re===0?Et:it.x,Re===1?Et:it.y)];Ee.length>Ke+1?Qe.push({polygons:jt,bounds:nt,depth:Ke+1}):de(jt,nt)}if(_t.length){let nt=[new _e(Re===0?Et:Ce.x,Re===1?Et:Ce.y),it];Ee.length>Ke+1?Qe.push({polygons:_t,bounds:nt,depth:Ke+1}):de(_t,nt)}}return se}(w,m,Math.ceil((q-O)/11.25),Math.ceil((H-K)/11.25),1,(J,Q,le)=>{if(J===0)return .5*(Q+le);{let he=Qt((s.y+Q/He)/L);return(Us(.5*(Qt((s.y+le/He)/L)+he))*L-s.y)*He}})}else{A=[];for(let k of w)A.push({polygon:k,bounds:m})}for(let k of A){let L=k.polygon,O=0,q=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let le=0;le<L.length;le++){let he=L[le];if(he.length===0)continue;O+=he.length;let fe=0;v&&v.startRing(he[0]);for(let ge=0;ge<he.length;ge++){let se=he[ge];if(ge>=1){let de=he[ge-1];if(!Tf(se,de,k.bounds)){v&&v.append(se,de),q.vertexLength+4>Pt.MAX_VERTEX_ARRAY_LENGTH&&(q=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let xe=se.sub(de)._perp(),Se=xe.x/(Math.abs(xe.x)+Math.abs(xe.y)),be=xe.y>0?1:0,Ee=de.dist(se);fe+Ee>32768&&(fe=0),tl(this.layoutVertexArray,se.x,se.y,Se,be,0,0,fe),tl(this.layoutVertexArray,se.x,se.y,Se,be,0,1,fe),fe+=Ee,tl(this.layoutVertexArray,de.x,de.y,Se,be,0,0,fe),tl(this.layoutVertexArray,de.x,de.y,Se,be,0,1,fe);let Xe=q.vertexLength;if(this.indexArray.emplaceBack(Xe,Xe+2,Xe+1),this.indexArray.emplaceBack(Xe+1,Xe+2,Xe+3),q.vertexLength+=4,q.primitiveLength+=2,x){let Qe=this.layoutVertexExtArray,We=g.projectTilePoint(se.x,se.y,s),Ke=g.projectTilePoint(de.x,de.y,s),Re=g.upVector(s,se.x,se.y),Ce=g.upVector(s,de.x,de.y);il(Qe,We,Re),il(Qe,We,Re),il(Qe,Ke,Ce),il(Qe,Ke,Ce)}}}}}if(q.vertexLength+O>Pt.MAX_VERTEX_ARRAY_LENGTH&&(q=this.segments.prepareSegment(O,this.layoutVertexArray,this.indexArray)),bf[e.type]!=="Polygon")continue;let H=[],K=[],J=q.vertexLength;for(let le=0;le<L.length;le++){let he=L[le];if(he.length!==0){he!==L[0]&&K.push(H.length/2);for(let fe=0;fe<he.length;fe++){let ge=he[fe];tl(this.layoutVertexArray,ge.x,ge.y,0,0,1,1,0),H.push(ge.x),H.push(ge.y),v&&v.currentPolyCount.top++,x&&il(this.layoutVertexExtArray,g.projectTilePoint(ge.x,ge.y,s),g.upVector(s,ge.x,ge.y))}}}let Q=bc(H,K);for(let le=0;le<Q.length;le+=3)this.indexArray.emplaceBack(J+Q[le],J+Q[le+2],J+Q[le+1]);q.primitiveLength+=Q.length/3,q.vertexLength+=O}if(v&&v.polyCount.length>0){if(v.borders){v.vertexArrayOffset=this.centroidVertexArray.length;let k=v.borders,L=this.featuresOnBorder.push(v)-1;for(let O=0;O<4;O++)k[O][0]!==Number.MAX_VALUE&&this.borders[O].push(L)}this.encodeCentroid(v.borders?void 0:v.centroid(),v)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,u,s)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((r,n)=>this.featuresOnBorder[r].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}encodeCentroid(e,r,n=!0){let s,c;if(e)if(e.y!==0){let p=r.span()._mult(this.tileToMeter);s=(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 s=Math.ceil(7*(e.x+450)),c=0;else s=0,c=+n;let u=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(let p of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*p.edges+p.top);for(let m=0;m<2*p.edges;m++)this.centroidVertexArray.emplace(u++,0,c),this.centroidVertexArray.emplace(u++,s,c);for(let m=0;m<p.top;m++)this.centroidVertexArray.emplace(u++,s,c)}}}function Tf(i,e,r){return i.x===e.x&&(i.x<r[0].x||i.x>r[1].x)||i.y===e.y&&(i.y<r[0].y||i.y>r[1].y)}ze(rl,"FillExtrusionBucket",{omit:["layers","features"]}),ze(tp,"PartMetadata");var Ef={paint:new M({"fill-extrusion-opacity":new _(oe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new y(oe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new _(oe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new _(oe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new b(oe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new y(oe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new y(oe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new _(oe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function nl(i,e){return i.x*e.x+i.y*e.y}function ip(i,e){if(i.length===1){let r=0,n=e[r++],s;for(;!s||n.equals(s);)if(s=e[r++],!s)return 1/0;for(;r<e.length;r++){let c=e[r],u=i[0],p=s.sub(n),m=c.sub(n),g=u.sub(n),x=nl(p,p),v=nl(p,m),w=nl(m,m),S=nl(g,p),A=nl(g,m),k=x*w-v*v,L=(w*S-v*A)/k,O=(x*A-v*S)/k,q=n.z*(1-L-O)+s.z*L+c.z*O;if(isFinite(q))return q}return 1/0}{let r=1/0;for(let n of e)r=Math.min(r,n.z);return r}}function rp(i){let e=new _e(i[0],i[1]);return e.z=i[2],e}function Sf(i,e,r,n,s,c,u,p){let m=u*s.getElevationAt(i,e,!0,!0),g=c[0]!==0,x=g?c[1]===0?u*(c[0]/7-450):u*function(v,w,S){let A=Math.floor(w[0]/8),k=Math.floor(w[1]/8),L=10*(w[0]-8*A),O=10*(w[1]-8*k),q=v.getElevationAt(A,k,!0,!0),H=v.getMeterToDEM(S),K=Math.floor(.5*(L*H-1)),J=Math.floor(.5*(O*H-1)),Q=v.tileCoordToPixel(A,k),le=2*K+1,he=2*J+1,fe=function(be,Ee,Xe,Qe,We){return[be.getElevationAtPixel(Ee,Xe,!0),be.getElevationAtPixel(Ee+We,Xe,!0),be.getElevationAtPixel(Ee,Xe+We,!0),be.getElevationAtPixel(Ee+Qe,Xe+We,!0)]}(v,Q.x-K,Q.y-J,le,he),ge=Math.abs(fe[0]-fe[1]),se=Math.abs(fe[2]-fe[3]),de=Math.abs(fe[0]-fe[2])+Math.abs(fe[1]-fe[3]),xe=Math.min(.25,.5*H*(ge+se)/le),Se=Math.min(.25,.5*H*de/he);return q+Math.max(xe*L,Se*O)}(s,c,p):m;return{base:m+(r===0)?-1:r,top:g?Math.max(x+n,m+r+2):m+n}}let If=G([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Mf}=If,Af=G([{name:"a_packed",components:3,type:"Float32"}]),{members:Cf}=Af,zf=qo.VectorTileFeature.types,kf=Math.cos(Math.PI/180*37.5);class Ac{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new V,this.layoutVertexArray2=new we,this.indexArray=new ke,this.programConfigurations=new No(e.layers,e.zoom),this.segments=new Pt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,n,s){this.hasPattern=Bh("line",this.layers,r);let c=this.layers[0].layout.get("line-sort-key"),u=[];for(let{feature:x,id:v,index:w,sourceLayerIndex:S}of e){let A=this.layers[0]._featureFilter.needGeometry,k=Go(x,A);if(!this.layers[0]._featureFilter.filter(new Tt(this.zoom),k,n))continue;let L=c?c.evaluate(k,{},n):void 0,O={id:v,properties:x.properties,type:x.type,sourceLayerIndex:S,index:w,geometry:A?k.geometry:fn(x,n,s),patterns:{},sortKey:L};u.push(O)}c&&u.sort((x,v)=>x.sortKey-v.sortKey);let{lineAtlas:p,featureIndex:m}=r,g=this.addConstantDashes(p);for(let x of u){let{geometry:v,index:w,sourceLayerIndex:S}=x;if(g&&this.addFeatureDashes(x,p),this.hasPattern){let A=Rh("line",this.layers,x,this.zoom,r);this.patternFeatures.push(A)}else this.addFeature(x,v,w,n,p.positions,r.availableImages);m.insert(e[w].feature,v,w,S,this.index)}}addConstantDashes(e){let r=!1;for(let n of this.layers){let s=n.paint.get("line-dasharray").value,c=n.layout.get("line-cap").value;if(s.kind!=="constant"||c.kind!=="constant")r=!0;else{let u=c.value,p=s.value;if(!p)continue;e.addDash(p.from,u),e.addDash(p.to,u),p.other&&e.addDash(p.other,u)}}return r}addFeatureDashes(e,r){let n=this.zoom;for(let s of this.layers){let c=s.paint.get("line-dasharray").value,u=s.layout.get("line-cap").value;if(c.kind==="constant"&&u.kind==="constant")continue;let p,m,g,x,v,w;if(c.kind==="constant"){let L=c.value;if(!L)continue;p=L.other||L.to,m=L.to,g=L.from}else p=c.evaluate({zoom:n-1},e),m=c.evaluate({zoom:n},e),g=c.evaluate({zoom:n+1},e);u.kind==="constant"?x=v=w=u.value:(x=u.evaluate({zoom:n-1},e),v=u.evaluate({zoom:n},e),w=u.evaluate({zoom:n+1},e)),r.addDash(p,x),r.addDash(m,v),r.addDash(g,w);let S=r.getKey(p,x),A=r.getKey(m,v),k=r.getKey(g,w);e.patterns[s.id]={min:S,mid:A,max:k}}}update(e,r,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,n,s)}addFeatures(e,r,n,s,c){for(let u of this.patternFeatures)this.addFeature(u,u.geometry,u.index,r,n,s)}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,Cf)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Mf),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,r,n,s,c,u){let p=this.layers[0].layout,m=p.get("line-join").evaluate(e,{}),g=p.get("line-cap").evaluate(e,{}),x=p.get("line-miter-limit"),v=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(let w of r)this.addLine(w,e,m,g,x,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,u,s)}addLine(e,r,n,s,c,u){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let O=0;O<e.length-1;O++)this.totalDistance+=e[O].dist(e[O+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}let p=zf[r.type]==="Polygon",m=e.length;for(;m>=2&&e[m-1].equals(e[m-2]);)m--;let g=0;for(;g<m-1&&e[g].equals(e[g+1]);)g++;if(m<(p?3:2))return;n==="bevel"&&(c=1.05);let x=this.overscaling<=16?122880/(512*this.overscaling):0,v=this.segments.prepareSegment(10*m,this.layoutVertexArray,this.indexArray),w,S,A,k,L;this.e1=this.e2=-1,p&&(w=e[m-2],L=e[g].sub(w)._unit()._perp());for(let O=g;O<m;O++){if(A=O===m-1?p?e[g+1]:void 0:e[O+1],A&&e[O].equals(A))continue;L&&(k=L),w&&(S=w),w=e[O],L=A?A.sub(w)._unit()._perp():k,k=k||L;let q=k.add(L);q.x===0&&q.y===0||q._unit();let H=k.x*L.x+k.y*L.y,K=q.x*L.x+q.y*L.y,J=K!==0?1/K:1/0,Q=2*Math.sqrt(2-2*K),le=K<kf&&S&&A,he=k.x*L.y-k.y*L.x>0;if(le&&O>g){let se=w.dist(S);if(se>2*x){let de=w.sub(w.sub(S)._mult(x/se)._round());this.updateDistance(S,de),this.addCurrentVertex(de,k,0,0,v),S=de}}let fe=S&&A,ge=fe?n:p?"butt":s;if(fe&&ge==="round"&&(J<u?ge="miter":J<=2&&(ge="fakeround")),ge==="miter"&&J>c&&(ge="bevel"),ge==="bevel"&&(J>2&&(ge="flipbevel"),J<c&&(ge="miter")),S&&this.updateDistance(S,w),ge==="miter")q._mult(J),this.addCurrentVertex(w,q,0,0,v);else if(ge==="flipbevel"){if(J>100)q=L.mult(-1);else{let se=J*k.add(L).mag()/k.sub(L).mag();q._perp()._mult(se*(he?-1:1))}this.addCurrentVertex(w,q,0,0,v),this.addCurrentVertex(w,q.mult(-1),0,0,v)}else if(ge==="bevel"||ge==="fakeround"){let se=-Math.sqrt(J*J-1),de=he?se:0,xe=he?0:se;if(S&&this.addCurrentVertex(w,k,de,xe,v),ge==="fakeround"){let Se=Math.round(180*Q/Math.PI/20);for(let be=1;be<Se;be++){let Ee=be/Se;if(Ee!==.5){let Qe=Ee-.5;Ee+=Ee*Qe*(Ee-1)*((1.0904+H*(H*(3.55645-1.43519*H)-3.2452))*Qe*Qe+(.848013+H*(.215638*H-1.06021)))}let Xe=L.sub(k)._mult(Ee)._add(k)._unit()._mult(he?-1:1);this.addHalfVertex(w,Xe.x,Xe.y,!1,he,0,v)}}A&&this.addCurrentVertex(w,L,-de,-xe,v)}else if(ge==="butt")this.addCurrentVertex(w,q,0,0,v);else if(ge==="square"){let se=S?1:-1;S||this.addCurrentVertex(w,q,se,se,v),this.addCurrentVertex(w,q,0,0,v),S&&this.addCurrentVertex(w,q,se,se,v)}else ge==="round"&&(S&&(this.addCurrentVertex(w,k,0,0,v),this.addCurrentVertex(w,k,1,1,v,!0)),A&&(this.addCurrentVertex(w,L,-1,-1,v,!0),this.addCurrentVertex(w,L,0,0,v)));if(le&&O<m-1){let se=w.dist(A);if(se>2*x){let de=w.add(A.sub(w)._mult(x/se)._round());this.updateDistance(w,de),this.addCurrentVertex(de,L,0,0,v),w=de}}}}addCurrentVertex(e,r,n,s,c,u=!1){let p=r.y*s-r.x,m=-r.y-r.x*s;this.addHalfVertex(e,r.x+r.y*n,r.y-r.x*n,u,!1,n,c),this.addHalfVertex(e,p,m,u,!0,-s,c)}addHalfVertex({x:e,y:r},n,s,c,u,p,m){this.layoutVertexArray.emplaceBack((e<<1)+(c?1:0),(r<<1)+(u?1:0),Math.round(63*n)+128,Math.round(63*s)+128,1+(p===0?0:p<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);let g=m.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,g),m.primitiveLength++),u?this.e2=g:this.e1=g}updateScaledDistance(){if(this.lineClips){let 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,r){this.distance+=e.dist(r),this.updateScaledDistance()}}ze(Ac,"LineBucket",{omit:["layers","patternFeatures"]});let Df=new M({"line-cap":new y(oe.layout_line["line-cap"]),"line-join":new y(oe.layout_line["line-join"]),"line-miter-limit":new _(oe.layout_line["line-miter-limit"]),"line-round-limit":new _(oe.layout_line["line-round-limit"]),"line-sort-key":new y(oe.layout_line["line-sort-key"])});var np={paint:new M({"line-opacity":new y(oe.paint_line["line-opacity"]),"line-color":new y(oe.paint_line["line-color"]),"line-translate":new _(oe.paint_line["line-translate"]),"line-translate-anchor":new _(oe.paint_line["line-translate-anchor"]),"line-width":new y(oe.paint_line["line-width"]),"line-gap-width":new y(oe.paint_line["line-gap-width"]),"line-offset":new y(oe.paint_line["line-offset"]),"line-blur":new y(oe.paint_line["line-blur"]),"line-dasharray":new b(oe.paint_line["line-dasharray"]),"line-pattern":new b(oe.paint_line["line-pattern"]),"line-gradient":new E(oe.paint_line["line-gradient"])}),layout:Df};let op=new class extends y{possiblyEvaluate(i,e){return e=new Tt(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(i,e)}evaluate(i,e,r,n){return e=Gt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(i,e,r,n)}}(np.paint.properties["line-width"].specification);function sp(i,e){return e>0?e+2*i:i}op.useIntegerZoom=!0;let Pf=G([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),Lf=G([{name:"a_projected_pos",components:3,type:"Float32"}],4);G([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let Bf=G([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Rf=G([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);G([{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"}]);let ap=G([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ff=G([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);G([{name:"triangle",components:3,type:"Uint16"}]),G([{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"}]),G([{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"}]),G([{type:"Float32",name:"offsetX"}]),G([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var ei=24;let Rr=128;function Fh(i,e){let{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new Tt(i+1))};if(r.kind==="source")return{kind:"source"};{let{zoomStops:n,interpolationType:s}=r,c=0;for(;c<n.length&&n[c]<=i;)c++;c=Math.max(0,c-1);let u=c;for(;u<n.length&&n[u]<i+1;)u++;u=Math.min(n.length-1,u);let p=n[c],m=n[u];return r.kind==="composite"?{kind:"composite",minZoom:p,maxZoom:m,interpolationType:s}:{kind:"camera",minZoom:p,maxZoom:m,minSize:r.evaluate(new Tt(p)),maxSize:r.evaluate(new Tt(m)),interpolationType:s}}}function Cc(i,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:s}){return i.kind==="source"?n/Rr:i.kind==="composite"?je(n/Rr,s/Rr,r):e}function Xs(i,e){let r=0,n=0;if(i.kind==="constant")n=i.layoutSize;else if(i.kind!=="source"){let{interpolationType:s,minZoom:c,maxZoom:u}=i,p=s?at(fi.interpolationFactor(s,e,c,u),0,1):0;i.kind==="camera"?n=je(i.minSize,i.maxSize,p):r=p}return{uSizeT:r,uSize:n}}var Of=Object.freeze({__proto__:null,getSizeData:Fh,evaluateSizeForFeature:Cc,evaluateSizeForZoom:Xs,SIZE_PACK_FACTOR:Rr});function Uf(i,e,r){return i.sections.forEach(n=>{n.text=function(s,c,u){let p=c.layout.get("text-transform").evaluate(u,{});return p==="uppercase"?s=s.toLocaleUpperCase():p==="lowercase"&&(s=s.toLocaleLowerCase()),Ii.applyArabicShaping&&(s=Ii.applyArabicShaping(s)),s}(n.text,e,r)}),i}let ol={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};function Vf(i){return i==="\uFE36"||i==="\uFE48"||i==="\uFE38"||i==="\uFE44"||i==="\uFE42"||i==="\uFE3E"||i==="\uFE3C"||i==="\uFE3A"||i==="\uFE18"||i==="\uFE40"||i==="\uFE10"||i==="\uFE13"||i==="\uFE14"||i==="\uFF40"||i==="\uFFE3"||i==="\uFE11"||i==="\uFE12"}function jf(i){return i==="\uFE35"||i==="\uFE47"||i==="\uFE37"||i==="\uFE43"||i==="\uFE41"||i==="\uFE3D"||i==="\uFE3B"||i==="\uFE39"||i==="\uFE17"||i==="\uFE3F"}var lp=function(i,e,r,n,s){var c,u,p=8*s-n-1,m=(1<<p)-1,g=m>>1,x=-7,v=r?s-1:0,w=r?-1:1,S=i[e+v];for(v+=w,c=S&(1<<-x)-1,S>>=-x,x+=p;x>0;c=256*c+i[e+v],v+=w,x-=8);for(u=c&(1<<-x)-1,c>>=-x,x+=n;x>0;u=256*u+i[e+v],v+=w,x-=8);if(c===0)c=1-g;else{if(c===m)return u?NaN:1/0*(S?-1:1);u+=Math.pow(2,n),c-=g}return(S?-1:1)*u*Math.pow(2,c-n)},cp=function(i,e,r,n,s,c){var u,p,m,g=8*c-s-1,x=(1<<g)-1,v=x>>1,w=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:c-1,A=n?1:-1,k=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,u=x):(u=Math.floor(Math.log(e)/Math.LN2),e*(m=Math.pow(2,-u))<1&&(u--,m*=2),(e+=u+v>=1?w/m:w*Math.pow(2,1-v))*m>=2&&(u++,m/=2),u+v>=x?(p=0,u=x):u+v>=1?(p=(e*m-1)*Math.pow(2,s),u+=v):(p=e*Math.pow(2,v-1)*Math.pow(2,s),u=0));s>=8;i[r+S]=255&p,S+=A,p/=256,s-=8);for(u=u<<s|p,g+=s;g>0;i[r+S]=255&u,S+=A,u/=256,g-=8);i[r+S-A]|=128*k},sl=wt;function wt(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}wt.Varint=0,wt.Fixed64=1,wt.Bytes=2,wt.Fixed32=5;var Oh=4294967296,hp=1/Oh,up=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function _n(i){return i.type===wt.Bytes?i.readVarint()+i.pos:i.pos+1}function Ws(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function pp(i,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var s=r.pos-1;s>=i;s--)r.buf[s+n]=r.buf[s]}function Nf(i,e){for(var r=0;r<i.length;r++)e.writeVarint(i[r])}function Gf(i,e){for(var r=0;r<i.length;r++)e.writeSVarint(i[r])}function Zf(i,e){for(var r=0;r<i.length;r++)e.writeFloat(i[r])}function $f(i,e){for(var r=0;r<i.length;r++)e.writeDouble(i[r])}function qf(i,e){for(var r=0;r<i.length;r++)e.writeBoolean(i[r])}function Xf(i,e){for(var r=0;r<i.length;r++)e.writeFixed32(i[r])}function Wf(i,e){for(var r=0;r<i.length;r++)e.writeSFixed32(i[r])}function Hf(i,e){for(var r=0;r<i.length;r++)e.writeFixed64(i[r])}function Yf(i,e){for(var r=0;r<i.length;r++)e.writeSFixed64(i[r])}function zc(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+16777216*i[e+3]}function Hs(i,e,r){i[r]=e,i[r+1]=e>>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function dp(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}function Kf(i,e,r){e.glyphs=[],i===1&&r.readMessage(Jf,e)}function Jf(i,e,r){if(i===3){let{id:n,bitmap:s,width:c,height:u,left:p,top:m,advance:g}=r.readMessage(Qf,{});e.glyphs.push({id:n,bitmap:new mn({width:c+6,height:u+6},s),metrics:{width:c,height:u,left:p,top:m,advance:g}})}else i===4?e.ascender=r.readSVarint():i===5&&(e.descender=r.readSVarint())}function Qf(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}function Uh(i){let e=0,r=0;for(let u of i)e+=u.w*u.h,r=Math.max(r,u.w);i.sort((u,p)=>p.h-u.h);let n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}],s=0,c=0;for(let u of i)for(let p=n.length-1;p>=0;p--){let m=n[p];if(!(u.w>m.w||u.h>m.h)){if(u.x=m.x,u.y=m.y,c=Math.max(c,u.y+u.h),s=Math.max(s,u.x+u.w),u.w===m.w&&u.h===m.h){let g=n.pop();p<n.length&&(n[p]=g)}else u.h===m.h?(m.x+=u.w,m.w-=u.w):u.w===m.w?(m.y+=u.h,m.h-=u.h):(n.push({x:m.x+u.w,y:m.y,w:m.w-u.w,h:u.h}),m.y+=u.h,m.h-=u.h);break}}return{w:s,h:c,fill:e/(s*c)||0}}wt.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),s=n>>3,c=this.pos;this.type=7&n,i(s,e,this),this.pos===c&&this.skip(n)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=zc(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=dp(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=zc(this.buf,this.pos)+zc(this.buf,this.pos+4)*Oh;return this.pos+=8,i},readSFixed64:function(){var i=zc(this.buf,this.pos)+dp(this.buf,this.pos+4)*Oh;return this.pos+=8,i},readFloat:function(){var i=lp(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=lp(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(s,c,u){var p,m,g=u.buf;if(p=(112&(m=g[u.pos++]))>>4,m<128||(p|=(127&(m=g[u.pos++]))<<3,m<128)||(p|=(127&(m=g[u.pos++]))<<10,m<128)||(p|=(127&(m=g[u.pos++]))<<17,m<128)||(p|=(127&(m=g[u.pos++]))<<24,m<128)||(p|=(1&(m=g[u.pos++]))<<31,m<128))return Ws(s,p,c);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i=this.readVarint()+this.pos,e=this.pos;return this.pos=i,i-e>=12&&up?function(r,n,s){return up.decode(r.subarray(n,s))}(this.buf,e,i):function(r,n,s){for(var c="",u=n;u<s;){var p,m,g,x=r[u],v=null,w=x>239?4:x>223?3:x>191?2:1;if(u+w>s)break;w===1?x<128&&(v=x):w===2?(192&(p=r[u+1]))==128&&(v=(31&x)<<6|63&p)<=127&&(v=null):w===3?(m=r[u+2],(192&(p=r[u+1]))==128&&(192&m)==128&&((v=(15&x)<<12|(63&p)<<6|63&m)<=2047||v>=55296&&v<=57343)&&(v=null)):w===4&&(m=r[u+2],g=r[u+3],(192&(p=r[u+1]))==128&&(192&m)==128&&(192&g)==128&&((v=(15&x)<<18|(63&p)<<12|(63&m)<<6|63&g)<=65535||v>=1114112)&&(v=null)),v===null?(v=65533,w=1):v>65535&&(v-=65536,c+=String.fromCharCode(v>>>10&1023|55296),v=56320|1023&v),c+=String.fromCharCode(v),u+=w}return c}(this.buf,e,i)},readBytes:function(){var i=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,i);return this.pos=i,e},readPackedVarint:function(i,e){if(this.type!==wt.Bytes)return i.push(this.readVarint(e));var r=_n(this);for(i=i||[];this.pos<r;)i.push(this.readVarint(e));return i},readPackedSVarint:function(i){if(this.type!==wt.Bytes)return i.push(this.readSVarint());var e=_n(this);for(i=i||[];this.pos<e;)i.push(this.readSVarint());return i},readPackedBoolean:function(i){if(this.type!==wt.Bytes)return i.push(this.readBoolean());var e=_n(this);for(i=i||[];this.pos<e;)i.push(this.readBoolean());return i},readPackedFloat:function(i){if(this.type!==wt.Bytes)return i.push(this.readFloat());var e=_n(this);for(i=i||[];this.pos<e;)i.push(this.readFloat());return i},readPackedDouble:function(i){if(this.type!==wt.Bytes)return i.push(this.readDouble());var e=_n(this);for(i=i||[];this.pos<e;)i.push(this.readDouble());return i},readPackedFixed32:function(i){if(this.type!==wt.Bytes)return i.push(this.readFixed32());var e=_n(this);for(i=i||[];this.pos<e;)i.push(this.readFixed32());return i},readPackedSFixed32:function(i){if(this.type!==wt.Bytes)return i.push(this.readSFixed32());var e=_n(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed32());return i},readPackedFixed64:function(i){if(this.type!==wt.Bytes)return i.push(this.readFixed64());var e=_n(this);for(i=i||[];this.pos<e;)i.push(this.readFixed64());return i},readPackedSFixed64:function(i){if(this.type!==wt.Bytes)return i.push(this.readSFixed64());var e=_n(this);for(i=i||[];this.pos<e;)i.push(this.readSFixed64());return i},skip:function(i){var e=7&i;if(e===wt.Varint)for(;this.buf[this.pos++]>127;);else if(e===wt.Bytes)this.pos=this.readVarint()+this.pos;else if(e===wt.Fixed32)this.pos+=4;else{if(e!==wt.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(i,e){this.writeVarint(i<<3|e)},realloc:function(i){for(var e=this.length||16;e<this.pos+i;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(i){this.realloc(4),Hs(this.buf,i,this.pos),this.pos+=4},writeSFixed32:function(i){this.realloc(4),Hs(this.buf,i,this.pos),this.pos+=4},writeFixed64:function(i){this.realloc(8),Hs(this.buf,-1&i,this.pos),Hs(this.buf,Math.floor(i*hp),this.pos+4),this.pos+=8},writeSFixed64:function(i){this.realloc(8),Hs(this.buf,-1&i,this.pos),Hs(this.buf,Math.floor(i*hp),this.pos+4),this.pos+=8},writeVarint:function(i){(i=+i||0)>268435455||i<0?function(e,r){var n,s;if(e>=0?(n=e%4294967296|0,s=e/4294967296|0):(s=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,s=s+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(c,u,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,r),function(c,u){var p=(7&c)<<4;u.buf[u.pos++]|=p|((c>>>=3)?128:0),c&&(u.buf[u.pos++]=127&c|((c>>>=7)?128:0),c&&(u.buf[u.pos++]=127&c|((c>>>=7)?128:0),c&&(u.buf[u.pos++]=127&c|((c>>>=7)?128:0),c&&(u.buf[u.pos++]=127&c|((c>>>=7)?128:0),c&&(u.buf[u.pos++]=127&c)))))}(s,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var e=this.pos;this.pos=function(n,s,c){for(var u,p,m=0;m<s.length;m++){if((u=s.charCodeAt(m))>55295&&u<57344){if(!p){u>56319||m+1===s.length?(n[c++]=239,n[c++]=191,n[c++]=189):p=u;continue}if(u<56320){n[c++]=239,n[c++]=191,n[c++]=189,p=u;continue}u=p-55296<<10|u-56320|65536,p=null}else p&&(n[c++]=239,n[c++]=191,n[c++]=189,p=null);u<128?n[c++]=u:(u<2048?n[c++]=u>>6|192:(u<65536?n[c++]=u>>12|224:(n[c++]=u>>18|240,n[c++]=u>>12&63|128),n[c++]=u>>6&63|128),n[c++]=63&u|128)}return c}(this.buf,i,this.pos);var r=this.pos-e;r>=128&&pp(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),cp(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),cp(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var e=i.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=i[r]},writeRawMessage:function(i,e){this.pos++;var r=this.pos;i(e,this);var n=this.pos-r;n>=128&&pp(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(i,e,r){this.writeTag(i,wt.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,Nf,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,Gf,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,qf,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,Zf,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,$f,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,Xf,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,Wf,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,Hf,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,Yf,e)},writeBytesField:function(i,e){this.writeTag(i,wt.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,wt.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,wt.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,wt.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,wt.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,wt.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,wt.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,wt.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,wt.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,wt.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,Boolean(e))}};class Vh{constructor(e,{pixelRatio:r,version:n,stretchX:s,stretchY:c,content:u}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=s,this.stretchY=c,this.content=u,this.version=n}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class fp{constructor(e,r){let n={},s={};this.haveRenderCallbacks=[];let c=[];this.addImages(e,n,c),this.addImages(r,s,c);let{w:u,h:p}=Uh(c),m=new Ci({width:u||1,height:p||1});for(let g in e){let x=e[g],v=n[g].paddedRect;Ci.copy(x.data,m,{x:0,y:0},{x:v.x+1,y:v.y+1},x.data)}for(let g in r){let x=r[g],v=s[g].paddedRect,w=v.x+1,S=v.y+1,A=x.data.width,k=x.data.height;Ci.copy(x.data,m,{x:0,y:0},{x:w,y:S},x.data),Ci.copy(x.data,m,{x:0,y:k-1},{x:w,y:S-1},{width:A,height:1}),Ci.copy(x.data,m,{x:0,y:0},{x:w,y:S+k},{width:A,height:1}),Ci.copy(x.data,m,{x:A-1,y:0},{x:w-1,y:S},{width:1,height:k}),Ci.copy(x.data,m,{x:0,y:0},{x:w+A,y:S},{width:1,height:k})}this.image=m,this.iconPositions=n,this.patternPositions=s}addImages(e,r,n){for(let s in e){let c=e[s],u={x:0,y:0,w:c.data.width+2,h:c.data.height+2};n.push(u),r[s]=new Vh(u,c),c.hasRenderCallback&&this.haveRenderCallbacks.push(s)}}patchUpdatedImages(e,r){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(n=>e.hasImage(n)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(let n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),r)}patchUpdatedImage(e,r,n){if(!e||!r||e.version===r.version)return;e.version=r.version;let[s,c]=e.tl;n.update(r.data,void 0,{x:s,y:c})}}ze(Vh,"ImagePosition"),ze(fp,"ImageAtlas");let Xi={horizontal:1,vertical:2,horizontalOnly:3};class al{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){let n=new al;return n.scale=e||1,n.fontStack=r,n}static forImage(e){let r=new al;return r.imageName=e,r}}class Ys{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){let n=new Ys;for(let s=0;s<e.sections.length;s++){let c=e.sections[s];c.image?n.addImageSection(c):n.addTextSection(c,r)}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(r,n){let s="";for(let c=0;c<r.length;c++){let u=r.charCodeAt(c+1)||null,p=r.charCodeAt(c-1)||null;s+=!n&&(u&&Bs(u)&&!ol[r[c+1]]||p&&Bs(p)&&!ol[r[c-1]])||!ol[r[c]]?r[c]:ol[r[c]]}return s}(this.text,e)}trim(){let e=0;for(let n=0;n<this.text.length&&kc[this.text.charCodeAt(n)];n++)e++;let r=this.text.length;for(let n=this.text.length-1;n>=0&&n>=e&&kc[this.text.charCodeAt(n)];n--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){let n=new Ys;return n.text=this.text.substring(e,r),n.sectionIndex=this.sectionIndex.slice(e,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(al.forText(e.scale,e.fontStack||r));let n=this.sections.length-1;for(let s=0;s<e.text.length;++s)this.sectionIndex.push(n)}addImageSection(e){let r=e.image?e.image.name:"";if(r.length===0)return void bt("Can't add FormattedSection with an empty image.");let n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push(al.forImage(r)),this.sectionIndex.push(this.sections.length-1)):bt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function jh(i,e,r,n,s,c,u,p,m,g,x,v,w,S,A,k){let L=Ys.fromFeature(i,s),O;v===Xi.vertical&&L.verticalizePunctuation(w);let{processBidirectionalText:q,processStyledBidirectionalText:H}=Ii;if(q&&L.sections.length===1){O=[];let Q=q(L.toString(),Nh(L,g,c,e,n,S,A));for(let le of Q){let he=new Ys;he.text=le,he.sections=L.sections;for(let fe=0;fe<le.length;fe++)he.sectionIndex.push(0);O.push(he)}}else if(H){O=[];let Q=H(L.text,L.sectionIndex,Nh(L,g,c,e,n,S,A));for(let le of Q){let he=new Ys;he.text=le[0],he.sectionIndex=le[1],he.sections=L.sections,O.push(he)}}else O=function(Q,le){let he=[],fe=Q.text,ge=0;for(let se of le)he.push(Q.substring(ge,se)),ge=se;return ge<fe.length&&he.push(Q.substring(ge,fe.length)),he}(L,Nh(L,g,c,e,n,S,A));let K=[],J={positionedLines:K,text:L.toString(),top:x[1],bottom:x[1],left:x[0],right:x[0],writingMode:v,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(Q,le,he,fe,ge,se,de,xe,Se,be,Ee,Xe){let Qe=0,We=0,Ke=0,Re=xe==="right"?1:xe==="left"?0:.5,Ce=!1;for(let _t of ge){let nt=_t.getSections();for(let xt of nt){if(xt.imageName)continue;let kt=le[xt.fontStack];if(kt&&(Ce=kt.ascender!==void 0&&kt.descender!==void 0,!Ce))break}if(!Ce)break}let it=0;for(let _t of ge){_t.trim();let nt=_t.getMaxScale(),xt=(nt-1)*ei,kt={positionedGlyphs:[],lineOffset:0};Q.positionedLines[it]=kt;let Lt=kt.positionedGlyphs,Nt=0;if(!_t.length()){We+=se,++it;continue}let $t=0,Di=0;for(let vt=0;vt<_t.length();vt++){let li=_t.getSection(vt),Pi=_t.getSectionIndex(vt),Ht=_t.getCharCode(vt),qt=li.scale,It=null,St=null,bi=null,ci=ei,Ot=0,hi=!(Se===Xi.horizontal||!Ee&&!Ls(Ht)||Ee&&(kc[Ht]||(mt=Ht,Kl(mt)||Cs(mt)||Bo(mt)||Ra(mt)||Ds(mt))));if(li.imageName){let ii=fe[li.imageName];if(!ii)continue;bi=li.imageName,Q.iconsInText=Q.iconsInText||!0,St=ii.paddedRect;let Xt=ii.displaySize;qt=qt*ei/Xe,It={width:Xt[0],height:Xt[1],left:1,top:-3,advance:hi?Xt[1]:Xt[0],localGlyph:!1},Ot=Ce?-It.height*qt:nt*ei-17-Xt[1]*qt,ci=It.advance;let rr=(hi?Xt[0]:Xt[1])*qt-ei*nt;rr>0&&rr>Nt&&(Nt=rr)}else{let ii=he[li.fontStack];if(!ii)continue;ii[Ht]&&(St=ii[Ht]);let Xt=le[li.fontStack];if(!Xt)continue;let rr=Xt.glyphs[Ht];if(!rr)continue;if(It=rr.metrics,ci=Ht!==8203?ei:0,Ce){let ro=Xt.ascender!==void 0?Math.abs(Xt.ascender):0,gl=Xt.descender!==void 0?Math.abs(Xt.descender):0,yl=(ro+gl)*qt;$t<yl&&($t=yl,Di=(ro-gl)/2*qt),Ot=-ro*qt}else Ot=(nt-qt)*ei-17}hi?(Q.verticalizable=!0,Lt.push({glyph:Ht,imageName:bi,x:Qe,y:We+Ot,vertical:hi,scale:qt,localGlyph:It.localGlyph,fontStack:li.fontStack,sectionIndex:Pi,metrics:It,rect:St}),Qe+=ci*qt+be):(Lt.push({glyph:Ht,imageName:bi,x:Qe,y:We+Ot,vertical:hi,scale:qt,localGlyph:It.localGlyph,fontStack:li.fontStack,sectionIndex:Pi,metrics:It,rect:St}),Qe+=It.advance*qt+be)}Lt.length!==0&&(Ke=Math.max(Qe-be,Ke),Ce?xp(Lt,Re,Nt,Di,se*nt/2):xp(Lt,Re,Nt,0,se/2)),Qe=0;let vi=se*nt+Nt;kt.lineOffset=Math.max(Nt,xt),We+=vi,++it}var mt;let Vt=We,{horizontalAlign:Et,verticalAlign:jt}=Gh(de);(function(_t,nt,xt,kt,Lt,Nt){let $t=(nt-xt)*Lt,Di=-Nt*kt;for(let vi of _t)for(let vt of vi.positionedGlyphs)vt.x+=$t,vt.y+=Di})(Q.positionedLines,Re,Et,jt,Ke,Vt),Q.top+=-jt*Vt,Q.bottom=Q.top+Vt,Q.left+=-Et*Ke,Q.right=Q.left+Ke,Q.hasBaseline=Ce}(J,e,r,n,O,u,p,m,v,g,w,k),!function(Q){for(let le of Q)if(le.positionedGlyphs.length!==0)return!1;return!0}(K)&&J}let kc={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},em={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 mp(i,e,r,n,s,c){if(e.imageName){let u=n[e.imageName];return u?u.displaySize[0]*e.scale*ei/c+s:0}{let u=r[e.fontStack],p=u&&u.glyphs[i];return p?p.metrics.advance*e.scale+s:0}}function _p(i,e,r,n){let s=Math.pow(i-e,2);return n?i<e?s/2:2*s:s+Math.abs(r)*r}function tm(i,e,r){let n=0;return i===10&&(n-=1e4),r&&(n+=150),i!==40&&i!==65288||(n+=50),e!==41&&e!==65289||(n+=50),n}function gp(i,e,r,n,s,c){let u=null,p=_p(e,r,s,c);for(let m of n){let g=_p(e-m.x,r,s,c)+m.badness;g<=p&&(u=m,p=g)}return{index:i,x:e,priorBreak:u,badness:p}}function yp(i){return i?yp(i.priorBreak).concat(i.index):[]}function Nh(i,e,r,n,s,c,u){if(c!=="point")return[];if(!i)return[];let p=[],m=function(w,S,A,k,L,O){let q=0;for(let H=0;H<w.length();H++){let K=w.getSection(H);q+=mp(w.getCharCode(H),K,k,L,S,O)}return q/Math.max(1,Math.ceil(q/A))}(i,e,r,n,s,u),g=i.text.indexOf("\u200B")>=0,x=0;for(let w=0;w<i.length();w++){let S=i.getSection(w),A=i.getCharCode(w);if(kc[A]||(x+=mp(A,S,n,s,e,u)),w<i.length()-1){let k=!((v=A)<11904||!(ec(v)||Ql(v)||Nn(v)||Fo(v)||rc(v)||Da(v)||tc(v)||zs(v)||nc(v)||Ba(v)||ic(v)||Fa(v)||Ro(v)||Pa(v)||Jl(v)||La(v)||ks(v)||lc(v)||sc(v)||oc(v)));(em[A]||k||S.imageName)&&p.push(gp(w+1,x,m,p,tm(A,i.getCharCode(w+1),k&&g),!1))}}var v;return yp(gp(i.length(),x,m,p,0,!0))}function Gh(i){let e=.5,r=.5;switch(i){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(i){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function xp(i,e,r,n,s){if(!(e||r||n||s))return;let c=i.length-1,u=i[c],p=(u.x+u.metrics.advance*u.scale)*e;for(let m=0;m<=c;m++)i[m].x-=p,i[m].y+=r+n+s}function im(i,e,r){let{horizontalAlign:n,verticalAlign:s}=Gh(r),c=e[0]-i.displaySize[0]*n,u=e[1]-i.displaySize[1]*s;return{image:i,top:u,bottom:u+i.displaySize[1],left:c,right:c+i.displaySize[0]}}function vp(i,e,r,n,s,c){let u=i.image,p;if(u.content){let L=u.content,O=u.pixelRatio||1;p=[L[0]/O,L[1]/O,u.displaySize[0]-L[2]/O,u.displaySize[1]-L[3]/O]}let m=e.left*c,g=e.right*c,x,v,w,S;r==="width"||r==="both"?(S=s[0]+m-n[3],v=s[0]+g+n[1]):(S=s[0]+(m+g-u.displaySize[0])/2,v=S+u.displaySize[0]);let A=e.top*c,k=e.bottom*c;return r==="height"||r==="both"?(x=s[1]+A-n[0],w=s[1]+k+n[2]):(x=s[1]+(A+k-u.displaySize[1])/2,w=x+u.displaySize[1]),{image:u,top:x,right:v,bottom:w,left:S,collisionPadding:p}}class gn extends _e{constructor(e,r,n,s,c){super(e,r),this.angle=s,this.z=n,c!==void 0&&(this.segment=c)}clone(){return new gn(this.x,this.y,this.z,this.angle,this.segment)}}function bp(i,e,r,n,s){if(e.segment===void 0)return!0;let c=e,u=e.segment+1,p=0;for(;p>-r/2;){if(u--,u<0)return!1;p-=i[u].dist(c),c=i[u]}p+=i[u].dist(i[u+1]),u++;let m=[],g=0;for(;p<r/2;){let x=i[u],v=i[u+1];if(!v)return!1;let w=i[u-1].angleTo(x)-x.angleTo(v);for(w=Math.abs((w+3*Math.PI)%(2*Math.PI)-Math.PI),m.push({distance:p,angleDelta:w}),g+=w;p-m[0].distance>n;)g-=m.shift().angleDelta;if(g>s)return!1;u++,p+=x.dist(v)}return!0}function wp(i){let e=0;for(let r=0;r<i.length-1;r++)e+=i[r].dist(i[r+1]);return e}function Tp(i,e,r){return i?.6*e*r:0}function Ep(i,e){return Math.max(i?i.right-i.left:0,e?e.right-e.left:0)}function rm(i,e,r,n,s,c){let u=Tp(r,s,c),p=Ep(r,n)*c,m=0,g=wp(i)/2;for(let x=0;x<i.length-1;x++){let v=i[x],w=i[x+1],S=v.dist(w);if(m+S>g){let A=(g-m)/S,k=je(v.x,w.x,A),L=je(v.y,w.y,A),O=new gn(k,L,0,w.angleTo(v),x);return!u||bp(i,O,p,u,e)?O:void 0}m+=S}}function nm(i,e,r,n,s,c,u,p,m){let g=Tp(n,c,u),x=Ep(n,s),v=x*u,w=i[0].x===0||i[0].x===m||i[0].y===0||i[0].y===m;return e-v<e/4&&(e=v+e/4),Sp(i,w?e/2*p%e:(x/2+2*c)*u*p%e,e,g,r,v,w,!1,m)}function Sp(i,e,r,n,s,c,u,p,m){let g=c/2,x=wp(i),v=0,w=e-r,S=[];for(let A=0;A<i.length-1;A++){let k=i[A],L=i[A+1],O=k.dist(L),q=L.angleTo(k);for(;w+r<v+O;){w+=r;let H=(w-v)/O,K=je(k.x,L.x,H),J=je(k.y,L.y,H);if(K>=0&&K<m&&J>=0&&J<m&&w-g>=0&&w+g<=x){let Q=new gn(K,J,0,q,A);Q._round(),n&&!bp(i,Q,c,n,s)||S.push(Q)}}v+=O}return p||S.length||u||(S=Sp(i,v/2,r,n,s,c,u,!0,m)),S}function Ip(i,e,r,n,s){let c=[];for(let u=0;u<i.length;u++){let p=i[u],m;for(let g=0;g<p.length-1;g++){let x=p[g],v=p[g+1];x.x<e&&v.x<e||(x.x<e?x=new _e(e,x.y+(e-x.x)/(v.x-x.x)*(v.y-x.y))._round():v.x<e&&(v=new _e(e,x.y+(e-x.x)/(v.x-x.x)*(v.y-x.y))._round()),x.y<r&&v.y<r||(x.y<r?x=new _e(x.x+(r-x.y)/(v.y-x.y)*(v.x-x.x),r)._round():v.y<r&&(v=new _e(x.x+(r-x.y)/(v.y-x.y)*(v.x-x.x),r)._round()),x.x>=n&&v.x>=n||(x.x>=n?x=new _e(n,x.y+(n-x.x)/(v.x-x.x)*(v.y-x.y))._round():v.x>=n&&(v=new _e(n,x.y+(n-x.x)/(v.x-x.x)*(v.y-x.y))._round()),x.y>=s&&v.y>=s||(x.y>=s?x=new _e(x.x+(s-x.y)/(v.y-x.y)*(v.x-x.x),s)._round():v.y>=s&&(v=new _e(x.x+(s-x.y)/(v.y-x.y)*(v.x-x.x),s)._round()),m&&x.equals(m[m.length-1])||(m=[x],c.push(m)),m.push(v)))))}}return c}ze(gn,"Anchor");let ll=1e20;function Mp(i,e,r,n,s,c,u,p,m){for(let g=e;g<e+n;g++)Ap(i,r*c+g,c,s,u,p,m);for(let g=r;g<r+s;g++)Ap(i,g*c+e,1,n,u,p,m)}function Ap(i,e,r,n,s,c,u){c[0]=0,u[0]=-ll,u[1]=ll,s[0]=i[e];for(let p=1,m=0,g=0;p<n;p++){s[p]=i[e+p*r];let x=p*p;do{let v=c[m];g=(s[p]-s[v]+x-v*v)/(p-v)/2}while(g<=u[m]&&--m>-1);m++,c[m]=p,u[m]=g,u[m+1]=ll}for(let p=0,m=0;p<n;p++){for(;u[m+1]<p;)m++;let g=c[m],x=p-g;i[e+p*r]=s[g]+x*x}}let Zh={none:0,ideographs:1,all:2};class Ks{constructor(e,r,n){this.requestManager=e,this.localGlyphMode=r,this.localFontFamily=n,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,r){let n=[];for(let s in e)for(let c of e[s])n.push({stack:s,id:c});vn(n,({stack:s,id:c},u)=>{let p=this.entries[s];p||(p=this.entries[s]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let m=p.glyphs[c];if(m!==void 0)return void u(null,{stack:s,id:c,glyph:m});if(m=this._tinySDF(p,s,c),m)return p.glyphs[c]=m,void u(null,{stack:s,id:c,glyph:m});let g=Math.floor(c/256);if(256*g>65535)return void u(new Error("glyphs > 65535 not supported"));if(p.ranges[g])return void u(null,{stack:s,id:c,glyph:m});let x=p.requests[g];x||(x=p.requests[g]=[],Ks.loadGlyphRange(s,g,this.url,this.requestManager,(v,w)=>{if(w){p.ascender=w.ascender,p.descender=w.descender;for(let S in w.glyphs)this._doesCharSupportLocalGlyph(+S)||(p.glyphs[+S]=w.glyphs[+S]);p.ranges[g]=!0}for(let S of x)S(v,w);delete p.requests[g]})),x.push((v,w)=>{v?u(v):w&&u(null,{stack:s,id:c,glyph:w.glyphs[c]||null})})},(s,c)=>{if(s)r(s);else if(c){let u={};for(let{stack:p,id:m,glyph:g}of c)u[p]===void 0&&(u[p]={}),u[p].glyphs===void 0&&(u[p].glyphs={}),u[p].glyphs[m]=g&&{id:g.id,bitmap:g.bitmap.clone(),metrics:g.metrics},u[p].ascender=this.entries[p].ascender,u[p].descender=this.entries[p].descender;r(null,u)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Zh.none&&(this.localGlyphMode===Zh.all?!!this.localFontFamily:!!this.localFontFamily&&(Ba(e)||ac(e)||Ro(e)||ks(e)||zs(e)))}_tinySDF(e,r,n){let s=this.localFontFamily;if(!s||!this._doesCharSupportLocalGlyph(n))return;let c=e.tinySDF;if(!c){let k="400";/bold/i.test(r)?k="900":/medium/i.test(r)?k="500":/light/i.test(r)&&(k="200"),c=e.tinySDF=new Ks.TinySDF({fontFamily:s,fontWeight:k,fontSize:48,buffer:6,radius:16}),c.fontWeight=k}if(this.localGlyphs[c.fontWeight][n])return this.localGlyphs[c.fontWeight][n];let u=String.fromCharCode(n),{data:p,width:m,height:g,glyphWidth:x,glyphHeight:v,glyphLeft:w,glyphTop:S,glyphAdvance:A}=c.draw(u);return this.localGlyphs[c.fontWeight][n]={id:n,bitmap:new mn({width:m,height:g},p),metrics:{width:x/2,height:v/2,left:w/2,top:S/2-27,advance:A/2,localGlyph:!0}}}}function Cp(i,e,r,n){let s=[],c=i.image,u=c.pixelRatio,p=c.paddedRect.w-2,m=c.paddedRect.h-2,g=i.right-i.left,x=i.bottom-i.top,v=c.stretchX||[[0,p]],w=c.stretchY||[[0,m]],S=(se,de)=>se+de[1]-de[0],A=v.reduce(S,0),k=w.reduce(S,0),L=p-A,O=m-k,q=0,H=A,K=0,J=k,Q=0,le=L,he=0,fe=O;if(c.content&&n){let se=c.content;q=Dc(v,0,se[0]),K=Dc(w,0,se[1]),H=Dc(v,se[0],se[2]),J=Dc(w,se[1],se[3]),Q=se[0]-q,he=se[1]-K,le=se[2]-se[0]-H,fe=se[3]-se[1]-J}let ge=(se,de,xe,Se)=>{let be=Pc(se.stretch-q,H,g,i.left),Ee=Lc(se.fixed-Q,le,se.stretch,A),Xe=Pc(de.stretch-K,J,x,i.top),Qe=Lc(de.fixed-he,fe,de.stretch,k),We=Pc(xe.stretch-q,H,g,i.left),Ke=Lc(xe.fixed-Q,le,xe.stretch,A),Re=Pc(Se.stretch-K,J,x,i.top),Ce=Lc(Se.fixed-he,fe,Se.stretch,k),it=new _e(be,Xe),mt=new _e(We,Xe),Vt=new _e(We,Re),Et=new _e(be,Re),jt=new _e(Ee/u,Qe/u),_t=new _e(Ke/u,Ce/u),nt=e*Math.PI/180;if(nt){let Lt=Math.sin(nt),Nt=Math.cos(nt),$t=[Nt,-Lt,Lt,Nt];it._matMult($t),mt._matMult($t),Et._matMult($t),Vt._matMult($t)}let xt=se.stretch+se.fixed,kt=de.stretch+de.fixed;return{tl:it,tr:mt,bl:Et,br:Vt,tex:{x:c.paddedRect.x+1+xt,y:c.paddedRect.y+1+kt,w:xe.stretch+xe.fixed-xt,h:Se.stretch+Se.fixed-kt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:jt,pixelOffsetBR:_t,minFontScaleX:le/u/g,minFontScaleY:fe/u/x,isSDF:r}};if(n&&(c.stretchX||c.stretchY)){let se=zp(v,L,A),de=zp(w,O,k);for(let xe=0;xe<se.length-1;xe++){let Se=se[xe],be=se[xe+1];for(let Ee=0;Ee<de.length-1;Ee++)s.push(ge(Se,de[Ee],be,de[Ee+1]))}}else s.push(ge({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:p+1},{fixed:0,stretch:m+1}));return s}function Dc(i,e,r){let n=0;for(let s of i)n+=Math.max(e,Math.min(r,s[1]))-Math.max(e,Math.min(r,s[0]));return n}function zp(i,e,r){let n=[{fixed:-1,stretch:0}];for(let[s,c]of i){let u=n[n.length-1];n.push({fixed:s-u.stretch,stretch:u.stretch}),n.push({fixed:s-u.stretch,stretch:u.stretch+(c-s)})}return n.push({fixed:e+1,stretch:r}),n}function Pc(i,e,r,n){return i/e*r+n}function Lc(i,e,r,n){return i-e*r/n}function om(i,e,r,n){let s=e+i.positionedLines[n].lineOffset;return n===0?r+s/2:r+(s+(e+i.positionedLines[n-1].lineOffset))/2}Ks.loadGlyphRange=function(i,e,r,n,s){let c=256*e,u=c+255,p=n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",i).replace("{range}",`${c}-${u}`),U.Glyphs);Z(p,(m,g)=>{if(m)s(m);else if(g){let x={},v=function(w){return new sl(w).readFields(Kf,{})}(g);for(let w of v.glyphs)x[w.id]=w;s(null,{glyphs:x,ascender:v.ascender,descender:v.descender})}})},Ks.TinySDF=class{constructor({fontSize:i=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:s="sans-serif",fontWeight:c="normal",fontStyle:u="normal"}){this.buffer=e,this.cutoff=n,this.radius=r;let p=this.size=i+4*e,m=this._createCanvas(p),g=this.ctx=m.getContext("2d",{willReadFrequently:!0});g.font=`${u} ${c} ${i}px ${s}`,g.textBaseline="alphabetic",g.textAlign="left",g.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(i){let e=document.createElement("canvas");return e.width=e.height=i,e}draw(i){let{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:s,actualBoundingBoxRight:c}=this.ctx.measureText(i),u=Math.floor(r),p=Math.min(this.size-this.buffer,Math.ceil(c-s)),m=Math.min(this.size-this.buffer,Math.ceil(r)+Math.ceil(n)),g=p+2*this.buffer,x=m+2*this.buffer,v=g*x,w=new Uint8ClampedArray(v),S={data:w,width:g,height:x,glyphWidth:p,glyphHeight:m,glyphTop:u,glyphLeft:0,glyphAdvance:e};if(p===0||m===0)return S;let{ctx:A,buffer:k,gridInner:L,gridOuter:O}=this;A.clearRect(k,k,p,m),A.fillText(i,k,k+u+1);let q=A.getImageData(k,k,p,m);O.fill(ll,0,v),L.fill(0,0,v);for(let H=0;H<m;H++)for(let K=0;K<p;K++){let J=q.data[4*(H*p+K)+3]/255;if(J===0)continue;let Q=(H+k)*g+K+k;if(J===1)O[Q]=0,L[Q]=ll;else{let le=.5-J;O[Q]=le>0?le*le:0,L[Q]=le<0?le*le:0}}Mp(O,0,0,g,x,g,this.f,this.v,this.z),Mp(L,k,k,p,m,g,this.f,this.v,this.z);for(let H=0;H<v;H++){let K=Math.sqrt(O[H])-Math.sqrt(L[H]);w[H]=Math.round(255-255*(K/this.radius+this.cutoff))}return S}};class sm{constructor(e=[],r=am){if(this.data=e,this.length=this.data.length,this.compare=r,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;let e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:r,compare:n}=this,s=r[e];for(;e>0;){let c=e-1>>1,u=r[c];if(n(s,u)>=0)break;r[e]=u,e=c}r[e]=s}_down(e){let{data:r,compare:n}=this,s=this.length>>1,c=r[e];for(;e<s;){let u=1+(e<<1),p=r[u],m=u+1;if(m<this.length&&n(r[m],p)<0&&(u=m,p=r[m]),n(p,c)>=0)break;r[e]=p,e=u}r[e]=c}}function am(i,e){return i<e?-1:i>e?1:0}function lm(i,e=1,r=!1){let n=1/0,s=1/0,c=-1/0,u=-1/0,p=i[0];for(let S=0;S<p.length;S++){let A=p[S];(!S||A.x<n)&&(n=A.x),(!S||A.y<s)&&(s=A.y),(!S||A.x>c)&&(c=A.x),(!S||A.y>u)&&(u=A.y)}let m=Math.min(c-n,u-s),g=m/2,x=new sm([],cm);if(m===0)return new _e(n,s);for(let S=n;S<c;S+=m)for(let A=s;A<u;A+=m)x.push(new Js(S+g,A+g,g,i));let v=function(S){let A=0,k=0,L=0,O=S[0];for(let q=0,H=O.length,K=H-1;q<H;K=q++){let J=O[q],Q=O[K],le=J.x*Q.y-Q.x*J.y;k+=(J.x+Q.x)*le,L+=(J.y+Q.y)*le,A+=3*le}return new Js(k/A,L/A,0,S)}(i),w=x.length;for(;x.length;){let S=x.pop();(S.d>v.d||!v.d)&&(v=S,r&&console.log("found best %d after %d probes",Math.round(1e4*S.d)/1e4,w)),S.max-v.d<=e||(g=S.h/2,x.push(new Js(S.p.x-g,S.p.y-g,g,i)),x.push(new Js(S.p.x+g,S.p.y-g,g,i)),x.push(new Js(S.p.x-g,S.p.y+g,g,i)),x.push(new Js(S.p.x+g,S.p.y+g,g,i)),w+=4)}return r&&(console.log(`num probes: ${w}`),console.log(`best distance: ${v.d}`)),v.p}function cm(i,e){return e.max-i.max}function Js(i,e,r,n){this.p=new _e(i,e),this.h=r,this.d=function(s,c){let u=!1,p=1/0;for(let m=0;m<c.length;m++){let g=c[m];for(let x=0,v=g.length,w=v-1;x<v;w=x++){let S=g[x],A=g[w];S.y>s.y!=A.y>s.y&&s.x<(A.x-S.x)*(s.y-S.y)/(A.y-S.y)+S.x&&(u=!u),p=Math.min(p,Iu(s,S,A))}}return(u?1:-1)*Math.sqrt(p)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}let $h=Number.POSITIVE_INFINITY,hm=Math.sqrt(2);function kp(i,e){return e[1]!==$h?function(r,n,s){let c=0,u=0;switch(n=Math.abs(n),s=Math.abs(s),r){case"top-right":case"top-left":case"top":u=s-7;break;case"bottom-right":case"bottom-left":case"bottom":u=7-s}switch(r){case"top-right":case"bottom-right":case"right":c=-n;break;case"top-left":case"bottom-left":case"left":c=n}return[c,u]}(i,e[0],e[1]):function(r,n){let s=0,c=0;n<0&&(n=0);let u=n/hm;switch(r){case"top-right":case"top-left":c=u-7;break;case"bottom-right":case"bottom-left":c=7-u;break;case"bottom":c=7-n;break;case"top":c=n-7}switch(r){case"top-right":case"bottom-right":s=-u;break;case"top-left":case"bottom-left":s=u;break;case"left":s=n;break;case"right":s=-n}return[s,c]}(i,e[0])}function um(i,e,r,n,s,c,u,p,m,g){i.createArrays(),i.tilePixelRatio=He/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;let x=i.layers[0].layout,v=i.layers[0]._unevaluatedLayout._values,w={};if(i.textSizeData.kind==="composite"){let{minZoom:k,maxZoom:L}=i.textSizeData;w.compositeTextSizes=[v["text-size"].possiblyEvaluate(new Tt(k),p),v["text-size"].possiblyEvaluate(new Tt(L),p)]}if(i.iconSizeData.kind==="composite"){let{minZoom:k,maxZoom:L}=i.iconSizeData;w.compositeIconSizes=[v["icon-size"].possiblyEvaluate(new Tt(k),p),v["icon-size"].possiblyEvaluate(new Tt(L),p)]}w.layoutTextSize=v["text-size"].possiblyEvaluate(new Tt(m+1),p),w.layoutIconSize=v["icon-size"].possiblyEvaluate(new Tt(m+1),p),w.textMaxSize=v["text-size"].possiblyEvaluate(new Tt(18),p);let S=x.get("text-rotation-alignment")==="map"&&x.get("symbol-placement")!=="point",A=x.get("text-size");for(let k of i.features){let L=x.get("text-font").evaluate(k,{},p).join(","),O=A.evaluate(k,{},p),q=w.layoutTextSize.evaluate(k,{},p),H=(w.layoutIconSize.evaluate(k,{},p),{horizontal:{},vertical:void 0}),K=k.text,J,Q=[0,0];if(K){let fe=K.toString(),ge=x.get("text-letter-spacing").evaluate(k,{},p)*ei,se=x.get("text-line-height").evaluate(k,{},p)*ei,de=hc(fe)?ge:0,xe=x.get("text-anchor").evaluate(k,{},p),Se=x.get("text-variable-anchor");if(!Se){let Ke=x.get("text-radial-offset").evaluate(k,{},p);Q=Ke?kp(xe,[Ke*ei,$h]):x.get("text-offset").evaluate(k,{},p).map(Re=>Re*ei)}let be=S?"center":x.get("text-justify").evaluate(k,{},p),Ee=x.get("symbol-placement"),Xe=Ee==="point",Qe=Ee==="point"?x.get("text-max-width").evaluate(k,{},p)*ei:0,We=Ke=>{i.allowVerticalPlacement&&Ps(fe)&&(H.vertical=jh(K,e,r,s,L,Qe,se,xe,Ke,de,Q,Xi.vertical,!0,Ee,q,O))};if(!S&&Se){let Ke=be==="auto"?Se.map(Ce=>qh(Ce)):[be],Re=!1;for(let Ce=0;Ce<Ke.length;Ce++){let it=Ke[Ce];if(!H.horizontal[it])if(Re)H.horizontal[it]=H.horizontal[0];else{let mt=jh(K,e,r,s,L,Qe,se,"center",it,de,Q,Xi.horizontal,!1,Ee,q,O);mt&&(H.horizontal[it]=mt,Re=mt.positionedLines.length===1)}}We("left")}else{if(be==="auto"&&(be=qh(xe)),Xe||x.get("text-writing-mode").indexOf("horizontal")>=0||!Ps(fe)){let Ke=jh(K,e,r,s,L,Qe,se,xe,be,de,Q,Xi.horizontal,!1,Ee,q,O);Ke&&(H.horizontal[be]=Ke)}We(Ee==="point"?"left":be)}}let le=!1;if(k.icon&&k.icon.name){let fe=n[k.icon.name];fe&&(J=im(s[k.icon.name],x.get("icon-offset").evaluate(k,{},p),x.get("icon-anchor").evaluate(k,{},p)),le=fe.sdf,i.sdfIcons===void 0?i.sdfIcons=fe.sdf:i.sdfIcons!==fe.sdf&&bt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(fe.pixelRatio!==i.pixelRatio||x.get("icon-rotate").constantOr(1)!==0)&&(i.iconsNeedLinear=!0))}let he=Pp(H.horizontal)||H.vertical;i.iconsInText||(i.iconsInText=!!he&&he.iconsInText),(he||J)&&pm(i,k,H,J,n,w,q,0,Q,le,u,p,g)}c&&i.generateCollisionDebugBuffers(m,i.collisionBoxArray)}function qh(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function pm(i,e,r,n,s,c,u,p,m,g,x,v,w){let S=c.textMaxSize.evaluate(e,{},v);S===void 0&&(S=u);let A=i.layers[0].layout,k=A.get("icon-offset").evaluate(e,{},v),L=Pp(r.horizontal)||r.vertical,O=u/24,q=i.tilePixelRatio*S/24,H=(se=i.overscaling,i.zoom>18&&se>2&&(se>>=1),Math.max(He/(512*se),1)*A.get("symbol-spacing")),K=A.get("text-padding")*i.tilePixelRatio,J=A.get("icon-padding")*i.tilePixelRatio,Q=lt(A.get("text-max-angle")),le=A.get("text-rotation-alignment")==="map"&&A.get("symbol-placement")!=="point",he=A.get("icon-rotation-alignment")==="map"&&A.get("symbol-placement")!=="point",fe=A.get("symbol-placement"),ge=H/2;var se;let de=A.get("icon-text-fit"),xe;n&&de!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(xe=vp(n,r.vertical,de,A.get("icon-text-fit-padding"),k,O)),L&&(n=vp(n,L,de,A.get("icon-text-fit-padding"),k,O)));let Se=(be,Ee,Xe)=>{if(Ee.x<0||Ee.x>=He||Ee.y<0||Ee.y>=He)return;let{x:Qe,y:We,z:Ke}=w.projectTilePoint(Ee.x,Ee.y,Xe),Re=new gn(Qe,We,Ke,0,void 0);(function(Ce,it,mt,Vt,Et,jt,_t,nt,xt,kt,Lt,Nt,$t,Di,vi,vt,li,Pi,Ht,qt,It,St,bi,ci,Ot){let hi=Ce.addToLineVertexArray(it,Vt),ii,Xt,rr,ro,gl,yl,md,_d=0,gd=0,yd=0,xd=0,cu=-1,hu=-1,Vr={},vd=Pr(""),uu=0,pu=0;if(xt._unevaluatedLayout.getValue("text-radial-offset")===void 0?[uu,pu]=xt.layout.get("text-offset").evaluate(It,{},Ot).map(Li=>Li*ei):(uu=xt.layout.get("text-radial-offset").evaluate(It,{},Ot)*ei,pu=$h),Ce.allowVerticalPlacement&&Et.vertical){let Li=Et.vertical;if(vi)yl=Xh(Li),nt&&(md=Xh(nt));else{let Bi=xt.layout.get("text-rotate").evaluate(It,{},Ot)+90;rr=Bc(kt,mt,it,Lt,Nt,$t,Li,Di,Bi,vt),nt&&(ro=Bc(kt,mt,it,Lt,Nt,$t,nt,Pi,Bi))}}if(jt){let Li=xt.layout.get("icon-rotate").evaluate(It,{},Ot),Bi=xt.layout.get("icon-text-fit")!=="none",xl=Cp(jt,Li,bi,Bi),fu=nt?Cp(nt,Li,bi,Bi):void 0;Xt=Bc(kt,mt,it,Lt,Nt,$t,jt,Pi,Li),_d=4*xl.length;let bd=Ce.iconSizeData,Ho=null;bd.kind==="source"?(Ho=[Rr*xt.layout.get("icon-size").evaluate(It,{},Ot)],Ho[0]>Kn&&bt(`${Ce.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):bd.kind==="composite"&&(Ho=[Rr*St.compositeIconSizes[0].evaluate(It,{},Ot),Rr*St.compositeIconSizes[1].evaluate(It,{},Ot)],(Ho[0]>Kn||Ho[1]>Kn)&&bt(`${Ce.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ce.addSymbols(Ce.icon,xl,Ho,qt,Ht,It,!1,mt,it,hi.lineStartIndex,hi.lineLength,-1,ci,Ot),cu=Ce.icon.placedSymbolArray.length-1,fu&&(gd=4*fu.length,Ce.addSymbols(Ce.icon,fu,Ho,qt,Ht,It,Xi.vertical,mt,it,hi.lineStartIndex,hi.lineLength,-1,ci,Ot),hu=Ce.icon.placedSymbolArray.length-1)}for(let Li in Et.horizontal){let Bi=Et.horizontal[Li];ii||(vd=Pr(Bi.text),vi?gl=Xh(Bi):ii=Bc(kt,mt,it,Lt,Nt,$t,Bi,Di,xt.layout.get("text-rotate").evaluate(It,{},Ot),vt));let xl=Bi.positionedLines.length===1;if(yd+=Dp(Ce,mt,it,Bi,_t,xt,vi,It,vt,hi,Et.vertical?Xi.horizontal:Xi.horizontalOnly,xl?Object.keys(Et.horizontal):[Li],Vr,cu,St,ci,Ot),xl)break}Et.vertical&&(xd+=Dp(Ce,mt,it,Et.vertical,_t,xt,vi,It,vt,hi,Xi.vertical,["vertical"],Vr,hu,St,ci,Ot));let no=-1,du=(Li,Bi)=>Li?Math.max(Li,Bi):Bi;no=du(gl,no),no=du(yl,no),no=du(md,no);let qm=no>-1?1:0;Ce.glyphOffsetArray.length>=Jn.MAX_GLYPHS&&bt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),It.sortKey!==void 0&&Ce.addToSortKeyRanges(Ce.symbolInstances.length,It.sortKey),Ce.symbolInstances.emplaceBack(mt.x,mt.y,mt.z,it.x,it.y,Vr.right>=0?Vr.right:-1,Vr.center>=0?Vr.center:-1,Vr.left>=0?Vr.left:-1,Vr.vertical>=0?Vr.vertical:-1,cu,hu,vd,ii!==void 0?ii:Ce.collisionBoxArray.length,ii!==void 0?ii+1:Ce.collisionBoxArray.length,rr!==void 0?rr:Ce.collisionBoxArray.length,rr!==void 0?rr+1:Ce.collisionBoxArray.length,Xt!==void 0?Xt:Ce.collisionBoxArray.length,Xt!==void 0?Xt+1:Ce.collisionBoxArray.length,ro||Ce.collisionBoxArray.length,ro?ro+1:Ce.collisionBoxArray.length,Lt,yd,xd,_d,gd,qm,0,uu,pu,no)})(i,Ee,Re,be,r,n,s,xe,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,K,le,m,0,J,he,k,e,c,g,x,v)};if(fe==="line")for(let be of Ip(e.geometry,0,0,He,He)){let Ee=nm(be,H,Q,r.vertical||L,n,24,q,i.overscaling,He);for(let Xe of Ee){let Qe=L;Qe&&dm(i,Qe.text,ge,Xe)||Se(be,Xe,v)}}else if(fe==="line-center"){for(let be of e.geometry)if(be.length>1){let Ee=rm(be,Q,r.vertical||L,n,24,q);Ee&&Se(be,Ee,v)}}else if(e.type==="Polygon")for(let be of Lh(e.geometry,0)){let Ee=lm(be,16);Se(be[0],new gn(Ee.x,Ee.y,0,0,void 0),v)}else if(e.type==="LineString")for(let be of e.geometry)Se(be,new gn(be[0].x,be[0].y,0,0,void 0),v);else if(e.type==="Point")for(let be of e.geometry)for(let Ee of be)Se([Ee],new gn(Ee.x,Ee.y,0,0,void 0),v)}let Kn=32640;function Dp(i,e,r,n,s,c,u,p,m,g,x,v,w,S,A,k,L){let O=function(K,J,Q,le,he,fe,ge,se){let de=[];if(J.positionedLines.length===0)return de;let xe=le.layout.get("text-rotate").evaluate(fe,{})*Math.PI/180,Se=function(We){let Ke=We[0],Re=We[1],Ce=Ke*Re;return Ce>0?[Ke,-Re]:Ce<0?[-Ke,Re]:Ke===0?[Re,Ke]:[Re,-Ke]}(Q),be=Math.abs(J.top-J.bottom);for(let We of J.positionedLines)be-=We.lineOffset;let Ee=J.positionedLines.length,Xe=be/Ee,Qe=J.top-Q[1];for(let We=0;We<Ee;++We){let Ke=J.positionedLines[We];Qe=om(J,Xe,Qe,We);for(let Re of Ke.positionedGlyphs){if(!Re.rect)continue;let Ce=Re.rect||{},it=4,mt=!0,Vt=1,Et=0;if(Re.imageName){let St=ge[Re.imageName];if(!St)continue;if(St.sdf){bt("SDF images are not supported in formatted text and will be ignored.");continue}mt=!1,Vt=St.pixelRatio,it=1/Vt}let jt=(he||se)&&Re.vertical,_t=Re.metrics.advance*Re.scale/2,nt=Re.metrics,xt=Re.rect;if(xt===null)continue;se&&J.verticalizable&&(Et=Re.imageName?_t-Re.metrics.width*Re.scale/2:0);let kt=he?[Re.x+_t,Re.y]:[0,0],Lt=[0,0],Nt=[0,0],$t=!1;he||(jt?(Nt=[Re.x+_t+Se[0],Re.y+Se[1]-Et],$t=!0):Lt=[Re.x+_t+Q[0],Re.y+Q[1]-Et]);let Di=xt.w*Re.scale/(Vt*(Re.localGlyph?2:1)),vi=xt.h*Re.scale/(Vt*(Re.localGlyph?2:1)),vt,li,Pi,Ht;if(jt){let St=Re.y-Qe,bi=new _e(-_t,_t-St),ci=-Math.PI/2,Ot=new _e(...Nt);vt=new _e(-_t+Lt[0],Lt[1]),vt._rotateAround(ci,bi)._add(Ot),vt.x+=-St+_t,vt.y-=(nt.left-it)*Re.scale;let hi=Re.imageName?nt.advance*Re.scale:ei*Re.scale,ii=String.fromCharCode(Re.glyph);Vf(ii)?vt.x+=(1-it)*Re.scale:jf(ii)?vt.x+=hi-nt.height*Re.scale+(-it-1)*Re.scale:vt.x+=Re.imageName||nt.width+2*it===xt.w&&nt.height+2*it===xt.h?(hi-vi)/2:(hi-(nt.height+2*it)*Re.scale)/2,li=new _e(vt.x,vt.y-Di),Pi=new _e(vt.x+vi,vt.y),Ht=new _e(vt.x+vi,vt.y-Di)}else{let St=(nt.left-it)*Re.scale-_t+Lt[0],bi=(-nt.top-it)*Re.scale+Lt[1],ci=St+Di,Ot=bi+vi;vt=new _e(St,bi),li=new _e(ci,bi),Pi=new _e(St,Ot),Ht=new _e(ci,Ot)}if(xe){let St;St=he?new _e(0,0):$t?new _e(Se[0],Se[1]):new _e(Q[0],Q[1]),vt._rotateAround(xe,St),li._rotateAround(xe,St),Pi._rotateAround(xe,St),Ht._rotateAround(xe,St)}let qt=new _e(0,0),It=new _e(0,0);de.push({tl:vt,tr:li,bl:Pi,br:Ht,tex:Ce,writingMode:J.writingMode,glyphOffset:kt,sectionIndex:Re.sectionIndex,isSDF:mt,pixelOffsetTL:qt,pixelOffsetBR:It,minFontScaleX:0,minFontScaleY:0})}}return de}(0,n,m,c,u,p,s,i.allowVerticalPlacement),q=i.textSizeData,H=null;q.kind==="source"?(H=[Rr*c.layout.get("text-size").evaluate(p,{},L)],H[0]>Kn&&bt(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):q.kind==="composite"&&(H=[Rr*A.compositeTextSizes[0].evaluate(p,{},L),Rr*A.compositeTextSizes[1].evaluate(p,{},L)],(H[0]>Kn||H[1]>Kn)&&bt(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),i.addSymbols(i.text,O,H,m,u,p,x,e,r,g.lineStartIndex,g.lineLength,S,k,L);for(let K of v)w[K]=i.text.placedSymbolArray.length-1;return 4*O.length}function Pp(i){for(let e in i)return i[e];return null}function Bc(i,e,r,n,s,c,u,p,m,g){let x=u.top,v=u.bottom,w=u.left,S=u.right,A=u.collisionPadding;if(A&&(w-=A[0],x-=A[1],S+=A[2],v+=A[3]),m){let k=new _e(w,x),L=new _e(S,x),O=new _e(w,v),q=new _e(S,v),H=lt(m),K=new _e(0,0);g&&(K=new _e(g[0],g[1])),k._rotateAround(H,K),L._rotateAround(H,K),O._rotateAround(H,K),q._rotateAround(H,K),w=Math.min(k.x,L.x,O.x,q.x),S=Math.max(k.x,L.x,O.x,q.x),x=Math.min(k.y,L.y,O.y,q.y),v=Math.max(k.y,L.y,O.y,q.y)}return i.emplaceBack(e.x,e.y,e.z,r.x,r.y,w,x,S,v,p,n,s,c),i.length-1}function Xh(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);let e=i.bottom-i.top;return e>0?Math.max(10,e):null}function dm(i,e,r,n){let s=i.compareText;if(e in s){let c=s[e];for(let u=c.length-1;u>=0;u--)if(n.dist(c[u])<r)return!0}else s[e]=[];return s[e].push(n),!1}let fm=qo.VectorTileFeature.types,mm=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Rc(i,e,r,n,s,c,u,p,m,g,x,v,w,S,A,k){let L=x?Math.min(Kn,Math.round(x[0])):0,O=x?Math.min(Kn,Math.round(x[1])):0;i.emplaceBack(e,r,Math.round(32*u),Math.round(32*p),m,g,(L<<1)+(v?1:0),O,16*w,16*S,256*A,256*k,n,s,c,0)}function Wh(i,e,r){i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r),i.emplaceBack(e.x,e.y,r)}function _m(i){for(let e of i.sections)if(ch(e.text))return!0;return!1}class Hh{constructor(e){this.layoutVertexArray=new ce,this.indexArray=new ke,this.programConfigurations=e,this.segments=new Pt,this.dynamicLayoutVertexArray=new we,this.opacityVertexArray=new re,this.placedSymbolArray=new ur}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,n,s){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Pf.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Lf.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,mm,!0),this.opacityVertexBuffer.itemSize=1),(n||s)&&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())}}ze(Hh,"SymbolBuffers");class Yh{constructor(e,r,n){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new n,this.segments=new Pt,this.collisionVertexArray=new pe,this.collisionVertexArrayExt=new we}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Bf.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Rf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ze(Yh,"CollisionBuffers");class Jn{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(u=>u.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=Br([]),this.placementViewportMatrix=Br([]);let r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fh(this.zoom,r["text-size"]),this.iconSizeData=Fh(this.zoom,r["icon-size"]);let n=this.layers[0].layout,s=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"&&s.constantOr(1)!==void 0,this.sortFeaturesByY=(c==="viewport-y"||c==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(u=>Xi[u]),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Hh(new No(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Hh(new No(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new ft,this.lineVertexArray=new Rt,this.symbolInstances=new Dt}calculateGlyphDependencies(e,r,n,s,c){for(let u=0;u<e.length;u++)if(r[e.charCodeAt(u)]=!0,s&&c){let p=ol[e.charAt(u)];p&&(r[p.charCodeAt(0)]=!0)}}populate(e,r,n,s){let c=this.layers[0],u=c.layout,p=u.get("text-font"),m=u.get("text-field"),g=u.get("icon-image"),x=(m.value.kind!=="constant"||m.value.value instanceof Ut&&!m.value.value.isEmpty()||m.value.value.toString().length>0)&&(p.value.kind!=="constant"||p.value.value.length>0),v=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,w=u.get("symbol-sort-key");if(this.features=[],!x&&!v)return;let S=r.iconDependencies,A=r.glyphDependencies,k=r.availableImages,L=new Tt(this.zoom);for(let{feature:O,id:q,index:H,sourceLayerIndex:K}of e){let J=c._featureFilter.needGeometry,Q=Go(O,J);if(!c._featureFilter.filter(L,Q,n))continue;let le,he;if(J||(Q.geometry=fn(O,n,s)),x){let ge=c.getValueAndResolveTokens("text-field",Q,n,k),se=Ut.factory(ge);_m(se)&&(this.hasRTLText=!0),(!this.hasRTLText||Fs()==="unavailable"||this.hasRTLText&&Ii.isParsed())&&(le=Uf(se,c,Q))}if(v){let ge=c.getValueAndResolveTokens("icon-image",Q,n,k);he=ge instanceof pi?ge:pi.fromString(ge)}if(!le&&!he)continue;let fe=this.sortFeaturesByKey?w.evaluate(Q,{},n):void 0;if(this.features.push({id:q,text:le,icon:he,index:H,sourceLayerIndex:K,geometry:Q.geometry,properties:O.properties,type:fm[O.type],sortKey:fe}),he&&(S[he.name]=!0),le){let ge=p.evaluate(Q,{},n).join(","),se=u.get("text-rotation-alignment")==="map"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Xi.vertical)>=0;for(let de of le.sections)if(de.image)S[de.image.name]=!0;else{let xe=Ps(le.toString()),Se=de.fontStack||ge,be=A[Se]=A[Se]||{};this.calculateGlyphDependencies(de.text,be,se,this.allowVerticalPlacement,xe)}}}u.get("symbol-placement")==="line"&&(this.features=function(O){let q={},H={},K=[],J=0;function Q(ge){K.push(O[ge]),J++}function le(ge,se,de){let xe=H[ge];return delete H[ge],H[se]=xe,K[xe].geometry[0].pop(),K[xe].geometry[0]=K[xe].geometry[0].concat(de[0]),xe}function he(ge,se,de){let xe=q[se];return delete q[se],q[ge]=xe,K[xe].geometry[0].shift(),K[xe].geometry[0]=de[0].concat(K[xe].geometry[0]),xe}function fe(ge,se,de){let xe=de?se[0][se[0].length-1]:se[0][0];return`${ge}:${xe.x}:${xe.y}`}for(let ge=0;ge<O.length;ge++){let se=O[ge],de=se.geometry,xe=se.text?se.text.toString():null;if(!xe){Q(ge);continue}let Se=fe(xe,de),be=fe(xe,de,!0);if(Se in H&&be in q&&H[Se]!==q[be]){let Ee=he(Se,be,de),Xe=le(Se,be,K[Ee].geometry);delete q[Se],delete H[be],H[fe(xe,K[Xe].geometry,!0)]=Xe,K[Ee].geometry=null}else Se in H?le(Se,be,de):be in q?he(Se,be,de):(Q(ge),q[Se]=J-1,H[be]=J-1)}return K.filter(ge=>ge.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((O,q)=>O.sortKey-q.sortKey)}update(e,r,n,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,n,s),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,n,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){let n=this.lineVertexArray.length,s=e.segment;if(s!==void 0){let c=e.dist(r[s+1]),u=e.dist(r[s]),p={};for(let m=s+1;m<r.length;m++)p[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:c},m<r.length-1&&(c+=r[m+1].dist(r[m]));for(let m=s||0;m>=0;m--)p[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:u},m>0&&(u+=r[m-1].dist(r[m]));for(let m=0;m<r.length;m++){let g=p[m];this.lineVertexArray.emplaceBack(g.x,g.y,g.tileUnitDistanceFromAnchor)}}return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,r,n,s,c,u,p,m,g,x,v,w,S,A){let k=e.indexArray,L=e.layoutVertexArray,O=e.segments.prepareSegment(4*r.length,L,k,this.canOverlap?u.sortKey:void 0),q=this.glyphOffsetArray.length,H=O.vertexLength,K=this.allowVerticalPlacement&&p===Xi.vertical?Math.PI/2:0,J=u.text&&u.text.sections;for(let Q=0;Q<r.length;Q++){let{tl:le,tr:he,bl:fe,br:ge,tex:se,pixelOffsetTL:de,pixelOffsetBR:xe,minFontScaleX:Se,minFontScaleY:be,glyphOffset:Ee,isSDF:Xe,sectionIndex:Qe}=r[Q],We=O.vertexLength,Ke=Ee[1];Rc(L,m.x,m.y,m.z,g.x,g.y,le.x,Ke+le.y,se.x,se.y,n,Xe,de.x,de.y,Se,be),Rc(L,m.x,m.y,m.z,g.x,g.y,he.x,Ke+he.y,se.x+se.w,se.y,n,Xe,xe.x,de.y,Se,be),Rc(L,m.x,m.y,m.z,g.x,g.y,fe.x,Ke+fe.y,se.x,se.y+se.h,n,Xe,de.x,xe.y,Se,be),Rc(L,m.x,m.y,m.z,g.x,g.y,ge.x,Ke+ge.y,se.x+se.w,se.y+se.h,n,Xe,xe.x,xe.y,Se,be),Wh(e.dynamicLayoutVertexArray,m,K),k.emplaceBack(We,We+1,We+2),k.emplaceBack(We+1,We+2,We+3),O.vertexLength+=4,O.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Ee[0]),Q!==r.length-1&&Qe===r[Q+1].sectionIndex||e.programConfigurations.populatePaintArrays(L.length,u,u.index,{},S,A,J&&J[Qe])}e.placedSymbolArray.emplaceBack(m.x,m.y,m.z,g.x,g.y,q,this.glyphOffsetArray.length-q,H,x,v,g.segment,n?n[0]:0,n?n[1]:0,s[0],s[1],p,0,!1,0,w,0)}_commitLayoutVertex(e,r,n,s,c,u,p){e.emplaceBack(r,n,s,c,u,Math.round(p.x),Math.round(p.y))}_addCollisionDebugVertices(e,r,n,s,c,u,p){let m=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),g=m.vertexLength,x=p.tileAnchorX,v=p.tileAnchorY;for(let S=0;S<4;S++)n.collisionVertexArray.emplaceBack(0,0,0,0);n.collisionVertexArrayExt.emplaceBack(r,-e.padding,-e.padding),n.collisionVertexArrayExt.emplaceBack(r,e.padding,-e.padding),n.collisionVertexArrayExt.emplaceBack(r,e.padding,e.padding),n.collisionVertexArrayExt.emplaceBack(r,-e.padding,e.padding),this._commitLayoutVertex(n.layoutVertexArray,s,c,u,x,v,new _e(e.x1,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,c,u,x,v,new _e(e.x2,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,c,u,x,v,new _e(e.x2,e.y2)),this._commitLayoutVertex(n.layoutVertexArray,s,c,u,x,v,new _e(e.x1,e.y2)),m.vertexLength+=4;let w=n.indexArray;w.emplaceBack(g,g+1),w.emplaceBack(g+1,g+2),w.emplaceBack(g+2,g+3),w.emplaceBack(g+3,g),m.primitiveLength+=4}_addTextDebugCollisionBoxes(e,r,n,s,c,u){for(let p=s;p<c;p++){let m=n.get(p),g=this.getSymbolInstanceTextSize(e,u,r,p);this._addCollisionDebugVertices(m,g,this.textCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,u)}}_addIconDebugCollisionBoxes(e,r,n,s,c,u){for(let p=s;p<c;p++){let m=n.get(p),g=this.getSymbolInstanceIconSize(e,r,p);this._addCollisionDebugVertices(m,g,this.iconCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,u)}}generateCollisionDebugBuffers(e,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Yh(ve,ap.members,qe),this.iconCollisionBox=new Yh(ve,ap.members,qe);let n=Xs(this.iconSizeData,e),s=Xs(this.textSizeData,e);for(let c=0;c<this.symbolInstances.length;c++){let u=this.symbolInstances.get(c);this._addTextDebugCollisionBoxes(s,e,r,u.textBoxStartIndex,u.textBoxEndIndex,u),this._addTextDebugCollisionBoxes(s,e,r,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u),this._addIconDebugCollisionBoxes(n,e,r,u.iconBoxStartIndex,u.iconBoxEndIndex,u),this._addIconDebugCollisionBoxes(n,e,r,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex,u)}}getSymbolInstanceTextSize(e,r,n,s){let c=this.text.placedSymbolArray.get(r.rightJustifiedTextSymbolIndex>=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:s),u=Cc(this.textSizeData,e,c)/ei;return this.tilePixelRatio*u}getSymbolInstanceIconSize(e,r,n){let s=this.icon.placedSymbolArray.get(n),c=Cc(this.iconSizeData,e,s);return this.tilePixelRatio*c}_commitDebugCollisionVertexUpdate(e,r,n){e.emplaceBack(r,-n,-n),e.emplaceBack(r,n,-n),e.emplaceBack(r,n,n),e.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(e,r,n,s,c,u){for(let p=s;p<c;p++){let m=n.get(p),g=this.getSymbolInstanceTextSize(e,u,r,p);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,g,m.padding)}}_updateIconDebugCollisionBoxes(e,r,n,s,c){for(let u=s;u<c;u++){let p=n.get(u),m=this.getSymbolInstanceIconSize(e,r,u);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,m,p.padding)}}updateCollisionDebugBuffers(e,r){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();let n=Xs(this.iconSizeData,e),s=Xs(this.textSizeData,e);for(let c=0;c<this.symbolInstances.length;c++){let u=this.symbolInstances.get(c);this._updateTextDebugCollisionBoxes(s,e,r,u.textBoxStartIndex,u.textBoxEndIndex,u),this._updateTextDebugCollisionBoxes(s,e,r,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u),this._updateIconDebugCollisionBoxes(n,e,r,u.iconBoxStartIndex,u.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(n,e,r,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex)}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,r,n,s,c,u,p,m,g){let x={};for(let v=r;v<n;v++){let w=e.get(v);x.textBox={x1:w.x1,y1:w.y1,x2:w.x2,y2:w.y2,padding:w.padding,projectedAnchorX:w.projectedAnchorX,projectedAnchorY:w.projectedAnchorY,projectedAnchorZ:w.projectedAnchorZ,tileAnchorX:w.tileAnchorX,tileAnchorY:w.tileAnchorY},x.textFeatureIndex=w.featureIndex;break}for(let v=s;v<c;v++){let w=e.get(v);x.verticalTextBox={x1:w.x1,y1:w.y1,x2:w.x2,y2:w.y2,padding:w.padding,projectedAnchorX:w.projectedAnchorX,projectedAnchorY:w.projectedAnchorY,projectedAnchorZ:w.projectedAnchorZ,tileAnchorX:w.tileAnchorX,tileAnchorY:w.tileAnchorY},x.verticalTextFeatureIndex=w.featureIndex;break}for(let v=u;v<p;v++){let w=e.get(v);x.iconBox={x1:w.x1,y1:w.y1,x2:w.x2,y2:w.y2,padding:w.padding,projectedAnchorX:w.projectedAnchorX,projectedAnchorY:w.projectedAnchorY,projectedAnchorZ:w.projectedAnchorZ,tileAnchorX:w.tileAnchorX,tileAnchorY:w.tileAnchorY},x.iconFeatureIndex=w.featureIndex;break}for(let v=m;v<g;v++){let w=e.get(v);x.verticalIconBox={x1:w.x1,y1:w.y1,x2:w.x2,y2:w.y2,padding:w.padding,projectedAnchorX:w.projectedAnchorX,projectedAnchorY:w.projectedAnchorY,projectedAnchorZ:w.projectedAnchorZ,tileAnchorX:w.tileAnchorX,tileAnchorY:w.tileAnchorY},x.verticalIconFeatureIndex=w.featureIndex;break}return x}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){let n=this.symbolInstances.get(r);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,r){let n=e.placedSymbolArray.get(r),s=n.vertexStartIndex+4*n.numGlyphs;for(let c=n.vertexStartIndex;c<s;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;let r=Math.sin(e),n=Math.cos(e),s=[],c=[],u=[];for(let p=0;p<this.symbolInstances.length;++p){u.push(p);let m=this.symbolInstances.get(p);s.push(0|Math.round(r*m.tileAnchorX+n*m.tileAnchorY)),c.push(m.featureIndex)}return u.sort((p,m)=>s[p]-s[m]||c[m]-c[p]),u}addToSortKeyRanges(e,r){let n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let r of this.symbolInstanceIndexes){let n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((s,c,u)=>{s>=0&&u.indexOf(s)===c&&this.addIndicesForPlacedSymbol(this.text,s)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ze(Jn,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Jn.MAX_GLYPHS=65535,Jn.addDynamicAttributes=Wh;let gm=new M({"symbol-placement":new _(oe.layout_symbol["symbol-placement"]),"symbol-spacing":new _(oe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new _(oe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new y(oe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new _(oe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new _(oe.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new _(oe.layout_symbol["icon-ignore-placement"]),"icon-optional":new _(oe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new _(oe.layout_symbol["icon-rotation-alignment"]),"icon-size":new y(oe.layout_symbol["icon-size"]),"icon-text-fit":new _(oe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new _(oe.layout_symbol["icon-text-fit-padding"]),"icon-image":new y(oe.layout_symbol["icon-image"]),"icon-rotate":new y(oe.layout_symbol["icon-rotate"]),"icon-padding":new _(oe.layout_symbol["icon-padding"]),"icon-keep-upright":new _(oe.layout_symbol["icon-keep-upright"]),"icon-offset":new y(oe.layout_symbol["icon-offset"]),"icon-anchor":new y(oe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new _(oe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new _(oe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new _(oe.layout_symbol["text-rotation-alignment"]),"text-field":new y(oe.layout_symbol["text-field"]),"text-font":new y(oe.layout_symbol["text-font"]),"text-size":new y(oe.layout_symbol["text-size"]),"text-max-width":new y(oe.layout_symbol["text-max-width"]),"text-line-height":new y(oe.layout_symbol["text-line-height"]),"text-letter-spacing":new y(oe.layout_symbol["text-letter-spacing"]),"text-justify":new y(oe.layout_symbol["text-justify"]),"text-radial-offset":new y(oe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new _(oe.layout_symbol["text-variable-anchor"]),"text-anchor":new y(oe.layout_symbol["text-anchor"]),"text-max-angle":new _(oe.layout_symbol["text-max-angle"]),"text-writing-mode":new _(oe.layout_symbol["text-writing-mode"]),"text-rotate":new y(oe.layout_symbol["text-rotate"]),"text-padding":new _(oe.layout_symbol["text-padding"]),"text-keep-upright":new _(oe.layout_symbol["text-keep-upright"]),"text-transform":new y(oe.layout_symbol["text-transform"]),"text-offset":new y(oe.layout_symbol["text-offset"]),"text-allow-overlap":new _(oe.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new _(oe.layout_symbol["text-ignore-placement"]),"text-optional":new _(oe.layout_symbol["text-optional"])});var Kh={paint:new M({"icon-opacity":new y(oe.paint_symbol["icon-opacity"]),"icon-color":new y(oe.paint_symbol["icon-color"]),"icon-halo-color":new y(oe.paint_symbol["icon-halo-color"]),"icon-halo-width":new y(oe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new y(oe.paint_symbol["icon-halo-blur"]),"icon-translate":new _(oe.paint_symbol["icon-translate"]),"icon-translate-anchor":new _(oe.paint_symbol["icon-translate-anchor"]),"text-opacity":new y(oe.paint_symbol["text-opacity"]),"text-color":new y(oe.paint_symbol["text-color"],{runtimeType:Qi,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new y(oe.paint_symbol["text-halo-color"]),"text-halo-width":new y(oe.paint_symbol["text-halo-width"]),"text-halo-blur":new y(oe.paint_symbol["text-halo-blur"]),"text-translate":new _(oe.paint_symbol["text-translate"]),"text-translate-anchor":new _(oe.paint_symbol["text-translate-anchor"])}),layout:gm};class Lp{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:nr,this.defaultValue=e}evaluate(e){if(e.formattedSection){let r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ze(Lp,"FormatSectionOverride",{omit:["defaultValue"]});class Fc extends dr{constructor(e){super(e,Kh)}recalculate(e,r){super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));let n=this.layout.get("text-writing-mode");if(n){let s=[];for(let c of n)s.indexOf(c)<0&&s.push(c);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,r,n,s){let c=this.layout.get(e).evaluate(r,{},n,s),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||On(u.value)||!c?c:function(p,m){return m.replace(/{([^{}]+)}/g,(g,x)=>x in p?String(p[x]):"")}(r.properties,c)}createBucket(e){return new Jn(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(let e of Kh.paint.overridableProperties){if(!Fc.hasPaintOverride(this.layout,e))continue;let r=this.paint.get(e),n=new Lp(r),s=new Ts(n,r.property.specification),c=null;c=r.value.kind==="constant"||r.value.kind==="source"?new wa("source",s):new Ta("composite",s,r.value.zoomStops,r.value._interpolationType),this.paint._values[e]=new d(r.property,c,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&Fc.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){let n=e.get("text-field"),s=Kh.paint.properties[r],c=!1,u=p=>{for(let m of p)if(s.overrides&&s.overrides.hasOverride(m))return void(c=!0)};if(n.value.kind==="constant"&&n.value.value instanceof Ut)u(n.value.value.sections);else if(n.value.kind==="source"){let p=g=>{c||(g instanceof sr&&Bt(g.value)===zn?u(g.value.sections):g instanceof Pn?u(g.sections):g.eachChild(p))},m=n.value;m._styleExpression&&p(m._styleExpression.expression)}return c}getProgramConfiguration(e){return new Xn(this,e)}}var ym={paint:new M({"background-color":new _(oe.paint_background["background-color"]),"background-pattern":new T(oe.paint_background["background-pattern"]),"background-opacity":new _(oe.paint_background["background-opacity"])})},xm={paint:new M({"raster-opacity":new _(oe.paint_raster["raster-opacity"]),"raster-hue-rotate":new _(oe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new _(oe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new _(oe.paint_raster["raster-brightness-max"]),"raster-saturation":new _(oe.paint_raster["raster-saturation"]),"raster-contrast":new _(oe.paint_raster["raster-contrast"]),"raster-resampling":new _(oe.paint_raster["raster-resampling"]),"raster-fade-duration":new _(oe.paint_raster["raster-fade-duration"])})};class vm extends dr{constructor(e){super(e,{}),this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}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 bm={paint:new M({"sky-type":new _(oe.paint_sky["sky-type"]),"sky-atmosphere-sun":new _(oe.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new _(oe.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new _(oe.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new _(oe.paint_sky["sky-gradient-radius"]),"sky-gradient":new E(oe.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new _(oe.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new _(oe.paint_sky["sky-atmosphere-color"]),"sky-opacity":new _(oe.paint_sky["sky-opacity"])})};function Jh(i,e,r){let n=[0,0,1],s=Vu([]);return function(c,u,p){p*=.5;var m=u[0],g=u[1],x=u[2],v=u[3],w=Math.sin(p),S=Math.cos(p);c[0]=m*S-x*w,c[1]=g*S+v*w,c[2]=x*S+m*w,c[3]=v*S-g*w}(s,s,r?-lt(i)+Math.PI:lt(i)),ju(s,s,-lt(e)),Ou(n,n,s),Wa(n,n)}let wm={circle:class extends dr{constructor(i){super(i,Vd)}createBucket(i){return new gh(i)}queryRadius(i){let e=i;return Ns("circle-radius",this,e)+Ns("circle-stroke-width",this,e)+vc(this.paint.get("circle-translate"))}queryIntersectsFeature(i,e,r,n,s,c,u,p){let m=zu(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),c.angle,i.pixelToTileUnitsFactor),g=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r);return Nu(i,n,c,u,p,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",m,g)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new Xn(this,i)}},heatmap:class extends dr{createBucket(i){return new Zu(i)}constructor(i){super(i,Xd),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){i==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=zh({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(i){return Ns("heatmap-radius",this,i)}queryIntersectsFeature(i,e,r,n,s,c,u,p){let m=this.paint.get("heatmap-radius").evaluate(e,r);return Nu(i,n,c,u,p,!0,!0,new _e(0,0),m)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new Xn(this,i)}},hillshade:class extends dr{constructor(i){super(i,Wd)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends dr{constructor(i){super(i,pf)}getProgramIds(){let i=this.paint.get("fill-pattern"),e=i&&i.constantOr(1),r=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getProgramConfiguration(i){return new Xn(this,i)}recalculate(i,e){super.recalculate(i,e);let r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new Ic(i)}queryRadius(){return vc(this.paint.get("fill-translate"))}queryIntersectsFeature(i,e,r,n,s,c){return!i.queryGeometry.isAboveHorizon&&Su(Cu(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),c.angle,i.pixelToTileUnitsFactor),n)}isTileClipped(){return!0}},"fill-extrusion":class extends dr{constructor(i){super(i,Ef)}createBucket(i){return new rl(i)}queryRadius(){return vc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new Xn(this,i)}queryIntersectsFeature(i,e,r,n,s,c,u,p,m){let g=zu(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),c.angle,i.pixelToTileUnitsFactor),x=this.paint.get("fill-extrusion-height").evaluate(e,r),v=this.paint.get("fill-extrusion-base").evaluate(e,r),w=[0,0],S=p&&c.elevation,A=c.elevation?c.elevation.exaggeration():1,k=i.tile.getBucket(this);if(S&&k instanceof rl){let q=k.centroidVertexArray,H=m+1;if(H<q.length){let K=q.get(H);w[0]=K.a_centroid_pos0,w[1]=K.a_centroid_pos1}}if(w[0]===0&&w[1]===1)return!1;let L=function(q,H,K,J,Q,le,he,fe,ge){return le?function(se,de,xe,Se,be,Ee,Xe,Qe,We){let Ke=[],Re=[],Ce=[0,0,0,1];for(let it of se){let mt=[],Vt=[];for(let Et of it){let jt=Et.x+Se.x,_t=Et.y+Se.y,nt=Sf(jt,_t,de,xe,Ee,Xe,Qe,We);Ce[0]=jt,Ce[1]=_t,Ce[2]=nt.base,Ce[3]=1,Zs(Ce,Ce,be),Ce[3]=Math.max(Ce[3],1e-5);let xt=rp([Ce[0]/Ce[3],Ce[1]/Ce[3],Ce[2]/Ce[3]]);Ce[0]=jt,Ce[1]=_t,Ce[2]=nt.top,Ce[3]=1,Zs(Ce,Ce,be),Ce[3]=Math.max(Ce[3],1e-5);let kt=rp([Ce[0]/Ce[3],Ce[1]/Ce[3],Ce[2]/Ce[3]]);mt.push(xt),Vt.push(kt)}Ke.push(mt),Re.push(Vt)}return[Ke,Re]}(q,H,K,J,Q,le,he,fe,ge):function(se,de,xe,Se,be){let Ee=[],Xe=[],Qe=be[8]*de,We=be[9]*de,Ke=be[10]*de,Re=be[11]*de,Ce=be[8]*xe,it=be[9]*xe,mt=be[10]*xe,Vt=be[11]*xe;for(let Et of se){let jt=[],_t=[];for(let nt of Et){let xt=nt.x+Se.x,kt=nt.y+Se.y,Lt=be[0]*xt+be[4]*kt+be[12],Nt=be[1]*xt+be[5]*kt+be[13],$t=be[2]*xt+be[6]*kt+be[14],Di=be[3]*xt+be[7]*kt+be[15],vi=Lt+Qe,vt=Nt+We,li=$t+Ke,Pi=Math.max(Di+Re,1e-5),Ht=Lt+Ce,qt=Nt+it,It=$t+mt,St=Math.max(Di+Vt,1e-5),bi=new _e(vi/Pi,vt/Pi);bi.z=li/Pi,jt.push(bi);let ci=new _e(Ht/St,qt/St);ci.z=It/St,_t.push(ci)}Ee.push(jt),Xe.push(_t)}return[Ee,Xe]}(q,H,K,J,Q)}(n,v,x,g,u,S?p:null,w,A,c.center.lat),O=i.queryGeometry;return function(q,H,K){let J=1/0;Su(K,H)&&(J=ip(K,H[0]));for(let Q=0;Q<H.length;Q++){let le=H[Q],he=q[Q];for(let fe=0;fe<le.length-1;fe++){let ge=le[fe],se=[ge,le[fe+1],he[fe+1],he[fe],ge];Eu(K,se)&&(J=Math.min(J,ip(K,se)))}}return J!==1/0&&J}(L[0],L[1],O.isPointQuery()?O.screenBounds:O.screenGeometry)}},line:class extends dr{constructor(i){super(i,np),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(i){if(i==="line-gradient"){let e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof vo,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(i,e){super.recalculate(i,e),this.paint._values["line-floorwidth"]=op.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,i)}createBucket(i){return new Ac(i)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(i){return new Xn(this,i)}queryRadius(i){let e=i,r=sp(Ns("line-width",this,e),Ns("line-gap-width",this,e)),n=Ns("line-offset",this,e);return r/2+Math.abs(n)+vc(this.paint.get("line-translate"))}queryIntersectsFeature(i,e,r,n,s,c){if(i.queryGeometry.isAboveHorizon)return!1;let u=Cu(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),c.angle,i.pixelToTileUnitsFactor),p=i.pixelToTileUnitsFactor/2*sp(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),m=this.paint.get("line-offset").evaluate(e,r);return m&&(n=function(g,x){let v=[],w=new _e(0,0);for(let S=0;S<g.length;S++){let A=g[S],k=[];for(let L=0;L<A.length;L++){let O=A[L-1],q=A[L],H=A[L+1],K=L===0?w:q.sub(O)._unit()._perp(),J=L===A.length-1?w:H.sub(q)._unit()._perp(),Q=K._add(J)._unit();Q._mult(1/(Q.x*J.x+Q.y*J.y)),k.push(Q._mult(x)._add(q))}v.push(k)}return v}(n,m*i.pixelToTileUnitsFactor)),function(g,x,v){for(let w=0;w<x.length;w++){let S=x[w];if(g.length>=3){for(let A=0;A<S.length;A++)if(js(g,S[A]))return!0}if(Rd(g,S,v))return!0}return!1}(u,n,p)}isTileClipped(){return!0}},symbol:Fc,background:class extends dr{constructor(i){super(i,ym)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends dr{constructor(i){super(i,xm)}getProgramIds(){return["raster"]}},sky:class extends dr{constructor(i){super(i,bm),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){i==="sky-gradient"?this._updateColorRamp():i!=="sky-atmosphere-sun"&&i!=="sky-atmosphere-halo-color"&&i!=="sky-atmosphere-color"&&i!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=zh({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(i){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){let e=i.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(i,e){if(this.paint.get("sky-type")==="atmosphere"){let n=this.paint.get("sky-atmosphere-sun"),s=!n,c=i.style.light,u=c.properties.get("position");return s&&c.properties.get("anchor")==="viewport"&&bt("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),s?Jh(u.azimuthal,90-u.polar,e):Jh(n[0],90-n[1],e)}let r=this.paint.get("sky-gradient-center");return Jh(r[0],90-r[1],e)}is3D(){return!1}isSky(){return!0}markSkyboxValid(i){this._skyboxInvalidated=!1,this._lightPosition=i.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){let i=this.paint.get("sky-type");return i==="atmosphere"?["skyboxCapture","skybox"]:i==="gradient"?["skyboxGradient"]:null}}};class cl{constructor(e,r,n,s){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(r,s)}update(e,r,n){let{width:s,height:c}=e,{context:u}=this,{gl:p}=u,{HTMLImageElement:m,HTMLCanvasElement:g,HTMLVideoElement:x,ImageData:v,ImageBitmap:w}=Ne;if(p.bindTexture(p.TEXTURE_2D,this.texture),u.pixelStoreUnpackFlipY.set(!1),u.pixelStoreUnpack.set(1),u.pixelStoreUnpackPremultiplyAlpha.set(this.format===p.RGBA&&(!r||r.premultiply!==!1)),n||this.size&&this.size[0]===s&&this.size[1]===c){let{x:S,y:A}=n||{x:0,y:0};e instanceof m||e instanceof g||e instanceof x||e instanceof v||w&&e instanceof w?p.texSubImage2D(p.TEXTURE_2D,0,S,A,p.RGBA,p.UNSIGNED_BYTE,e):p.texSubImage2D(p.TEXTURE_2D,0,S,A,s,c,p.RGBA,p.UNSIGNED_BYTE,e.data)}else this.size=[s,c],e instanceof m||e instanceof g||e instanceof x||e instanceof v||w&&e instanceof w?p.texImage2D(p.TEXTURE_2D,0,this.format,this.format,p.UNSIGNED_BYTE,e):p.texImage2D(p.TEXTURE_2D,0,this.format,s,c,0,this.format,p.UNSIGNED_BYTE,e.data);this.useMipmap=Boolean(r&&r.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&p.generateMipmap(p.TEXTURE_2D)}bind(e,r){let{context:n}=this,{gl:s}=n;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?e===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_NEAREST:e),this.filter=e),r!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,r),this.wrap=r)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Qh{constructor(e,r){this.width=e,this.height=r,this.nextRow=0,this.image=new mn({width:e,height:r}),this.positions={},this.uploaded=!1}getDash(e,r){let n=this.getKey(e,r);return this.positions[n]}trim(){let e=this.width,r=this.height=Jo(this.nextRow);this.image.resize({width:e,height:r})}getKey(e,r){return e.join(",")+r}getDashRanges(e,r,n){let s=[],c=e.length%2==1?-e[e.length-1]*n:0,u=e[0]*n,p=!0;s.push({left:c,right:u,isDash:p,zeroLength:e[0]===0});let m=e[0];for(let g=1;g<e.length;g++){p=!p;let x=e[g];c=m*n,m+=x,u=m*n,s.push({left:c,right:u,isDash:p,zeroLength:x===0})}return s}addRoundDash(e,r,n){let s=r/2;for(let c=-n;c<=n;c++){let u=this.width*(this.nextRow+n+c),p=0,m=e[p];for(let g=0;g<this.width;g++){g/m.right>1&&(m=e[++p]);let x=Math.abs(g-m.left),v=Math.abs(g-m.right),w=Math.min(x,v),S,A=c/n*(s+1);if(m.isDash){let k=s-Math.abs(A);S=Math.sqrt(w*w+k*k)}else S=s-Math.sqrt(w*w+A*A);this.image.data[u+g]=Math.max(0,Math.min(255,S+128))}}}addRegularDash(e,r){for(let m=e.length-1;m>=0;--m){let g=e[m],x=e[m+1];g.zeroLength?e.splice(m,1):x&&x.isDash===g.isDash&&(x.left=g.left,e.splice(m,1))}let n=e[0],s=e[e.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);let c=this.width*this.nextRow,u=0,p=e[u];for(let m=0;m<this.width;m++){m/p.right>1&&(p=e[++u]);let g=Math.abs(m-p.left),x=Math.abs(m-p.right),v=Math.min(g,x);this.image.data[c+m]=Math.max(0,Math.min(255,(p.isDash?v:-v)+r+128))}}addDash(e,r){let n=this.getKey(e,r);if(this.positions[n])return this.positions[n];let s=r==="round",c=s?7:0,u=2*c+1;if(this.nextRow+u>this.height)return bt("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&&(bt("Negative value is found in line dasharray, replacing values with 0"),e[x]=0),p+=e[x];if(p!==0){let x=this.width/p,v=this.getDashRanges(e,this.width,x);s?this.addRoundDash(v,x,c):this.addRegularDash(v,r==="square"?.5*x:0)}let m=this.nextRow+c;this.nextRow+=u;let g={tl:[m,c],br:[p,0]};return this.positions[n]=g,g}}ze(Qh,"LineAtlas");class Tm{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=()=>{}}}let Em=Ne.performance;function Bp(i){let e=i?i.url.toString():void 0;return Em.getEntriesByName(e)}class Sm{constructor(){this.tasks={},this.taskQueue=[],wn(["process"],this),this.invoker=new Tm(this.process),this.nextId=0}add(e,r){let n=this.nextId++,s=function({type:c,isSymbolTile:u,zoom:p}){return p=p||0,c==="message"?0:c!=="maybePrepare"||u?c!=="parseTile"||u?c==="parseTile"&&u?300-p:c==="maybePrepare"&&u?400-p:500:200-p:100-p}(r);if(s===0){Fi();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:r,priority:s,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){Fi();try{if(this.taskQueue=this.taskQueue.filter(n=>!!this.tasks[n]),!this.taskQueue.length)return;let e=this.pick();if(e===null)return;let r=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}finally{}}pick(){let e=null,r=1/0;for(let s=0;s<this.taskQueue.length;s++){let c=this.tasks[this.taskQueue[s]];c.priority<r&&(r=c.priority,e=s)}if(e===null)return null;let n=this.taskQueue[e];return this.taskQueue.splice(e,1),n}remove(){this.invoker.remove()}}let Im=G([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),Mm=G([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Rp}=Im,Fp=G([{name:"a_pos_3",components:3,type:"Int16"}]);var hl=G([{name:"a_pos",type:"Int16",components:2}]);let Qs=He/Math.PI/2,zi=-Qs,ki=Qs,Am=[new qi([zi,zi,zi],[ki,ki,ki]),new qi([zi,zi,zi],[0,0,ki]),new qi([0,zi,zi],[ki,0,ki]),new qi([zi,0,zi],[0,ki,ki]),new qi([0,0,zi],[ki,ki,ki])];class Cm{constructor(e,r,n){this.a=Gs([],e,n),this.b=Gs([],r,n),this.center=n;let s=Wa([],this.a),c=Wa([],this.b);this.angle=Math.acos(Ha(s,c))}}function eu(i,e){if(i.angle===0)return null;let r;return r=i.a[e]===0?1/i.angle*.5*Math.PI:1/i.angle*Math.atan(i.b[e]/i.a[e]/Math.sin(i.angle)-1/Math.tan(i.angle)),r<0||r>1?null:function(n,s,c,u){let p=Math.sin(c);return n*(Math.sin((1-u)*c)/p)+s*(Math.sin(u*c)/p)}(i.a[e],i.b[e],i.angle,at(r,0,1))+i.center[e]}function ul(i){if(i.z<=1)return Am[i.z+2*i.y+i.x];let[e,r]=tu(i),n=[yn(e[0],e[1]),yn(e[0],r[1]),yn(r[0],e[1]),yn(r[0],r[1])],s=[ki,ki,ki],c=[zi,zi,zi];for(let u of n)s[0]=Math.min(s[0],u[0]),s[1]=Math.min(s[1],u[1]),s[2]=Math.min(s[2],u[2]),c[0]=Math.max(c[0],u[0]),c[1]=Math.max(c[1],u[1]),c[2]=Math.max(c[2],u[2]);return new qi(s,c)}function zm(i,e,r){let n=e/i.worldSize,s=(de,xe)=>{Xa(de,de,n),Xa(xe,xe,n)},c=Number.MAX_VALUE,u=[-c,-c,-c],p=[c,c,c],m=Np(i);if(r.z<=1){let de=ul(r).getCorners();for(let xe=0;xe<de.length;xe++)$o(de[xe],de[xe],m),Sh(p,p,de[xe]),Ih(u,u,de[xe]);return s(p,u),new qi(p,u)}let[g,x]=tu(r),v=new Wn;v.setSouthWest([g[1],x[0]]),v.setNorthEast([x[1],g[0]]);let w=[yn(v.getSouth(),v.getWest()),yn(v.getSouth(),v.getEast()),yn(v.getNorth(),v.getEast()),yn(v.getNorth(),v.getWest())];for(let de=0;de<w.length;de++)$o(w[de],w[de],m),Sh(p,p,w[de]),Ih(u,u,w[de]);if(v.contains(i.center))return u[2]=0,s(p,u),new qi(p,u);let S=[m[12],m[13],m[14]],A=i.center.lng,k=at(i.center.lat,-85.051129,Lr),L=[$a(A),Us(k)],O=v.getCenter().lng,q=at(v.getCenter().lat,-85.051129,Lr),H=[$a(O),Us(q)],K=new Array(3),J=0,Q=L[0]-H[0],le=L[1]-H[1];if(Math.abs(Q)>Math.abs(le))J=Q>=0?1:3,K=S;else{J=le>=0?0:2;let de=[m[4],m[5],m[6]],xe;xe=le>=0?-Math.sin(lt(v.getSouth()))*Qs:-Math.sin(lt(v.getNorth()))*Qs,K=Mh(K,S,de,xe)}let he=w[J],fe=w[(J+1)%4],ge=new Cm(he,fe,K),se=[eu(ge,0)||he[0],eu(ge,1)||he[1],eu(ge,2)||he[2]];return p[2]=Math.min(he[2],fe[2]),Sh(p,p,se),Ih(u,u,se),s(p,u),new qi(p,u)}function tu(i){let e=1<<i.z,r=i.x/e,n=(i.x+1)/e,s=(i.y+1)/e;return[[Qt(i.y/e),tr(r)],[Qt(s),tr(n)]]}function Op(i,e,r,n=Qs){return r=lt(r),[i*Math.sin(r)*n,-e*n,i*Math.cos(r)*n]}function yn(i,e,r){return Op(Math.cos(lt(i)),Math.sin(lt(i)),e,r)}function Up(i,e,r){let n=Math.pow(2,r.z),s=(i/He+r.x)/n;return yn(Qt((e/He+r.y)/n),tr(s))}function iu(i){return 16383/Math.max(...Gs([],i.max,i.min))}function Vp(i){let e=Br(new Float64Array(16)),r=iu(i);var n,s;return Hn(e,e,[r,r,r]),Zo(e,e,((n=[])[0]=-(s=i.min)[0],n[1]=-s[1],n[2]=-s[2],n)),e}function jp(i,e,r,n,s){let c=function(m){let g=He/(2*Math.PI);return m/(2*Math.PI)/g}(r),u=[i,e,-r/(2*Math.PI)],p=Br(new Float64Array(16));return Zo(p,p,u),Hn(p,p,[c,c,c]),wh(p,p,lt(-s)),Th(p,p,lt(-n)),p}function Np(i){let{x:e,y:r}=i.point,{lng:n,lat:s}=i._center;return jp(e,r,i.worldSize,n,s)}let Gp=lt(85),km=Math.cos(Gp),Dm=Math.sin(Gp);function Zp(i,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return[i*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Oc{constructor(e,r,n){this.z=e,this.x=r,this.y=n,this.key=pl(0,e,e,r,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r){let n=function(c,u,p){var m=Zp(256*c,256*(u=Math.pow(2,p)-u-1),p),g=Zp(256*(c+1),256*(u+1),p);return m[0]+","+m[1]+","+g[0]+","+g[1]}(this.x,this.y,this.z),s=function(c,u,p){let m,g="";for(let x=c;x>0;x--)m=1<<x-1,g+=(u&m?1:0)+(p&m?2:0);return g}(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}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String(r==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",s).replace("{bbox-epsg-3857}",n)}toString(){return`${this.z}/${this.x}/${this.y}`}}class $p{constructor(e,r){this.wrap=e,this.canonical=r,this.key=pl(e,r.z,r.z,r.x,r.y)}}class ai{constructor(e,r,n,s,c){this.overscaledZ=e,this.wrap=r,this.canonical=new Oc(n,+s,+c),this.key=r===0&&e===n?this.canonical.key:pl(r,e,n,s,c)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){let r=this.canonical.z-e;return e>this.canonical.z?new ai(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ai(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r=!0){if(this.overscaledZ===e&&r)return this.key;if(e>this.canonical.z)return pl(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y);{let n=this.canonical.z-e;return pl(this.wrap*+r,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;let r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new ai(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,n=2*this.canonical.x,s=2*this.canonical.y;return[new ai(r,this.wrap,r,n,s),new ai(r,this.wrap,r,n+1,s),new ai(r,this.wrap,r,n,s+1),new ai(r,this.wrap,r,n+1,s+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 ai(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new ai(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 $p(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function pl(i,e,r,n,s){let c=1<<Math.min(r,22),u=c*(s%c)+n%c;return i&&r<22&&(u+=c*c*((i<0?-2*i-1:2*i)%(1<<2*(22-r)))),16*(32*u+r)+(e-r)}function Xo(i,e){if(!e.isReprojectedInTileSpace)return{scale:1<<i.z,x:i.x,y:i.y,x2:i.x+1,y2:i.y+1,projection:e};let r=Math.pow(2,-i.z),n=i.x*r,s=(i.x+1)*r,c=i.y*r,u=(i.y+1)*r,p=tr(n),m=tr(s),g=Qt(c),x=Qt(u),v=e.project(p,g),w=e.project(m,g),S=e.project(m,x),A=e.project(p,x),k=Math.min(v.x,w.x,S.x,A.x),L=Math.min(v.y,w.y,S.y,A.y),O=Math.max(v.x,w.x,S.x,A.x),q=Math.max(v.y,w.y,S.y,A.y),H=r/16;function K(Q,le,he,fe,ge,se){let de=(he+ge)/2,xe=(fe+se)/2,Se=e.project(tr(de),Qt(xe)),be=Math.max(0,k-Se.x,L-Se.y,Se.x-O,Se.y-q);k=Math.min(k,Se.x),O=Math.max(O,Se.x),L=Math.min(L,Se.y),q=Math.max(q,Se.y),be>H&&(K(Q,Se,he,fe,de,xe),K(Se,le,de,xe,ge,se))}K(v,w,n,c,s,c),K(w,S,s,c,s,u),K(S,A,s,u,n,u),K(A,v,n,u,n,c),k-=H,L-=H,O+=H,q+=H;let J=1/Math.max(O-k,q-L);return{scale:J,x:k*J,y:L*J,x2:O*J,y2:q*J,projection:e}}ze(Oc,"CanonicalTileID"),ze(ai,"OverscaledTileID",{omit:["projMatrix"]});class qp{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){let n=e[r];this._stringToNumber[n]=r,this._numberToString[r]=n}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}let Pm=["tile","layer","source","sourceLayer","state"];class Xp{constructor(e,r,n,s,c){this.type="Feature",this._vectorTileFeature=e,this._z=r,this._x=n,this._y=s,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(){let e={type:"Feature",geometry:this.geometry,properties:this.properties};this.id!==void 0&&(e.id=this.id);for(let r of Pm)this[r]!==void 0&&(e[r]=this[r]);return e}}let ir=32,Fr=33,Qn=new Uint16Array(8184);for(let i=0;i<2046;i++){let e=i+2,r=0,n=0,s=0,c=0,u=0,p=0;for(1&e?s=c=u=ir:r=n=p=ir;(e>>=1)>1;){let g=r+s>>1,x=n+c>>1;1&e?(s=r,c=n,r=u,n=p):(r=s,n=c,s=u,c=p),u=g,p=x}let m=4*i;Qn[m+0]=r,Qn[m+1]=n,Qn[m+2]=s,Qn[m+3]=c}let Or=new Uint16Array(2178),eo=new Uint8Array(1089),Uc=new Uint16Array(1089);function Wp(i){return i===0?-.03125:i===32?.03125:0}var Hp=G([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);let Yp={type:2,extent:He,loadGeometry:()=>[[new _e(0,0),new _e(8193,0),new _e(8193,8193),new _e(0,8193),new _e(0,0)]]};class ru{constructor(e,r,n,s,c){this.tileID=e,this.uid=bn(),this.uses=0,this.tileSize=r,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",s&&s.transform&&(this.projection=s.transform.projection)}registerFadeDuration(e){let r=e+this.timeAdded;r<ni.now()||this.fadeEndTime&&r<this.fadeEndTime||(this.fadeEndTime=r)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=Xo(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,r,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(s,c){let u={};if(!c)return u;for(let p of s){let m=p.layerIds.map(g=>c.getLayer(g)).filter(Boolean);if(m.length!==0){p.layers=m,p.stateDependentLayerIds&&(p.stateDependentLayers=p.stateDependentLayerIds.map(g=>m.filter(x=>x.id===g)[0]));for(let g of m)u[g.id]=p}}return u}(e.buckets,r.style),this.hasSymbolBuckets=!1;for(let s in this.buckets){let c=this.buckets[s];if(c instanceof Jn){if(this.hasSymbolBuckets=!0,!n)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let s in this.buckets){let c=this.buckets[s];if(c instanceof Jn&&c.hasRTLText){this.hasRTLText=!0,Ii.isLoading()||Ii.isLoaded()||Fs()!=="deferred"||Gn();break}}this.queryPadding=0;for(let s in this.buckets){let c=this.buckets[s];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(s).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new hr}unloadVectorData(){if(this.hasData()){for(let 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._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=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(let n in this.buckets){let s=this.buckets[n];s.uploadPending()&&s.upload(e)}let r=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new cl(e,this.imageAtlas.image,r.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new cl(e,this.glyphAtlasImage,r.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new cl(e,this.lineAtlas.image,r.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,r,n,s,c,u,p,m){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:s,pixelPosMatrix:p,transform:u,params:c,tileTransform:this.tileTransform},e,r,n):{}}querySourceFeatures(e,r){let n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;let s=n.loadVTLayers(),c=r?r.sourceLayer:"",u=s._geojsonTileLayer||s[c];if(!u)return;let p=Ar(r&&r.filter),{z:m,x:g,y:x}=this.tileID.canonical,v={z:m,x:g,y:x};for(let w=0;w<u.length;w++){let S=u.feature(w);if(p.needGeometry){let L=Go(S,!0);if(!p.filter(new Tt(this.tileID.overscaledZ),L,this.tileID.canonical))continue}else if(!p.filter(new Tt(this.tileID.overscaledZ),S))continue;let A=n.getId(S,c),k=new Xp(S,m,g,x,A);k.tile=v,e.push(k)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){let r=this.expirationTime;if(e.cacheControl){let n=Tn(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){let n=Date.now(),s=!1;if(this.expirationTime>n)s=!1;else if(r)if(this.expirationTime<r)s=!0;else{let c=this.expirationTime-r;c?this.expirationTime=n+Math.max(c,3e4):s=!0}else s=!0;s?(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,r){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0||!r)return;let n=this.latestFeatureIndex.loadVTLayers(),s=r.style.listImages();for(let c in this.buckets){if(!r.style.hasLayer(c))continue;let u=this.buckets[c],p=u.layers[0].sourceLayer||"_geojsonTileLayer",m=n[p],g=e[p];if(!m||!g||Object.keys(g).length===0)continue;if(u.update(g,m,s,this.imageAtlas&&this.imageAtlas.patternPositions||{}),u instanceof Ac||u instanceof Ic){let v=r.style._getSourceCache(u.layers[0].source);r._terrain&&r._terrain.enabled&&v&&u.programConfigurations.needsUpload&&r._terrain._clearRenderCacheForTile(v.id,this.tileID)}let x=r&&r.style&&r.style.getLayer(c);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(u)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<ni.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=ni.now()+e}setTexture(e,r){let n=r.context,s=n.gl;this.texture=r.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new cl(n,e,s.RGBA,{useMipmap:!0}),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),n.extTextureFilterAnisotropic&&s.texParameterf(s.TEXTURE_2D,n.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,n.extTextureFilterAnisotropicMax))}setDependencies(e,r){let n={};for(let s of r)n[s]=!0;this.dependencies[e]=n}hasDependency(e,r){for(let n of e){let s=this.dependencies[n];if(s){for(let c of r)if(s[c])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,r){if(!r||r.name==="mercator"||this._tileDebugBuffer)return;let n=fn(Yp,this.tileID.canonical,this.tileTransform)[0],s=new j,c=new st;for(let u=0;u<n.length;u++){let{x:p,y:m}=n[u];s.emplaceBack(p,m),c.emplaceBack(u)}c.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(c),this._tileDebugBuffer=e.createVertexBuffer(s,hl.members),this._tileDebugSegments=Pt.simpleSegment(0,0,s.length,c.length)}_makeTileBoundsBuffers(e,r){if(this._tileBoundsBuffer||!r||r.name==="mercator")return;let n=fn(Yp,this.tileID.canonical,this.tileTransform)[0],s,c;if(this.isRaster){let u=function(p,m){let g=Xo(p,m),x=Math.pow(2,p.z);for(let L=0;L<Fr;L++)for(let O=0;O<Fr;O++){let q=tr((p.x+(O+Wp(O))/ir)/x),H=Qt((p.y+(L+Wp(L))/ir)/x),K=m.project(q,H),J=L*Fr+O;Or[2*J+0]=Math.round((K.x*g.scale-g.x)*He),Or[2*J+1]=Math.round((K.y*g.scale-g.y)*He)}eo.fill(0),Uc.fill(0);for(let L=2045;L>=0;L--){let O=4*L,q=Qn[O+0],H=Qn[O+1],K=Qn[O+2],J=Qn[O+3],Q=q+K>>1,le=H+J>>1,he=Q+le-H,fe=le+q-Q,ge=H*Fr+q,se=J*Fr+K,de=le*Fr+Q,xe=Math.hypot((Or[2*ge+0]+Or[2*se+0])/2-Or[2*de+0],(Or[2*ge+1]+Or[2*se+1])/2-Or[2*de+1])>=16;if(eo[de]=eo[de]||(xe?1:0),L<1022){let Se=(H+fe>>1)*Fr+(q+he>>1),be=(J+fe>>1)*Fr+(K+he>>1);eo[de]=eo[de]||eo[Se]||eo[be]}}let v=new $,w=new ke,S=0;function A(L,O){let q=O*Fr+L;return Uc[q]===0&&(v.emplaceBack(Or[2*q+0],Or[2*q+1],L*He/ir,O*He/ir),Uc[q]=++S),Uc[q]-1}function k(L,O,q,H,K,J){let Q=L+q>>1,le=O+H>>1;if(Math.abs(L-K)+Math.abs(O-J)>1&&eo[le*Fr+Q])k(K,J,L,O,Q,le),k(q,H,K,J,Q,le);else{let he=A(L,O),fe=A(q,H),ge=A(K,J);w.emplaceBack(he,fe,ge)}}return k(0,0,ir,ir,ir,0),k(ir,ir,0,0,0,ir),{vertices:v,indices:w}}(this.tileID.canonical,r);s=u.vertices,c=u.indices}else{s=new $,c=new ke;for(let{x:p,y:m}of n)s.emplaceBack(p,m,0,0);let u=bc(s.int16,void 0,4);for(let p=0;p<u.length;p+=3)c.emplaceBack(u[p],u[p+1],u[p+2])}this._tileBoundsBuffer=e.createVertexBuffer(s,Hp.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(c),this._tileBoundsSegments=Pt.simpleSegment(0,0,s.length,c.length)}_makeGlobeTileDebugBuffers(e,r){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!r||r.name!=="globe")return;let n=this.tileID.canonical,s=Vp(ul(n));this._makeGlobeTileDebugBorderBuffer(e,n,s),this._makeGlobeTileDebugTextBuffer(e,n,s)}_makeGlobeTileDebugBorderBuffer(e,r,n){let s=new j,c=new st,u=new N,p=(g,x,v,w,S)=>{let A=(v-g)/(S-1),k=(w-x)/(S-1),L=s.length;for(let O=0;O<S;O++){let q=g+O*A,H=x+O*k;s.emplaceBack(q,H);let K=Up(q,H,r),J=$o(K,K,n);u.emplaceBack(J[0],J[1],J[2]),c.emplaceBack(L+O)}},m=He;p(0,0,m,0,16),p(m,0,m,m,16),p(m,m,0,m,16),p(0,m,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(c),this._tileDebugBuffer=e.createVertexBuffer(s,hl.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(u,Fp.members),this._tileDebugSegments=Pt.simpleSegment(0,0,s.length,c.length)}_makeGlobeTileDebugTextBuffer(e,r,n){let s=new j,c=new ke,u=new N,p=25;c.reserve(32),s.reserve(p),u.reserve(p);let m=(g,x)=>p*g+x;for(let g=0;g<p;g++){let x=2048*g;for(let v=0;v<p;v++){let w=2048*v;s.emplaceBack(w,x);let S=Up(w,x,r),A=$o(S,S,n);u.emplaceBack(A[0],A[1],A[2])}}for(let g=0;g<4;g++)for(let x=0;x<4;x++){let v=m(g,x),w=m(g,x+1),S=m(g+1,x),A=m(g+1,x+1);c.emplaceBack(v,w,S),c.emplaceBack(S,w,A)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(c),this._tileDebugTextBuffer=e.createVertexBuffer(s,hl.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(u,Fp.members),this._tileDebugTextSegments=Pt.simpleSegment(0,0,p,32)}}class Lm{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,r,n){let s=String(r);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][s]=this.stateChanges[e][s]||{},Gt(this.stateChanges[e][s],n),this.deletedStates[e]===null){this.deletedStates[e]={};for(let c in this.state[e])c!==s&&(this.deletedStates[e][c]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][s]===null){this.deletedStates[e][s]={};for(let c in this.state[e][s])n[c]||(this.deletedStates[e][s][c]=null)}else for(let c in n)this.deletedStates[e]&&this.deletedStates[e][s]&&this.deletedStates[e][s][c]===null&&delete this.deletedStates[e][s][c]}removeFeatureState(e,r,n){if(this.deletedStates[e]===null)return;let s=String(r);if(this.deletedStates[e]=this.deletedStates[e]||{},n&&r!==void 0)this.deletedStates[e][s]!==null&&(this.deletedStates[e][s]=this.deletedStates[e][s]||{},this.deletedStates[e][s][n]=null);else if(r!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][s])for(n in this.deletedStates[e][s]={},this.stateChanges[e][s])this.deletedStates[e][s][n]=null;else this.deletedStates[e][s]=null;else this.deletedStates[e]=null}getState(e,r){let n=String(r),s=Gt({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let c=this.deletedStates[e][r];if(c===null)return{};for(let u in c)delete s[u]}return s}initializeTileState(e,r){e.setFeatureState(this.state,r)}coalesceChanges(e,r){let n={};for(let s in this.stateChanges){this.state[s]=this.state[s]||{};let c={};for(let u in this.stateChanges[s])this.state[s][u]||(this.state[s][u]={}),Gt(this.state[s][u],this.stateChanges[s][u]),c[u]=this.state[s][u];n[s]=c}for(let s in this.deletedStates){this.state[s]=this.state[s]||{};let c={};if(this.deletedStates[s]===null)for(let u in this.state[s])c[u]={},this.state[s][u]={};else for(let u in this.deletedStates[s]){if(this.deletedStates[s][u]===null)this.state[s][u]={};else for(let p of Object.keys(this.deletedStates[s][u]))delete this.state[s][u][p];c[u]=this.state[s][u]}n[s]=n[s]||{},Gt(n[s],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(n).length!==0)for(let s in e)e[s].setFeatureState(n,r)}}class Kp{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,r){let n=this.toIdx(e,r);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,r){return this.leaves[this.toIdx(e,r)]}toIdx(e,r){return r*this.size+e}}function Jp(i,e,r,n){let s=0,c=Number.MAX_VALUE;for(let u=0;u<3;u++)if(Math.abs(n[u])<1e-15){if(r[u]<i[u]||r[u]>e[u])return null}else{let p=1/n[u],m=(i[u]-r[u])*p,g=(e[u]-r[u])*p;if(m>g){let x=m;m=g,g=x}if(m>s&&(s=m),g<c&&(c=g),s>c)return null}return s}function Qp(i,e,r,n,s,c,u,p,m,g,x){let v=n-i,w=s-e,S=c-r,A=u-i,k=p-e,L=m-r,O=x[1]*L-x[2]*k,q=x[2]*A-x[0]*L,H=x[0]*k-x[1]*A,K=v*O+w*q+S*H;if(Math.abs(K)<1e-15)return null;let J=1/K,Q=g[0]-i,le=g[1]-e,he=g[2]-r,fe=(Q*O+le*q+he*H)*J;if(fe<0||fe>1)return null;let ge=le*S-he*w,se=he*v-Q*S,de=Q*w-le*v,xe=(x[0]*ge+x[1]*se+x[2]*de)*J;return xe<0||fe+xe>1?null:(A*ge+k*se+L*de)*J}function ed(i,e,r){return(i-e)/(r-e)}function td(i,e,r,n,s,c,u,p,m){let g=1<<r,x=c-n,v=u-s,w=(i+1)/g*x+n,S=(e+0)/g*v+s,A=(e+1)/g*v+s;p[0]=(i+0)/g*x+n,p[1]=S,m[0]=w,m[1]=A}class id{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;let r=function(c){let u=Math.ceil(Math.log2(c.dim/8)),p=[],m=Math.ceil(Math.pow(2,u)),g=1/m,x=(S,A,k,L,O)=>{let q=L?1:0,H=(S+1)*k-q,K=A*k,J=(A+1)*k-q;O[0]=S*k,O[1]=K,O[2]=H,O[3]=J},v=new Kp(m),w=[];for(let S=0;S<m*m;S++){x(S%m,Math.floor(S/m),g,!1,w);let A=to(w[0],w[1],c),k=to(w[2],w[1],c),L=to(w[2],w[3],c),O=to(w[0],w[3],c);v.minimums.push(Math.min(A,k,L,O)),v.maximums.push(Math.max(A,k,L,O)),v.leaves.push(1)}for(p.push(v),m/=2;m>=1;m/=2){let S=p[p.length-1];v=new Kp(m);for(let A=0;A<m*m;A++){x(A%m,Math.floor(A/m),2,!0,w);let k=S.getElevation(w[0],w[1]),L=S.getElevation(w[2],w[1]),O=S.getElevation(w[2],w[3]),q=S.getElevation(w[0],w[3]),H=S.isLeaf(w[0],w[1]),K=S.isLeaf(w[2],w[1]),J=S.isLeaf(w[2],w[3]),Q=S.isLeaf(w[0],w[3]),le=Math.min(k.min,L.min,O.min,q.min),he=Math.max(k.max,L.max,O.max,q.max),fe=H&&K&&J&&Q;v.maximums.push(he),v.minimums.push(le),v.leaves.push(he-le<=5&&fe?1:0)}p.push(v)}return p}(this.dem),n=r.length-1,s=r[n];this._addNode(s.minimums[0],s.maximums[0],s.leaves[0]),this._construct(r,0,0,n,0)}raycastRoot(e,r,n,s,c,u,p=1){return Jp([e,r,-100],[n,s,this.maximums[0]*p],c,u)}raycast(e,r,n,s,c,u,p=1){if(!this.nodeCount)return null;let m=this.raycastRoot(e,r,n,s,c,u,p);if(m==null)return null;let g=[],x=[],v=[],w=[],S=[{idx:0,t:m,nodex:0,nodey:0,depth:0}];for(;S.length>0;){let{idx:A,t:k,nodex:L,nodey:O,depth:q}=S.pop();if(this.leaves[A]){td(L,O,q,e,r,n,s,v,w);let K=1<<q,J=(L+0)/K,Q=(L+1)/K,le=(O+0)/K,he=(O+1)/K,fe=to(J,le,this.dem)*p,ge=to(Q,le,this.dem)*p,se=to(Q,he,this.dem)*p,de=to(J,he,this.dem)*p,xe=Qp(v[0],v[1],fe,w[0],v[1],ge,w[0],w[1],se,c,u),Se=Qp(w[0],w[1],se,v[0],w[1],de,v[0],v[1],fe,c,u),be=Math.min(xe!==null?xe:Number.MAX_VALUE,Se!==null?Se:Number.MAX_VALUE);if(be!==Number.MAX_VALUE)return be;{let Ee=Mh([],c,u,k);if(rd(fe,ge,de,se,ed(Ee[0],v[0],w[0]),ed(Ee[1],v[1],w[1]))>=Ee[2])return k}continue}let H=0;for(let K=0;K<this._siblingOffset.length;K++){td((L<<1)+this._siblingOffset[K][0],(O<<1)+this._siblingOffset[K][1],q+1,e,r,n,s,v,w),v[2]=-100,w[2]=this.maximums[this.childOffsets[A]+K]*p;let J=Jp(v,w,c,u);if(J!=null){let Q=J;g[K]=Q;let le=!1;for(let he=0;he<H&&!le;he++)Q>=g[x[he]]&&(x.splice(he,0,K),le=!0);le||(x[H]=K),H++}}for(let K=0;K<H;K++){let J=x[K];S.push({idx:this.childOffsets[A]+J,t:g[J],nodex:(L<<1)+this._siblingOffset[J][0],nodey:(O<<1)+this._siblingOffset[J][1],depth:q+1})}}return null}_addNode(e,r,n){return this.minimums.push(e),this.maximums.push(r),this.leaves.push(n),this.childOffsets.push(0),this.nodeCount++}_construct(e,r,n,s,c){if(e[s].isLeaf(r,n)===1)return;this.childOffsets[c]||(this.childOffsets[c]=this.nodeCount);let u=s-1,p=e[u],m=0,g=0;for(let x=0;x<this._siblingOffset.length;x++){let v=2*r+this._siblingOffset[x][0],w=2*n+this._siblingOffset[x][1],S=p.getElevation(v,w),A=p.isLeaf(v,w),k=this._addNode(S.min,S.max,A);A&&(m|=1<<x),g||(g=k)}for(let x=0;x<this._siblingOffset.length;x++)m&1<<x||this._construct(e,2*r+this._siblingOffset[x][0],2*n+this._siblingOffset[x][1],u,g+x)}}function rd(i,e,r,n,s,c){return je(je(i,r,c),je(e,n,c),s)}function to(i,e,r){let n=r.dim,s=at(i*n-.5,0,n-1),c=at(e*n-.5,0,n-1),u=Math.floor(s),p=Math.floor(c),m=Math.min(u+1,n-1),g=Math.min(p+1,n-1);return rd(r.get(u,p),r.get(m,p),r.get(u,g),r.get(m,g),s-u,c-p)}let nd={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Vc{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,r,n,s=!1,c=!1){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(n&&n!=="mapbox"&&n!=="terrarium")return bt(`"${n}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=r.height;let u=this.dim=r.height-2,p=new Uint32Array(r.data.buffer);if(this.pixels=new Uint8Array(r.data.buffer),this.encoding=n||"mapbox",this.borderReady=s,!s){for(let m=0;m<u;m++)p[this._idx(-1,m)]=p[this._idx(0,m)],p[this._idx(u,m)]=p[this._idx(u-1,m)],p[this._idx(m,-1)]=p[this._idx(m,0)],p[this._idx(m,u)]=p[this._idx(m,u-1)];p[this._idx(-1,-1)]=p[this._idx(0,0)],p[this._idx(u,-1)]=p[this._idx(u-1,0)],p[this._idx(-1,u)]=p[this._idx(0,u-1)],p[this._idx(u,u)]=p[this._idx(u-1,u-1)],c&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new id(this)}get(e,r,n=!1){n&&(e=at(e,-1,this.dim),r=at(r,-1,this.dim));let s=4*this._idx(e,r);return(this.encoding==="terrarium"?this._unpackTerrarium:this._unpackMapbox)(this.pixels[s],this.pixels[s+1],this.pixels[s+2])}static getUnpackVector(e){return nd[e]}get unpackVector(){return nd[this.encoding]}_idx(e,r){if(e<-1||e>=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}_unpackMapbox(e,r,n){return(256*e*256+256*r+n)/10-1e4}_unpackTerrarium(e,r,n){return 256*e+r+n/256-32768}static pack(e,r){let n=[0,0,0,0],s=Vc.getUnpackVector(r),c=Math.floor((e+s[3])/s[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 Ci({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,r,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let s=r*this.dim,c=r*this.dim+this.dim,u=n*this.dim,p=n*this.dim+this.dim;switch(r){case-1:s=c-1;break;case 1:c=s+1}switch(n){case-1:u=p-1;break;case 1:p=u+1}let m=-r*this.dim,g=-n*this.dim;for(let x=u;x<p;x++)for(let v=s;v<c;v++){let w=4*this._idx(v,x),S=4*this._idx(v+m,x+g);this.pixels[w+0]=e.pixels[S+0],this.pixels[w+1]=e.pixels[S+1],this.pixels[w+2]=e.pixels[S+2],this.pixels[w+3]=e.pixels[S+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}ze(Vc,"DEMData"),ze(id,"DemMinMaxQuadTree",{omit:["dem"]});class Bm{constructor(e,r){this.max=e,this.onRemove=r,this.reset()}reset(){for(let e in this.data)for(let r of this.data[e])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(e,r,n){let s=e.wrapped().key;this.data[s]===void 0&&(this.data[s]=[]);let c={value:r,timeout:void 0};if(n!==void 0&&(c.timeout=setTimeout(()=>{this.remove(e,c)},n)),this.data[s].push(c),this.order.push(s),this.order.length>this.max){let u=this._getAndRemoveByKey(this.order[0]);u&&this.onRemove(u)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let r=this.data[e].shift();return r.timeout&&clearTimeout(r.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),r.value}getByKey(e){let r=this.data[e];return r?r[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,r){if(!this.has(e))return this;let n=e.wrapped().key,s=r===void 0?0:this.data[n].indexOf(r),c=this.data[n][s];return this.data[n].splice(s,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;){let r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(e){let r=[];for(let n in this.data)for(let s of this.data[n])e(s.value)||r.push(s);for(let n of r)this.remove(n.value.tileID,n)}}class ea{constructor(e,r,n){this.func=e,this.mask=r,this.range=n}}ea.ReadOnly=!1,ea.ReadWrite=!0,ea.disabled=new ea(519,ea.ReadOnly,[0,1]);let nu=7680;class ou{constructor(e,r,n,s,c,u){this.test=e,this.ref=r,this.mask=n,this.fail=s,this.depthFail=c,this.pass=u}}ou.disabled=new ou({func:519,mask:0},0,0,nu,nu,nu);class Ur{constructor(e,r,n){this.blendFunction=e,this.blendColor=r,this.mask=n}}Ur.Replace=[1,0],Ur.disabled=new Ur(Ur.Replace,ht.transparent,[!1,!1,!1,!1]),Ur.unblended=new Ur(Ur.Replace,ht.transparent,[!0,!0,!0,!0]),Ur.alphaBlended=new Ur([1,771],ht.transparent,[!0,!0,!0,!0]);let su=1029,au=2305;class fr{constructor(e,r,n){this.enable=e,this.mode=r,this.frontFace=n}}fr.disabled=new fr(!1,su,au),fr.backCCW=new fr(!0,su,au),fr.backCW=new fr(!0,su,2304),fr.frontCW=new fr(!0,1028,2304),fr.frontCCW=new fr(!0,1028,au);class Wo extends $e{constructor(e,r,n){super(),this.id=e,this._onlySymbols=n,r.on("data",s=>{s.dataType==="source"&&s.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&s.dataType==="source"&&s.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new Bm(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=r.minTileCacheSize,this._maxTileCacheSize=r.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Lm,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(let e in this._tiles){let r=this._tiles[e];if(r.state!=="loaded"&&r.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,r){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,r)}_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){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(let r in this._tiles){let n=this._tiles[r];this._source.prepareTile(n)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,n.tileID),n.upload(e),n.prepare(this.map.style.imageManager)}else for(let r in this._tiles){let n=this._tiles[r];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return ao(this._tiles).map(e=>e.tileID).sort(od).map(e=>e.key)}getRenderableIds(e){let r=[];for(let n in this._tiles)this._isIdRenderable(+n,e)&&r.push(this._tiles[n]);return e?r.sort((n,s)=>{let c=n.tileID,u=s.tileID,p=new _e(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),m=new _e(u.canonical.x,u.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-u.overscaledZ||m.y-p.y||m.x-p.x}).map(n=>n.tileID.key):r.map(n=>n.tileID).sort(od).map(n=>n.key)}hasRenderableParent(e){let r=this.findLoadedParent(e,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(e,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(r||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(+e,"reloading")}}_reloadTile(e,r){let n=this._tiles[e];n&&(n.state!=="loading"&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,e,r)))}_tileLoaded(e,r,n,s){if(s)if(e.state="errored",s.status!==404)this._source.fire(new Ue(s,{tile:e}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){let c=this.map.painter.terrain;this.update(this.transform,c.getScaledDemTileSize(),!0),c.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=ni.now(),n==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(r,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 Oe("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){let r=this.getRenderableIds();for(let s=0;s<r.length;s++){let c=r[s];if(e.neighboringTiles&&e.neighboringTiles[c]){let u=this.getTileByID(c);n(e,u),n(u,e)}}function n(s,c){if(!s.dem||s.dem.borderReady)return;s.needsHillshadePrepare=!0,s.needsDEMTextureUpload=!0;let u=c.tileID.canonical.x-s.tileID.canonical.x,p=c.tileID.canonical.y-s.tileID.canonical.y,m=Math.pow(2,s.tileID.canonical.z),g=c.tileID.key;u===0&&p===0||Math.abs(p)>1||(Math.abs(u)>1&&(Math.abs(u+m)===1?u+=m:Math.abs(u-m)===1&&(u-=m)),c.dem&&s.dem&&(s.dem.backfillBorder(c.dem,u,p),s.neighboringTiles&&s.neighboringTiles[g]&&(s.neighboringTiles[g].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,r,n,s){for(let c in this._tiles){let u=this._tiles[c];if(s[c]||!u.hasData()||u.tileID.overscaledZ<=r||u.tileID.overscaledZ>n)continue;let p=u.tileID;for(;u&&u.tileID.overscaledZ>r+1;){let g=u.tileID.scaledTo(u.tileID.overscaledZ-1);u=this._tiles[g.key],u&&u.hasData()&&(p=g)}let m=p;for(;m.overscaledZ>r;)if(m=m.scaledTo(m.overscaledZ-1),e[m.key]){s[p.key]=p;break}}}findLoadedParent(e,r){if(e.key in this._loadedParentTiles){let n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let n=e.overscaledZ-1;n>=r;n--){let s=e.scaledTo(n),c=this._getLoadedTile(s);if(c)return c}}_getLoadedTile(e){let r=this._tiles[e.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,r){r=r||this._source.tileSize;let n=Math.ceil(e.width/r)+1,s=Math.ceil(e.height/r)+1,c=Math.floor(n*s*5),u=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,c):c,p=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,u):u;this._cache.setMaxSize(p)}handleWrapJump(e){let r=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,r){let n={};for(let s in this._tiles){let c=this._tiles[s];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+r),n[c.tileID.key]=c}this._tiles=n;for(let s in this._timers)clearTimeout(this._timers[s]),delete this._timers[s];for(let s in this._tiles)this._setTileReloadTimer(+s,this._tiles[s])}}update(e,r,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;let s;this.updateCacheSize(e,r),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(p=>new ai(p.canonical.z,p.wrap,p.canonical.z,p.canonical.x,p.canonical.y)):(s=e.coveringTiles({tileSize:r||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&&(s=s.filter(p=>this._source.hasTile(p)))):s=[];let c=this._updateRetainedTiles(s);if(sd(this._source.type)&&s.length!==0){let p={},m={},g=Object.keys(c);for(let v of g){let w=c[v],S=this._tiles[v];if(!S||S.fadeEndTime&&S.fadeEndTime<=ni.now())continue;let A=this.findLoadedParent(w,Math.max(w.overscaledZ-Wo.maxOverzooming,this._source.minzoom));A&&(this._addTile(A.tileID),p[A.tileID.key]=A.tileID),m[v]=w}let x=s[s.length-1].overscaledZ;for(let v in this._tiles){let w=this._tiles[v];if(c[v]||!w.hasData())continue;let S=w.tileID;for(;S.overscaledZ>x;){S=S.scaledTo(S.overscaledZ-1);let A=this._tiles[S.key];if(A&&A.hasData()&&m[S.key]){c[v]=w.tileID;break}}}for(let v in p)c[v]||(this._coveredTiles[v]=!0,c[v]=p[v])}for(let p in c)this._tiles[p].clearFadeHold();let u=function(p,m){let g=[];for(let x in p)x in m||g.push(x);return g}(this._tiles,c);for(let p of u){let 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(let e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){let r={};if(e.length===0)return r;let n={},s=e.reduce((g,x)=>Math.min(g,x.overscaledZ),1/0),c=e[0].overscaledZ,u=Math.max(c-Wo.maxOverzooming,this._source.minzoom),p=Math.max(c+Wo.maxUnderzooming,this._source.minzoom),m={};for(let g of e){let x=this._addTile(g);r[g.key]=g,x.hasData()||s<this._source.maxzoom&&(m[g.key]=g)}this._retainLoadedChildren(m,s,p,r);for(let g of e){let x=this._tiles[g.key];if(x.hasData())continue;if(g.canonical.z>=this._source.maxzoom){let w=g.children(this._source.maxzoom)[0],S=this.getTile(w);if(S&&S.hasData()){r[w.key]=w;continue}}else{let w=g.children(this._source.maxzoom);if(r[w[0].key]&&r[w[1].key]&&r[w[2].key]&&r[w[3].key])continue}let v=x.wasRequested();for(let w=g.overscaledZ-1;w>=u;--w){let S=g.scaledTo(w);if(n[S.key]||(n[S.key]=!0,x=this.getTile(S),!x&&v&&(x=this._addTile(S)),x&&(r[S.key]=S,v=x.wasRequested(),x.hasData())))break}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let e in this._tiles){let r=[],n,s=this._tiles[e].tileID;for(;s.overscaledZ>0;){if(s.key in this._loadedParentTiles){n=this._loadedParentTiles[s.key];break}r.push(s.key);let c=s.scaledTo(s.overscaledZ-1);if(n=this._getLoadedTile(c),n)break;s=c}for(let c of r)this._loadedParentTiles[c]=n}}_addTile(e){let r=this._tiles[e.key];if(r)return this._source.prepareTile&&this._source.prepareTile(r),r;r=this._cache.getAndRemove(e),r&&(this._setTileReloadTimer(e.key,r),r.tileID=e,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,r)));let n=Boolean(r);if(!n){let s=this.map?this.map.painter:null;r=new ru(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,s,this._isRaster),this._source.prepareTile&&this._source.prepareTile(r)||this._loadTile(r,this._tileLoaded.bind(this,r,e.key,r.state))}return r?(r.uses++,this._tiles[e.key]=r,n||this._source.fire(new Oe("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(e,r){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);let n=r.getExpiryTimeout();n&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},n))}_removeTile(e){let r=this._tiles[e];r&&(r.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),r.uses>0||(r.hasData()&&r.state!=="reloading"?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let 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,r,n){let s=[],c=this.transform;if(!c)return s;for(let u in this._tiles){let p=this._tiles[u];if(n&&p.clearQueryDebugViz(),p.holdingForFade())continue;let m=e.containsTile(p,c,r);m&&s.push(m)}return s}getVisibleCoordinates(e){let r=this.getRenderableIds(e).map(n=>this._tiles[n].tileID);for(let n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(sd(this._source.type))for(let e in this._tiles){let r=this._tiles[e];if(r.fadeEndTime!==void 0&&r.fadeEndTime>=ni.now())return!0}return!1}setFeatureState(e,r,n){this._state.updateState(e=e||"_geojsonTileLayer",r,n)}removeFeatureState(e,r,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",r,n)}getFeatureState(e,r){return this._state.getState(e=e||"_geojsonTileLayer",r)}setDependencies(e,r,n){let s=this._tiles[e];s&&s.setDependencies(r,n)}reloadTilesForDependencies(e,r){for(let n in this._tiles)this._tiles[n].hasDependency(e,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(e,r))}_preloadTiles(e,r){let n=new Map,s=Array.isArray(e)?e:[e],c=this.map.painter.terrain,u=this.usedForTerrain&&c?c.getScaledDemTileSize():this._source.tileSize;for(let p of s){let m=p.coveringTiles({tileSize:u,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(let g of m)n.set(g.key,g);this.usedForTerrain&&p.updateElevation(!1)}vn(Array.from(n.values()),(p,m)=>{let g=new ru(p,this._source.tileSize*p.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(g,x=>{this._source.type==="raster-dem"&&g.dem&&this._backfillDEM(g),m(x,g)})},r)}}function od(i,e){let r=Math.abs(2*i.wrap)-+(i.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return i.overscaledZ-e.overscaledZ||n-r||e.canonical.y-i.canonical.y||e.canonical.x-i.canonical.x}function sd(i){return i==="raster"||i==="image"||i==="video"}Wo.maxOverzooming=10,Wo.maxUnderzooming=3;class jc{constructor(e,r,n){this._demTile=e,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(e,r,n){let s=n||e.findDEMTileFor(r);if(!s||!s.dem)return;let c=s.dem,u=s.tileID,p=1<<r.canonical.z-u.canonical.z;return new jc(s,s.tileSize/He/p,[(r.canonical.x/p-u.canonical.x)*c.dim,(r.canonical.y/p-u.canonical.y)*c.dim])}tileCoordToPixel(e,r){let n=r*this._scale+this._offset[1],s=Math.floor(e*this._scale+this._offset[0]),c=Math.floor(n);return new _e(s,c)}getElevationAt(e,r,n,s){let c=e*this._scale+this._offset[0],u=r*this._scale+this._offset[1],p=Math.floor(c),m=Math.floor(u),g=this._dem;return s=!!s,n?je(je(g.get(p,m,s),g.get(p,m+1,s),u-m),je(g.get(p+1,m,s),g.get(p+1,m+1,s),u-m),c-p):g.get(p,m,s)}getElevationAtPixel(e,r,n){return this._dem.get(e,r,!!n)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Vs(1,e)*this._dem.stride}}class ad{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new kr(He,16,0),this.featureIndexArray=new Ct,this.promoteId=r}insert(e,r,n,s,c,u=0){let p=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,s,c,u);let m=this.grid;for(let g=0;g<r.length;g++){let x=r[g],v=[1/0,1/0,-1/0,-1/0];for(let w=0;w<x.length;w++){let S=x[w];v[0]=Math.min(v[0],S.x),v[1]=Math.min(v[1],S.y),v[2]=Math.max(v[2],S.x),v[3]=Math.max(v[3],S.y)}v[0]<He&&v[1]<He&&v[2]>=0&&v[3]>=0&&m.insert(p,v[0],v[1],v[2],v[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new qo.VectorTile(new sl(this.rawTileData)).layers,this.sourceLayerCoder=new qp(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(let e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,r,n,s){this.loadVTLayers();let c=e.params||{},u=Ar(c.filter),p=e.tileResult,m=e.transform,g=p.bufferedTilespaceBounds,x=this.grid.query(g.min.x,g.min.y,g.max.x,g.max.y,(A,k,L,O)=>Au(p.bufferedTilespaceGeometry,A,k,L,O));x.sort(Rm);let v=null;m.elevation&&x.length>0&&(v=jc.create(m.elevation,this.tileID));let w={},S;for(let A=0;A<x.length;A++){let k=x[A];if(k===S)continue;S=k;let L=this.featureIndexArray.get(k),O=null;this.loadMatchingFeature(w,L,u,c.layers,c.availableImages,r,n,s,(q,H,K,J=0)=>(O||(O=fn(q,this.tileID.canonical,e.tileTransform)),H.queryIntersectsFeature(p,q,K,O,this.z,e.transform,e.pixelPosMatrix,v,J)))}return w}loadMatchingFeature(e,r,n,s,c,u,p,m,g){let{featureIndex:x,bucketIndex:v,sourceLayerIndex:w,layoutVertexArrayOffset:S}=r,A=this.bucketLayerIDs[v];if(s&&!function(q,H){for(let K=0;K<q.length;K++)if(H.indexOf(q[K])>=0)return!0;return!1}(s,A))return;let k=this.sourceLayerCoder.decode(w),L=this.vtLayers[k].feature(x);if(n.needGeometry){let q=Go(L,!0);if(!n.filter(new Tt(this.tileID.overscaledZ),q,this.tileID.canonical))return}else if(!n.filter(new Tt(this.tileID.overscaledZ),L))return;let O=this.getId(L,k);for(let q=0;q<A.length;q++){let H=A[q];if(s&&s.indexOf(H)<0)continue;let K=u[H];if(!K)continue;let J={};O!==void 0&&m&&(J=m.getState(K.sourceLayer||"_geojsonTileLayer",O));let Q=Gt({},p[H]);Q.paint=ld(Q.paint,K.paint,L,J,c),Q.layout=ld(Q.layout,K.layout,L,J,c);let le=!g||g(L,K,J,S);if(!le)continue;let he=new Xp(L,this.z,this.x,this.y,O);he.layer=Q;let fe=e[H];fe===void 0&&(fe=e[H]=[]),fe.push({featureIndex:x,feature:he,intersectionZ:le})}}lookupSymbolFeatures(e,r,n,s,c,u,p,m){let g={};this.loadVTLayers();let x=Ar(c);for(let v of e)this.loadMatchingFeature(g,{bucketIndex:n,sourceLayerIndex:s,featureIndex:v,layoutVertexArrayOffset:0},x,u,p,m,r);return g}loadFeature(e){let{featureIndex:r,sourceLayerIndex:n}=e;this.loadVTLayers();let s=this.sourceLayerCoder.decode(n),c=this.vtFeatures[s];if(c[r])return c[r];let u=this.vtLayers[s].feature(r);return c[r]=u,u}hasLayer(e){for(let r of this.bucketLayerIDs)for(let n of r)if(e===n)return!0;return!1}getId(e,r){let n=e.id;return this.promoteId&&(n=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[r]],typeof n=="boolean"&&(n=Number(n))),n}}function ld(i,e,r,n,s){return _r(i,(c,u)=>{let p=e instanceof f?e.get(u):null;return p&&p.evaluate?p.evaluate(r,n,s):p})}function Rm(i,e){return e-i}ze(ad,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class cd{constructor(e){let r={},n=[];for(let p in e){let m=e[p],g=r[p]={};for(let x in m.glyphs){let v=m.glyphs[+x];if(!v||v.bitmap.width===0||v.bitmap.height===0)continue;let w=v.metrics.localGlyph?2:1,S={x:0,y:0,w:v.bitmap.width+2*w,h:v.bitmap.height+2*w};n.push(S),g[x]=S}}let{w:s,h:c}=Uh(n),u=new mn({width:s||1,height:c||1});for(let p in e){let m=e[p];for(let g in m.glyphs){let x=m.glyphs[+g];if(!x||x.bitmap.width===0||x.bitmap.height===0)continue;let v=r[p][g],w=x.metrics.localGlyph?2:1;mn.copy(x.bitmap,u,{x:0,y:0},{x:v.x+w,y:v.y+w},x.bitmap)}}this.image=u,this.positions=r}}ze(cd,"GlyphAtlas");class Fm{constructor(e){this.tileID=new ai(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=Xo(e.tileID.canonical,e.projection),this.projection=e.projection}parse(e,r,n,s,c){this.status="parsing",this.data=e,this.collisionBoxArray=new hr;let u=new qp(Object.keys(e.layers).sort()),p=new ad(this.tileID,this.promoteId);p.bucketLayerIDs=[];let m={},g=new Qh(256,256),x={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:g,availableImages:n},v=r.familiesBySource[this.source];for(let J in v){let Q=e.layers[J];if(!Q)continue;let le=!1,he=!1;for(let se of v[J])se[0].type==="symbol"?le=!0:he=!0;if(this.isSymbolTile===!0&&!le||this.isSymbolTile===!1&&!he)continue;Q.version===1&&bt(`Vector tile source "${this.source}" layer "${J}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let fe=u.encode(J),ge=[];for(let se=0;se<Q.length;se++){let de=Q.feature(se),xe=p.getId(de,J);ge.push({feature:de,id:xe,index:se,sourceLayerIndex:fe})}for(let se of v[J]){let de=se[0];this.isSymbolTile!==void 0&&de.type==="symbol"!==this.isSymbolTile||de.minzoom&&this.zoom<Math.floor(de.minzoom)||de.maxzoom&&this.zoom>=de.maxzoom||de.visibility!=="none"&&(lu(se,this.zoom,n),(m[de.id]=de.createBucket({index:p.bucketLayerIDs.length,layers:se,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:fe,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.name,availableImages:n})).populate(ge,x,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(se.map(xe=>xe.id)))}}let w,S,A,k;g.trim();let L={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},O=_r(x.glyphDependencies,J=>Object.keys(J).map(Number));Object.keys(O).length?s.send("getGlyphs",{uid:this.uid,stacks:O},(J,Q)=>{w||(w=J,S=Q,K.call(this))},void 0,!1,L):S={};let q=Object.keys(x.iconDependencies);q.length?s.send("getImages",{icons:q,source:this.source,tileID:this.tileID,type:"icons"},(J,Q)=>{w||(w=J,A=Q,K.call(this))},void 0,!1,L):A={};let H=Object.keys(x.patternDependencies);function K(){if(w)return c(w);if(S&&A&&k){let J=new cd(S),Q=new fp(A,k);for(let le in m){let he=m[le];he instanceof Jn?(lu(he.layers,this.zoom,n),um(he,S,J.positions,A,Q.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):he.hasPattern&&(he instanceof Ac||he instanceof Ic||he instanceof rl)&&(lu(he.layers,this.zoom,n),he.addFeatures(x,this.tileID.canonical,Q.patternPositions,n,this.tileTransform))}this.status="done",c(null,{buckets:ao(m).filter(le=>!le.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:J.image,lineAtlas:g,imageAtlas:Q,glyphMap:this.returnDependencies?S:null,iconMap:this.returnDependencies?A:null,glyphPositions:this.returnDependencies?J.positions:null})}}H.length?s.send("getImages",{icons:H,source:this.source,tileID:this.tileID,type:"patterns"},(J,Q)=>{w||(w=J,k=Q,K.call(this))},void 0,!1,L):k={},K.call(this)}}function lu(i,e,r){let n=new Tt(e);for(let s of i)s.recalculate(n,r)}class hd{constructor(e){this.entries={},this.scheduler=e}request(e,r,n,s){let c=this.entries[e]=this.entries[e]||{callbacks:[]};if(c.result){let[u,p]=c.result;return this.scheduler?this.scheduler.add(()=>{s(u,p)},r):s(u,p),()=>{}}return c.callbacks.push(s),c.cancel||(c.cancel=n((u,p)=>{c.result=[u,p];for(let m of c.callbacks)this.scheduler?this.scheduler.add(()=>{m(u,p)},r):m(u,p);setTimeout(()=>delete this.entries[e],3e3)})),()=>{c.result||(c.callbacks=c.callbacks.filter(u=>u!==s),c.callbacks.length||(c.cancel(),delete this.entries[e]))}}}function ud(i,e,r){let n=JSON.stringify(i.request);return i.data&&(this.deduped.entries[n]={result:[null,i.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},s=>{let c=Z(i.request,(u,p,m,g)=>{u?s(u):p&&s(null,{vectorTile:r?void 0:new qo.VectorTile(new sl(p)),rawData:p,cacheControl:m,expires:g})});return()=>{c.cancel(),s()}},e)}let Om=Br(new Float32Array(16));class io{constructor(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,r){return{x:0,y:0,z:0}}unproject(e,r){return new yt(0,0)}projectTilePoint(e,r,n){return{x:e,y:r,z:0}}locationPoint(e,r){return e._coordinatePoint(e.locationCoordinate(r),!1)}pixelsPerMeter(e,r){return Vs(1,e)*r}farthestPixelDistance(e){return function(r,n){let s=r.fovAboveCenter,c=r.elevation?r.elevation.getMinElevationBelowMSL()*n:0,u=(r._camera.position[2]*r.worldSize-c)/Math.cos(r._pitch),p=Math.sin(s)*u/Math.sin(Math.max(Math.PI/2-r._pitch-s,.01)),m=Math.sin(r._pitch)*p+u;return Math.min(1.01*m,u*(1/r._horizonShift))}(e,e.pixelsPerMeter)}pointCoordinate(e,r,n,s){let c=e.horizonLineFromTop(!1),u=new _e(r,Math.max(c,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(u,s))}createInversionMatrix(e,r){return Om}createTileMatrix(e,r,n){let s,c,u,p=n.canonical,m=Br(new Float64Array(16));if(this.isReprojectedInTileSpace){let g=Xo(p,this);s=1,c=g.x+n.wrap*g.scale,u=g.y,Hn(m,m,[s/g.scale,s/g.scale,e.pixelsPerMeter/r])}else s=r/e.zoomScale(p.z),c=(p.x+Math.pow(2,p.z)*n.wrap)*s,u=p.y*s;return Zo(m,m,[c,u,0]),Hn(m,m,[s/He,s/He,1]),m}upVector(e,r,n){return[0,0,1]}upVectorScale(e,r,n){return{metersToTile:1,metersToLabelSpace:1}}}class Um extends io{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,r){return{x:$a(e),y:Us(r),z:0}}unproject(e,r){let n=tr(e),s=Qt(r);return new yt(n,s)}}class Vm extends io{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];let[r,n]=this.parallels=e.parallels||[29.5,45.5],s=Math.sin(lt(r));this.n=(s+Math.sin(lt(n)))/2,this.c=1+s*(2*this.n-s),this.r0=Math.sqrt(this.c)/this.n}project(e,r){let{n,c:s,r0:c}=this,u=lt(e-this.center[0]),p=lt(r),m=Math.sqrt(s-2*n*Math.sin(p))/n;return{x:m*Math.sin(u*n),y:m*Math.cos(u*n)-c,z:0}}unproject(e,r){let{n,c:s,r0:c}=this,u=c+r,p=Math.atan2(e,Math.abs(u))*Math.sign(u);u*n<0&&(p-=Math.PI*Math.sign(e)*Math.sign(u));let m=lt(this.center[0])*n;p=Yi(p,-Math.PI-m,Math.PI-m);let g=ri(p/n)+this.center[0],x=Math.asin(at((s-(e*e+u*u)*n*n)/(2*n),-1,1)),v=at(ri(x),-85.051129,Lr);return new yt(g,v)}}let dl=1.340264,fl=-.081106,ml=893e-6,_l=.003796,Nc=Math.sqrt(3)/2;class jm extends io{project(e,r){r=r/180*Math.PI,e=e/180*Math.PI;let n=Math.asin(Nc*Math.sin(r)),s=n*n,c=s*s*s;return{x:.5*(e*Math.cos(n)/(Nc*(dl+3*fl*s+c*(7*ml+9*_l*s)))/Math.PI+.5),y:1-.5*(n*(dl+fl*s+c*(ml+_l*s))/Math.PI+1),z:0}}unproject(e,r){e=(2*e-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,s=n*n,c=s*s*s;for(let x,v,w,S=0;S<12&&(v=n*(dl+fl*s+c*(ml+_l*s))-r,w=dl+3*fl*s+c*(7*ml+9*_l*s),x=v/w,n=at(n-x,-Math.PI/3,Math.PI/3),s=n*n,c=s*s*s,!(Math.abs(x)<1e-12));++S);let u=Nc*e*(dl+3*fl*s+c*(7*ml+9*_l*s))/Math.cos(n),p=Math.asin(Math.sin(n)/Nc),m=at(180*u/Math.PI,-180,180),g=at(180*p/Math.PI,-85.051129,Lr);return new yt(m,g)}}class Nm extends io{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,r){return{x:.5+e/360,y:.5-r/360,z:0}}unproject(e,r){let n=360*(e-.5),s=at(360*(.5-r),-85.051129,Lr);return new yt(n,s)}}let ta=Math.PI/2;function Gc(i){return Math.tan((ta+i)/2)}class Gm extends io{constructor(e){super(e),this.center=e.center||[0,30];let[r,n]=this.parallels=e.parallels||[30,30],s=lt(r),c=lt(n),u=Math.cos(s);this.n=s===c?Math.sin(s):Math.log(u/Math.cos(c))/Math.log(Gc(c)/Gc(s)),this.f=u*Math.pow(Gc(s),this.n)/this.n}project(e,r){r=lt(r),e=lt(e-this.center[0]);let n=1e-6,{n:s,f:c}=this;c>0?r<-ta+n&&(r=-ta+n):r>ta-n&&(r=ta-n);let u=c/Math.pow(Gc(r),s),p=u*Math.sin(s*e),m=c-u*Math.cos(s*e);return{x:.5*(p/Math.PI+.5),y:1-.5*(m/Math.PI+.5),z:0}}unproject(e,r){e=(2*e-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;let{n,f:s}=this,c=s-r,u=Math.sign(c),p=Math.sign(n)*Math.sqrt(e*e+c*c),m=Math.atan2(e,Math.abs(c))*u;c*n<0&&(m-=Math.PI*Math.sign(e)*u);let g=at(ri(m/n)+this.center[0],-180,180),x=at(ri(2*Math.atan(Math.pow(s/p,1/n))-ta),-85.051129,Lr);return new yt(g,x)}}let pd=lt(Lr);class Zm extends io{project(e,r){let n=(r=lt(r))*r,s=n*n;return{x:.5*((e=lt(e))*(.8707-.131979*n+s*(s*(.003971*n-.001529*s)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+s*(.028874*n-.044475-.005916*s)))/Math.PI+1),z:0}}unproject(e,r){e=(2*e-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,s=25,c=0,u=n*n;do{u=n*n;let g=u*u;c=(n*(1.007226+u*(.015085+g*(.028874*u-.044475-.005916*g)))-r)/(1.007226+u*(.045255+g*(.259866*u-.311325-.005916*11*g))),n=at(n-c,-pd,pd)}while(Math.abs(c)>1e-6&&--s>0);u=n*n;let p=at(ri(e/(.8707+u*(u*(u*u*u*(.003971-.001529*u)-.013791)-.131979))),-180,180),m=ri(n);return new yt(p,m)}}let dd=lt(Lr);class $m extends io{project(e,r){r=lt(r),e=lt(e);let n=Math.cos(r),s=2/Math.PI,c=Math.acos(n*Math.cos(e/2)),u=Math.sin(c)/c,p=.5*(e*s+2*n*Math.sin(e/2)/u)||0,m=.5*(r+Math.sin(r)/u)||0;return{x:.5*(p/Math.PI+.5),y:1-.5*(m/Math.PI+1),z:0}}unproject(e,r){let n=e=(2*e-.5)*Math.PI,s=r=(2*(1-r)-1)*Math.PI,c=25,u=1e-6,p=0,m=0;do{let g=Math.cos(s),x=Math.sin(s),v=2*x*g,w=x*x,S=g*g,A=Math.cos(n/2),k=Math.sin(n/2),L=2*A*k,O=k*k,q=1-S*A*A,H=q?1/q:0,K=q?Math.acos(g*A)*Math.sqrt(1/q):0,J=.5*(2*K*g*k+2*n/Math.PI)-e,Q=.5*(K*x+s)-r,le=.5*H*(S*O+K*g*A*w)+1/Math.PI,he=H*(L*v/4-K*x*k),fe=.125*H*(v*k-K*x*S*L),ge=.5*H*(w*A+K*O*g)+.5,se=he*fe-ge*le;p=(Q*he-J*ge)/se,m=(J*fe-Q*le)/se,n=at(n-p,-Math.PI,Math.PI),s=at(s-m,-dd,dd)}while((Math.abs(p)>u||Math.abs(m)>u)&&--c>0);return new yt(ri(n),ri(s))}}class fd extends io{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(lt(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,r){let{scale:n,cosPhi:s}=this;return{x:lt(e)*s*n+.5,y:-Math.sin(lt(r))/s*n+.5,z:0}}unproject(e,r){let{scale:n,cosPhi:s}=this,c=-(r-.5)/n,u=at(ri((e-.5)/n)/s,-180,180),p=Math.asin(at(c*s,-1,1)),m=at(ri(p),-85.051129,Lr);return new yt(u,m)}}a.ARRAY_TYPE=Ai,a.AUTH_ERR_MSG=Hr,a.Aabb=qi,a.Actor=class{constructor(i,e,r){this.target=i,this.parent=e,this.mapId=r,this.callbacks={},this.cancelCallbacks={},wn(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=Fi()?i:Ne,this.scheduler=new Sm}send(i,e,r,n,s=!1,c){let u=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=c,this.callbacks[u]=r);let p=xr(this.globalScope)?void 0:[];return this.target.postMessage({id:u,type:i,hasCallback:!!r,targetMapId:n,mustQueue:s,sourceMapId:this.mapId,data:Lo(e,p)},p),{cancel:()=>{r&&delete this.callbacks[u],this.target.postMessage({id:u,type:"<cancel>",targetMapId:n,sourceMapId:this.mapId})}}}receive(i){let e=i.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){let n=this.cancelCallbacks[r];delete this.cancelCallbacks[r],n&&n.cancel()}else if(e.mustQueue||Fi()){let n=this.callbacks[r];this.cancelCallbacks[r]=this.scheduler.add(()=>this.processTask(r,e),n&&n.metadata||{type:"message"})}else this.processTask(r,e)}processTask(i,e){if(e.type==="<response>"){let r=this.callbacks[i];delete this.callbacks[i],r&&(e.error?r(jn(e.error)):r(null,jn(e.data)))}else{let r=xr(this.globalScope)?void 0:[],n=e.hasCallback?(c,u)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"<response>",sourceMapId:this.mapId,error:c?Lo(c):null,data:Lo(u,r)},r)}:c=>{},s=jn(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,s,n);else if(this.parent.getWorkerSource){let c=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,c[0],s.source)[c[1]](s,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=Oc,a.Color=ht,a.ColorMode=Ur,a.CullFaceMode=fr,a.DEMData=Vc,a.DataConstantProperty=_,a.DedupedRequest=hd,a.DepthMode=ea,a.EXTENT=He,a.Elevation=class{isDataAvailableAtPoint(i){let e=this._source();if(!e||i.y<0||i.y>1)return!1;let r=e.getSource().maxzoom,n=1<<r,s=Math.floor(i.x),c=Math.floor((i.x-s)*n),u=Math.floor(i.y*n),p=this.findDEMTileFor(new ai(r,s,r,c,u));return!(!p||!p.dem)}getAtPointOrZero(i,e=0){return this.getAtPoint(i,e)||0}getAtPoint(i,e,r=!0){e==null&&(e=null);let n=this._source();if(!n||i.y<0||i.y>1)return e;let s=n.getSource().maxzoom,c=1<<s,u=Math.floor(i.x),p=i.x-u,m=new ai(s,u,s,Math.floor(p*c),Math.floor(i.y*c)),g=this.findDEMTileFor(m);if(!g||!g.dem)return e;let x=g.dem,v=1<<g.tileID.canonical.z,w=(p*v-g.tileID.canonical.x)*x.dim,S=(i.y*v-g.tileID.canonical.y)*x.dim,A=Math.floor(w),k=Math.floor(S);return(r?this.exaggeration():1)*je(je(x.get(A,k),x.get(A,k+1),S-k),je(x.get(A+1,k),x.get(A+1,k+1),S-k),w-A)}getAtTileOffset(i,e,r){let n=1<<i.canonical.z;return this.getAtPointOrZero(new gc(i.wrap+(i.canonical.x+e/He)/n,(i.canonical.y+r/He)/n))}getAtTileOffsetFunc(i,e,r,n){return s=>{let c=this.getAtTileOffset(i,s.x,s.y),u=n.upVector(i.canonical,s.x,s.y);return Xa(u,u,c*n.upVectorScale(i.canonical,e,r).metersToTile),u}}getForTilePoints(i,e,r,n){let s=jc.create(this,i,n);return!!s&&(e.forEach(c=>{c[2]=this.exaggeration()*s.getElevationAt(c[0],c[1],r)}),!0)}getMinMaxForTile(i){let e=this.findDEMTileFor(i);if(!e||!e.dem)return null;let r=e.dem.tree,n=e.tileID,s=1<<i.canonical.z-n.canonical.z,c=i.canonical.x/s-n.canonical.x,u=i.canonical.y/s-n.canonical.y,p=0;for(let m=0;m<i.canonical.z-n.canonical.z&&!r.leaves[p];m++){c*=2,u*=2;let g=2*Math.floor(u)+Math.floor(c);p=r.childOffsets[p]+g,c%=1,u%=1}return{min:this.exaggeration()*r.minimums[p],max:this.exaggeration()*r.maximums[p]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(i,e,r){throw new Error("Pure virtual method called.")}pointCoordinate(i){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(i){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},a.ErrorEvent=Ue,a.EvaluationParameters=Tt,a.Event=Oe,a.Evented=$e,a.FillExtrusionBucket=rl,a.Frustum=Ah,a.GLOBE_RADIUS=Qs,a.GlobeSharedBuffers=class{constructor(i){this._createGrid(i),this._createPoles(i),this._createAtmosphere(i)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(let i of this._poleSegments)i.destroy();this._gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this._wireframeIndexBuffer&&(this._wireframeIndexBuffer.destroy(),this._wireframeSegments.destroy())}_createGrid(i){let e=new j,r=new ke,n=65;for(let s=0;s<n;s++)for(let c=0;c<n;c++)e.emplaceBack(c,s);for(let s=0;s<64;s++)for(let c=0;c<64;c++){let u=s*n+c;r.emplaceBack(u+1,u,u+n),r.emplaceBack(u+n,u+n+1,u+1)}this._gridBuffer=i.createVertexBuffer(e,hl.members),this._gridIndexBuffer=i.createIndexBuffer(r,!0),this._gridSegments=Pt.simpleSegment(0,0,4225,8192)}_createPoles(i){let e=new ke;for(let s=0;s<=64;s++)e.emplaceBack(0,s+1,s+2);this._poleIndexBuffer=i.createIndexBuffer(e,!0);let r=new Ze,n=new Ze;this._poleSegments=[];for(let s=0,c=0;s<5;s++){let u=1<<s,p=512*u/Math.PI/2,m=360/u;r.emplaceBack(0,-p,0,0,0,.5,0),n.emplaceBack(0,-p,0,0,0,.5,1);for(let g=0;g<=64;g++){let x=g/64,v=je(0,m,x),[w,S,A]=Op(km,Dm,v,p);r.emplaceBack(w,S,A,0,0,x,0),n.emplaceBack(w,S,A,0,0,x,1)}this._poleSegments.push(Pt.simpleSegment(c,0,66,64)),c+=66}this._poleNorthVertexBuffer=i.createVertexBuffer(r,Rp,!1),this._poleSouthVertexBuffer=i.createVertexBuffer(n,Rp,!1)}_createAtmosphere(i){let e=new Ye;e.emplaceBack(-1,1,1,0,0),e.emplaceBack(1,1,1,1,0),e.emplaceBack(1,-1,1,1,1),e.emplaceBack(-1,-1,1,0,1);let r=new ke;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.atmosphereVertexBuffer=i.createVertexBuffer(e,Mm.members),this.atmosphereIndexBuffer=i.createIndexBuffer(r),this.atmosphereSegments=Pt.simpleSegment(0,0,4,2)}getGridBuffers(){return[this._gridBuffer,this._gridIndexBuffer,this._gridSegments]}getPoleBuffers(i){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[i]]}getWirefameBuffers(i){if(!this._wireframeSegments){let e=new qe,r=64,n=r+1;for(let s=0;s<r;s++)for(let c=0;c<r;c++){let u=s*n+c;e.emplaceBack(u,u+1),e.emplaceBack(u,u+n),e.emplaceBack(u,u+n+1)}this._wireframeIndexBuffer=i.createIndexBuffer(e),this._wireframeSegments=Pt.simpleSegment(0,0,r*r,e.length)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments]}},a.GlyphManager=Ks,a.ImagePosition=Vh,a.LineAtlas=Qh,a.LngLat=yt,a.LngLatBounds=Wn,a.LocalGlyphMode=Zh,a.MAX_MERCATOR_LATITUDE=Lr,a.MercatorCoordinate=gc,a.ONE_EM=ei,a.OverscaledTileID=ai,a.Properties=M,a.RGBAImage=Ci,a.Ray=class{constructor(i,e){this.pos=i,this.dir=e}intersectsPlane(i,e,r){let n=Ha(e,this.dir);if(Math.abs(n)<1e-6)return!1;let s=((i[0]-this.pos[0])*e[0]+(i[1]-this.pos[1])*e[1]+(i[2]-this.pos[2])*e[2])/n;return r[0]=this.pos[0]+this.dir[0]*s,r[1]=this.pos[1]+this.dir[1]*s,r[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,e,r){if(function(w,S){var A=w[0],k=w[1],L=w[2],O=S[0],q=S[1],H=S[2];return Math.abs(A-O)<=vh*Math.max(1,Math.abs(A),Math.abs(O))&&Math.abs(k-q)<=vh*Math.max(1,Math.abs(k),Math.abs(q))&&Math.abs(L-H)<=vh*Math.max(1,Math.abs(L),Math.abs(H))}(this.pos,i)||e===0)return r[0]=r[1]=r[2]=0,!1;let[n,s,c]=this.dir,u=this.pos[0]-i[0],p=this.pos[1]-i[1],m=this.pos[2]-i[2],g=n*n+s*s+c*c,x=2*(u*n+p*s+m*c),v=x*x-4*g*(u*u+p*p+m*m-e*e);if(v<0){let w=Math.max(-x/2,0),S=u+n*w,A=p+s*w,k=m+c*w,L=Math.hypot(S,A,k);return r[0]=S*e/L,r[1]=A*e/L,r[2]=k*e/L,!1}{let w=(-x-Math.sqrt(v))/(2*g);if(w<0){let S=Math.hypot(u,p,m);return r[0]=u*e/S,r[1]=p*e/S,r[2]=m*e/S,!1}return r[0]=u+n*w,r[1]=p+s*w,r[2]=m+c*w,!0}}},a.RequestManager=class{constructor(i,e,r){this._transformRequestFn=i,this._customAccessToken=e,this._silenceAuthErrors=!!r,this._createSkuToken()}_createSkuToken(){let i=function(){let e="";for(let r=0;r<10;r++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Sn,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,e){return this._transformRequestFn&&this._transformRequestFn(i,e)||{url:i}}normalizeStyleURL(i,e){if(!Oi(i))return i;let r=Vi(i);return r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeGlyphsURL(i,e){if(!Oi(i))return i;let r=Vi(i);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeSourceURL(i,e){if(!Oi(i))return i;let r=Vi(i);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(i,e,r,n){let s=Vi(i);return Oi(i)?(s.path=`/styles/v1${s.path}/sprite${e}${r}`,this._makeAPIURL(s,this._customAccessToken||n)):(s.path+=`${e}${r}`,br(s))}normalizeTileURL(i,e,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!Oi(i))return i;let n=Vi(i);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||r&&n.authority!=="raster"&&r===512?"@2x":""}${vr.supported?".webp":"$1"}`),n.authority==="raster"?n.path=`/${ut.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${ut.TILE_URL_VERSION}${n.path}`);let s=this._customAccessToken||function(c){for(let u of c){let p=u.match(/^access_token=(.*)$/);if(p)return p[1]}return null}(n.params)||ut.ACCESS_TOKEN;return ut.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(i,e){let r=Vi(i);if(!r.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!r.path.match(/\.[\w]+$/))return i;let n="mapbox://";r.path.match(/^\/raster\/v1\//)?n+=`raster/${r.path.replace(`/${ut.RASTER_URL_PREFIX}/`,"")}`:n+=`tiles/${r.path.replace(`/${ut.TILE_URL_VERSION}/`,"")}`;let s=r.params;return e&&(s=s.filter(c=>!c.match(/^access_token=/))),s.length&&(n+=`?${s.join("&")}`),n}canonicalizeTileset(i,e){let r=!!e&&Oi(e),n=[];for(let s of i.tiles||[])Yr(s)?n.push(this.canonicalizeTileURL(s,r)):n.push(s);return n}_makeAPIURL(i,e){let r="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",n=Vi(ut.API_URL);if(i.protocol=n.protocol,i.authority=n.authority,i.protocol==="http"){let s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if(n.path!=="/"&&(i.path=`${n.path}${i.path}`),!ut.REQUIRE_ACCESS_TOKEN)return br(i);if(e=e||ut.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if(e[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return i.params=i.params.filter(s=>s.indexOf("access_token")===-1),i.params.push(`access_token=${e||""}`),br(i)}},a.ResourceType=U,a.SegmentVector=Pt,a.SourceCache=Wo,a.StencilMode=ou,a.StructArrayLayout1ui2=st,a.StructArrayLayout2f1f2i16=Le,a.StructArrayLayout2i4=j,a.StructArrayLayout2ui4=qe,a.StructArrayLayout3f12=we,a.StructArrayLayout3ui6=ke,a.StructArrayLayout4i8=$,a.Texture=cl,a.Tile=ru,a.Transitionable=l,a.Uniform1f=mc,a.Uniform1i=class extends pn{constructor(i,e){super(i,e),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},a.Uniform2f=class extends pn{constructor(i,e){super(i,e),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},a.Uniform3f=class extends pn{constructor(i,e){super(i,e),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},a.Uniform4f=yu,a.UniformColor=xu,a.UniformMatrix2f=class extends pn{constructor(i,e){super(i,e),this.current=Id}set(i){for(let e=0;e<4;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},a.UniformMatrix3f=class extends pn{constructor(i,e){super(i,e),this.current=Sd}set(i){for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},a.UniformMatrix4f=class extends pn{constructor(i,e){super(i,e),this.current=Ed}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},a.UnwrappedTileID=$p,a.ValidationError=Ae,a.VectorTileWorkerSource=class extends $e{constructor(i,e,r,n,s){super(),this.actor=i,this.layerIndex=e,this.availableImages=r,this.loadVectorData=s||ud,this.loading={},this.loaded={},this.deduped=new hd(i.scheduler),this.isSpriteLoaded=n,this.scheduler=i.scheduler}loadTile(i,e){let r=i.uid,n=i&&i.request,s=n&&n.collectResourceTiming,c=this.loading[r]=new Fm(i);c.abort=this.loadVectorData(i,(u,p)=>{let m=!this.loading[r];if(delete this.loading[r],m||u||!p)return c.status="done",m||(this.loaded[r]=c),e(u);let g=p.rawData,x={};p.expires&&(x.expires=p.expires),p.cacheControl&&(x.cacheControl=p.cacheControl),c.vectorTile=p.vectorTile||new qo.VectorTile(new sl(g));let v=()=>{c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,(w,S)=>{if(w||!S)return e(w);let A={};if(s){let k=Bp(n);k.length>0&&(A.resourceTiming=JSON.parse(JSON.stringify(k)))}e(null,Gt({rawTileData:g.slice(0)},S,x,A))})};this.isSpriteLoaded?v():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(v,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):v()}),this.loaded=this.loaded||{},this.loaded[r]=c})}reloadTile(i,e){let r=this.loaded,n=i.uid,s=this;if(r&&r[n]){let c=r[n];c.showCollisionBoxes=i.showCollisionBoxes,c.enableTerrain=!!i.enableTerrain,c.projection=i.projection,c.tileTransform=Xo(i.tileID.canonical,i.projection);let u=(p,m)=>{let g=c.reloadCallback;g&&(delete c.reloadCallback,c.parse(c.vectorTile,s.layerIndex,this.availableImages,s.actor,g)),e(p,m)};c.status==="parsing"?c.reloadCallback=u:c.status==="done"&&(c.vectorTile?c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,u):u())}}abortTile(i,e){let r=i.uid,n=this.loading[r];n&&(n.abort&&n.abort(),delete this.loading[r]),e()}removeTile(i,e){let r=this.loaded,n=i.uid;r&&r[n]&&delete r[n],e()}},a.WritingMode=Xi,a.ZoomHistory=ka,a.add=Lu,a.addDynamicAttributes=Wh,a.adjoint=function(i,e){var r=e[0],n=e[1],s=e[2],c=e[3],u=e[4],p=e[5],m=e[6],g=e[7],x=e[8];return i[0]=u*x-p*g,i[1]=s*g-n*x,i[2]=n*p-s*u,i[3]=p*m-c*x,i[4]=r*x-s*m,i[5]=s*c-r*p,i[6]=c*g-u*m,i[7]=n*m-r*g,i[8]=r*u-n*c,i},a.asyncAll=vn,a.bezier=Gr,a.bindAll=wn,a.boundsAttributes=Hp,a.bufferConvexPolygon=function(i,e){let r=[];for(let n=0;n<i.length;n++){let s=Yi(n-1,-1,i.length-1),c=Yi(n+1,-1,i.length-1),u=i[n],p=i[c],m=i[s].sub(u).unit(),g=p.sub(u).unit(),x=g.angleWithSep(m.x,m.y),v=m.add(g).unit().mult(-1*e/Math.sin(x/2));r.push(u.add(v))}return r},a.cacheEntryPossiblyAdded=function(i){Cn++,Cn>en&&(i.getActor().send("enforceCacheSizeLimit",Qr),Cn=0)},a.calculateGlobeLabelMatrix=function(i,e){let{lng:r,lat:n}=i._center,s=jp(0,0,i.worldSize/i._projectionScaler,r,n);return bh(s,s,function(c){let u=Br(new Float64Array(16)),p=1/iu(c);return Zo(u,u,c.min),Hn(u,u,[p,p,p]),u}(ul(e)))},a.calculateGlobeMatrix=Np,a.calculateGlobeMercatorMatrix=function(i){let e=i.worldSize,r=i.point,n=Vs(1,i.center.lat)*e,s=i.pixelsPerMeter,c=e/(n/i.pixelsPerMeter),u=Br(new Float64Array(16));return Zo(u,u,[r.x,r.y,0]),Hn(u,u,[c,c,s]),Float32Array.from(u)},a.circumferenceAtLatitude=fh,a.clamp=at,a.clearTileCache=function(i){let e=Ne.caches.delete(ns);i&&e.catch(i).then(()=>i())},a.clipLine=Ip,a.clone=function(i){var e=new Ai(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},a.clone$1=wi,a.collisionCircleLayout=Ff,a.config=ut,a.conjugate=function(i,e){return i[0]=-e[0],i[1]=-e[1],i[2]=-e[2],i[3]=e[3],i},a.create=function(){var i=new Ai(16);return Ai!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},a.create$1=ku,a.createExpression=Io,a.createLayout=G,a.createStyleLayer=function(i){return i.type==="custom"?new vm(i):new wm[i.type](i)},a.cross=Fu,a.degToRad=lt,a.div=function(i,e,r){return i[0]=e[0]/r[0],i[1]=e[1]/r[1],i[2]=e[2]/r[2],i},a.dot=Ha,a.earthRadius=dh,a.ease=Hi,a.easeCubicInOut=Nr,a.emitValidationErrors=Hl,a.endsWith=Ki,a.enforceCacheSizeLimit=function(i){An(),ji&&ji.then(e=>{e.keys().then(r=>{for(let n=0;n<r.length-i;n++)e.delete(r[n])})})},a.evaluateSizeForFeature=Cc,a.evaluateSizeForZoom=Xs,a.evaluateVariableOffset=kp,a.evented=ja,a.exactEquals=function(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]},a.exactEquals$1=function(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]},a.exported=ni,a.exported$1=vr,a.extend=Gt,a.extend$1=pt,a.filterObject=co,a.fromMat4=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],i},a.fromQuat=function(i,e){var r=e[0],n=e[1],s=e[2],c=e[3],u=r+r,p=n+n,m=s+s,g=r*u,x=n*u,v=n*p,w=s*u,S=s*p,A=s*m,k=c*u,L=c*p,O=c*m;return i[0]=1-v-A,i[1]=x+O,i[2]=w-L,i[3]=0,i[4]=x-O,i[5]=1-g-A,i[6]=S+k,i[7]=0,i[8]=w+L,i[9]=S-k,i[10]=1-g-v,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},a.fromRotation=function(i,e){var r=Math.sin(e),n=Math.cos(e);return i[0]=n,i[1]=r,i[2]=0,i[3]=-r,i[4]=n,i[5]=0,i[6]=0,i[7]=0,i[8]=1,i},a.fromScaling=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},a.furthestTileCorner=function(i){let e=Math.round((i+45+360)%360/90)%4;return Yo[e]},a.getAABBPointSquareDist=function(i,e,r){let n=0;for(let s=0;s<2;++s){let c=r?r[s]:0;i[s]>c&&(n+=(i[s]-c)*(i[s]-c)),e[s]<c&&(n+=(c-e[s])*(c-e[s]))}return n},a.getAnchorAlignment=Gh,a.getAnchorJustification=qh,a.getBounds=function(i){let e=1/0,r=1/0,n=-1/0,s=-1/0;for(let c of i)e=Math.min(e,c.x),r=Math.min(r,c.y),n=Math.max(n,c.x),s=Math.max(s,c.y);return{min:new _e(e,r),max:new _e(n,s)}},a.getColumn=function(i,e){return[i[4*e],i[4*e+1],i[4*e+2],i[4*e+3]]},a.getGridMatrix=function(i,e){let[r,n]=e,s=.015625;return[0,(n[1]-r[1])*s,1<<i.z,(n[0]-r[0])*s,0,i.y,r[0],r[1],s]},a.getImage=Me,a.getJSON=function(i,e){return R(Gt(i,{type:"json"}),e)},a.getMapSessionAPI=rs,a.getPerformanceMeasurement=Bp,a.getProjection=function(i){let e=i.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(i.name){case"mercator":return new Um(i);case"equirectangular":return new Nm(i);case"naturalEarth":return new Zm(i);case"equalEarth":return new jm(i);case"winkelTripel":return new $m(i);case"albers":return r?new fd(i):new Vm(i);case"lambertConformalConic":return r?new fd(i):new Gm(i)}throw new Error(`Invalid projection name: ${i.name}`)},a.getRTLTextPluginStatus=Fs,a.getReferrer=C,a.getTilePoint=function(i,{x:e,y:r},n=0){return new _e(((e-n)*i.scale-i.x)*He,(r*i.scale-i.y)*He)},a.getTileVec3=function(i,e,r=0){return qa(((e.x-r)*i.scale-i.x)*He,(e.y*i.scale-i.y)*He,wu(e.z,e.y))},a.getVideo=function(i,e){let r=Ne.document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r)};for(let n=0;n<i.length;n++){let s=Ne.document.createElement("source");ee(i[n])||(r.crossOrigin="Anonymous"),s.src=i[n],r.appendChild(s)}return{cancel:()=>{}}},a.globeECEFOrigin=function(i,e){let r=[0,0,0];return $o(r,r,Vp(ul(e.canonical))),$o(r,r,i),r},a.globePixelsToTileUnits=function(i,e){return He/(512*Math.pow(2,i))*iu(ul(e))},a.globePoleMatrixForTile=function(i,e,r){let n=Br(new Float64Array(16)),s=1<<i,c=360*(e/s-.5),u=r.point,p=r.worldSize/(r.tileSize*s);return Zo(n,n,[u.x,u.y,-r.worldSize/Math.PI/2]),Hn(n,n,[p,p,p]),wh(n,n,lt(-r._center.lat)),Th(n,n,lt(-r._center.lng+c)),Float32Array.from(n)},a.globeTileLatLngCorners=tu,a.globeToMercatorTransition=function(i){return so(5,6,i)},a.identity=Br,a.identity$1=Vu,a.invert=function(i,e){var r=e[0],n=e[1],s=e[2],c=e[3],u=e[4],p=e[5],m=e[6],g=e[7],x=e[8],v=e[9],w=e[10],S=e[11],A=e[12],k=e[13],L=e[14],O=e[15],q=r*p-n*u,H=r*m-s*u,K=r*g-c*u,J=n*m-s*p,Q=n*g-c*p,le=s*g-c*m,he=x*k-v*A,fe=x*L-w*A,ge=x*O-S*A,se=v*L-w*k,de=v*O-S*k,xe=w*O-S*L,Se=q*xe-H*de+K*se+J*ge-Q*fe+le*he;return Se?(i[0]=(p*xe-m*de+g*se)*(Se=1/Se),i[1]=(s*de-n*xe-c*se)*Se,i[2]=(k*le-L*Q+O*J)*Se,i[3]=(w*Q-v*le-S*J)*Se,i[4]=(m*ge-u*xe-g*fe)*Se,i[5]=(r*xe-s*ge+c*fe)*Se,i[6]=(L*K-A*le-O*H)*Se,i[7]=(x*le-w*K+S*H)*Se,i[8]=(u*de-p*ge+g*he)*Se,i[9]=(n*ge-r*de-c*he)*Se,i[10]=(A*Q-k*K+O*q)*Se,i[11]=(v*K-x*Q-S*q)*Se,i[12]=(p*fe-u*se-m*he)*Se,i[13]=(r*se-n*fe+s*he)*Se,i[14]=(k*H-A*J-L*q)*Se,i[15]=(x*J-v*H+w*q)*Se,i):null},a.isMapAuthenticated=function(i){return Jr.has(i)},a.isMapboxURL=Oi,a.isSafariWithAntialiasingBug=function(i){let e=i.navigator?i.navigator.userAgent:null;return!!xr(i)&&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/))},a.latFromMercatorY=Qt,a.len=Gd,a.length=Pu,a.length$1=function(i){return Math.hypot(i[0],i[1],i[2],i[3])},a.loadVectorTile=ud,a.makeRequest=R,a.mercatorXfromLng=$a,a.mercatorYfromLat=Us,a.mercatorZfromAltitude=Vs,a.mul=jd,a.mul$1=Nd,a.multiply=function(i,e,r){var n=e[0],s=e[1],c=e[2],u=e[3],p=e[4],m=e[5],g=e[6],x=e[7],v=e[8],w=r[0],S=r[1],A=r[2],k=r[3],L=r[4],O=r[5],q=r[6],H=r[7],K=r[8];return i[0]=w*n+S*u+A*g,i[1]=w*s+S*p+A*x,i[2]=w*c+S*m+A*v,i[3]=k*n+L*u+O*g,i[4]=k*s+L*p+O*x,i[5]=k*c+L*m+O*v,i[6]=q*n+H*u+K*g,i[7]=q*s+H*p+K*x,i[8]=q*c+H*m+K*v,i},a.multiply$1=bh,a.multiply$2=Ru,a.nextPowerOfTwo=Jo,a.normalize=Wa,a.normalize$1=function(i,e){var r=e[0],n=e[1],s=e[2],c=e[3],u=r*r+n*n+s*s+c*c;return u>0&&(u=1/Math.sqrt(u)),i[0]=r*u,i[1]=n*u,i[2]=s*u,i[3]=c*u,i},a.number=je,a.ortho=function(i,e,r,n,s,c,u){var p=1/(e-r),m=1/(n-s),g=1/(c-u);return i[0]=-2*p,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*m,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*g,i[11]=0,i[12]=(e+r)*p,i[13]=(s+n)*m,i[14]=(u+c)*g,i[15]=1,i},a.pbf=sl,a.perspective=function(i,e,r,n,s){var c,u=1/Math.tan(e/2);return i[0]=u/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=u,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,s!=null&&s!==1/0?(i[10]=(s+n)*(c=1/(n-s)),i[14]=2*s*n*c):(i[10]=-1,i[14]=-2*n),i},a.pick=function(i,e){let r={};for(let n=0;n<e.length;n++){let s=e[n];s in i&&(r[s]=i[s])}return r},a.plugin=Ii,a.pointGeometry=_e,a.polygonIntersectsBox=Au,a.polygonIntersectsPolygon=Eu,a.polygonizeBounds=function(i,e,r=0,n=!0){let s=new _e(r,r),c=i.sub(s),u=e.add(s),p=[c,new _e(u.x,c.y),u,new _e(c.x,u.y)];return n&&p.push(c),p},a.posAttributes=hl,a.postMapLoadEvent=is,a.postTurnstileEvent=ia,a.potpack=Uh,a.prevPowerOfTwo=function(i){return i<=1?1:Math.pow(2,Math.floor(Math.log(i)/Math.LN2))},a.radToDeg=ri,a.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],a.registerForPluginStateChange=function(i){return i({pluginStatus:si,pluginURL:_i}),ja.on("pluginStateChange",i),i},a.removeAuthState=function(i){Jr.delete(i)},a.renderColorRamp=zh,a.rotateX=wh,a.rotateX$1=ju,a.rotateY=Th,a.rotateZ=function(i,e,r){var n=Math.sin(r),s=Math.cos(r),c=e[0],u=e[1],p=e[2],m=e[3],g=e[4],x=e[5],v=e[6],w=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=c*s+g*n,i[1]=u*s+x*n,i[2]=p*s+v*n,i[3]=m*s+w*n,i[4]=g*s-c*n,i[5]=x*s-u*n,i[6]=v*s-p*n,i[7]=w*s-m*n,i},a.rotateZ$1=function(i,e,r){r*=.5;var n=e[0],s=e[1],c=e[2],u=e[3],p=Math.sin(r),m=Math.cos(r);return i[0]=n*m+s*p,i[1]=s*m-n*p,i[2]=c*m+u*p,i[3]=u*m-c*p,i},a.scale=Hn,a.scale$1=function(i,e,r){return i[0]=e[0]*r,i[1]=e[1]*r,i[2]=e[2]*r,i[3]=e[3]*r,i},a.scale$2=Xa,a.scaleAndAdd=Mh,a.setCacheLimits=function(i,e){Qr=i,en=e},a.setColumn=function(i,e,r){i[4*e+0]=r[0],i[4*e+1]=r[1],i[4*e+2]=r[2],i[4*e+3]=r[3]},a.setRTLTextPlugin=function(i,e,r=!1){if(si===Oa||si===Oo||si===Ua)throw new Error("setRTLTextPlugin cannot be called multiple times.");_i=ni.resolveURL(i),si=Oa,Va=e,hn(),r||Gn()},a.smoothstep=so,a.spec=oe,a.storeAuthState=function(i,e){e?Jr.add(i):Jr.delete(i)},a.sub=Gs,a.subtract=Bu,a.symbolSize=Of,a.tileAABB=function(i,e,r,n,s,c,u,p,m){if(m.name==="globe")return zm(i,e,new Oc(r,n,s));let g=Xo({z:r,x:n,y:s},m);return new qi([(c+g.x/g.scale)*e,e*(g.y/g.scale),u],[(c+g.x2/g.scale)*e,e*(g.y2/g.scale),p])},a.tileTransform=Xo,a.transformMat3=function(i,e,r){var n=e[0],s=e[1],c=e[2];return i[0]=n*r[0]+s*r[3]+c*r[6],i[1]=n*r[1]+s*r[4]+c*r[7],i[2]=n*r[2]+s*r[5]+c*r[8],i},a.transformMat4=$o,a.transformMat4$1=Zs,a.transformQuat=Ou,a.translate=Zo,a.transpose=function(i,e){if(i===e){var r=e[1],n=e[2],s=e[5];i[1]=e[3],i[2]=e[6],i[3]=r,i[5]=e[7],i[6]=n,i[7]=s}else i[0]=e[0],i[1]=e[3],i[2]=e[6],i[3]=e[1],i[4]=e[4],i[5]=e[7],i[6]=e[2],i[7]=e[5],i[8]=e[8];return i},a.triggerPluginCompletionEvent=Uo,a.uniqueId=bn,a.validateCustomStyleLayer=function(i){let e=[],r=i.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),i.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},a.validateFilter=i=>cr(zr(i)),a.validateFog=i=>cr(Wl(i)),a.validateLayer=i=>cr(Gl(i)),a.validateLight=i=>cr(ql(i)),a.validateSource=i=>cr($l(i)),a.validateStyle=Po,a.validateTerrain=i=>cr(Xl(i)),a.values=ao,a.vectorTile=qo,a.version=Ri,a.warnOnce=bt,a.window=Ne,a.wrap=Yi}),$c(["./shared"],function(a){"use strict";function Ri(U){if(typeof U=="number"||typeof U=="boolean"||typeof U=="string"||U==null)return JSON.stringify(U);if(Array.isArray(U)){let C="[";for(let R of U)C+=`${Ri(R)},`;return`${C}]`}let I="{";for(let C of Object.keys(U).sort())I+=`${C}:${Ri(U[C])},`;return`${I}}`}function mr(U){let I="";for(let C of a.refProperties)I+=`/${Ri(U[C])}`;return I}class ui{constructor(I){this.keyCache={},I&&this.replace(I)}replace(I){this._layerConfigs={},this._layers={},this.update(I,[])}update(I,C){for(let Z of I)this._layerConfigs[Z.id]=Z,(this._layers[Z.id]=a.createStyleLayer(Z)).compileFilter(),this.keyCache[Z.id]&&delete this.keyCache[Z.id];for(let Z of C)delete this.keyCache[Z],delete this._layerConfigs[Z],delete this._layers[Z];this.familiesBySource={};let R=function(Z,W){let te={};for(let Y=0;Y<Z.length;Y++){let ne=W&&W[Z[Y].id]||mr(Z[Y]);W&&(W[Z[Y].id]=ne);let me=te[ne];me||(me=te[ne]=[]),me.push(Z[Y])}let ee=[];for(let Y in te)ee.push(te[Y]);return ee}(a.values(this._layerConfigs),this.keyCache);for(let Z of R){let W=Z.map(Me=>this._layers[Me.id]),te=W[0];if(te.visibility==="none")continue;let ee=te.source||"",Y=this.familiesBySource[ee];Y||(Y=this.familiesBySource[ee]={});let ne=te.sourceLayer||"_geojsonTileLayer",me=Y[ne];me||(me=Y[ne]=[]),me.push(W)}}}class _e{loadTile(I,C){let{uid:R,encoding:Z,rawImageData:W,padding:te,buildQuadTree:ee}=I,Y=a.window.ImageBitmap&&W instanceof a.window.ImageBitmap?this.getImageData(W,te):W;C(null,new a.DEMData(R,Y,Z,te<1,ee))}getImageData(I,C){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(I.width,I.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=I.width,this.offscreenCanvas.height=I.height,this.offscreenCanvasContext.drawImage(I,0,0,I.width,I.height);let R=this.offscreenCanvasContext.getImageData(-C,-C,I.width+2*C,I.height+2*C);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),R}}var et=function U(I,C){var R,Z=I&&I.type;if(Z==="FeatureCollection")for(R=0;R<I.features.length;R++)U(I.features[R],C);else if(Z==="GeometryCollection")for(R=0;R<I.geometries.length;R++)U(I.geometries[R],C);else if(Z==="Feature")U(I.geometry,C);else if(Z==="Polygon")Ne(I.coordinates,C);else if(Z==="MultiPolygon")for(R=0;R<I.coordinates.length;R++)Ne(I.coordinates[R],C);return I};function Ne(U,I){if(U.length!==0){Wi(U[0],I);for(var C=1;C<U.length;C++)Wi(U[C],!I)}}function Wi(U,I){for(var C=0,R=0,Z=0,W=U.length,te=W-1;Z<W;te=Z++){var ee=(U[Z][0]-U[te][0])*(U[te][1]+U[Z][1]),Y=C+ee;R+=Math.abs(C)>=Math.abs(ee)?C-Y+ee:ee-Y+C,C=Y}C+R>=0!=!!I&&U.reverse()}let jr=a.vectorTile.VectorTileFeature.prototype.toGeoJSON;class lt{constructor(I){this._feature=I,this.extent=a.EXTENT,this.type=I.type,this.properties=I.tags,"id"in I&&!isNaN(I.id)&&(this.id=parseInt(I.id,10))}loadGeometry(){if(this._feature.type===1){let I=[];for(let C of this._feature.geometry)I.push([new a.pointGeometry(C[0],C[1])]);return I}{let I=[];for(let C of this._feature.geometry){let R=[];for(let Z of C)R.push(new a.pointGeometry(Z[0],Z[1]));I.push(R)}return I}}toGeoJSON(I,C,R){return jr.call(this,I,C,R)}}class ri{constructor(I){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=I.length,this._features=I}feature(I){return new lt(this._features[I])}}var Yo=a.vectorTile.VectorTileFeature,Nr=Gr;function Gr(U,I){this.options=I||{},this.features=U,this.length=U.length}function Hi(U,I){this.id=typeof U.id=="number"?U.id:void 0,this.type=U.type,this.rawGeometry=U.type===1?[U.geometry]:U.geometry,this.properties=U.tags,this.extent=I||4096}Gr.prototype.feature=function(U){return new Hi(this.features[U],this.options.extent)},Hi.prototype.loadGeometry=function(){var U=this.rawGeometry;this.geometry=[];for(var I=0;I<U.length;I++){for(var C=U[I],R=[],Z=0;Z<C.length;Z++)R.push(new a.pointGeometry(C[Z][0],C[Z][1]));this.geometry.push(R)}return this.geometry},Hi.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var U=this.geometry,I=1/0,C=-1/0,R=1/0,Z=-1/0,W=0;W<U.length;W++)for(var te=U[W],ee=0;ee<te.length;ee++){var Y=te[ee];I=Math.min(I,Y.x),C=Math.max(C,Y.x),R=Math.min(R,Y.y),Z=Math.max(Z,Y.y)}return[I,R,C,Z]},Hi.prototype.toGeoJSON=Yo.prototype.toGeoJSON;var at=Yi,so=Nr;function Yi(U){var I=new a.pbf;return function(C,R){for(var Z in C.layers)R.writeMessage(3,vn,C.layers[Z])}(U,I),I.finish()}function vn(U,I){var C;I.writeVarintField(15,U.version||1),I.writeStringField(1,U.name||""),I.writeVarintField(5,U.extent||4096);var R={keys:[],values:[],keycache:{},valuecache:{}};for(C=0;C<U.length;C++)R.feature=U.feature(C),I.writeMessage(2,ao,R);var Z=R.keys;for(C=0;C<Z.length;C++)I.writeStringField(3,Z[C]);var W=R.values;for(C=0;C<W.length;C++)I.writeMessage(4,Jo,W[C])}function ao(U,I){var C=U.feature;C.id!==void 0&&I.writeVarintField(1,C.id),I.writeMessage(2,Gt,U),I.writeVarintField(3,C.type),I.writeMessage(4,Ko,C)}function Gt(U,I){var C=U.feature,R=U.keys,Z=U.values,W=U.keycache,te=U.valuecache;for(var ee in C.properties){var Y=C.properties[ee],ne=W[ee];if(Y!==null){ne===void 0&&(R.push(ee),W[ee]=ne=R.length-1),I.writeVarint(ne);var me=typeof Y;me!=="string"&&me!=="boolean"&&me!=="number"&&(Y=JSON.stringify(Y));var Me=me+":"+Y,ye=te[Me];ye===void 0&&(Z.push(Y),te[Me]=ye=Z.length-1),I.writeVarint(ye)}}}function lo(U,I){return(I<<3)+(7&U)}function bn(U){return U<<1^U>>31}function Ko(U,I){for(var C=U.loadGeometry(),R=U.type,Z=0,W=0,te=C.length,ee=0;ee<te;ee++){var Y=C[ee],ne=1;R===1&&(ne=Y.length),I.writeVarint(lo(1,ne));for(var me=R===3?Y.length-1:Y.length,Me=0;Me<me;Me++){Me===1&&R!==1&&I.writeVarint(lo(2,me-1));var ye=Y[Me].x-Z,Ge=Y[Me].y-W;I.writeVarint(bn(ye)),I.writeVarint(bn(Ge)),Z+=ye,W+=Ge}R===3&&I.writeVarint(lo(7,1))}}function Jo(U,I){var C=typeof U;C==="string"?I.writeStringField(1,U):C==="boolean"?I.writeBooleanField(7,U):C==="number"&&(U%1!=0?I.writeDoubleField(3,U):U<0?I.writeSVarintField(6,U):I.writeVarintField(5,U))}function Zr(U,I,C,R,Z,W){if(Z-R<=C)return;let te=R+Z>>1;wn(U,I,te,R,Z,W%2),Zr(U,I,C,R,te-1,W+1),Zr(U,I,C,te+1,Z,W+1)}function wn(U,I,C,R,Z,W){for(;Z>R;){if(Z-R>600){let ne=Z-R+1,me=C-R+1,Me=Math.log(ne),ye=.5*Math.exp(2*Me/3),Ge=.5*Math.sqrt(Me*ye*(ne-ye)/ne)*(me-ne/2<0?-1:1);wn(U,I,C,Math.max(R,Math.floor(C-me*ye/ne+Ge)),Math.min(Z,Math.floor(C+(ne-me)*ye/ne+Ge)),W)}let te=I[2*C+W],ee=R,Y=Z;for(Ki(U,I,R,C),I[2*Z+W]>te&&Ki(U,I,R,Z);ee<Y;){for(Ki(U,I,ee,Y),ee++,Y--;I[2*ee+W]<te;)ee++;for(;I[2*Y+W]>te;)Y--}I[2*R+W]===te?Ki(U,I,R,Y):(Y++,Ki(U,I,Y,Z)),Y<=C&&(R=Y+1),C<=Y&&(Z=Y-1)}}function Ki(U,I,C,R){_r(U,C,R),_r(I,2*C,2*R),_r(I,2*C+1,2*R+1)}function _r(U,I,C){let R=U[I];U[I]=U[C],U[C]=R}function co(U,I,C,R){let Z=U-C,W=I-R;return Z*Z+W*W}at.fromVectorTileJs=Yi,at.fromGeojsonVt=function(U,I){I=I||{};var C={};for(var R in U)C[R]=new Nr(U[R].features,I),C[R].name=R,C[R].version=I.version,C[R].extent=I.extent;return Yi({layers:C})},at.GeoJSONWrapper=so;let wi=U=>U[0],Qo=U=>U[1];class bt{constructor(I,C=wi,R=Qo,Z=64,W=Float64Array){this.nodeSize=Z,this.points=I;let te=I.length<65536?Uint16Array:Uint32Array,ee=this.ids=new te(I.length),Y=this.coords=new W(2*I.length);for(let ne=0;ne<I.length;ne++)ee[ne]=ne,Y[2*ne]=C(I[ne]),Y[2*ne+1]=R(I[ne]);Zr(ee,Y,Z,0,ee.length-1,0)}range(I,C,R,Z){return function(W,te,ee,Y,ne,me,Me){let ye=[0,W.length-1,0],Ge=[],Oe,Ue;for(;ye.length;){let $e=ye.pop(),oe=ye.pop(),pt=ye.pop();if(oe-pt<=Me){for(let dt=pt;dt<=oe;dt++)Oe=te[2*dt],Ue=te[2*dt+1],Oe>=ee&&Oe<=ne&&Ue>=Y&&Ue<=me&&Ge.push(W[dt]);continue}let Be=Math.floor((pt+oe)/2);Oe=te[2*Be],Ue=te[2*Be+1],Oe>=ee&&Oe<=ne&&Ue>=Y&&Ue<=me&&Ge.push(W[Be]);let ct=($e+1)%2;($e===0?ee<=Oe:Y<=Ue)&&(ye.push(pt),ye.push(Be-1),ye.push(ct)),($e===0?ne>=Oe:me>=Ue)&&(ye.push(Be+1),ye.push(oe),ye.push(ct))}return Ge}(this.ids,this.coords,I,C,R,Z,this.nodeSize)}within(I,C,R){return function(Z,W,te,ee,Y,ne){let me=[0,Z.length-1,0],Me=[],ye=Y*Y;for(;me.length;){let Ge=me.pop(),Oe=me.pop(),Ue=me.pop();if(Oe-Ue<=ne){for(let ct=Ue;ct<=Oe;ct++)co(W[2*ct],W[2*ct+1],te,ee)<=ye&&Me.push(Z[ct]);continue}let $e=Math.floor((Ue+Oe)/2),oe=W[2*$e],pt=W[2*$e+1];co(oe,pt,te,ee)<=ye&&Me.push(Z[$e]);let Be=(Ge+1)%2;(Ge===0?te-Y<=oe:ee-Y<=pt)&&(me.push(Ue),me.push($e-1),me.push(Be)),(Ge===0?te+Y>=oe:ee+Y>=pt)&&(me.push($e+1),me.push(Oe),me.push(Be))}return Me}(this.ids,this.coords,I,C,R,this.nodeSize)}}let Yt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:U=>U},gr=Math.fround||(Fi=new Float32Array(1),U=>(Fi[0]=+U,Fi[0]));var Fi;class Tn{constructor(I){this.options=ni(Object.create(Yt),I),this.trees=new Array(this.options.maxZoom+1)}load(I){let{log:C,minZoom:R,maxZoom:Z,nodeSize:W}=this.options;C&&console.time("total time");let te=`prepare ${I.length} points`;C&&console.time(te),this.points=I;let ee=[];for(let Y=0;Y<I.length;Y++)I[Y].geometry&&ee.push(ho(I[Y],Y));this.trees[Z+1]=new bt(ee,qr,ut,W,Float32Array),C&&console.timeEnd(te);for(let Y=Z;Y>=R;Y--){let ne=+Date.now();ee=this._cluster(ee,Y),this.trees[Y]=new bt(ee,qr,ut,W,Float32Array),C&&console.log("z%d: %d clusters in %dms",Y,ee.length,+Date.now()-ne)}return C&&console.timeEnd("total time"),this}getClusters(I,C){let R=((I[0]+180)%360+360)%360-180,Z=Math.max(-90,Math.min(90,I[1])),W=I[2]===180?180:((I[2]+180)%360+360)%360-180,te=Math.max(-90,Math.min(90,I[3]));if(I[2]-I[0]>=360)R=-180,W=180;else if(R>W){let me=this.getClusters([R,Z,180,te],C),Me=this.getClusters([-180,Z,W,te],C);return me.concat(Me)}let ee=this.trees[this._limitZoom(C)],Y=ee.range(ot(R),xr(te),ot(W),xr(Z)),ne=[];for(let me of Y){let Me=ee.points[me];ne.push(Me.numPoints?$r(Me):this.points[Me.index])}return ne}getChildren(I){let C=this._getOriginId(I),R=this._getOriginZoom(I),Z="No cluster with the specified id.",W=this.trees[R];if(!W)throw new Error(Z);let te=W.points[C];if(!te)throw new Error(Z);let ee=this.options.radius/(this.options.extent*Math.pow(2,R-1)),Y=W.within(te.x,te.y,ee),ne=[];for(let me of Y){let Me=W.points[me];Me.parentId===I&&ne.push(Me.numPoints?$r(Me):this.points[Me.index])}if(ne.length===0)throw new Error(Z);return ne}getLeaves(I,C,R){let Z=[];return this._appendLeaves(Z,I,C=C||10,R=R||0,0),Z}getTile(I,C,R){let Z=this.trees[this._limitZoom(I)],W=Math.pow(2,I),{extent:te,radius:ee}=this.options,Y=ee/te,ne=(R-Y)/W,me=(R+1+Y)/W,Me={features:[]};return this._addTileFeatures(Z.range((C-Y)/W,ne,(C+1+Y)/W,me),Z.points,C,R,W,Me),C===0&&this._addTileFeatures(Z.range(1-Y/W,ne,1,me),Z.points,W,R,W,Me),C===W-1&&this._addTileFeatures(Z.range(0,ne,Y/W,me),Z.points,-1,R,W,Me),Me.features.length?Me:null}getClusterExpansionZoom(I){let C=this._getOriginZoom(I)-1;for(;C<=this.options.maxZoom;){let R=this.getChildren(I);if(C++,R.length!==1)break;I=R[0].properties.cluster_id}return C}_appendLeaves(I,C,R,Z,W){let te=this.getChildren(C);for(let ee of te){let Y=ee.properties;if(Y&&Y.cluster?W+Y.point_count<=Z?W+=Y.point_count:W=this._appendLeaves(I,Y.cluster_id,R,Z,W):W<Z?W++:I.push(ee),I.length===R)break}return W}_addTileFeatures(I,C,R,Z,W,te){for(let ee of I){let Y=C[ee],ne=Y.numPoints,me,Me,ye;if(ne)me=Ji(Y),Me=Y.x,ye=Y.y;else{let Ue=this.points[Y.index];me=Ue.properties,Me=ot(Ue.geometry.coordinates[0]),ye=xr(Ue.geometry.coordinates[1])}let Ge={type:1,geometry:[[Math.round(this.options.extent*(Me*W-R)),Math.round(this.options.extent*(ye*W-Z))]],tags:me},Oe;ne?Oe=Y.id:this.options.generateId?Oe=Y.index:this.points[Y.index].id&&(Oe=this.points[Y.index].id),Oe!==void 0&&(Ge.id=Oe),te.features.push(Ge)}}_limitZoom(I){return Math.max(this.options.minZoom,Math.min(+I,this.options.maxZoom+1))}_cluster(I,C){let R=[],{radius:Z,extent:W,reduce:te,minPoints:ee}=this.options,Y=Z/(W*Math.pow(2,C));for(let ne=0;ne<I.length;ne++){let me=I[ne];if(me.zoom<=C)continue;me.zoom=C;let Me=this.trees[C+1],ye=Me.within(me.x,me.y,Y),Ge=me.numPoints||1,Oe=Ge;for(let Ue of ye){let $e=Me.points[Ue];$e.zoom>C&&(Oe+=$e.numPoints||1)}if(Oe>Ge&&Oe>=ee){let Ue=me.x*Ge,$e=me.y*Ge,oe=te&&Ge>1?this._map(me,!0):null,pt=(ne<<5)+(C+1)+this.points.length;for(let Be of ye){let ct=Me.points[Be];if(ct.zoom<=C)continue;ct.zoom=C;let dt=ct.numPoints||1;Ue+=ct.x*dt,$e+=ct.y*dt,ct.parentId=pt,te&&(oe||(oe=this._map(me,!0)),te(oe,this._map(ct)))}me.parentId=pt,R.push(yr(Ue/Oe,$e/Oe,pt,Oe,oe))}else if(R.push(me),Oe>1)for(let Ue of ye){let $e=Me.points[Ue];$e.zoom<=C||($e.zoom=C,R.push($e))}}return R}_getOriginId(I){return I-this.points.length>>5}_getOriginZoom(I){return(I-this.points.length)%32}_map(I,C){if(I.numPoints)return C?ni({},I.properties):I.properties;let R=this.points[I.index].properties,Z=this.options.map(R);return C&&Z===R?ni({},Z):Z}}function yr(U,I,C,R,Z){return{x:gr(U),y:gr(I),zoom:1/0,id:C,parentId:-1,numPoints:R,properties:Z}}function ho(U,I){let[C,R]=U.geometry.coordinates;return{x:gr(ot(C)),y:gr(xr(R)),zoom:1/0,index:I,parentId:-1}}function $r(U){return{type:"Feature",id:U.id,properties:Ji(U),geometry:{type:"Point",coordinates:[(I=U.x,360*(I-.5)),es(U.y)]}};var I}function Ji(U){let I=U.numPoints,C=I>=1e4?`${Math.round(I/1e3)}k`:I>=1e3?Math.round(I/100)/10+"k":I;return ni(ni({},U.properties),{cluster:!0,cluster_id:U.id,point_count:I,point_count_abbreviated:C})}function ot(U){return U/360+.5}function xr(U){let I=Math.sin(U*Math.PI/180),C=.5-.25*Math.log((1+I)/(1-I))/Math.PI;return C<0?0:C>1?1:C}function es(U){let I=(180-360*U)*Math.PI/180;return 360*Math.atan(Math.exp(I))/Math.PI-90}function ni(U,I){for(let C in I)U[C]=I[C];return U}function qr(U){return U.x}function ut(U){return U.y}function vr(U,I,C,R){for(var Z,W=R,te=C-I>>1,ee=C-I,Y=U[I],ne=U[I+1],me=U[C],Me=U[C+1],ye=I+3;ye<C;ye+=3){var Ge=Xr(U[ye],U[ye+1],Y,ne,me,Me);if(Ge>W)Z=ye,W=Ge;else if(Ge===W){var Oe=Math.abs(ye-te);Oe<ee&&(Z=ye,ee=Oe)}}W>R&&(Z-I>3&&vr(U,I,Z,R),U[Z+2]=W,C-Z>3&&vr(U,Z,C,R))}function Xr(U,I,C,R,Z,W){var te=Z-C,ee=W-R;if(te!==0||ee!==0){var Y=((U-C)*te+(I-R)*ee)/(te*te+ee*ee);Y>1?(C=Z,R=W):Y>0&&(C+=te*Y,R+=ee*Y)}return(te=U-C)*te+(ee=I-R)*ee}function Ti(U,I,C,R){var Z={id:U===void 0?null:U,type:I,geometry:C,tags:R,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(W){var te=W.geometry,ee=W.type;if(ee==="Point"||ee==="MultiPoint"||ee==="LineString")Wr(W,te);else if(ee==="Polygon"||ee==="MultiLineString")for(var Y=0;Y<te.length;Y++)Wr(W,te[Y]);else if(ee==="MultiPolygon")for(Y=0;Y<te.length;Y++)for(var ne=0;ne<te[Y].length;ne++)Wr(W,te[Y][ne])}(Z),Z}function Wr(U,I){for(var C=0;C<I.length;C+=3)U.minX=Math.min(U.minX,I[C]),U.minY=Math.min(U.minY,I[C+1]),U.maxX=Math.max(U.maxX,I[C]),U.maxY=Math.max(U.maxY,I[C+1])}function En(U,I,C,R){if(I.geometry){var Z=I.geometry.coordinates,W=I.geometry.type,te=Math.pow(C.tolerance/((1<<C.maxZoom)*C.extent),2),ee=[],Y=I.id;if(C.promoteId?Y=I.properties[C.promoteId]:C.generateId&&(Y=R||0),W==="Point")uo(Z,ee);else if(W==="MultiPoint")for(var ne=0;ne<Z.length;ne++)uo(Z[ne],ee);else if(W==="LineString")Sn(Z,ee,te,!1);else if(W==="MultiLineString"){if(C.lineMetrics){for(ne=0;ne<Z.length;ne++)Sn(Z[ne],ee=[],te,!1),U.push(Ti(Y,"LineString",ee,I.properties));return}Hr(Z,ee,te,!1)}else if(W==="Polygon")Hr(Z,ee,te,!0);else{if(W!=="MultiPolygon"){if(W==="GeometryCollection"){for(ne=0;ne<I.geometry.geometries.length;ne++)En(U,{id:Y,geometry:I.geometry.geometries[ne],properties:I.properties},C,R);return}throw new Error("Input data is not a valid GeoJSON object.")}for(ne=0;ne<Z.length;ne++){var me=[];Hr(Z[ne],me,te,!0),ee.push(me)}}U.push(Ti(Y,W,ee,I.properties))}}function uo(U,I){I.push(Oi(U[0])),I.push(Yr(U[1])),I.push(0)}function Sn(U,I,C,R){for(var Z,W,te=0,ee=0;ee<U.length;ee++){var Y=Oi(U[ee][0]),ne=Yr(U[ee][1]);I.push(Y),I.push(ne),I.push(0),ee>0&&(te+=R?(Z*ne-Y*W)/2:Math.sqrt(Math.pow(Y-Z,2)+Math.pow(ne-W,2))),Z=Y,W=ne}var me=I.length-3;I[2]=1,vr(I,0,me,C),I[me+2]=1,I.size=Math.abs(te),I.start=0,I.end=I.size}function Hr(U,I,C,R){for(var Z=0;Z<U.length;Z++){var W=[];Sn(U[Z],W,C,R),I.push(W)}}function Oi(U){return U/360+.5}function Yr(U){var I=Math.sin(U*Math.PI/180),C=.5-.25*Math.log((1+I)/(1-I))/Math.PI;return C<0?0:C>1?1:C}function Ui(U,I,C,R,Z,W,te,ee){if(R/=I,W>=(C/=I)&&te<R)return U;if(te<C||W>=R)return null;for(var Y=[],ne=0;ne<U.length;ne++){var me=U[ne],Me=me.geometry,ye=me.type,Ge=Z===0?me.minX:me.minY,Oe=Z===0?me.maxX:me.maxY;if(Ge>=C&&Oe<R)Y.push(me);else if(!(Oe<C||Ge>=R)){var Ue=[];if(ye==="Point"||ye==="MultiPoint")Vi(Me,Ue,C,R,Z);else if(ye==="LineString")br(Me,Ue,C,R,Z,!1,ee.lineMetrics);else if(ye==="MultiLineString")Kr(Me,Ue,C,R,Z,!1);else if(ye==="Polygon")Kr(Me,Ue,C,R,Z,!0);else if(ye==="MultiPolygon")for(var $e=0;$e<Me.length;$e++){var oe=[];Kr(Me[$e],oe,C,R,Z,!0),oe.length&&Ue.push(oe)}if(Ue.length){if(ee.lineMetrics&&ye==="LineString"){for($e=0;$e<Ue.length;$e++)Y.push(Ti(me.id,ye,Ue[$e],me.tags));continue}ye!=="LineString"&&ye!=="MultiLineString"||(Ue.length===1?(ye="LineString",Ue=Ue[0]):ye="MultiLineString"),ye!=="Point"&&ye!=="MultiPoint"||(ye=Ue.length===3?"Point":"MultiPoint"),Y.push(Ti(me.id,ye,Ue,me.tags))}}}return Y.length?Y:null}function Vi(U,I,C,R,Z){for(var W=0;W<U.length;W+=3){var te=U[W+Z];te>=C&&te<=R&&(I.push(U[W]),I.push(U[W+1]),I.push(U[W+2]))}}function br(U,I,C,R,Z,W,te){for(var ee,Y,ne=po(U),me=Z===0?ia:ts,Me=U.start,ye=0;ye<U.length-3;ye+=3){var Ge=U[ye],Oe=U[ye+1],Ue=U[ye+2],$e=U[ye+3],oe=U[ye+4],pt=Z===0?Ge:Oe,Be=Z===0?$e:oe,ct=!1;te&&(ee=Math.sqrt(Math.pow(Ge-$e,2)+Math.pow(Oe-oe,2))),pt<C?Be>C&&(Y=me(ne,Ge,Oe,$e,oe,C),te&&(ne.start=Me+ee*Y)):pt>R?Be<R&&(Y=me(ne,Ge,Oe,$e,oe,R),te&&(ne.start=Me+ee*Y)):In(ne,Ge,Oe,Ue),Be<C&&pt>=C&&(Y=me(ne,Ge,Oe,$e,oe,C),ct=!0),Be>R&&pt<=R&&(Y=me(ne,Ge,Oe,$e,oe,R),ct=!0),!W&&ct&&(te&&(ne.end=Me+ee*Y),I.push(ne),ne=po(U)),te&&(Me+=ee)}var dt=U.length-3;Ge=U[dt],Oe=U[dt+1],Ue=U[dt+2],(pt=Z===0?Ge:Oe)>=C&&pt<=R&&In(ne,Ge,Oe,Ue),dt=ne.length-3,W&&dt>=3&&(ne[dt]!==ne[0]||ne[dt+1]!==ne[1])&&In(ne,ne[0],ne[1],ne[2]),ne.length&&I.push(ne)}function po(U){var I=[];return I.size=U.size,I.start=U.start,I.end=U.end,I}function Kr(U,I,C,R,Z,W){for(var te=0;te<U.length;te++)br(U[te],I,C,R,Z,W,!1)}function In(U,I,C,R){U.push(I),U.push(C),U.push(R)}function ia(U,I,C,R,Z,W){var te=(W-I)/(R-I);return U.push(W),U.push(C+(Z-C)*te),U.push(1),te}function ts(U,I,C,R,Z,W){var te=(W-C)/(Z-C);return U.push(I+(R-I)*te),U.push(W),U.push(1),te}function is(U,I){for(var C=[],R=0;R<U.length;R++){var Z,W=U[R],te=W.type;if(te==="Point"||te==="MultiPoint"||te==="LineString")Z=Mn(W.geometry,I);else if(te==="MultiLineString"||te==="Polygon"){Z=[];for(var ee=0;ee<W.geometry.length;ee++)Z.push(Mn(W.geometry[ee],I))}else if(te==="MultiPolygon")for(Z=[],ee=0;ee<W.geometry.length;ee++){for(var Y=[],ne=0;ne<W.geometry[ee].length;ne++)Y.push(Mn(W.geometry[ee][ne],I));Z.push(Y)}C.push(Ti(W.id,te,Z,W.tags))}return C}function Mn(U,I){var C=[];C.size=U.size,U.start!==void 0&&(C.start=U.start,C.end=U.end);for(var R=0;R<U.length;R+=3)C.push(U[R]+I,U[R+1],U[R+2]);return C}function rs(U,I){if(U.transformed)return U;var C,R,Z,W=1<<U.z,te=U.x,ee=U.y;for(C=0;C<U.features.length;C++){var Y=U.features[C],ne=Y.geometry,me=Y.type;if(Y.geometry=[],me===1)for(R=0;R<ne.length;R+=2)Y.geometry.push(Jr(ne[R],ne[R+1],I,W,te,ee));else for(R=0;R<ne.length;R++){var Me=[];for(Z=0;Z<ne[R].length;Z+=2)Me.push(Jr(ne[R][Z],ne[R][Z+1],I,W,te,ee));Y.geometry.push(Me)}}return U.transformed=!0,U}function Jr(U,I,C,R,Z,W){return[Math.round(C*(U*R-Z)),Math.round(C*(I*R-W))]}function ns(U,I,C,R,Z){for(var W=I===Z.maxZoom?0:Z.tolerance/((1<<I)*Z.extent),te={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:C,y:R,z:I,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},ee=0;ee<U.length;ee++){te.numFeatures++,ji(te,U[ee],W,Z);var Y=U[ee].minX,ne=U[ee].minY,me=U[ee].maxX,Me=U[ee].maxY;Y<te.minX&&(te.minX=Y),ne<te.minY&&(te.minY=ne),me>te.maxX&&(te.maxX=me),Me>te.maxY&&(te.maxY=Me)}return te}function ji(U,I,C,R){var Z=I.geometry,W=I.type,te=[];if(W==="Point"||W==="MultiPoint")for(var ee=0;ee<Z.length;ee+=3)te.push(Z[ee]),te.push(Z[ee+1]),U.numPoints++,U.numSimplified++;else if(W==="LineString")wr(te,Z,U,C,!1,!1);else if(W==="MultiLineString"||W==="Polygon")for(ee=0;ee<Z.length;ee++)wr(te,Z[ee],U,C,W==="Polygon",ee===0);else if(W==="MultiPolygon")for(var Y=0;Y<Z.length;Y++){var ne=Z[Y];for(ee=0;ee<ne.length;ee++)wr(te,ne[ee],U,C,!0,ee===0)}if(te.length){var me=I.tags||null;if(W==="LineString"&&R.lineMetrics){for(var Me in me={},I.tags)me[Me]=I.tags[Me];me.mapbox_clip_start=Z.start/Z.size,me.mapbox_clip_end=Z.end/Z.size}var ye={geometry:te,type:W==="Polygon"||W==="MultiPolygon"?3:W==="LineString"||W==="MultiLineString"?2:1,tags:me};I.id!==null&&(ye.id=I.id),U.features.push(ye)}}function wr(U,I,C,R,Z,W){var te=R*R;if(R>0&&I.size<(Z?te:R))C.numPoints+=I.length/3;else{for(var ee=[],Y=0;Y<I.length;Y+=3)(R===0||I[Y+2]>te)&&(C.numSimplified++,ee.push(I[Y]),ee.push(I[Y+1])),C.numPoints++;Z&&function(ne,me){for(var Me=0,ye=0,Ge=ne.length,Oe=Ge-2;ye<Ge;Oe=ye,ye+=2)Me+=(ne[ye]-ne[Oe])*(ne[ye+1]+ne[Oe+1]);if(Me>0===me)for(ye=0,Ge=ne.length;ye<Ge/2;ye+=2){var Ue=ne[ye],$e=ne[ye+1];ne[ye]=ne[Ge-2-ye],ne[ye+1]=ne[Ge-1-ye],ne[Ge-2-ye]=Ue,ne[Ge-1-ye]=$e}}(ee,W),U.push(ee)}}function Qr(U,I){var C=(I=this.options=function(Z,W){for(var te in W)Z[te]=W[te];return Z}(Object.create(this.options),I)).debug;if(C&&console.time("preprocess data"),I.maxZoom<0||I.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(I.promoteId&&I.generateId)throw new Error("promoteId and generateId cannot be used together.");var R=function(Z,W){var te=[];if(Z.type==="FeatureCollection")for(var ee=0;ee<Z.features.length;ee++)En(te,Z.features[ee],W,ee);else En(te,Z.type==="Feature"?Z:{geometry:Z},W);return te}(U,I);this.tiles={},this.tileCoords=[],C&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",I.indexMaxZoom,I.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(R=function(Z,W){var te=W.buffer/W.extent,ee=Z,Y=Ui(Z,1,-1-te,te,0,-1,2,W),ne=Ui(Z,1,1-te,2+te,0,-1,2,W);return(Y||ne)&&(ee=Ui(Z,1,-te,1+te,0,-1,2,W)||[],Y&&(ee=is(Y,1).concat(ee)),ne&&(ee=ee.concat(is(ne,-1)))),ee}(R,I)).length&&this.splitTile(R,0,0,0),C&&(R.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 en(U,I,C){return 32*((1<<U)*C+I)+U}function An(U,I){let C=U.tileID.canonical;if(!this._geoJSONIndex)return I(null,null);let R=this._geoJSONIndex.getTile(C.z,C.x,C.y);if(!R)return I(null,null);let Z=new ri(R.features),W=at(Z);W.byteOffset===0&&W.byteLength===W.buffer.byteLength||(W=new Uint8Array(W)),I(null,{vectorTile:Z,rawData:W.buffer})}Qr.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Qr.prototype.splitTile=function(U,I,C,R,Z,W,te){for(var ee=[U,I,C,R],Y=this.options,ne=Y.debug;ee.length;){R=ee.pop(),C=ee.pop(),I=ee.pop(),U=ee.pop();var me=1<<I,Me=en(I,C,R),ye=this.tiles[Me];if(!ye&&(ne>1&&console.time("creation"),ye=this.tiles[Me]=ns(U,I,C,R,Y),this.tileCoords.push({z:I,x:C,y:R}),ne)){ne>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",I,C,R,ye.numFeatures,ye.numPoints,ye.numSimplified),console.timeEnd("creation"));var Ge="z"+I;this.stats[Ge]=(this.stats[Ge]||0)+1,this.total++}if(ye.source=U,Z){if(I===Y.maxZoom||I===Z)continue;var Oe=1<<Z-I;if(C!==Math.floor(W/Oe)||R!==Math.floor(te/Oe))continue}else if(I===Y.indexMaxZoom||ye.numPoints<=Y.indexMaxPoints)continue;if(ye.source=null,U.length!==0){ne>1&&console.time("clipping");var Ue,$e,oe,pt,Be,ct,dt=.5*Y.buffer/Y.extent,tn=.5-dt,nr=.5+dt,Ie=1+dt;Ue=$e=oe=pt=null,Be=Ui(U,me,C-dt,C+nr,0,ye.minX,ye.maxX,Y),ct=Ui(U,me,C+tn,C+Ie,0,ye.minX,ye.maxX,Y),U=null,Be&&(Ue=Ui(Be,me,R-dt,R+nr,1,ye.minY,ye.maxY,Y),$e=Ui(Be,me,R+tn,R+Ie,1,ye.minY,ye.maxY,Y),Be=null),ct&&(oe=Ui(ct,me,R-dt,R+nr,1,ye.minY,ye.maxY,Y),pt=Ui(ct,me,R+tn,R+Ie,1,ye.minY,ye.maxY,Y),ct=null),ne>1&&console.timeEnd("clipping"),ee.push(Ue||[],I+1,2*C,2*R),ee.push($e||[],I+1,2*C,2*R+1),ee.push(oe||[],I+1,2*C+1,2*R),ee.push(pt||[],I+1,2*C+1,2*R+1)}}},Qr.prototype.getTile=function(U,I,C){var R=this.options,Z=R.extent,W=R.debug;if(U<0||U>24)return null;var te=1<<U,ee=en(U,I=(I%te+te)%te,C);if(this.tiles[ee])return rs(this.tiles[ee],Z);W>1&&console.log("drilling down to z%d-%d-%d",U,I,C);for(var Y,ne=U,me=I,Me=C;!Y&&ne>0;)ne--,me=Math.floor(me/2),Me=Math.floor(Me/2),Y=this.tiles[en(ne,me,Me)];return Y&&Y.source?(W>1&&console.log("found parent tile z%d-%d-%d",ne,me,Me),W>1&&console.time("drilling down"),this.splitTile(Y.source,ne,me,Me,U,I,C),W>1&&console.timeEnd("drilling down"),this.tiles[ee]?rs(this.tiles[ee],Z):null):null};class fo extends a.VectorTileWorkerSource{constructor(I,C,R,Z,W){super(I,C,R,Z,An),W&&(this.loadGeoJSON=W)}loadData(I,C){let R=I&&I.request,Z=R&&R.collectResourceTiming;this.loadGeoJSON(I,(W,te)=>{if(W||!te)return C(W);if(typeof te!="object")return C(new Error(`Input data given to '${I.source}' is not a valid GeoJSON object.`));{et(te,!0);try{if(I.filter){let Y=a.createExpression(I.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Y.result==="error")throw new Error(Y.value.map(me=>`${me.key}: ${me.message}`).join(", "));let ne=te.features.filter(me=>Y.value.evaluate({zoom:0},me));te={type:"FeatureCollection",features:ne}}this._geoJSONIndex=I.cluster?new Tn(function({superclusterOptions:Y,clusterProperties:ne}){if(!ne||!Y)return Y;let me={},Me={},ye={accumulated:null,zoom:0},Ge={properties:null},Oe=Object.keys(ne);for(let Ue of Oe){let[$e,oe]=ne[Ue],pt=a.createExpression(oe),Be=a.createExpression(typeof $e=="string"?[$e,["accumulated"],["get",Ue]]:$e);me[Ue]=pt.value,Me[Ue]=Be.value}return Y.map=Ue=>{Ge.properties=Ue;let $e={};for(let oe of Oe)$e[oe]=me[oe].evaluate(ye,Ge);return $e},Y.reduce=(Ue,$e)=>{Ge.properties=$e;for(let oe of Oe)ye.accumulated=Ue[oe],Ue[oe]=Me[oe].evaluate(ye,Ge)},Y}(I)).load(te.features):function(Y,ne){return new Qr(Y,ne)}(te,I.geojsonVtOptions)}catch(Y){return C(Y)}this.loaded={};let ee={};if(Z){let Y=a.getPerformanceMeasurement(R);Y&&(ee.resourceTiming={},ee.resourceTiming[I.source]=JSON.parse(JSON.stringify(Y)))}C(null,ee)}})}reloadTile(I,C){let R=this.loaded;return R&&R[I.uid]?super.reloadTile(I,C):this.loadTile(I,C)}loadGeoJSON(I,C){if(I.request)a.getJSON(I.request,C);else{if(typeof I.data!="string")return C(new Error(`Input data given to '${I.source}' is not a valid GeoJSON object.`));try{return C(null,JSON.parse(I.data))}catch{return C(new Error(`Input data given to '${I.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(I,C){try{C(null,this._geoJSONIndex.getClusterExpansionZoom(I.clusterId))}catch(R){C(R)}}getClusterChildren(I,C){try{C(null,this._geoJSONIndex.getChildren(I.clusterId))}catch(R){C(R)}}getClusterLeaves(I,C){try{C(null,this._geoJSONIndex.getLeaves(I.clusterId,I.limit,I.offset))}catch(R){C(R)}}}class Cn{constructor(I){this.self=I,this.actor=new a.Actor(I,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:fo},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(C,R)=>{if(this.workerSourceTypes[C])throw new Error(`Worker source with name "${C}" already registered.`);this.workerSourceTypes[C]=R},this.self.registerRTLTextPlugin=C=>{if(a.plugin.isParsed())throw new Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=C.applyArabicShaping,a.plugin.processBidirectionalText=C.processBidirectionalText,a.plugin.processStyledBidirectionalText=C.processStyledBidirectionalText}}clearCaches(I,C,R){delete this.layerIndexes[I],delete this.availableImages[I],delete this.workerSources[I],delete this.demWorkerSources[I],R()}checkIfReady(I,C,R){R()}setReferrer(I,C){this.referrer=C}spriteLoaded(I,C){this.isSpriteLoaded[I]=C;for(let R in this.workerSources[I]){let Z=this.workerSources[I][R];for(let W in Z)Z[W]instanceof a.VectorTileWorkerSource&&(Z[W].isSpriteLoaded=C,Z[W].fire(new a.Event("isSpriteLoaded")))}}setImages(I,C,R){this.availableImages[I]=C;for(let Z in this.workerSources[I]){let W=this.workerSources[I][Z];for(let te in W)W[te].availableImages=C}R()}enableTerrain(I,C,R){this.terrain=C,R()}setProjection(I,C){this.projections[I]=a.getProjection(C)}setLayers(I,C,R){this.getLayerIndex(I).replace(C),R()}updateLayers(I,C,R){this.getLayerIndex(I).update(C.layers,C.removedIds),R()}loadTile(I,C,R){let Z=this.enableTerrain?a.extend({enableTerrain:this.terrain},C):C;Z.projection=this.projections[I]||this.defaultProjection,this.getWorkerSource(I,C.type,C.source).loadTile(Z,R)}loadDEMTile(I,C,R){let Z=this.enableTerrain?a.extend({buildQuadTree:this.terrain},C):C;this.getDEMWorkerSource(I,C.source).loadTile(Z,R)}reloadTile(I,C,R){let Z=this.enableTerrain?a.extend({enableTerrain:this.terrain},C):C;Z.projection=this.projections[I]||this.defaultProjection,this.getWorkerSource(I,C.type,C.source).reloadTile(Z,R)}abortTile(I,C,R){this.getWorkerSource(I,C.type,C.source).abortTile(C,R)}removeTile(I,C,R){this.getWorkerSource(I,C.type,C.source).removeTile(C,R)}removeSource(I,C,R){if(!this.workerSources[I]||!this.workerSources[I][C.type]||!this.workerSources[I][C.type][C.source])return;let Z=this.workerSources[I][C.type][C.source];delete this.workerSources[I][C.type][C.source],Z.removeSource!==void 0?Z.removeSource(C,R):R()}loadWorkerSource(I,C,R){try{this.self.importScripts(C.url),R()}catch(Z){R(Z.toString())}}syncRTLPluginState(I,C,R){try{a.plugin.setState(C);let Z=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&Z!=null){this.self.importScripts(Z);let W=a.plugin.isParsed();R(W?void 0:new Error(`RTL Text Plugin failed to import scripts from ${Z}`),W)}}catch(Z){R(Z.toString())}}getAvailableImages(I){let C=this.availableImages[I];return C||(C=[]),C}getLayerIndex(I){let C=this.layerIndexes[I];return C||(C=this.layerIndexes[I]=new ui),C}getWorkerSource(I,C,R){return this.workerSources[I]||(this.workerSources[I]={}),this.workerSources[I][C]||(this.workerSources[I][C]={}),this.workerSources[I][C][R]||(this.workerSources[I][C][R]=new this.workerSourceTypes[C]({send:(Z,W,te,ee,Y,ne)=>{this.actor.send(Z,W,te,I,Y,ne)},scheduler:this.actor.scheduler},this.getLayerIndex(I),this.getAvailableImages(I),this.isSpriteLoaded[I])),this.workerSources[I][C][R]}getDEMWorkerSource(I,C){return this.demWorkerSources[I]||(this.demWorkerSources[I]={}),this.demWorkerSources[I][C]||(this.demWorkerSources[I][C]=new _e),this.demWorkerSources[I][C]}enforceCacheSizeLimit(I,C){a.enforceCacheSizeLimit(C)}getWorkerPerformanceMetrics(I,C,R){R(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new Cn(self)),Cn}),$c(["./shared"],function(a){"use strict";var Ri=mr;function mr(l){return!function(t){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 h,d,f=new Blob([""],{type:"text/javascript"}),_=URL.createObjectURL(f);try{d=new Worker(_),h=!0}catch{h=!1}return d&&d.terminate(),URL.revokeObjectURL(_),h}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var h=document.createElement("canvas");h.width=h.height=1;var d=h.getContext("2d");if(!d)return!1;var f=d.getImageData(0,0,1,1);return f&&f.width===h.width}()?(ui[o=t&&t.failIfMajorPerformanceCaveat]===void 0&&(ui[o]=function(h){var d,f=function(_){var y=document.createElement("canvas"),b=Object.create(mr.webGLContextAttributes);return b.failIfMajorPerformanceCaveat=_,y.getContext("webgl",b)||y.getContext("experimental-webgl",b)}(h);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)),ui[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 ui={};function _e(l,t){if(Array.isArray(l)){if(!Array.isArray(t)||l.length!==t.length)return!1;for(let o=0;o<l.length;o++)if(!_e(l[o],t[o]))return!1;return!0}if(typeof l=="object"&&l!==null&&t!==null){if(typeof t!="object"||Object.keys(l).length!==Object.keys(t).length)return!1;for(let o in l)if(!_e(l[o],t[o]))return!1;return!0}return l===t}function et(l,t,o){let h=a.window.document.createElement(l);return t!==void 0&&(h.className=t),o&&o.appendChild(h),h}function Ne(l,t,o){let h=a.window.document.createElementNS("http://www.w3.org/2000/svg",l);for(let d of Object.keys(t))h.setAttributeNS(null,d,t[d]);return o&&o.appendChild(h),h}mr.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};let Wi=a.window.document&&a.window.document.documentElement.style,jr=Wi&&Wi.userSelect!==void 0?"userSelect":"WebkitUserSelect",lt;function ri(){Wi&&jr&&(lt=Wi[jr],Wi[jr]="none")}function Yo(){Wi&&jr&&(Wi[jr]=lt)}function Nr(l){l.preventDefault(),l.stopPropagation(),a.window.removeEventListener("click",Nr,!0)}function Gr(){a.window.addEventListener("click",Nr,!0),a.window.setTimeout(()=>{a.window.removeEventListener("click",Nr,!0)},0)}function Hi(l,t){let o=l.getBoundingClientRect();return Yi(l,o,t)}function at(l,t){let o=l.getBoundingClientRect(),h=[];for(let d=0;d<t.length;d++)h.push(Yi(l,o,t[d]));return h}function so(l){return a.window.InstallTrigger!==void 0&&l.button===2&&l.ctrlKey&&a.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:l.button}function Yi(l,t,o){let h=l.offsetWidth===t.width?1:l.offsetWidth/t.width;return new a.pointGeometry((o.clientX-t.left)*h,(o.clientY-t.top)*h)}function vn(l,t){var o=t[0],h=t[1],d=t[2],f=t[3],_=o*f-d*h;return _?(l[0]=f*(_=1/_),l[1]=-h*_,l[2]=-d*_,l[3]=o*_,l):null}function ao(l){let{userImage:t}=l;return!!(t&&t.render&&t.render())&&(l.data.replace(new Uint8Array(t.data.buffer)),!0)}class Gt extends a.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(let{ids:o,callback:h}of this.requestors)this._notify(o,h);this.requestors=[]}}hasImage(t){return!!this.getImage(t)}getImage(t){return this.images[t]}addImage(t,o){this._validate(t,o)&&(this.images[t]=o)}_validate(t,o){let h=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new a.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),h=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new a.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),h=!1),this._validateContent(o.content,o)||(this.fire(new a.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),h=!1),h}_validateStretch(t,o){if(!t)return!0;let h=0;for(let d of t){if(d[0]<h||d[1]<d[0]||o<d[1])return!1;h=d[1]}return!0}_validateContent(t,o){return!(t&&(t.length!==4||t[0]<0||o.data.width<t[0]||t[1]<0||o.data.height<t[1]||t[2]<0||o.data.width<t[2]||t[3]<0||o.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,o){o.version=this.images[t].version+1,this.images[t]=o,this.updatedImages[t]=!0}removeImage(t){let o=this.images[t];delete this.images[t],delete this.patterns[t],o.userImage&&o.userImage.onRemove&&o.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,o){let h=!0;if(!this.isLoaded())for(let d of t)this.images[d]||(h=!1);this.isLoaded()||h?this._notify(t,o):this.requestors.push({ids:t,callback:o})}_notify(t,o){let h={};for(let d of t){this.images[d]||this.fire(new a.Event("styleimagemissing",{id:d}));let f=this.images[d];f?h[d]={data:f.data.clone(),pixelRatio:f.pixelRatio,sdf:f.sdf,version:f.version,stretchX:f.stretchX,stretchY:f.stretchY,content:f.content,hasRenderCallback:Boolean(f.userImage&&f.userImage.render)}:a.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,h)}getPixelSize(){let{width:t,height:o}=this.atlasImage;return{width:t,height:o}}getPattern(t){let o=this.patterns[t],h=this.getImage(t);if(!h)return null;if(o&&o.position.version===h.version)return o.position;if(o)o.position.version=h.version;else{let d={w:h.data.width+2,h:h.data.height+2,x:0,y:0},f=new a.ImagePosition(d,h);this.patterns[t]={bin:d,position:f}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){let o=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.Texture(t,this.atlasImage,o.RGBA),this.atlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE)}_updatePatternAtlas(){let t=[];for(let f in this.patterns)t.push(this.patterns[f].bin);let{w:o,h}=a.potpack(t),d=this.atlasImage;d.resize({width:o||1,height:h||1});for(let f in this.patterns){let{bin:_}=this.patterns[f],y=_.x+1,b=_.y+1,T=this.images[f].data,E=T.width,M=T.height;a.RGBAImage.copy(T,d,{x:0,y:0},{x:y,y:b},{width:E,height:M}),a.RGBAImage.copy(T,d,{x:0,y:M-1},{x:y,y:b-1},{width:E,height:1}),a.RGBAImage.copy(T,d,{x:0,y:0},{x:y,y:b+M},{width:E,height:1}),a.RGBAImage.copy(T,d,{x:E-1,y:0},{x:y-1,y:b},{width:1,height:M}),a.RGBAImage.copy(T,d,{x:0,y:0},{x:y+E,y:b},{width:1,height:M})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(let o of t){if(this.callbackDispatchedThisFrame[o])continue;this.callbackDispatchedThisFrame[o]=!0;let h=this.images[o];ao(h)&&this.updateImage(o,h)}}}let lo=new a.Properties({anchor:new a.DataConstantProperty(a.spec.light.anchor),position:new class{constructor(){this.specification=a.spec.light.position}possiblyEvaluate(l,t){return function([o,h,d]){let f=a.degToRad(h+90),_=a.degToRad(d);return{x:o*Math.cos(f)*Math.sin(_),y:o*Math.sin(f)*Math.sin(_),z:o*Math.cos(_),azimuthal:h,polar:d}}(l.expression.evaluate(t))}interpolate(l,t,o){return{x:a.number(l.x,t.x,o),y:a.number(l.y,t.y,o),z:a.number(l.z,t.z,o),azimuthal:a.number(l.azimuthal,t.azimuthal,o),polar:a.number(l.polar,t.polar,o)}}},color:new a.DataConstantProperty(a.spec.light.color),intensity:new a.DataConstantProperty(a.spec.light.intensity)}),bn="-transition";class Ko extends a.Evented{constructor(t){super(),this._transitionable=new a.Transitionable(lo),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,o={}){if(!this._validate(a.validateLight,t,o))for(let h in t){let d=t[h];a.endsWith(h,bn)?this._transitionable.setTransition(h.slice(0,-bn.length),d):this._transitionable.setValue(h,d)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,o,h){return(!h||h.validate!==!1)&&a.emitValidationErrors(this,t.call(a.validateStyle,a.extend({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}let Jo=new a.Properties({source:new a.DataConstantProperty(a.spec.terrain.source),exaggeration:new a.DataConstantProperty(a.spec.terrain.exaggeration)}),Zr="-transition";class wn extends a.Evented{constructor(t,o){super(),this._transitionable=new a.Transitionable(Jo),this.set(t),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=o}get(){return this._transitionable.serialize()}set(t){for(let o in t){let h=t[o];a.endsWith(o,Zr)?this._transitionable.setTransition(o.slice(0,-Zr.length),h):this._transitionable.setValue(o,h)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}}function Ki(l,t,o,h){let d=a.smoothstep(45,65,o),[f,_]=_r(l,h),y=a.length(t),b=1-Math.min(1,Math.exp((y-f)/(_-f)*-6));return b*=b*b,b=Math.min(1,1.00747*b),b*d*l.alpha}function _r(l,t){let o=.5/Math.tan(.5*t);return[l.range[0]+o,l.range[1]+o]}let co=new a.Properties({range:new a.DataConstantProperty(a.spec.fog.range),color:new a.DataConstantProperty(a.spec.fog.color),"horizon-blend":new a.DataConstantProperty(a.spec.fog["horizon-blend"])}),wi="-transition";class Qo extends a.Evented{constructor(t,o){super(),this._transitionable=new a.Transitionable(co),this.set(t),this._transitioning=this._transitionable.untransitioned(),this._transform=o}get state(){return{range:this.properties.get("range"),horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,o={}){if(!this._validate(a.validateFog,t,o))for(let h in t){let d=t[h];a.endsWith(h,wi)?this._transitionable.setTransition(h.slice(0,-wi.length),d):this._transitionable.setValue(h,d)}}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;let o=this.properties&&this.properties.get("color")||1;return a.smoothstep(45,65,t)*o.a}getOpacityAtLatLng(t,o){return this._transform.projection.supportsFog?function(h,d,f){let _=a.MercatorCoordinate.fromLngLat(d),y=f.elevation?f.elevation.getAtPointOrZero(_):0,b=[_.x,_.y,y];return a.transformMat4(b,b,f.mercatorFogMatrix),Ki(h,b,f.pitch,f._fov)}(this.state,t,o):0}getFovAdjustedRange(t){return this._transform.projection.supportsFog?_r(this.state,t):[0,1]}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,o,h){return(!h||h.validate!==!1)&&a.emitValidationErrors(this,t.call(a.validateStyle,a.extend({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}class bt{constructor(t,o){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=a.uniqueId();let h=this.workerPool.acquire(this.id);for(let d=0;d<h.length;d++){let f=new bt.Actor(h[d],o,this.id);f.name=`Worker ${d}`,this.actors.push(f)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(t,o,h){a.asyncAll(this.actors,(d,f)=>{d.send(t,o,f)},h=h||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(t=>{t.remove()}),this.actors=[],this.workerPool.release(this.id)}}function Yt(l,t,o){return t*(a.EXTENT/(l.tileSize*Math.pow(2,o-l.tileID.overscaledZ)))}bt.Actor=a.Actor;class gr{constructor(t,o,h,d){this.screenBounds=t,this.cameraPoint=o,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=h,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(f=>d.pointCoordinate3D(f)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(t,o){let h,d;if(t instanceof a.pointGeometry||typeof t[0]=="number"){let f=a.pointGeometry.convert(t);h=[a.pointGeometry.convert(t)],d=o.isPointAboveHorizon(f)}else{let f=a.pointGeometry.convert(t[0]),_=a.pointGeometry.convert(t[1]);h=[f,_],d=a.polygonizeBounds(f,_).every(y=>o.isPointAboveHorizon(y))}return new gr(h,o.getCameraPoint(),d,o)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(t){return a.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){let o=this.screenBounds[0],h=this.screenBounds.length===1?this.screenBounds[0].add(new a.pointGeometry(1,1)):this.screenBounds[1],d=a.polygonizeBounds(o,h,0,!1);return this.cameraPoint.y>h.y&&(this.cameraPoint.x>o.x&&this.cameraPoint.x<h.x?d.splice(3,0,this.cameraPoint):this.cameraPoint.x>=h.x?d[2]=this.cameraPoint:this.cameraPoint.x<=o.x&&(d[3]=this.cameraPoint)),a.bufferConvexPolygon(d,t)}containsTile(t,o,h){let d=t.queryPadding+1,f=t.tileID.wrap,_=h?this._bufferedCameraMercator(d,o).map(P=>a.getTilePoint(t.tileTransform,P,f)):this._bufferedScreenMercator(d,o).map(P=>a.getTilePoint(t.tileTransform,P,f)),y=this.screenGeometryMercator.map(P=>a.getTileVec3(t.tileTransform,P,f)),b=y.map(P=>new a.pointGeometry(P[0],P[1])),T=o.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),E=a.getTileVec3(t.tileTransform,T,f),M=y.map(P=>{let z=a.sub(P,P,E);return a.normalize(z,z),new a.Ray(E,z)}),D=Yt(t,1,o.zoom);if(a.polygonIntersectsBox(_,0,0,a.EXTENT,a.EXTENT))return{queryGeometry:this,tilespaceGeometry:b,tilespaceRays:M,bufferedTilespaceGeometry:_,bufferedTilespaceBounds:(B=a.getBounds(_),B.min.x=a.clamp(B.min.x,0,a.EXTENT),B.min.y=a.clamp(B.min.y,0,a.EXTENT),B.max.x=a.clamp(B.max.x,0,a.EXTENT),B.max.y=a.clamp(B.max.y,0,a.EXTENT),B),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:D};var B}_bufferedScreenMercator(t,o){let h=Fi(t);if(this._screenRaycastCache[h])return this._screenRaycastCache[h];{let d=this.bufferedScreenGeometry(t).map(f=>o.pointCoordinate3D(f));return this._screenRaycastCache[h]=d,d}}_bufferedCameraMercator(t,o){let h=Fi(t);if(this._cameraRaycastCache[h])return this._cameraRaycastCache[h];{let d=this.bufferedCameraGeometry(t).map(f=>o.pointCoordinate3D(f));return this._cameraRaycastCache[h]=d,d}}}function Fi(l){return 100*l|0}function Tn(l,t,o){let h=function(d,f){if(d)return o(d);if(f){let _=a.pick(a.extend(f,l),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);f.vector_layers&&(_.vectorLayers=f.vector_layers,_.vectorLayerIds=_.vectorLayers.map(y=>y.id)),_.tiles=t.canonicalizeTileset(_,l.url),o(null,_)}};return l.url?a.getJSON(t.transformRequest(t.normalizeSourceURL(l.url),a.ResourceType.Source),h):a.exported.frame(()=>h(null,l))}class yr{constructor(t,o,h){this.bounds=a.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=o||0,this.maxzoom=h||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){let o=Math.pow(2,t.z),h=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*o),d=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*o),f=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*o),_=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*o);return t.x>=h&&t.x<f&&t.y>=d&&t.y<_}}class ho{constructor(t,o,h){this.context=t;let d=t.gl;this.buffer=d.createBuffer(),this.dynamicDraw=Boolean(h),this.context.unbindVAO(),t.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(t){let o=this.context.gl;this.context.unbindVAO(),this.bind(),o.bufferSubData(o.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let $r={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ji{constructor(t,o,h,d){this.length=o.length,this.attributes=h,this.itemSize=o.bytesPerElement,this.dynamicDraw=d,this.context=t;let f=t.gl;this.buffer=f.createBuffer(),t.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(t){let o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,o){for(let h=0;h<this.attributes.length;h++){let d=o.attributes[this.attributes[h].name];d!==void 0&&t.enableVertexAttribArray(d)}}setVertexAttribPointers(t,o,h){for(let d=0;d<this.attributes.length;d++){let f=this.attributes[d],_=o.attributes[f.name];_!==void 0&&t.vertexAttribPointer(_,f.components,t[$r[f.type]],!1,this.itemSize,f.offset+this.itemSize*(h||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class ot{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class xr extends ot{getDefault(){return a.Color.transparent}set(t){let o=this.current;(t.r!==o.r||t.g!==o.g||t.b!==o.b||t.a!==o.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class es extends ot{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class ni extends ot{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class qr extends ot{getDefault(){return[!0,!0,!0,!0]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||t[3]!==o[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class ut extends ot{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class vr extends ot{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Xr extends ot{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let o=this.current;(t.func!==o.func||t.ref!==o.ref||t.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Ti extends ot{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Wr extends ot{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=t,this.dirty=!1}}class En extends ot{getDefault(){return[0,1]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class uo extends ot{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=t,this.dirty=!1}}class Sn extends ot{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Hr extends ot{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.BLEND):o.disable(o.BLEND),this.current=t,this.dirty=!1}}class Oi extends ot{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Yr extends ot{getDefault(){return a.Color.transparent}set(t){let o=this.current;(t.r!==o.r||t.g!==o.g||t.b!==o.b||t.a!==o.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Ui extends ot{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class Vi extends ot{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=t,this.dirty=!1}}class br extends ot{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class po extends ot{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Kr extends ot{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class In extends ot{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class ia extends ot{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||t[3]!==o[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class ts extends ot{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class is extends ot{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Mn extends ot{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindTexture(o.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class rs extends ot{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Jr extends ot{getDefault(){return null}set(t){let o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ns extends ot{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class ji extends ot{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class wr extends ot{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Qr extends ot{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class en extends ot{constructor(t,o){super(t),this.context=t,this.parent=o}getDefault(){return null}}class An extends en{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class fo extends en{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Cn extends fo{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class U{constructor(t,o,h,d){this.context=t,this.width=o,this.height=h;let f=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new An(t,f),d&&(this.depthAttachment=new fo(t,f))}destroy(){let t=this.context.gl,o=this.colorAttachment.get();if(o&&t.deleteTexture(o),this.depthAttachment){let h=this.depthAttachment.get();h&&t.deleteRenderbuffer(h)}t.deleteFramebuffer(this.framebuffer)}}class I{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new xr(this),this.clearDepth=new es(this),this.clearStencil=new ni(this),this.colorMask=new qr(this),this.depthMask=new ut(this),this.stencilMask=new vr(this),this.stencilFunc=new Xr(this),this.stencilOp=new Ti(this),this.stencilTest=new Wr(this),this.depthRange=new En(this),this.depthTest=new uo(this),this.depthFunc=new Sn(this),this.blend=new Hr(this),this.blendFunc=new Oi(this),this.blendColor=new Yr(this),this.blendEquation=new Ui(this),this.cullFace=new Vi(this),this.cullFaceSide=new br(this),this.frontFace=new po(this),this.program=new Kr(this),this.activeTexture=new In(this),this.viewport=new ia(this),this.bindFramebuffer=new ts(this),this.bindRenderbuffer=new is(this),this.bindTexture=new Mn(this),this.bindVertexBuffer=new rs(this),this.bindElementBuffer=new Jr(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ns(this),this.pixelStoreUnpack=new ji(this),this.pixelStoreUnpackPremultiplyAlpha=new wr(this),this.pixelStoreUnpackFlipY=new Qr(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.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(t,o){return new ho(this,t,o)}createVertexBuffer(t,o,h){return new Ji(this,t,o,h)}createRenderbuffer(t,o,h){let d=this.gl,f=d.createRenderbuffer();return this.bindRenderbuffer.set(f),d.renderbufferStorage(d.RENDERBUFFER,t,o,h),this.bindRenderbuffer.set(null),f}createFramebuffer(t,o,h){return new U(this,t,o,h)}clear({color:t,depth:o,stencil:h}){let d=this.gl,f=0;t&&(f|=d.COLOR_BUFFER_BIT,this.clearColor.set(t),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)),h!==void 0&&(f|=d.STENCIL_BUFFER_BIT,this.clearStencil.set(h),this.stencilMask.set(255)),d.clear(f)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){_e(t.blendFunction,a.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class C extends a.Evented{constructor(t,o,h,d){super(),this.id=t,this.dispatcher=h,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=a.extend({type:"raster"},o),a.extend(this,a.pick(o,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=Tn(this._options,this.map._requestManager,(t,o)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new a.ErrorEvent(t)):o&&(a.extend(this,o),o.bounds&&(this.tileBounds=new yr(o.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(o.tiles),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,o){let h=a.exported.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),h,this.tileSize);t.request=a.getImage(this.map._requestManager.transformRequest(d,a.ResourceType.Tile),(f,_,y,b)=>(delete t.request,t.aborted?(t.state="unloaded",o(null)):f?(t.state="errored",o(f)):_?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:y,expires:b}),t.setTexture(_,this.map.painter),t.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),void o(null)):o(null)))}static loadTileData(t,o,h){t.setTexture(o,h)}static unloadTileData(t,o){t.texture&&o.saveTileTexture(t.texture)}abortTile(t,o){t.request&&(t.request.cancel(),delete t.request),o()}unloadTile(t,o){t.texture&&this.map.painter.saveTileTexture(t.texture),o()}hasTransition(){return!1}}let R;function Z(l,t,o,h,d,f,_,y){let b=[l,o,d,t,h,f,1,1,1],T=[_,y,1],E=a.adjoint([],b),[M,D,B]=a.transformMat3(T,T,a.transpose(E,E));return a.multiply(b,[M,0,0,0,D,0,0,0,B],b)}class W extends a.Evented{constructor(t,o,h,d){super(),this.id=t,this.dispatcher=h,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}load(t){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this.url=this.options.url,a.getImage(this.map._requestManager.transformRequest(this.url,a.ResourceType.Image),(o,h)=>{if(this._loaded=!0,o)this.fire(new a.ErrorEvent(o));else if(h){let{HTMLImageElement:d}=a.window;this.image=h instanceof d?a.exported.getImageData(h):h,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}})}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;let o=t.map(a.MercatorCoordinate.fromLngLat);return this.tileID=function(h){let d=1/0,f=1/0,_=-1/0,y=-1/0;for(let M of h)d=Math.min(d,M.x),f=Math.min(f,M.y),_=Math.max(_,M.x),y=Math.max(y,M.y);let b=Math.max(_-d,y-f),T=Math.max(0,Math.floor(-Math.log(b)/Math.LN2)),E=Math.pow(2,T);return new a.CanonicalTileID(T,Math.floor((d+_)/2*E),Math.floor((f+y)/2*E))}(o),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(let b in this.tiles){let T=this.tiles[b];T.state!=="loaded"&&(T.state="loaded",T.texture=this.texture)}if(this._boundsArray)return;let o=a.tileTransform(this.tileID,this.map.transform.projection),[h,d,f,_]=this.coordinates.map(b=>{let T=o.projection.project(b[0],b[1]);return a.getTilePoint(o,T)._round()});this.perspectiveTransform=function(b,T,E,M,D,B,P,z,G,F){let j=Z(0,0,b,0,0,T,b,T),N=Z(E,M,D,B,P,z,G,F);return a.multiply(N,a.adjoint(j,j),N),[N[6]/N[8]*b/a.EXTENT,N[7]/N[8]*T/a.EXTENT]}(this.width,this.height,h.x,h.y,d.x,d.y,_.x,_.y,f.x,f.y);let y=this._boundsArray=new a.StructArrayLayout4i8;y.emplaceBack(h.x,h.y,0,0),y.emplaceBack(d.x,d.y,a.EXTENT,0),y.emplaceBack(_.x,_.y,0,a.EXTENT),y.emplaceBack(f.x,f.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(y,a.boundsAttributes.members),this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let t=this.map.painter.context,o=t.gl;this.texture?this.texture.update(this.image):(this.texture=new a.Texture(t,this.image,o.RGBA),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE)),this._prepareData(t)}loadTile(t,o){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},o(null)):(t.state="errored",o(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}let te={vector:class extends a.Evented{constructor(l,t,o,h){if(super(),this.id=l,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.extend(this,a.pick(t,["url","scheme","tileSize","promoteId"])),this._options=a.extend({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(h),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=Tn(this._options,this.map._requestManager,(l,t)=>{this._tileJSONRequest=null,this._loaded=!0,l?this.fire(new a.ErrorEvent(l)):t&&(a.extend(this,t),t.bounds&&(this.tileBounds=new yr(t.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(t.tiles,this.map._requestManager._customAccessToken),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(l){return!this.tileBounds||this.tileBounds.contains(l.canonical)}onAdd(l){this.map=l,this.load()}setSourceProperty(l){this._tileJSONRequest&&this._tileJSONRequest.cancel(),l();let t=this.map.style._getSourceCaches(this.id);for(let o of t)o.clearTiles();this.load()}setTiles(l){return this.setSourceProperty(()=>{this._options.tiles=l}),this}setUrl(l){return this.setSourceProperty(()=>{this.url=l,this._options.url=l}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}loadTile(l,t){let o=this.map._requestManager.normalizeTileURL(l.tileID.canonical.url(this.tiles,this.scheme)),h={request:this.map._requestManager.transformRequest(o,a.ResourceType.Tile),data:void 0,uid:l.uid,tileID:l.tileID,tileZoom:l.tileZoom,zoom:l.tileID.overscaledZ,tileSize:this.tileSize*l.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:l.isSymbolTile};if(h.request.collectResourceTiming=this._collectResourceTiming,l.actor&&l.state!=="expired")l.state==="loading"?l.reloadCallback=t:l.request=l.actor.send("reloadTile",h,d.bind(this));else if(l.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)l.request=l.actor.send("loadTile",h,d.bind(this),void 0,!0);else{let f=a.loadVectorTile.call({deduped:this._deduped},h,(_,y)=>{_||!y?d.call(this,_):(h.data={cacheControl:y.cacheControl,expires:y.expires,rawData:y.rawData.slice(0)},l.actor&&l.actor.send("loadTile",h,d.bind(this),void 0,!0))},!0);l.request={cancel:f}}function d(f,_){return delete l.request,l.aborted?t(null):f&&f.status!==404?t(f):(_&&_.resourceTiming&&(l.resourceTiming=_.resourceTiming),this.map._refreshExpiredTiles&&_&&l.setExpiryData(_),l.loadVectorData(_,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),t(null),void(l.reloadCallback&&(this.loadTile(l,l.reloadCallback),l.reloadCallback=null)))}}abortTile(l){l.request&&(l.request.cancel(),delete l.request),l.actor&&l.actor.send("abortTile",{uid:l.uid,type:this.type,source:this.id})}unloadTile(l){l.unloadVectorData(),l.actor&&l.actor.send("removeTile",{uid:l.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:C,"raster-dem":class extends C{constructor(l,t,o,h){super(l,t,o,h),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTile(l,t){let o=this.map._requestManager.normalizeTileURL(l.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function h(d,f){d&&(l.state="errored",t(d)),f&&(l.dem=f,l.dem.onDeserialize(),l.needsHillshadePrepare=!0,l.needsDEMTextureUpload=!0,l.state="loaded",t(null))}l.request=a.getImage(this.map._requestManager.transformRequest(o,a.ResourceType.Tile),function(d,f,_,y){if(delete l.request,l.aborted)l.state="unloaded",t(null);else if(d)l.state="errored",t(d);else if(f){this.map._refreshExpiredTiles&&l.setExpiryData({cacheControl:_,expires:y});let b=a.window.ImageBitmap&&f instanceof a.window.ImageBitmap&&(R==null&&(R=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&typeof a.window.createImageBitmap=="function"),R),T=1-(f.width-a.prevPowerOfTwo(f.width))/2;T<1||l.neighboringTiles||(l.neighboringTiles=this._getNeighboringTiles(l.tileID));let E=b?f:a.exported.getImageData(f,T),M={uid:l.uid,coord:l.tileID,source:this.id,rawImageData:E,encoding:this.encoding,padding:T};l.actor&&l.state!=="expired"||(l.actor=this.dispatcher.getActor(),l.actor.send("loadDEMTile",M,h.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(l){let t=l.canonical,o=Math.pow(2,t.z),h=(t.x-1+o)%o,d=t.x===0?l.wrap-1:l.wrap,f=(t.x+1+o)%o,_=t.x+1===o?l.wrap+1:l.wrap,y={};return y[new a.OverscaledTileID(l.overscaledZ,d,t.z,h,t.y).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,_,t.z,f,t.y).key]={backfilled:!1},t.y>0&&(y[new a.OverscaledTileID(l.overscaledZ,d,t.z,h,t.y-1).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,l.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,_,t.z,f,t.y-1).key]={backfilled:!1}),t.y+1<o&&(y[new a.OverscaledTileID(l.overscaledZ,d,t.z,h,t.y+1).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,l.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,_,t.z,f,t.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 a.Evented{constructor(l,t,o,h){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(h),this._data=t.data,this._options=a.extend({},t),this._collectResourceTiming=t.collectResourceTiming,t.maxzoom!==void 0&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;let d=a.EXTENT/this.tileSize;this.workerOptions=a.extend({source:this.id,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(t.buffer!==void 0?t.buffer:128)*d,tolerance:(t.tolerance!==void 0?t.tolerance:.375)*d,extent:a.EXTENT,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:t.clusterMaxZoom!==void 0?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:a.EXTENT,radius:(t.clusterRadius!==void 0?t.clusterRadius:50)*d,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}onAdd(l){this.map=l,this.setData(this._data)}setData(l){return this._data=l,this._updateWorkerData(),this}getClusterExpansionZoom(l,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:l,source:this.id},t),this}getClusterChildren(l,t){return this.actor.send("geojson.getClusterChildren",{clusterId:l,source:this.id},t),this}getClusterLeaves(l,t,o,h){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:l,limit:t,offset:o},h),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new a.Event("dataloading",{dataType:"source"})),this._loaded=!1;let l=a.extend({},this.workerOptions),t=this._data;typeof t=="string"?(l.request=this.map._requestManager.transformRequest(a.exported.resolveURL(t),a.ResourceType.Source),l.request.collectResourceTiming=this._collectResourceTiming):l.data=JSON.stringify(t),this._pendingLoad=this.actor.send(`${this.type}.loadData`,l,(o,h)=>{if(this._loaded=!0,this._pendingLoad=null,o)this.fire(new a.ErrorEvent(o));else{let d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&h&&h.resourceTiming&&h.resourceTiming[this.id]&&(d.resourceTiming=h.resourceTiming[this.id]),this.fire(new a.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(l,t){let 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:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(h,d)=>(delete l.request,l.unloadVectorData(),l.aborted?t(null):h?t(h):(l.loadVectorData(d,this.map.painter,o==="reloadTile"),t(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 a.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends W{constructor(l,t,o,h){super(l,t,o,h),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;let l=this.options;this.urls=[];for(let t of l.urls)this.urls.push(this.map._requestManager.transformRequest(t,a.ResourceType.Source).url);a.getVideo(this.urls,(t,o)=>{this._loaded=!0,t?this.fire(new a.ErrorEvent(t)):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){let t=this.video.seekable;l<t.start(0)||l>t.end(0)?this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.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;let l=this.map.painter.context,t=l.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new a.Texture(l,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.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:W,canvas:class extends W{constructor(l,t,o,h){super(l,t,o,h),t.coordinates?Array.isArray(t.coordinates)&&t.coordinates.length===4&&!t.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(f=>typeof f!="number"))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${l}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${l}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${l}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas=="string"||t.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.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 a.ErrorEvent(new a.ValidationError(`sources.${l}`,null,'missing required property "canvas"'))),this.options=t,this.animate=t.animate===void 0||t.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof a.window.HTMLCanvasElement?this.options.canvas:a.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.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;let t=this.map.painter.context;this.texture?(l||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(t,this.canvas,t.gl.RGBA,{premultiply:!0}),this._prepareData(t)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let l of[this.canvas.width,this.canvas.height])if(isNaN(l)||l<=0)return!0;return!1}},custom:class extends a.Evented{constructor(l,t,o,h){super(),this.id=l,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=t,this.setEventedParent(h),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new a.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new a.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new yr(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.coveringTiles=this._coveringTiles.bind(this),a.extend(this,a.pick(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return a.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(l){this._map=l,this._loaded=!1,this.fire(new a.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){let{x:t,y:o,z:h}=l.canonical;return this._implementation.hasTile({x:t,y:o,z:h})}return!this.tileBounds||this.tileBounds.contains(l.canonical)}loadTile(l,t){let{x:o,y:h,z:d}=l.tileID.canonical,f=new a.window.AbortController,_=this._implementation.loadTile({x:o,y:h,z:d},{signal:f.signal});if(!_)return this.loadTileData(l,{width:this.tileSize,height:this.tileSize,data:null}),l.state="loaded",t(null);_.cancel=()=>f.abort(),l.request=_.then(function(y){return delete l.request,l.aborted?(l.state="unloaded",t(null)):y?function(b){return b instanceof a.window.ImageData||b instanceof a.window.ImageBitmap||b instanceof a.window.HTMLCanvasElement}(y)?(this.loadTileData(l,y),l.state="loaded",void t(null)):(l.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(l,{width:this.tileSize,height:this.tileSize,data:null}),l.state="loaded",t(null))}.bind(this)).catch(y=>{y.code!==20&&(l.state="errored",t(y))})}loadTileData(l,t){C.loadTileData(l,t,this._map.painter)}unloadTileData(l){C.unloadTileData(l,this._map.painter)}prepareTile(l){if(!this._implementation.prepareTile)return null;let{x:t,y:o,z:h}=l.tileID.canonical,d=this._implementation.prepareTile({x:t,y:o,z:h});return d?(this.loadTileData(l,d),l.state="loaded",d):null}unloadTile(l,t){if(this.unloadTileData(l),this._implementation.unloadTile){let{x:o,y:h,z:d}=l.tileID.canonical;this._implementation.unloadTile({x:o,y:h,z:d})}t()}abortTile(l,t){l.request&&l.request.cancel&&(l.request.cancel(),delete l.request),t()}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}))}_update(){this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"}))}}},ee=function(l,t,o,h){let d=new te[t.type](l,t,o,h);if(d.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${d.id}`);return a.bindAll(["load","abort","unload","serialize","prepare"],d),d};function Y(l,t){let o=a.identity([]);return a.scale(o,o,[.5*l.width,.5*-l.height,1]),a.translate(o,o,[1,-1,0]),a.multiply$1(o,o,l.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(o)}function ne(l,t,o,h,d,f,_,y=!1){let b=l.tilesIn(h,_,y);b.sort(Me);let T=[];for(let M of b)T.push({wrappedTileID:M.tile.tileID.wrapped().key,queryResults:M.tile.queryRenderedFeatures(t,o,l._state,M,d,f,Y(l.transform,M.tile.tileID),y)});let E=function(M){let D={},B={};for(let P of M){let z=P.queryResults,G=P.wrappedTileID,F=B[G]=B[G]||{};for(let j in z){let N=z[j],$=F[j]=F[j]||{},V=D[j]=D[j]||[];for(let X of N)$[X.featureIndex]||($[X.featureIndex]=!0,V.push(X))}}return D}(T);for(let M in E)E[M].forEach(D=>{let B=D.feature,P=B.layer;P&&P.type!=="background"&&P.type!=="sky"&&(B.source=P.source,P["source-layer"]&&(B.sourceLayer=P["source-layer"]),B.state=B.id!==void 0?l.getFeatureState(P["source-layer"],B.id):{})});return E}function me(l,t){let o=l.getRenderableIds().map(f=>l.getTileByID(f)),h=[],d={};for(let f=0;f<o.length;f++){let _=o[f],y=_.tileID.canonical.key;d[y]||(d[y]=!0,_.querySourceFeatures(h,t))}return h}function Me(l,t){let o=l.tileID,h=t.tileID;return o.overscaledZ-h.overscaledZ||o.canonical.y-h.canonical.y||o.wrap-h.wrap||o.canonical.x-h.canonical.x}function ye(){return Zn.workerClass!=null?new Zn.workerClass:new a.window.Worker(Zn.workerUrl)}let Ge="mapboxgl_preloaded_worker_pool";class Oe{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Oe.workerCount;)this.workers.push(new ye);return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach(o=>{o.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ge]}numActive(){return Object.keys(this.active).length}}let Ue;function $e(){return Ue||(Ue=new Oe),Ue}function oe(l,t){let o={};for(let h in l)h!=="ref"&&(o[h]=l[h]);return a.refProperties.forEach(h=>{h in t&&(o[h]=t[h])}),o}function pt(l){l=l.slice();let t=Object.create(null);for(let o=0;o<l.length;o++)t[l[o].id]=l[o];for(let o=0;o<l.length;o++)"ref"in l[o]&&(l[o]=oe(l[o],t[l[o].ref]));return l}Oe.workerCount=2;let Be={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 ct(l,t,o){o.push({command:Be.addSource,args:[l,t[l]]})}function dt(l,t,o){t.push({command:Be.removeSource,args:[l]}),o[l]=!0}function tn(l,t,o,h){dt(l,o,h),ct(l,t,o)}function nr(l,t,o){let h;for(h in l[o])if(l[o].hasOwnProperty(h)&&h!=="data"&&!_e(l[o][h],t[o][h]))return!1;for(h in t[o])if(t[o].hasOwnProperty(h)&&h!=="data"&&!_e(l[o][h],t[o][h]))return!1;return!0}function Ie(l,t,o,h,d,f){let _;for(_ in t=t||{},l=l||{})l.hasOwnProperty(_)&&(_e(l[_],t[_])||o.push({command:f,args:[h,_,t[_],d]}));for(_ in t)t.hasOwnProperty(_)&&!l.hasOwnProperty(_)&&(_e(l[_],t[_])||o.push({command:f,args:[h,_,t[_],d]}))}function rt(l){return l.id}function Je(l,t){return l[t.id]=t,l}class Qi{constructor(t,o){this.reset(t,o)}reset(t,o){this.points=t||[],this._distances=[0];for(let h=1;h<this.points.length;h++)this._distances[h]=this._distances[h-1]+this.points[h].dist(this.points[h-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(t){if(this.points.length===1)return this.points[0];t=a.clamp(t,0,1);let o=1,h=this._distances[o],d=t*this.paddedLength+this.padding;for(;h<d&&o<this._distances.length;)h=this._distances[++o];let f=o-1,_=this._distances[f],y=h-_,b=y>0?(d-_)/y:0;return this.points[f].mult(1-b).add(this.points[o].mult(b))}}class rn{constructor(t,o,h){let d=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(t/h),this.yCellCount=Math.ceil(o/h);for(let _=0;_<this.xCellCount*this.yCellCount;_++)d.push([]),f.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=o,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/o,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,o,h,d,f){this._forEachCell(o,h,d,f,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(o),this.bboxes.push(h),this.bboxes.push(d),this.bboxes.push(f)}insertCircle(t,o,h,d){this._forEachCell(o-d,h-d,o+d,h+d,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(o),this.circles.push(h),this.circles.push(d)}_insertBoxCell(t,o,h,d,f,_){this.boxCells[f].push(_)}_insertCircleCell(t,o,h,d,f,_){this.circleCells[f].push(_)}_query(t,o,h,d,f,_){if(h<0||t>this.width||d<0||o>this.height)return!f&&[];let y=[];if(t<=0&&o<=0&&this.width<=h&&this.height<=d){if(f)return!0;for(let b=0;b<this.boxKeys.length;b++)y.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let b=0;b<this.circleKeys.length;b++){let T=this.circles[3*b],E=this.circles[3*b+1],M=this.circles[3*b+2];y.push({key:this.circleKeys[b],x1:T-M,y1:E-M,x2:T+M,y2:E+M})}return _?y.filter(_):y}return this._forEachCell(t,o,h,d,this._queryCell,y,{hitTest:f,seenUids:{box:{},circle:{}}},_),f?y.length>0:y}_queryCircle(t,o,h,d,f){let _=t-h,y=t+h,b=o-h,T=o+h;if(y<0||_>this.width||T<0||b>this.height)return!d&&[];let E=[];return this._forEachCell(_,b,y,T,this._queryCellCircle,E,{hitTest:d,circle:{x:t,y:o,radius:h},seenUids:{box:{},circle:{}}},f),d?E.length>0:E}query(t,o,h,d,f){return this._query(t,o,h,d,!1,f)}hitTest(t,o,h,d,f){return this._query(t,o,h,d,!0,f)}hitTestCircle(t,o,h,d){return this._queryCircle(t,o,h,!0,d)}_queryCell(t,o,h,d,f,_,y,b){let T=y.seenUids,E=this.boxCells[f];if(E!==null){let D=this.bboxes;for(let B of E)if(!T.box[B]){T.box[B]=!0;let P=4*B;if(t<=D[P+2]&&o<=D[P+3]&&h>=D[P+0]&&d>=D[P+1]&&(!b||b(this.boxKeys[B]))){if(y.hitTest)return _.push(!0),!0;_.push({key:this.boxKeys[B],x1:D[P],y1:D[P+1],x2:D[P+2],y2:D[P+3]})}}}let M=this.circleCells[f];if(M!==null){let D=this.circles;for(let B of M)if(!T.circle[B]){T.circle[B]=!0;let P=3*B;if(this._circleAndRectCollide(D[P],D[P+1],D[P+2],t,o,h,d)&&(!b||b(this.circleKeys[B]))){if(y.hitTest)return _.push(!0),!0;{let z=D[P],G=D[P+1],F=D[P+2];_.push({key:this.circleKeys[B],x1:z-F,y1:G-F,x2:z+F,y2:G+F})}}}}}_queryCellCircle(t,o,h,d,f,_,y,b){let T=y.circle,E=y.seenUids,M=this.boxCells[f];if(M!==null){let B=this.bboxes;for(let P of M)if(!E.box[P]){E.box[P]=!0;let z=4*P;if(this._circleAndRectCollide(T.x,T.y,T.radius,B[z+0],B[z+1],B[z+2],B[z+3])&&(!b||b(this.boxKeys[P])))return _.push(!0),!0}}let D=this.circleCells[f];if(D!==null){let B=this.circles;for(let P of D)if(!E.circle[P]){E.circle[P]=!0;let z=3*P;if(this._circlesCollide(B[z],B[z+1],B[z+2],T.x,T.y,T.radius)&&(!b||b(this.circleKeys[P])))return _.push(!0),!0}}}_forEachCell(t,o,h,d,f,_,y,b){let T=this._convertToXCellCoord(t),E=this._convertToYCellCoord(o),M=this._convertToXCellCoord(h),D=this._convertToYCellCoord(d);for(let B=T;B<=M;B++)for(let P=E;P<=D;P++)if(f.call(this,t,o,h,d,this.xCellCount*P+B,_,y,b))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,o,h,d,f,_){let y=d-t,b=f-o,T=h+_;return T*T>y*y+b*b}_circleAndRectCollide(t,o,h,d,f,_,y){let b=(_-d)/2,T=Math.abs(t-(d+b));if(T>b+h)return!1;let E=(y-f)/2,M=Math.abs(o-(f+E));if(M>E+h)return!1;if(T<=b||M<=E)return!0;let D=T-b,B=M-E;return D*D+B*B<=h*h}}let tt=Math.tan(85*Math.PI/180);function nn(l,t,o,h,d,f){let _=a.create();if(o){if(d.projection.name==="globe")a.multiply$1(_,_,a.calculateGlobeLabelMatrix(d,t));else{let y=vn([],f);_[0]=y[0],_[1]=y[1],_[4]=y[2],_[5]=y[3]}h||a.rotateZ(_,_,d.angle)}else a.multiply$1(_,d.labelPlaneMatrix,l);return _}function zn(l,t,o,h,d,f){if(o){if(d.projection.name==="globe"){let _=nn(l,t,o,h,d,f);return a.invert(_,_),a.multiply$1(_,l,_),_}{let _=a.clone(l),y=a.identity([]);return y[0]=f[0],y[1]=f[1],y[4]=f[2],y[5]=f[3],a.multiply$1(_,_,y),h||a.rotateZ(_,_,-d.angle),_}}return d.glCoordMatrix}function ti(l,t,o=0){let h=[l.x,l.y,o,1];o?a.transformMat4$1(h,h,t):pi(h,h,t);let d=h[3];return{point:new a.pointGeometry(h[0]/d,h[1]/d),signedDistanceFromCamera:d}}function Ei(l,t){let o=[l[0],l[1],l[2],1];a.transformMat4$1(o,o,t);let h=o[3];return{point:new a.pointGeometry(o[0]/h,o[1]/h),signedDistanceFromCamera:h}}function Mt(l,t){return Math.min(.5+l/t*.5,1.5)}function qc(l,t){let o=l[0]/l[3],h=l[1]/l[3];return o>=-t[0]&&o<=t[0]&&h>=-t[1]&&h<=t[1]}function mo(l,t,o,h,d,f,_,y,b,T){let E=o.transform,M=h?l.textSizeData:l.iconSizeData,D=a.evaluateSizeForZoom(M,o.transform.zoom),B=[256/o.width*2+1,256/o.height*2+1],P=h?l.text.dynamicLayoutVertexArray:l.icon.dynamicLayoutVertexArray;P.clear();let z=l.lineVertexArray,G=h?l.text.placedSymbolArray:l.icon.placedSymbolArray,F=o.transform.width/o.transform.height,j=!1;for(let N=0;N<G.length;N++){let $=G.get(N);if($.writingMode!==a.WritingMode.vertical||j||N!==0&&G.get(N-1).writingMode===a.WritingMode.horizontal||(j=!0),($.hidden||$.writingMode===a.WritingMode.vertical)&&!j){Ut($.numGlyphs,P);continue}j=!1;let V=new a.pointGeometry($.tileAnchorX,$.tileAnchorY),X=b?b(V):[0,0,0],ie=E.projection.projectTilePoint(V.x,V.y,T.canonical),ae=[ie.x+X[0],ie.y+X[1],ie.z+X[2]],ue=[...ae,1];if(a.transformMat4$1(ue,ue,t),!qc(ue,B)){Ut($.numGlyphs,P);continue}let ce=Mt(o.transform.cameraToCenterDistance,ue[3]),we=a.evaluateSizeForFeature(M,D,$),re=_?we/ce:we*ce,Te=ti(new a.pointGeometry(ae[0],ae[1]),d,ae[2]);if(Te.signedDistanceFromCamera<=0){Ut($.numGlyphs,P);continue}let ve={},Le=_?null:b,pe=ss($,re,!1,y,t,d,f,l.glyphOffsetArray,z,P,Te.point,V,ve,F,Le,E.projection,T);j=pe.useVertical,Le&&pe.needsFlipping&&(ve={}),(pe.notEnoughRoom||j||pe.needsFlipping&&ss($,re,!0,y,t,d,f,l.glyphOffsetArray,z,P,Te.point,V,ve,F,Le,E.projection,T).notEnoughRoom)&&Ut($.numGlyphs,P)}h?l.text.dynamicLayoutVertexBuffer.updateData(P):l.icon.dynamicLayoutVertexBuffer.updateData(P)}function os(l,t,o,h,d,f,_,y,b,T,E,M,D,B,P){let z=y.glyphStartIndex+y.numGlyphs,G=y.lineStartIndex,F=y.lineStartIndex+y.lineLength,j=t.getoffsetX(y.glyphStartIndex),N=t.getoffsetX(z-1),$=Dn(l*j,o,h,d,f,_,y.segment,G,F,b,T,E,M,D,!0,B,P);if(!$)return null;let V=Dn(l*N,o,h,d,f,_,y.segment,G,F,b,T,E,M,D,!0,B,P);return V?{first:$,last:V}:null}function kn(l,t,o,h){return l.writingMode===a.WritingMode.horizontal&&Math.abs(o.y-t.y)>Math.abs(o.x-t.x)*h?{useVertical:!0}:l.writingMode===a.WritingMode.vertical?t.y<o.y?{needsFlipping:!0}:null:l.flipState!==0&&function(d,f,_){let y=(f.x-d.x)*_;return y===0||Math.abs((f.y-d.y)/y)>tt}(t,o,h)?l.flipState===1?{needsFlipping:!0}:null:t.x>o.x?{needsFlipping:!0}:null}function ss(l,t,o,h,d,f,_,y,b,T,E,M,D,B,P,z,G){let F=t/24,j=l.lineOffsetX*F,N=l.lineOffsetY*F,$;if(l.numGlyphs>1){let V=l.glyphStartIndex+l.numGlyphs,X=l.lineStartIndex,ie=l.lineStartIndex+l.lineLength,ae=os(F,y,j,N,o,E,M,l,b,f,D,P,!1,z,G);if(!ae)return{notEnoughRoom:!0};let ue=ti(ae.first.point,_).point,ce=ti(ae.last.point,_).point;if(h&&!o){let we=kn(l,ue,ce,B);if(l.flipState=we&&we.needsFlipping?1:2,we)return we}$=[ae.first];for(let we=l.glyphStartIndex+1;we<V-1;we++)$.push(Dn(F*y.getoffsetX(we),j,N,o,E,M,l.segment,X,ie,b,f,D,P,!1,!1,z,G));$.push(ae.last)}else{if(h&&!o){let X=ti(M,d).point,ie=l.lineStartIndex+l.segment+1,ae=new a.pointGeometry(b.getx(ie),b.gety(ie)),ue=ti(ae,d),ce=kn(l,X,ue.signedDistanceFromCamera>0?ue.point:ht(M,ae,X,1,d,void 0,z,G.canonical),B);if(l.flipState=ce&&ce.needsFlipping?1:2,ce)return ce}let V=Dn(F*y.getoffsetX(l.glyphStartIndex),j,N,o,E,M,l.segment,l.lineStartIndex,l.lineStartIndex+l.lineLength,b,f,D,P,!1,!1,z,G);if(!V)return{notEnoughRoom:!0};$=[V]}for(let V of $)a.addDynamicAttributes(T,V.point,V.angle);return{}}function ra(l,t,o,h,d){let f=h.projectTilePoint(l.x,l.y,t);if(!d)return ti(f,o,f.z);let _=d(l);return ti(new a.pointGeometry(f.x+_[0],f.y+_[1]),o,f.z+_[2])}function ht(l,t,o,h,d,f,_,y){let b=ra(l.add(l.sub(t)._unit()),y,d,_,f).point,T=o.sub(b);return o.add(T._mult(h/T.mag()))}function Dn(l,t,o,h,d,f,_,y,b,T,E,M,D,B,P,z,G){let F=h?l-t:l+t,j=F>0?1:-1,N=0;h&&(j*=-1,N=Math.PI),j<0&&(N+=Math.PI);let $=j>0?y+_:y+_+1,V=d,X=d,ie=0,ae=0,ue=Math.abs(F),ce=[],we=[],re=f,Te=()=>{let De=$-j;return ie===0?f:new a.pointGeometry(T.getx(De),T.gety(De))},ve=()=>ht(Te(),re,X,ue-ie+1,E,D,z,G.canonical);for(;ie+ae<=ue;){if($+=j,$<y||$>=b)return null;if(X=V,ce.push(V),B&&we.push(re||Te()),V=M[$],V===void 0){re=new a.pointGeometry(T.getx($),T.gety($));let De=ra(re,G.canonical,E,z,D);V=De.signedDistanceFromCamera>0?M[$]=De.point:ve()}else re=null;ie+=ae,ae=X.dist(V)}P&&D&&(re=re||new a.pointGeometry(T.getx($),T.gety($)),M[$]=V=M[$]===void 0?V:ve(),ae=X.dist(V));let Le=(ue-ie)/ae,pe=V.sub(X),ke=pe.mult(Le)._add(X);o&&ke._add(pe._unit()._perp()._mult(o*j));let Ve=N+Math.atan2(V.y-X.y,V.x-X.x);return ce.push(ke),B&&(re=re||new a.pointGeometry(T.getx($),T.gety($)),we.push(function(De,Pe,Ze){let Ye=1-Ze;return new a.pointGeometry(De.x*Ye+Pe.x*Ze,De.y*Ye+Pe.y*Ze)}(we.length>0?we[we.length-1]:re,re,Le))),{point:ke,angle:Ve,path:ce,tilePath:we}}let na=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ut(l,t){for(let o=0;o<l;o++){let h=t.length;t.resize(h+4),t.float32.set(na,3*h)}}function pi(l,t,o){let h=t[0],d=t[1];return l[0]=o[0]*h+o[4]*d+o[12],l[1]=o[1]*h+o[5]*d+o[13],l[3]=o[3]*h+o[7]*d+o[15],l}let Ni=100;class as{constructor(t,o,h=new rn(t.width+200,t.height+200,25),d=new rn(t.width+200,t.height+200,25)){this.transform=t,this.grid=h,this.ignoredGrid=d,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+Ni,this.screenBottomBoundary=t.height+Ni,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=o}placeCollisionBox(t,o,h,d,f,_,y){let b=o.projectedAnchorX,T=o.projectedAnchorY,E=o.projectedAnchorZ,M=o.elevation,D=o.tileID;if(M&&D){let $=this.transform.projection.upVector(D.canonical,o.tileAnchorX,o.tileAnchorY),V=this.transform.projection.upVectorScale(D.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;b+=$[0]*M*V,T+=$[1]*M*V,E+=$[2]*M*V}let B=this.projectAndGetPerspectiveRatio(_,[b,T,E],o.tileID,this.transform.projection.name==="globe"||!!M||this.transform.pitch>0),P=f*B.perspectiveRatio,z=(o.x1*t+h.x-o.padding)*P+B.point.x,G=(o.y1*t+h.y-o.padding)*P+B.point.y,F=(o.x2*t+h.x+o.padding)*P+B.point.x,j=(o.y2*t+h.y+o.padding)*P+B.point.y,N=B.perspectiveRatio<=.55||B.occluded;return!this.isInsideGrid(z,G,F,j)||!d&&this.grid.hitTest(z,G,F,j,y)||N?{box:[],offscreen:!1,occluded:B.occluded}:{box:[z,G,F,j],offscreen:this.isOffscreen(z,G,F,j),occluded:!1}}placeCollisionCircles(t,o,h,d,f,_,y,b,T,E,M,D,B,P){let z=[],G=this.transform.elevation,F=G?G.getAtTileOffsetFunc(P,this.transform.center.lat,this.transform.worldSize,this.transform.projection):ve=>[0,0,0],j=new a.pointGeometry(o.tileAnchorX,o.tileAnchorY),N=this.transform.projection.projectTilePoint(o.tileAnchorX,o.tileAnchorY,P.canonical),$=F(j),V=[N.x+$[0],N.y+$[1],N.z+$[2]],X=this.projectAndGetPerspectiveRatio(_,[V[0],V[1],V[2]],P,this.transform.projection.name==="globe"||!!G||this.transform.pitch>0),{perspectiveRatio:ie}=X,ae=(E?f/ie:f*ie)/a.ONE_EM,ue=ti(new a.pointGeometry(V[0],V[1]),y,V[2]).point,ce=X.signedDistanceFromCamera>0?os(ae,d,o.lineOffsetX*ae,o.lineOffsetY*ae,!1,ue,j,o,h,y,{},G&&!E?F:null,E&&!!G,this.transform.projection,P):null,we=!1,re=!1,Te=!0;if(ce&&!X.occluded){let ve=.5*D*ie+B,Le=new a.pointGeometry(-100,-100),pe=new a.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),ke=new Qi,Ve=ce.first,De=ce.last,Pe=[];for(let Fe=Ve.path.length-1;Fe>=1;Fe--)Pe.push(Ve.path[Fe]);for(let Fe=1;Fe<De.path.length;Fe++)Pe.push(De.path[Fe]);let Ze=2.5*ve;if(b){let Fe=Pe.map(G?(qe,st)=>{let At=F(st<Ve.path.length-1?Ve.tilePath[Ve.path.length-1-st]:De.tilePath[st-Ve.path.length+2]);return ti(qe,b,At[2])}:qe=>ti(qe,b));Pe=Fe.some(qe=>qe.signedDistanceFromCamera<=0)?[]:Fe.map(qe=>qe.point)}let Ye=[];if(Pe.length>0){let Fe=Pe[0].clone(),qe=Pe[0].clone();for(let st=1;st<Pe.length;st++)Fe.x=Math.min(Fe.x,Pe[st].x),Fe.y=Math.min(Fe.y,Pe[st].y),qe.x=Math.max(qe.x,Pe[st].x),qe.y=Math.max(qe.y,Pe[st].y);Ye=Fe.x>=Le.x&&qe.x<=pe.x&&Fe.y>=Le.y&&qe.y<=pe.y?[Pe]:qe.x<Le.x||Fe.x>pe.x||qe.y<Le.y||Fe.y>pe.y?[]:a.clipLine([Pe],Le.x,Le.y,pe.x,pe.y)}for(let Fe of Ye){ke.reset(Fe,.25*ve);let qe=0;qe=ke.length<=.5*ve?1:Math.ceil(ke.paddedLength/Ze)+1;for(let st=0;st<qe;st++){let At=st/Math.max(qe-1,1),Kt=ke.lerp(At),Jt=Kt.x+Ni,gi=Kt.y+Ni;z.push(Jt,gi,ve,0);let $i=Jt-ve,hr=gi-ve,Dr=Jt+ve,ur=gi+ve;if(Te=Te&&this.isOffscreen($i,hr,Dr,ur),re=re||this.isInsideGrid($i,hr,Dr,ur),!t&&this.grid.hitTestCircle(Jt,gi,ve,M)&&(we=!0,!T))return{circles:[],offscreen:!1,collisionDetected:we,occluded:!1}}}}return{circles:!T&&we||!re?[]:z,offscreen:Te,collisionDetected:we,occluded:X.occluded}}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let o=[],h=1/0,d=1/0,f=-1/0,_=-1/0;for(let E of t){let M=new a.pointGeometry(E.x+Ni,E.y+Ni);h=Math.min(h,M.x),d=Math.min(d,M.y),f=Math.max(f,M.x),_=Math.max(_,M.y),o.push(M)}let y=this.grid.query(h,d,f,_).concat(this.ignoredGrid.query(h,d,f,_)),b={},T={};for(let E of y){let M=E.key;if(b[M.bucketInstanceId]===void 0&&(b[M.bucketInstanceId]={}),b[M.bucketInstanceId][M.featureIndex])continue;let D=[new a.pointGeometry(E.x1,E.y1),new a.pointGeometry(E.x2,E.y1),new a.pointGeometry(E.x2,E.y2),new a.pointGeometry(E.x1,E.y2)];a.polygonIntersectsPolygon(o,D)&&(b[M.bucketInstanceId][M.featureIndex]=!0,T[M.bucketInstanceId]===void 0&&(T[M.bucketInstanceId]=[]),T[M.bucketInstanceId].push(M.featureIndex))}return T}insertCollisionBox(t,o,h,d,f){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:h,featureIndex:d,collisionGroupID:f},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,o,h,d,f){let _=o?this.ignoredGrid:this.grid,y={bucketInstanceId:h,featureIndex:d,collisionGroupID:f};for(let b=0;b<t.length;b+=4)_.insertCircle(y,t[b],t[b+1],t[b+2])}projectAndGetPerspectiveRatio(t,o,h,d){let f=[o[0],o[1],o[2],1],_=!1;return o[2]||this.transform.pitch>0?(a.transformMat4$1(f,f,t),this.fogState&&h&&(_=function(y,b,T,E,M,D){let B=D.calculateFogTileMatrix(M),P=[b,T,E];return a.transformMat4(P,P,B),Ki(y,P,D.pitch,D._fov)}(this.fogState,o[0],o[1],o[2],h.toUnwrapped(),this.transform)>.9)):pi(f,f,t),{point:new a.pointGeometry((f[0]/f[3]+1)/2*this.transform.width+Ni,(-f[1]/f[3]+1)/2*this.transform.height+Ni),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/f[3]*.5,1.5),signedDistanceFromCamera:f[3],occluded:d&&f[2]>f[3]||_}}isOffscreen(t,o,h,d){return h<Ni||t>=this.screenRightBoundary||d<Ni||o>this.screenBottomBoundary}isInsideGrid(t,o,h,d){return h>=0&&t<this.gridRightBoundary&&d>=0&&o<this.gridBottomBoundary}getViewportMatrix(){let t=a.identity([]);return a.translate(t,t,[-100,-100,0]),t}}class Bt{constructor(t,o,h,d){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?o:-o))):d&&h?1:0,this.placed=h}isHidden(){return this.opacity===0&&!this.placed}}class or{constructor(t,o,h,d,f,_=!1){this.text=new Bt(t?t.text:null,o,h,f),this.icon=new Bt(t?t.icon:null,o,d,f),this.clipped=_}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class sr{constructor(t,o,h,d=!1){this.text=t,this.icon=o,this.skipFade=h,this.clipped=d}}class Wt{constructor(){this.invProjMatrix=a.create(),this.viewportMatrix=a.create(),this.circles=[]}}class oa{constructor(t,o,h,d,f){this.bucketInstanceId=t,this.featureIndex=o,this.sourceLayerIndex=h,this.bucketIndex=d,this.tileID=f}}class Gi{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let o=++this.maxGroupID;this.collisionGroups[t]={ID:o,predicate:h=>h.collisionGroupID===o}}return this.collisionGroups[t]}}function Pn(l,t,o,h,d){let{horizontalAlign:f,verticalAlign:_}=a.getAnchorAlignment(l),y=-(f-.5)*t,b=-(_-.5)*o,T=a.evaluateVariableOffset(l,h);return new a.pointGeometry(y+T[0]*d,b+T[1]*d)}function Ln(l,t,o,h,d){let f=new a.pointGeometry(l,t);return o&&f._rotate(h?d:-d),f}class Xc{constructor(t,o,h,d,f){this.transform=t.clone(),this.collisionIndex=new as(this.transform,f),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Gi(h),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,o,h,d){let f=h.getBucket(o),_=h.latestFeatureIndex;if(!f||!_||o.id!==f.layerIds[0])return;let y=f.layers[0].layout,b=h.collisionBoxArray,T=Math.pow(2,this.transform.zoom-h.tileID.overscaledZ),E=h.tileSize/a.EXTENT,M=h.tileID.toUnwrapped(),D=this.transform.calculateProjMatrix(M),B=y.get("text-pitch-alignment")==="map",P=y.get("text-rotation-alignment")==="map";o.compileFilter();let z=o.dynamicFilter(),G=o.dynamicFilterNeedsFeature(),F=this.transform.calculatePixelsToTileUnitsMatrix(h),j=nn(D,h.tileID.canonical,B,P,this.transform,F),N=null;if(B){let X=zn(D,h.tileID.canonical,B,P,this.transform,F);N=a.multiply$1([],this.transform.labelPlaneMatrix,X)}let $=null;z&&h.latestFeatureIndex&&($={unwrappedTileID:M,dynamicFilter:z,dynamicFilterNeedsFeature:G,featureIndex:h.latestFeatureIndex}),this.retainedQueryData[f.bucketInstanceId]=new oa(f.bucketInstanceId,_,f.sourceLayerIndex,f.index,h.tileID);let V={bucket:f,layout:y,posMatrix:D,textLabelPlaneMatrix:j,labelToScreenMatrix:N,clippingData:$,scale:T,textPixelRatio:E,holdingForFade:h.holdingForFade(),collisionBoxArray:b,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(f.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(f.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(f.sourceID)};if(d)for(let X of f.sortKeyRanges){let{sortKey:ie,symbolInstanceStart:ae,symbolInstanceEnd:ue}=X;t.push({sortKey:ie,symbolInstanceStart:ae,symbolInstanceEnd:ue,parameters:V})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:f.symbolInstances.length,parameters:V})}attemptAnchorPlacement(t,o,h,d,f,_,y,b,T,E,M,D,B,P,z,G,F,j){let N=[D.textOffset0,D.textOffset1],$=Pn(t,h,d,N,f),V=this.collisionIndex.placeCollisionBox(f,o,Ln($.x,$.y,_,y,this.transform.angle),M,b,T,E.predicate);if((!G||this.collisionIndex.placeCollisionBox(P.getSymbolInstanceIconSize(j,this.transform.zoom,B),G,Ln($.x,$.y,_,y,this.transform.angle),M,b,T,E.predicate).box.length!==0)&&V.box.length>0){let X;return this.prevPlacement&&this.prevPlacement.variableOffsets[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID]&&this.prevPlacement.placements[D.crossTileID].text&&(X=this.prevPlacement.variableOffsets[D.crossTileID].anchor),this.variableOffsets[D.crossTileID]={textOffset:N,width:h,height:d,anchor:t,textScale:f,prevAnchor:X},this.markUsedJustification(P,t,D,z),P.allowVerticalPlacement&&(this.markUsedOrientation(P,z,D),this.placedOrientations[D.crossTileID]=z),{shift:$,placedGlyphBoxes:V}}}placeLayerBucketPart(t,o,h,d){let{bucket:f,layout:_,posMatrix:y,textLabelPlaneMatrix:b,labelToScreenMatrix:T,clippingData:E,textPixelRatio:M,holdingForFade:D,collisionBoxArray:B,partiallyEvaluatedTextSize:P,partiallyEvaluatedIconSize:z,collisionGroup:G}=t.parameters,F=_.get("text-optional"),j=_.get("icon-optional"),N=_.get("text-allow-overlap"),$=_.get("icon-allow-overlap"),V=_.get("text-rotation-alignment")==="map",X=_.get("text-pitch-alignment")==="map",ie=_.get("icon-text-fit")!=="none",ae=_.get("symbol-z-order")==="viewport-y",ue=N&&($||!f.hasIconData()||j),ce=$&&(N||!f.hasTextData()||F);!f.collisionArrays&&B&&f.deserializeCollisionBoxes(B),h&&d&&f.updateCollisionDebugBuffers(this.transform.zoom,B);let we=(re,Te,ve)=>{if(E){let zt={zoom:this.transform.zoom,pitch:this.transform.pitch},Dt=null;if(E.dynamicFilterNeedsFeature){let ft=this.retainedQueryData[f.bucketInstanceId];Dt=E.featureIndex.loadFeature({featureIndex:re.featureIndex,bucketIndex:ft.bucketIndex,sourceLayerIndex:ft.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,E.dynamicFilter)(zt,Dt,this.retainedQueryData[f.bucketInstanceId].tileID.canonical,new a.pointGeometry(re.tileAnchorX,re.tileAnchorY),this.transform.calculateDistanceTileData(E.unwrappedTileID)))return this.placements[re.crossTileID]=new sr(!1,!1,!1,!0),void(o[re.crossTileID]=!0)}if(o[re.crossTileID])return;if(D)return void(this.placements[re.crossTileID]=new sr(!1,!1,!1));let Le=!1,pe=!1,ke=!0,Ve=!1,De=!1,Pe=null,Ze={box:null,offscreen:null,occluded:null},Ye={box:null,offscreen:null,occluded:null},Fe=null,qe=null,st=null,At=0,Kt=0,Jt=0;ve.textFeatureIndex?At=ve.textFeatureIndex:re.useRuntimeCollisionCircles&&(At=re.featureIndex),ve.verticalTextFeatureIndex&&(Kt=ve.verticalTextFeatureIndex);let gi=zt=>{zt.tileID=this.retainedQueryData[f.bucketInstanceId].tileID,(this.transform.elevation||zt.elevation)&&(zt.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[f.bucketInstanceId].tileID,zt.tileAnchorX,zt.tileAnchorY):0)},$i=ve.textBox;if($i){gi($i);let zt=ft=>{let Rt=a.WritingMode.horizontal;if(f.allowVerticalPlacement&&!ft&&this.prevPlacement){let yi=this.prevPlacement.placedOrientations[re.crossTileID];yi&&(this.placedOrientations[re.crossTileID]=yi,Rt=yi,this.markUsedOrientation(f,Rt,re))}return Rt},Dt=(ft,Rt)=>{if(f.allowVerticalPlacement&&re.numVerticalGlyphVertices>0&&ve.verticalTextBox){for(let yi of f.writingModes)if(yi===a.WritingMode.vertical?(Ze=Rt(),Ye=Ze):Ze=ft(),Ze&&Ze.box&&Ze.box.length)break}else Ze=ft()};if(_.get("text-variable-anchor")){let ft=_.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[re.crossTileID]){let Ct=this.prevPlacement.variableOffsets[re.crossTileID];ft.indexOf(Ct.anchor)>0&&(ft=ft.filter(Mi=>Mi!==Ct.anchor),ft.unshift(Ct.anchor))}let Rt=(Ct,Mi,jo)=>{let xi=f.getSymbolInstanceTextSize(P,re,this.transform.zoom,Te),un=(Ct.x2-Ct.x1)*xi+2*Ct.padding,pc=(Ct.y2-Ct.y1)*xi+2*Ct.padding,Na=ie&&!$?Mi:null;Na&&gi(Na);let $n={box:[],offscreen:!1,occluded:!1},hh=N?2*ft.length:ft.length;for(let Pr=0;Pr<hh;++Pr){let Ga=this.attemptAnchorPlacement(ft[Pr%ft.length],Ct,un,pc,xi,V,X,M,y,G,Pr>=ft.length,re,Te,f,jo,Na,P,z);if(Ga&&($n=Ga.placedGlyphBoxes,$n&&$n.box&&$n.box.length)){Le=!0,Pe=Ga.shift;break}}return $n};Dt(()=>Rt($i,ve.iconBox,a.WritingMode.horizontal),()=>{let Ct=ve.verticalTextBox;return Ct&&gi(Ct),f.allowVerticalPlacement&&!(Ze&&Ze.box&&Ze.box.length)&&re.numVerticalGlyphVertices>0&&Ct?Rt(Ct,ve.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),Ze&&(Le=Ze.box,ke=Ze.offscreen,Ve=Ze.occluded);let yi=zt(Ze&&Ze.box);if(!Le&&this.prevPlacement){let Ct=this.prevPlacement.variableOffsets[re.crossTileID];Ct&&(this.variableOffsets[re.crossTileID]=Ct,this.markUsedJustification(f,Ct.anchor,re,yi))}}else{let ft=(Rt,yi)=>{let Ct=f.getSymbolInstanceTextSize(P,re,this.transform.zoom,Te),Mi=this.collisionIndex.placeCollisionBox(Ct,Rt,new a.pointGeometry(0,0),N,M,y,G.predicate);return Mi&&Mi.box&&Mi.box.length&&(this.markUsedOrientation(f,yi,re),this.placedOrientations[re.crossTileID]=yi),Mi};Dt(()=>ft($i,a.WritingMode.horizontal),()=>{let Rt=ve.verticalTextBox;return f.allowVerticalPlacement&&re.numVerticalGlyphVertices>0&&Rt?(gi(Rt),ft(Rt,a.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),zt(Ze&&Ze.box&&Ze.box.length)}}if(Fe=Ze,Le=Fe&&Fe.box&&Fe.box.length>0,ke=Fe&&Fe.offscreen,Ve=Fe&&Fe.occluded,re.useRuntimeCollisionCircles){let zt=f.text.placedSymbolArray.get(re.centerJustifiedTextSymbolIndex>=0?re.centerJustifiedTextSymbolIndex:re.verticalPlacedTextSymbolIndex),Dt=a.evaluateSizeForFeature(f.textSizeData,P,zt),ft=_.get("text-padding");qe=this.collisionIndex.placeCollisionCircles(N,zt,f.lineVertexArray,f.glyphOffsetArray,Dt,y,b,T,h,X,G.predicate,re.collisionCircleDiameter*Dt/a.ONE_EM,ft,this.retainedQueryData[f.bucketInstanceId].tileID),Le=N||qe.circles.length>0&&!qe.collisionDetected,ke=ke&&qe.offscreen,Ve=qe.occluded}if(ve.iconFeatureIndex&&(Jt=ve.iconFeatureIndex),ve.iconBox){let zt=Dt=>{gi(Dt);let ft=ie&&Pe?Ln(Pe.x,Pe.y,V,X,this.transform.angle):new a.pointGeometry(0,0),Rt=f.getSymbolInstanceIconSize(z,this.transform.zoom,Te);return this.collisionIndex.placeCollisionBox(Rt,Dt,ft,$,M,y,G.predicate)};Ye&&Ye.box&&Ye.box.length&&ve.verticalIconBox?(st=zt(ve.verticalIconBox),pe=st.box.length>0):(st=zt(ve.iconBox),pe=st.box.length>0),ke=ke&&st.offscreen,De=st.occluded}let hr=F||re.numHorizontalGlyphVertices===0&&re.numVerticalGlyphVertices===0,Dr=j||re.numIconVertices===0;if(hr||Dr?Dr?hr||(pe=pe&&Le):Le=pe&&Le:pe=Le=pe&&Le,Le&&Fe&&Fe.box&&this.collisionIndex.insertCollisionBox(Fe.box,_.get("text-ignore-placement"),f.bucketInstanceId,Ye&&Ye.box&&Kt?Kt:At,G.ID),pe&&st&&this.collisionIndex.insertCollisionBox(st.box,_.get("icon-ignore-placement"),f.bucketInstanceId,Jt,G.ID),qe&&(Le&&this.collisionIndex.insertCollisionCircles(qe.circles,_.get("text-ignore-placement"),f.bucketInstanceId,At,G.ID),h)){let zt=f.bucketInstanceId,Dt=this.collisionCircleArrays[zt];Dt===void 0&&(Dt=this.collisionCircleArrays[zt]=new Wt);for(let ft=0;ft<qe.circles.length;ft+=4)Dt.circles.push(qe.circles[ft+0]),Dt.circles.push(qe.circles[ft+1]),Dt.circles.push(qe.circles[ft+2]),Dt.circles.push(qe.collisionDetected?1:0)}let ur=this.transform.projection.name!=="globe";ue=ue&&(ur||!Ve),ce=ce&&(ur||!De),this.placements[re.crossTileID]=new sr(Le||ue,pe||ce,ke||f.justReloaded),o[re.crossTileID]=!0};if(ae){let re=f.getSortedSymbolIndexes(this.transform.angle);for(let Te=re.length-1;Te>=0;--Te){let ve=re[Te];we(f.symbolInstances.get(ve),ve,f.collisionArrays[ve])}}else for(let re=t.symbolInstanceStart;re<t.symbolInstanceEnd;re++)we(f.symbolInstances.get(re),re,f.collisionArrays[re]);if(h&&f.bucketInstanceId in this.collisionCircleArrays){let re=this.collisionCircleArrays[f.bucketInstanceId];a.invert(re.invProjMatrix,y),re.viewportMatrix=this.collisionIndex.getViewportMatrix()}f.justReloaded=!1}markUsedJustification(t,o,h,d){let f;f=d===a.WritingMode.vertical?h.verticalPlacedTextSymbolIndex:{left:h.leftJustifiedTextSymbolIndex,center:h.centerJustifiedTextSymbolIndex,right:h.rightJustifiedTextSymbolIndex}[a.getAnchorJustification(o)];let _=[h.leftJustifiedTextSymbolIndex,h.centerJustifiedTextSymbolIndex,h.rightJustifiedTextSymbolIndex,h.verticalPlacedTextSymbolIndex];for(let y of _)y>=0&&(t.text.placedSymbolArray.get(y).crossTileID=f>=0&&y!==f?0:h.crossTileID)}markUsedOrientation(t,o,h){let d=o===a.WritingMode.horizontal||o===a.WritingMode.horizontalOnly?o:0,f=o===a.WritingMode.vertical?o:0,_=[h.leftJustifiedTextSymbolIndex,h.centerJustifiedTextSymbolIndex,h.rightJustifiedTextSymbolIndex];for(let y of _)t.text.placedSymbolArray.get(y).placedOrientation=d;h.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(h.verticalPlacedTextSymbolIndex).placedOrientation=f)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let o=this.prevPlacement,h=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;let d=o?o.symbolFadeChange(t):1,f=o?o.opacities:{},_=o?o.variableOffsets:{},y=o?o.placedOrientations:{};for(let b in this.placements){let T=this.placements[b],E=f[b];E?(this.opacities[b]=new or(E,d,T.text,T.icon,null,T.clipped),h=h||T.text!==E.text.placed||T.icon!==E.icon.placed):(this.opacities[b]=new or(null,d,T.text,T.icon,T.skipFade,T.clipped),h=h||T.text||T.icon)}for(let b in f){let T=f[b];if(!this.opacities[b]){let E=new or(T,d,!1,!1);E.isHidden()||(this.opacities[b]=E,h=h||T.text.placed||T.icon.placed)}}for(let b in _)this.variableOffsets[b]||!this.opacities[b]||this.opacities[b].isHidden()||(this.variableOffsets[b]=_[b]);for(let b in y)this.placedOrientations[b]||!this.opacities[b]||this.opacities[b].isHidden()||(this.placedOrientations[b]=y[b]);h?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:t)}updateLayerOpacities(t,o){let h={};for(let d of o){let f=d.getBucket(t);f&&d.latestFeatureIndex&&t.id===f.layerIds[0]&&this.updateBucketOpacities(f,h,d.collisionBoxArray)}}updateBucketOpacities(t,o,h){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();let d=t.layers[0].layout,f=!!t.layers[0].dynamicFilter(),_=new or(null,0,!1,!1,!0),y=d.get("text-allow-overlap"),b=d.get("icon-allow-overlap"),T=d.get("text-variable-anchor"),E=d.get("text-rotation-alignment")==="map",M=d.get("text-pitch-alignment")==="map",D=d.get("icon-text-fit")!=="none",B=new or(null,0,y&&(b||!t.hasIconData()||d.get("icon-optional")),b&&(y||!t.hasTextData()||d.get("text-optional")),!0);!t.collisionArrays&&h&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(h);let P=(G,F,j)=>{for(let N=0;N<F/4;N++)G.opacityVertexArray.emplaceBack(j)},z=0;for(let G=0;G<t.symbolInstances.length;G++){let F=t.symbolInstances.get(G),{numHorizontalGlyphVertices:j,numVerticalGlyphVertices:N,crossTileID:$}=F,V=this.opacities[$];o[$]?V=_:V||(V=B,this.opacities[$]=V),o[$]=!0;let X=j>0||N>0,ie=F.numIconVertices>0,ae=this.placedOrientations[F.crossTileID],ue=ae===a.WritingMode.vertical,ce=ae===a.WritingMode.horizontal||ae===a.WritingMode.horizontalOnly;if(!X&&!ie||V.isHidden()||z++,X){let we=bl(V.text);P(t.text,j,ue?hs:we),P(t.text,N,ce?hs:we);let re=V.text.isHidden();[F.rightJustifiedTextSymbolIndex,F.centerJustifiedTextSymbolIndex,F.leftJustifiedTextSymbolIndex].forEach(Le=>{Le>=0&&(t.text.placedSymbolArray.get(Le).hidden=re||ue?1:0)}),F.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(F.verticalPlacedTextSymbolIndex).hidden=re||ce?1:0);let Te=this.variableOffsets[F.crossTileID];Te&&this.markUsedJustification(t,Te.anchor,F,ae);let ve=this.placedOrientations[F.crossTileID];ve&&(this.markUsedJustification(t,"left",F,ve),this.markUsedOrientation(t,ve,F))}if(ie){let we=bl(V.icon);F.placedIconSymbolIndex>=0&&(P(t.icon,F.numIconVertices,ue?hs:we),t.icon.placedSymbolArray.get(F.placedIconSymbolIndex).hidden=V.icon.isHidden()),F.verticalPlacedIconSymbolIndex>=0&&(P(t.icon,F.numVerticalIconVertices,ce?hs:we),t.icon.placedSymbolArray.get(F.verticalPlacedIconSymbolIndex).hidden=V.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let we=t.collisionArrays[G];if(we){let re=new a.pointGeometry(0,0),Te=!0;if(we.textBox||we.verticalTextBox){if(T){let Le=this.variableOffsets[$];Le?(re=Pn(Le.anchor,Le.width,Le.height,Le.textOffset,Le.textScale),E&&re._rotate(M?this.transform.angle:-this.transform.angle)):Te=!1}f&&(Te=!V.clipped),we.textBox&&Zi(t.textCollisionBox.collisionVertexArray,V.text.placed,!Te||ue,re.x,re.y),we.verticalTextBox&&Zi(t.textCollisionBox.collisionVertexArray,V.text.placed,!Te||ce,re.x,re.y)}let ve=Te&&Boolean(!ce&&we.verticalIconBox);we.iconBox&&Zi(t.iconCollisionBox.collisionVertexArray,V.icon.placed,ve,D?re.x:0,D?re.y:0),we.verticalIconBox&&Zi(t.iconCollisionBox.collisionVertexArray,V.icon.placed,!ve,D?re.x:0,D?re.y:0)}}}if(t.fullyClipped=z===0,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){let G=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=G.invProjMatrix,t.placementViewportMatrix=G.viewportMatrix,t.collisionCircleArray=G.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,o){let h=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*h>t}setStale(){this.stale=!0}}function Zi(l,t,o,h,d){l.emplaceBack(t?1:0,o?1:0,h||0,d||0),l.emplaceBack(t?1:0,o?1:0,h||0,d||0),l.emplaceBack(t?1:0,o?1:0,h||0,d||0),l.emplaceBack(t?1:0,o?1:0,h||0,d||0)}let Wc=Math.pow(2,25),vl=Math.pow(2,24),di=Math.pow(2,17),ls=Math.pow(2,16),Tr=Math.pow(2,9),sa=Math.pow(2,8),cs=Math.pow(2,1);function bl(l){if(l.opacity===0&&!l.placed)return 0;if(l.opacity===1&&l.placed)return 4294967295;let t=l.placed?1:0,o=Math.floor(127*l.opacity);return o*Wc+t*vl+o*di+t*ls+o*Tr+t*sa+o*cs+t}let hs=0;class aa{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&t.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,o,h,d,f){let _=this._bucketParts;for(;this._currentTileIndex<t.length;)if(o.getBucketParts(_,d,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,f())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,_.sort((y,b)=>y.sortKey-b.sortKey));this._currentPartIndex<_.length;){let y=_[this._currentPartIndex];if(o.placeLayerBucketPart(y,this._seenCrossTileIDs,h,y.symbolInstanceStart===0),this._currentPartIndex++,f())return!0}return!1}}class Hc{constructor(t,o,h,d,f,_,y,b){this.placement=new Xc(t,f,_,y,b),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=h,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(t,o,h){let d=a.exported.now(),f=()=>{let _=a.exported.now()-d;return!this._forceFullPlacement&&_>2};for(;this._currentPlacementIndex>=0;){let _=o[t[this._currentPlacementIndex]],y=this.placement.collisionIndex.transform.zoom;if(_.type==="symbol"&&(!_.minzoom||_.minzoom<=y)&&(!_.maxzoom||_.maxzoom>y)){if(this._inProgressLayer||(this._inProgressLayer=new aa(_)),this._inProgressLayer.continuePlacement(h[_.source],this.placement,this._showCollisionBoxes,_,f))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}let wl=512/a.EXTENT/2;class Yc{constructor(t,o,h){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=h;for(let d=0;d<o.length;d++){let f=o.get(d),_=f.key;this.indexedSymbolInstances[_]||(this.indexedSymbolInstances[_]=[]),this.indexedSymbolInstances[_].push({crossTileID:f.crossTileID,coord:this.getScaledCoordinates(f,t)})}}getScaledCoordinates(t,o){let h=wl/Math.pow(2,o.canonical.z-this.tileID.canonical.z);return{x:Math.floor((o.canonical.x*a.EXTENT+t.tileAnchorX)*h),y:Math.floor((o.canonical.y*a.EXTENT+t.tileAnchorY)*h)}}findMatches(t,o,h){let d=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z);for(let f=0;f<t.length;f++){let _=t.get(f);if(_.crossTileID)continue;let y=this.indexedSymbolInstances[_.key];if(!y)continue;let b=this.getScaledCoordinates(_,o);for(let T of y)if(Math.abs(T.coord.x-b.x)<=d&&Math.abs(T.coord.y-b.y)<=d&&!h[T.crossTileID]){h[T.crossTileID]=!0,_.crossTileID=T.crossTileID;break}}}}class Tl{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Kc{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let o=Math.round((t-this.lng)/360);if(o!==0)for(let h in this.indexes){let d=this.indexes[h],f={};for(let _ in d){let y=d[_];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+o),f[y.tileID.key]=y}this.indexes[h]=f}this.lng=t}addBucket(t,o,h){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let f=0;f<o.symbolInstances.length;f++)o.symbolInstances.get(f).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});let d=this.usedCrossTileIDs[t.overscaledZ];for(let f in this.indexes){let _=this.indexes[f];if(Number(f)>t.overscaledZ)for(let y in _){let b=_[y];b.tileID.isChildOf(t)&&b.findMatches(o.symbolInstances,t,d)}else{let y=_[t.scaledTo(Number(f)).key];y&&y.findMatches(o.symbolInstances,t,d)}}for(let f=0;f<o.symbolInstances.length;f++){let _=o.symbolInstances.get(f);_.crossTileID||(_.crossTileID=h.generate(),d[_.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Yc(t,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(t,o){for(let h in o.indexedSymbolInstances)for(let d of o.indexedSymbolInstances[h])delete this.usedCrossTileIDs[t][d.crossTileID]}removeStaleBuckets(t){let o=!1;for(let h in this.indexes){let d=this.indexes[h];for(let f in d)t[d[f].bucketInstanceId]||(this.removeBucketCrossTileIDs(h,d[f]),delete d[f],o=!0)}return o}}class us{constructor(){this.layerIndexes={},this.crossTileIDs=new Tl,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,o,h,d){let f=this.layerIndexes[t.id];f===void 0&&(f=this.layerIndexes[t.id]=new Kc);let _=!1,y={};d.name!=="globe"&&f.handleWrapJump(h);for(let b of o){let T=b.getBucket(t);T&&t.id===T.layerIds[0]&&(T.bucketInstanceId||(T.bucketInstanceId=++this.maxBucketInstanceId),f.addBucket(b.tileID,T,this.crossTileIDs)&&(_=!0),y[T.bucketInstanceId]=!0)}return f.removeStaleBuckets(y)&&(_=!0),_}pruneUnusedLayers(t){let o={};t.forEach(h=>{o[h]=!0});for(let h in this.layerIndexes)o[h]||delete this.layerIndexes[h]}}let _o=(l,t)=>a.emitValidationErrors(l,t&&t.filter(o=>o.identifier!=="source.canvas")),El=a.pick(Be,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Sl=a.pick(Be,["setCenter","setZoom","setBearing","setPitch"]),Il={version:8,layers:[],sources:{}},on={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class oi extends a.Evented{constructor(t,o={}){super(),this.map=t,this.dispatcher=new bt($e(),this),this.imageManager=new Gt,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(t._requestManager,o.localFontFamily?a.LocalGlyphMode.all:o.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,o.localFontFamily||o.localIdeographFontFamily),this.lineAtlas=new a.LineAtlas(256,512),this.crossTileSymbolIndex=new us,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new a.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",a.getReferrer());let h=this;this._rtlTextPluginCallback=oi.registerForPluginStateChange(d=>{h.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:d.pluginStatus,pluginURL:d.pluginURL},(f,_)=>{if(a.triggerPluginCompletionEvent(f),_&&_.every(y=>y))for(let y in h._sourceCaches){let b=h._sourceCaches[y],T=b.getSource().type;T!=="vector"&&T!=="geojson"||b.reload()}})}),this.on("data",d=>{if(d.dataType!=="source"||d.sourceDataType!=="metadata")return;let f=this.getSource(d.sourceId);if(f&&f.vectorLayerIds)for(let _ in this._layers){let y=this._layers[_];y.source===f.id&&this._validateLayer(y)}})}loadURL(t,o={}){this.fire(new a.Event("dataloading",{dataType:"style"}));let h=typeof o.validate=="boolean"?o.validate:!a.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,o.accessToken);let d=this.map._requestManager.transformRequest(t,a.ResourceType.Style);this._request=a.getJSON(d,(f,_)=>{this._request=null,f?this.fire(new a.ErrorEvent(f)):_&&this._load(_,h)})}loadJSON(t,o={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(t,o.validate!==!1)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(Il,!1)}_updateLayerCount(t,o){let h=o?1:-1;t.is3D()&&(this._num3DLayers+=h),t.type==="circle"&&(this._numCircleLayers+=h),t.type==="symbol"&&(this._numSymbolLayers+=h)}_load(t,o){if(o&&_o(this,a.validateStyle(t)))return;this._loaded=!0,this.stylesheet=t,this._updateMapProjection();for(let d in t.sources)this.addSource(d,t.sources[d],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);let h=pt(this.stylesheet.layers);this._order=h.map(d=>d.id),this._layers={},this._serializedLayers={};for(let d of h)d=a.createStyleLayer(d),d.setEventedParent(this,{layer:{id:d.id}}),this._layers[d.id]=d,this._serializedLayers[d.id]=d.serialize(),this._updateLayerCount(d,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Ko(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 a.Event("data",{dataType:"style"})),this.fire(new a.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}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))}_loadSprite(t){this._spriteRequest=function(o,h,d){let f,_,y,b=a.exported.devicePixelRatio>1?"@2x":"",T=a.getJSON(h.transformRequest(h.normalizeSpriteURL(o,b,".json"),a.ResourceType.SpriteJSON),(D,B)=>{T=null,y||(y=D,f=B,M())}),E=a.getImage(h.transformRequest(h.normalizeSpriteURL(o,b,".png"),a.ResourceType.SpriteImage),(D,B)=>{E=null,y||(y=D,_=B,M())});function M(){if(y)d(y);else if(f&&_){let D=a.exported.getImageData(_),B={};for(let P in f){let{width:z,height:G,x:F,y:j,sdf:N,pixelRatio:$,stretchX:V,stretchY:X,content:ie}=f[P],ae=new a.RGBAImage({width:z,height:G});a.RGBAImage.copy(D,ae,{x:F,y:j},{x:0,y:0},{width:z,height:G}),B[P]={data:ae,pixelRatio:$,sdf:N,stretchX:V,stretchY:X,content:ie}}d(null,B)}}return{cancel(){T&&(T.cancel(),T=null),E&&(E.cancel(),E=null)}}}(t,this.map._requestManager,(o,h)=>{if(this._spriteRequest=null,o)this.fire(new a.ErrorEvent(o));else if(h)for(let d in h)this.imageManager.addImage(d,h[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new a.Event("data",{dataType:"style"}))})}_validateLayer(t){let o=this.getSource(t.source);if(!o)return;let h=t.sourceLayer;h&&(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(h)===-1)&&this.fire(new a.ErrorEvent(new Error(`Source layer "${h}" does not exist on source "${o.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){let o=[];for(let h of t){let d=this._layers[h];d.type!=="custom"&&o.push(d.serialize())}return o}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(let t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&on[t.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;let o=this._changed;if(this._changed){let d=Object.keys(this._updatedLayers),f=Object.keys(this._removedLayers);(d.length||f.length)&&this._updateWorkerLayers(d,f);for(let _ in this._updatedSources){let y=this._updatedSources[_];y==="reload"?this._reloadSource(_):y==="clear"&&this._clearSource(_)}this._updateTilesForChangedImages();for(let _ in this._updatedPaintProps)this._layers[_].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}let h={};for(let d in this._sourceCaches){let f=this._sourceCaches[d];h[d]=f.used,f.used=!1}for(let d of this._order){let f=this._layers[d];if(f.recalculate(t,this._availableImages),!f.isHidden(t.zoom)){let y=this._getLayerSourceCache(f);y&&(y.used=!0)}let _=this.map.painter;if(_){let y=f.getProgramIds();if(!y)continue;let b=f.getProgramConfiguration(t.zoom);for(let T of y)_.useProgram(T,b)}}for(let d in h){let f=this._sourceCaches[d];h[d]!==f.used&&f.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:f.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),o&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){let t=Object.keys(this._changedImages);if(t.length){for(let o in this._sourceCaches)this._sourceCaches[o].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,o){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:o})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(t){if(this._checkLoaded(),_o(this,a.validateStyle(t)))return!1;(t=a.clone$1(t)).layers=pt(t.layers);let o=function(d,f){if(!d)return[{command:Be.setStyle,args:[f]}];let _=[];try{if(!_e(d.version,f.version))return[{command:Be.setStyle,args:[f]}];_e(d.center,f.center)||_.push({command:Be.setCenter,args:[f.center]}),_e(d.zoom,f.zoom)||_.push({command:Be.setZoom,args:[f.zoom]}),_e(d.bearing,f.bearing)||_.push({command:Be.setBearing,args:[f.bearing]}),_e(d.pitch,f.pitch)||_.push({command:Be.setPitch,args:[f.pitch]}),_e(d.sprite,f.sprite)||_.push({command:Be.setSprite,args:[f.sprite]}),_e(d.glyphs,f.glyphs)||_.push({command:Be.setGlyphs,args:[f.glyphs]}),_e(d.transition,f.transition)||_.push({command:Be.setTransition,args:[f.transition]}),_e(d.light,f.light)||_.push({command:Be.setLight,args:[f.light]}),_e(d.fog,f.fog)||_.push({command:Be.setFog,args:[f.fog]}),_e(d.projection,f.projection)||_.push({command:Be.setProjection,args:[f.projection]});let y={},b=[];(function(M,D,B,P){let z;for(z in D=D||{},M=M||{})M.hasOwnProperty(z)&&(D.hasOwnProperty(z)||dt(z,B,P));for(z in D)D.hasOwnProperty(z)&&(M.hasOwnProperty(z)?_e(M[z],D[z])||(M[z].type==="geojson"&&D[z].type==="geojson"&&nr(M,D,z)?B.push({command:Be.setGeoJSONSourceData,args:[z,D[z].data]}):tn(z,D,B,P)):ct(z,D,B))})(d.sources,f.sources,b,y);let T=[];d.layers&&d.layers.forEach(M=>{M.source&&y[M.source]?_.push({command:Be.removeLayer,args:[M.id]}):T.push(M)});let E=d.terrain;E&&y[E.source]&&(_.push({command:Be.setTerrain,args:[void 0]}),E=void 0),_=_.concat(b),_e(E,f.terrain)||_.push({command:Be.setTerrain,args:[f.terrain]}),function(M,D,B){D=D||[];let P=(M=M||[]).map(rt),z=D.map(rt),G=M.reduce(Je,{}),F=D.reduce(Je,{}),j=P.slice(),N=Object.create(null),$,V,X,ie,ae,ue,ce;for($=0,V=0;$<P.length;$++)X=P[$],F.hasOwnProperty(X)?V++:(B.push({command:Be.removeLayer,args:[X]}),j.splice(j.indexOf(X,V),1));for($=0,V=0;$<z.length;$++)X=z[z.length-1-$],j[j.length-1-$]!==X&&(G.hasOwnProperty(X)?(B.push({command:Be.removeLayer,args:[X]}),j.splice(j.lastIndexOf(X,j.length-V),1)):V++,ue=j[j.length-$],B.push({command:Be.addLayer,args:[F[X],ue]}),j.splice(j.length-$,0,X),N[X]=!0);for($=0;$<z.length;$++)if(X=z[$],ie=G[X],ae=F[X],!N[X]&&!_e(ie,ae))if(_e(ie.source,ae.source)&&_e(ie["source-layer"],ae["source-layer"])&&_e(ie.type,ae.type)){for(ce in Ie(ie.layout,ae.layout,B,X,null,Be.setLayoutProperty),Ie(ie.paint,ae.paint,B,X,null,Be.setPaintProperty),_e(ie.filter,ae.filter)||B.push({command:Be.setFilter,args:[X,ae.filter]}),_e(ie.minzoom,ae.minzoom)&&_e(ie.maxzoom,ae.maxzoom)||B.push({command:Be.setLayerZoomRange,args:[X,ae.minzoom,ae.maxzoom]}),ie)ie.hasOwnProperty(ce)&&ce!=="layout"&&ce!=="paint"&&ce!=="filter"&&ce!=="metadata"&&ce!=="minzoom"&&ce!=="maxzoom"&&(ce.indexOf("paint.")===0?Ie(ie[ce],ae[ce],B,X,ce.slice(6),Be.setPaintProperty):_e(ie[ce],ae[ce])||B.push({command:Be.setLayerProperty,args:[X,ce,ae[ce]]}));for(ce in ae)ae.hasOwnProperty(ce)&&!ie.hasOwnProperty(ce)&&ce!=="layout"&&ce!=="paint"&&ce!=="filter"&&ce!=="metadata"&&ce!=="minzoom"&&ce!=="maxzoom"&&(ce.indexOf("paint.")===0?Ie(ie[ce],ae[ce],B,X,ce.slice(6),Be.setPaintProperty):_e(ie[ce],ae[ce])||B.push({command:Be.setLayerProperty,args:[X,ce,ae[ce]]}))}else B.push({command:Be.removeLayer,args:[X]}),ue=j[j.lastIndexOf(X)+1],B.push({command:Be.addLayer,args:[ae,ue]})}(T,f.layers,_)}catch(y){console.warn("Unable to compute style diff:",y),_=[{command:Be.setStyle,args:[f]}]}return _}(this.serialize(),t).filter(d=>!(d.command in Sl));if(o.length===0)return!1;let h=o.filter(d=>!(d.command in El));if(h.length>0)throw new Error(`Unimplemented: ${h.map(d=>d.command).join(", ")}.`);return o.forEach(d=>{d.command!=="setTransition"&&this[d.command].apply(this,d.args)}),this.stylesheet=t,this._updateMapProjection(),!0}addImage(t,o){return this.getImage(t)?this.fire(new a.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,o),this._afterImageUpdated(t),this)}updateImage(t,o){this.imageManager.updateImage(t,o)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new a.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new a.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,o,h={}){if(this._checkLoaded(),this.getSource(t)!==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(a.validateSource,`sources.${t}`,o,null,h))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);let d=ee(t,o,this.dispatcher,this);d.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:d.serialize(),sourceId:t}));let f=_=>{let y=(_?"symbol:":"other:")+t,b=this._sourceCaches[y]=new a.SourceCache(y,d,_);(_?this._symbolSourceCaches:this._otherSourceCaches)[t]=b,b.style=this,b.onAdd(this.map)};f(!1),o.type!=="vector"&&o.type!=="geojson"||f(!0),d.onAdd&&d.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();let o=this.getSource(t);if(!o)throw new Error("There is no source with this ID");for(let d in this._layers)if(this._layers[d].source===t)return this.fire(new a.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new a.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));let h=this._getSourceCaches(t);for(let d of h)delete this._sourceCaches[d.id],delete this._updatedSources[d.id],d.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(t,o){this._checkLoaded(),this.getSource(t).setData(o),this._changed=!0}getSource(t){let o=this._getSourceCache(t);return o&&o.getSource()}addLayer(t,o,h={}){this._checkLoaded();let d=t.id;if(this.getLayer(d))return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${d}" already exists on this map`)));let f;if(t.type==="custom"){if(_o(this,a.validateCustomStyleLayer(t)))return;f=a.createStyleLayer(t)}else{if(typeof t.source=="object"&&(this.addSource(d,t.source),t=a.clone$1(t),t=a.extend(t,{source:d})),this._validate(a.validateLayer,`layers.${d}`,t,{arrayIndex:-1},h))return;f=a.createStyleLayer(t),this._validateLayer(f),f.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[f.id]=f.serialize(),this._updateLayerCount(f,!0)}let _=o?this._order.indexOf(o):this._order.length;if(o&&_===-1)return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${o}" does not exist on this map.`)));this._order.splice(_,0,d),this._layerOrderChanged=!0,this._layers[d]=f;let y=this._getLayerSourceCache(f);if(this._removedLayers[d]&&f.source&&y&&f.type!=="custom"){let b=this._removedLayers[d];delete this._removedLayers[d],b.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(t,o){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new a.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===o)return;let h=this._order.indexOf(t);this._order.splice(h,1);let d=o?this._order.indexOf(o):this._order.length;o&&d===-1?this.fire(new a.ErrorEvent(new Error(`Layer with id "${o}" does not exist on this map.`))):(this._order.splice(d,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();let o=this._layers[t];if(!o)return void this.fire(new a.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));o.setEventedParent(null),this._updateLayerCount(o,!1);let h=this._order.indexOf(t);this._order.splice(h,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=o,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],o.onRemove&&o.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(let o in this._layers)if(this._layers[o].type===t)return!0;return!1}setLayerZoomRange(t,o,h){this._checkLoaded();let d=this.getLayer(t);d?d.minzoom===o&&d.maxzoom===h||(o!=null&&(d.minzoom=o),h!=null&&(d.maxzoom=h),this._updateLayer(d)):this.fire(new a.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(t,o,h={}){this._checkLoaded();let d=this.getLayer(t);if(d){if(!_e(d.filter,o))return o==null?(d.filter=void 0,void this._updateLayer(d)):void(this._validate(a.validateFilter,`layers.${d.id}.filter`,o,{layerType:d.type},h)||(d.filter=a.clone$1(o),this._updateLayer(d)))}else this.fire(new a.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){let o=this.getLayer(t);return o&&a.clone$1(o.filter)}setLayoutProperty(t,o,h,d={}){this._checkLoaded();let f=this.getLayer(t);f?_e(f.getLayoutProperty(o),h)||(f.setLayoutProperty(o,h,d),this._updateLayer(f)):this.fire(new a.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,o){let h=this.getLayer(t);if(h)return h.getLayoutProperty(o);this.fire(new a.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(t,o,h,d={}){this._checkLoaded();let f=this.getLayer(t);f?_e(f.getPaintProperty(o),h)||(f.setPaintProperty(o,h,d)&&this._updateLayer(f),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new a.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,o){let h=this.getLayer(t);return h&&h.getPaintProperty(o)}setFeatureState(t,o){this._checkLoaded();let h=t.source,d=t.sourceLayer,f=this.getSource(h);if(!f)return void this.fire(new a.ErrorEvent(new Error(`The source '${h}' does not exist in the map's style.`)));let _=f.type;if(_==="geojson"&&d)return void this.fire(new a.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(_==="vector"&&!d)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));t.id===void 0&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided.")));let y=this._getSourceCaches(h);for(let b of y)b.setFeatureState(d,t.id,o)}removeFeatureState(t,o){this._checkLoaded();let h=t.source,d=this.getSource(h);if(!d)return void this.fire(new a.ErrorEvent(new Error(`The source '${h}' does not exist in the map's style.`)));let f=d.type,_=f==="vector"?t.sourceLayer:void 0;if(f==="vector"&&!_)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&typeof t.id!="string"&&typeof t.id!="number")return void this.fire(new a.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));let y=this._getSourceCaches(h);for(let b of y)b.removeFeatureState(_,t.id,o)}getFeatureState(t){this._checkLoaded();let o=t.source,h=t.sourceLayer,d=this.getSource(o);if(d){if(d.type!=="vector"||h)return t.id===void 0&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(o)[0].getFeatureState(h,t.id);this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(new Error(`The source '${o}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){let t={};for(let o in this._sourceCaches){let h=this._sourceCaches[o].getSource();t[h.id]||(t[h.id]=h.serialize())}return a.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,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:t,layers:this._serializeLayers(this._order)},o=>o!==void 0)}_updateLayer(t){this._updatedLayers[t.id]=!0;let o=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&o&&o.getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",o.pause()),this._changed=!0,t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){let o=_=>this._layers[_].type==="fill-extrusion",h={},d=[];for(let _=this._order.length-1;_>=0;_--){let y=this._order[_];if(o(y)){h[y]=_;for(let b of t){let T=b[y];if(T)for(let E of T)d.push(E)}}}d.sort((_,y)=>y.intersectionZ-_.intersectionZ);let f=[];for(let _=this._order.length-1;_>=0;_--){let y=this._order[_];if(o(y))for(let b=d.length-1;b>=0;b--){let T=d[b].feature;if(h[T.layer.id]<_)break;f.push(T),d.pop()}else for(let b of t){let T=b[y];if(T)for(let E of T)f.push(E.feature)}}return f}queryRenderedFeatures(t,o,h){o&&o.filter&&this._validate(a.validateFilter,"queryRenderedFeatures.filter",o.filter,null,o);let d={};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new a.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(let b of o.layers){let T=this._layers[b];if(!T)return this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style and cannot be queried for features.`))),[];d[T.source]=!0}}let f=[];o.availableImages=this._availableImages;let _=o&&o.layers?o.layers.some(b=>{let T=this.getLayer(b);return T&&T.is3D()}):this.has3DLayers(),y=gr.createFromScreenPoints(t,h);for(let b in this._sourceCaches){let T=this._sourceCaches[b].getSource().id;o.layers&&!d[T]||f.push(ne(this._sourceCaches[b],this._layers,this._serializedLayers,y,o,h,_,!!this.map._showQueryGeometry))}return this.placement&&f.push(function(b,T,E,M,D,B,P){let z={},G=B.queryRenderedSymbols(M),F=[];for(let j of Object.keys(G).map(Number))F.push(P[j]);F.sort(Me);for(let j of F){let N=j.featureIndex.lookupSymbolFeatures(G[j.bucketInstanceId],T,j.bucketIndex,j.sourceLayerIndex,D.filter,D.layers,D.availableImages,b);for(let $ in N){let V=z[$]=z[$]||[],X=N[$];X.sort((ie,ae)=>{let ue=j.featureSortOrder;if(ue){let ce=ue.indexOf(ie.featureIndex);return ue.indexOf(ae.featureIndex)-ce}return ae.featureIndex-ie.featureIndex});for(let ie of X)V.push(ie)}}for(let j in z)z[j].forEach(N=>{let $=N.feature,V=E(b[j]).getFeatureState($.layer["source-layer"],$.id);$.source=$.layer.source,$.layer["source-layer"]&&($.sourceLayer=$.layer["source-layer"]),$.state=V});return z}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),y.screenGeometry,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(f)}querySourceFeatures(t,o){o&&o.filter&&this._validate(a.validateFilter,"querySourceFeatures.filter",o.filter,null,o);let h=this._getSourceCaches(t),d=[];for(let f of h)d=d.concat(me(f,o));return d}addSourceType(t,o,h){return oi.getSourceType(t)?h(new Error(`A source type called "${t}" already exists.`)):(oi.setSourceType(t,o),o.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:o.workerSourceURL},h):h(null,null))}getLight(){return this.light.getLight()}setLight(t,o={}){this._checkLoaded();let h=this.light.getLight(),d=!1;for(let _ in t)if(!_e(t[_],h[_])){d=!0;break}if(!d)return;let f={now:a.exported.now(),transition:a.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,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(t,o=1){if(this._checkLoaded(),!t)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(o===1){if(typeof t.source=="object"){let h="terrain-dem-src";this.addSource(h,t.source),t=a.clone$1(t),t=a.extend(t,{source:h})}if(this._validate(a.validateTerrain,"terrain",t))return}if(!this.terrain||this.terrain&&o!==this.terrain.drapeRenderMode)this._createTerrain(t,o);else{let h=this.terrain,d=h.get();for(let f in t)if(!_e(t[f],d[f])){h.set(t),this.stylesheet.terrain=t;let _={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};h.updateTransitions(_);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){let o=this.fog=new Qo(t,this.map.transform);this.stylesheet.fog=t;let h={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(h)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(let t of this.map._markers)t._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){let o=this.fog,h=o.get();for(let d in t)if(!_e(t[d],h[d])){o.set(t),this.stylesheet.fog=t;let f={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(f);break}}else this._createFog(t);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;let t=this._order.filter(h=>this.isLayerDraped(this._layers[h])),o=this._order.filter(h=>!this.isLayerDraped(this._layers[h]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...o)}_createTerrain(t,o){let h=this.terrain=new wn(t,o);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();let d={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};h.updateTransitions(d)}_force3DLayerUpdate(){for(let t in this._layers){let o=this._layers[t];o.type==="fill-extrusion"&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(let t in this._layers){let o=this._layers[t];o.type==="symbol"&&this._updateLayer(o)}}_validate(t,o,h,d,f={}){return(!f||f.validate!==!1)&&_o(this,t.call(a.validateStyle,a.extend({key:o,style:this.serialize(),value:h,styleSpec:a.spec},d)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){let o=this._getSourceCaches(t);for(let h of o)h.clearTiles()}_reloadSource(t){let o=this._getSourceCaches(t);for(let h of o)h.resume(),h.reload()}_updateSources(t){for(let o in this._sourceCaches)this._sourceCaches[o].update(t)}_generateCollisionBoxes(){for(let t in this._sourceCaches){let o=this._sourceCaches[t];o.resume(),o.reload()}}_updatePlacement(t,o,h,d,f=!1){let _=!1,y=!1,b={};for(let T of this._order){let E=this._layers[T];if(E.type!=="symbol")continue;if(!b[E.source]){let D=this._getLayerSourceCache(E);if(!D)continue;b[E.source]=D.getRenderableIds(!0).map(B=>D.getTileByID(B)).sort((B,P)=>P.tileID.overscaledZ-B.tileID.overscaledZ||(B.tileID.isLessThan(P.tileID)?-1:1))}let M=this.crossTileSymbolIndex.addLayer(E,b[E.source],t.center.lng,t.projection);_=_||M}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),f=f||this._layerOrderChanged||h===0,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(f||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),t.zoom))&&(this.pauseablePlacement=new Hc(t,this._order,f,o,h,d,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,b),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),y=!0),_&&this.pauseablePlacement.placement.setStale()),y||_)for(let T of this._order){let E=this._layers[T];E.type==="symbol"&&this.placement.updateLayerOpacities(E,b[E.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(let t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,o,h){this.imageManager.getImages(o.icons,h),this._updateTilesForChangedImages();let d=f=>{f&&f.setDependencies(o.tileID.key,o.type,o.icons)};d(this._otherSourceCaches[o.source]),d(this._symbolSourceCaches[o.source])}getGlyphs(t,o,h){this.glyphManager.getGlyphs(o.stacks,h)}getResource(t,o,h){return a.makeRequest(o,h)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return t.type==="symbol"?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){let o=[];return this._otherSourceCaches[t]&&o.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&o.push(this._symbolSourceCaches[t]),o}_isSourceCacheLoaded(t){let o=this._getSourceCaches(t);return o.length===0?(this.fire(new a.ErrorEvent(new Error(`There is no source with ID '${t}'`))),!1):o.every(h=>h.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)}}oi.getSourceType=function(l){return te[l]},oi.setSourceType=function(l,t){te[l]=t},oi.registerForPluginStateChange=a.registerForPluginStateChange;var go=`
|
|
9
|
-
#define EPSILON 0.0000001
|
|
10
|
-
#define PI 3.141592653589793
|
|
11
|
-
#define EXTENT 8192.0
|
|
12
|
-
#define HALF_PI PI/2.0
|
|
13
|
-
#define QUARTER_PI PI/4.0
|
|
14
|
-
#define RAD_TO_DEG 180.0/PI
|
|
15
|
-
#define DEG_TO_RAD PI/180.0
|
|
16
|
-
#define GLOBE_RADIUS EXTENT/PI/2.0
|
|
17
|
-
#ifdef FOG
|
|
18
|
-
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;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);}
|
|
19
|
-
#endif`,yo="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;}";let sn={},Er={};sn=je("",`
|
|
20
|
-
#define ELEVATION_SCALE 7.0
|
|
21
|
-
#define ELEVATION_OFFSET 450.0
|
|
22
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
23
|
-
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(
|
|
24
|
-
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;}
|
|
25
|
-
#else
|
|
26
|
-
vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
|
|
27
|
-
#endif
|
|
28
|
-
#ifdef TERRAIN
|
|
29
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
30
|
-
uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;
|
|
31
|
-
#else
|
|
32
|
-
uniform sampler2D u_dem;uniform sampler2D u_dem_prev;
|
|
33
|
-
#endif
|
|
34
|
-
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) {
|
|
35
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
36
|
-
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;
|
|
37
|
-
#else
|
|
38
|
-
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));
|
|
39
|
-
#ifdef TERRAIN_DEM_NEAREST_FILTER
|
|
40
|
-
return u_exaggeration*tl;
|
|
41
|
-
#endif
|
|
42
|
-
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);
|
|
43
|
-
#endif
|
|
44
|
-
}float prevElevation(vec2 apos) {
|
|
45
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
46
|
-
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;
|
|
47
|
-
#else
|
|
48
|
-
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);
|
|
49
|
-
#endif
|
|
50
|
-
}
|
|
51
|
-
#ifdef TERRAIN_VERTEX_MORPHING
|
|
52
|
-
float elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
|
|
53
|
-
#else
|
|
54
|
-
float elevation(vec2 apos) {return currentElevation(apos);}
|
|
55
|
-
#endif
|
|
56
|
-
float unpack_depth(vec4 rgba_depth)
|
|
57
|
-
{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.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(
|
|
58
|
-
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))
|
|
59
|
-
);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) {
|
|
60
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
61
|
-
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;
|
|
62
|
-
#else
|
|
63
|
-
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);
|
|
64
|
-
#endif
|
|
65
|
-
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;vec4 bounds=vec4(d,vec2(1.0)-d);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);}
|
|
66
|
-
#else
|
|
67
|
-
float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }
|
|
68
|
-
#endif`,!0),Er=je(`#ifdef FOG
|
|
69
|
-
uniform float u_fog_temporal_offset;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=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);}
|
|
70
|
-
#endif`,`#ifdef FOG
|
|
71
|
-
uniform mat4 u_fog_matrix;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);}
|
|
72
|
-
#endif`,!0);let ps=je(`
|
|
73
|
-
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;}
|
|
74
|
-
#ifdef TERRAIN
|
|
75
|
-
highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
|
|
76
|
-
#endif`,`
|
|
77
|
-
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;}
|
|
78
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
79
|
-
vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
|
|
80
|
-
#ifndef PROJECTED_POS_ON_VIEWPORT
|
|
81
|
-
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;
|
|
82
|
-
#else
|
|
83
|
-
return vec3(0.0);
|
|
84
|
-
#endif
|
|
85
|
-
}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);}
|
|
86
|
-
#endif
|
|
87
|
-
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(
|
|
88
|
-
unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
|
|
89
|
-
);}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.`),xo=go;var vo={background:je(`uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;
|
|
90
|
-
#ifdef FOG
|
|
91
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
92
|
-
#endif
|
|
93
|
-
gl_FragColor=out_color*u_opacity;
|
|
94
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
95
|
-
gl_FragColor=vec4(1.0);
|
|
96
|
-
#endif
|
|
97
|
-
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
|
|
98
|
-
#ifdef FOG
|
|
99
|
-
v_fog_pos=fog_position(a_pos);
|
|
100
|
-
#endif
|
|
101
|
-
}`),backgroundPattern:je(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);
|
|
102
|
-
#ifdef FOG
|
|
103
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
104
|
-
#endif
|
|
105
|
-
gl_FragColor=out_color*u_opacity;
|
|
106
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
107
|
-
gl_FragColor=vec4(1.0);
|
|
108
|
-
#endif
|
|
109
|
-
}`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);
|
|
110
|
-
#ifdef FOG
|
|
111
|
-
v_fog_pos=fog_position(a_pos);
|
|
112
|
-
#endif
|
|
113
|
-
}`),circle:je(`varying vec3 v_data;varying float v_visibility;
|
|
114
|
-
#pragma mapbox: define highp vec4 color
|
|
115
|
-
#pragma mapbox: define mediump float radius
|
|
116
|
-
#pragma mapbox: define lowp float blur
|
|
117
|
-
#pragma mapbox: define lowp float opacity
|
|
118
|
-
#pragma mapbox: define highp vec4 stroke_color
|
|
119
|
-
#pragma mapbox: define mediump float stroke_width
|
|
120
|
-
#pragma mapbox: define lowp float stroke_opacity
|
|
121
|
-
void main() {
|
|
122
|
-
#pragma mapbox: initialize highp vec4 color
|
|
123
|
-
#pragma mapbox: initialize mediump float radius
|
|
124
|
-
#pragma mapbox: initialize lowp float blur
|
|
125
|
-
#pragma mapbox: initialize lowp float opacity
|
|
126
|
-
#pragma mapbox: initialize highp vec4 stroke_color
|
|
127
|
-
#pragma mapbox: initialize mediump float stroke_width
|
|
128
|
-
#pragma mapbox: initialize lowp float stroke_opacity
|
|
129
|
-
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(
|
|
130
|
-
antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
|
|
131
|
-
);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
|
|
132
|
-
#ifdef FOG
|
|
133
|
-
out_color=fog_apply_premultiplied(out_color,v_fog_pos);
|
|
134
|
-
#endif
|
|
135
|
-
gl_FragColor=out_color*(v_visibility*opacity_t);
|
|
136
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
137
|
-
gl_FragColor=vec4(1.0);
|
|
138
|
-
#endif
|
|
139
|
-
}`,`#define NUM_VISIBILITY_RINGS 2
|
|
140
|
-
#define INV_SQRT2 0.70710678
|
|
141
|
-
#define ELEVATION_BIAS 0.0001
|
|
142
|
-
#define NUM_SAMPLES_PER_RING 16
|
|
143
|
-
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;
|
|
144
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
145
|
-
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;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;
|
|
146
|
-
#endif
|
|
147
|
-
varying vec3 v_data;varying float v_visibility;
|
|
148
|
-
#pragma mapbox: define highp vec4 color
|
|
149
|
-
#pragma mapbox: define mediump float radius
|
|
150
|
-
#pragma mapbox: define lowp float blur
|
|
151
|
-
#pragma mapbox: define lowp float opacity
|
|
152
|
-
#pragma mapbox: define highp vec4 stroke_color
|
|
153
|
-
#pragma mapbox: define mediump float stroke_width
|
|
154
|
-
#pragma mapbox: define lowp float stroke_opacity
|
|
155
|
-
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) {
|
|
156
|
-
#if defined(TERRAIN)
|
|
157
|
-
return elevation(pos)+ELEVATION_BIAS;
|
|
158
|
-
#else
|
|
159
|
-
return 0.0;
|
|
160
|
-
#endif
|
|
161
|
-
}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);
|
|
162
|
-
#ifdef PITCH_WITH_MAP
|
|
163
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
164
|
-
return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
|
|
165
|
-
#else
|
|
166
|
-
return u_matrix*( world_center+vec4(sample_offset,0,0) );
|
|
167
|
-
#endif
|
|
168
|
-
#else
|
|
169
|
-
return projected_center+vec4(sample_offset,0,0);
|
|
170
|
-
#endif
|
|
171
|
-
}float get_sample_step() {
|
|
172
|
-
#ifdef PITCH_WITH_MAP
|
|
173
|
-
return 2.0*PI/float(NUM_SAMPLES_PER_RING);
|
|
174
|
-
#else
|
|
175
|
-
return PI/float(NUM_SAMPLES_PER_RING);
|
|
176
|
-
#endif
|
|
177
|
-
}void main(void) {
|
|
178
|
-
#pragma mapbox: initialize highp vec4 color
|
|
179
|
-
#pragma mapbox: initialize mediump float radius
|
|
180
|
-
#pragma mapbox: initialize lowp float blur
|
|
181
|
-
#pragma mapbox: initialize lowp float opacity
|
|
182
|
-
#pragma mapbox: initialize highp vec4 stroke_color
|
|
183
|
-
#pragma mapbox: initialize mediump float stroke_width
|
|
184
|
-
#pragma mapbox: initialize lowp float stroke_opacity
|
|
185
|
-
vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);
|
|
186
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
187
|
-
vec2 scaled_extrude=extrude*a_scale;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=scaled_extrude.x*surface_vectors[0]+scaled_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);vec4 world_center=vec4(pos,1);
|
|
188
|
-
#else
|
|
189
|
-
mat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);
|
|
190
|
-
#endif
|
|
191
|
-
vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
|
|
192
|
-
#ifdef PITCH_WITH_MAP
|
|
193
|
-
#ifdef SCALE_WITH_MAP
|
|
194
|
-
view_scale=1.0;
|
|
195
|
-
#else
|
|
196
|
-
view_scale=projected_center.w/u_camera_to_center_distance;
|
|
197
|
-
#endif
|
|
198
|
-
#else
|
|
199
|
-
#ifdef SCALE_WITH_MAP
|
|
200
|
-
view_scale=u_camera_to_center_distance;
|
|
201
|
-
#else
|
|
202
|
-
view_scale=projected_center.w;
|
|
203
|
-
#endif
|
|
204
|
-
#endif
|
|
205
|
-
#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)
|
|
206
|
-
view_scale*=a_scale;
|
|
207
|
-
#endif
|
|
208
|
-
gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
|
|
209
|
-
#ifdef TERRAIN
|
|
210
|
-
float step=get_sample_step();
|
|
211
|
-
#ifdef PITCH_WITH_MAP
|
|
212
|
-
float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;
|
|
213
|
-
#else
|
|
214
|
-
vec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;
|
|
215
|
-
#endif
|
|
216
|
-
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);
|
|
217
|
-
#else
|
|
218
|
-
visibility=1.0;
|
|
219
|
-
#endif
|
|
220
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
221
|
-
visibility=1.0;
|
|
222
|
-
#endif
|
|
223
|
-
v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
|
|
224
|
-
#ifdef FOG
|
|
225
|
-
v_fog_pos=fog_position(world_center.xyz);
|
|
226
|
-
#endif
|
|
227
|
-
}`),clippingMask:je("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:je(`uniform highp float u_intensity;varying vec2 v_extrude;
|
|
228
|
-
#pragma mapbox: define highp float weight
|
|
229
|
-
#define GAUSS_COEF 0.3989422804014327
|
|
230
|
-
void main() {
|
|
231
|
-
#pragma mapbox: initialize highp float weight
|
|
232
|
-
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);
|
|
233
|
-
#ifdef FOG
|
|
234
|
-
gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);
|
|
235
|
-
#endif
|
|
236
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
237
|
-
gl_FragColor=vec4(1.0);
|
|
238
|
-
#endif
|
|
239
|
-
}`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;
|
|
240
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
241
|
-
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;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;
|
|
242
|
-
#endif
|
|
243
|
-
varying vec2 v_extrude;
|
|
244
|
-
#pragma mapbox: define highp float weight
|
|
245
|
-
#pragma mapbox: define mediump float radius
|
|
246
|
-
const highp float ZERO=1.0/255.0/16.0;
|
|
247
|
-
#define GAUSS_COEF 0.3989422804014327
|
|
248
|
-
void main(void) {
|
|
249
|
-
#pragma mapbox: initialize highp float weight
|
|
250
|
-
#pragma mapbox: initialize mediump float radius
|
|
251
|
-
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);
|
|
252
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
253
|
-
extrude*=a_scale;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;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
|
|
254
|
-
#else
|
|
255
|
-
vec3 pos=vec3(tilePos+extrude,elevation(tilePos));
|
|
256
|
-
#endif
|
|
257
|
-
gl_Position=u_matrix*vec4(pos,1);
|
|
258
|
-
#ifdef FOG
|
|
259
|
-
v_fog_pos=fog_position(pos);
|
|
260
|
-
#endif
|
|
261
|
-
}`),heatmapTexture:je(`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;
|
|
262
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
263
|
-
gl_FragColor=vec4(0.0);
|
|
264
|
-
#endif
|
|
265
|
-
}`,"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:je("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(
|
|
266
|
-
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:je("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(
|
|
267
|
-
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(
|
|
268
|
-
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:je("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;
|
|
269
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
270
|
-
attribute vec3 a_pos_3;
|
|
271
|
-
#endif
|
|
272
|
-
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;
|
|
273
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
274
|
-
gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
|
|
275
|
-
#else
|
|
276
|
-
gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
|
|
277
|
-
#endif
|
|
278
|
-
}`),fill:je(`#pragma mapbox: define highp vec4 color
|
|
279
|
-
#pragma mapbox: define lowp float opacity
|
|
280
|
-
void main() {
|
|
281
|
-
#pragma mapbox: initialize highp vec4 color
|
|
282
|
-
#pragma mapbox: initialize lowp float opacity
|
|
283
|
-
vec4 out_color=color;
|
|
284
|
-
#ifdef FOG
|
|
285
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
286
|
-
#endif
|
|
287
|
-
gl_FragColor=out_color*opacity;
|
|
288
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
289
|
-
gl_FragColor=vec4(1.0);
|
|
290
|
-
#endif
|
|
291
|
-
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
|
|
292
|
-
#pragma mapbox: define highp vec4 color
|
|
293
|
-
#pragma mapbox: define lowp float opacity
|
|
294
|
-
void main() {
|
|
295
|
-
#pragma mapbox: initialize highp vec4 color
|
|
296
|
-
#pragma mapbox: initialize lowp float opacity
|
|
297
|
-
gl_Position=u_matrix*vec4(a_pos,0,1);
|
|
298
|
-
#ifdef FOG
|
|
299
|
-
v_fog_pos=fog_position(a_pos);
|
|
300
|
-
#endif
|
|
301
|
-
}`),fillOutline:je(`varying vec2 v_pos;
|
|
302
|
-
#pragma mapbox: define highp vec4 outline_color
|
|
303
|
-
#pragma mapbox: define lowp float opacity
|
|
304
|
-
void main() {
|
|
305
|
-
#pragma mapbox: initialize highp vec4 outline_color
|
|
306
|
-
#pragma mapbox: initialize lowp float opacity
|
|
307
|
-
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
|
|
308
|
-
#ifdef FOG
|
|
309
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
310
|
-
#endif
|
|
311
|
-
gl_FragColor=out_color*(alpha*opacity);
|
|
312
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
313
|
-
gl_FragColor=vec4(1.0);
|
|
314
|
-
#endif
|
|
315
|
-
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
|
|
316
|
-
#pragma mapbox: define highp vec4 outline_color
|
|
317
|
-
#pragma mapbox: define lowp float opacity
|
|
318
|
-
void main() {
|
|
319
|
-
#pragma mapbox: initialize highp vec4 outline_color
|
|
320
|
-
#pragma mapbox: initialize lowp float opacity
|
|
321
|
-
gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
|
322
|
-
#ifdef FOG
|
|
323
|
-
v_fog_pos=fog_position(a_pos);
|
|
324
|
-
#endif
|
|
325
|
-
}`),fillOutlinePattern:je(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
|
|
326
|
-
#pragma mapbox: define lowp float opacity
|
|
327
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
328
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
329
|
-
void main() {
|
|
330
|
-
#pragma mapbox: initialize lowp float opacity
|
|
331
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
332
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
333
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);
|
|
334
|
-
#ifdef FOG
|
|
335
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
336
|
-
#endif
|
|
337
|
-
gl_FragColor=out_color*(alpha*opacity);
|
|
338
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
339
|
-
gl_FragColor=vec4(1.0);
|
|
340
|
-
#endif
|
|
341
|
-
}`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
|
|
342
|
-
#pragma mapbox: define lowp float opacity
|
|
343
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
344
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
345
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
346
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
347
|
-
void main() {
|
|
348
|
-
#pragma mapbox: initialize lowp float opacity
|
|
349
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
350
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
351
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
352
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
353
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
|
354
|
-
#ifdef FOG
|
|
355
|
-
v_fog_pos=fog_position(a_pos);
|
|
356
|
-
#endif
|
|
357
|
-
}`),fillPattern:je(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;
|
|
358
|
-
#pragma mapbox: define lowp float opacity
|
|
359
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
360
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
361
|
-
void main() {
|
|
362
|
-
#pragma mapbox: initialize lowp float opacity
|
|
363
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
364
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
365
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);
|
|
366
|
-
#ifdef FOG
|
|
367
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
368
|
-
#endif
|
|
369
|
-
gl_FragColor=out_color*opacity;
|
|
370
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
371
|
-
gl_FragColor=vec4(1.0);
|
|
372
|
-
#endif
|
|
373
|
-
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;
|
|
374
|
-
#pragma mapbox: define lowp float opacity
|
|
375
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
376
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
377
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
378
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
379
|
-
void main() {
|
|
380
|
-
#pragma mapbox: initialize lowp float opacity
|
|
381
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
382
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
383
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
384
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
385
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);
|
|
386
|
-
#ifdef FOG
|
|
387
|
-
v_fog_pos=fog_position(a_pos);
|
|
388
|
-
#endif
|
|
389
|
-
}`),fillExtrusion:je(`varying vec4 v_color;void main() {vec4 color=v_color;
|
|
390
|
-
#ifdef FOG
|
|
391
|
-
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
|
|
392
|
-
#endif
|
|
393
|
-
gl_FragColor=color;
|
|
394
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
395
|
-
gl_FragColor=vec4(1.0);
|
|
396
|
-
#endif
|
|
397
|
-
}`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
|
|
398
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
399
|
-
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;
|
|
400
|
-
#endif
|
|
401
|
-
varying vec4 v_color;
|
|
402
|
-
#pragma mapbox: define highp float base
|
|
403
|
-
#pragma mapbox: define highp float height
|
|
404
|
-
#pragma mapbox: define highp vec4 color
|
|
405
|
-
void main() {
|
|
406
|
-
#pragma mapbox: initialize highp float base
|
|
407
|
-
#pragma mapbox: initialize highp float height
|
|
408
|
-
#pragma mapbox: initialize highp vec4 color
|
|
409
|
-
vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
|
|
410
|
-
#if defined(HAS_CENTROID) || defined(TERRAIN)
|
|
411
|
-
centroid_pos=a_centroid_pos;
|
|
412
|
-
#endif
|
|
413
|
-
#ifdef TERRAIN
|
|
414
|
-
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);
|
|
415
|
-
#else
|
|
416
|
-
vec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
|
|
417
|
-
#endif
|
|
418
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
419
|
-
float lift=float((t+base) > 0.0)*u_height_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*(pos.z+lift));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);
|
|
420
|
-
#endif
|
|
421
|
-
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(
|
|
422
|
-
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;
|
|
423
|
-
#ifdef FOG
|
|
424
|
-
v_fog_pos=fog_position(pos);
|
|
425
|
-
#endif
|
|
426
|
-
}`),fillExtrusionPattern:je(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
|
|
427
|
-
#pragma mapbox: define lowp float base
|
|
428
|
-
#pragma mapbox: define lowp float height
|
|
429
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
430
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
431
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
432
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
433
|
-
void main() {
|
|
434
|
-
#pragma mapbox: initialize lowp float base
|
|
435
|
-
#pragma mapbox: initialize lowp float height
|
|
436
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
437
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
438
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
439
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
440
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;
|
|
441
|
-
#ifdef FOG
|
|
442
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
443
|
-
#endif
|
|
444
|
-
gl_FragColor=out_color;
|
|
445
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
446
|
-
gl_FragColor=vec4(1.0);
|
|
447
|
-
#endif
|
|
448
|
-
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
|
|
449
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
450
|
-
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;
|
|
451
|
-
#endif
|
|
452
|
-
varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
|
|
453
|
-
#pragma mapbox: define lowp float base
|
|
454
|
-
#pragma mapbox: define lowp float height
|
|
455
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
456
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
457
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
458
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
459
|
-
void main() {
|
|
460
|
-
#pragma mapbox: initialize lowp float base
|
|
461
|
-
#pragma mapbox: initialize lowp float height
|
|
462
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
463
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
464
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
465
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
466
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;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);
|
|
467
|
-
#if defined(HAS_CENTROID) || defined(TERRAIN)
|
|
468
|
-
centroid_pos=a_centroid_pos;
|
|
469
|
-
#endif
|
|
470
|
-
#ifdef TERRAIN
|
|
471
|
-
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);
|
|
472
|
-
#else
|
|
473
|
-
vec3 p=vec3(pos_nx.xy,z);
|
|
474
|
-
#endif
|
|
475
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
476
|
-
float lift=float((t+base) > 0.0)*u_height_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);
|
|
477
|
-
#endif
|
|
478
|
-
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
|
|
479
|
-
? pos_nx.xy
|
|
480
|
-
: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(
|
|
481
|
-
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
|
|
482
|
-
#ifdef FOG
|
|
483
|
-
v_fog_pos=fog_position(p);
|
|
484
|
-
#endif
|
|
485
|
-
}`),hillshadePrepare:je(`#ifdef GL_ES
|
|
486
|
-
precision highp float;
|
|
487
|
-
#endif
|
|
488
|
-
uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {
|
|
489
|
-
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
|
490
|
-
return texture2D(u_image,coord).a/4.0;
|
|
491
|
-
#else
|
|
492
|
-
vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;
|
|
493
|
-
#endif
|
|
494
|
-
}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);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=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(
|
|
495
|
-
(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)
|
|
496
|
-
)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(
|
|
497
|
-
deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
|
|
498
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
499
|
-
gl_FragColor=vec4(1.0);
|
|
500
|
-
#endif
|
|
501
|
-
}`,"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:je(`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;
|
|
502
|
-
#ifdef FOG
|
|
503
|
-
gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));
|
|
504
|
-
#endif
|
|
505
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
506
|
-
gl_FragColor=vec4(1.0);
|
|
507
|
-
#endif
|
|
508
|
-
}`,`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;
|
|
509
|
-
#ifdef FOG
|
|
510
|
-
v_fog_pos=fog_position(a_pos);
|
|
511
|
-
#endif
|
|
512
|
-
}`),line:je(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
|
|
513
|
-
#ifdef RENDER_LINE_DASH
|
|
514
|
-
uniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;
|
|
515
|
-
#endif
|
|
516
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
517
|
-
uniform sampler2D u_gradient_image;varying highp vec2 v_uv;
|
|
518
|
-
#endif
|
|
519
|
-
#pragma mapbox: define highp vec4 color
|
|
520
|
-
#pragma mapbox: define lowp float floorwidth
|
|
521
|
-
#pragma mapbox: define lowp vec4 dash_from
|
|
522
|
-
#pragma mapbox: define lowp vec4 dash_to
|
|
523
|
-
#pragma mapbox: define lowp float blur
|
|
524
|
-
#pragma mapbox: define lowp float opacity
|
|
525
|
-
void main() {
|
|
526
|
-
#pragma mapbox: initialize highp vec4 color
|
|
527
|
-
#pragma mapbox: initialize lowp float floorwidth
|
|
528
|
-
#pragma mapbox: initialize lowp vec4 dash_from
|
|
529
|
-
#pragma mapbox: initialize lowp vec4 dash_to
|
|
530
|
-
#pragma mapbox: initialize lowp float blur
|
|
531
|
-
#pragma mapbox: initialize lowp float opacity
|
|
532
|
-
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);
|
|
533
|
-
#ifdef RENDER_LINE_DASH
|
|
534
|
-
float sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);
|
|
535
|
-
#endif
|
|
536
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
537
|
-
vec4 out_color=texture2D(u_gradient_image,v_uv);
|
|
538
|
-
#else
|
|
539
|
-
vec4 out_color=color;
|
|
540
|
-
#endif
|
|
541
|
-
#ifdef FOG
|
|
542
|
-
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
|
543
|
-
#endif
|
|
544
|
-
#ifdef RENDER_LINE_ALPHA_DISCARD
|
|
545
|
-
if (alpha < u_alpha_discard_threshold) {discard;}
|
|
546
|
-
#endif
|
|
547
|
-
gl_FragColor=out_color*(alpha*opacity);
|
|
548
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
549
|
-
gl_FragColor=vec4(1.0);
|
|
550
|
-
#endif
|
|
551
|
-
}`,`
|
|
552
|
-
#define EXTRUDE_SCALE 0.015873016
|
|
553
|
-
attribute vec2 a_pos_normal;attribute vec4 a_data;
|
|
554
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
555
|
-
attribute vec3 a_packed;
|
|
556
|
-
#else
|
|
557
|
-
attribute float a_linesofar;
|
|
558
|
-
#endif
|
|
559
|
-
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;
|
|
560
|
-
#ifdef RENDER_LINE_DASH
|
|
561
|
-
uniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;
|
|
562
|
-
#endif
|
|
563
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
564
|
-
uniform float u_image_height;varying highp vec2 v_uv;
|
|
565
|
-
#endif
|
|
566
|
-
#pragma mapbox: define highp vec4 color
|
|
567
|
-
#pragma mapbox: define lowp float floorwidth
|
|
568
|
-
#pragma mapbox: define lowp vec4 dash_from
|
|
569
|
-
#pragma mapbox: define lowp vec4 dash_to
|
|
570
|
-
#pragma mapbox: define lowp float blur
|
|
571
|
-
#pragma mapbox: define lowp float opacity
|
|
572
|
-
#pragma mapbox: define mediump float gapwidth
|
|
573
|
-
#pragma mapbox: define lowp float offset
|
|
574
|
-
#pragma mapbox: define mediump float width
|
|
575
|
-
void main() {
|
|
576
|
-
#pragma mapbox: initialize highp vec4 color
|
|
577
|
-
#pragma mapbox: initialize lowp float floorwidth
|
|
578
|
-
#pragma mapbox: initialize lowp vec4 dash_from
|
|
579
|
-
#pragma mapbox: initialize lowp vec4 dash_to
|
|
580
|
-
#pragma mapbox: initialize lowp float blur
|
|
581
|
-
#pragma mapbox: initialize lowp float opacity
|
|
582
|
-
#pragma mapbox: initialize mediump float gapwidth
|
|
583
|
-
#pragma mapbox: initialize lowp float offset
|
|
584
|
-
#pragma mapbox: initialize mediump float width
|
|
585
|
-
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;
|
|
586
|
-
#ifndef RENDER_TO_TEXTURE
|
|
587
|
-
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;
|
|
588
|
-
#else
|
|
589
|
-
v_gamma_scale=1.0;
|
|
590
|
-
#endif
|
|
591
|
-
#ifdef RENDER_LINE_GRADIENT
|
|
592
|
-
float a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);
|
|
593
|
-
#endif
|
|
594
|
-
#ifdef RENDER_LINE_DASH
|
|
595
|
-
float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);
|
|
596
|
-
#endif
|
|
597
|
-
v_width2=vec2(outset,inset);
|
|
598
|
-
#ifdef FOG
|
|
599
|
-
v_fog_pos=fog_position(pos);
|
|
600
|
-
#endif
|
|
601
|
-
}`),linePattern:je(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
|
|
602
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
603
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
604
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
605
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
606
|
-
#pragma mapbox: define lowp float blur
|
|
607
|
-
#pragma mapbox: define lowp float opacity
|
|
608
|
-
void main() {
|
|
609
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
610
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
611
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
612
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
613
|
-
#pragma mapbox: initialize lowp float blur
|
|
614
|
-
#pragma mapbox: initialize lowp float opacity
|
|
615
|
-
vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);
|
|
616
|
-
#ifdef FOG
|
|
617
|
-
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
|
|
618
|
-
#endif
|
|
619
|
-
gl_FragColor=color*(alpha*opacity);
|
|
620
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
621
|
-
gl_FragColor=vec4(1.0);
|
|
622
|
-
#endif
|
|
623
|
-
}`,`
|
|
624
|
-
#define scale 0.015873016
|
|
625
|
-
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;
|
|
626
|
-
#pragma mapbox: define lowp float blur
|
|
627
|
-
#pragma mapbox: define lowp float opacity
|
|
628
|
-
#pragma mapbox: define lowp float offset
|
|
629
|
-
#pragma mapbox: define mediump float gapwidth
|
|
630
|
-
#pragma mapbox: define mediump float width
|
|
631
|
-
#pragma mapbox: define lowp float floorwidth
|
|
632
|
-
#pragma mapbox: define lowp vec4 pattern_from
|
|
633
|
-
#pragma mapbox: define lowp vec4 pattern_to
|
|
634
|
-
#pragma mapbox: define lowp float pixel_ratio_from
|
|
635
|
-
#pragma mapbox: define lowp float pixel_ratio_to
|
|
636
|
-
void main() {
|
|
637
|
-
#pragma mapbox: initialize lowp float blur
|
|
638
|
-
#pragma mapbox: initialize lowp float opacity
|
|
639
|
-
#pragma mapbox: initialize lowp float offset
|
|
640
|
-
#pragma mapbox: initialize mediump float gapwidth
|
|
641
|
-
#pragma mapbox: initialize mediump float width
|
|
642
|
-
#pragma mapbox: initialize lowp float floorwidth
|
|
643
|
-
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
644
|
-
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
645
|
-
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
646
|
-
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
647
|
-
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;
|
|
648
|
-
#ifndef RENDER_TO_TEXTURE
|
|
649
|
-
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;
|
|
650
|
-
#else
|
|
651
|
-
v_gamma_scale=1.0;
|
|
652
|
-
#endif
|
|
653
|
-
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;
|
|
654
|
-
#ifdef FOG
|
|
655
|
-
v_fog_pos=fog_position(pos);
|
|
656
|
-
#endif
|
|
657
|
-
}`),raster:je(`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(
|
|
658
|
-
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);
|
|
659
|
-
#ifdef FOG
|
|
660
|
-
out_color=fog_dither(fog_apply(out_color,v_fog_pos));
|
|
661
|
-
#endif
|
|
662
|
-
gl_FragColor=vec4(out_color*color.a,color.a);
|
|
663
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
664
|
-
gl_FragColor=vec4(1.0);
|
|
665
|
-
#endif
|
|
666
|
-
}`,`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;
|
|
667
|
-
#ifdef FOG
|
|
668
|
-
v_fog_pos=fog_position(a_pos);
|
|
669
|
-
#endif
|
|
670
|
-
}`),symbolIcon:je(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
|
|
671
|
-
#pragma mapbox: define lowp float opacity
|
|
672
|
-
void main() {
|
|
673
|
-
#pragma mapbox: initialize lowp float opacity
|
|
674
|
-
lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
|
|
675
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
676
|
-
gl_FragColor=vec4(1.0);
|
|
677
|
-
#endif
|
|
678
|
-
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform 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;
|
|
679
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
680
|
-
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;
|
|
681
|
-
#endif
|
|
682
|
-
varying vec2 v_tex;varying float v_fade_opacity;
|
|
683
|
-
#pragma mapbox: define lowp float opacity
|
|
684
|
-
void main() {
|
|
685
|
-
#pragma mapbox: initialize lowp float opacity
|
|
686
|
-
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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
|
|
687
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
688
|
-
vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
|
|
689
|
-
#else
|
|
690
|
-
vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
|
|
691
|
-
#endif
|
|
692
|
-
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 ?
|
|
693
|
-
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
694
|
-
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
|
695
|
-
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=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);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);}
|
|
696
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
697
|
-
vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
|
|
698
|
-
#else
|
|
699
|
-
vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
|
|
700
|
-
#endif
|
|
701
|
-
#ifdef PROJECTED_POS_ON_VIEWPORT
|
|
702
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
|
|
703
|
-
#else
|
|
704
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
|
|
705
|
-
#endif
|
|
706
|
-
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);
|
|
707
|
-
#ifdef PITCH_WITH_MAP_TERRAIN
|
|
708
|
-
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
|
709
|
-
#endif
|
|
710
|
-
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;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));float projection_transition_fade=1.0;
|
|
711
|
-
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
|
712
|
-
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
|
713
|
-
#endif
|
|
714
|
-
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:je(`#define SDF_PX 8.0
|
|
715
|
-
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;
|
|
716
|
-
#pragma mapbox: define highp vec4 fill_color
|
|
717
|
-
#pragma mapbox: define highp vec4 halo_color
|
|
718
|
-
#pragma mapbox: define lowp float opacity
|
|
719
|
-
#pragma mapbox: define lowp float halo_width
|
|
720
|
-
#pragma mapbox: define lowp float halo_blur
|
|
721
|
-
void main() {
|
|
722
|
-
#pragma mapbox: initialize highp vec4 fill_color
|
|
723
|
-
#pragma mapbox: initialize highp vec4 halo_color
|
|
724
|
-
#pragma mapbox: initialize lowp float opacity
|
|
725
|
-
#pragma mapbox: initialize lowp float halo_width
|
|
726
|
-
#pragma mapbox: initialize lowp float halo_blur
|
|
727
|
-
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);
|
|
728
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
729
|
-
gl_FragColor=vec4(1.0);
|
|
730
|
-
#endif
|
|
731
|
-
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_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;
|
|
732
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
733
|
-
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;
|
|
734
|
-
#endif
|
|
735
|
-
varying vec2 v_data0;varying vec3 v_data1;
|
|
736
|
-
#pragma mapbox: define highp vec4 fill_color
|
|
737
|
-
#pragma mapbox: define highp vec4 halo_color
|
|
738
|
-
#pragma mapbox: define lowp float opacity
|
|
739
|
-
#pragma mapbox: define lowp float halo_width
|
|
740
|
-
#pragma mapbox: define lowp float halo_blur
|
|
741
|
-
void main() {
|
|
742
|
-
#pragma mapbox: initialize highp vec4 fill_color
|
|
743
|
-
#pragma mapbox: initialize highp vec4 halo_color
|
|
744
|
-
#pragma mapbox: initialize lowp float opacity
|
|
745
|
-
#pragma mapbox: initialize lowp float halo_width
|
|
746
|
-
#pragma mapbox: initialize lowp float halo_blur
|
|
747
|
-
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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
|
|
748
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
749
|
-
vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
|
|
750
|
-
#else
|
|
751
|
-
vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
|
|
752
|
-
#endif
|
|
753
|
-
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 ?
|
|
754
|
-
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
755
|
-
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
|
756
|
-
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=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);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);}
|
|
757
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
758
|
-
vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
|
|
759
|
-
#else
|
|
760
|
-
vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
|
|
761
|
-
#endif
|
|
762
|
-
#ifdef PROJECTED_POS_ON_VIEWPORT
|
|
763
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
|
|
764
|
-
#else
|
|
765
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
|
|
766
|
-
#endif
|
|
767
|
-
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);
|
|
768
|
-
#ifdef PITCH_WITH_MAP_TERRAIN
|
|
769
|
-
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
|
770
|
-
#endif
|
|
771
|
-
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;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));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;
|
|
772
|
-
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
|
773
|
-
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
|
774
|
-
#endif
|
|
775
|
-
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:je(`#define SDF_PX 8.0
|
|
776
|
-
#define SDF 1.0
|
|
777
|
-
#define ICON 0.0
|
|
778
|
-
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;
|
|
779
|
-
#pragma mapbox: define highp vec4 fill_color
|
|
780
|
-
#pragma mapbox: define highp vec4 halo_color
|
|
781
|
-
#pragma mapbox: define lowp float opacity
|
|
782
|
-
#pragma mapbox: define lowp float halo_width
|
|
783
|
-
#pragma mapbox: define lowp float halo_blur
|
|
784
|
-
void main() {
|
|
785
|
-
#pragma mapbox: initialize highp vec4 fill_color
|
|
786
|
-
#pragma mapbox: initialize highp vec4 halo_color
|
|
787
|
-
#pragma mapbox: initialize lowp float opacity
|
|
788
|
-
#pragma mapbox: initialize lowp float halo_width
|
|
789
|
-
#pragma mapbox: initialize lowp float halo_blur
|
|
790
|
-
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;
|
|
791
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
792
|
-
gl_FragColor=vec4(1.0);
|
|
793
|
-
#endif
|
|
794
|
-
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);
|
|
795
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
796
|
-
gl_FragColor=vec4(1.0);
|
|
797
|
-
#endif
|
|
798
|
-
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;
|
|
799
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
800
|
-
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;
|
|
801
|
-
#endif
|
|
802
|
-
varying vec4 v_data0;varying vec4 v_data1;
|
|
803
|
-
#pragma mapbox: define highp vec4 fill_color
|
|
804
|
-
#pragma mapbox: define highp vec4 halo_color
|
|
805
|
-
#pragma mapbox: define lowp float opacity
|
|
806
|
-
#pragma mapbox: define lowp float halo_width
|
|
807
|
-
#pragma mapbox: define lowp float halo_blur
|
|
808
|
-
void main() {
|
|
809
|
-
#pragma mapbox: initialize highp vec4 fill_color
|
|
810
|
-
#pragma mapbox: initialize highp vec4 halo_color
|
|
811
|
-
#pragma mapbox: initialize lowp float opacity
|
|
812
|
-
#pragma mapbox: initialize lowp float halo_width
|
|
813
|
-
#pragma mapbox: initialize lowp float halo_blur
|
|
814
|
-
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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);
|
|
815
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
816
|
-
vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchor_z)+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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
|
|
817
|
-
#else
|
|
818
|
-
vec3 world_pos=vec3(a_pos,anchor_z)+h;float globe_occlusion_fade=1.0;
|
|
819
|
-
#endif
|
|
820
|
-
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 ?
|
|
821
|
-
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
822
|
-
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
|
823
|
-
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),anchor_z,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);}
|
|
824
|
-
#ifdef PROJECTION_GLOBE_VIEW
|
|
825
|
-
vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);
|
|
826
|
-
#else
|
|
827
|
-
vec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);
|
|
828
|
-
#endif
|
|
829
|
-
#ifdef PROJECTED_POS_ON_VIEWPORT
|
|
830
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);
|
|
831
|
-
#else
|
|
832
|
-
vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);
|
|
833
|
-
#endif
|
|
834
|
-
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);
|
|
835
|
-
#ifdef PITCH_WITH_MAP_TERRAIN
|
|
836
|
-
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
|
837
|
-
#endif
|
|
838
|
-
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;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));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;
|
|
839
|
-
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
|
840
|
-
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
|
841
|
-
#endif
|
|
842
|
-
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:je(`uniform sampler2D u_image0;varying vec2 v_pos0;
|
|
843
|
-
#ifdef FOG
|
|
844
|
-
varying float v_fog_opacity;
|
|
845
|
-
#endif
|
|
846
|
-
void main() {vec4 color=texture2D(u_image0,v_pos0);
|
|
847
|
-
#ifdef FOG
|
|
848
|
-
color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
|
|
849
|
-
#endif
|
|
850
|
-
gl_FragColor=color;
|
|
851
|
-
#ifdef TERRAIN_WIREFRAME
|
|
852
|
-
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
|
|
853
|
-
#endif
|
|
854
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
855
|
-
gl_FragColor=vec4(1.0);
|
|
856
|
-
#endif
|
|
857
|
-
}`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;
|
|
858
|
-
#ifdef FOG
|
|
859
|
-
varying float v_fog_opacity;
|
|
860
|
-
#endif
|
|
861
|
-
const float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;
|
|
862
|
-
#ifdef TERRAIN_WIREFRAME
|
|
863
|
-
elevation+=u_skirt_height*u_skirt_height*wireframeOffset;
|
|
864
|
-
#endif
|
|
865
|
-
vec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
|
|
866
|
-
#ifdef FOG
|
|
867
|
-
v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
|
|
868
|
-
#endif
|
|
869
|
-
}`),terrainDepth:je(`#ifdef GL_ES
|
|
870
|
-
precision highp float;
|
|
871
|
-
#endif
|
|
872
|
-
varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:je(`
|
|
873
|
-
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(
|
|
874
|
-
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;
|
|
875
|
-
#ifdef FOG
|
|
876
|
-
sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
|
|
877
|
-
#endif
|
|
878
|
-
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);
|
|
879
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
880
|
-
gl_FragColor=vec4(1.0);
|
|
881
|
-
#endif
|
|
882
|
-
}`,yo),skyboxGradient:je(`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));
|
|
883
|
-
#ifdef FOG
|
|
884
|
-
color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
|
|
885
|
-
#endif
|
|
886
|
-
color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;
|
|
887
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
888
|
-
gl_FragColor=vec4(1.0);
|
|
889
|
-
#endif
|
|
890
|
-
}`,yo),skyboxCapture:je(`
|
|
891
|
-
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;
|
|
892
|
-
#ifdef GL_ES
|
|
893
|
-
precision highp float;
|
|
894
|
-
#endif
|
|
895
|
-
#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)
|
|
896
|
-
#define BETA_M vec3(21e-6,21e-6,21e-6)
|
|
897
|
-
#define MIE_G 0.76
|
|
898
|
-
#define DENSITY_HEIGHT_SCALE_R 8000.0
|
|
899
|
-
#define DENSITY_HEIGHT_SCALE_M 1200.0
|
|
900
|
-
#define PLANET_RADIUS 6360e3
|
|
901
|
-
#define ATMOSPHERE_RADIUS 6420e3
|
|
902
|
-
#define SAMPLE_STEPS 10
|
|
903
|
-
#define DENSITY_STEPS 4
|
|
904
|
-
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:je(`uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);
|
|
905
|
-
#ifdef TERRAIN_WIREFRAME
|
|
906
|
-
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
|
|
907
|
-
#endif
|
|
908
|
-
#ifdef OVERDRAW_INSPECTOR
|
|
909
|
-
gl_FragColor=vec4(1.0);
|
|
910
|
-
#endif
|
|
911
|
-
}`,`uniform mat4 u_proj_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;
|
|
912
|
-
#ifdef GLOBE_POLES
|
|
913
|
-
attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;
|
|
914
|
-
#else
|
|
915
|
-
attribute vec2 a_pos;
|
|
916
|
-
#endif
|
|
917
|
-
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() {
|
|
918
|
-
#ifdef GLOBE_POLES
|
|
919
|
-
vec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;
|
|
920
|
-
#else
|
|
921
|
-
float tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
|
|
922
|
-
#endif
|
|
923
|
-
v_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);
|
|
924
|
-
#ifdef TERRAIN_WIREFRAME
|
|
925
|
-
height+=wireframeOffset;
|
|
926
|
-
#endif
|
|
927
|
-
vec4 globe=u_globe_matrix*vec4(globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}`),globeAtmosphere:je(`uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;varying highp vec3 v_ray_dir;void main() {highp vec3 dir=normalize(v_ray_dir);highp vec3 closest_point=abs(dot(u_globe_pos,dir))*dir;float norm_dist_from_center=length(closest_point-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 1.0)
|
|
928
|
-
discard;float t=clamp(1.0-sqrt(norm_dist_from_center-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}`,"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;varying highp vec3 v_ray_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);gl_Position=vec4(a_pos,1.0);}")};function je(l,t,o){let h=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,d=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,f=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),_=l.match(d),y=t.match(d),b=go.match(d),T=y?y.concat(_):_;o||(sn.staticUniforms&&(T=sn.staticUniforms.concat(T)),Er.staticUniforms&&(T=Er.staticUniforms.concat(T))),T&&(T=T.concat(b));let E={};return{fragmentSource:l=l.replace(h,(M,D,B,P,z)=>(E[z]=!0,D==="define"?`
|
|
929
|
-
#ifndef HAS_UNIFORM_u_${z}
|
|
930
|
-
varying ${B} ${P} ${z};
|
|
931
|
-
#else
|
|
932
|
-
uniform ${B} ${P} u_${z};
|
|
933
|
-
#endif
|
|
934
|
-
`:`
|
|
935
|
-
#ifdef HAS_UNIFORM_u_${z}
|
|
936
|
-
${B} ${P} ${z} = u_${z};
|
|
937
|
-
#endif
|
|
938
|
-
`)),vertexSource:t=t.replace(h,(M,D,B,P,z)=>{let G=P==="float"?"vec2":"vec4",F=z.match(/color/)?"color":G;return E[z]?D==="define"?`
|
|
939
|
-
#ifndef HAS_UNIFORM_u_${z}
|
|
940
|
-
uniform lowp float u_${z}_t;
|
|
941
|
-
attribute ${B} ${G} a_${z};
|
|
942
|
-
varying ${B} ${P} ${z};
|
|
943
|
-
#else
|
|
944
|
-
uniform ${B} ${P} u_${z};
|
|
945
|
-
#endif
|
|
946
|
-
`:F==="vec4"?`
|
|
947
|
-
#ifndef HAS_UNIFORM_u_${z}
|
|
948
|
-
${z} = a_${z};
|
|
949
|
-
#else
|
|
950
|
-
${B} ${P} ${z} = u_${z};
|
|
951
|
-
#endif
|
|
952
|
-
`:`
|
|
953
|
-
#ifndef HAS_UNIFORM_u_${z}
|
|
954
|
-
${z} = unpack_mix_${F}(a_${z}, u_${z}_t);
|
|
955
|
-
#else
|
|
956
|
-
${B} ${P} ${z} = u_${z};
|
|
957
|
-
#endif
|
|
958
|
-
`:D==="define"?`
|
|
959
|
-
#ifndef HAS_UNIFORM_u_${z}
|
|
960
|
-
uniform lowp float u_${z}_t;
|
|
961
|
-
attribute ${B} ${G} a_${z};
|
|
962
|
-
#else
|
|
963
|
-
uniform ${B} ${P} u_${z};
|
|
964
|
-
#endif
|
|
965
|
-
`:F==="vec4"?`
|
|
966
|
-
#ifndef HAS_UNIFORM_u_${z}
|
|
967
|
-
${B} ${P} ${z} = a_${z};
|
|
968
|
-
#else
|
|
969
|
-
${B} ${P} ${z} = u_${z};
|
|
970
|
-
#endif
|
|
971
|
-
`:`
|
|
972
|
-
#ifndef HAS_UNIFORM_u_${z}
|
|
973
|
-
${B} ${P} ${z} = unpack_mix_${F}(a_${z}, u_${z}_t);
|
|
974
|
-
#else
|
|
975
|
-
${B} ${P} ${z} = u_${z};
|
|
976
|
-
#endif
|
|
977
|
-
`}),staticAttributes:f,staticUniforms:T}}class ds{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,o,h,d,f,_,y,b){this.context=t;let T=this.boundPaintVertexBuffers.length!==d.length;for(let E=0;!T&&E<d.length;E++)this.boundPaintVertexBuffers[E]!==d[E]&&(T=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===o&&this.boundLayoutVertexBuffer===h&&!T&&this.boundIndexBuffer===f&&this.boundVertexOffset===_&&this.boundDynamicVertexBuffer===y&&this.boundDynamicVertexBuffer2===b?(t.bindVertexArrayOES.set(this.vao),y&&y.bind(),f&&f.dynamicDraw&&f.bind(),b&&b.bind()):this.freshBind(o,h,d,f,_,y,b)}freshBind(t,o,h,d,f,_,y){let b,T=t.numAttributes,E=this.context,M=E.gl;if(E.extVertexArrayObject)this.vao&&this.destroy(),this.vao=E.extVertexArrayObject.createVertexArrayOES(),E.bindVertexArrayOES.set(this.vao),b=0,this.boundProgram=t,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=h,this.boundIndexBuffer=d,this.boundVertexOffset=f,this.boundDynamicVertexBuffer=_,this.boundDynamicVertexBuffer2=y;else{b=E.currentNumAttributes||0;for(let D=T;D<b;D++)M.disableVertexAttribArray(D)}o.enableAttributes(M,t);for(let D of h)D.enableAttributes(M,t);_&&_.enableAttributes(M,t),y&&y.enableAttributes(M,t),o.bind(),o.setVertexAttribPointers(M,t,f);for(let D of h)D.bind(),D.setVertexAttribPointers(M,t,f);_&&(_.bind(),_.setVertexAttribPointers(M,t,f)),d&&d.bind(),y&&(y.bind(),y.setVertexAttribPointers(M,t,f)),E.currentNumAttributes=T}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Ml(l,t){let o=Math.pow(2,t.canonical.z),h=t.canonical.y;return[new a.MercatorCoordinate(0,h/o).toLngLat().lat,new a.MercatorCoordinate(0,(h+1)/o).toLngLat().lat]}function Al(l,t,o,h,d,f,_){let y=l.context,b=y.gl,T=o.fbo;if(!T)return;l.prepareDrawTile();let E=l.useProgram("hillshade");y.activeTexture.set(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,T.colorAttachment.get());let M=((z,G,F,j)=>{let N=F.paint.get("hillshade-shadow-color"),$=F.paint.get("hillshade-highlight-color"),V=F.paint.get("hillshade-accent-color"),X=F.paint.get("hillshade-illumination-direction")*(Math.PI/180);F.paint.get("hillshade-illumination-anchor")==="viewport"&&(X-=z.transform.angle);let ie=!z.options.moving;return{u_matrix:j||z.transform.calculateProjMatrix(G.tileID.toUnwrapped(),ie),u_image:0,u_latrange:Ml(0,G.tileID),u_light:[F.paint.get("hillshade-exaggeration"),X],u_shadow:N,u_highlight:$,u_accent:V}})(l,o,h,l.terrain?t.projMatrix:null);l.prepareDrawProgram(y,E,t.toUnwrapped());let{tileBoundsBuffer:D,tileBoundsIndexBuffer:B,tileBoundsSegments:P}=l.getTileBoundsBuffers(o);E.draw(y,b.TRIANGLES,d,f,_,a.CullFaceMode.disabled,M,h.id,D,B,P)}function la(l,t,o){if(!t.needsDEMTextureUpload)return;let h=l.context,d=h.gl;h.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||l.getTileTexture(o.stride);let f=o.getPixels();t.demTexture?t.demTexture.update(f,{premultiply:!1}):t.demTexture=new a.Texture(h,f,d.RGBA,{premultiply:!1}),t.needsDEMTextureUpload=!1}function ca(l,t,o,h,d,f){let _=l.context,y=_.gl;if(!t.dem)return;let b=t.dem;if(_.activeTexture.set(y.TEXTURE1),la(l,t,b),!t.demTexture)return;t.demTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE);let T=b.dim;_.activeTexture.set(y.TEXTURE0);let E=t.fbo;if(!E){let P=new a.Texture(_,{width:T,height:T,data:null},y.RGBA);P.bind(y.LINEAR,y.CLAMP_TO_EDGE),E=t.fbo=_.createFramebuffer(T,T,!0),E.colorAttachment.set(P.texture)}_.bindFramebuffer.set(E.framebuffer),_.viewport.set([0,0,T,T]);let{tileBoundsBuffer:M,tileBoundsIndexBuffer:D,tileBoundsSegments:B}=l.getMercatorTileBoundsBuffers();l.useProgram("hillshadePrepare").draw(_,y.TRIANGLES,h,d,f,a.CullFaceMode.disabled,((P,z)=>{let G=z.stride,F=a.create();return a.ortho(F,0,a.EXTENT,-a.EXTENT,0,0,1),a.translate(F,F,[0,-a.EXTENT,0]),{u_matrix:F,u_image:1,u_dimension:[G,G],u_zoom:P.overscaledZ,u_unpack:z.unpackVector}})(t.tileID,b),o.id,M,D,B),t.needsHillshadePrepare=!1}let ha=(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_image0:new a.Uniform1i(l,t.u_image0),u_skirt_height:new a.Uniform1f(l,t.u_skirt_height)}),Cl=(l,t)=>({u_matrix:l,u_image0:0,u_skirt_height:t}),zl=(l,t,o,h,d,f)=>({u_proj_matrix:Float32Array.from(l),u_globe_matrix:t,u_merc_matrix:o,u_zoom_transition:h,u_merc_center:d,u_image0:0,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9)});function fs(l,t){return l!=null&&t!=null&&!(!l.hasData()||!t.hasData())&&l.demTexture!=null&&t.demTexture!=null&&l.tileID.key!==t.tileID.key}let Sr=new class{constructor(){this.operations={}}newMorphing(l,t,o,h,d){if(l in this.operations){let f=this.operations[l];f.to.tileID.key!==o.tileID.key&&(f.queued=o)}else this.operations[l]={startTime:h,phase:0,duration:d,from:t,to:o,queued:null}}getMorphValuesForProxy(l){if(!(l in this.operations))return null;let t=this.operations[l];return{from:t.from,to:t.to,phase:t.phase}}update(l){for(let t in this.operations){let o=this.operations[t];for(o.phase=(l-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,l)){delete this.operations[t];break}}}_nextOp(l,t){return!!l.queued&&(l.from=l.to,l.to=l.queued,l.queued=null,l.phase=0,l.startTime=t,!0)}_validOp(l){return l.from.hasData()&&l.to.hasData()}},Bn={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function ua(l,t){let o=1<<l.z;return!t&&(l.x===0||l.x===o-1)||l.y===0||l.y===o-1}let ms=l=>({u_matrix:l});function pa(l,t,o,h,d){if(d>0){let f=a.exported.now(),_=(f-l.timeAdded)/d,y=t?(f-t.timeAdded)/d:-1,b=o.getSource(),T=h.coveringZoomLevel({tileSize:b.tileSize,roundZoom:b.roundZoom}),E=!t||Math.abs(t.tileID.overscaledZ-T)>Math.abs(l.tileID.overscaledZ-T),M=E&&l.refreshedUponExpiration?1:a.clamp(E?_:1-y,0,1);return l.refreshedUponExpiration&&_>=1&&(l.refreshedUponExpiration=!1),t?{opacity:1,mix:1-M}:{opacity:M,mix:0}}return{opacity:1,mix:0}}let Jc=2*a.mercatorZfromAltitude(1,0)*a.GLOBE_RADIUS*Math.PI;class bo extends a.SourceCache{constructor(t){let o={type:"raster-dem",maxzoom:t.transform.maxZoom},h=new bt($e(),null),d=ee("mock-dem",o,h,t.style);super("mock-dem",d,!1),d.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,o){t.state="loaded",o(null)}}class wo extends a.SourceCache{constructor(t){let o=ee("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new bt($e(),null),t.style);super("proxy",o,!1),o.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,o,h){if(t.freezeTileCoverage)return;this.transform=t;let d=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((f,_)=>{if(f[_.key]="",!this._tiles[_.key]){let y=new a.Tile(_,this._source.tileSize*_.overscaleFactor(),t.tileZoom);y.state="loaded",this._tiles[_.key]=y}return f},{});for(let f in this._tiles)f in d||(this.freeFBO(f),this._tiles[f].unloadVectorData(),delete this._tiles[f])}freeFBO(t){let o=this.proxyCachedFBO[t];if(o!==void 0){let h=Object.values(o);this.renderCachePool.push(...h),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach(t=>t.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class da extends a.OverscaledTileID{constructor(t,o,h){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=o,this.projMatrix=h}}class fi extends a.Elevation{constructor(t,o){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};let[h,d,f]=function(b){let T=new a.StructArrayLayout4i8,E=new a.StructArrayLayout3ui6,M=131;T.reserve(17161),E.reserve(33800);let D=a.EXTENT/128,B=a.EXTENT+D/2,P=B+D;for(let G=-D;G<P;G+=D)for(let F=-D;F<P;F+=D){let j=F<0||F>B||G<0||G>B?24575:0,N=a.clamp(Math.round(F),0,a.EXTENT),$=a.clamp(Math.round(G),0,a.EXTENT);T.emplaceBack(N+j,$,N,$)}let z=(G,F)=>{let j=F*M+G;E.emplaceBack(j+1,j,j+M),E.emplaceBack(j+M,j+M+1,j+1)};for(let G=1;G<129;G++)for(let F=1;F<129;F++)z(F,G);return[0,129].forEach(G=>{for(let F=0;F<130;F++)z(F,G),z(G,F)}),[T,E,32768]}(),_=t.context;this.gridBuffer=_.createVertexBuffer(h,a.boundsAttributes.members),this.gridIndexBuffer=_.createIndexBuffer(d),this.gridSegments=a.SegmentVector.simpleSegment(0,0,h.length,d.length),this.gridNoSkirtSegments=a.SegmentVector.simpleSegment(0,0,h.length,f),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new wo(o.map),this.orthoMatrix=a.create(),a.ortho(this.orthoMatrix,0,a.EXTENT,0,a.EXTENT,0,1);let y=_.gl;this._overlapStencilMode=new a.StencilMode({func:y.GEQUAL,mask:255},0,255,y.KEEP,y.KEEP,y.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new bo(o.map)}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency()}update(t,o,h){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;let d=t.terrain.properties;this.sourceCache=t.terrain.drapeRenderMode===0?this._mockSourceCache:t._getSourceCache(d.get("source")),this._exaggeration=d.get("exaggeration");let f=()=>{this.sourceCache.used&&a.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
|
|
978
|
-
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);let _=this.getScaledDemTileSize();this.sourceCache.update(o,_,!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(!h),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){let t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||t.efficiency!==100&&a.warnOnce(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance
|
|
979
|
-
may be affected negatively, consider placing all background, fill and line layers before layer
|
|
980
|
-
with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&t.dataType==="source"?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):t.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(let t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(t=>t.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){let t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;let o=this.proxySourceCache,h=this.painter.transform;this._initializing&&(this._initializing=h._centerAltitude===0&&this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(h.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);let d=this.proxyCoords=o.getIds().map(b=>{let T=o.getTileByID(b).tileID;return T.projMatrix=h.calculateProjMatrix(T.toUnwrapped()),T});(function(b,T){let E=T.transform.pointCoordinate(T.transform.getCameraPoint()),M=new a.pointGeometry(E.x,E.y);b.sort((D,B)=>{if(B.overscaledZ-D.overscaledZ)return B.overscaledZ-D.overscaledZ;let P=new a.pointGeometry(D.canonical.x+(1<<D.canonical.z)*D.wrap,D.canonical.y),z=new a.pointGeometry(B.canonical.x+(1<<B.canonical.z)*B.wrap,B.canonical.y),G=M.mult(1<<D.canonical.z);return G.x-=.5,G.y-=.5,G.distSqr(P)-G.distSqr(z)})})(d,this.painter),this._previousZoom=h.zoom;let f=this.proxyToSource||{};this.proxyToSource={},d.forEach(b=>{this.proxyToSource[b.key]={}}),this.terrainTileForTile={};let _=this._style._sourceCaches;for(let b in _){let T=_[b];if(!T.used||(T!==this.sourceCache&&this.resetTileLookupCache(T.id),this._setupProxiedCoordsForOrtho(T,t[b],f),T.usedForTerrain))continue;let E=t[b];T.getSource().reparseOverscaled&&this._assignTerrainTiles(E)}this.proxiedCoords[o.id]=d.map(b=>new da(b,b.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(f),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();let y={};this._visibleDemTiles=[];for(let b of this.proxyCoords){let T=this.terrainTileForTile[b.key];if(!T)continue;let E=T.tileID.key;E in y||(this._visibleDemTiles.push(T),y[E]=E)}}_assignTerrainTiles(t){this._initializing||t.forEach(o=>{if(this.terrainTileForTile[o.key])return;let h=this._findTileCoveringTileID(o,this.sourceCache);h&&(this.terrainTileForTile[o.key]=h)})}_prepareDEMTextures(){let t=this.painter.context,o=t.gl;for(let h in this.terrainTileForTile){let d=this.terrainTileForTile[h],f=d.dem;!f||d.demTexture&&!d.needsDEMTextureUpload||(t.activeTexture.set(o.TEXTURE1),la(this.painter,d,f))}}_prepareDemTileUniforms(t,o,h,d){if(!o||o.demTexture==null)return!1;let f=t.tileID.canonical,_=Math.pow(2,o.tileID.canonical.z-f.z),y=d||"";return h[`u_dem_tl${y}`]=[f.x*_%1,f.y*_%1],h[`u_dem_scale${y}`]=_,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){let t=this.painter.context,o=t.gl;if(!this._emptyDepthBufferTexture){let h=new a.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new a.Texture(t,h,o.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let t=0,o=this._visibleDemTiles.reduce((h,d)=>{if(!d.dem)return h;let f=d.dem.tree.minimums[0];return f>0&&t++,h+f},0);return t?o/t:0}_updateEmptyDEMTexture(){let t=this.painter.context,o=t.gl;t.activeTexture.set(o.TEXTURE2);let h=this._getLoadedAreaMinimum(),d=new a.RGBAImage({width:1,height:1},new Uint8Array(a.DEMData.pack(h,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let f=this._emptyDEMTexture;return f?f.update(d,{premultiply:!1}):f=this._emptyDEMTexture=new a.Texture(t,d,o.RGBA,{premultiply:!1}),f}setupElevationDraw(t,o,h){let d=this.painter.context,f=d.gl,_=(y=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.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,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var y;_.u_dem_size=this.sourceCache.getSource().tileSize,_.u_exaggeration=this.exaggeration();let b=this.painter.transform,T=b.projection,E=t.tileID.canonical;_.u_tile_tl_up=T.upVector(E,0,0),_.u_tile_tr_up=T.upVector(E,a.EXTENT,0),_.u_tile_br_up=T.upVector(E,a.EXTENT,a.EXTENT),_.u_tile_bl_up=T.upVector(E,0,a.EXTENT),_.u_tile_up_scale=h&&h.useDenormalizedUpVectorScale?Jc:T.upVectorScale(E,b.center.lat,b.worldSize).metersToTile;let M=null,D=null,B=1;if(h&&h.morphing&&this._useVertexMorphing){let P=h.morphing.srcDemTile,z=h.morphing.dstDemTile;B=h.morphing.phase,P&&z&&(this._prepareDemTileUniforms(t,P,_,"_prev")&&(D=P),this._prepareDemTileUniforms(t,z,_)&&(M=z))}if(D&&M?(d.activeTexture.set(f.TEXTURE2),M.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE,f.NEAREST),d.activeTexture.set(f.TEXTURE4),D.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE,f.NEAREST),_.u_dem_lerp=B):(M=this.terrainTileForTile[t.tileID.key],d.activeTexture.set(f.TEXTURE2),(this._prepareDemTileUniforms(t,M,_)?M.demTexture:this.emptyDEMTexture).bind(f.NEAREST,f.CLAMP_TO_EDGE)),d.activeTexture.set(f.TEXTURE3),h&&h.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),this._depthFBO&&(_.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),_.u_depth_size_inv=[1,1]),h&&h.useMeterToDem&&M){let P=(1<<M.tileID.canonical.z)*a.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;_.u_meter_to_dem=P}h&&h.labelPlaneMatrixInv&&(_.u_label_plane_matrix_inv=h.labelPlaneMatrixInv),o.setTerrainUniformValues(d,_)}renderToBackBuffer(t){let o=this.painter,h=this.painter.context;t.length!==0&&(h.bindFramebuffer.set(null),h.viewport.set([0,0,o.width,o.height]),this.renderingToTexture=!1,function(d,f,_,y,b){if(d.transform.projection.name==="globe")(function(T,E,M,D,B){let P=T.context,z=P.gl,G,F,j=T.options.showTerrainWireframe?2:0,N=(ce,we)=>{if(F===ce)return;let re=[Bn[ce],"PROJECTION_GLOBE_VIEW"];we&&re.push(Bn[j]),G=T.useProgram("globeRaster",null,re),F=ce},$=T.colorModeForRenderPass(),V=new a.DepthMode(z.LEQUAL,a.DepthMode.ReadWrite,T.depthRangeFor3D);Sr.update(B);let X=T.transform,ie=a.calculateGlobeMercatorMatrix(X),ae=[a.mercatorXfromLng(X.center.lng),a.mercatorYfromLat(X.center.lat)],ue=T.globeSharedBuffers;if((j?[!1,!0]:[!1]).forEach(ce=>{F=-1;let we=ce?z.LINES:z.TRIANGLES;for(let re of D){let Te=M.getTile(re),ve=a.StencilMode.disabled,Le=E.prevTerrainTileForTile[re.key],pe=E.terrainTileForTile[re.key];fs(Le,pe)&&Sr.newMorphing(re.key,Le,pe,B,250),P.activeTexture.set(z.TEXTURE0),Te.texture.bind(z.LINEAR,z.CLAMP_TO_EDGE);let ke=Sr.getMorphValuesForProxy(re.key),Ve=ke?1:0,De={useDenormalizedUpVectorScale:!0};ke&&a.extend$1(De,{morphing:{srcDemTile:ke.from,dstDemTile:ke.to,phase:a.easeCubicInOut(ke.phase)}});let Pe=Float32Array.from(X.globeMatrix),Ze=a.globeTileLatLngCorners(re.canonical),Ye=a.getGridMatrix(re.canonical,Ze),Fe=zl(X.projMatrix,Pe,ie,a.globeToMercatorTransition(X.zoom),ae,Ye);if(N(Ve,ce),E.setupElevationDraw(Te,G,De),T.prepareDrawProgram(P,G,re.toUnwrapped()),ue){let[qe,st,At]=ce?ue.getWirefameBuffers(T.context):ue.getGridBuffers();G.draw(P,we,V,ve,$,a.CullFaceMode.backCCW,Fe,"globe_raster",qe,st,At)}}}),ue){G=T.useProgram("globeRaster",null,["GLOBE_POLES","PROJECTION_GLOBE_VIEW"]);for(let ce of D){let{x:we,y:re,z:Te}=ce.canonical,ve=re===0,Le=re===(1<<Te)-1,[pe,ke,Ve,De]=ue.getPoleBuffers(Te);if(De&&(ve||Le)){let Pe=M.getTile(ce);P.activeTexture.set(z.TEXTURE0),Pe.texture.bind(z.LINEAR,z.CLAMP_TO_EDGE);let Ze=a.globePoleMatrixForTile(Te,we,X),Ye=(Fe,qe)=>Fe.draw(P,z.TRIANGLES,V,a.StencilMode.disabled,$,a.CullFaceMode.disabled,zl(X.projMatrix,Ze,Ze,0,ae),"globe_pole_raster",qe,Ve,De);E.setupElevationDraw(Pe,G,{}),T.prepareDrawProgram(P,G,ce.toUnwrapped()),ve&&Ye(G,pe),Le&&(Ze=a.scale(a.create(),Ze,[1,-1,1]),Ye(G,ke))}}}})(d,f,_,y,b);else{let T=d.context,E=T.gl,M,D,B=d.options.showTerrainWireframe?2:0,P=(N,$)=>{if(D===N)return;let V=[Bn[N]];$&&V.push(Bn[B]),M=d.useProgram("terrainRaster",null,V),D=N},z=d.colorModeForRenderPass(),G=new a.DepthMode(E.LEQUAL,a.DepthMode.ReadWrite,d.depthRangeFor3D);Sr.update(b);let F=d.transform,j=6*Math.pow(1.5,22-F.zoom)*f.exaggeration();(B?[!1,!0]:[!1]).forEach(N=>{D=-1;let $=N?E.LINES:E.TRIANGLES,[V,X]=N?f.getWirefameBuffer():[f.gridIndexBuffer,f.gridSegments];for(let ie of y){let ae=_.getTile(ie),ue=a.StencilMode.disabled,ce=f.prevTerrainTileForTile[ie.key],we=f.terrainTileForTile[ie.key];fs(ce,we)&&Sr.newMorphing(ie.key,ce,we,b,250),T.activeTexture.set(E.TEXTURE0),ae.texture.bind(E.LINEAR,E.CLAMP_TO_EDGE,E.LINEAR_MIPMAP_NEAREST);let re=Sr.getMorphValuesForProxy(ie.key),Te=re?1:0,ve;re&&(ve={morphing:{srcDemTile:re.from,dstDemTile:re.to,phase:a.easeCubicInOut(re.phase)}});let Le=Cl(ie.projMatrix,ua(ie.canonical,F.renderWorldCopies)?j/10:j);P(Te,N),f.setupElevationDraw(ae,M,ve),d.prepareDrawProgram(T,M,ie.toUnwrapped()),M.draw(T,$,G,ue,z,a.CullFaceMode.backCCW,Le,"terrain_raster",f.gridBuffer,V,X)}})}}(o,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,t.splice(0,t.length))}renderBatch(t){if(this._drapedRenderBatches.length===0)return t+1;this.renderingToTexture=!0;let o=this.painter,h=this.painter.context,d=this.proxySourceCache,f=this.proxiedCoords[d.id],_=this._drapedRenderBatches.shift(),y=[],b=o.style.order,T=0;for(let E of f){let M=d.getTileByID(E.proxyTileKey),D=d.proxyCachedFBO[E.key]?d.proxyCachedFBO[E.key][t]:void 0,B=D!==void 0?d.renderCache[D]:this.pool[T++],P=D!==void 0;if(M.texture=B.tex,P&&!B.dirty){y.push(M.tileID);continue}let z;h.bindFramebuffer.set(B.fb.framebuffer),this.renderedToTile=!1,B.dirty&&(h.clear({color:a.Color.transparent,stencil:0}),B.dirty=!1);for(let G=_.start;G<=_.end;++G){let F=o.style._layers[b[G]];if(F.isHidden(o.transform.zoom))continue;let j=o.style._getLayerSourceCache(F),N=j?this.proxyToSource[E.key][j.id]:[E];if(!N)continue;let $=N;h.viewport.set([0,0,B.fb.width,B.fb.height]),z!==(j?j.id:null)&&(this._setupStencil(B,N,F,j),z=j?j.id:null),o.renderLayer(o,j,F,$)}this.renderedToTile?(B.dirty=!0,y.push(M.tileID)):P||--T,T===5&&(T=0,this.renderToBackBuffer(y))}return this.renderToBackBuffer(y),this.renderingToTexture=!1,h.bindFramebuffer.set(null),h.viewport.set([0,0,o.width,o.height]),_.end+1}postRender(){}renderCacheEfficiency(t){let o=t.order.length;if(o===0)return{efficiency:100};let h,d=0,f=0,_=!1;for(let y=0;y<o;++y){let b=t._layers[t.order[y]];this._style.isLayerDraped(b)?(_&&++d,++f):_||(_=!0,h=b.id)}return f===0?{efficiency:100}:{efficiency:100*(1-d/f),firstUndrapedLayer:h}}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{t=Math.min(t,o.dem.tree.minimums[0])}),t===0?t:(t-30)*this._exaggeration}raycast(t,o,h){if(!this._visibleDemTiles)return null;let d=this._visibleDemTiles.filter(f=>f.dem).map(f=>{let _=f.tileID,y=Math.pow(2,_.overscaledZ),{x:b,y:T}=_.canonical,E=b/y,M=(b+1)/y,D=T/y,B=(T+1)/y;return{minx:E,miny:D,maxx:M,maxy:B,t:f.dem.tree.raycastRoot(E,D,M,B,t,o,h),tile:f}});d.sort((f,_)=>(f.t!==null?f.t:Number.MAX_VALUE)-(_.t!==null?_.t:Number.MAX_VALUE));for(let f of d){if(f.t==null)return null;let _=f.tile.dem.tree.raycast(f.minx,f.miny,f.maxx,f.maxy,t,o,h);if(_!=null)return _}return null}_createFBO(){let t=this.painter.context,o=t.gl,h=this.drapeBufferSize;t.activeTexture.set(o.TEXTURE0);let d=new a.Texture(t,{width:h[0],height:h[1],data:null},o.RGBA);d.bind(o.LINEAR,o.CLAMP_TO_EDGE);let f=t.createFramebuffer(h[0],h[1],!1);return f.colorAttachment.set(d.texture),f.depthAttachment=new Cn(t,f.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,h[0],h[1]),this._stencilRef=0,f.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):f.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&o.texParameterf(o.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.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(let t in this._style._sourceCaches)if(this._style._sourceCaches[t].hasTransition())return!0;return this._style.order.some(t=>{let o=this._style._layers[t],h=o.isHidden(this.painter.transform.zoom),d=o.getCrossfadeParameters(),f=!!d&&d.t!==1,_=o.hasTransition();return o.type!=="custom"&&!h&&(f||_)})}_clearRasterFadeFromRenderCache(){let t=!1;for(let o in this._style._sourceCaches)if(this._style._sourceCaches[o]._source instanceof C){t=!0;break}if(t)for(let o=0;o<this._style.order.length;++o){let h=this._style._layers[this._style.order[o]],d=h.isHidden(this.painter.transform.zoom),f=this._style._getLayerSourceCache(h);if(h.type!=="raster"||d||!f)continue;let _=h.paint.get("raster-fade-duration");for(let y of this.proxyCoords){let b=this.proxyToSource[y.key][f.id];if(b)for(let T of b){let E=pa(f.getTile(T),f.findLoadedParent(T,0),f,this.painter.transform,_);(E.opacity!==1||E.mix!==0)&&this._clearRenderCacheForTile(f.id,T)}}}}_setupDrapedRenderBatches(){let t=this._style.order,o=t.length;if(o===0)return;let h=[],d,f=0,_=this._style._layers[t[f]];for(;!this._style.isLayerDraped(_)&&_.isHidden(this.painter.transform.zoom)&&++f<o;)_=this._style._layers[t[f]];for(;f<o;++f){let y=this._style._layers[t[f]];y.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(y)?d===void 0&&(d=f):d!==void 0&&(h.push({start:d,end:f-1}),d=void 0))}d!==void 0&&h.push({start:d,end:f-1}),this._drapedRenderBatches=h}_setupRenderCache(t){let o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){let _=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let y=0;y<_.length;++y){let b=Object.values(_[y]);o.renderCachePool.push(...b)}}return}this._clearRasterFadeFromRenderCache();let h=this.proxyCoords,d=this._tilesDirty;for(let _=h.length-1;_>=0;_--){let y=h[_];if(o.getTileByID(y.key),o.proxyCachedFBO[y.key]!==void 0){let b=t[y.key],T=this.proxyToSource[y.key],E=0;for(let M in T){let D=T[M],B=b[M];if(!B||B.length!==D.length||D.some((P,z)=>P!==B[z]||d[M]&&d[M].hasOwnProperty(P.key))){E=-1;break}++E}for(let M in o.proxyCachedFBO[y.key])o.renderCache[o.proxyCachedFBO[y.key][M]].dirty=E<0||E!==Object.values(b).length}}let f=[...this._drapedRenderBatches];f.sort((_,y)=>y.end-y.start-(_.end-_.start));for(let _ of f)for(let y of h){if(o.proxyCachedFBO[y.key])continue;let b=o.renderCachePool.pop();b===void 0&&o.renderCache.length<50&&(b=o.renderCache.length,o.renderCache.push(this._createFBO())),b!==void 0&&(o.proxyCachedFBO[y.key]={},o.proxyCachedFBO[y.key][_.start]=b,o.renderCache[b].dirty=!0)}this._tilesDirty={}}_setupStencil(t,o,h,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));let f=this.painter.context,_=f.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let y;if(h.isTileClipped())y=o.length,this._overlapStencilMode.test={func:_.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:_.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,h.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs.get(t.key)||0),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(t,o){let h=this.painter,d=this.painter.context,f=d.gl;h._tileClippingMaskIDs.clear(),d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);let _=h.useProgram("clippingMask");for(let y of t){let b=--o;h._tileClippingMaskIDs.set(y.key,b),_.draw(d,f.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:f.ALWAYS,mask:0},b,255,f.KEEP,f.KEEP,f.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,ms(y.projMatrix),"$clipping",h.tileExtentBuffer,h.quadTriangleIndexBuffer,h.tileExtentSegments)}}pointCoordinate(t){let o=this.painter.transform;if(t.x<0||t.x>o.width||t.y<0||t.y>o.height)return null;let h=[t.x,t.y,1,1];a.transformMat4$1(h,h,o.pixelMatrixInverse),a.scale$1(h,h,1/h[3]),h[0]/=o.worldSize,h[1]/=o.worldSize;let d=o._camera.position,f=a.mercatorZfromAltitude(1,o.center.lat),_=[d[0],d[1],d[2]/f,0],y=a.subtract([],h.slice(0,3),_);a.normalize(y,y);let b=this.raycast(_,y,this._exaggeration);return b!==null&&b?(a.scaleAndAdd(_,_,y,b),_[3]=_[2],_[2]*=f,_):null}drawDepth(){let t=this.painter,o=t.context,h=this.proxySourceCache,d=Math.ceil(t.width),f=Math.ceil(t.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){let _=o.gl,y=o.createFramebuffer(d,f,!0);o.activeTexture.set(_.TEXTURE0);let b=new a.Texture(o,{width:d,height:f,data:null},_.RGBA);b.bind(_.NEAREST,_.CLAMP_TO_EDGE),y.colorAttachment.set(b.texture);let T=o.createRenderbuffer(o.gl.DEPTH_COMPONENT16,d,f);y.depthAttachment.set(T),this._depthFBO=y,this._depthTexture=b}o.bindFramebuffer.set(this._depthFBO.framebuffer),o.viewport.set([0,0,d,f]),function(_,y,b,T){if(_.transform.projection.name==="globe")return;let E=_.context,M=E.gl;E.clear({depth:1});let D=_.useProgram("terrainDepth"),B=new a.DepthMode(M.LESS,a.DepthMode.ReadWrite,_.depthRangeFor3D);for(let P of T){let z=b.getTile(P),G=Cl(P.projMatrix,0);y.setupElevationDraw(z,D),D.draw(E,M.TRIANGLES,B,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,G,"terrain_depth",y.gridBuffer,y.gridIndexBuffer,y.gridNoSkirtSegments)}}(t,this,h,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,o,h){if(t.getSource()instanceof W)return this._setupProxiedCoordsForImageSource(t,o,h);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};let d=this.proxiedCoords[t.id]=[],f=this.proxyCoords;for(let y=0;y<f.length;y++){let b=f[y],T=this._findTileCoveringTileID(b,t);if(T){let E=this._createProxiedId(b,T,h[b.key]&&h[b.key][t.id]);d.push(E),this.proxyToSource[b.key][t.id]=[E]}}let _=!1;for(let y=0;y<o.length;y++){let b=t.getTile(o[y]);if(!b||!b.hasData())continue;let T=this._findTileCoveringTileID(b.tileID,this.proxySourceCache);if(T&&T.tileID.canonical.z!==b.tileID.canonical.z){let E=this.proxyToSource[T.tileID.key][t.id],M=this._createProxiedId(T.tileID,b,h[T.tileID.key]&&h[T.tileID.key][t.id]);E?E.splice(E.length-1,0,M):this.proxyToSource[T.tileID.key][t.id]=[M],d.push(M),_=!0}}this._sourceTilesOverlap[t.id]=_}_setupProxiedCoordsForImageSource(t,o,h){if(!t.getSource().loaded())return;let d=this.proxiedCoords[t.id]=[],f=this.proxyCoords,_=t.getSource(),y=new a.pointGeometry(_.tileID.x,_.tileID.y)._div(1<<_.tileID.z),b=_.coordinates.map(a.MercatorCoordinate.fromLngLat).reduce((E,M)=>(E.min.x=Math.min(E.min.x,M.x-y.x),E.min.y=Math.min(E.min.y,M.y-y.y),E.max.x=Math.max(E.max.x,M.x-y.x),E.max.y=Math.max(E.max.y,M.y-y.y),E),{min:new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),T=(E,M)=>{let D=E.wrap+E.canonical.x/(1<<E.canonical.z),B=E.canonical.y/(1<<E.canonical.z),P=a.EXTENT/(1<<E.canonical.z),z=M.wrap+M.canonical.x/(1<<M.canonical.z),G=M.canonical.y/(1<<M.canonical.z);return D+P<z+b.min.x||D>z+b.max.x||B+P<G+b.min.y||B>G+b.max.y};for(let E=0;E<f.length;E++){let M=f[E];for(let D=0;D<o.length;D++){let B=t.getTile(o[D]);if(!B||!B.hasData()||T(M,B.tileID))continue;let P=this._createProxiedId(M,B,h[M.key]&&h[M.key][t.id]),z=this.proxyToSource[M.key][t.id];z?z.push(P):this.proxyToSource[M.key][t.id]=[P],d.push(P)}}}_createProxiedId(t,o,h){let d=this.orthoMatrix;if(h){let f=h.find(_=>_.key===o.tileID.key);if(f)return f}if(o.tileID.key!==t.key){let f=t.canonical.z-o.tileID.canonical.z,_,y,b;d=a.create();let T=o.tileID.wrap-t.wrap<<t.overscaledZ;f>0?(_=a.EXTENT>>f,y=_*((o.tileID.canonical.x<<f)-t.canonical.x+T),b=_*((o.tileID.canonical.y<<f)-t.canonical.y)):(_=a.EXTENT<<-f,y=a.EXTENT*(o.tileID.canonical.x-(t.canonical.x+T<<-f)),b=a.EXTENT*(o.tileID.canonical.y-(t.canonical.y<<-f))),a.ortho(d,0,_,0,_,0,1),a.translate(d,d,[y,b,0])}return new da(o.tileID,t.key,d)}_findTileCoveringTileID(t,o){let h=o.getTile(t);if(h&&h.hasData())return h;let d=this._findCoveringTileCache[o.id],f=d[t.key];if(h=f?o.getTileByID(f):null,h&&h.hasData()||f===null)return h;let _=h?h.tileID:t,y=_.overscaledZ,b=o.getSource().minzoom,T=[];if(!f){let M=o.getSource().maxzoom;if(t.canonical.z>=M){let D=t.canonical.z-M;o.getSource().reparseOverscaled?(y=Math.max(t.canonical.z+2,o.transform.tileZoom),_=new a.OverscaledTileID(y,t.wrap,M,t.canonical.x>>D,t.canonical.y>>D)):D!==0&&(y=M,_=new a.OverscaledTileID(y,t.wrap,M,t.canonical.x>>D,t.canonical.y>>D))}_.key!==t.key&&(T.push(_.key),h=o.getTile(_))}let E=M=>{T.forEach(D=>{d[D]=M}),T.length=0};for(y-=1;y>=b&&(!h||!h.hasData());y--){h&&E(h.tileID.key);let M=_.calculateScaledKey(y);if(h=o.getTileByID(M),h&&h.hasData())break;let D=d[M];if(D===null)break;D===void 0?T.push(M):h=o.getTileByID(D)}return E(h?h.tileID.key:null),h&&h.hasData()?h:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,o){let h=this._tilesDirty[t];h||(h=this._tilesDirty[t]={}),h[o.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){let t=function(o){let h=0,d=new a.StructArrayLayout2ui4,f=131;for(let _=1;_<129;_++){for(let y=1;y<129;y++)h=_*f+y,d.emplaceBack(h,h+1),d.emplaceBack(h,h+f),d.emplaceBack(h+1,h+f),_===128&&d.emplaceBack(h+f,h+f+1);d.emplaceBack(h+1,h+1+f)}return d}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function _s(l){let t=[];for(let o=0;o<l.length;o++){if(l[o]===null)continue;let h=l[o].split(" ");t.push(h.pop())}return t}class To{static cacheKey(t,o,h){let d=`${t}${h?h.cacheKey:""}`;for(let f of o)d+=`/${f}`;return d}constructor(t,o,h,d,f,_){let y=t.gl;this.program=y.createProgram();let b=_s(h.staticAttributes),T=d?d.getBinderAttributes():[],E=b.concat(T),M=h.staticUniforms?_s(h.staticUniforms):[],D=d?d.getBinderUniforms():[],B=M.concat(D),P=[];for(let V of B)P.indexOf(V)<0&&P.push(V);let z=d?d.defines():[];z=z.concat(_.map(V=>`#define ${V}`));let G=z.concat(`
|
|
981
|
-
#ifdef GL_ES
|
|
982
|
-
precision mediump float;
|
|
983
|
-
#else
|
|
984
|
-
|
|
985
|
-
#if !defined(lowp)
|
|
986
|
-
#define lowp
|
|
987
|
-
#endif
|
|
988
|
-
|
|
989
|
-
#if !defined(mediump)
|
|
990
|
-
#define mediump
|
|
991
|
-
#endif
|
|
992
|
-
|
|
993
|
-
#if !defined(highp)
|
|
994
|
-
#define highp
|
|
995
|
-
#endif
|
|
996
|
-
|
|
997
|
-
#endif`,xo,ps.fragmentSource,Er.fragmentSource,h.fragmentSource).join(`
|
|
998
|
-
`),F=z.concat(`
|
|
999
|
-
#ifdef GL_ES
|
|
1000
|
-
precision highp float;
|
|
1001
|
-
#else
|
|
1002
|
-
|
|
1003
|
-
#if !defined(lowp)
|
|
1004
|
-
#define lowp
|
|
1005
|
-
#endif
|
|
1006
|
-
|
|
1007
|
-
#if !defined(mediump)
|
|
1008
|
-
#define mediump
|
|
1009
|
-
#endif
|
|
1010
|
-
|
|
1011
|
-
#if !defined(highp)
|
|
1012
|
-
#define highp
|
|
1013
|
-
#endif
|
|
1014
|
-
|
|
1015
|
-
#endif`,xo,ps.vertexSource,Er.vertexSource,sn.vertexSource,h.vertexSource).join(`
|
|
1016
|
-
`),j=y.createShader(y.FRAGMENT_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(j,G),y.compileShader(j),y.attachShader(this.program,j);let N=y.createShader(y.VERTEX_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(N,F),y.compileShader(N),y.attachShader(this.program,N),this.attributes={};let $={};this.numAttributes=E.length;for(let V=0;V<this.numAttributes;V++)E[V]&&(y.bindAttribLocation(this.program,V,E[V]),this.attributes[E[V]]=V);y.linkProgram(this.program),y.deleteShader(N),y.deleteShader(j);for(let V=0;V<P.length;V++){let X=P[V];if(X&&!$[X]){let ie=y.getUniformLocation(this.program,X);ie&&($[X]=ie)}}this.fixedUniforms=f(t,$),this.binderUniforms=d?d.getUniforms(t,$):[],_.indexOf("TERRAIN")!==-1&&(this.terrainUniforms=((V,X)=>({u_dem:new a.Uniform1i(V,X.u_dem),u_dem_prev:new a.Uniform1i(V,X.u_dem_prev),u_dem_unpack:new a.Uniform4f(V,X.u_dem_unpack),u_dem_tl:new a.Uniform2f(V,X.u_dem_tl),u_dem_scale:new a.Uniform1f(V,X.u_dem_scale),u_dem_tl_prev:new a.Uniform2f(V,X.u_dem_tl_prev),u_dem_scale_prev:new a.Uniform1f(V,X.u_dem_scale_prev),u_dem_size:new a.Uniform1f(V,X.u_dem_size),u_dem_lerp:new a.Uniform1f(V,X.u_dem_lerp),u_exaggeration:new a.Uniform1f(V,X.u_exaggeration),u_depth:new a.Uniform1i(V,X.u_depth),u_depth_size_inv:new a.Uniform2f(V,X.u_depth_size_inv),u_meter_to_dem:new a.Uniform1f(V,X.u_meter_to_dem),u_label_plane_matrix_inv:new a.UniformMatrix4f(V,X.u_label_plane_matrix_inv),u_tile_tl_up:new a.Uniform3f(V,X.u_tile_tl_up),u_tile_tr_up:new a.Uniform3f(V,X.u_tile_tr_up),u_tile_br_up:new a.Uniform3f(V,X.u_tile_br_up),u_tile_bl_up:new a.Uniform3f(V,X.u_tile_bl_up),u_tile_up_scale:new a.Uniform1f(V,X.u_tile_up_scale)}))(t,$)),_.indexOf("FOG")!==-1&&(this.fogUniforms=((V,X)=>({u_fog_matrix:new a.UniformMatrix4f(V,X.u_fog_matrix),u_fog_range:new a.Uniform2f(V,X.u_fog_range),u_fog_color:new a.Uniform4f(V,X.u_fog_color),u_fog_horizon_blend:new a.Uniform1f(V,X.u_fog_horizon_blend),u_fog_temporal_offset:new a.Uniform1f(V,X.u_fog_temporal_offset)}))(t,$))}setTerrainUniformValues(t,o){if(!this.terrainUniforms)return;let h=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)h[d].set(o[d])}}setFogUniformValues(t,o){if(!this.fogUniforms)return;let h=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)h[d].location&&h[d].set(o[d])}}draw(t,o,h,d,f,_,y,b,T,E,M,D,B,P,z,G){let F=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(h),t.setStencilMode(d),t.setColorMode(f),t.setCullFace(_);for(let N of Object.keys(this.fixedUniforms))this.fixedUniforms[N].set(y[N]);P&&P.setUniforms(t,this.binderUniforms,D,{zoom:B});let j={[F.LINES]:2,[F.TRIANGLES]:3,[F.LINE_STRIP]:1}[o];for(let N of M.get()){let $=N.vaos||(N.vaos={});($[b]||($[b]=new ds)).bind(t,this,T,P?P.getPaintVertexBuffers():[],E,N.vertexOffset,z,G),F.drawElements(o,N.primitiveLength*j,F.UNSIGNED_SHORT,N.primitiveOffset*j*2)}}}function Eo(l,t,o){let h=1/Yt(o,1,t.transform.tileZoom),d=Math.pow(2,o.tileID.overscaledZ),f=o.tileSize*Math.pow(2,t.transform.tileZoom)/d,_=f*(o.tileID.canonical.x+o.tileID.wrap*d),y=f*o.tileID.canonical.y;return{u_image:0,u_texsize:o.imageAtlasTexture.size,u_scale:[h,l.fromScale,l.toScale],u_fade:l.t,u_pixel_coord_upper:[_>>16,y>>16],u_pixel_coord_lower:[65535&_,65535&y]}}let fa=a.create(),gs=(l,t,o,h,d,f,_,y,b)=>{let T=t.style.light,E=T.properties.get("position"),M=[E.x,E.y,E.z],D=a.create$1();T.properties.get("anchor")==="viewport"&&(a.fromRotation(D,-t.transform.angle),a.transformMat3(M,M,D));let B=T.properties.get("color"),P=t.transform,z={u_matrix:l,u_lightpos:M,u_lightintensity:T.properties.get("intensity"),u_lightcolor:[B.r,B.g,B.b],u_vertical_gradient:+o,u_opacity:h,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:fa,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return P.projection.name==="globe"&&(z.u_tile_id=[d.canonical.x,d.canonical.y,1<<d.canonical.z],z.u_zoom_transition=_,z.u_inv_rot_matrix=b,z.u_merc_center=y,z.u_up_dir=P.projection.upVector(new a.CanonicalTileID(0,0,0),y[0]*a.EXTENT,y[1]*a.EXTENT),z.u_height_lift=f),z},ys=(l,t,o,h,d,f,_,y,b,T,E)=>{let M=gs(l,t,o,h,d,y,b,T,E),D={u_height_factor:-Math.pow(2,d.overscaledZ)/_.tileSize/8};return a.extend(M,Eo(f,t,_),D)},xs=l=>({u_matrix:l}),vs=(l,t,o,h)=>a.extend(xs(l),Eo(o,t,h)),bs=(l,t)=>({u_matrix:l,u_world:t}),kl=(l,t,o,h,d)=>a.extend(vs(l,t,o,h),{u_world:d}),Dl=a.create(),Rn=(l,t,o,h,d,f)=>{let _=l.transform,y=_.projection.name==="globe",b;if(f.paint.get("circle-pitch-alignment")==="map")if(y){let E=a.globePixelsToTileUnits(_.zoom,t.canonical);b=Float32Array.from([E,0,0,E])}else b=_.calculatePixelsToTileUnitsMatrix(o);else b=new Float32Array([_.pixelsToGLUnits[0],0,0,_.pixelsToGLUnits[1]]);let T={u_camera_to_center_distance:_.cameraToCenterDistance,u_matrix:l.translatePosMatrix(t.projMatrix,o,f.paint.get("circle-translate"),f.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:b,u_inv_rot_matrix:Dl,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return y&&(T.u_inv_rot_matrix=h,T.u_merc_center=d,T.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],T.u_zoom_transition=a.globeToMercatorTransition(_.zoom),T.u_up_dir=_.projection.upVector(t.canonical,d[0],d[1])),T},Qc=l=>{let t=[];return l.paint.get("circle-pitch-alignment")==="map"&&t.push("PITCH_WITH_MAP"),l.paint.get("circle-pitch-scale")==="map"&&t.push("SCALE_WITH_MAP"),t},eh=(l,t,o)=>{let h=a.EXTENT/o.tileSize;return{u_matrix:l,u_camera_to_center_distance:t.cameraToCenterDistance,u_extrude_scale:[t.pixelsToGLUnits[0]/h,t.pixelsToGLUnits[1]/h]}},Pl=(l,t,o=1)=>({u_matrix:l,u_color:t,u_overlay:0,u_overlay_scale:o}),th=a.create(),ih=(l,t,o,h,d,f,_)=>{let y=l.transform,b=y.projection.name==="globe",T=b?a.globePixelsToTileUnits(y.zoom,t.canonical):Yt(o,1,f),E={u_matrix:t.projMatrix,u_extrude_scale:T,u_intensity:_,u_inv_rot_matrix:th,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return b&&(E.u_inv_rot_matrix=h,E.u_merc_center=d,E.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],E.u_zoom_transition=a.globeToMercatorTransition(y.zoom),E.u_up_dir=y.projection.upVector(t.canonical,d[0],d[1])),E},rh=(l,t,o,h,d,f,_)=>{let y=l.transform,b=y.calculatePixelsToTileUnitsMatrix(t),T={u_matrix:an(l,t,o,d),u_pixels_to_tile_units:b,u_device_pixel_ratio:_,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:f,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(_a(o)){let E=ws(t,l.transform);T.u_texsize=t.lineAtlasTexture.size,T.u_scale=[E,h.fromScale,h.toScale],T.u_mix=h.t}return T},ma=(l,t,o,h,d,f)=>{let _=l.transform,y=ws(t,_);return{u_matrix:an(l,t,o,d),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:_.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:f,u_image:0,u_scale:[y,h.fromScale,h.toScale],u_fade:h.t,u_units_to_pixels:[1/_.pixelsToGLUnits[0],1/_.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function ws(l,t){return 1/Yt(l,1,t.tileZoom)}function an(l,t,o,h){return l.translatePosMatrix(h||t.tileID.projMatrix,t,o.paint.get("line-translate"),o.paint.get("line-translate-anchor"))}function _a(l){let t=l.paint.get("line-dasharray").value;return t.value||t.kind!=="constant"}let Ll=(l,t,o,h,d,f)=>{return{u_matrix:l,u_tl_parent:t,u_scale_parent:o,u_fade_t:h.mix,u_opacity:h.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:(_=d.paint.get("raster-contrast"),_>0?1/(1-_):1+_),u_spin_weights:ga(d.paint.get("raster-hue-rotate")),u_perspective_transform:f};var _,y};function ga(l){l*=Math.PI/180;let t=Math.sin(l),o=Math.cos(l);return[(2*o+1)/3,(-Math.sqrt(3)*t-o+1)/3,(Math.sqrt(3)*t-o+1)/3]}let Ir=a.create(),ya=(l,t,o,h,d,f,_,y,b,T,E,M,D,B)=>{let P=d.transform,z={u_is_size_zoom_constant:+(l==="constant"||l==="source"),u_is_size_feature_constant:+(l==="constant"||l==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:P.cameraToCenterDistance,u_rotate_symbol:+o,u_aspect_ratio:P.width/P.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:f,u_label_plane_matrix:_,u_coord_matrix:y,u_is_text:+b,u_pitch_with_map:+h,u_texsize:T,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ir,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Ir};return P.projection.name==="globe"&&(z.u_tile_id=[E.canonical.x,E.canonical.y,1<<E.canonical.z],z.u_zoom_transition=M,z.u_inv_rot_matrix=B,z.u_merc_center=D,z.u_camera_forward=P._camera.forward(),z.u_ecef_origin=a.globeECEFOrigin(P.globeMatrix,E.toUnwrapped()),z.u_tile_matrix=Float32Array.from(P.globeMatrix)),z},ln=(l,t,o,h,d,f,_,y,b,T,E,M,D,B,P)=>{let{cameraToCenterDistance:z,_pitch:G}=d.transform;return a.extend(ya(l,t,o,h,d,f,_,y,b,T,M,D,B,P),{u_gamma_scale:h?z*Math.cos(d.terrain?0:G):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+E})},Fn=(l,t,o,h,d,f,_,y,b,T,E,M,D,B)=>a.extend(ln(l,t,o,h,d,f,_,y,!0,b,!0,E,M,D,B),{u_texsize_icon:T,u_texture_icon:1}),Bl=(l,t,o)=>({u_matrix:l,u_opacity:t,u_color:o}),xa=(l,t,o,h,d,f)=>a.extend(function(_,y,b,T){let E=b.imageManager.getPattern(_.from.toString()),M=b.imageManager.getPattern(_.to.toString()),{width:D,height:B}=b.imageManager.getPixelSize(),P=Math.pow(2,T.tileID.overscaledZ),z=T.tileSize*Math.pow(2,b.transform.tileZoom)/P,G=z*(T.tileID.canonical.x+T.tileID.wrap*P),F=z*T.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:E.tl,u_pattern_br_a:E.br,u_pattern_tl_b:M.tl,u_pattern_br_b:M.br,u_texsize:[D,B],u_mix:y.t,u_pattern_size_a:E.displaySize,u_pattern_size_b:M.displaySize,u_scale_a:y.fromScale,u_scale_b:y.toScale,u_tile_units_to_pixels:1/Yt(T,1,b.transform.tileZoom),u_pixel_coord_upper:[G>>16,F>>16],u_pixel_coord_lower:[65535&G,65535&F]}}(h,f,o,d),{u_matrix:l,u_opacity:t}),gt={fillExtrusion:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_lightpos:new a.Uniform3f(l,t.u_lightpos),u_lightintensity:new a.Uniform1f(l,t.u_lightintensity),u_lightcolor:new a.Uniform3f(l,t.u_lightcolor),u_vertical_gradient:new a.Uniform1f(l,t.u_vertical_gradient),u_opacity:new a.Uniform1f(l,t.u_opacity),u_tile_id:new a.Uniform3f(l,t.u_tile_id),u_zoom_transition:new a.Uniform1f(l,t.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(l,t.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(l,t.u_merc_center),u_up_dir:new a.Uniform3f(l,t.u_up_dir),u_height_lift:new a.Uniform1f(l,t.u_height_lift)}),fillExtrusionPattern:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_lightpos:new a.Uniform3f(l,t.u_lightpos),u_lightintensity:new a.Uniform1f(l,t.u_lightintensity),u_lightcolor:new a.Uniform3f(l,t.u_lightcolor),u_vertical_gradient:new a.Uniform1f(l,t.u_vertical_gradient),u_height_factor:new a.Uniform1f(l,t.u_height_factor),u_tile_id:new a.Uniform3f(l,t.u_tile_id),u_zoom_transition:new a.Uniform1f(l,t.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(l,t.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(l,t.u_merc_center),u_up_dir:new a.Uniform3f(l,t.u_up_dir),u_height_lift:new a.Uniform1f(l,t.u_height_lift),u_image:new a.Uniform1i(l,t.u_image),u_texsize:new a.Uniform2f(l,t.u_texsize),u_pixel_coord_upper:new a.Uniform2f(l,t.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(l,t.u_pixel_coord_lower),u_scale:new a.Uniform3f(l,t.u_scale),u_fade:new a.Uniform1f(l,t.u_fade),u_opacity:new a.Uniform1f(l,t.u_opacity)}),fill:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix)}),fillPattern:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_image:new a.Uniform1i(l,t.u_image),u_texsize:new a.Uniform2f(l,t.u_texsize),u_pixel_coord_upper:new a.Uniform2f(l,t.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(l,t.u_pixel_coord_lower),u_scale:new a.Uniform3f(l,t.u_scale),u_fade:new a.Uniform1f(l,t.u_fade)}),fillOutline:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_world:new a.Uniform2f(l,t.u_world)}),fillOutlinePattern:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_world:new a.Uniform2f(l,t.u_world),u_image:new a.Uniform1i(l,t.u_image),u_texsize:new a.Uniform2f(l,t.u_texsize),u_pixel_coord_upper:new a.Uniform2f(l,t.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(l,t.u_pixel_coord_lower),u_scale:new a.Uniform3f(l,t.u_scale),u_fade:new a.Uniform1f(l,t.u_fade)}),circle:(l,t)=>({u_camera_to_center_distance:new a.Uniform1f(l,t.u_camera_to_center_distance),u_extrude_scale:new a.UniformMatrix2f(l,t.u_extrude_scale),u_device_pixel_ratio:new a.Uniform1f(l,t.u_device_pixel_ratio),u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_inv_rot_matrix:new a.UniformMatrix4f(l,t.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(l,t.u_merc_center),u_tile_id:new a.Uniform3f(l,t.u_tile_id),u_zoom_transition:new a.Uniform1f(l,t.u_zoom_transition),u_up_dir:new a.Uniform3f(l,t.u_up_dir)}),collisionBox:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_camera_to_center_distance:new a.Uniform1f(l,t.u_camera_to_center_distance),u_extrude_scale:new a.Uniform2f(l,t.u_extrude_scale)}),collisionCircle:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_inv_matrix:new a.UniformMatrix4f(l,t.u_inv_matrix),u_camera_to_center_distance:new a.Uniform1f(l,t.u_camera_to_center_distance),u_viewport_size:new a.Uniform2f(l,t.u_viewport_size)}),debug:(l,t)=>({u_color:new a.UniformColor(l,t.u_color),u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_overlay:new a.Uniform1i(l,t.u_overlay),u_overlay_scale:new a.Uniform1f(l,t.u_overlay_scale)}),clippingMask:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix)}),heatmap:(l,t)=>({u_extrude_scale:new a.Uniform1f(l,t.u_extrude_scale),u_intensity:new a.Uniform1f(l,t.u_intensity),u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_inv_rot_matrix:new a.UniformMatrix4f(l,t.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(l,t.u_merc_center),u_tile_id:new a.Uniform3f(l,t.u_tile_id),u_zoom_transition:new a.Uniform1f(l,t.u_zoom_transition),u_up_dir:new a.Uniform3f(l,t.u_up_dir)}),heatmapTexture:(l,t)=>({u_image:new a.Uniform1i(l,t.u_image),u_color_ramp:new a.Uniform1i(l,t.u_color_ramp),u_opacity:new a.Uniform1f(l,t.u_opacity)}),hillshade:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_image:new a.Uniform1i(l,t.u_image),u_latrange:new a.Uniform2f(l,t.u_latrange),u_light:new a.Uniform2f(l,t.u_light),u_shadow:new a.UniformColor(l,t.u_shadow),u_highlight:new a.UniformColor(l,t.u_highlight),u_accent:new a.UniformColor(l,t.u_accent)}),hillshadePrepare:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_image:new a.Uniform1i(l,t.u_image),u_dimension:new a.Uniform2f(l,t.u_dimension),u_zoom:new a.Uniform1f(l,t.u_zoom),u_unpack:new a.Uniform4f(l,t.u_unpack)}),line:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_pixels_to_tile_units:new a.UniformMatrix2f(l,t.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(l,t.u_device_pixel_ratio),u_units_to_pixels:new a.Uniform2f(l,t.u_units_to_pixels),u_dash_image:new a.Uniform1i(l,t.u_dash_image),u_gradient_image:new a.Uniform1i(l,t.u_gradient_image),u_image_height:new a.Uniform1f(l,t.u_image_height),u_texsize:new a.Uniform2f(l,t.u_texsize),u_scale:new a.Uniform3f(l,t.u_scale),u_mix:new a.Uniform1f(l,t.u_mix),u_alpha_discard_threshold:new a.Uniform1f(l,t.u_alpha_discard_threshold)}),linePattern:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_texsize:new a.Uniform2f(l,t.u_texsize),u_pixels_to_tile_units:new a.UniformMatrix2f(l,t.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(l,t.u_device_pixel_ratio),u_image:new a.Uniform1i(l,t.u_image),u_units_to_pixels:new a.Uniform2f(l,t.u_units_to_pixels),u_scale:new a.Uniform3f(l,t.u_scale),u_fade:new a.Uniform1f(l,t.u_fade),u_alpha_discard_threshold:new a.Uniform1f(l,t.u_alpha_discard_threshold)}),raster:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_tl_parent:new a.Uniform2f(l,t.u_tl_parent),u_scale_parent:new a.Uniform1f(l,t.u_scale_parent),u_fade_t:new a.Uniform1f(l,t.u_fade_t),u_opacity:new a.Uniform1f(l,t.u_opacity),u_image0:new a.Uniform1i(l,t.u_image0),u_image1:new a.Uniform1i(l,t.u_image1),u_brightness_low:new a.Uniform1f(l,t.u_brightness_low),u_brightness_high:new a.Uniform1f(l,t.u_brightness_high),u_saturation_factor:new a.Uniform1f(l,t.u_saturation_factor),u_contrast_factor:new a.Uniform1f(l,t.u_contrast_factor),u_spin_weights:new a.Uniform3f(l,t.u_spin_weights),u_perspective_transform:new a.Uniform2f(l,t.u_perspective_transform)}),symbolIcon:(l,t)=>({u_is_size_zoom_constant:new a.Uniform1i(l,t.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(l,t.u_is_size_feature_constant),u_size_t:new a.Uniform1f(l,t.u_size_t),u_size:new a.Uniform1f(l,t.u_size),u_camera_to_center_distance:new a.Uniform1f(l,t.u_camera_to_center_distance),u_rotate_symbol:new a.Uniform1i(l,t.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(l,t.u_aspect_ratio),u_fade_change:new a.Uniform1f(l,t.u_fade_change),u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(l,t.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(l,t.u_coord_matrix),u_is_text:new a.Uniform1i(l,t.u_is_text),u_pitch_with_map:new a.Uniform1i(l,t.u_pitch_with_map),u_texsize:new a.Uniform2f(l,t.u_texsize),u_tile_id:new a.Uniform3f(l,t.u_tile_id),u_zoom_transition:new a.Uniform1f(l,t.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(l,t.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(l,t.u_merc_center),u_camera_forward:new a.Uniform3f(l,t.u_camera_forward),u_tile_matrix:new a.UniformMatrix4f(l,t.u_tile_matrix),u_ecef_origin:new a.Uniform3f(l,t.u_ecef_origin),u_texture:new a.Uniform1i(l,t.u_texture)}),symbolSDF:(l,t)=>({u_is_size_zoom_constant:new a.Uniform1i(l,t.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(l,t.u_is_size_feature_constant),u_size_t:new a.Uniform1f(l,t.u_size_t),u_size:new a.Uniform1f(l,t.u_size),u_camera_to_center_distance:new a.Uniform1f(l,t.u_camera_to_center_distance),u_rotate_symbol:new a.Uniform1i(l,t.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(l,t.u_aspect_ratio),u_fade_change:new a.Uniform1f(l,t.u_fade_change),u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(l,t.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(l,t.u_coord_matrix),u_is_text:new a.Uniform1i(l,t.u_is_text),u_pitch_with_map:new a.Uniform1i(l,t.u_pitch_with_map),u_texsize:new a.Uniform2f(l,t.u_texsize),u_texture:new a.Uniform1i(l,t.u_texture),u_gamma_scale:new a.Uniform1f(l,t.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(l,t.u_device_pixel_ratio),u_tile_id:new a.Uniform3f(l,t.u_tile_id),u_zoom_transition:new a.Uniform1f(l,t.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(l,t.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(l,t.u_merc_center),u_camera_forward:new a.Uniform3f(l,t.u_camera_forward),u_tile_matrix:new a.UniformMatrix4f(l,t.u_tile_matrix),u_ecef_origin:new a.Uniform3f(l,t.u_ecef_origin),u_is_halo:new a.Uniform1i(l,t.u_is_halo)}),symbolTextAndIcon:(l,t)=>({u_is_size_zoom_constant:new a.Uniform1i(l,t.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(l,t.u_is_size_feature_constant),u_size_t:new a.Uniform1f(l,t.u_size_t),u_size:new a.Uniform1f(l,t.u_size),u_camera_to_center_distance:new a.Uniform1f(l,t.u_camera_to_center_distance),u_rotate_symbol:new a.Uniform1i(l,t.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(l,t.u_aspect_ratio),u_fade_change:new a.Uniform1f(l,t.u_fade_change),u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(l,t.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(l,t.u_coord_matrix),u_is_text:new a.Uniform1i(l,t.u_is_text),u_pitch_with_map:new a.Uniform1i(l,t.u_pitch_with_map),u_texsize:new a.Uniform2f(l,t.u_texsize),u_texsize_icon:new a.Uniform2f(l,t.u_texsize_icon),u_texture:new a.Uniform1i(l,t.u_texture),u_texture_icon:new a.Uniform1i(l,t.u_texture_icon),u_gamma_scale:new a.Uniform1f(l,t.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(l,t.u_device_pixel_ratio),u_is_halo:new a.Uniform1i(l,t.u_is_halo)}),background:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_opacity:new a.Uniform1f(l,t.u_opacity),u_color:new a.UniformColor(l,t.u_color)}),backgroundPattern:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_opacity:new a.Uniform1f(l,t.u_opacity),u_image:new a.Uniform1i(l,t.u_image),u_pattern_tl_a:new a.Uniform2f(l,t.u_pattern_tl_a),u_pattern_br_a:new a.Uniform2f(l,t.u_pattern_br_a),u_pattern_tl_b:new a.Uniform2f(l,t.u_pattern_tl_b),u_pattern_br_b:new a.Uniform2f(l,t.u_pattern_br_b),u_texsize:new a.Uniform2f(l,t.u_texsize),u_mix:new a.Uniform1f(l,t.u_mix),u_pattern_size_a:new a.Uniform2f(l,t.u_pattern_size_a),u_pattern_size_b:new a.Uniform2f(l,t.u_pattern_size_b),u_scale_a:new a.Uniform1f(l,t.u_scale_a),u_scale_b:new a.Uniform1f(l,t.u_scale_b),u_pixel_coord_upper:new a.Uniform2f(l,t.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(l,t.u_pixel_coord_lower),u_tile_units_to_pixels:new a.Uniform1f(l,t.u_tile_units_to_pixels)}),terrainRaster:ha,terrainDepth:ha,skybox:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_sun_direction:new a.Uniform3f(l,t.u_sun_direction),u_cubemap:new a.Uniform1i(l,t.u_cubemap),u_opacity:new a.Uniform1f(l,t.u_opacity),u_temporal_offset:new a.Uniform1f(l,t.u_temporal_offset)}),skyboxGradient:(l,t)=>({u_matrix:new a.UniformMatrix4f(l,t.u_matrix),u_color_ramp:new a.Uniform1i(l,t.u_color_ramp),u_center_direction:new a.Uniform3f(l,t.u_center_direction),u_radius:new a.Uniform1f(l,t.u_radius),u_opacity:new a.Uniform1f(l,t.u_opacity),u_temporal_offset:new a.Uniform1f(l,t.u_temporal_offset)}),skyboxCapture:(l,t)=>({u_matrix_3f:new a.UniformMatrix3f(l,t.u_matrix_3f),u_sun_direction:new a.Uniform3f(l,t.u_sun_direction),u_sun_intensity:new a.Uniform1f(l,t.u_sun_intensity),u_color_tint_r:new a.Uniform4f(l,t.u_color_tint_r),u_color_tint_m:new a.Uniform4f(l,t.u_color_tint_m),u_luminance:new a.Uniform1f(l,t.u_luminance)}),globeRaster:(l,t)=>({u_proj_matrix:new a.UniformMatrix4f(l,t.u_proj_matrix),u_globe_matrix:new a.UniformMatrix4f(l,t.u_globe_matrix),u_merc_matrix:new a.UniformMatrix4f(l,t.u_merc_matrix),u_zoom_transition:new a.Uniform1f(l,t.u_zoom_transition),u_merc_center:new a.Uniform2f(l,t.u_merc_center),u_image0:new a.Uniform1i(l,t.u_image0),u_grid_matrix:new a.UniformMatrix3f(l,t.u_grid_matrix)}),globeAtmosphere:(l,t)=>({u_frustum_tl:new a.Uniform3f(l,t.u_frustum_tl),u_frustum_tr:new a.Uniform3f(l,t.u_frustum_tr),u_frustum_br:new a.Uniform3f(l,t.u_frustum_br),u_frustum_bl:new a.Uniform3f(l,t.u_frustum_bl),u_globe_pos:new a.Uniform3f(l,t.u_globe_pos),u_globe_radius:new a.Uniform1f(l,t.u_globe_radius),u_opacity:new a.Uniform1f(l,t.u_opacity),u_fadeout_range:new a.Uniform1f(l,t.u_fadeout_range),u_start_color:new a.Uniform3f(l,t.u_start_color),u_end_color:new a.Uniform3f(l,t.u_end_color)})},cn;function Rl(l,t,o,h,d,f,_){let y=l.context,b=y.gl,T=l.useProgram("collisionBox"),E=[],M=0,D=0;for(let N=0;N<h.length;N++){let $=h[N],V=t.getTile($),X=V.getBucket(o);if(!X)continue;let ie=$.projMatrix;d[0]===0&&d[1]===0||(ie=l.translatePosMatrix($.projMatrix,V,d,f));let ae=_?X.textCollisionBox:X.iconCollisionBox,ue=X.collisionCircleArray;if(ue.length>0){let ce=a.create(),we=ie;a.mul(ce,X.placementInvProjMatrix,l.transform.glCoordMatrix),a.mul(ce,ce,X.placementViewportMatrix),E.push({circleArray:ue,circleOffset:D,transform:we,invTransform:ce}),M+=ue.length/4,D=M}ae&&(l.terrain&&l.terrain.setupElevationDraw(V,T),T.draw(y,b.LINES,a.DepthMode.disabled,a.StencilMode.disabled,l.colorModeForRenderPass(),a.CullFaceMode.disabled,eh(ie,l.transform,V),o.id,ae.layoutVertexBuffer,ae.indexBuffer,ae.segments,null,l.transform.zoom,null,ae.collisionVertexBuffer,ae.collisionVertexBufferExt))}if(!_||!E.length)return;let B=l.useProgram("collisionCircle"),P=new a.StructArrayLayout2f1f2i16;P.resize(4*M),P._trim();let z=0;for(let N of E)for(let $=0;$<N.circleArray.length/4;$++){let V=4*$,X=N.circleArray[V+0],ie=N.circleArray[V+1],ae=N.circleArray[V+2],ue=N.circleArray[V+3];P.emplace(z++,X,ie,ae,ue,0),P.emplace(z++,X,ie,ae,ue,1),P.emplace(z++,X,ie,ae,ue,2),P.emplace(z++,X,ie,ae,ue,3)}(!cn||cn.length<2*M)&&(cn=function(N){let $=2*N,V=new a.StructArrayLayout3ui6;V.resize($),V._trim();for(let X=0;X<$;X++){let ie=6*X;V.uint16[ie+0]=4*X+0,V.uint16[ie+1]=4*X+1,V.uint16[ie+2]=4*X+2,V.uint16[ie+3]=4*X+2,V.uint16[ie+4]=4*X+3,V.uint16[ie+5]=4*X+0}return V}(M));let G=y.createIndexBuffer(cn,!0),F=y.createVertexBuffer(P,a.collisionCircleLayout.members,!0);for(let N of E){let $={u_matrix:N.transform,u_inv_matrix:N.invTransform,u_camera_to_center_distance:(j=l.transform).cameraToCenterDistance,u_viewport_size:[j.width,j.height]};B.draw(y,b.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,l.colorModeForRenderPass(),a.CullFaceMode.disabled,$,o.id,F,G,a.SegmentVector.simpleSegment(0,2*N.circleOffset,N.circleArray.length,N.circleArray.length/2),null,l.transform.zoom,null,null,null)}var j;F.destroy(),G.destroy()}let va=a.create();function So(l,t,o,h,d,f){let{horizontalAlign:_,verticalAlign:y}=a.getAnchorAlignment(l),b=-(_-.5)*t,T=-(y-.5)*o,E=a.evaluateVariableOffset(l,h);return new a.pointGeometry((b/d+E[0])*f,(T/d+E[1])*f)}function nh(l,t,o,h,d,f,_,y,b,T,E,M){let D=l.text.placedSymbolArray,B=l.text.dynamicLayoutVertexArray,P=l.icon.dynamicLayoutVertexArray,z={},G=y.projMatrix,F=f.elevation,j=M.upVectorScale(y.canonical,f.center.lat,f.worldSize);B.clear();for(let N=0;N<D.length;N++){let $=D.get(N),V=l.allowVerticalPlacement&&!$.placedOrientation,X=$.hidden||!$.crossTileID||V?null:h[$.crossTileID];if(X){let ie=new a.pointGeometry($.tileAnchorX,$.tileAnchorY),ae=M.upVector(y.canonical,ie.x,ie.y),ue=F?F.getAtTileOffset(y,ie.x,ie.y):0,ce=Ei([$.projectedAnchorX+ue*ae[0]*j.metersToTile,$.projectedAnchorY+ue*ae[1]*j.metersToTile,$.projectedAnchorZ+ue*ae[2]*j.metersToTile],o?G:_),we=Mt(f.cameraToCenterDistance,ce.signedDistanceFromCamera),re=d.evaluateSizeForFeature(l.textSizeData,T,$)*we/a.ONE_EM;o&&(re*=l.tilePixelRatio/b);let{width:Te,height:ve,anchor:Le,textOffset:pe,textScale:ke}=X,Ve=So(Le,Te,ve,pe,ke,re),De=o?ti(ie.add(Ve),_,ue*j.metersToLabelSpace).point:ce.point.add(t?Ve.rotate(-f.angle):Ve),Pe=l.allowVerticalPlacement&&$.placedOrientation===a.WritingMode.vertical?Math.PI/2:0;for(let Ze=0;Ze<$.numGlyphs;Ze++)a.addDynamicAttributes(B,De,Pe);E&&$.associatedIconIndex>=0&&(z[$.associatedIconIndex]={shiftedAnchor:De,angle:Pe})}else Ut($.numGlyphs,B)}if(E){P.clear();let N=l.icon.placedSymbolArray;for(let $=0;$<N.length;$++){let V=N.get($);if(V.hidden)Ut(V.numGlyphs,P);else{let X=z[$];if(X)for(let ie=0;ie<V.numGlyphs;ie++)a.addDynamicAttributes(P,X.shiftedAnchor,X.angle);else Ut(V.numGlyphs,P)}}l.icon.dynamicLayoutVertexBuffer.updateData(P)}l.text.dynamicLayoutVertexBuffer.updateData(B)}function oh(l,t,o){return o.iconsInText&&t?"symbolTextAndIcon":l?"symbolSDF":"symbolIcon"}function ba(l,t,o,h,d,f,_,y,b,T,E,M){let D=l.context,B=D.gl,P=l.transform,z=y==="map",G=b==="map",F=z&&o.layout.get("symbol-placement")!=="point",j=z&&!G&&!F,N=o.layout.get("symbol-sort-key").constantOr(1)!==void 0,$=!1,V=l.depthModeForSublayer(0,a.DepthMode.ReadOnly),X=[a.mercatorXfromLng(P.center.lng),a.mercatorYfromLat(P.center.lat)],ie=o.layout.get("text-variable-anchor"),ae=P.projection.name==="globe",ue=ae?a.globeToMercatorTransition(P.zoom):0,ce=[],we=[];l.terrain&&G&&we.push("PITCH_WITH_MAP_TERRAIN"),ae&&we.push("PROJECTION_GLOBE_VIEW");for(let re of h){let Te=t.getTile(re),ve=Te.getBucket(o);if(!ve||ve.projection!==P.projection.name)continue;let Le=d?ve.text:ve.icon;if(!Le||ve.fullyClipped||!Le.segments.get().length)continue;let pe=Le.programConfigurations.get(o.id),ke=d||ve.sdfIcons,Ve=d?ve.textSizeData:ve.iconSizeData,De=G||P.pitch!==0,Pe=a.evaluateSizeForZoom(Ve,P.zoom),Ze,Ye,Fe,qe,st=[0,0],At=null;if(d){if(Ye=Te.glyphAtlasTexture,Fe=B.LINEAR,Ze=Te.glyphAtlasTexture.size,ve.iconsInText){st=Te.imageAtlasTexture.size,At=Te.imageAtlasTexture;let xi=Ve.kind==="composite"||Ve.kind==="camera";qe=De||l.options.rotating||l.options.zooming||xi?B.LINEAR:B.NEAREST}}else{let xi=o.layout.get("icon-size").constantOr(0)!==1||ve.iconsNeedLinear;Ye=Te.imageAtlasTexture,Fe=ke||l.options.rotating||l.options.zooming||xi||De?B.LINEAR:B.NEAREST,Ze=Te.imageAtlasTexture.size}let Kt=l.transform.calculatePixelsToTileUnitsMatrix(Te),Jt=nn(re.projMatrix,Te.tileID.canonical,G,z,l.transform,Kt),gi=l.terrain&&G&&F?a.invert(a.create(),Jt):va,$i=zn(re.projMatrix,Te.tileID.canonical,G,z,l.transform,Kt),hr=ie&&ve.hasTextData(),Dr=o.layout.get("icon-text-fit")!=="none"&&hr&&ve.hasIconData();if(F){let xi=P.elevation,un=xi?xi.getAtTileOffsetFunc(re,P.center.lat,P.worldSize,P.projection):pc=>[0,0,0];mo(ve,re.projMatrix,l,d,Jt,$i,G,T,un,re)}let ur=F||d&&ie||Dr,zt=l.translatePosMatrix(re.projMatrix,Te,f,_),Dt=ur?va:Jt,ft=l.translatePosMatrix($i,Te,f,_,!0),Rt=P.projection.createInversionMatrix(P,re.canonical),yi=ur?we.concat(["PROJECTED_POS_ON_VIEWPORT"]):we,Ct=ke&&o.paint.get(d?"text-halo-width":"icon-halo-width").constantOr(1)!==0,Mi;Mi=ke?ve.iconsInText?Fn(Ve.kind,Pe,j,G,l,zt,Dt,ft,Ze,st,re,ue,X,Rt):ln(Ve.kind,Pe,j,G,l,zt,Dt,ft,d,Ze,!0,re,ue,X,Rt):ya(Ve.kind,Pe,j,G,l,zt,Dt,ft,d,Ze,re,ue,X,Rt);let jo={program:l.useProgram(oh(ke,d,ve),pe,yi),buffers:Le,uniformValues:Mi,atlasTexture:Ye,atlasTextureIcon:At,atlasInterpolation:Fe,atlasInterpolationIcon:qe,isSDF:ke,hasHalo:Ct,tile:Te,labelPlaneMatrixInv:gi};if(N&&ve.canOverlap){$=!0;let xi=Le.segments.get();for(let un of xi)ce.push({segments:new a.SegmentVector([un]),sortKey:un.sortKey,state:jo})}else ce.push({segments:Le.segments,sortKey:0,state:jo})}$&&ce.sort((re,Te)=>re.sortKey-Te.sortKey);for(let re of ce){let Te=re.state;if(l.terrain&&l.terrain.setupElevationDraw(Te.tile,Te.program,{useDepthForOcclusion:!ae,labelPlaneMatrixInv:Te.labelPlaneMatrixInv}),D.activeTexture.set(B.TEXTURE0),Te.atlasTexture.bind(Te.atlasInterpolation,B.CLAMP_TO_EDGE),Te.atlasTextureIcon&&(D.activeTexture.set(B.TEXTURE1),Te.atlasTextureIcon&&Te.atlasTextureIcon.bind(Te.atlasInterpolationIcon,B.CLAMP_TO_EDGE)),Te.isSDF){let ve=Te.uniformValues;Te.hasHalo&&(ve.u_is_halo=1,Fl(Te.buffers,re.segments,o,l,Te.program,V,E,M,ve)),ve.u_is_halo=0}Fl(Te.buffers,re.segments,o,l,Te.program,V,E,M,Te.uniformValues)}}function Fl(l,t,o,h,d,f,_,y,b){let T=h.context;d.draw(T,T.gl.TRIANGLES,f,_,y,a.CullFaceMode.disabled,b,o.id,l.layoutVertexBuffer,l.indexBuffer,t,o.paint,h.transform.zoom,l.programConfigurations.get(o.id),l.dynamicLayoutVertexBuffer,l.opacityVertexBuffer)}function Ts(l,t,o,h,d,f,_){let y=l.context.gl,b=o.paint.get("fill-pattern"),T=b&&b.constantOr(1),E=o.getCrossfadeParameters(),M,D,B,P,z;_?(D=T&&!o.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",M=y.LINES):(D=T?"fillPattern":"fill",M=y.TRIANGLES);for(let G of h){let F=t.getTile(G);if(T&&!F.patternsLoaded())continue;let j=F.getBucket(o);if(!j)continue;l.prepareDrawTile();let N=j.programConfigurations.get(o.id),$=l.useProgram(D,N);T&&(l.context.activeTexture.set(y.TEXTURE0),F.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),N.updatePaintBuffers(E));let V=b.constantOr(null);if(V&&F.imageAtlas){let ie=F.imageAtlas,ae=ie.patternPositions[V.to.toString()],ue=ie.patternPositions[V.from.toString()];ae&&ue&&N.setConstantPatternPositions(ae,ue)}let X=l.translatePosMatrix(G.projMatrix,F,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));if(_){P=j.indexBuffer2,z=j.segments2;let ie=l.terrain&&l.terrain.renderingToTexture?l.terrain.drapeBufferSize:[y.drawingBufferWidth,y.drawingBufferHeight];B=D==="fillOutlinePattern"&&T?kl(X,l,E,F,ie):bs(X,ie)}else P=j.indexBuffer,z=j.segments,B=T?vs(X,l,E,F):xs(X);l.prepareDrawProgram(l.context,$,G.toUnwrapped()),$.draw(l.context,M,d,l.stencilModeForClipping(G),f,a.CullFaceMode.disabled,B,o.id,j.layoutVertexBuffer,P,z,o.paint,l.transform.zoom,N)}}function On(l,t,o,h,d,f,_){let y=l.context,b=y.gl,T=l.transform,E=o.paint.get("fill-extrusion-pattern"),M=E.constantOr(1),D=o.getCrossfadeParameters(),B=o.paint.get("fill-extrusion-opacity"),P=function(N){if(N.projection.name!=="globe")return 0;let $=Math.PI/32,V=Math.tan($),X=a.earthRadius;return X*Math.sqrt(1+2*V*V)-X}(T),z=T.projection.name==="globe",G=z?a.globeToMercatorTransition(T.zoom):0,F=[a.mercatorXfromLng(T.center.lng),a.mercatorYfromLat(T.center.lat)],j=[];z&&j.push("PROJECTION_GLOBE_VIEW");for(let N of h){let $=t.getTile(N),V=$.getBucket(o);if(!V||V.projection!==T.projection.name)continue;let X=V.programConfigurations.get(o.id),ie=l.useProgram(M?"fillExtrusionPattern":"fillExtrusion",X,j);if(l.terrain){let Te=l.terrain;if(l.style.terrainSetForDrapingOnly())Te.setupElevationDraw($,ie,{useMeterToDem:!0});else{if(!V.enableTerrain)continue;if(Te.setupElevationDraw($,ie,{useMeterToDem:!0}),Io(y,t,N,V,o,Te),!V.centroidVertexBuffer){let ve=ie.attributes.a_centroid_pos;ve!==void 0&&b.vertexAttrib2f(ve,0,0)}}}M&&(l.context.activeTexture.set(b.TEXTURE0),$.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),X.updatePaintBuffers(D));let ae=E.constantOr(null);if(ae&&$.imageAtlas){let Te=$.imageAtlas,ve=Te.patternPositions[ae.to.toString()],Le=Te.patternPositions[ae.from.toString()];ve&&Le&&X.setConstantPatternPositions(ve,Le)}let ue=l.translatePosMatrix(N.projMatrix,$,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),ce=T.projection.createInversionMatrix(T,N.canonical),we=o.paint.get("fill-extrusion-vertical-gradient"),re=M?ys(ue,l,we,B,N,D,$,P,G,F,ce):gs(ue,l,we,B,N,P,G,F,ce);l.prepareDrawProgram(y,ie,N.toUnwrapped()),ie.draw(y,y.gl.TRIANGLES,d,f,_,a.CullFaceMode.backCCW,re,o.id,V.layoutVertexBuffer,V.indexBuffer,V.segments,o.paint,l.transform.zoom,X,l.terrain?V.centroidVertexBuffer:null,z?V.layoutVertexExtBuffer:null)}}function Io(l,t,o,h,d,f){let _=[F=>{let j=F.canonical.x-1,N=F.wrap;return j<0&&(j=(1<<F.canonical.z)-1,N--),new a.OverscaledTileID(F.overscaledZ,N,F.canonical.z,j,F.canonical.y)},F=>{let j=F.canonical.x+1,N=F.wrap;return j===1<<F.canonical.z&&(j=0,N++),new a.OverscaledTileID(F.overscaledZ,N,F.canonical.z,j,F.canonical.y)},F=>new a.OverscaledTileID(F.overscaledZ,F.wrap,F.canonical.z,F.canonical.x,(F.canonical.y===0?1<<F.canonical.z:F.canonical.y)-1),F=>new a.OverscaledTileID(F.overscaledZ,F.wrap,F.canonical.z,F.canonical.x,F.canonical.y===(1<<F.canonical.z)-1?0:F.canonical.y+1)],y=F=>{let j=t.getSource().minzoom,N=V=>{let X=t.getTileByID(V);if(X&&X.hasData())return X.getBucket(d)},$=[0,-1,1];for(let V of $){if(F.overscaledZ+V<j)continue;let X=N(F.calculateScaledKey(F.overscaledZ+V));if(X)return X}},b=[0,0,0],T=(F,j)=>(b[0]=Math.min(F.min.y,j.min.y),b[1]=Math.max(F.max.y,j.max.y),b[2]=a.EXTENT-j.min.x>F.max.x?j.min.x-a.EXTENT:F.max.x,b),E=(F,j)=>(b[0]=Math.min(F.min.x,j.min.x),b[1]=Math.max(F.max.x,j.max.x),b[2]=a.EXTENT-j.min.y>F.max.y?j.min.y-a.EXTENT:F.max.y,b),M=[(F,j)=>T(F,j),(F,j)=>T(j,F),(F,j)=>E(F,j),(F,j)=>E(j,F)],D=new a.pointGeometry(0,0),B,P,z,G=(F,j,N,$,V)=>{let X=[[$?N:F,$?F:N,0],[$?N:j,$?j:N,0]],ie=V<0?a.EXTENT+V:V,ae=[$?ie:(F+j)/2,$?(F+j)/2:ie,0];return N===0&&V<0||N!==0&&V>0?f.getForTilePoints(z,[ae],!0,P):X.push(ae),f.getForTilePoints(o,X,!0,B),Math.max(X[0][2],X[1][2],ae[2])/f.exaggeration()};for(let F=0;F<4;F++){let j=(F<2?1:5)-F,N=h.borders[F];if(N.length===0)continue;let $=z=_[F](o),V=y($);if(!(V&&V instanceof a.FillExtrusionBucket&&V.enableTerrain)||h.borderDoneWithNeighborZ[F]===V.canonical.z&&V.borderDoneWithNeighborZ[j]===h.canonical.z||(P=f.findDEMTileFor($),!P||!P.dem))continue;if(!B){let ue=f.findDEMTileFor(o);if(!ue||!ue.dem)return;B=ue}let X=V.borders[j],ie=0,ae=V.borderDoneWithNeighborZ[j]!==h.canonical.z;if(h.canonical.z===V.canonical.z){for(let ue=0;ue<N.length;ue++){let ce=h.featuresOnBorder[N[ue]],we=ce.borders[F],re;for(;ie<X.length&&(re=V.featuresOnBorder[X[ie]],!(re.borders[j][1]>we[0]+3));)ae&&V.encodeCentroid(void 0,re,!1),ie++;if(re&&ie<X.length){let Te=ie,ve=0;for(;!(re.borders[j][0]>we[1]-3)&&(ve++,++ie!==X.length);)re=V.featuresOnBorder[X[ie]];if(re=V.featuresOnBorder[X[Te]],ce.intersectsCount()>1||re.intersectsCount()>1||ve!==1){ve!==1&&(ie=Te),h.encodeCentroid(void 0,ce,!1),ae&&V.encodeCentroid(void 0,re,!1);continue}let Le=M[F](ce,re),pe=F%2?a.EXTENT-1:0;D.x=G(Le[0],Math.min(a.EXTENT-1,Le[1]),pe,F<2,Le[2]),D.y=0,h.encodeCentroid(D,ce,!1),ae&&V.encodeCentroid(D,re,!1)}else h.encodeCentroid(void 0,ce,!1)}h.borderDoneWithNeighborZ[F]=V.canonical.z,h.needsCentroidUpdate=!0,ae&&(V.borderDoneWithNeighborZ[j]=h.canonical.z,V.needsCentroidUpdate=!0)}else{for(let ue of N)h.encodeCentroid(void 0,h.featuresOnBorder[ue],!1);if(ae){for(let ue of X)V.encodeCentroid(void 0,V.featuresOnBorder[ue],!1);V.borderDoneWithNeighborZ[j]=h.canonical.z,V.needsCentroidUpdate=!0}h.borderDoneWithNeighborZ[F]=V.canonical.z,h.needsCentroidUpdate=!0}}(h.needsCentroidUpdate||!h.centroidVertexBuffer&&h.centroidVertexArray.length!==0)&&h.uploadCentroid(l)}let wa=new a.Color(1,0,0,1),Ta=new a.Color(0,1,0,1),Ol=new a.Color(0,0,1,1),Es=new a.Color(1,0,1,1),Ss=new a.Color(0,1,1,1);function Ae(l,t,o,h){Mo(l,0,t+o/2,l.transform.width,o,h)}function Si(l,t,o,h){Mo(l,t-o/2,0,o,l.transform.height,h)}function Mo(l,t,o,h,d,f){let _=l.context,y=_.gl;y.enable(y.SCISSOR_TEST),y.scissor(t*a.exported.devicePixelRatio,o*a.exported.devicePixelRatio,h*a.exported.devicePixelRatio,d*a.exported.devicePixelRatio),_.clear({color:f}),y.disable(y.SCISSOR_TEST)}function Ul(l,t,o){let h=l.context,d=h.gl,f=l.transform.projection.name==="globe",_=o.projMatrix,y=l.useProgram("debug",null,f?["PROJECTION_GLOBE_VIEW"]:null),b=t.getTileByID(o.key);l.terrain&&l.terrain.setupElevationDraw(b,y);let T=a.DepthMode.disabled,E=a.StencilMode.disabled,M=l.colorModeForRenderPass(),D="$debug";h.activeTexture.set(d.TEXTURE0),l.emptyTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),f?b._makeGlobeTileDebugBuffers(l.context,l.transform.projection):b._makeDebugTileBoundsBuffers(l.context,l.transform.projection);let B=b._tileDebugBuffer||l.debugBuffer,P=b._tileDebugIndexBuffer||l.debugIndexBuffer,z=b._tileDebugSegments||l.debugSegments;y.draw(h,d.LINE_STRIP,T,E,M,a.CullFaceMode.disabled,Pl(_,a.Color.red),D,B,P,z,null,null,null,b._globeTileDebugBorderBuffer);let G=b.latestRawTileData,F=Math.floor((G&&G.byteLength||0)/1024),j=t.getTile(o).tileSize,N=512/Math.min(j,512)*(o.overscaledZ/l.transform.zoom)*.5,$=o.canonical.toString();o.overscaledZ!==o.canonical.z&&($+=` => ${o.overscaledZ}`),function(ae,ue){ae.initDebugOverlayCanvas();let ce=ae.debugOverlayCanvas,we=ae.context.gl,re=ae.debugOverlayCanvas.getContext("2d");re.clearRect(0,0,ce.width,ce.height),re.shadowColor="white",re.shadowBlur=2,re.lineWidth=1.5,re.strokeStyle="white",re.textBaseline="top",re.font="bold 36px Open Sans, sans-serif",re.fillText(ue,5,5),re.strokeText(ue,5,5),ae.debugOverlayTexture.update(ce),ae.debugOverlayTexture.bind(we.LINEAR,we.CLAMP_TO_EDGE)}(l,`${$} ${F}kb`);let V=b._tileDebugTextBuffer||l.debugBuffer,X=b._tileDebugTextIndexBuffer||l.quadTriangleIndexBuffer,ie=b._tileDebugTextSegments||l.debugSegments;y.draw(h,d.TRIANGLES,T,E,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,Pl(_,a.Color.transparent,N),D,V,X,ie,null,null,null,b._globeTileDebugTextBuffer)}let Vl=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Un}=Vl;function ar(l,t,o,h){l.emplaceBack(t,o,h)}class Ao{constructor(t){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,ar(this.vertexArray,-1,-1,1),ar(this.vertexArray,1,-1,1),ar(this.vertexArray,-1,1,1),ar(this.vertexArray,1,1,1),ar(this.vertexArray,-1,-1,-1),ar(this.vertexArray,1,-1,-1),ar(this.vertexArray,-1,1,-1),ar(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=t.createVertexBuffer(this.vertexArray,Un),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function Mr(l,t,o,h,d,f){let _=l.gl,y=t.paint.get("sky-atmosphere-color"),b=t.paint.get("sky-atmosphere-halo-color"),T=t.paint.get("sky-atmosphere-sun-intensity"),E=((M,D,B,P,z)=>({u_matrix_3f:M,u_sun_direction:D,u_sun_intensity:B,u_color_tint_r:[P.r,P.g,P.b,P.a],u_color_tint_m:[z.r,z.g,z.b,z.a],u_luminance:5e-5}))(a.fromMat4(a.create$1(),h),d,T,y,b);_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+f,t.skyboxTexture,0),o.draw(l,_.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,E,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}function Ar(l,t){return a.transformMat4(l,l,t)}let Ea={symbol:function(l,t,o,h,d){if(l.renderPass!=="translucent")return;let f=a.StencilMode.disabled,_=l.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(y,b,T,E,M,D,B){let P=b.transform,z=M==="map",G=D==="map";for(let F of y){let j=E.getTile(F),N=j.getBucket(T);if(!N||N.projection!==P.projection.name||!N.text||!N.text.segments.get().length)continue;let $=a.evaluateSizeForZoom(N.textSizeData,P.zoom),V=b.transform.calculatePixelsToTileUnitsMatrix(j),X=nn(F.projMatrix,j.tileID.canonical,G,z,b.transform,V),ie=T.layout.get("icon-text-fit")!=="none"&&N.hasIconData();if($){let ae=Math.pow(2,P.zoom-j.tileID.overscaledZ);nh(N,z,G,B,a.symbolSize,P,X,F,ae,$,ie,P.projection)}}}(h,l,o,t,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),d),o.paint.get("icon-opacity").constantOr(1)!==0&&ba(l,t,o,h,!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,_),o.paint.get("text-opacity").constantOr(1)!==0&&ba(l,t,o,h,!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,_),t.map.showCollisionBoxes&&(Rl(l,t,o,h,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),Rl(l,t,o,h,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(l,t,o,h){if(l.renderPass!=="translucent")return;let d=o.paint.get("circle-opacity"),f=o.paint.get("circle-stroke-width"),_=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||_.constantOr(1)===0))return;let b=l.context,T=b.gl,E=l.transform,M=l.depthModeForSublayer(0,a.DepthMode.ReadOnly),D=a.StencilMode.disabled,B=l.colorModeForRenderPass(),P=E.projection.name==="globe",z=[a.mercatorXfromLng(E.center.lng),a.mercatorYfromLat(E.center.lat)],G=[];for(let j=0;j<h.length;j++){let N=h[j],$=t.getTile(N),V=$.getBucket(o);if(!V)continue;let X=V.programConfigurations.get(o.id),ie=Qc(o);P&&ie.push("PROJECTION_GLOBE_VIEW");let ae=l.useProgram("circle",X,ie),ue=V.layoutVertexBuffer,ce=V.globeExtVertexBuffer,we=V.indexBuffer,re=E.projection.createInversionMatrix(E,N.canonical),Te={programConfiguration:X,program:ae,layoutVertexBuffer:ue,globeExtVertexBuffer:ce,indexBuffer:we,uniformValues:Rn(l,N,$,re,z,o),tile:$};if(y){let ve=V.segments.get();for(let Le of ve)G.push({segments:new a.SegmentVector([Le]),sortKey:Le.sortKey,state:Te})}else G.push({segments:V.segments,sortKey:0,state:Te})}y&&G.sort((j,N)=>j.sortKey-N.sortKey);let F={useDepthForOcclusion:!P};for(let j of G){let{programConfiguration:N,program:$,layoutVertexBuffer:V,globeExtVertexBuffer:X,indexBuffer:ie,uniformValues:ae,tile:ue}=j.state,ce=j.segments;l.terrain&&l.terrain.setupElevationDraw(ue,$,F),l.prepareDrawProgram(b,$,ue.tileID.toUnwrapped()),$.draw(b,T.TRIANGLES,M,D,B,a.CullFaceMode.disabled,ae,o.id,V,ie,ce,o.paint,E.zoom,N,P?X:null)}},heatmap:function(l,t,o,h){if(o.paint.get("heatmap-opacity")!==0)if(l.renderPass==="offscreen"){let d=l.context,f=d.gl,_=a.StencilMode.disabled,y=new a.ColorMode([f.ONE,f.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(D,B,P){let z=D.gl;D.activeTexture.set(z.TEXTURE1),D.viewport.set([0,0,B.width/4,B.height/4]);let G=P.heatmapFbo;if(G)z.bindTexture(z.TEXTURE_2D,G.colorAttachment.get()),D.bindFramebuffer.set(G.framebuffer);else{let F=z.createTexture();z.bindTexture(z.TEXTURE_2D,F),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MIN_FILTER,z.LINEAR),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MAG_FILTER,z.LINEAR),G=P.heatmapFbo=D.createFramebuffer(B.width/4,B.height/4,!1),function(j,N,$,V){let X=j.gl;X.texImage2D(X.TEXTURE_2D,0,X.RGBA,N.width/4,N.height/4,0,X.RGBA,j.extRenderToTextureHalfFloat?j.extTextureHalfFloat.HALF_FLOAT_OES:X.UNSIGNED_BYTE,null),V.colorAttachment.set($)}(D,B,F,G)}})(d,l,o),d.clear({color:a.Color.transparent});let b=l.transform,T=b.projection.name==="globe",E=T?["PROJECTION_GLOBE_VIEW"]:null,M=[a.mercatorXfromLng(b.center.lng),a.mercatorYfromLat(b.center.lat)];for(let D=0;D<h.length;D++){let B=h[D];if(t.hasRenderableParent(B))continue;let P=t.getTile(B),z=P.getBucket(o);if(!z)continue;let G=z.programConfigurations.get(o.id),F=l.useProgram("heatmap",G,E),{zoom:j}=l.transform;l.terrain&&l.terrain.setupElevationDraw(P,F),l.prepareDrawProgram(d,F,B.toUnwrapped());let N=b.projection.createInversionMatrix(b,B.canonical);F.draw(d,f.TRIANGLES,a.DepthMode.disabled,_,y,a.CullFaceMode.disabled,ih(l,B,P,N,M,j,o.paint.get("heatmap-intensity")),o.id,z.layoutVertexBuffer,z.indexBuffer,z.segments,o.paint,l.transform.zoom,G,T?z.globeExtVertexBuffer:null)}d.viewport.set([0,0,l.width,l.height])}else l.renderPass==="translucent"&&(l.context.setColorMode(l.colorModeForRenderPass()),function(d,f){let _=d.context,y=_.gl,b=f.heatmapFbo;if(!b)return;_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),_.activeTexture.set(y.TEXTURE1);let T=f.colorRampTexture;T||(T=f.colorRampTexture=new a.Texture(_,f.colorRamp,y.RGBA)),T.bind(y.LINEAR,y.CLAMP_TO_EDGE),d.useProgram("heatmapTexture").draw(_,y.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,d.colorModeForRenderPass(),a.CullFaceMode.disabled,((E,M,D,B)=>({u_image:0,u_color_ramp:1,u_opacity:M.paint.get("heatmap-opacity")}))(0,f),f.id,d.viewportBuffer,d.quadTriangleIndexBuffer,d.viewportSegments,f.paint,d.transform.zoom)}(l,o))},line:function(l,t,o,h){if(l.renderPass!=="translucent")return;let d=o.paint.get("line-opacity"),f=o.paint.get("line-width");if(d.constantOr(1)===0||f.constantOr(1)===0)return;let _=l.depthModeForSublayer(0,a.DepthMode.ReadOnly),y=l.colorModeForRenderPass(),b=l.terrain&&l.terrain.renderingToTexture?1:a.exported.devicePixelRatio,T=o.paint.get("line-dasharray"),E=T.constantOr(1),M=o.layout.get("line-cap"),D=o.paint.get("line-pattern"),B=D.constantOr(1),P=o.paint.get("line-gradient"),z=o.getCrossfadeParameters(),G=B?"linePattern":"line",F=l.context,j=F.gl,N=(V=>{let X=[];_a(V)&&X.push("RENDER_LINE_DASH"),V.paint.get("line-gradient")&&X.push("RENDER_LINE_GRADIENT");let ie=V.paint.get("line-pattern").constantOr(1),ae=V.paint.get("line-opacity").constantOr(1)!==1;return!ie&&ae&&X.push("RENDER_LINE_ALPHA_DISCARD"),X})(o),$=N.includes("RENDER_LINE_ALPHA_DISCARD");l.terrain&&l.terrain.clipOrMaskOverlapStencilType()&&($=!1);for(let V of h){let X=t.getTile(V);if(B&&!X.patternsLoaded())continue;let ie=X.getBucket(o);if(!ie)continue;l.prepareDrawTile();let ae=ie.programConfigurations.get(o.id),ue=l.useProgram(G,ae,N),ce=D.constantOr(null);if(ce&&X.imageAtlas){let pe=X.imageAtlas,ke=pe.patternPositions[ce.to.toString()],Ve=pe.patternPositions[ce.from.toString()];ke&&Ve&&ae.setConstantPatternPositions(ke,Ve)}let we=T.constantOr(null),re=M.constantOr(null);if(!B&&we&&re&&X.lineAtlas){let pe=X.lineAtlas,ke=pe.getDash(we.to,re),Ve=pe.getDash(we.from,re);ke&&Ve&&ae.setConstantPatternPositions(ke,Ve)}let Te=l.terrain?V.projMatrix:null,ve=B?ma(l,X,o,z,Te,b):rh(l,X,o,z,Te,ie.lineClipsArray.length,b);if(P){let pe=ie.gradients[o.id],ke=pe.texture;if(o.gradientVersion!==pe.version){let Ve=256;if(o.stepInterpolant){let De=t.getSource().maxzoom,Pe=V.canonical.z===De?Math.ceil(1<<l.transform.maxZoom-V.canonical.z):1;Ve=a.clamp(a.nextPowerOfTwo(ie.maxLineLength/a.EXTENT*1024*Pe),256,F.maxTextureSize)}pe.gradient=a.renderColorRamp({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:Ve,image:pe.gradient||void 0,clips:ie.lineClipsArray}),pe.texture?pe.texture.update(pe.gradient):pe.texture=new a.Texture(F,pe.gradient,j.RGBA),pe.version=o.gradientVersion,ke=pe.texture}F.activeTexture.set(j.TEXTURE1),ke.bind(o.stepInterpolant?j.NEAREST:j.LINEAR,j.CLAMP_TO_EDGE)}E&&(F.activeTexture.set(j.TEXTURE0),X.lineAtlasTexture.bind(j.LINEAR,j.REPEAT),ae.updatePaintBuffers(z)),B&&(F.activeTexture.set(j.TEXTURE0),X.imageAtlasTexture.bind(j.LINEAR,j.CLAMP_TO_EDGE),ae.updatePaintBuffers(z)),l.prepareDrawProgram(F,ue,V.toUnwrapped());let Le=pe=>{ue.draw(F,j.TRIANGLES,_,pe,y,a.CullFaceMode.disabled,ve,o.id,ie.layoutVertexBuffer,ie.indexBuffer,ie.segments,o.paint,l.transform.zoom,ae,ie.layoutVertexBuffer2)};if($){let pe=l.stencilModeForClipping(V).ref;pe===0&&l.terrain&&F.clear({stencil:0});let ke={func:j.EQUAL,mask:255};ve.u_alpha_discard_threshold=.8,Le(new a.StencilMode(ke,pe,255,j.KEEP,j.KEEP,j.INVERT)),ve.u_alpha_discard_threshold=0,Le(new a.StencilMode(ke,pe,255,j.KEEP,j.KEEP,j.KEEP))}else Le(l.stencilModeForClipping(V))}$&&(l.resetStencilClippingMasks(),l.terrain&&F.clear({stencil:0}))},fill:function(l,t,o,h){let d=o.paint.get("fill-color"),f=o.paint.get("fill-opacity");if(f.constantOr(1)===0)return;let _=l.colorModeForRenderPass(),y=o.paint.get("fill-pattern"),b=l.opaquePassEnabledForLayer()&&!y.constantOr(1)&&d.constantOr(a.Color.transparent).a===1&&f.constantOr(0)===1?"opaque":"translucent";if(l.renderPass===b){let T=l.depthModeForSublayer(1,l.renderPass==="opaque"?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);Ts(l,t,o,h,T,_,!1)}if(l.renderPass==="translucent"&&o.paint.get("fill-antialias")){let T=l.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);Ts(l,t,o,h,T,_,!0)}},"fill-extrusion":function(l,t,o,h){let d=o.paint.get("fill-extrusion-opacity");if(d!==0&&l.renderPass==="translucent"){let f=new a.DepthMode(l.context.gl.LEQUAL,a.DepthMode.ReadWrite,l.depthRangeFor3D);if(d!==1||o.paint.get("fill-extrusion-pattern").constantOr(1))On(l,t,o,h,f,a.StencilMode.disabled,a.ColorMode.disabled),On(l,t,o,h,f,l.stencilModeFor3D(),l.colorModeForRenderPass()),l.resetStencilClippingMasks();else{let _=l.colorModeForRenderPass();On(l,t,o,h,f,a.StencilMode.disabled,_)}}},hillshade:function(l,t,o,h){if(l.renderPass!=="offscreen"&&l.renderPass!=="translucent")return;let d=l.context,f=l.depthModeForSublayer(0,a.DepthMode.ReadOnly),_=l.colorModeForRenderPass(),y=l.terrain&&l.terrain.renderingToTexture,[b,T]=l.renderPass!=="translucent"||y?[{},h]:l.stencilConfigForOverlap(h);for(let E of T){let M=t.getTile(E);if(M.needsHillshadePrepare&&l.renderPass==="offscreen")ca(l,M,o,f,a.StencilMode.disabled,_);else if(l.renderPass==="translucent"){let D=y&&l.terrain?l.terrain.stencilModeForRTTOverlap(E):b[E.overscaledZ];Al(l,E,M,o,f,D,_)}}d.viewport.set([0,0,l.width,l.height]),l.resetStencilClippingMasks()},raster:function(l,t,o,h,d,f){if(l.renderPass!=="translucent"||o.paint.get("raster-opacity")===0||!h.length)return;let _=l.context,y=_.gl,b=t.getSource(),T=l.useProgram("raster"),E=l.colorModeForRenderPass(),M=l.terrain&&l.terrain.renderingToTexture,[D,B]=b instanceof W||M?[{},h]:l.stencilConfigForOverlap(h),P=B[B.length-1].overscaledZ,z=!l.options.moving;for(let G of B){let F=M?a.DepthMode.disabled:l.depthModeForSublayer(G.overscaledZ-P,o.paint.get("raster-opacity")===1?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,y.LESS),j=G.toUnwrapped(),N=t.getTile(G);if(M&&(!N||!N.hasData()))continue;let $=M?G.projMatrix:l.transform.calculateProjMatrix(j,z),V=l.terrain&&M?l.terrain.stencilModeForRTTOverlap(G):D[G.overscaledZ],X=f?0:o.paint.get("raster-fade-duration");N.registerFadeDuration(X);let ie=t.findLoadedParent(G,0),ae=pa(N,ie,t,l.transform,X),ue,ce;l.terrain&&l.terrain.prepareDrawTile();let we=o.paint.get("raster-resampling")==="nearest"?y.NEAREST:y.LINEAR;_.activeTexture.set(y.TEXTURE0),N.texture.bind(we,y.CLAMP_TO_EDGE),_.activeTexture.set(y.TEXTURE1),ie?(ie.texture.bind(we,y.CLAMP_TO_EDGE),ue=Math.pow(2,ie.tileID.overscaledZ-N.tileID.overscaledZ),ce=[N.tileID.canonical.x*ue%1,N.tileID.canonical.y*ue%1]):N.texture.bind(we,y.CLAMP_TO_EDGE);let re=Ll($,ce||[0,0],ue||1,ae,o,b instanceof W?b.perspectiveTransform:[0,0]);if(l.prepareDrawProgram(_,T,j),b instanceof W)b.boundsBuffer&&b.boundsSegments&&T.draw(_,y.TRIANGLES,F,a.StencilMode.disabled,E,a.CullFaceMode.disabled,re,o.id,b.boundsBuffer,l.quadTriangleIndexBuffer,b.boundsSegments);else{let{tileBoundsBuffer:Te,tileBoundsIndexBuffer:ve,tileBoundsSegments:Le}=l.getTileBoundsBuffers(N);T.draw(_,y.TRIANGLES,F,V,E,a.CullFaceMode.disabled,re,o.id,Te,ve,Le)}}l.resetStencilClippingMasks()},background:function(l,t,o,h){let d=o.paint.get("background-color"),f=o.paint.get("background-opacity");if(f===0)return;let _=l.context,y=_.gl,b=l.transform,T=b.tileSize,E=o.paint.get("background-pattern");if(l.isPatternMissing(E))return;let M=!E&&d.a===1&&f===1&&l.opaquePassEnabledForLayer()?"opaque":"translucent";if(l.renderPass!==M)return;let D=a.StencilMode.disabled,B=l.depthModeForSublayer(0,M==="opaque"?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),P=l.colorModeForRenderPass(),z=l.useProgram(E?"backgroundPattern":"background"),G,F=h;F||(G=l.getBackgroundTiles(),F=Object.values(G).map(N=>N.tileID)),E&&(_.activeTexture.set(y.TEXTURE0),l.imageManager.bind(l.context));let j=o.getCrossfadeParameters();for(let N of F){let $=N.toUnwrapped(),V=h?N.projMatrix:l.transform.calculateProjMatrix($);l.prepareDrawTile();let X=t?t.getTile(N):G?G[N.key]:new a.Tile(N,T,b.zoom,l),ie=E?xa(V,f,l,E,{tileID:N,tileSize:T},j):Bl(V,f,d);l.prepareDrawProgram(_,z,$);let{tileBoundsBuffer:ae,tileBoundsIndexBuffer:ue,tileBoundsSegments:ce}=l.getTileBoundsBuffers(X);z.draw(_,y.TRIANGLES,B,D,P,a.CullFaceMode.disabled,ie,o.id,ae,ue,ce)}},sky:function(l,t,o){let h=l.transform,d=h.projection.name==="mercator"||h.projection.name==="globe"?1:a.smoothstep(7,8,h.zoom),f=o.paint.get("sky-opacity")*d;if(f===0)return;let _=l.context,y=o.paint.get("sky-type"),b=new a.DepthMode(_.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),T=l.frameCounter/1e3%1;y==="atmosphere"?l.renderPass==="offscreen"?o.needsSkyboxCapture(l)&&(function(E,M,D,B){let P=E.context,z=P.gl,G=M.skyboxFbo;if(!G){G=M.skyboxFbo=P.createFramebuffer(32,32,!1),M.skyboxGeometry=new Ao(P),M.skyboxTexture=P.gl.createTexture(),z.bindTexture(z.TEXTURE_CUBE_MAP,M.skyboxTexture),z.texParameteri(z.TEXTURE_CUBE_MAP,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_CUBE_MAP,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_CUBE_MAP,z.TEXTURE_MIN_FILTER,z.LINEAR),z.texParameteri(z.TEXTURE_CUBE_MAP,z.TEXTURE_MAG_FILTER,z.LINEAR);for(let $=0;$<6;++$)z.texImage2D(z.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,z.RGBA,32,32,0,z.RGBA,z.UNSIGNED_BYTE,null)}P.bindFramebuffer.set(G.framebuffer),P.viewport.set([0,0,32,32]);let F=M.getCenter(E,!0),j=E.useProgram("skyboxCapture"),N=new Float64Array(16);a.identity(N),a.rotateY(N,N,.5*-Math.PI),Mr(P,M,j,N,F,0),a.identity(N),a.rotateY(N,N,.5*Math.PI),Mr(P,M,j,N,F,1),a.identity(N),a.rotateX(N,N,.5*-Math.PI),Mr(P,M,j,N,F,2),a.identity(N),a.rotateX(N,N,.5*Math.PI),Mr(P,M,j,N,F,3),a.identity(N),Mr(P,M,j,N,F,4),a.identity(N),a.rotateY(N,N,Math.PI),Mr(P,M,j,N,F,5),P.viewport.set([0,0,E.width,E.height])}(l,o),o.markSkyboxValid(l)):l.renderPass==="sky"&&function(E,M,D,B,P){let z=E.context,G=z.gl,F=E.transform,j=E.useProgram("skybox");z.activeTexture.set(G.TEXTURE0),G.bindTexture(G.TEXTURE_CUBE_MAP,M.skyboxTexture);let N=(($,V,X,ie,ae)=>({u_matrix:$,u_sun_direction:V,u_cubemap:0,u_opacity:ie,u_temporal_offset:ae}))(F.skyboxMatrix,M.getCenter(E,!1),0,B,P);E.prepareDrawProgram(z,j),j.draw(z,G.TRIANGLES,D,a.StencilMode.disabled,E.colorModeForRenderPass(),a.CullFaceMode.backCW,N,"skybox",M.skyboxGeometry.vertexBuffer,M.skyboxGeometry.indexBuffer,M.skyboxGeometry.segment)}(l,o,b,f,T):y==="gradient"&&l.renderPass==="sky"&&function(E,M,D,B,P){let z=E.context,G=z.gl,F=E.transform,j=E.useProgram("skyboxGradient");M.skyboxGeometry||(M.skyboxGeometry=new Ao(z)),z.activeTexture.set(G.TEXTURE0);let N=M.colorRampTexture;N||(N=M.colorRampTexture=new a.Texture(z,M.colorRamp,G.RGBA)),N.bind(G.LINEAR,G.CLAMP_TO_EDGE);let $=((V,X,ie,ae,ue)=>({u_matrix:V,u_color_ramp:0,u_center_direction:X,u_radius:a.degToRad(ie),u_opacity:ae,u_temporal_offset:ue}))(F.skyboxMatrix,M.getCenter(E,!1),M.paint.get("sky-gradient-radius"),B,P);E.prepareDrawProgram(z,j),j.draw(z,G.TRIANGLES,D,a.StencilMode.disabled,E.colorModeForRenderPass(),a.CullFaceMode.backCW,$,"skyboxGradient",M.skyboxGeometry.vertexBuffer,M.skyboxGeometry.indexBuffer,M.skyboxGeometry.segment)}(l,o,b,f,T)},debug:function(l,t,o){for(let h=0;h<o.length;h++)Ul(l,t,o[h])},custom:function(l,t,o){let h=l.context,d=o.implementation;if(l.transform.projection.unsupportedLayers&&l.transform.projection.unsupportedLayers.includes("custom"))a.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if(l.renderPass==="offscreen"){let f=d.prerender;f&&(l.setCustomLayerDefaults(),h.setColorMode(l.colorModeForRenderPass()),f.call(d,h.gl,l.transform.customLayerMatrix()),h.setDirty(),l.setBaseState())}else if(l.renderPass==="translucent"){l.setCustomLayerDefaults(),h.setColorMode(l.colorModeForRenderPass()),h.setStencilMode(a.StencilMode.disabled);let f=d.renderingMode==="3d"?new a.DepthMode(l.context.gl.LEQUAL,a.DepthMode.ReadWrite,l.depthRangeFor3D):l.depthModeForSublayer(0,a.DepthMode.ReadOnly);h.setDepthMode(f),d.render(h.gl,l.transform.customLayerMatrix()),h.setDirty(),l.setBaseState(),h.bindFramebuffer.set(null)}}};class jl{constructor(t,o){this.context=new I(t),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=a.SourceCache.maxUnderzooming+a.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new us,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this._tileClippingMaskIDs=new Map,this._skippedStencilTileIDs=new Set}updateTerrain(t,o){let h=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(h||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new fi(this,t));let d=this._terrain;this.transform.elevation=h?d:null,d.update(t,this.transform,o)}_updateFog(t){let o=t.fog;if(!o||o.getOpacity(this.transform.pitch)<1||o.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);let[h,d]=o.getFovAdjustedRange(this.transform._fov);if(h>d)return void(this.transform.fogCullDistSq=null);let f=h+.78*(d-h);this.transform.fogCullDistSq=f*f}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,o){if(this.width=t*a.exported.devicePixelRatio,this.height=o*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let h of this.style.order)this.style._layers[h].resize()}setup(){let t=this.context,o=new a.StructArrayLayout2i4;o.emplaceBack(0,0),o.emplaceBack(a.EXTENT,0),o.emplaceBack(0,a.EXTENT),o.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(o,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);let h=new a.StructArrayLayout2i4;h.emplaceBack(0,0),h.emplaceBack(a.EXTENT,0),h.emplaceBack(0,a.EXTENT),h.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=t.createVertexBuffer(h,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);let d=new a.StructArrayLayout2i4;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);let f=new a.StructArrayLayout4i8;f.emplaceBack(0,0,0,0),f.emplaceBack(a.EXTENT,0,a.EXTENT,0),f.emplaceBack(0,a.EXTENT,0,a.EXTENT),f.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(f,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);let _=new a.StructArrayLayout3ui6;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(_);let y=new a.StructArrayLayout1ui2;for(let T of[0,1,3,2,0])y.emplaceBack(T);this.debugIndexBuffer=t.createIndexBuffer(y),this.emptyTexture=new a.Texture(t,new a.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=a.create();let b=this.context.gl;this.stencilClearMode=new a.StencilMode({func:b.ALWAYS,mask:0},0,255,b.ZERO,b.ZERO,b.ZERO),this.loadTimeStamps.push(a.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){let t=this.context,o=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear(),this.useProgram("clippingMask").draw(t,o.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,ms(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear())}_renderTileClippingMasks(t,o,h){if(!o||this.currentStencilSource===o.id||!t.isTileClipped()||!h||h.length===0)return;let d=[],f=!1;if(this._tileClippingMaskIDs&&!this.terrain){for(let E of h)if(this._tileClippingMaskIDs.has(E.key)||(f=!0),this._skippedStencilTileIDs.has(E.key)){if(!o.getTile(E).getBucket(t))continue;this._skippedStencilTileIDs.delete(E.key),d.push(E)}if(!f&&d.length===0)return}let _=this.context,y=_.gl;_.setColorMode(a.ColorMode.disabled),_.setDepthMode(a.DepthMode.disabled);let b=this.useProgram("clippingMask"),T=E=>{let M=o.getTile(E),{tileBoundsBuffer:D,tileBoundsIndexBuffer:B,tileBoundsSegments:P}=this.getTileBoundsBuffers(M);b.draw(_,y.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:y.GREATER,mask:255},this._tileClippingMaskIDs.get(E.key)||0,255,y.KEEP,y.KEEP,y.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,ms(E.projMatrix),"$clipping",D,B,P)};if(!f&&d.length>0)for(let E of d)T(E);else{(this._tileClippingMaskIDs.size===0||this.nextStencilID+h.length>256)&&this.clearStencil(),this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear();for(let E of h)this._tileClippingMaskIDs.set(E.key,this.nextStencilID++),o.getTile(E).getBucket(t)?T(E):this._skippedStencilTileIDs.add(E.key)}this._skippedStencilTileIDs.size===0&&(this.currentStencilSource=o.id)}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,o=this.context.gl;return new a.StencilMode({func:o.NOTEQUAL,mask:255},t,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);let o=this.context.gl;return new a.StencilMode({func:o.EQUAL,mask:255},this._tileClippingMaskIDs.get(t.key)||0,0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(t){let o=this.context.gl,h=t.sort((_,y)=>y.overscaledZ-_.overscaledZ),d=h[h.length-1].overscaledZ,f=h[0].overscaledZ-d+1;if(f>1){this.currentStencilSource=void 0,this.nextStencilID+f>256&&this.clearStencil();let _={};for(let y=0;y<f;y++)_[y+d]=new a.StencilMode({func:o.GEQUAL,mask:255},y+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=f,[_,h]}return[{[d]:a.StencilMode.disabled},h]}colorModeForRenderPass(){let t=this.context.gl;return this._showOverdrawInspector?new a.ColorMode([t.CONSTANT_COLOR,t.ONE],new a.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?a.ColorMode.unblended:a.ColorMode.alphaBlended}depthModeForSublayer(t,o,h){if(!this.opaquePassEnabledForLayer())return a.DepthMode.disabled;let d=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new a.DepthMode(h||this.context.gl.LEQUAL,o,[d,d])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,o){this.style=t,this.options=o,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(a.exported.now()),this.imageManager.beginFrame();let h=this.style.order,d=this.style._sourceCaches;for(let T in d){let E=d[T];E.used&&E.prepare(this.context)}let f={},_={},y={};for(let T in d){let E=d[T];f[T]=E.getVisibleCoordinates(),_[T]=f[T].slice().reverse(),y[T]=E.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let T=0;T<h.length;T++)if(this.style._layers[h[T]].is3D()){this.opaquePassCutoff=T;break}if(this.terrain&&(this.terrain.updateTileBinding(y),this.opaquePassCutoff=0),this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new a.GlobeSharedBuffers(this.context)),!a.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(let T of h){let E=this.style._layers[T],M=t._getLayerSourceCache(E);if(!E.hasOffscreenPass()||E.isHidden(this.transform.zoom))continue;let D=M?_[M.id]:void 0;(E.type==="custom"||E.isSky()||D&&D.length)&&this.renderLayer(this,M,E,D)}this.depthRangeFor3D=[0,1-(t.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let b=a.Color.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(b=this.style.fog.properties.get("color")),this.context.clear({color:o.showOverdrawInspector?a.Color.black:b,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=h.length-1;this.currentLayer>=0;this.currentLayer--){let T=this.style._layers[h[this.currentLayer]],E=t._getLayerSourceCache(T);if(T.isSky())continue;let M=E?_[E.id]:void 0;this._renderTileClippingMasks(T,E,M),this.renderLayer(this,E,T,M)}if(this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<h.length;this.currentLayer++){let T=this.style._layers[h[this.currentLayer]],E=t._getLayerSourceCache(T);T.isSky()&&this.renderLayer(this,E,T,E?_[E.id]:void 0)}for(this.transform.projection.name==="globe"&&function(T){let E=T.context,M=E.gl,D=T.transform,B=new a.DepthMode(M.LEQUAL,a.DepthMode.ReadOnly,[0,1]),P=T.useProgram("globeAtmosphere"),z=D.centerOffset,G=D._camera.getCameraToClipPerspective(D._fov,D.width/D.height,D._nearZ,D._farZ);G[8]=2*-z.x/D.width,G[9]=2*z.y/D.height;let F=a.invert([],G),j=a.mul([],F,D.projMatrix),N={u_frustum_tl:Ar([-1,1,1],F),u_frustum_tr:Ar([1,1,1],F),u_frustum_br:Ar([1,-1,1],F),u_frustum_bl:Ar([-1,-1,1],F),u_globe_pos:Ar([D.globeMatrix[12],D.globeMatrix[13],D.globeMatrix[14]],j),u_globe_radius:D.worldSize/2/Math.PI-1,u_opacity:1-a.globeToMercatorTransition(D.zoom),u_fadeout_range:2,u_start_color:[1,1,1],u_end_color:[.0118,.7451,.9882]};T.prepareDrawProgram(E,P);let $=T.globeSharedBuffers;$&&P.draw(E,M.TRIANGLES,B,a.StencilMode.disabled,a.ColorMode.alphaBlended,a.CullFaceMode.backCW,N,"skybox",$.atmosphereVertexBuffer,$.atmosphereIndexBuffer,$.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<h.length;){let T=this.style._layers[h[this.currentLayer]],E=t._getLayerSourceCache(T);if(T.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(T)){if(T.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}let M=E?(T.type==="symbol"?y:_)[E.id]:void 0;this._renderTileClippingMasks(T,E,E?f[E.id]:void 0),this.renderLayer(this,E,T,M),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let T=null;a.values(this.style._layers).forEach(E=>{let M=t._getLayerSourceCache(E);M&&!E.isHidden(this.transform.zoom)&&(!T||T.getSource().maxzoom<M.getSource().maxzoom)&&(T=M)}),T&&this.options.showTileBoundaries&&Ea.debug(this,T,T.getVisibleCoordinates())}this.options.showPadding&&function(T){let E=T.transform.padding;Ae(T,T.transform.height-(E.top||0),3,wa),Ae(T,E.bottom||0,3,Ta),Si(T,E.left||0,3,Ol),Si(T,T.transform.width-(E.right||0),3,Es);let M=T.transform.centerPoint;(function(D,B,P,z){Mo(D,B-1,P-10,2,20,z),Mo(D,B-10,P-1,20,2,z)})(T,M.x,T.transform.height-M.y,Ss)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(a.window.performance.now()),this.saveCanvasCopy())}renderLayer(t,o,h,d){h.isHidden(this.transform.zoom)||(h.type==="background"||h.type==="sky"||h.type==="custom"||d&&d.length)&&(this.id=h.id,this.gpuTimingStart(h),t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes(h.type)||Ea[h.type](t,o,h,d,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;let o=this.context.extTimerQuery,h=this.gpuTimers[t.id];h||(h=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:o.createQueryEXT()}),h.calls++,o.beginQueryEXT(o.TIME_ELAPSED_EXT,h.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;let t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){let t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){let o={};for(let h in t){let d=t[h],f=this.context.extTimerQuery,_=f.getQueryObjectEXT(d.query,f.QUERY_RESULT_EXT)/1e6;f.deleteQueryEXT(d.query),o[h]=_}return o}translatePosMatrix(t,o,h,d,f){if(!h[0]&&!h[1])return t;let _=f?d==="map"?this.transform.angle:0:d==="viewport"?-this.transform.angle:0;if(_){let T=Math.sin(_),E=Math.cos(_);h=[h[0]*E-h[1]*T,h[0]*T+h[1]*E]}let y=[f?h[0]:Yt(o,h[0],this.transform.zoom),f?h[1]:Yt(o,h[1],this.transform.zoom),0],b=new Float32Array(16);return a.translate(b,t,y),b}saveTileTexture(t){let o=this._tileTextures[t.size[0]];o?o.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let o=this._tileTextures[t];return o&&o.length>0?o.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let o=this.imageManager.getPattern(t.from.toString()),h=this.imageManager.getPattern(t.to.toString());return!o||!h}currentGlobalDefines(){let t=this.terrain&&this.terrain.renderingToTexture,o=this.style&&this.style.fog,h=[];return this.terrain&&!this.terrain.renderingToTexture&&h.push("TERRAIN"),o&&!t&&o.getOpacity(this.transform.pitch)!==0&&h.push("FOG"),t&&h.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&h.push("OVERDRAW_INSPECTOR"),h}useProgram(t,o,h){this.cache=this.cache||{};let d=h||[],f=this.currentGlobalDefines().concat(d),_=To.cacheKey(t,f,o);return this.cache[_]||(this.cache[_]=new To(this.context,t,vo[t],o,gt[t],f)),this.cache[_]}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(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=a.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.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()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(t,o,h){if(this.terrain&&this.terrain.renderingToTexture)return;let d=this.style.fog;if(d){let f=d.getOpacity(this.transform.pitch);f!==0&&o.setFogUniformValues(t,((_,y,b,T)=>{let E=y.properties.get("color"),M=_.frameCounter/1e3%1,D=[E.r/E.a,E.g/E.a,E.b/E.a,T];return{u_fog_matrix:b?_.transform.calculateFogTileMatrix(b):_.identityMat,u_fog_range:y.getFovAdjustedRange(_.transform._fov),u_fog_color:D,u_fog_horizon_blend:y.properties.get("horizon-blend"),u_fog_temporal_offset:M}})(this,d,h,f))}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){let t=this.context.gl,o=t.createTexture();return t.bindTexture(t.TEXTURE_2D,o),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;let t=this.style&&this.style.fog;return!!t&&t.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){let t=this._backgroundTiles,o=this._backgroundTiles={},h=this.transform.coveringTiles({tileSize:512});for(let d of h)o[d.key]=t[d.key]||new a.Tile(d,512,this.transform.tileZoom,this);return o}clearBackgroundTiles(){this._backgroundTiles={}}}class Cr{constructor(t=0,o=0,h=0,d=0){if(isNaN(t)||t<0||isNaN(o)||o<0||isNaN(h)||h<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=o,this.left=h,this.right=d}interpolate(t,o,h){return o.top!=null&&t.top!=null&&(this.top=a.number(t.top,o.top,h)),o.bottom!=null&&t.bottom!=null&&(this.bottom=a.number(t.bottom,o.bottom,h)),o.left!=null&&t.left!=null&&(this.left=a.number(t.left,o.left,h)),o.right!=null&&t.right!=null&&(this.right=a.number(t.right,o.right,h)),this}getCenter(t,o){let h=a.clamp((this.left+t-this.right)/2,0,t),d=a.clamp((this.top+o-this.bottom)/2,0,o);return new a.pointGeometry(h,d)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Cr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Nl(l,t){let o=a.getColumn(l,3);a.fromQuat(l,t),a.setColumn(l,3,o)}function Sa(l,t){let o=a.identity$1([]);return a.rotateZ$1(o,o,-t),a.rotateX$1(o,o,-l),o}function Is(l,t){let o=[l[0],l[1],0],h=[t[0],t[1],0];if(a.length(o)>=1e-15){let _=a.normalize([],o);a.scale$2(h,_,a.dot(h,_)),t[0]=h[0],t[1]=h[1]}let d=a.cross([],t,l);if(a.len(d)<1e-15)return null;let f=Math.atan2(-d[1],d[0]);return Sa(Math.atan2(Math.sqrt(l[0]*l[0]+l[1]*l[1]),-l[2]),f)}class Co{constructor(t,o){this.position=t,this.orientation=o}get position(){return this._position}set position(t){if(t){let o=t instanceof a.MercatorCoordinate?t:new a.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(o.x=a.wrap(o.x,0,1)),this._position=o}else this._position=null}lookAtPoint(t,o){if(this.orientation=null,!this.position)return;let h=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(t)):0,d=this.position,f=a.MercatorCoordinate.fromLngLat(t,h),_=[f.x-d.x,f.y-d.y,f.z-d.z];o||(o=[0,0,1]),o[2]=Math.abs(o[2]),this.orientation=Is(_,o)}setPitchBearing(t,o){this.orientation=Sa(a.degToRad(t),a.degToRad(-o))}}class zo{constructor(t,o){this._transform=a.identity([]),this.orientation=o,this.position=t}get mercatorPosition(){let t=this.position;return new a.MercatorCoordinate(t[0],t[1],t[2])}get position(){let t=a.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var o;t&&a.setColumn(this._transform,3,[(o=t)[0],o[1],o[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||a.identity$1([]),t&&Nl(this._transform,this._orientation)}getPitchBearing(){let t=this.forward(),o=this.right();return{bearing:Math.atan2(-o[1],o[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,o){this._orientation=Sa(t,o),Nl(this._transform,this._orientation)}forward(){let t=a.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){let t=a.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){let t=a.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,o){let h=new Float64Array(16);return a.invert(h,this.getWorldToCamera(t,o)),h}getWorldToCameraPosition(t,o,h){let d=this.position;a.scale$2(d,d,-t);let f=new Float64Array(16);return a.fromScaling(f,[h,h,h]),a.translate(f,f,d),f[10]*=o,f}getWorldToCamera(t,o){let h=new Float64Array(16),d=new Float64Array(4),f=this.position;return a.conjugate(d,this._orientation),a.scale$2(f,f,-t),a.fromQuat(h,d),a.translate(h,h,f),h[1]*=-1,h[5]*=-1,h[9]*=-1,h[13]*=-1,h[8]*=o,h[9]*=o,h[10]*=o,h[11]*=o,h}getCameraToClipPerspective(t,o,h,d){let f=new Float64Array(16);return a.perspective(f,t,o,h,d),f}getDistanceToElevation(t){let o=t===0?0:a.mercatorZfromAltitude(t,this.position[1]),h=this.forward();return(o-this.position[2])/h[2]}clone(){return new zo([...this.position],[...this.orientation])}}function Ia(l,t){let o=ko(l),h=function(f,_,y,b,T){let E=new a.LngLat(y.lng-180*zr,y.lat),M=new a.LngLat(y.lng+180*zr,y.lat),D=f.project(E.lng,E.lat),B=f.project(M.lng,M.lat),P=-Math.atan2(B.y-D.y,B.x-D.x),z=a.MercatorCoordinate.fromLngLat(y);z.y=a.clamp(z.y,-.999975,.999975);let G=z.toLngLat(),F=f.project(G.lng,G.lat),j=a.MercatorCoordinate.fromLngLat(G);j.x+=zr;let N=j.toLngLat(),$=f.project(N.lng,N.lat),V=Ca($.x-F.x,$.y-F.y,P),X=a.MercatorCoordinate.fromLngLat(G);X.y+=zr;let ie=X.toLngLat(),ae=f.project(ie.lng,ie.lat),ue=Ca(ae.x-F.x,ae.y-F.y,P),ce=Math.abs(V.x)/Math.abs(ue.y),we=a.identity([]);a.rotateZ(we,we,-P*(1-(T?0:b)));let re=a.identity([]);return a.scale(re,re,[1,1-(1-ce)*b,1]),re[4]=-ue.x/ue.y*b,a.rotateZ(re,re,P),a.multiply$1(re,we,re),re}(l.projection,0,l.center,o,t),d=Ma(l);return a.scale(h,h,[d,d,1]),h}function Ma(l){let t=l.projection,o=ko(l),h=Aa(t,l.center),d=Aa(t,a.LngLat.convert(t.center));return Math.pow(2,h*o+(1-o)*d)}function ko(l){let t=l.projection.range;if(!t)return 0;let o=Math.max(l.width,l.height),h=Math.log(o/1024)/Math.LN2;return a.smoothstep(t[0]+h,t[1]+h,l.zoom)}let zr=1/4e4;function Aa(l,t){let o=a.clamp(t.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),h=new a.LngLat(t.lng-180*zr,o),d=new a.LngLat(t.lng+180*zr,o),f=l.project(h.lng,o),_=l.project(d.lng,o),y=a.MercatorCoordinate.fromLngLat(h),b=a.MercatorCoordinate.fromLngLat(d),T=_.x-f.x,E=_.y-f.y,M=b.x-y.x,D=b.y-y.y,B=Math.sqrt((M*M+D*D)/(T*T+E*E));return Math.log(B)/Math.LN2}function Ca(l,t,o){let h=Math.cos(o),d=Math.sin(o);return{x:l*h-t*d,y:l*d+t*h}}class Ms{constructor(t,o,h,d,f,_,y){this.tileSize=512,this._renderWorldCopies=f===void 0||f,this._minZoom=t||0,this._maxZoom=o||22,this._minPitch=h??0,this._maxPitch=d??60,this.setProjection(_),this.setMaxBounds(y),this.width=0,this.height=0,this._center=new a.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 Cr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new zo,this._centerAltitude=0,this._centerAltitudeValidForExaggeration=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){let t=new Ms(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(t){let o=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||o)&&this._updateCameraOnTerrain(),(t||o)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels"])}setProjection(t){t==null&&(t={name:"mercator"}),this.projectionOptions=t;let o=this.projection?this.getProjection():void 0;this.projection=a.getProjection(t);let h=this.getProjection();return _e(o,h)?null:(this._calcMatrices(),h)}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){let t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.pointGeometry(this.width,this.height)}get bearing(){return a.wrap(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(t){let o=-t*Math.PI/180;var h;this.angle!==o&&(this._unmodified=!1,this.angle=o,this._calcMatrices(),this.rotationMatrix=(h=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(h[1]=0,h[2]=0),h[0]=1,h[3]=1,h),function(d,f,_){var y=f[0],b=f[1],T=f[2],E=f[3],M=Math.sin(_),D=Math.cos(_);d[0]=y*D+T*M,d[1]=b*D+E*M,d[2]=y*-M+T*D,d[3]=b*-M+E*D}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){let o=a.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==o&&(this._unmodified=!1,this._pitch=o,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){let o=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==o&&(this._unmodified=!1,this._setZoom(o),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=0);let t=this._elevation;this._centerAltitude=t.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=t.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;let t=this._elevation,o=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],h=this.horizonLineFromTop(),d=0,f=0;for(let _=0;_<o.length;_++){let y=new a.pointGeometry(o[_][0]*this.width,h+o[_][1]*(this.height-h)),b=t.pointCoordinate(y);if(!b)continue;let T=1/Math.hypot(b[0]-this._camera.position[0],b[1]-this._camera.position[1]);d+=b[3]*T,f+=T}return f===0?NaN:d/f}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;let t=this._seaLevelZoom,o=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),h=this.pixelsPerMeter/this.worldSize*o,d=this._mercatorZfromZoom(t),f=this._mercatorZfromZoom(this._maxZoom),_=Math.max(d-h,f);this._setZoom(this._zoomFromMercatorZ(_))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}computeZoomRelativeTo(t){let o=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude())),h;h=t.z<this._camera.position[2]?[o.x,o.y,o.z]:[t.x,t.y,t.z];let d=a.length(a.sub([],this._camera.position,h));return a.clamp(this._zoomFromMercatorZ(d),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height||!t.position&&!t.orientation)return;this._updateCameraState();let o=!1;if(t.orientation&&!a.exactEquals(t.orientation,this._camera.orientation)&&(o=this._setCameraOrientation(t.orientation)),t.position){let h=[t.position.x,t.position.y,t.position.z];a.exactEquals$1(h,this._camera.position)||(this._setCameraPosition(h),o=!0)}o&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();let t=this._camera.position,o=new Co;return o.position=new a.MercatorCoordinate(t[0],t[1],t[2]),o.orientation=this._camera.orientation,o._elevation=this.elevation,o._renderWorldCopies=this.renderWorldCopies,o}_setCameraOrientation(t){if(!a.length$1(t))return!1;a.normalize$1(t,t);let o=a.transformQuat([],[0,0,-1],t),h=a.transformQuat([],[0,-1,0],t);if(h[2]<0)return!1;let d=Is(o,h);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(t){let o=this.zoomScale(this.minZoom)*this.tileSize,h=this.zoomScale(this.maxZoom)*this.tileSize,d=this.cameraToCenterDistance;t[2]=a.clamp(t[2],d/h,d/o),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,o,h){this._unmodified=!1,this._edgeInsets.interpolate(t,o,h),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){let o=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,o)}getVisibleUnwrappedCoordinates(t){let o=[new a.UnwrappedTileID(0,t)];if(this.renderWorldCopies){let h=this.pointCoordinate(new a.pointGeometry(0,0)),d=this.pointCoordinate(new a.pointGeometry(this.width,0)),f=this.pointCoordinate(new a.pointGeometry(this.width,this.height)),_=this.pointCoordinate(new a.pointGeometry(0,this.height)),y=Math.floor(Math.min(h.x,d.x,f.x,_.x)),b=Math.floor(Math.max(h.x,d.x,f.x,_.x)),T=1;for(let E=y-T;E<=b+T;E++)E!==0&&o.push(new a.UnwrappedTileID(E,t))}return o}coveringTiles(t){let o=this.coveringZoomLevel(t),h=o,d=this.elevation&&!t.isTerrainDEM,f=this.projection.name==="mercator";if(t.minzoom!==void 0&&o<t.minzoom)return[];t.maxzoom!==void 0&&o>t.maxzoom&&(o=t.maxzoom);let _=this.locationCoordinate(this.center),y=this.center.lat,b=1<<o,T=[b*_.x,b*_.y,0],E=this.projection.name==="globe",M=!E,D=a.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,o,M),B=E?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),P=b*a.mercatorZfromAltitude(1,this.center.lat),z=this._camera.position[2]/a.mercatorZfromAltitude(1,this.center.lat),G=[b*B.x,b*B.y,z*(M?1:P)],F=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),j=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?o:0,N=t.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,$=t.isTerrainDEM?-N:this._elevation?this._elevation.getMinElevationBelowMSL():0,V=this.projection.isReprojectedInTileSpace?Ma(this):1,X=pe=>{let Ve=new a.MercatorCoordinate(pe.x+25e-6,pe.y,pe.z),De=new a.MercatorCoordinate(pe.x,pe.y+25e-6,pe.z),Pe=pe.toLngLat(),Ze=Ve.toLngLat(),Ye=De.toLngLat(),Fe=this.locationCoordinate(Pe),qe=this.locationCoordinate(Ze),st=this.locationCoordinate(Ye),At=Math.hypot(qe.x-Fe.x,qe.y-Fe.y),Kt=Math.hypot(st.x-Fe.x,st.y-Fe.y);return Math.sqrt(At*Kt)*V/25e-6},ie=pe=>{let ke=N,Ve=$;return{aabb:a.tileAABB(this,b,0,0,0,pe,Ve,ke,this.projection),zoom:0,x:0,y:0,minZ:Ve,maxZ:ke,wrap:pe,fullyVisible:!1}},ae=[],ue=[],ce=o,we=t.reparseOverscaled?h:o,re=pe=>pe*pe,Te=re((z-this._centerAltitude)*P),ve=pe=>{if(!this._elevation||!pe.tileID||!f)return;let ke=this._elevation.getMinMaxForTile(pe.tileID),Ve=pe.aabb;ke?(Ve.min[2]=ke.min,Ve.max[2]=ke.max,Ve.center[2]=(Ve.min[2]+Ve.max[2])/2):(pe.shouldSplit=Le(pe),pe.shouldSplit||(Ve.min[2]=Ve.max[2]=Ve.center[2]=this._centerAltitude))},Le=pe=>{if(pe.zoom<j)return!0;if(pe.zoom===ce)return!1;if(pe.shouldSplit!=null)return pe.shouldSplit;let ke=pe.aabb.distanceX(G),Ve=pe.aabb.distanceY(G),De=Te,Pe=1;if(E){De=re(pe.aabb.distanceZ(G));let Ye=Math.pow(2,pe.zoom),Fe=a.latFromMercatorY((pe.y+1)/Ye),qe=a.latFromMercatorY(pe.y/Ye),st=Math.min(Math.max(y,Fe),qe),At=a.circumferenceAtLatitude(st)/a.circumferenceAtLatitude(y);Pe=Math.min(At,1)}else if(d&&(De=re(pe.aabb.distanceZ(G)*P)),this.projection.isReprojectedInTileSpace&&h<=5){let Ye=Math.pow(2,pe.zoom),Fe=X(new a.MercatorCoordinate((pe.x+.5)/Ye,(pe.y+.5)/Ye));Pe=Fe>.85?1:Fe}let Ze=ke*ke+Ve*Ve+De;return Ze<re((1<<ce-pe.zoom)*F*Pe*((Ye,Fe)=>{if(Fe*re(.707)<Ye)return 1;let qe=Math.sqrt(Fe/Ye);return qe/(1.4144271570014144+(Math.pow(1.1,qe-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(De,Te),Ze))};if(this.renderWorldCopies)for(let pe=1;pe<=3;pe++)ae.push(ie(-pe)),ae.push(ie(pe));for(ae.push(ie(0));ae.length>0;){let pe=ae.pop(),ke=pe.x,Ve=pe.y,De=pe.fullyVisible;if(!De){let Pe=pe.aabb.intersects(D);if(Pe===0)continue;De=Pe===2}if(pe.zoom!==ce&&Le(pe))for(let Pe=0;Pe<4;Pe++){let Ze=(ke<<1)+Pe%2,Ye=(Ve<<1)+(Pe>>1),Fe={aabb:f?pe.aabb.quadrant(Pe):a.tileAABB(this,b,pe.zoom+1,Ze,Ye,pe.wrap,pe.minZ,pe.maxZ,this.projection),zoom:pe.zoom+1,x:Ze,y:Ye,wrap:pe.wrap,fullyVisible:De,tileID:void 0,shouldSplit:void 0,minZ:pe.minZ,maxZ:pe.maxZ};d&&!E&&(Fe.tileID=new a.OverscaledTileID(pe.zoom+1===ce?we:pe.zoom+1,pe.wrap,pe.zoom+1,Ze,Ye),ve(Fe)),ae.push(Fe)}else{let Pe=pe.zoom===ce?we:pe.zoom;if(t.minzoom&&t.minzoom>Pe)continue;let Ze=T[0]-(.5+ke+(pe.wrap<<pe.zoom))*(1<<o-pe.zoom),Ye=T[1]-.5-Ve,Fe=pe.tileID?pe.tileID:new a.OverscaledTileID(Pe,pe.wrap,pe.zoom,ke,Ve);ue.push({tileID:Fe,distanceSq:Ze*Ze+Ye*Ye})}}if(this.fogCullDistSq){let pe=this.fogCullDistSq,ke=this.horizonLineFromTop();ue=ue.filter(Ve=>{let De=[0,0,0,1],Pe=[a.EXTENT,a.EXTENT,0,1],Ze=this.calculateFogTileMatrix(Ve.tileID.toUnwrapped());a.transformMat4$1(De,De,Ze),a.transformMat4$1(Pe,Pe,Ze);let Ye=a.getAABBPointSquareDist(De,Pe);if(Ye===0)return!0;let Fe=!1,qe=this._elevation;if(qe&&Ye>pe&&ke!==0){let st=this.calculateProjMatrix(Ve.tileID.toUnwrapped()),At;t.isTerrainDEM||(At=qe.getMinMaxForTile(Ve.tileID)),At||(At={min:$,max:N});let Kt=a.furthestTileCorner(this.rotation),Jt=[Kt[0]*a.EXTENT,Kt[1]*a.EXTENT,At.max];a.transformMat4(Jt,Jt,st),Fe=(1-Jt[1])*this.height*.5<ke}return Ye<pe||Fe})}return ue.sort((pe,ke)=>pe.distanceSq-ke.distanceSq).map(pe=>pe.tileID)}resize(t,o){this.width=t,this.height=o,this.pixelsToGLUnits=[2/t,-2/o],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){let o=a.clamp(t.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),h=this.projection.project(t.lng,o);return new a.pointGeometry(h.x*this.worldSize,h.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(t,o){let h,d,f=this.centerPoint;if(this.projection.name==="globe"){let y=this.worldSize;h=(o.x-f.x)/y,d=(o.y-f.y)/y}else{let y=this.pointCoordinate(o),b=this.pointCoordinate(f);h=y.x-b.x,d=y.y-b.y}let _=this.locationCoordinate(t);this.setLocation(new a.MercatorCoordinate(_.x-h,_.y-d))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this._coordinatePoint(this.locationCoordinate(t),!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(t,o){let h=o?a.mercatorZfromAltitude(o,t.lat):void 0,d=this.projection.project(t.lng,t.lat);return new a.MercatorCoordinate(d.x,d.y,h)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(t,o){let h=o??this._centerAltitude,d=[t.x,t.y,0,1],f=[t.x,t.y,1,1];a.transformMat4$1(d,d,this.pixelMatrixInverse),a.transformMat4$1(f,f,this.pixelMatrixInverse);let _=f[3];a.scale$1(d,d,1/d[3]),a.scale$1(f,f,1/_);let y=d[2],b=f[2];return{p0:d,p1:f,t:y===b?0:(h-y)/(b-y)}}screenPointToMercatorRay(t){let o=[t.x,t.y,0,1],h=[t.x,t.y,1,1];return a.transformMat4$1(o,o,this.pixelMatrixInverse),a.transformMat4$1(h,h,this.pixelMatrixInverse),a.scale$1(o,o,1/o[3]),a.scale$1(h,h,1/h[3]),o[2]=a.mercatorZfromAltitude(o[2],this._center.lat)*this.worldSize,h[2]=a.mercatorZfromAltitude(h[2],this._center.lat)*this.worldSize,a.scale$1(o,o,1/this.worldSize),a.scale$1(h,h,1/this.worldSize),new a.Ray([o[0],o[1],o[2]],a.normalize([],a.sub([],h,o)))}rayIntersectionCoordinate(t){let{p0:o,p1:h,t:d}=t,f=a.mercatorZfromAltitude(o[2],this._center.lat),_=a.mercatorZfromAltitude(h[2],this._center.lat);return new a.MercatorCoordinate(a.number(o[0],h[0],d)/this.worldSize,a.number(o[1],h[1],d)/this.worldSize,a.number(f,_,d))}pointCoordinate(t,o=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,o)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let o=this.elevation,h=this.elevation.pointCoordinate(t);if(h)return new a.MercatorCoordinate(h[0],h[1],h[2]);let d=0,f=this.horizonLineFromTop();if(t.y>f)return this.pointCoordinate(t);let _=.02*f,y=t.clone();for(let b=0;b<10&&f-d>_;b++){y.y=a.number(d,f,.66);let T=o.pointCoordinate(y);T?(f=y.y,h=T):d=y.y}return h?new a.MercatorCoordinate(h[0],h[1],h[2]):this.pointCoordinate(t)}isPointAboveHorizon(t){if(this.elevation)return!this.elevation.pointCoordinate(t);{let o=this.horizonLineFromTop();return t.y<o}}_coordinatePoint(t,o){let h=o&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,d=[t.x*this.worldSize,t.y*this.worldSize,h+t.toAltitude(),1];return a.transformMat4$1(d,d,this.pixelMatrix),d[3]>0?new a.pointGeometry(d[0]/d[3],d[1]/d[3]):new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(t,o){let h=new a.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),d=new a.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),f=new a.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),_=new a.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom),y=this.pointCoordinate(h,t),b=this.pointCoordinate(d,t),T=this.pointCoordinate(f,o),E=this.pointCoordinate(_,o),M=(D,B)=>(B.y-D.y)/(B.x-D.x);return y.y>1&&b.y>=0?y=new a.MercatorCoordinate((1-E.y)/M(E,y)+E.x,1):y.y<0&&b.y<=1&&(y=new a.MercatorCoordinate(-E.y/M(E,y)+E.x,0)),b.y>1&&y.y>=0?b=new a.MercatorCoordinate((1-T.y)/M(T,b)+T.x,1):b.y<0&&y.y<=1&&(b=new a.MercatorCoordinate(-T.y/M(T,b)+T.x,0)),new a.LngLatBounds().extend(this.coordinateLocation(y)).extend(this.coordinateLocation(b)).extend(this.coordinateLocation(E)).extend(this.coordinateLocation(T))}_getBounds3D(){let t=this.elevation;if(!t.visibleDemTiles.length)return this._getBounds(0,0);let o=t.visibleDemTiles.reduce((h,d)=>{if(d.dem){let f=d.dem.tree;h.min=Math.min(h.min,f.minimums[0]),h.max=Math.max(h.max,f.maximums[0])}return h},{min:Number.MAX_VALUE,max:0});return this._getBounds(o.min*t.exaggeration(),o.max*t.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(t=!0){let o=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,h=this.height/2-o*(1-this._horizonShift);return t?Math.max(0,h):h}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=a.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=a.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=a.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=a.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,o){return this.projection.createTileMatrix(this,o,t)}calculateDistanceTileData(t){let o=t.key,h=this._distanceTileDataCache;if(h[o])return h[o];let d=t.canonical,f=1/this.height,_=this.cameraWorldSize/this.zoomScale(d.z),y=(d.x+Math.pow(2,d.z)*t.wrap)*_,b=d.y*_,T=this.point,E=this.angle,M=Math.sin(-E),D=-Math.cos(-E);return h[o]={bearing:[M,D],center:[(T.x-y)*f,(T.y-b)*f],scale:_/a.EXTENT*f},h[o]}calculateFogTileMatrix(t){let o=t.key,h=this._fogTileMatrixCache;if(h[o])return h[o];let d=this.calculatePosMatrix(t,this.cameraWorldSize);return a.multiply$1(d,this.worldToFogMatrix,d),h[o]=new Float32Array(d),h[o]}calculateProjMatrix(t,o=!1){let h=t.key,d=o?this._alignedProjMatrixCache:this._projMatrixCache;if(d[h])return d[h];let f=this.calculatePosMatrix(t,this.worldSize);return a.multiply$1(f,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:o?this.alignedProjMatrix:this.projMatrix,f),d[h]=new Float32Array(f),d[h]}calculatePixelsToTileUnitsMatrix(t){let o=t.tileID.key,h=this._pixelsToTileUnitsCache;if(h[o])return h[o];let d=function(f,_){let{scale:y}=f.tileTransform,b=y*a.EXTENT/(f.tileSize*Math.pow(2,_.zoom-f.tileID.overscaledZ+f.tileID.canonical.z));return T=new Float32Array(4),D=(E=_.inverseAdjustmentMatrix)[1],B=E[2],P=E[3],G=(M=[b,b])[1],T[0]=E[0]*(z=M[0]),T[1]=D*z,T[2]=B*G,T[3]=P*G,T;var T,E,M,D,B,P,z,G}(t,this);return h[o]=d,h[o]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;let t=this._elevation;this._updateCameraState();let o=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,h=this._computeCameraPosition(o),d=this._camera.forward(),f=a.mercatorZfromAltitude(1,this._center.lat);h[2]/=f,d[2]/=f,a.normalize(d,d);let _=t.raycast(h,d,t.exaggeration());if(_){let y=a.scaleAndAdd([],h,d,_),b=new a.MercatorCoordinate(y[0],y[1],a.mercatorZfromAltitude(y[2],a.latFromMercatorY(y[1]))),T=(b.z+a.length([b.x-h[0],b.y-h[1],b.z-h[2]*f]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(T),this._centerAltitude=b.toAltitude(),this._center=this.coordinateLocation(b),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;let t=this._elevation;this._updateCameraState();let o=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,h=this._computeCameraPosition(o),d=t.getAtPointOrZero(new a.MercatorCoordinate(...h)),f=this._minimumHeightOverTerrain()*Math.cos(a.degToRad(this._maxPitch)),_=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*d;if(_<f){let y=this.locationCoordinate(this._center,this._centerAltitude),b=[y.x-h[0],y.y-h[1],y.z-h[2]],T=a.length(b);b[2]-=(f-_)/this._projectionScaler;let E=a.length(b);if(E===0)return;a.scale$2(b,b,T/E*this._projectionScaler),this._camera.position=[y.x-b[0],y.y-b[1],y.z*this._projectionScaler-b[2]],this._camera.orientation=Is(b,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){let M=this.center;return M.lat=a.clamp(M.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(M.lng=a.clamp(M.lng,this.minLng,this.maxLng)),this.center=M,void(this._constraining=!1)}let t=this._unmodified,{x:o,y:h}=this.point,d=0,f=o,_=h,y=this.width/2,b=this.height/2,T=this.worldMinY*this.scale,E=this.worldMaxY*this.scale;if(h-b<T&&(_=T+b),h+b>E&&(_=E-b),E-T<this.height&&(d=Math.max(d,this.height/(E-T)),_=(E+T)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){let M=this.worldMinX*this.scale,D=this.worldMaxX*this.scale,B=this.worldSize/2-(M+D)/2;f=(o+B+this.worldSize)%this.worldSize-B,f-y<M&&(f=M+y),f+y>D&&(f=D-y),D-M<this.width&&(d=Math.max(d,this.width/(D-M)),f=(D+M)/2)}f===o&&_===h||(this.center=this.unproject(new a.pointGeometry(f,_))),d&&(this.zoom+=this.scaleZoom(d)),this._constrainCameraAltitude(),this._unmodified=t,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;let t=this._fov/2,o=this.centerOffset,h=this.pixelsPerMeter;this._projectionScaler=h/(a.mercatorZfromAltitude(1,this.center.lat)*this.worldSize),this.cameraToCenterDistance=.5/Math.tan(t)*this.height*this._projectionScaler,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;let d=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?h:1),f=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);f[8]=2*-o.x/this.width,f[9]=2*o.y/this.height;let _=a.mul([],f,d);if(this.projection.isReprojectedInTileSpace){let $=this.locationCoordinate(this.center),V=a.identity([]);a.translate(V,V,[$.x*this.worldSize,$.y*this.worldSize,0]),a.multiply$1(V,V,Ia(this)),a.translate(V,V,[-$.x*this.worldSize,-$.y*this.worldSize,0]),a.multiply$1(_,_,V),this.inverseAdjustmentMatrix=function(X){let ie=Ia(X,!0);return vn([],[ie[0],ie[1],ie[4],ie[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=a.scale([],_,[this.worldSize,this.worldSize,this.worldSize/h,1]),this.projMatrix=_,this.invProjMatrix=a.invert(new Float64Array(16),this.projMatrix);let y=new Float32Array(16);a.identity(y),a.scale(y,y,[1,-1,1]),a.rotateX(y,y,this._pitch),a.rotateZ(y,y,this.angle);let b=a.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),T=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;b[8]=2*-o.x/this.width,b[9]=2*(o.y+T)/this.height,this.skyboxMatrix=a.multiply$1(y,b,y);let E=this.point,M=E.x,D=E.y,B=this.width%2/2,P=this.height%2/2,z=Math.cos(this.angle),G=Math.sin(this.angle),F=M-Math.round(M)+z*B+G*P,j=D-Math.round(D)+z*P+G*B,N=new Float64Array(_);if(a.translate(N,N,[F>.5?F-1:F,j>.5?j-1:j,0]),this.alignedProjMatrix=N,_=a.create(),a.scale(_,_,[this.width/2,-this.height/2,1]),a.translate(_,_,[1,-1,0]),this.labelPlaneMatrix=_,_=a.create(),a.scale(_,_,[1,-1,1]),a.translate(_,_,[-1,-1,0]),a.scale(_,_,[2/this.width,2/this.height,1]),this.glCoordMatrix=_,this.pixelMatrix=a.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},_=a.invert(new Float64Array(16),this.pixelMatrix),!_)throw new Error("failed to invert matrix");this.pixelMatrixInverse=_,this.globeMatrix=this.projection.name==="globe"?a.calculateGlobeMatrix(this):_,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};let t=this.cameraWorldSize,o=this.cameraPixelsPerMeter,h=this._camera.position,d=1/this.height,f=[t,t,o];a.scale$2(f,f,d),a.scale$2(h,h,-1),a.multiply$2(h,h,f);let _=a.create();a.translate(_,_,h),a.scale(_,_,f),this.mercatorFogMatrix=_,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,o,d)}_computeCameraPosition(t){let o=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,h=this._camera.forward(),d=this.point,f=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*o-t/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-h[0]*f,d.y/this.worldSize-h[1]*f,t/this.worldSize*this._centerAltitude-h[2]*f]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){let o=this._maxCameraBoundsDistance()*Math.cos(this._pitch),h=t[2],d=1;h>0&&(d=Math.min((o-this._camera.position[2])/h,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,t,d),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){let t=this._camera.position,o=this._camera.forward(),{pitch:h,bearing:d}=this._camera.getPitchBearing(),f=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,_=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),y=Math.max((t[2]-f)/Math.cos(h),_),b=this._zoomFromMercatorZ(y);a.scaleAndAdd(t,t,o,y),this._pitch=a.clamp(h,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(d,-Math.PI,Math.PI),this._setZoom(a.clamp(b,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new a.MercatorCoordinate(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){let t=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(a.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(t,o){let h=Math.min(t.x,o.x),d=Math.max(t.x,o.x),f=Math.min(t.y,o.y),_=Math.max(t.y,o.y);if(f<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;let y=[new a.pointGeometry(h,f),new a.pointGeometry(d,_),new a.pointGeometry(h,_),new a.pointGeometry(d,f)],b=this.renderWorldCopies?-3:0,T=this.renderWorldCopies?4:1;for(let E of y){let M=this.pointRayIntersection(E);if(M.t<0)return!0;let D=this.rayIntersectionCoordinate(M);if(D.x<b||D.y<0||D.x>T||D.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.pointGeometry(0,0),new a.pointGeometry(this.width,this.height))}zoomDeltaToMovement(t,o){let h=a.length(a.sub([],this._camera.position,t)),d=this._zoomFromMercatorZ(h)+o;return h-this._mercatorZfromZoom(d)}getCameraPoint(){let t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.pointGeometry(0,t))}}function za(l,t){let o=!1,h=null,d=()=>{h=null,o&&(l(),h=setTimeout(d,t),o=!1)};return()=>(o=!0,h||d(),h)}class Gl{constructor(t){this._hashName=t&&encodeURIComponent(t),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=za(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,a.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),a.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(t){let o=this._map;if(!o)return"";let h=o.getCenter(),d=Math.round(100*o.getZoom())/100,f=Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10),_=Math.pow(10,f),y=Math.round(h.lng*_)/_,b=Math.round(h.lat*_)/_,T=o.getBearing(),E=o.getPitch(),M="";if(M+=t?`/${y}/${b}/${d}`:`${d}/${b}/${y}`,(T||E)&&(M+="/"+Math.round(10*T)/10),E&&(M+=`/${Math.round(E)}`),this._hashName){let D=this._hashName,B=!1,P=a.window.location.hash.slice(1).split("&").map(z=>{let G=z.split("=")[0];return G===D?(B=!0,`${G}=${M}`):z}).filter(z=>z);return B||P.push(`${D}=${M}`),`#${P.join("&")}`}return`#${M}`}_getCurrentHash(){let t=a.window.location.hash.replace("#","");if(this._hashName){let o;return t.split("&").map(h=>h.split("=")).forEach(h=>{h[0]===this._hashName&&(o=h)}),(o&&o[1]||"").split("/")}return t.split("/")}_onHashChange(){let t=this._map;if(!t)return!1;let o=this._getCurrentHash();if(o.length>=3&&!o.some(h=>isNaN(h))){let h=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(o[3]||0):t.getBearing();return t.jumpTo({center:[+o[2],+o[1]],zoom:+o[0],bearing:h,pitch:+(o[4]||0)}),!0}return!1}_updateHashUnthrottled(){let t=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,t)}}let lr={linearity:.3,easing:a.bezier(0,0,.3,1)},Zl=a.extend({deceleration:2500,maxSpeed:1400},lr),$l=a.extend({deceleration:20,maxSpeed:1400},lr),ql=a.extend({deceleration:1e3,maxSpeed:360},lr),Xl=a.extend({deceleration:1e3,maxSpeed:90},lr);class Wl{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,o=a.exported.now();for(;t.length>0&&o-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let o={zoom:0,bearing:0,pitch:0,pan:new a.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(let{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);let h=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,d={};if(o.pan.mag()){let f=Zt(o.pan.mag(),h,a.extend({},Zl,t||{}));d.offset=o.pan.mult(f.amount/o.pan.mag()),d.center=this._map.transform.center,Do(d,f)}if(o.zoom){let f=Zt(o.zoom,h,$l);d.zoom=this._map.transform.zoom+f.amount,Do(d,f)}if(o.bearing){let f=Zt(o.bearing,h,ql);d.bearing=this._map.transform.bearing+a.clamp(f.amount,-179,179),Do(d,f)}if(o.pitch){let f=Zt(o.pitch,h,Xl);d.pitch=this._map.transform.pitch+f.amount,Do(d,f)}if(d.zoom||d.bearing){let 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 Do(l,t){(!l.duration||l.duration<t.duration)&&(l.duration=t.duration,l.easing=t.easing)}function Zt(l,t,o){let{maxSpeed:h,linearity:d,deceleration:f}=o,_=a.clamp(l*d/(t/1e3),-h,h),y=Math.abs(_)/(f*d);return{easing:o.easing,duration:1e3*y,amount:_*(y/2)}}class mi extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o,h,d={}){let f=Hi(o.getCanvasContainer(),h),_=o.unproject(f);super(t,a.extend({point:f,lngLat:_,originalEvent:h},d)),this._defaultPrevented=!1,this.target=o}}class Po extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o,h){let d=t==="touchend"?h.changedTouches:h.touches,f=at(o.getCanvasContainer(),d),_=f.map(b=>o.unproject(b)),y=f.reduce((b,T,E,M)=>b.add(T.div(M.length)),new a.pointGeometry(0,0));super(t,{points:f,point:y,lngLats:_,lngLat:o.unproject(y),originalEvent:h}),this._defaultPrevented=!1}}class sh extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o,h){super(t,{originalEvent:h}),this._defaultPrevented=!1}}class ah{constructor(t,o){this._map=t,this._clickTolerance=o.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new sh(t.type,this._map,t))}mousedown(t,o){return this._mousedownPos=o,this._firePreventable(new mi(t.type,this._map,t))}mouseup(t){this._map.fire(new mi(t.type,this._map,t))}preclick(t){let o=a.extend({},t);o.type="preclick",this._map.fire(new mi(o.type,this._map,o))}click(t,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(t),this._map.fire(new mi(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new mi(t.type,this._map,t))}mouseover(t){this._map.fire(new mi(t.type,this._map,t))}mouseout(t){this._map.fire(new mi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Po(t.type,this._map,t))}touchmove(t){this._map.fire(new Po(t.type,this._map,t))}touchend(t){this._map.fire(new Po(t.type,this._map,t))}touchcancel(t){this._map.fire(new Po(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cr{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new mi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new mi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new mi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Hl{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._container=t.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(t,o){this.isEnabled()&&t.shiftKey&&t.button===0&&(ri(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(t,o){if(!this._active)return;let h=o;if(this._lastPos.equals(h)||!this._box&&h.dist(this._startPos)<this._clickTolerance)return;let d=this._startPos;this._lastPos=h,this._box||(this._box=et("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));let f=Math.min(d.x,h.x),_=Math.max(d.x,h.x),y=Math.min(d.y,h.y),b=Math.max(d.y,h.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${f}px,${y}px)`,this._box.style.width=_-f+"px",this._box.style.height=b-y+"px")})}mouseupWindow(t,o){if(!this._active||t.button!==0)return;let h=this._startPos,d=o;if(this.reset(),Gr(),h.x!==d.x||h.y!==d.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:f=>f.fitScreenCoordinates(h,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),Yo(),delete this._startPos,delete this._lastPos}_fireEvent(t,o){return this._map.fire(new a.Event(t,{originalEvent:o}))}}function kr(l,t){let o={};for(let h=0;h<l.length;h++)o[l[h].identifier]=t[h];return o}class er{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,o,h){(this.centroid||h.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=t.timeStamp),h.length===this.numTouches&&(this.centroid=function(d){let f=new a.pointGeometry(0,0);for(let _ of d)f._add(_);return f.div(d.length)}(o),this.touches=kr(h,o)))}touchmove(t,o,h){if(this.aborted||!this.centroid)return;let d=kr(h,o);for(let f in this.touches){let _=this.touches[f],y=d[f];(!y||y.dist(_)>30)&&(this.aborted=!0)}}touchend(t,o,h){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),h.length===0){let d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class Vn{constructor(t){this.singleTap=new er(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,o,h){this.singleTap.touchstart(t,o,h)}touchmove(t,o,h){this.singleTap.touchmove(t,o,h)}touchend(t,o,h){let d=this.singleTap.touchend(t,o,h);if(d){let f=t.timeStamp-this.lastTime<500,_=!this.lastTap||this.lastTap.dist(d)<30;if(f&&_||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class ze{constructor(){this._zoomIn=new Vn({numTouches:1,numTaps:2}),this._zoomOut=new Vn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,o,h){this._zoomIn.touchstart(t,o,h),this._zoomOut.touchstart(t,o,h)}touchmove(t,o,h){this._zoomIn.touchmove(t,o,h),this._zoomOut.touchmove(t,o,h)}touchend(t,o,h){let d=this._zoomIn.touchend(t,o,h),f=this._zoomOut.touchend(t,o,h);return d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()+1,around:_.unproject(d)},{originalEvent:t})}):f?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()-1,around:_.unproject(f)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}let Yl={0:1,2:2};class As{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,o){return!1}_move(t,o){return{}}mousedown(t,o){if(this._lastPoint)return;let h=so(t);this._correctButton(t,h)&&(this._lastPoint=o,this._eventButton=h)}mousemoveWindow(t,o){let h=this._lastPoint;if(h){if(t.preventDefault(),this._eventButton!=null&&function(d,f){let _=Yl[f];return d.buttons===void 0||(d.buttons&_)!==_}(t,this._eventButton))this.reset();else if(this._moved||!(o.dist(h)<this._clickTolerance))return this._moved=!0,this._lastPoint=o,this._move(h,o)}}mouseupWindow(t){this._lastPoint&&so(t)===this._eventButton&&(this._moved&&Gr(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Lo extends As{mousedown(t,o){super.mousedown(t,o),this._lastPoint&&(this._active=!0)}_correctButton(t,o){return o===0&&!t.ctrlKey}_move(t,o){return{around:o,panDelta:o.sub(t)}}}class jn extends As{_correctButton(t,o){return o===0&&t.ctrlKey||o===2}_move(t,o){let h=.8*(o.x-t.x);if(h)return this._active=!0,{bearingDelta:h}}contextmenu(t){t.preventDefault()}}class ka extends As{_correctButton(t,o){return o===0&&t.ctrlKey||o===2}_move(t,o){let h=-.5*(o.y-t.y);if(h)return this._active=!0,{pitchDelta:h}}contextmenu(t){t.preventDefault()}}class Kl{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),a.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new a.pointGeometry(0,0)}touchstart(t,o,h){return this._calculateTransform(t,o,h)}touchmove(t,o,h){if(this._active&&!(h.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(h.length===1)return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.preventDefault(),this._calculateTransform(t,o,h)}}touchend(t,o,h){this._calculateTransform(t,o,h),this._active&&h.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,o,h){h.length>0&&(this._active=!0);let d=kr(h,o),f=new a.pointGeometry(0,0),_=new a.pointGeometry(0,0),y=0;for(let T in d){let E=d[T],M=this._touches[T];M&&(f._add(E),_._add(E.sub(M)),y++,d[T]=E)}if(this._touches=d,y<this._minTouches||!_.mag())return;let b=_.div(y);return this._sum._add(b),this._sum.mag()<this._clickTolerance?void 0:{around:f.div(y),panDelta:b}}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=et("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==="hidden"&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class Cs{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,o,h){return{}}touchstart(t,o,h){this._firstTwoTouches||h.length<2||(this._firstTwoTouches=[h[0].identifier,h[1].identifier],this._start([o[0],o[1]]))}touchmove(t,o,h){let d=this._firstTwoTouches;if(!d)return;t.preventDefault();let[f,_]=d,y=Bo(h,o,f),b=Bo(h,o,_);if(!y||!b)return;let T=this._aroundCenter?null:y.add(b).div(2);return this._move([y,b],T,t)}touchend(t,o,h){if(!this._firstTwoTouches)return;let[d,f]=this._firstTwoTouches,_=Bo(h,o,d),y=Bo(h,o,f);_&&y||(this._active&&Gr(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Bo(l,t,o){for(let h=0;h<l.length;h++)if(l[h].identifier===o)return t[h]}function Da(l,t){return Math.log(l/t)/Math.LN2}class Jl extends Cs{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,o){let h=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Da(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Da(this._distance,h),pinchAround:o}}}function Pa(l,t){return 180*l.angleWith(t)/Math.PI}class zs extends Cs{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,o){let h=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Pa(this._vector,h),pinchAround:o}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let o=25/(Math.PI*this._minDiameter)*360,h=Pa(t,this._startVector);return Math.abs(h)<o}}function Ro(l){return Math.abs(l.y)>Math.abs(l.x)}class ks extends Cs{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Ro(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,o,h){let d=this._lastPoints;if(!d)return;let f=t[0].sub(d[0]),_=t[1].sub(d[1]);return this._map._cooperativeGestures&&h.touches.length<3||(this._valid=this.gestureBeginsVertically(f,_,h.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(f.y+_.y)/2*-.5})}gestureBeginsVertically(t,o,h){if(this._valid!==void 0)return this._valid;let d=t.mag()>=2,f=o.mag()>=2;if(!d&&!f)return;if(!d||!f)return this._firstMove==null&&(this._firstMove=h),h-this._firstMove<100&&void 0;let _=t.y>0==o.y>0;return Ro(t)&&Ro(o)&&_}}let Ql={panStep:100,bearingStep:15,pitchStep:10};class ec{constructor(){let t=Ql;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let o=0,h=0,d=0,f=0,_=0;switch(t.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:t.shiftKey?h=-1:(t.preventDefault(),f=-1);break;case 39:t.shiftKey?h=1:(t.preventDefault(),f=1);break;case 38:t.shiftKey?d=1:(t.preventDefault(),_=-1);break;case 40:t.shiftKey?d=-1:(t.preventDefault(),_=1);break;default:return}return this._rotationDisabled&&(h=0,d=0),{cameraAnimation:y=>{let b=y.getZoom();y.easeTo({duration:300,easeId:"keyboardHandler",easing:tc,zoom:o?Math.round(b)+o*(t.shiftKey?2:1):b,bearing:y.getBearing()+h*this._bearingStep,pitch:y.getPitch()+d*this._pitchStep,offset:[-f*this._panStep,-_*this._panStep],center:y.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function tc(l){return l*(2-l)}let La=4.000244140625;class ic{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._handler=o,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=t.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,h=a.exported.now(),d=h-(this._lastWheelEventTime||0);this._lastWheelEventTime=h,o!==0&&o%La==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,t)):this._type||(this._type=Math.abs(d*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),t.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=t,this._delta-=o,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let o=Hi(this._el,t);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;let t=this._map.transform,o=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(this._delta!==0){let b=this._type==="wheel"&&Math.abs(this._delta)>La?this._wheelZoomRate:this._defaultZoomRate,T=2/(1+Math.exp(-Math.abs(this._delta*b)));this._delta<0&&T!==0&&(T=1/T);let E=o(),M=Math.pow(2,E),D=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):M;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(D*T))),this._type==="wheel"&&(this._startZoom=o(),this._easing=this._smoothOutEasing(200)),this._delta=0}let h=typeof this._targetZoom=="number"?this._targetZoom:o(),d=this._startZoom,f=this._easing,_,y=!1;if(this._type==="wheel"&&d&&f){let b=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),T=f(b);_=a.number(d,h,T),b<1?this._frameId||(this._frameId=!0):y=!0}else _=h,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:_-o(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let o=a.ease;if(this._prevEase){let h=this._prevEase,d=(a.exported.now()-h.start)/h.duration,f=h.easing(d+.01)-h.easing(d),_=.27/Math.sqrt(f*f+1e-4)*.01,y=Math.sqrt(.0729-_*_);o=a.bezier(_,y,.25,1)}return this._prevEase={start:a.exported.now(),duration:t,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=et("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(a.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`)}_isFullscreen(){return!!a.window.document.fullscreenElement||!!a.window.document.webkitFullscreenElement}_showBlockerAlert(){this._alertContainer.style.visibility==="hidden"&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class rc{constructor(t,o){this._clickZoom=t,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 nc{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,o){return t.preventDefault(),{cameraAnimation:h=>{h.easeTo({duration:300,zoom:h.getZoom()+(t.shiftKey?-1:1),around:h.unproject(o)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ba{constructor(){this._tap=new Vn({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,o,h){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?h.length>0&&(this._swipePoint=o[0],this._swipeTouch=h[0].identifier):this._tap.touchstart(t,o,h))}touchmove(t,o,h){if(this._tapTime){if(this._swipePoint){if(h[0].identifier!==this._swipeTouch)return;let d=o[0],f=d.y-this._swipePoint.y;return this._swipePoint=d,t.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(t,o,h)}touchend(t,o,h){this._tapTime?this._swipePoint&&h.length===0&&this.reset():this._tap.touchend(t,o,h)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class oc{constructor(t,o,h){this._el=t,this._mousePan=o,this._touchPan=h}enable(t){this._inertiaOptions=t||{},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 sc{constructor(t,o,h){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=o,this._mousePitch=h}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 ac{constructor(t,o,h,d){this._el=t,this._touchZoom=o,this._touchRotate=h,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("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()}}let Fo=l=>l.zoom||l.drag||l.pitch||l.rotate;class Ra extends a.Event{}class lc{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,o){let h=a.sub([],o,t);this.radius=a.length(h[2]<0?a.div([],h,this.constants):[h[0],h[1],0])}projectRay(t){a.div(t,t,this.constants),a.normalize(t,t),a.mul$1(t,t,this.constants);let o=a.scale$2([],t,this.radius);if(o[2]>0){let h=a.scale$2([],[0,0,1],a.dot(o,[0,0,1])),d=a.scale$2([],a.normalize([],[o[0],o[1],0]),this.radius),f=a.add([],o,a.scale$2([],a.sub([],a.add([],d,h),o),2));o[0]=f[0],o[1]=f[1]}return o}}function Nn(l){return l.panDelta&&l.panDelta.mag()||l.zoomDelta||l.bearingDelta||l.pitchDelta}class cc{constructor(t,o){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wl(t),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new lc,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(o),a.bindAll(["handleEvent","handleWindowEvent"],this);let h=this._el;this._listeners=[[h,"touchstart",{passive:!0}],[h,"touchmove",{passive:!1}],[h,"touchend",void 0],[h,"touchcancel",void 0],[h,"mousedown",void 0],[h,"mousemove",void 0],[h,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0}],[a.window.document,"mouseup",void 0],[h,"mouseover",void 0],[h,"mouseout",void 0],[h,"dblclick",void 0],[h,"click",void 0],[h,"keydown",{capture:!1}],[h,"keyup",void 0],[h,"wheel",{passive:!1}],[h,"contextmenu",void 0],[a.window,"blur",void 0]];for(let[d,f,_]of this._listeners)d.addEventListener(f,d===a.window.document?this.handleWindowEvent:this.handleEvent,_)}destroy(){for(let[t,o,h]of this._listeners)t.removeEventListener(o,t===a.window.document?this.handleWindowEvent:this.handleEvent,h)}_addDefaultHandlers(t){let o=this._map,h=o.getCanvasContainer();this._add("mapEvent",new ah(o,t));let d=o.boxZoom=new Hl(o,t);this._add("boxZoom",d);let f=new ze,_=new nc;o.doubleClickZoom=new rc(_,f),this._add("tapZoom",f),this._add("clickZoom",_);let y=new Ba;this._add("tapDragZoom",y);let b=o.touchPitch=new ks(o);this._add("touchPitch",b);let T=new jn(t),E=new ka(t);o.dragRotate=new sc(t,T,E),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",E,["mouseRotate"]);let M=new Lo(t),D=new Kl(o,t);o.dragPan=new oc(h,M,D),this._add("mousePan",M),this._add("touchPan",D,["touchZoom","touchRotate"]);let B=new zs,P=new Jl;o.touchZoomRotate=new ac(h,P,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",P,["touchPan","touchRotate"]),this._add("blockableMapEvent",new cr(o));let z=o.scrollZoom=new ic(o,this);this._add("scrollZoom",z,["mousePan"]);let G=o.keyboard=new ec;this._add("keyboard",G);for(let F of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[F]&&o[F].enable(t[F])}_add(t,o,h){this._handlers.push({handlerName:t,handler:o,allowed:h}),this._handlersById[t]=o}stop(t){if(!this._updatingCamera){for(let{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Fo(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,o,h){for(let d in t)if(d!==h&&(!o||o.indexOf(d)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){let o=[];for(let h of t)this._el.contains(h.target)&&o.push(h);return o}handleEvent(t,o){this._updatingCamera=!0;let h=t.type==="renderFrame",d=h?void 0:t,f={needsRenderFrame:!1},_={},y={},b=t.touches?this._getMapTouches(t.touches):void 0,T=b?at(this._el,b):h?void 0:Hi(this._el,t);for(let{handlerName:D,handler:B,allowed:P}of this._handlers){if(!B.isEnabled())continue;let z;this._blockedByActive(y,P,D)?B.reset():B[o||t.type]&&(z=B[o||t.type](t,T,b),this.mergeHandlerResult(f,_,z,D,d),z&&z.needsRenderFrame&&this._triggerRenderFrame()),(z||B.isActive())&&(y[D]=B)}let E={};for(let D in this._previousActiveHandlers)y[D]||(E[D]=d);this._previousActiveHandlers=y,(Object.keys(E).length||Nn(f))&&(this._changes.push([f,_,E]),this._triggerRenderFrame()),(Object.keys(y).length||Nn(f))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:M}=f;M&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],M(this._map))}mergeHandlerResult(t,o,h,d,f){if(!h)return;a.extend(t,h);let _={handlerName:d,originalEvent:h.originalEvent||f};h.zoomDelta!==void 0&&(o.zoom=_),h.panDelta!==void 0&&(o.drag=_),h.pitchDelta!==void 0&&(o.pitch=_),h.bearingDelta!==void 0&&(o.rotate=_)}_applyChanges(){let t={},o={},h={};for(let[d,f,_]of this._changes)d.panDelta&&(t.panDelta=(t.panDelta||new a.pointGeometry(0,0))._add(d.panDelta)),d.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+d.pitchDelta),d.around!==void 0&&(t.around=d.around),d.aroundCoord!==void 0&&(t.aroundCoord=d.aroundCoord),d.pinchAround!==void 0&&(t.pinchAround=d.pinchAround),d.noInertia&&(t.noInertia=d.noInertia),a.extend(o,f),a.extend(h,_);this._updateMapTransform(t,o,h),this._changes=[]}_updateMapTransform(t,o,h){let d=this._map,f=d.transform,_=j=>[j.x,j.y,j.z];if((j=>{let N=this._eventsInProgress.drag;return N&&!this._handlersById[N.handlerName].isActive()})()&&!Nn(t)){let j=f.zoom;f.cameraElevationReference="sea",f.recenterOnTerrain(),f.cameraElevationReference="ground",j!==f.zoom&&this._map._update(!0)}if(!Nn(t))return void this._fireEvents(o,h,!0);let{panDelta:y,zoomDelta:b,bearingDelta:T,pitchDelta:E,around:M,aroundCoord:D,pinchAround:B}=t;B!==void 0&&(M=B),(j=>o.drag&&!this._eventsInProgress.drag)()&&M&&(this._dragOrigin=_(f.pointCoordinate3D(M)),this._trackingEllipsoid.setup(f._camera.position,this._dragOrigin)),f.cameraElevationReference="sea",d._stop(!0),M=M||d.transform.centerPoint,T&&(f.bearing+=T),E&&(f.pitch+=E),f._updateCameraState();let P=[0,0,0];if(y){let j=f.pointCoordinate(M);if(f.projection.name==="globe"){let N=a.latFromMercatorY(j.y),$=f.center.lat,V=Math.min(a.mercatorZfromAltitude(1,N)/a.mercatorZfromAltitude(1,$),2);y=y.rotate(-f.angle),P[0]=-y.x/f.worldSize*V,P[1]=-y.y/f.worldSize*V}else{let N=f.pointCoordinate(M.sub(y));j&&N&&(P[0]=N.x-j.x,P[1]=N.y-j.y)}}let z=f.zoom,G=[0,0,0];if(b){let j=_(D||f.pointCoordinate3D(M)),N={dir:a.normalize([],a.sub([],j,f._camera.position))};if(N.dir[2]<0){let $=f.zoomDeltaToMovement(j,b);a.scale$2(G,N.dir,$)}}let F=a.add(P,P,G);f._translateCameraConstrained(F),b&&Math.abs(f.zoom-z)>1e-4&&f.recenterOnTerrain(),f.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(o,h,!0)}_fireEvents(t,o,h){let d=Fo(this._eventsInProgress),f=Fo(t),_={};for(let E in t){let{originalEvent:M}=t[E];this._eventsInProgress[E]||(_[`${E}start`]=M),this._eventsInProgress[E]=t[E]}!d&&f&&this._fireEvent("movestart",f.originalEvent);for(let E in _)this._fireEvent(E,_[E]);f&&this._fireEvent("move",f.originalEvent);for(let E in t){let{originalEvent:M}=t[E];this._fireEvent(E,M)}let y={},b;for(let E in this._eventsInProgress){let{handlerName:M,originalEvent:D}=this._eventsInProgress[E];this._handlersById[M].isActive()||(delete this._eventsInProgress[E],b=o[M]||D,y[`${E}end`]=b)}for(let E in y)this._fireEvent(E,y[E]);let T=Fo(this._eventsInProgress);if(h&&(d||f)&&!T){this._updatingCamera=!0;let E=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),M=D=>D!==0&&-this._bearingSnap<D&&D<this._bearingSnap;E?(M(E.bearing||this._map.getBearing())&&(E.bearing=0),this._map.easeTo(E,{originalEvent:b})):(this._map.fire(new a.Event("moveend",{originalEvent:b})),M(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,o){this._map.fire(new a.Event(t,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{this._frameId=void 0,this.handleEvent(new Ra("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}let Ds="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Fa extends a.Evented{constructor(t,o){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=o.bearingSnap,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,o){return this.jumpTo({center:t},o)}panBy(t,o,h){return t=a.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,a.extend({offset:t},o),h)}panTo(t,o,h){return this.easeTo(a.extend({center:t},o),h)}getZoom(){return this.transform.zoom}setZoom(t,o){return this.jumpTo({zoom:t},o),this}zoomTo(t,o,h){return this.easeTo(a.extend({zoom:t},o),h)}zoomIn(t,o){return this.zoomTo(this.getZoom()+1,t,o),this}zoomOut(t,o){return this.zoomTo(this.getZoom()-1,t,o),this}getBearing(){return this.transform.bearing}setBearing(t,o){return this.jumpTo({bearing:t},o),this}getPadding(){return this.transform.padding}setPadding(t,o){return this.jumpTo({padding:t},o),this}rotateTo(t,o,h){return this.easeTo(a.extend({bearing:t},o),h)}resetNorth(t,o){return this.rotateTo(0,a.extend({duration:1e3},t),o),this}resetNorthPitch(t,o){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},t),o),this}snapToNorth(t,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,o):this}getPitch(){return this.transform.pitch}setPitch(t,o){return this.jumpTo({pitch:t},o),this}cameraForBounds(t,o){t=a.LngLatBounds.convert(t);let h=o&&o.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),h,o)}_extendCameraOptions(t){let o={top:0,bottom:0,right:0,left:0};if(typeof(t=a.extend({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding=="number"){let h=t.padding;t.padding={top:h,bottom:h,right:h,left:h}}return t.padding=a.extend(o,t.padding),t}_cameraForBoxAndBearing(t,o,h,d){let f=this._extendCameraOptions(d),_=this.transform,y=_.padding,b=_.project(a.LngLat.convert(t)),T=_.project(a.LngLat.convert(o)),E=new a.pointGeometry(b.x,T.y),M=new a.pointGeometry(T.x,b.y),D=-a.degToRad(h),B=b.rotate(D),P=T.rotate(D),z=E.rotate(D),G=M.rotate(D),F=new a.pointGeometry(Math.max(B.x,P.x,z.x,G.x),Math.max(B.y,P.y,z.y,G.y)),j=new a.pointGeometry(Math.min(B.x,P.x,z.x,G.x),Math.min(B.y,P.y,z.y,G.y)),N=F.sub(j),$=(_.width-((y.left||0)+(y.right||0)+f.padding.left+f.padding.right))/N.x,V=(_.height-((y.top||0)+(y.bottom||0)+f.padding.top+f.padding.bottom))/N.y;if(V<0||$<0)return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let X=Math.min(_.scaleZoom(_.scale*Math.min($,V)),f.maxZoom),ie=typeof f.offset.x=="number"&&typeof f.offset.y=="number"?new a.pointGeometry(f.offset.x,f.offset.y):a.pointGeometry.convert(f.offset),ae=new a.pointGeometry((f.padding.left-f.padding.right)/2,(f.padding.top-f.padding.bottom)/2).rotate(h*Math.PI/180),ue=ie.add(ae).mult(_.scale/_.zoomScale(X));return{center:_.unproject(b.add(T).div(2).sub(ue)),zoom:X,bearing:h}}_cameraForBox(t,o,h,d,f){let _=this._extendCameraOptions(f);h=h||0,d=d||0,t=a.LngLat.convert(t),o=a.LngLat.convert(o);let y=this.transform.clone();y.padding=_.padding;let b=this.getFreeCameraOptions(),T=new a.LngLat(.5*(t.lng+o.lng),.5*(t.lat+o.lat)),E=.5*(h+d);if(y._camera.position[2]<a.mercatorZfromAltitude(E,T.lat))return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");b.lookAtPoint(T),y.setFreeCameraOptions(b);let M=a.MercatorCoordinate.fromLngLat(t),D=a.MercatorCoordinate.fromLngLat(o),B=y.pointRayIntersection(y.centerPoint,E),P=[(z=y.rayIntersectionCoordinate(B)).x,z.y,z.z];var z;let G=y.screenPointToMercatorRay(y.centerPoint),F=y.projection.name!=="globe",j,N=0;do{let $=Math.floor(y.zoom),V=1<<$,X=Math.min(V*M.x,V*D.x),ie=Math.min(V*M.y,V*D.y),ae=Math.max(V*M.x,V*D.x),ue=Math.max(V*M.y,V*D.y),ce=new a.Aabb([X,ie,h],[ae,ue,d]),we=a.Frustum.fromInvProjectionMatrix(y.invProjMatrix,y.worldSize,$,F);if(ce.intersects(we)!==2){j&&(y._camera.position=a.scaleAndAdd([],y._camera.position,G.dir,-j),y._updateStateFromCamera());break}let re=a.sub([],y._camera.position,P);j=.5*a.length(re),y._camera.position=a.scaleAndAdd([],y._camera.position,G.dir,j);try{y._updateStateFromCamera()}catch{return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++N<10);return{center:y.center,zoom:y.zoom,bearing:y.bearing,pitch:y.pitch}}fitBounds(t,o,h){return this._fitInternal(this.cameraForBounds(t,o),o,h)}_raycastElevationBox(t,o){let h=this.transform.elevation;if(!h)return;let d=new a.pointGeometry(t.x,o.y),f=new a.pointGeometry(o.x,t.y),_=h.pointCoordinate(t);if(!_)return;let y=h.pointCoordinate(o);if(!y)return;let b=h.pointCoordinate(d);if(!b)return;let T=h.pointCoordinate(f);if(!T)return;let E=new a.MercatorCoordinate(_[0],_[1]).toLngLat(),M=new a.MercatorCoordinate(y[0],y[1]).toLngLat(),D=new a.MercatorCoordinate(b[0],b[1]).toLngLat(),B=new a.MercatorCoordinate(T[0],T[1]).toLngLat(),P=Math.min(E.lng,Math.min(M.lng,Math.min(D.lng,B.lng))),z=Math.min(E.lat,Math.min(M.lat,Math.min(D.lat,B.lat))),G=Math.max(E.lng,Math.max(M.lng,Math.max(D.lng,B.lng))),F=Math.max(E.lat,Math.max(M.lat,Math.max(D.lat,B.lat))),j=Math.min(_[3],Math.min(y[3],Math.min(b[3],T[3]))),N=Math.max(_[3],Math.max(y[3],Math.max(b[3],T[3])));return{minLngLat:new a.LngLat(P,z),maxLngLat:new a.LngLat(G,F),minAltitude:j,maxAltitude:N}}fitScreenCoordinates(t,o,h,d,f){let _,y,b,T,E=a.pointGeometry.convert(t),M=a.pointGeometry.convert(o),D=this._raycastElevationBox(E,M);if(D)_=D.minLngLat,y=D.maxLngLat,b=D.minAltitude,T=D.maxAltitude;else{if(this.transform.anyCornerOffEdge(E,M))return this;_=this.transform.pointLocation(E),y=this.transform.pointLocation(M)}return this._fitInternal(this.transform.pitch===0?this._cameraForBoxAndBearing(this.transform.pointLocation(a.pointGeometry.convert(t)),this.transform.pointLocation(a.pointGeometry.convert(o)),h,d):this._cameraForBox(_,y,b,T,d),d,f)}_fitInternal(t,o,h){return t?(delete(o=a.extend(t,o)).padding,o.linear?this.easeTo(o,h):this.flyTo(o,h)):this}jumpTo(t,o){this.stop();let h=t.preloadOnly?this.transform.clone():this.transform,d=!1,f=!1,_=!1;return"zoom"in t&&h.zoom!==+t.zoom&&(d=!0,h.zoom=+t.zoom),t.center!==void 0&&(h.center=a.LngLat.convert(t.center)),"bearing"in t&&h.bearing!==+t.bearing&&(f=!0,h.bearing=+t.bearing),"pitch"in t&&h.pitch!==+t.pitch&&(_=!0,h.pitch=+t.pitch),t.padding==null||h.isPaddingEqual(t.padding)||(h.padding=t.padding),t.preloadOnly?(this._preloadTiles(h),this):(this.fire(new a.Event("movestart",o)).fire(new a.Event("move",o)),d&&this.fire(new a.Event("zoomstart",o)).fire(new a.Event("zoom",o)).fire(new a.Event("zoomend",o)),f&&this.fire(new a.Event("rotatestart",o)).fire(new a.Event("rotate",o)).fire(new a.Event("rotateend",o)),_&&this.fire(new a.Event("pitchstart",o)).fire(new a.Event("pitch",o)).fire(new a.Event("pitchend",o)),this.fire(new a.Event("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||a.warnOnce(Ds),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,o){let h=this.transform;if(!h.projection.supportsFreeCamera)return a.warnOnce(Ds),this;this.stop();let d=h.zoom,f=h.pitch,_=h.bearing;h.setFreeCameraOptions(t);let y=d!==h.zoom,b=f!==h.pitch,T=_!==h.bearing;return this.fire(new a.Event("movestart",o)).fire(new a.Event("move",o)),y&&this.fire(new a.Event("zoomstart",o)).fire(new a.Event("zoom",o)).fire(new a.Event("zoomend",o)),T&&this.fire(new a.Event("rotatestart",o)).fire(new a.Event("rotate",o)).fire(new a.Event("rotateend",o)),b&&this.fire(new a.Event("pitchstart",o)).fire(new a.Event("pitch",o)).fire(new a.Event("pitchend",o)),this.fire(new a.Event("moveend",o)),this}easeTo(t,o){this._stop(!1,t.easeId),((t=a.extend({offset:[0,0],duration:500,easing:a.ease},t)).animate===!1||!t.essential&&a.exported.prefersReducedMotion)&&(t.duration=0);let h=this.transform,d=this.getZoom(),f=this.getBearing(),_=this.getPitch(),y=this.getPadding(),b="zoom"in t?+t.zoom:d,T="bearing"in t?this._normalizeBearing(t.bearing,f):f,E="pitch"in t?+t.pitch:_,M="padding"in t?t.padding:h.padding,D=a.pointGeometry.convert(t.offset),B,P,z;if(h.projection.name==="globe"){let ue=a.MercatorCoordinate.fromLngLat(h.center),ce=D.rotate(-h.angle);ue.x+=ce.x/h.worldSize,ue.y+=ce.y/h.worldSize;let we=ue.toLngLat(),re=a.LngLat.convert(t.center||we);this._normalizeCenter(re),B=h.centerPoint.add(ce),P=new a.pointGeometry(ue.x,ue.y).mult(h.worldSize),z=new a.pointGeometry(a.mercatorXfromLng(re.lng),a.mercatorYfromLat(re.lat)).mult(h.worldSize).sub(P)}else{B=h.centerPoint.add(D);let ue=h.pointLocation(B),ce=a.LngLat.convert(t.center||ue);this._normalizeCenter(ce),P=h.project(ue),z=h.project(ce).sub(P)}let G=h.zoomScale(b-d),F,j;t.around&&(F=a.LngLat.convert(t.around),j=h.locationPoint(F));let N=this._zooming||b!==d,$=this._rotating||f!==T,V=this._pitching||E!==_,X=!h.isPaddingEqual(M),ie=ue=>ce=>{if(N&&(ue.zoom=a.number(d,b,ce)),$&&(ue.bearing=a.number(f,T,ce)),V&&(ue.pitch=a.number(_,E,ce)),X&&(ue.interpolatePadding(y,M,ce),B=ue.centerPoint.add(D)),F)ue.setLocationAtPoint(F,j);else{let we=ue.zoomScale(ue.zoom-d),re=b>d?Math.min(2,G):Math.max(.5,G),Te=Math.pow(re,1-ce),ve=ue.unproject(P.add(z.mult(ce*Te)).mult(we));ue.setLocationAtPoint(ue.renderWorldCopies?ve.wrap():ve,B)}return t.preloadOnly||this._fireMoveEvents(o),ue};if(t.preloadOnly){let ue=this._emulate(ie,t.duration,h);return this._preloadTiles(ue),this}let ae={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=N,this._rotating=$,this._pitching=V,this._padding=X,this._easeId=t.easeId,this._prepareEase(o,t.noMoveStart,ae),this._ease(ie(h),ue=>{h.recenterOnTerrain(),this._afterEase(o,ue)},t),this}_prepareEase(t,o,h={}){this._moving=!0,this.transform.cameraElevationReference="sea",o||h.moving||this.fire(new a.Event("movestart",t)),this._zooming&&!h.zooming&&this.fire(new a.Event("zoomstart",t)),this._rotating&&!h.rotating&&this.fire(new a.Event("rotatestart",t)),this._pitching&&!h.pitching&&this.fire(new a.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new a.Event("move",t)),this._zooming&&this.fire(new a.Event("zoom",t)),this._rotating&&this.fire(new a.Event("rotate",t)),this._pitching&&this.fire(new a.Event("pitch",t))}_afterEase(t,o){if(this._easeId&&o&&this._easeId===o)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";let h=this._zooming,d=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,h&&this.fire(new a.Event("zoomend",t)),d&&this.fire(new a.Event("rotateend",t)),f&&this.fire(new a.Event("pitchend",t)),this.fire(new a.Event("moveend",t))}flyTo(t,o){if(!t.essential&&a.exported.prefersReducedMotion){let De=a.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(De,o)}this.stop(),t=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},t);let h=this.transform,d=this.getZoom(),f=this.getBearing(),_=this.getPitch(),y=this.getPadding(),b="zoom"in t?a.clamp(+t.zoom,h.minZoom,h.maxZoom):d,T="bearing"in t?this._normalizeBearing(t.bearing,f):f,E="pitch"in t?+t.pitch:_,M="padding"in t?t.padding:h.padding,D=h.zoomScale(b-d),B=a.pointGeometry.convert(t.offset),P=h.centerPoint.add(B),z=h.pointLocation(P),G=a.LngLat.convert(t.center||z);this._normalizeCenter(G);let F=h.project(z),j=h.project(G).sub(F),N=t.curve,$=Math.max(h.width,h.height),V=$/D,X=j.mag();if("minZoom"in t){let De=a.clamp(Math.min(t.minZoom,d,b),h.minZoom,h.maxZoom),Pe=$/h.zoomScale(De-d);N=Math.sqrt(Pe/X*2)}let ie=N*N;function ae(De){let Pe=(V*V-$*$+(De?-1:1)*ie*ie*X*X)/(2*(De?V:$)*ie*X);return Math.log(Math.sqrt(Pe*Pe+1)-Pe)}function ue(De){return(Math.exp(De)-Math.exp(-De))/2}function ce(De){return(Math.exp(De)+Math.exp(-De))/2}let we=ae(0),re=function(De){return ce(we)/ce(we+N*De)},Te=function(De){return $*((ce(we)*(ue(Pe=we+N*De)/ce(Pe))-ue(we))/ie)/X;var Pe},ve=(ae(1)-we)/N;if(Math.abs(X)<1e-6||!isFinite(ve)){if(Math.abs($-V)<1e-6)return this.easeTo(t,o);let De=V<$?-1:1;ve=Math.abs(Math.log(V/$))/N,Te=function(){return 0},re=function(Pe){return Math.exp(De*N*Pe)}}t.duration="duration"in t?+t.duration:1e3*ve/("screenSpeed"in t?+t.screenSpeed/N:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);let Le=f!==T,pe=E!==_,ke=!h.isPaddingEqual(M),Ve=De=>Pe=>{let Ze=Pe*ve,Ye=1/re(Ze);De.zoom=Pe===1?b:d+De.scaleZoom(Ye),Le&&(De.bearing=a.number(f,T,Pe)),pe&&(De.pitch=a.number(_,E,Pe)),ke&&(De.interpolatePadding(y,M,Pe),P=De.centerPoint.add(B));let Fe=Pe===1?G:De.unproject(F.add(j.mult(Te(Ze))).mult(Ye));return De.setLocationAtPoint(De.renderWorldCopies?Fe.wrap():Fe,P),De._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(o),De};if(t.preloadOnly){let De=this._emulate(Ve,t.duration,h);return this._preloadTiles(De),this}return this._zooming=!0,this._rotating=Le,this._pitching=pe,this._padding=ke,this._prepareEase(o,!1),this._ease(Ve(h),()=>this._afterEase(o),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,o){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){let h=this._onEaseEnd;this._onEaseEnd=void 0,h.call(this,o)}if(!t){let h=this.handlers;h&&h.stop(!1)}return this}_ease(t,o,h){h.animate===!1||h.duration===0?(t(1),o()):(this._easeStart=a.exported.now(),this._easeOptions=h,this._onEaseFrame=t,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){let t=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1),o=this._onEaseFrame;o&&o(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,o){t=a.wrap(t,-180,180);let h=Math.abs(t-o);return Math.abs(t-360-o)<h&&(t-=360),Math.abs(t+360-o)<h&&(t+=360),t}_normalizeCenter(t){let o=this.transform;if(!o.renderWorldCopies||o.maxBounds)return;let h=t.lng-o.center.lng;t.lng+=h>180?-360:h<-180?360:0}_emulate(t,o,h){let d=Math.ceil(15*o/1e3),f=[],_=t(h.clone());for(let y=0;y<=d;y++){let b=_(y/d);f.push(b.clone())}return f}}class Ps{constructor(t={}){this.options=t,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){let o=this.options&&this.options.compact;return this._map=t,this._container=et("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=et("button","mapboxgl-ctrl-attrib-button",this._container),et("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=et("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(t,o){let h=this._map._getUIString(`AttributionControl.${o}`);t.setAttribute("aria-label",h),t.removeAttribute("title"),t.firstElementChild&&t.firstElementChild.setAttribute("title",h)}_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 t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));let o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN}];if(t){let h=o.reduce((d,f,_)=>(f.value&&(d+=`${f.key}=${f.value}${_<o.length-1?"&":""}`),d),"?");t.href=`${a.config.FEEDBACK_URL}/${h}${this._map._hash?this._map._hash.getHashString(!0):""}`,t.rel="noopener nofollow",this._setElementTitle(t,"MapFeedback")}}_updateData(t){!t||t.sourceDataType!=="metadata"&&t.sourceDataType!=="visibility"&&t.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){let d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}let o=this._map.style._sourceCaches;for(let d in o){let f=o[d];if(f.used){let _=f.getSource();_.attribution&&t.indexOf(_.attribution)<0&&t.push(_.attribution)}}t.sort((d,f)=>d.length-f.length),t=t.filter((d,f)=>{for(let _=f+1;_<t.length;_++)if(t[_].indexOf(d)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));let h=t.join(" | ");h!==this._attribHTML&&(this._attribHTML=h,t.length?(this._innerContainer.innerHTML=h,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 hc{constructor(){a.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=et("div","mapboxgl-ctrl");let o=et("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(t){t&&t.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;let t=this._map.style._sourceCaches;if(Object.entries(t).length===0)return!0;for(let o in t){let h=t[o].getSource();if(h.hasOwnProperty("mapbox_logo")&&!h.mapbox_logo)return!1}return!0}_updateCompact(){let t=this._container.children;if(t.length){let o=t[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class uc{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let o=++this._id;return this._queue.push({callback:t,id:o,cancelled:!1}),o}remove(t){let o=this._currentlyRunning,h=o?this._queue.concat(o):this._queue;for(let d of h)if(d.id===t)return void(d.cancelled=!0)}run(t=0){let o=this._currentlyRunning=this._queue;this._queue=[];for(let h of o)if(!h.cancelled&&(h.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Ls(l,t,o){if(l=new a.LngLat(l.lng,l.lat),t){let h=new a.LngLat(l.lng-360,l.lat),d=new a.LngLat(l.lng+360,l.lat),f=360*Math.ceil(Math.abs(l.lng-o.center.lng)/360),_=o.locationPoint(l).distSqr(t),y=t.x<0||t.y<0||t.x>o.width||t.y>o.height;o.locationPoint(h).distSqr(t)<_&&(y||Math.abs(h.lng-o.center.lng)<f)?l=h:o.locationPoint(d).distSqr(t)<_&&(y||Math.abs(d.lng-o.center.lng)<f)&&(l=d)}for(;Math.abs(l.lng-o.center.lng)>180;){let h=o.locationPoint(l);if(h.x>=0&&h.y>=0&&h.x<=o.width&&h.y<=o.height)break;l.lng>o.center.lng?l.lng-=360:l.lng+=360}return l}let Bs={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 Rs extends a.Evented{constructor(t,o){if(super(),(t instanceof a.window.HTMLElement||o)&&(t=a.extend({element:t},o)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),t&&t.element)this._element=t.element,this._offset=a.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=et("div");let d=41,f=27,_=Ne("svg",{display:"block",height:d*this._scale+"px",width:f*this._scale+"px",viewBox:`0 0 ${f} ${d}`},this._element),y=Ne("radialGradient",{id:"shadowGradient"},Ne("defs",{},_));Ne("stop",{offset:"10%","stop-opacity":.4},y),Ne("stop",{offset:"100%","stop-opacity":.05},y),Ne("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},_),Ne("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"},_),Ne("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"},_),Ne("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},_),this._offset=a.pointGeometry.convert(t&&t.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()});let h=this._element.classList;for(let d in Bs)h.remove(`mapboxgl-marker-anchor-${d}`);h.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){let t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=a.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(t){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")),t){if(!("offset"in t.options)){let d=Math.sqrt(Math.pow(13.5,2)/2);t.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=t,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(t){let o=t.code,h=t.charCode||t.keyCode;o!=="Space"&&o!=="Enter"&&h!==32&&h!==13||this.togglePopup()}_onMapClick(t){let o=t.originalEvent.target,h=this._element;this._popup&&(o===h||h.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){let t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){let t=this._map;if(!t)return;let o=this._pos;if(!o||o.x<0||o.x>t.transform.width||o.y<0||o.y>t.transform.height)return void this._clearFadeTimer();let h=t.unproject(o),d=!1;if(t.transform._terrainEnabled()&&t.getTerrain()){let _=t.getFreeCameraOptions();if(_.position){let y=_.position.toLngLat();d=y.distanceTo(h)<.9*y.distanceTo(this._lngLat)}}let f=(1-t._queryFogOpacity(h))*(d?.2:1);this._element.style.opacity=`${f}`,this._popup&&this._popup._setOpacity(`${f}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){let t=this._pos;if(!t)return;let o=this._offset.mult(this._scale),h=this._calculatePitch(),d=this._calculateRotation();this._element.style.transform=`
|
|
1017
|
-
translate(${t.x}px, ${t.y}px) ${Bs[this._anchor]}
|
|
1018
|
-
rotateX(${h}deg) rotateZ(${d}deg)
|
|
1019
|
-
translate(${o.x}px, ${o.y}px)
|
|
1020
|
-
`}_calculatePitch(){return this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?0:this._map&&this._pitchAlignment==="map"?this._map.getPitch():0}_calculateRotation(){return this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?this._rotation:this._map&&this._rotationAlignment==="map"?this._rotation-this._map.getBearing():0}_update(t){a.window.cancelAnimationFrame(this._updateFrameId);let o=this._map;o&&(o.transform.renderWorldCopies&&(this._lngLat=Ls(this._lngLat,this._pos,o.transform)),this._pos=o.project(this._lngLat),t===!0?this._updateFrameId=a.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.getTerrain()&&!o.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=a.pointGeometry.convert(t),this._update(),this}_onMove(t){let o=this._map;if(o){if(!this._isDragging){let h=this._clickTolerance||o._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=h}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=o.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new a.Event("dragstart"))),this.fire(new a.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;let t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new a.Event("dragend")),this._state="inactive"}_addDragHandler(t){let o=this._map;o&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos),this._pointerdownPos=t.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(t){this._draggable=!!t;let o=this._map;return o&&(t?(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(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class lh{constructor(t){this.jumpTo(t)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;let o=a.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,o,h){this._start=this.getValue(o),this._end=t,this._startTime=o,this._endTime=o+h}}let ch={"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","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},Oa={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,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,crossSourceCollisions:!0};function Oo(l){l.parentNode&&l.parentNode.removeChild(l)}let Ua={showCompass:!0,showZoom:!0,visualizePitch:!1};class Va{constructor(t,o,h=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new jn({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,h&&(this.mousePitch=new ka({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),a.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(t,o){this.mouseRotate.mousedown(t,o),this.mousePitch&&this.mousePitch.mousedown(t,o),ri()}move(t,o){let h=this.map,d=this.mouseRotate.mousemoveWindow(t,o),f=d&&d.bearingDelta;if(f&&h.setBearing(h.getBearing()+f),this.mousePitch){let _=this.mousePitch.mousemoveWindow(t,o),y=_&&_.pitchDelta;y&&h.setPitch(h.getPitch()+y)}}off(){let t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){Yo(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(a.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),Hi(this.element,t)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,Hi(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){t.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=at(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){t.targetTouches.length!==1?this.reset():(this._lastPos=at(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){t.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()}}let si={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},_i,Uo=0,hn=!1,ja={maxWidth:100,unit:"metric"};function Fs(l,t,o){let h=o&&o.maxWidth||100,d=l._containerHeight/2,f=l._containerWidth/2-h/2,_=l.unproject([f,d]),y=l.unproject([f+h,d]),b=_.distanceTo(y);if(o&&o.unit==="imperial"){let T=3.2808*b;T>5280?Gn(t,h,T/5280,l._getUIString("ScaleControl.Miles"),l):Gn(t,h,T,l._getUIString("ScaleControl.Feet"),l)}else o&&o.unit==="nautical"?Gn(t,h,b/1852,l._getUIString("ScaleControl.NauticalMiles"),l):b>=1e3?Gn(t,h,b/1e3,l._getUIString("ScaleControl.Kilometers"),l):Gn(t,h,b,l._getUIString("ScaleControl.Meters"),l)}function Gn(l,t,o,h,d){let f=function(y){let b=Math.pow(10,`${Math.floor(y)}`.length-1),T=y/b;return T=T>=10?10:T>=5?5:T>=3?3:T>=2?2:T>=1?1:function(E){let M=Math.pow(10,Math.ceil(-Math.log(E)/Math.LN10));return Math.round(E*M)/M}(T),b*T}(o),_=f/o;d._requestDomTask(()=>{l.style.width=t*_+"px",l.innerHTML=`${f} ${h}`})}let Ii={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Tt=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Vo(l=new a.pointGeometry(0,0),t="bottom"){if(typeof l=="number"){let o=Math.round(Math.sqrt(.5*Math.pow(l,2)));switch(t){case"top":return new a.pointGeometry(0,l);case"top-left":return new a.pointGeometry(o,o);case"top-right":return new a.pointGeometry(-o,o);case"bottom":return new a.pointGeometry(0,-l);case"bottom-left":return new a.pointGeometry(o,-o);case"bottom-right":return new a.pointGeometry(-o,-o);case"left":return new a.pointGeometry(l,0);case"right":return new a.pointGeometry(-l,0)}return new a.pointGeometry(0,0)}return l instanceof a.pointGeometry||Array.isArray(l)?a.pointGeometry.convert(l):a.pointGeometry.convert(l[t]||[0,0])}let Zn={version:a.version,supported:Ri,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends Fa{constructor(l){if((l=a.extend({},Oa,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&&a.isSafariWithAntialiasingBug(a.window)&&(l.antialias=!1,a.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Ms(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._trackResize=l.trackResize,this._bearingSnap=l.bearingSnap,this._refreshExpiredTiles=l.refreshExpiredTiles,this._fadeDuration=l.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=l.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=l.collectResourceTiming,this._optimizeForTerrain=l.optimizeForTerrain,this._renderTaskQueue=new uc,this._domRenderTaskQueue=new uc,this._controls=[],this._markers=[],this._mapId=a.uniqueId(),this._locale=a.extend({},ch,l.locale),this._clickTolerance=l.clickTolerance,this._cooperativeGestures=l.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new lh(0),this._explicitProjection=null,this._requestManager=new a.RequestManager(l.transformRequest,l.accessToken,l.testMode),this._silenceAuthErrors=!!l.testMode,typeof l.container=="string"){if(this._container=a.window.document.getElementById(l.container),!this._container)throw new Error(`Container '${l.container}' not found.`)}else{if(!(l.container instanceof a.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=l.container}if(this._container.childNodes.length>0&&a.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),a.bindAll(["_onWindowOnline","_onWindowResize","_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)),a.window!==void 0&&(a.window.addEventListener("online",this._onWindowOnline,!1),a.window.addEventListener("resize",this._onWindowResize,!1),a.window.addEventListener("orientationchange",this._onWindowResize,!1),a.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new cc(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 Gl(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,a.extend({},l.fitBoundsOptions,{duration:0})))),this.resize(),l.attributionControl&&this.addControl(new Ps({customAttribution:l.customAttribution})),this._logoControl=new hc,this.addControl(this._logoControl,l.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update(t.dataType==="style"),this.fire(new a.Event(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new a.Event(`${t.dataType}dataloading`,t))})}_getMapId(){return this._mapId}addControl(l,t){if(t===void 0&&(t=l.getDefaultPosition?l.getDefaultPosition():"top-right"),!l||!l.onAdd)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let o=l.onAdd(this);this._controls.push(l);let h=this._controlPositions[t];return t.indexOf("bottom")!==-1?h.insertBefore(o,h.firstChild):h.appendChild(o),this}removeControl(l){if(!l||!l.onRemove)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(l);return t>-1&&this._controls.splice(t,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));let t=!this._moving;return t&&this.fire(new a.Event("movestart",l)).fire(new a.Event("move",l)),this.fire(new a.Event("resize",l)),t&&this.fire(new a.Event("moveend",l)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(l){return this.transform.setMaxBounds(a.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 a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.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 a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.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 a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.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 a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(l){return this.transform.renderWorldCopies=l,this._update()}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}setProjection(l){return this._lazyInitEmptyStyle(),l?typeof l=="string"&&(l={name:l}):l=null,this._updateProjection(l)}_updateProjection(l){l===null&&(this._explicitProjection=null);let t=l||this.getProjection(),o=this.transform.setProjection(t);if(l&&(this._explicitProjection=this.transform.getProjection()),o){this.painter.clearBackgroundTiles();for(let h in this.style._sourceCaches)this.style._sourceCaches[h].clearTiles();this.style.applyProjectionUpdate(),this._update(!0)}return this}project(l){return this.transform.locationPoint3D(a.LngLat.convert(l))}unproject(l){return this.transform.pointLocation3D(a.pointGeometry.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}_createDelegatedListener(l,t,o){if(l==="mouseenter"||l==="mouseover"){let h=!1,d=_=>{let y=t.filter(T=>this.getLayer(T)),b=y.length?this.queryRenderedFeatures(_.point,{layers:y}):[];b.length?h||(h=!0,o.call(this,new mi(l,this,_.originalEvent,{features:b}))):h=!1},f=()=>{h=!1};return{layers:new Set(t),listener:o,delegates:{mousemove:d,mouseout:f}}}if(l==="mouseleave"||l==="mouseout"){let h=!1,d=_=>{let y=t.filter(b=>this.getLayer(b));(y.length?this.queryRenderedFeatures(_.point,{layers:y}):[]).length?h=!0:h&&(h=!1,o.call(this,new mi(l,this,_.originalEvent)))},f=_=>{h&&(h=!1,o.call(this,new mi(l,this,_.originalEvent)))};return{layers:new Set(t),listener:o,delegates:{mousemove:d,mouseout:f}}}{let h=d=>{let f=t.filter(y=>this.getLayer(y)),_=f.length?this.queryRenderedFeatures(d.point,{layers:f}):[];_.length&&(d.features=_,o.call(this,d),delete d.features)};return{layers:new Set(t),listener:o,delegates:{[l]:h}}}}on(l,t,o){if(o===void 0)return super.on(l,t);Array.isArray(t)||(t=[t]);let h=this._createDelegatedListener(l,t,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[l]=this._delegatedListeners[l]||[],this._delegatedListeners[l].push(h);for(let d in h.delegates)this.on(d,h.delegates[d]);return this}once(l,t,o){if(o===void 0)return super.once(l,t);Array.isArray(t)||(t=[t]);let h=this._createDelegatedListener(l,t,o);for(let d in h.delegates)this.once(d,h.delegates[d]);return this}off(l,t,o){if(o===void 0)return super.off(l,t);t=new Set(Array.isArray(t)?t:[t]);let h=(f,_)=>{if(f.size!==_.size)return!1;for(let y of f)if(!_.has(y))return!1;return!0},d=this._delegatedListeners?this._delegatedListeners[l]:void 0;return d&&(f=>{for(let _=0;_<f.length;_++){let y=f[_];if(y.listener===o&&h(y.layers,t)){for(let b in y.delegates)this.off(b,y.delegates[b]);return f.splice(_,1),this}}})(d),this}queryRenderedFeatures(l,t){return this.style?(t!==void 0||l===void 0||l instanceof a.pointGeometry||Array.isArray(l)||(t=l,l=void 0),this.style.queryRenderedFeatures(l=l||[[0,0],[this.transform.width,this.transform.height]],t=t||{},this.transform)):[]}querySourceFeatures(l,t){return this.style.querySourceFeatures(l,t)}queryTerrainElevation(l,t){let o=this.transform.elevation;return o?(t=a.extend({},{exaggerated:!0},t),o.getAtPoint(a.MercatorCoordinate.fromLngLat(l),null,t.exaggerated)):null}setStyle(l,t){return(t=a.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&t.localFontFamily===this._localFontFamily&&this.style&&l?(this._diffStyle(l,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._updateStyle(l,t))}_getUIString(l){let t=this._locale[l];if(t==null)throw new Error(`Missing UI string '${l}'`);return t}_updateStyle(l,t){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),l&&(this.style=new oi(this,t||{}),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 oi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(l,t){if(typeof l=="string"){let o=this._requestManager.normalizeStyleURL(l),h=this._requestManager.transformRequest(o,a.ResourceType.Style);a.getJSON(h,(d,f)=>{d?this.fire(new a.ErrorEvent(d)):f&&this._updateDiff(f,t)})}else typeof l=="object"&&this._updateDiff(l,t)}_updateDiff(l,t){try{this.style.setState(l)&&this._update(!0)}catch(o){a.warnOnce(`Unable to perform style diff: ${o.message||o.error||o}. Rebuilding the style from scratch.`),this._updateStyle(l,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(a.warnOnce("There is no style added to the map."),!1)}addSource(l,t){return this._lazyInitEmptyStyle(),this.style.addSource(l,t),this._update(!0)}isSourceLoaded(l){return!!this.style&&this.style._isSourceCacheLoaded(l)}areTilesLoaded(){let l=this.style&&this.style._sourceCaches;for(let t in l){let o=l[t]._tiles;for(let h in o){let d=o[h];if(d.state!=="loaded"&&d.state!=="errored")return!1}}return!0}addSourceType(l,t,o){this._lazyInitEmptyStyle(),this.style.addSourceType(l,t,o)}removeSource(l){return this.style.removeSource(l),this._updateTerrain(),this._update(!0)}getSource(l){return this.style.getSource(l)}addImage(l,t,{pixelRatio:o=1,sdf:h=!1,stretchX:d,stretchY:f,content:_}={}){if(this._lazyInitEmptyStyle(),t instanceof a.window.HTMLImageElement||a.window.ImageBitmap&&t instanceof a.window.ImageBitmap){let{width:y,height:b,data:T}=a.exported.getImageData(t);this.style.addImage(l,{data:new a.RGBAImage({width:y,height:b},T),pixelRatio:o,stretchX:d,stretchY:f,content:_,sdf:h,version:0})}else if(t.width===void 0||t.height===void 0)this.fire(new a.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{let{width:y,height:b}=t,T=t;this.style.addImage(l,{data:new a.RGBAImage({width:y,height:b},new Uint8Array(T.data)),pixelRatio:o,stretchX:d,stretchY:f,content:_,sdf:h,version:0,userImage:T}),T.onAdd&&T.onAdd(this,l)}}updateImage(l,t){let o=this.style.getImage(l);if(!o)return void this.fire(new a.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let h=t instanceof a.window.HTMLImageElement||a.window.ImageBitmap&&t instanceof a.window.ImageBitmap?a.exported.getImageData(t):t,{width:d,height:f}=h;d!==void 0&&f!==void 0?d===o.data.width&&f===o.data.height?(o.data.replace(h.data,!(t instanceof a.window.HTMLImageElement||a.window.ImageBitmap&&t instanceof a.window.ImageBitmap)),this.style.updateImage(l,o)):this.fire(new a.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):this.fire(new a.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 a.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(l){this.style.removeImage(l)}loadImage(l,t){a.getImage(this._requestManager.transformRequest(l,a.ResourceType.Image),(o,h)=>{t(o,h instanceof a.window.HTMLImageElement?a.exported.getImageData(h):h)})}listImages(){return this.style.listImages()}addLayer(l,t){return this._lazyInitEmptyStyle(),this.style.addLayer(l,t),this._update(!0)}moveLayer(l,t){return this.style.moveLayer(l,t),this._update(!0)}removeLayer(l){return this.style.removeLayer(l),this._update(!0)}getLayer(l){return this.style.getLayer(l)}setLayerZoomRange(l,t,o){return this.style.setLayerZoomRange(l,t,o),this._update(!0)}setFilter(l,t,o={}){return this.style.setFilter(l,t,o),this._update(!0)}getFilter(l){return this.style.getFilter(l)}setPaintProperty(l,t,o,h={}){return this.style.setPaintProperty(l,t,o,h),this._update(!0)}getPaintProperty(l,t){return this.style.getPaintProperty(l,t)}setLayoutProperty(l,t,o,h={}){return this.style.setLayoutProperty(l,t,o,h),this._update(!0)}getLayoutProperty(l,t){return this.style.getLayoutProperty(l,t)}setLight(l,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(l,t),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(a.LngLat.convert(l),this.transform):0}setFeatureState(l,t){return this.style.setFeatureState(l,t),this._update()}removeFeatureState(l,t){return this.style.removeFeatureState(l,t),this._update()}getFeatureState(l){return this.style.getFeatureState(l)}_updateContainerDimensions(){if(!this._container)return;let l=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300,o,h,d,f=this._container;for(;f&&(!h||!d);){let _=a.window.getComputedStyle(f).transform;_&&_!=="none"&&(o=_.match(/matrix.*\((.+)\)/)[1].split(", "),o[0]&&o[0]!=="0"&&o[0]!=="1"&&(h=o[0]),o[3]&&o[3]!=="0"&&o[3]!=="1"&&(d=o[3])),f=f.parentElement}this._containerWidth=h?Math.abs(l/h):l,this._containerHeight=d?Math.abs(t/d):t}_detectMissingCSS(){a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&a.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(){let l=this._container;l.classList.add("mapboxgl-map"),(this._missingCSSCanary=et("div","mapboxgl-canary",l)).style.visibility="hidden",this._detectMissingCSS();let t=this._canvasContainer=et("div","mapboxgl-canvas-container",l);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=et("canvas","mapboxgl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);let o=this._controlContainer=et("div","mapboxgl-control-container",l),h=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(d=>{h[d]=et("div",`mapboxgl-ctrl-${d}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(l,t){let o=a.exported.devicePixelRatio||1;this._canvas.width=o*Math.ceil(l),this._canvas.height=o*Math.ceil(t),this._canvas.style.width=`${l}px`,this._canvas.style.height=`${t}px`}_addMarker(l){this._markers.push(l)}_removeMarker(l){let t=this._markers.indexOf(l);t!==-1&&this._markers.splice(t,1)}_setupPainter(){let l=a.extend({},Ri.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl",l)||this._canvas.getContext("experimental-webgl",l);t?(a.storeAuthState(t,!0),this.painter=new jl(t,this.transform),this.on("data",o=>{o.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(t)):this.fire(new a.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(l){l.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:l}))}_contextRestored(l){this._setupPainter(),this.resize(),this._update(),this.fire(new a.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 t,o=this.painter.context.extTimerQuery,h=a.exported.now();if(this.listens("gpu-timing-frame")&&(t=o.createQueryEXT(),o.beginQueryEXT(o.TIME_ELAPSED_EXT,t)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(l),this._domRenderTaskQueue.run(l),this._removed)return;let d=!1,f=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;let b=this.transform.zoom,T=this.transform.pitch,E=a.exported.now();this.style.zoomHistory.update(b,E);let M=new a.EvaluationParameters(b,{now:E,fadeDuration:f,pitch:T,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),D=M.crossFadingFactor();D===1&&D===this._crossFadingFactor||(d=!0,this._crossFadingFactor=D),this.style.update(M)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let _=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),_=this._updateAverageElevation(h),this.style._updateSources(this.transform),this._forceMarkerUpdate()):_=this._updateAverageElevation(h),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,f,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.Event("load"))),this.style&&(this.style.hasTransitions()||d)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){let b=a.exported.now()-h;o.endQueryEXT(o.TIME_ELAPSED_EXT,t),setTimeout(()=>{let T=o.getQueryObjectEXT(t,o.QUERY_RESULT_EXT)/1e6;o.deleteQueryEXT(t),this.fire(new a.Event("gpu-timing-frame",{cpuTime:b,gpuTime:T}))},50)}if(this.listens("gpu-timing-layer")){let b=this.painter.collectGpuTimers();setTimeout(()=>{let T=this.painter.queryGpuTimers(b);this.fire(new a.Event("gpu-timing-layer",{layerTimes:T}))},50)}let y=this._sourcesDirty||this._styleDirty||this._placementDirty||_;if(y||this._repaint)this.triggerRepaint();else{let b=!this.isMoving()&&this.loaded();if(b&&(_=this._updateAverageElevation(h,!0)),_)this.triggerRepaint();else if(this._triggerFrame(!1),b&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){let T=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:T})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||y||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(let l of this._markers)l._update()}_updateAverageElevation(l,t=!1){let o=h=>(this.transform.averageElevation=h,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&o(0);if((t||l-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(l)){let h=this.transform.averageElevation,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;let _=Math.abs(h-d);if(_>1){if(this._isInitialLoad||f)return this._averageElevation.jumpTo(d),o(d);this._averageElevation.easeTo(d,l,300)}else if(_>1e-4)return this._averageElevation.jumpTo(d),o(d)}return!!this._averageElevation.isEasing(l)&&o(this._averageElevation.getValue(l))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,l=>{if(l&&(l.message===a.AUTH_ERR_MSG||l.status===401)){let t=this.painter.context.gl;a.storeAuthState(t,!1),this._logoControl instanceof hc&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.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/")))}}),a.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){let l=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());let o=this.painter.context.gl,h=o.createFramebuffer();function d(f){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0);let _=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,_),_}return o.bindFramebuffer(o.FRAMEBUFFER,h),this._canvasPixelComparison(d(l),t.canvasCopies.map(d),t.timeStamps)}_canvasPixelComparison(l,t,o){let h=o[1]-o[0],d=l.length/4;for(let f=0;f<t.length;f++){let _=t[f],y=0;for(let b=0;b<_.length;b+=4)_[b]===l[b]&&_[b+1]===l[b+1]&&_[b+2]===l[b+2]&&_[b+3]===l[b+3]&&(y+=1);h+=(o[f+2]-o[f+1])*(1-y/d)}return h}remove(){this._hash&&this._hash.remove();for(let t of this._controls)t.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),a.window!==void 0&&(a.window.removeEventListener("resize",this._onWindowResize,!1),a.window.removeEventListener("orientationchange",this._onWindowResize,!1),a.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),a.window.removeEventListener("online",this._onWindowOnline,!1));let l=this.painter.context.gl.getExtension("WEBGL_lose_context");l&&l.loseContext(),Oo(this._canvasContainer),Oo(this._controlContainer),Oo(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),a.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new a.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(l){this._renderNextFrame=this._renderNextFrame||l,this.style&&!this._frame&&(this._frame=a.exported.frame(t=>{let o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(t)}))}_preloadTiles(l){let t=this.style?Object.values(this.style._sourceCaches):[];return a.asyncAll(t,(o,h)=>o._preloadTiles(l,h),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(l){this._trackResize&&this.resize({originalEvent:l})._update()}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()}_setCacheLimits(l,t){a.setCacheLimits(l,t)}get version(){return a.version}},NavigationControl:class{constructor(l){this.options=a.extend({},Ua,l),this._container=et("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",t=>{this._map&&this._map.zoomIn({},{originalEvent:t})}),et("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",t=>{this._map&&this._map.zoomOut({},{originalEvent:t})}),et("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",t=>{let o=this._map;o&&(this.options.visualizePitch?o.resetNorthPitch({},{originalEvent:t}):o.resetNorth({},{originalEvent:t}))}),this._compassIcon=et("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){let l=this._map;if(!l)return;let t=l.getZoom(),o=t===l.getMaxZoom(),h=t===l.getMinZoom();this._zoomInButton.disabled=o,this._zoomOutButton.disabled=h,this._zoomInButton.setAttribute("aria-disabled",o.toString()),this._zoomOutButton.setAttribute("aria-disabled",h.toString())}_rotateCompassArrow(){let l=this._map;if(!l)return;let t=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=t)})}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 Va(l,this._compass,this.options.visualizePitch)),this._container}onRemove(){let 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,t){let o=et("button",l,this._container);return o.type="button",o.addEventListener("click",t),o}_setButtonTitle(l,t){if(!this._map)return;let o=this._map._getUIString(`NavigationControl.${t}`);l.setAttribute("aria-label",o),l.firstElementChild&&l.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends a.Evented{constructor(l){super(),this.options=a.extend({},si,l),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=za(this._updateMarkerRotation,20)}onAdd(l){var t;return this._map=l,this._container=et("div","mapboxgl-ctrl mapboxgl-ctrl-group"),t=this._setupUI,_i!==void 0?t(_i):a.window.navigator.permissions!==void 0?a.window.navigator.permissions.query({name:"geolocation"}).then(o=>{_i=o.state!=="denied",t(_i)}):(_i=!!a.window.navigator.geolocation,t(_i)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,Uo=0,hn=!1}_isOutOfMapMaxBounds(l){let t=this._map.getMaxBounds(),o=l.coords;return!!t&&(o.longitude<t.getWest()||o.longitude>t.getEast()||o.latitude<t.getSouth()||o.latitude>t.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 a.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 a.Event("geolocate",l)),this._finish()}}_updateCamera(l){let t=new a.LngLat(l.coords.longitude,l.coords.latitude),o=l.coords.accuracy,h=this._map.getBearing(),d=a.extend({bearing:h},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(o),d,{geolocateSource:!0})}_updateMarker(l){if(l){let t=new a.LngLat(l.coords.longitude,l.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=l.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){let l=this._map._containerHeight/2,t=this._map.unproject([0,l]),o=this._map.unproject([100,l]),h=t.distanceTo(o)/100,d=Math.ceil(2*this._accuracy/h);this._circleElement.style.width=`${d}px`,this._circleElement.style.height=`${d}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;let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(l.code===3&&hn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",l)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(l){if(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=et("button","mapboxgl-ctrl-geolocate",this._container),et("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",l===!1){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{let t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=et("div","mapboxgl-user-location"),this._dotElement.appendChild(et("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(et("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Rs({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=et("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Rs({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",t=>{t.geolocateSource||this._watchState!=="ACTIVE_LOCK"||t.originalEvent&&t.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 a.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 a.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 a.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Uo--,hn=!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 a.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 a.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"),Uo++,Uo>1?(l={maximumAge:6e5,timeout:0},hn=!0):(l=this.options.positionOptions,hn=!1),this._geolocationWatchID=a.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,l),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else a.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){let l=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};a.window.DeviceMotionEvent!==void 0&&typeof a.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(t=>{t==="granted"&&l()}).catch(console.error):l()}_clearWatch(){a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientation),a.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:Ps,ScaleControl:class{constructor(l){this.options=a.extend({},ja,l),a.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){Fs(this._map,this._container,this.options)}onAdd(l){return this._map=l,this._container=et("div","mapboxgl-ctrl mapboxgl-ctrl-scale",l.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(l){this.options.unit=l,Fs(this._map,this._container,this.options)}},FullscreenControl:class{constructor(l){this._fullscreen=!1,l&&l.container&&(l.container instanceof a.window.HTMLElement?this._container=l.container:a.warnOnce("Full screen control 'container' must be a DOM element.")),a.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in a.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in a.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(l){return this._map=l,this._container||(this._container=this._map.getContainer()),this._controlContainer=et("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,a.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!a.window.document.fullscreenEnabled&&!a.window.document.webkitFullscreenEnabled)}_setupUI(){let l=this._fullscreenButton=et("button","mapboxgl-ctrl-fullscreen",this._controlContainer);et("span","mapboxgl-ctrl-icon",l).setAttribute("aria-hidden","true"),l.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){let 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(){(a.window.document.fullscreenElement||a.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()?a.window.document.exitFullscreen?a.window.document.exitFullscreen():a.window.document.webkitCancelFullScreen&&a.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.Evented{constructor(l){super(),this.options=a.extend(Object.create(Ii),l),a.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(),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 a.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);let 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),this._map=void 0),this.fire(new a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(l){this._lngLat=a.LngLat.convert(l),this._pos=null,this._trackPointer=!1,this._update();let t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();let 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(a.window.document.createTextNode(l))}setHTML(l){let t=a.window.document.createDocumentFragment(),o=a.window.document.createElement("body"),h;for(o.innerHTML=l;h=o.firstChild,h;)t.appendChild(h);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(l){return this.options.maxWidth=l,this._update(),this}setDOMContent(l){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=et("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(l),this.options.closeButton){let o=this._closeButton=et("button","mapboxgl-popup-close-button",t);o.type="button",o.setAttribute("aria-label","Close popup"),o.setAttribute("aria-hidden","true"),o.innerHTML="×",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 t;return this._classList.delete(l)?t=!1:(this._classList.add(l),t=!0),this._updateClassList(),t}_onMouseEvent(l){this._update(l.point)}_getAnchor(l){if(this.options.anchor)return this.options.anchor;let t=this._map,o=this._container,h=this._pos;if(!t||!o||!h)return"bottom";let d=o.offsetWidth,f=o.offsetHeight,_=h.x<d/2,y=h.x>t.transform.width-d/2;if(h.y+l<f)return _?"top-left":y?"top-right":"top";if(h.y>t.transform.height-f){if(_)return"bottom-left";if(y)return"bottom-right"}return _?"left":y?"right":"bottom"}_updateClassList(){let l=this._container;if(!l)return;let t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),l.className=t.join(" ")}_update(l){let t=this._map,o=this._content;if(!t||!this._lngLat&&!this._trackPointer||!o)return;let h=this._container;if(h||(h=this._container=et("div","mapboxgl-popup",t.getContainer()),this._tip=et("div","mapboxgl-popup-tip",h),h.appendChild(o)),this.options.maxWidth&&h.style.maxWidth!==this.options.maxWidth&&(h.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ls(this._lngLat,this._pos,t.transform)),!this._trackPointer||l){let d=this._pos=this._trackPointer&&l?l:t.project(this._lngLat),f=Vo(this.options.offset),_=this._anchor=this._getAnchor(f.y),y=Vo(this.options.offset,_),b=d.add(y).round();t._requestDomTask(()=>{this._container&&_&&(this._container.style.transform=`${Bs[_]} translate(${b.x}px,${b.y}px)`)})}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let l=this._container.querySelector(Tt);l&&l.focus()}_onClose(){this.remove()}_setOpacity(l){this._content&&(this._content.style.opacity=l),this._tip&&(this._tip.style.opacity=l)}},Marker:Rs,Style:oi,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.pointGeometry,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:Co,Evented:a.Evented,config:a.config,prewarm:function(){$e().acquire(Ge)},clearPrewarmedResources:function(){let l=Ue;l&&(l.isPreloaded()&&l.numActive()===1?(l.release(Ge),Ue=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 a.config.ACCESS_TOKEN},set accessToken(l){a.config.ACCESS_TOKEN=l},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(l){a.config.API_URL=l},get workerCount(){return Oe.workerCount},set workerCount(l){Oe.workerCount=l},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(l){a.config.MAX_PARALLEL_IMAGE_REQUESTS=l},clearStorage(l){a.clearTileCache(l)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return Zn});var Td=Zc;return Td})});export default Wm();
|