swc/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js
2022-06-15 14:36:57 +00:00

61 lines
890 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(a,b,c){var d=c(3454);!function(b,c){a.exports=c()}(this,function(){"use strict";var a,b,c;function f(d,f){if(a){if(b){var g="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 = {}; ("+a+")(sharedChunk); ("+b+")(sharedChunk); self.onerror = null;",h={};a(h),c=f(h),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(c.workerUrl=window.URL.createObjectURL(new Blob([g],{type:"text/javascript"})))}else b=f}else a=f}return f(["exports"],function(a){var b="2.7.0",c=f;function f(a,b,c,d){this.cx=3*a,this.bx=3*(c-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*b,this.by=3*(d-b)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=d,this.p2x=c,this.p2y=d}f.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},f.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},f.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},f.prototype.solveCurveX=function(a,b){var c,d,f,g,h;for(void 0===b&&(b=1e-6),f=a,h=0;h<8;h++){if(Math.abs(g=this.sampleCurveX(f)-a)<b)return f;var i=this.sampleCurveDerivativeX(f);if(1e-6>Math.abs(i))break;f-=g/i}if((f=a)<(c=0))return c;if(f>(d=1))return d;for(;c<d&&!(Math.abs((g=this.sampleCurveX(f))-a)<b);)a>g?c=f:d=f,f=.5*(d-c)+c;return f},f.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var g=h;function h(a,b){this.x=a,this.y=b}h.prototype={clone:function(){return new h(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},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(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(a,b){var c=Math.cos(a),d=Math.sin(a),f=b.y+d*(this.x-b.x)+c*(this.y-b.y);return this.x=b.x+c*(this.x-b.x)-d*(this.y-b.y),this.y=f,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},h.convert=function(a){return a instanceof h?a:Array.isArray(a)?new h(a[0],a[1]):a};var i="undefined"!=typeof self?self:{},j="undefined"!=typeof Float32Array?Float32Array:Array;function k(){var a=new j(9);return j!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function l(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function m(a,b,c){var d=b[0],f=b[1],g=b[2],h=b[3],i=b[4],j=b[5],k=b[6],l=b[7],m=b[8],n=b[9],o=b[10],p=b[11],q=b[12],r=b[13],s=b[14],u=b[15],v=c[0],w=c[1],x=c[2],y=c[3];return a[0]=v*d+w*i+x*m+y*q,a[1]=v*f+w*j+x*n+y*r,a[2]=v*g+w*k+x*o+y*s,a[3]=v*h+w*l+x*p+y*u,a[4]=(v=c[4])*d+(w=c[5])*i+(x=c[6])*m+(y=c[7])*q,a[5]=v*f+w*j+x*n+y*r,a[6]=v*g+w*k+x*o+y*s,a[7]=v*h+w*l+x*p+y*u,a[8]=(v=c[8])*d+(w=c[9])*i+(x=c[10])*m+(y=c[11])*q,a[9]=v*f+w*j+x*n+y*r,a[10]=v*g+w*k+x*o+y*s,a[11]=v*h+w*l+x*p+y*u,a[12]=(v=c[12])*d+(w=c[13])*i+(x=c[14])*m+(y=c[15])*q,a[13]=v*f+w*j+x*n+y*r,a[14]=v*g+w*k+x*o+y*s,a[15]=v*h+w*l+x*p+y*u,a}function n(a,b,c){var d,f,g,h,i,j,k,l,m,n,o,p,q=c[0],r=c[1],s=c[2];return b===a?(a[12]=b[0]*q+b[4]*r+b[8]*s+b[12],a[13]=b[1]*q+b[5]*r+b[9]*s+b[13],a[14]=b[2]*q+b[6]*r+b[10]*s+b[14],a[15]=b[3]*q+b[7]*r+b[11]*s+b[15]):(f=b[1],g=b[2],h=b[3],i=b[4],j=b[5],k=b[6],l=b[7],m=b[8],n=b[9],o=b[10],p=b[11],a[0]=d=b[0],a[1]=f,a[2]=g,a[3]=h,a[4]=i,a[5]=j,a[6]=k,a[7]=l,a[8]=m,a[9]=n,a[10]=o,a[11]=p,a[12]=d*q+i*r+m*s+b[12],a[13]=f*q+j*r+n*s+b[13],a[14]=g*q+k*r+o*s+b[14],a[15]=h*q+l*r+p*s+b[15]),a}function o(a,b,c){var d=c[0],f=c[1],g=c[2];return a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d,a[3]=b[3]*d,a[4]=b[4]*f,a[5]=b[5]*f,a[6]=b[6]*f,a[7]=b[7]*f,a[8]=b[8]*g,a[9]=b[9]*g,a[10]=b[10]*g,a[11]=b[11]*g,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function p(a,b,c){var d=Math.sin(c),f=Math.cos(c),g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=g*f+k*d,a[5]=h*f+l*d,a[6]=i*f+m*d,a[7]=j*f+n*d,a[8]=k*f-g*d,a[9]=l*f-h*d,a[10]=m*f-i*d,a[11]=n*f-j*d,a}function q(a,b,c){var d=Math.sin(c),f=Math.cos(c),g=b[0],h=b[1],i=b[2],j=b[3],k=b[8],l=b[9],m=b[10],n=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=g*f-k*d,a[1]=h*f-l*d,a[2]=i*f-m*d,a[3]=j*f-n*d,a[8]=g*d+k*f,a[9]=h*d+l*f,a[10]=i*d+m*f,a[11]=j*d+n*f,a}Math.hypot||(Math.hypot=function(){for(var a=0,b=arguments.length;b--;)a+=arguments[b]*arguments[b];return Math.sqrt(a)});var r=m;function s(){var a=new j(3);return j!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function u(a){var b=new j(3);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b}function v(a){return Math.hypot(a[0],a[1],a[2])}function w(a,b,c){var d=new j(3);return d[0]=a,d[1]=b,d[2]=c,d}function x(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function y(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function z(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function A(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function B(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function C(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function D(a,b){var c=b[0],d=b[1],f=b[2],g=c*c+d*d+f*f;return g>0&&(g=1/Math.sqrt(g)),a[0]=b[0]*g,a[1]=b[1]*g,a[2]=b[2]*g,a}function E(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function F(a,b,c){var d=b[0],f=b[1],g=b[2],h=c[0],i=c[1],j=c[2];return a[0]=f*j-g*i,a[1]=g*h-d*j,a[2]=d*i-f*h,a}function G(a,b,c){var d=b[0],f=b[1],g=b[2],h=c[3]*d+c[7]*f+c[11]*g+c[15];return a[0]=(c[0]*d+c[4]*f+c[8]*g+c[12])/(h=h||1),a[1]=(c[1]*d+c[5]*f+c[9]*g+c[13])/h,a[2]=(c[2]*d+c[6]*f+c[10]*g+c[14])/h,a}function H(a,b,c){var d=c[0],f=c[1],g=c[2],h=b[0],i=b[1],j=b[2],k=f*j-g*i,l=g*h-d*j,m=d*i-f*h,n=f*m-g*l,o=g*k-d*m,p=d*l-f*k,q=2*c[3];return l*=q,m*=q,o*=2,p*=2,a[0]=h+(k*=q)+(n*=2),a[1]=i+l+o,a[2]=j+m+p,a}var I,J=y;function K(a,b,c){var d=b[0],f=b[1],g=b[2],h=b[3];return a[0]=c[0]*d+c[4]*f+c[8]*g+c[12]*h,a[1]=c[1]*d+c[5]*f+c[9]*g+c[13]*h,a[2]=c[2]*d+c[6]*f+c[10]*g+c[14]*h,a[3]=c[3]*d+c[7]*f+c[11]*g+c[15]*h,a}function L(){var a=new j(4);return j!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function M(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function N(a,b,c){c*=.5;var d=b[0],f=b[1],g=b[2],h=b[3],i=Math.sin(c),j=Math.cos(c);return a[0]=d*j+h*i,a[1]=f*j+g*i,a[2]=g*j-f*i,a[3]=h*j-d*i,a}function O(a,b){return a[0]===b[0]&&a[1]===b[1]}s(),I=new j(4),j!=Float32Array&&(I[0]=0,I[1]=0,I[2]=0,I[3]=0),s(),w(1,0,0),w(0,1,0),L(),L(),k(),lq=new j(2),j!=Float32Array&&(lq[0]=0,lq[1]=0);const P=Math.PI/180,Q=180/Math.PI;function R(a){return a*P}function S(a){return a*Q}const T=[[0,0],[1,0],[1,1],[0,1],];function U(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function V(a,b,d,f){const g=new c(a,b,d,f);return function(a){return g.solve(a)}}const W=V(.25,.1,.25,1);function X(a,b,c){return Math.min(c,Math.max(b,a))}function Y(a,b,c){return(c=X((c-a)/(b-a),0,1))*c*(3-2*c)}function Z(a,b,c){const d=c-b,f=((a-b)%d+d)%d+b;return f===b?c:f}function $(a,b,c){if(!a.length)return c(null,[]);let d=a.length;const f=Array(a.length);let g=null;a.forEach((a,h)=>{b(a,(a,b)=>{a&&(g=a),f[h]=b,0== --d&&c(g,f)})})}function _(a){const b=[];for(const c in a)b.push(a[c]);return b}function aa(a,...b){for(const c of b)for(const d in c)a[d]=c[d];return a}let ab=1;function ac(){return ab++}function ad(){return function a(b){return b?(b^16*Math.random()>>b/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,a)}()}function ae(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function af(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function ag(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function ah(a,b){return -1!==a.indexOf(b,a.length-b.length)}function ai(a,b,c){const d={};for(const f in a)d[f]=b.call(c||this,a[f],f,a);return d}function aj(a,b,c){const d={};for(const f in a)b.call(c||this,a[f],f,a)&&(d[f]=a[f]);return d}function ak(a){return Array.isArray(a)?a.map(ak):"object"==typeof a&&a?ai(a,ak):a}const al={};function am(a){al[a]||("undefined"!=typeof console&&console.warn(a),al[a]=!0)}function an(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function ao(a){let b=0;for(let c,d,f=0,g=a.length,h=g-1;f<g;h=f++)c=a[f],d=a[h],b+=(d.x-c.x)*(c.y+d.y);return b}function ap(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function aq(a){const b={};if(a.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(a,c,d,f)=>{const g=d||f;return b[c]=!g||g.toLowerCase(),""}),b["max-age"]){const c=parseInt(b["max-age"],10);isNaN(c)?delete b["max-age"]:b["max-age"]=c}return b}let ar,as,at,au=null;function av(a){if(null==au){const b=a.navigator?a.navigator.userAgent:null;au=!!a.safari||!(!b||!(/\b(iPad|iPhone|iPod)\b/.test(b)||b.match("Safari")&&!b.match("Chrome")))}return au}function aw(a){try{const b=i[a];return b.setItem("_mapbox_test_",1),b.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const ax={now:()=>void 0!==at?at:i.performance.now(),setNow(a){at=a},restoreNow(){at=void 0},frame(a){const b=i.requestAnimationFrame(a);return{cancel:()=>i.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=i.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(ar||(ar=i.document.createElement("a")),ar.href=a,ar.href),get devicePixelRatio(){return i.devicePixelRatio},get prefersReducedMotion(){return!!i.matchMedia&&(null==as&&(as=i.matchMedia("(prefers-reduced-motion: reduce)")),as.matches)}};let ay;const az={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==ay){const aA=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{ay=null!=d.env.API_URL_REGEX?RegExp(d.env.API_URL_REGEX):aA}catch(aB){ay=aA}}return ay},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"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},aC={supported:!1,testSupport:function(a){!aF&&aE&&(aG?aH(a):aD=a)}};let aD,aE,aF=!1,aG=!1;function aH(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,aE),a.isContextLost())return;aC.supported=!0}catch(c){}a.deleteTexture(b),aF=!0}i.document&&((aE=i.document.createElement("img")).onload=function(){aD&&aH(aD),aD=null,aG=!0},aE.onerror=function(){aF=!0,aD=null},aE.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const aI="NO_ACCESS_TOKEN";function aJ(a){return 0===a.indexOf("mapbox:")}function aK(a){return az.API_URL_REGEX.test(a)}const aL=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function aM(a){const b=a.match(aL);if(!b)throw Error("Unable to parse URL object");return{protocol:b[1],authority:b[2],path:b[3]||"/",params:b[4]?b[4].split("&"):[]}}function aN(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function aO(a){if(!a)return null;const b=a.split(".");if(!b||3!==b.length)return null;try{return JSON.parse(decodeURIComponent(i.atob(b[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class aP{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(a){const b=aO(az.ACCESS_TOKEN);let c="";return c=b&&b.u?i.btoa(encodeURIComponent(b.u).replace(/%([0-9A-F]{2})/g,(a,b)=>String.fromCharCode(Number("0x"+b)))):az.ACCESS_TOKEN||"",a?`mapbox.eventData.${a}:${c}`:`mapbox.eventData:${c}`}fetchEventData(){const a=aw("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{const d=i.localStorage.getItem(b);d&&(this.eventData=JSON.parse(d));const f=i.localStorage.getItem(c);f&&(this.anonId=f)}catch(g){am("Unable to read from LocalStorage")}}saveEventData(){const a=aw("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{i.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&i.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){am("Unable to write to LocalStorage")}}processRequests(a){}postEvent(a,c,d,f){if(!az.EVENTS_URL)return;const g=aM(az.EVENTS_URL);g.params.push(`access_token=${f||az.ACCESS_TOKEN||""}`);const h={event:this.type,created:new Date(a).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:b,skuId:"01",userId:this.anonId},i=c?aa(h,c):h,j={url:aN(g),headers:{"Content-Type":"text/plain"},body:JSON.stringify([i])};this.pendingRequest=a8(j,a=>{this.pendingRequest=null,d(a),this.saveEventData(),this.processRequests(f)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const aQ=new class extends aP{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){az.EVENTS_URL&&az.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>aJ(a)||aK(a))&&this.queueRequest(Date.now(),b)}processRequests(a){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const b=aO(az.ACCESS_TOKEN),c=b?b.u:az.ACCESS_TOKEN;let d=c!==this.eventData.tokenU;af(this.anonId)||(this.anonId=ad(),d=!0);const f=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(f),i=(f-this.eventData.lastSuccess)/864e5;d=d||i>=1||i< -1||g.getDate()!==h.getDate()}else d=!0;if(!d)return this.processRequests();this.postEvent(f,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=f,this.eventData.tokenU=c)},a)}},aR=aQ.postTurnstileEvent.bind(aQ),aS=new class extends aP{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(a,b,c,d){this.skuToken=b,this.errorCb=d,az.EVENTS_URL&&(c||az.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},c):this.errorCb(Error(aI)))}processRequests(a){if(this.pendingRequest||0===this.queue.length)return;const{id:b,timestamp:c}=this.queue.shift();b&&this.success[b]||(this.anonId||this.fetchEventData(),af(this.anonId)||(this.anonId=ad()),this.postEvent(c,{skuToken:this.skuToken},a=>{a?this.errorCb(a):b&&(this.success[b]=!0)},a))}},aT=aS.postMapLoadEvent.bind(aS),aU=new class extends aP{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(a,b,c,d){if(!az.API_URL||!az.SESSION_PATH)return;const f=aM(az.API_URL+az.SESSION_PATH);f.params.push(`sku=${b||""}`),f.params.push(`access_token=${d||az.ACCESS_TOKEN||""}`);const g={url:aN(f),headers:{"Content-Type":"text/plain"}};this.pendingRequest=a9(g,a=>{this.pendingRequest=null,c(a),this.saveEventData(),this.processRequests(d)})}getSessionAPI(a,b,c,d){this.skuToken=b,this.errorCb=d,az.SESSION_PATH&&az.API_URL&&(c||az.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},c):this.errorCb(Error(aI)))}processRequests(a){if(this.pendingRequest||0===this.queue.length)return;const{id:b,timestamp:c}=this.queue.shift();b&&this.success[b]||this.getSession(c,this.skuToken,a=>{a?this.errorCb(a):b&&(this.success[b]=!0)},a)}},aV=aU.getSessionAPI.bind(aU),aW=new Set,aX="mapbox-tiles";let aY,aZ,a$=500,a_=50;function a0(){i.caches&&!aY&&(aY=i.caches.open(aX))}function a1(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let a2=1/0;const a3={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(a3);class a4 extends Error{constructor(a,b,c){401===b&&aK(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const a5=ap()?()=>self.worker&&self.worker.referrer:()=>("blob:"===i.location.protocol?i.parent:i).location.href,a6=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(a5())&&!/^\w+:/.test(c))){if(i.fetch&&i.Request&&i.AbortController&&i.Request.prototype.hasOwnProperty("signal"))return function(a,b){var c;const d=new i.AbortController,f=new i.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:a5(),signal:d.signal});let g=!1,h=!1;const j=(c=f.url).indexOf("sku=")>0&&aK(c);"json"===a.type&&f.headers.set("Accept","application/json");const k=(c,d,g)=>{if(h)return;if(c&&"SecurityError"!==c.message&&am(c),d&&g)return l(d);const k=Date.now();i.fetch(f).then(c=>{if(c.ok){const d=j?c.clone():null;return l(c,d,k)}return b(new a4(c.statusText,c.status,a.url))}).catch(a=>{20!==a.code&&b(Error(a.message))})},l=(c,d,j)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{h||(d&&j&&function(a,b,c){if(a0(),!aY)return;const d={status:b.status,statusText:b.statusText,headers:new i.Headers};b.headers.forEach((a,b)=>d.headers.set(b,a));const f=aq(b.headers.get("Cache-Control")||"");f["no-store"]||(f["max-age"]&&d.headers.set("Expires",new Date(c+1e3*f["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||function(a,b){if(void 0===aZ)try{new Response(new ReadableStream),aZ=!0}catch(c){aZ=!1}aZ?b(a.body):a.blob().then(b)}(b,b=>{const c=new i.Response(b,d);a0(),aY&&aY.then(b=>b.put(a1(a.url),c)).catch(a=>am(a.message))}))}(f,d,j),g=!0,b(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{h||b(Error(a.message))})};return j?function(a,b){if(a0(),!aY)return b(null);const c=a1(a.url);aY.then(a=>{a.match(c).then(d=>{const f=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=aq(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);a.delete(c),f&&a.put(c,d.clone()),b(null,d,f)}).catch(b)}).catch(b)}(f,k):k(null,null),{cancel(){h=!0,g||d.abort()}}}(a,b);if(ap()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return function(a,b){const c=new i.XMLHttpRequest;for(const d in c.open(a.method||"GET",a.url,!0),"arrayBuffer"===a.type&&(c.responseType="arraybuffer"),a.headers)c.setRequestHeader(d,a.headers[d]);return"json"===a.type&&(c.responseType="text",c.setRequestHeader("Accept","application/json")),c.withCredentials="include"===a.credentials,c.onerror=()=>{b(Error(c.statusText))},c.onload=()=>{if((c.status>=200&&c.status<300||0===c.status)&&null!==c.response){let d=c.response;if("json"===a.type)try{d=JSON.parse(c.response)}catch(f){return b(f)}b(null,d,c.getResponseHeader("Cache-Control"),c.getResponseHeader("Expires"))}else b(new a4(c.statusText,c.status,a.url))},c.send(a.body),{cancel:()=>c.abort()}}(a,b)},a7=function(a,b){return a6(aa(a,{type:"arrayBuffer"}),b)},a8=function(a,b){return a6(aa(a,{method:"POST"}),b)},a9=function(a,b){return a6(aa(a,{method:"GET"}),b)};function ba(a){const b=i.document.createElement("a");return b.href=a,b.protocol===i.document.location.protocol&&b.host===i.document.location.host}const bb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let bc,bd;bc=[],bd=0;const be=function(a,b){if(aC.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),bd>=az.MAX_PARALLEL_IMAGE_REQUESTS){const c={requestParameters:a,callback:b,cancelled:!1,cancel(){this.cancelled=!0}};return bc.push(c),c}bd++;let d=!1;const f=()=>{if(!d)for(d=!0,bd--;bc.length&&bd<az.MAX_PARALLEL_IMAGE_REQUESTS;){const a=bc.shift(),{requestParameters:b,callback:c,cancelled:f}=a;f||(a.cancel=be(b,c).cancel)}},g=a7(a,(a,c,d,g)=>{f(),a?b(a):c&&(i.createImageBitmap?function(a,b){const c=new i.Blob([new Uint8Array(a)],{type:"image/png"});i.createImageBitmap(c).then(a=>{b(null,a)}).catch(a=>{b(Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(c,(a,c)=>b(a,c,d,g)):function(a,b){const c=new i.Image,d=i.URL;c.onload=()=>{b(null,c),d.revokeObjectURL(c.src),c.onload=null,i.requestAnimationFrame(()=>{c.src=bb})},c.onerror=()=>b(Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const f=new i.Blob([new Uint8Array(a)],{type:"image/png"});c.src=a.byteLength?d.createObjectURL(f):bb}(c,(a,c)=>b(a,c,d,g)))});return{cancel(){g.cancel(),f()}}};function bf(a,b,c){c[a]&& -1!==c[a].indexOf(b)||(c[a]=c[a]||[],c[a].push(b))}function bg(a,b,c){if(c&&c[a]){const d=c[a].indexOf(b);-1!==d&&c[a].splice(d,1)}}class bh{constructor(a,b={}){aa(this,b),this.type=a}}class bi extends bh{constructor(a,b={}){super("error",aa({error:a},b))}}class bj{on(a,b){return this._listeners=this._listeners||{},bf(a,b,this._listeners),this}off(a,b){return bg(a,b,this._listeners),bg(a,b,this._oneTimeListeners),this}once(a,b){return b?(this._oneTimeListeners=this._oneTimeListeners||{},bf(a,b,this._oneTimeListeners),this):new Promise(b=>this.once(a,b))}fire(a,b){"string"==typeof a&&(a=new bh(a,b||{}));const c=a.type;if(this.listens(c)){a.target=this;const d=this._listeners&&this._listeners[c]?this._listeners[c].slice():[];for(const f of d)f.call(this,a);const g=this._oneTimeListeners&&this._oneTimeListeners[c]?this._oneTimeListeners[c].slice():[];for(const h of g)bg(c,h,this._oneTimeListeners),h.call(this,a);const i=this._eventedParent;i&&(aa(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(a))}else a instanceof bi&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var bk=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"}}}');class bl{constructor(a,b,c,d){this.message=(a?`${a}: `:"")+c,d&&(this.identifier=d),null!=b&&b.__line__&&(this.line=b.__line__)}}function bm(a){const b=a.value;return b?[new bl(a.key,b,"constants have been deprecated as of v8"),]:[]}function bn(a,...b){for(const c of b)for(const d in c)a[d]=c[d];return a}function bo(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function bp(a){if(Array.isArray(a))return a.map(bp);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=bp(a[c]);return b}return bo(a)}class bq extends Error{constructor(a,b){super(b),this.message=b,this.key=a}}class br{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new br(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const bs={kind:"null"},bt={kind:"number"},bu={kind:"string"},bv={kind:"boolean"},bw={kind:"color"},bx={kind:"object"},by={kind:"value"},bz={kind:"collator"},bA={kind:"formatted"},bB={kind:"resolvedImage"};function bC(a,b){return{kind:"array",itemType:a,N:b}}function bD(a){if("array"===a.kind){const b=bD(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const bE=[bs,bt,bu,bv,bw,bA,bx,bC(by),bB];function bF(a,b){if("error"===b.kind)return null;if("array"===a.kind){if("array"===b.kind&&(0===b.N&&"value"===b.itemType.kind||!bF(a.itemType,b.itemType))&&("number"!=typeof a.N||a.N===b.N))return null}else{if(a.kind===b.kind)return null;if("value"===a.kind){for(const c of bE)if(!bF(c,b))return null}}return`Expected ${bD(a)} but found ${bD(b)} instead.`}function bG(a,b){return b.some(b=>b.kind===a.kind)}function bH(a,b){return b.some(b=>"null"===b?null===a:"array"===b?Array.isArray(a):"object"===b?a&&!Array.isArray(a)&&"object"==typeof a:b===typeof a)}function bI(a){var b={exports:{}};return a(b,b.exports),b.exports}var bJ=bI(function(a,b){var c={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 d(a){return(a=Math.round(a))<0?0:a>255?255:a}function f(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function g(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function h(a,b,c){return c<0?c+=1:c>1&&(c-=1),6*c<1?a+(b-a)*c*6:2*c<1?b:3*c<2?a+(b-a)*(2/3-c)*6:a}try{b.parseCSSColor=function(a){var b,i=a.replace(/ /g,"").toLowerCase();if(i in c)return c[i].slice();if("#"===i[0])return 4===i.length?(b=parseInt(i.substr(1),16))>=0&&b<=4095?[(3840&b)>>4|(3840&b)>>8,240&b|(240&b)>>4,15&b|(15&b)<<4,1,]:null:7===i.length&&(b=parseInt(i.substr(1),16))>=0&&b<=16777215?[(16711680&b)>>16,(65280&b)>>8,255&b,1,]:null;var j=i.indexOf("("),k=i.indexOf(")");if(-1!==j&&k+1===i.length){var l=i.substr(0,j),m=i.substr(j+1,k-(j+1)).split(","),n=1;switch(l){case"rgba":if(4!==m.length)break;n=g(m.pop());case"rgb":return 3!==m.length?null:[f(m[0]),f(m[1]),f(m[2]),n,];case"hsla":if(4!==m.length)break;n=g(m.pop());case"hsl":if(3!==m.length)break;var o=(parseFloat(m[0])%360+360)%360/360,p=g(m[1]),q=g(m[2]),r=q<=.5?q*(p+1):q+p-q*p,s=2*q-r;return[d(255*h(s,r,o+1/3)),d(255*h(s,r,o)),d(255*h(s,r,o-1/3)),n,]}}return null}}catch(i){}});class bK{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(a){if(!a)return;if(a instanceof bK)return a;if("string"!=typeof a)return;const b=bJ.parseCSSColor(a);return b?new bK(b[0]/255*b[3],b[1]/255*b[3],b[2]/255*b[3],b[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:a,g:b,b:c,a:d}=this;return 0===d?[0,0,0,0]:[255*a/d,255*b/d,255*c/d,d,]}}bK.black=new bK(0,0,0,1),bK.white=new bK(1,1,1,1),bK.transparent=new bK(0,0,0,0),bK.red=new bK(1,0,0,1),bK.blue=new bK(0,0,1,1);class bL{constructor(a,b,c){this.sensitivity=a?b?"variant":"case":b?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class bM{constructor(a,b,c,d,f){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=f}}class bN{constructor(a){this.sections=a}static fromString(a){return new bN([new bM(a,null,null,null,null),])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof bN?a:bN.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const a=["format"];for(const b of this.sections){if(b.image){a.push(["image",b.image.name]);continue}a.push(b.text);const c={};b.fontStack&&(c["text-font"]=["literal",b.fontStack.split(","),]),b.scale&&(c["font-scale"]=b.scale),b.textColor&&(c["text-color"]=["rgba"].concat(b.textColor.toArray())),a.push(c)}return a}}class bO{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new bO({name:a,available:!1}):null}serialize(){return["image",this.name]}}function bP(a,b,c,d){return"number"==typeof a&&a>=0&&a<=255&&"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255?void 0===d||"number"==typeof d&&d>=0&&d<=1?null:`Invalid rgba value [${[a,b,c,d].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof d?[a,b,c,d]:[a,b,c]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function bQ(a){if(null===a||"string"==typeof a||"boolean"==typeof a||"number"==typeof a||a instanceof bK||a instanceof bL||a instanceof bN||a instanceof bO)return!0;if(Array.isArray(a)){for(const b of a)if(!bQ(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!bQ(a[c]))return!1;return!0}return!1}function bR(a){if(null===a)return bs;if("string"==typeof a)return bu;if("boolean"==typeof a)return bv;if("number"==typeof a)return bt;if(a instanceof bK)return bw;if(a instanceof bL)return bz;if(a instanceof bN)return bA;if(a instanceof bO)return bB;if(Array.isArray(a)){const b=a.length;let c;for(const d of a){const f=bR(d);if(c){if(c===f)continue;c=by;break}c=f}return bC(c||by,b)}return bx}function bS(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof bK||a instanceof bN||a instanceof bO?a.toString():JSON.stringify(a)}class bT{constructor(a,b){this.type=a,this.value=b}static parse(a,b){if(2!==a.length)return b.error(`'literal' expression requires exactly one argument, but found ${a.length-1} instead.`);if(!bQ(a[1]))return b.error("invalid value");const c=a[1];let d=bR(c);const f=b.expectedType;return"array"===d.kind&&0===d.N&&f&&"array"===f.kind&&("number"!=typeof f.N||0===f.N)&&(d=f),new bT(d,c)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof bK?["rgba"].concat(this.value.toArray()):this.value instanceof bN?this.value.serialize():this.value}}class bU{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const bV={string:bu,number:bt,boolean:bv,object:bx};class bW{constructor(a,b){this.type=a,this.args=b}static parse(a,b){if(a.length<2)return b.error("Expected at least one argument.");let c,d=1;const f=a[0];if("array"===f){let g,h;if(a.length>2){const i=a[1];if("string"!=typeof i||!(i in bV)||"object"===i)return b.error('The item type argument of "array" must be one of string, number, boolean',1);g=bV[i],d++}else g=by;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return b.error('The length argument to "array" must be a positive integer literal',2);h=a[2],d++}c=bC(g,h)}else c=bV[f];const j=[];for(;d<a.length;d++){const k=b.parse(a[d],d,by);if(!k)return null;j.push(k)}return new bW(c,j)}evaluate(a){for(let b=0;b<this.args.length;b++){const c=this.args[b].evaluate(a);if(!bF(this.type,bR(c)))return c;if(b===this.args.length-1)throw new bU(`Expected value to be of type ${bD(this.type)}, but found ${bD(bR(c))} instead.`)}return null}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=this.type,b=[a.kind];if("array"===a.kind){const c=a.itemType;if("string"===c.kind||"number"===c.kind||"boolean"===c.kind){b.push(c.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&b.push(d)}}return b.concat(this.args.map(a=>a.serialize()))}}class bX{constructor(a){this.type=bA,this.sections=a}static parse(a,b){if(a.length<2)return b.error("Expected at least one argument.");const c=a[1];if(!Array.isArray(c)&&"object"==typeof c)return b.error("First argument must be an image or text section.");const d=[];let f=!1;for(let g=1;g<=a.length-1;++g){const h=a[g];if(f&&"object"==typeof h&&!Array.isArray(h)){f=!1;let i=null;if(h["font-scale"]&&!(i=b.parse(h["font-scale"],1,bt)))return null;let j=null;if(h["text-font"]&&!(j=b.parse(h["text-font"],1,bC(bu))))return null;let k=null;if(h["text-color"]&&!(k=b.parse(h["text-color"],1,bw)))return null;const l=d[d.length-1];l.scale=i,l.font=j,l.textColor=k}else{const m=b.parse(a[g],1,by);if(!m)return null;const n=m.type.kind;if("string"!==n&&"value"!==n&&"null"!==n&&"resolvedImage"!==n)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");f=!0,d.push({content:m,scale:null,font:null,textColor:null})}}return new bX(d)}evaluate(a){return new bN(this.sections.map(b=>{const c=b.content.evaluate(a);return bR(c)===bB?new bM("",c,null,null,null):new bM(bS(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(a){for(const b of this.sections)a(b.content),b.scale&&a(b.scale),b.font&&a(b.font),b.textColor&&a(b.textColor)}outputDefined(){return!1}serialize(){const a=["format"];for(const b of this.sections){a.push(b.content.serialize());const c={};b.scale&&(c["font-scale"]=b.scale.serialize()),b.font&&(c["text-font"]=b.font.serialize()),b.textColor&&(c["text-color"]=b.textColor.serialize()),a.push(c)}return a}}class bY{constructor(a){this.type=bB,this.input=a}static parse(a,b){if(2!==a.length)return b.error("Expected two arguments.");const c=b.parse(a[1],1,bu);return c?new bY(c):b.error("No image name provided.")}evaluate(a){const b=this.input.evaluate(a),c=bO.fromString(b);return c&&a.availableImages&&(c.available=a.availableImages.indexOf(b)> -1),c}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const bZ={"to-boolean":bv,"to-color":bw,"to-number":bt,"to-string":bu};class b${constructor(a,b){this.type=a,this.args=b}static parse(a,b){if(a.length<2)return b.error("Expected at least one argument.");const c=a[0];if(("to-boolean"===c||"to-string"===c)&&2!==a.length)return b.error("Expected one argument.");const d=bZ[c],f=[];for(let g=1;g<a.length;g++){const h=b.parse(a[g],g,by);if(!h)return null;f.push(h)}return new b$(d,f)}evaluate(a){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(a));if("color"===this.type.kind){let b,c;for(const d of this.args){if(b=d.evaluate(a),c=null,b instanceof bK)return b;if("string"==typeof b){const f=a.parseColor(b);if(f)return f}else if(Array.isArray(b)&&!(c=b.length<3||b.length>4?`Invalid rbga value ${JSON.stringify(b)}: expected an array containing either three or four numeric values.`:bP(b[0],b[1],b[2],b[3])))return new bK(b[0]/255,b[1]/255,b[2]/255,b[3])}throw new bU(c||`Could not parse color from value '${"string"==typeof b?b:String(JSON.stringify(b))}'`)}if("number"===this.type.kind){let g=null;for(const h of this.args){if(null===(g=h.evaluate(a)))return 0;const i=Number(g);if(!isNaN(i))return i}throw new bU(`Could not convert ${JSON.stringify(g)} to number.`)}return"formatted"===this.type.kind?bN.fromString(bS(this.args[0].evaluate(a))):"resolvedImage"===this.type.kind?bO.fromString(bS(this.args[0].evaluate(a))):bS(this.args[0].evaluate(a))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new bX([{content:this.args[0],scale:null,font:null,textColor:null},]).serialize();if("resolvedImage"===this.type.kind)return new bY(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const b_=["Unknown","Point","LineString","Polygon",];class b0{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:null}geometryType(){return this.feature?"number"==typeof this.feature.type?b_[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=bK.parse(a)),b}}class b1{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(a,b){const c=a[0],d=b1.definitions[c];if(!d)return b.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0);const f=Array.isArray(d)?d[0]:d.type,g=Array.isArray(d)?[[d[1],d[2]]]:d.overloads,h=g.filter(([b])=>!Array.isArray(b)||b.length===a.length-1);let i=null;for(const[j,k]of h){i=new cn(b.registry,b.path,null,b.scope);const l=[];let m=!1;for(let n=1;n<a.length;n++){const o=a[n],p=Array.isArray(j)?j[n-1]:j.type,q=i.parse(o,1+l.length,p);if(!q){m=!0;break}l.push(q)}if(!m){if(Array.isArray(j)&&j.length!==l.length)i.error(`Expected ${j.length} arguments, but found ${l.length} instead.`);else{for(let r=0;r<l.length;r++){const s=Array.isArray(j)?j[r]:j.type,u=l[r];i.concat(r+1).checkSubtype(s,u.type)}if(0===i.errors.length)return new b1(c,f,k,l)}}}if(1===h.length)b.errors.push(...i.errors);else{const v=(h.length?h:g).map(([a])=>{var b;return Array.isArray(b=a)?`(${b.map(bD).join(", ")})`:`(${bD(b.type)}...)`}).join(" | "),w=[];for(let x=1;x<a.length;x++){const y=b.parse(a[x],1+w.length);if(!y)return null;w.push(bD(y.type))}b.error(`Expected arguments of type ${v}, but found (${w.join(", ")}) instead.`)}return null}static register(a,b){for(const c in b1.definitions=b,b)a[c]=b1}}class b2{constructor(a,b,c){this.type=bz,this.locale=c,this.caseSensitive=a,this.diacriticSensitive=b}static parse(a,b){if(2!==a.length)return b.error("Expected one argument.");const c=a[1];if("object"!=typeof c||Array.isArray(c))return b.error("Collator options argument must be an object.");const d=b.parse(void 0!==c["case-sensitive"]&&c["case-sensitive"],1,bv);if(!d)return null;const f=b.parse(void 0!==c["diacritic-sensitive"]&&c["diacritic-sensitive"],1,bv);if(!f)return null;let g=null;return!c.locale||(g=b.parse(c.locale,1,bu))?new b2(d,f,g):null}evaluate(a){return new bL(this.caseSensitive.evaluate(a),this.diacriticSensitive.evaluate(a),this.locale?this.locale.evaluate(a):null)}eachChild(a){a(this.caseSensitive),a(this.diacriticSensitive),this.locale&&a(this.locale)}outputDefined(){return!1}serialize(){const a={};return a["case-sensitive"]=this.caseSensitive.serialize(),a["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(a.locale=this.locale.serialize()),["collator",a]}}function b3(a,b){a[0]=Math.min(a[0],b[0]),a[1]=Math.min(a[1],b[1]),a[2]=Math.max(a[2],b[0]),a[3]=Math.max(a[3],b[1])}function b4(a,b){return!(a[0]<=b[0]||a[2]>=b[2]||a[1]<=b[1]||a[3]>=b[3])}function b5(a,b){const c=(180+a[0])/360,d=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,f=Math.pow(2,b.z);return[Math.round(c*f*8192),Math.round(d*f*8192),]}function b6(a,b,c){const d=a[0]-b[0],f=a[1]-b[1],g=a[0]-c[0],h=a[1]-c[1];return d*h-g*f==0&&d*g<=0&&f*h<=0}function b7(a,b){var c,d,f;let g=!1;for(let h=0,i=b.length;h<i;h++){const j=b[h];for(let k=0,l=j.length;k<l-1;k++){if(b6(a,j[k],j[k+1]))return!1;(d=j[k])[1]>(c=a)[1]!=(f=j[k+1])[1]>c[1]&&c[0]<(f[0]-d[0])*(c[1]-d[1])/(f[1]-d[1])+d[0]&&(g=!g)}}return g}function b8(a,b){for(let c=0;c<b.length;c++)if(b7(a,b[c]))return!0;return!1}function b9(a,b,c,d){const f=d[0]-c[0],g=d[1]-c[1],h=(a[0]-c[0])*g-f*(a[1]-c[1]),i=(b[0]-c[0])*g-f*(b[1]-c[1]);return h>0&&i<0||h<0&&i>0}function ca(a,b,c){var d,f,g,h,i,j;for(const k of c)for(let l=0;l<k.length-1;++l)if(0!=(i=[(h=k[l+1])[0]-(g=k[l])[0],h[1]-g[1],])[0]*(j=[(f=b)[0]-(d=a)[0],f[1]-d[1],])[1]-i[1]*j[0]&&b9(d,f,g,h)&&b9(g,h,d,f))return!0;return!1}function cb(a,b){for(let c=0;c<a.length;++c)if(!b7(a[c],b))return!1;for(let d=0;d<a.length-1;++d)if(ca(a[d],a[d+1],b))return!1;return!0}function cc(a,b){for(let c=0;c<b.length;c++)if(cb(a,b[c]))return!0;return!1}function cd(a,b,c){const d=[];for(let f=0;f<a.length;f++){const g=[];for(let h=0;h<a[f].length;h++){const i=b5(a[f][h],c);b3(b,i),g.push(i)}d.push(g)}return d}function ce(a,b,c){const d=[];for(let f=0;f<a.length;f++){const g=cd(a[f],b,c);d.push(g)}return d}function cf(a,b,c,d){if(a[0]<c[0]||a[0]>c[2]){const f=.5*d;let g=a[0]-c[0]>f?-d:c[0]-a[0]>f?d:0;0===g&&(g=a[0]-c[2]>f?-d:c[2]-a[0]>f?d:0),a[0]+=g}b3(b,a)}function cg(a,b,c,d){const f=8192*Math.pow(2,d.z),g=[8192*d.x,8192*d.y],h=[];for(const i of a)for(const j of i){const k=[j.x+g[0],j.y+g[1]];cf(k,b,c,f),h.push(k)}return h}function ch(a,b,c,d){var f;const g=8192*Math.pow(2,d.z),h=[8192*d.x,8192*d.y],i=[];for(const j of a){const k=[];for(const l of j){const m=[l.x+h[0],l.y+h[1]];b3(b,m),k.push(m)}i.push(k)}if(b[2]-b[0]<=g/2)for(const n of((f=b)[0]=f[1]=1/0,f[2]=f[3]=-1/0,i))for(const o of n)cf(o,b,c,g);return i}class ci{constructor(a,b){this.type=bv,this.geojson=a,this.geometries=b}static parse(a,b){if(2!==a.length)return b.error(`'within' expression requires exactly one argument, but found ${a.length-1} instead.`);if(bQ(a[1])){const c=a[1];if("FeatureCollection"===c.type)for(let d=0;d<c.features.length;++d){const f=c.features[d].geometry.type;if("Polygon"===f||"MultiPolygon"===f)return new ci(c,c.features[d].geometry)}else if("Feature"===c.type){const g=c.geometry.type;if("Polygon"===g||"MultiPolygon"===g)return new ci(c,c.geometry)}else if("Polygon"===c.type||"MultiPolygon"===c.type)return new ci(c,c)}return b.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(a){if(null!=a.geometry()&&null!=a.canonicalID()){if("Point"===a.geometryType())return function(a,b){const c=[1/0,1/0,-1/0,-1/0,],d=[1/0,1/0,-1/0,-1/0,],f=a.canonicalID();if("Polygon"===b.type){const g=cd(b.coordinates,d,f),h=cg(a.geometry(),c,d,f);if(!b4(c,d))return!1;for(const i of h)if(!b7(i,g))return!1}if("MultiPolygon"===b.type){const j=ce(b.coordinates,d,f),k=cg(a.geometry(),c,d,f);if(!b4(c,d))return!1;for(const l of k)if(!b8(l,j))return!1}return!0}(a,this.geometries);if("LineString"===a.geometryType())return function(a,b){const c=[1/0,1/0,-1/0,-1/0,],d=[1/0,1/0,-1/0,-1/0,],f=a.canonicalID();if("Polygon"===b.type){const g=cd(b.coordinates,d,f),h=ch(a.geometry(),c,d,f);if(!b4(c,d))return!1;for(const i of h)if(!cb(i,g))return!1}if("MultiPolygon"===b.type){const j=ce(b.coordinates,d,f),k=ch(a.geometry(),c,d,f);if(!b4(c,d))return!1;for(const l of k)if(!cc(l,j))return!1}return!0}(a,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function cj(a){if(a instanceof b1&&("get"===a.name&&1===a.args.length||"feature-state"===a.name||"has"===a.name&&1===a.args.length||"properties"===a.name||"geometry-type"===a.name||"id"===a.name||/^filter-/.test(a.name))||a instanceof ci)return!1;let b=!0;return a.eachChild(a=>{b&&!cj(a)&&(b=!1)}),b}function ck(a){if(a instanceof b1&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!ck(a)&&(b=!1)}),b}function cl(a,b){if(a instanceof b1&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!cl(a,b)&&(c=!1)}),c}class cm{constructor(a,b){this.type=b.type,this.name=a,this.boundExpression=b}static parse(a,b){if(2!==a.length||"string"!=typeof a[1])return b.error("'var' expression requires exactly one string literal argument.");const c=a[1];return b.scope.has(c)?new cm(c,b.scope.get(c)):b.error(`Unknown variable "${c}". Make sure "${c}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class cn{constructor(a,b=[],c,d=new br,f=[]){this.registry=a,this.path=b,this.key=b.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=f,this.expectedType=c}parse(a,b,c,d,f={}){return b?this.concat(b,c,d)._parse(a,f):this._parse(a,f)}_parse(a,b){function c(a,b,c){return"assert"===c?new bW(b,[a]):"coerce"===c?new b$(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const f=this.registry[d];if(f){let g=f.parse(a,this);if(!g)return null;if(this.expectedType){const h=this.expectedType,i=g.type;if("string"!==h.kind&&"number"!==h.kind&&"boolean"!==h.kind&&"object"!==h.kind&&"array"!==h.kind||"value"!==i.kind){if("color"!==h.kind&&"formatted"!==h.kind&&"resolvedImage"!==h.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(h,i))return null}else g=c(g,h,b.typeAnnotation||"coerce")}else g=c(g,h,b.typeAnnotation||"assert")}if(!(g instanceof bT)&&"resolvedImage"!==g.type.kind&&co(g)){const j=new b0;try{g=new bT(g.type,g.evaluate(j))}catch(k){return this.error(k.message),null}}return g}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof a} instead.`)}concat(a,b,c){const d="number"==typeof a?this.path.concat(a):this.path,f=c?this.scope.concat(c):this.scope;return new cn(this.registry,d,b||null,f,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new bq(c,a))}checkSubtype(a,b){const c=bF(a,b);return c&&this.error(c),c}}function co(a){if(a instanceof cm)return co(a.boundExpression);if(a instanceof b1&&"error"===a.name||a instanceof b2||a instanceof ci)return!1;const b=a instanceof b$||a instanceof bW;let c=!0;return a.eachChild(a=>{c=b?c&&co(a):c&&a instanceof bT}),!!c&&cj(a)&&cl(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center",])}function cp(a,b){const c=a.length-1;let d,f,g=0,h=c,i=0;for(;g<=h;)if(d=a[i=Math.floor((g+h)/2)],f=a[i+1],d<=b){if(i===c||b<f)return i;g=i+1}else{if(!(d>b))throw new bU("Input is not a number.");h=i-1}return 0}class cq{constructor(a,b,c){for(const[d,f]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(f)}static parse(a,b){if(a.length-1<4)return b.error(`Expected at least 4 arguments, but found only ${a.length-1}.`);if((a.length-1)%2!=0)return b.error("Expected an even number of arguments.");const c=b.parse(a[1],1,bt);if(!c)return null;const d=[];let f=null;b.expectedType&&"value"!==b.expectedType.kind&&(f=b.expectedType);for(let g=1;g<a.length;g+=2){const h=1===g?-1/0:a[g],i=a[g+1],j=g,k=g+1;if("number"!=typeof h)return b.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',j);if(d.length&&d[d.length-1][0]>=h)return b.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',j);const l=b.parse(i,k,f);if(!l)return null;f=f||l.type,d.push([h,l])}return new cq(f,c,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const f=b.length;return d>=b[f-1]?c[f-1].evaluate(a):c[cp(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const a=["step",this.input.serialize()];for(let b=0;b<this.labels.length;b++)b>0&&a.push(this.labels[b]),a.push(this.outputs[b].serialize());return a}}function cr(a,b,c){return a*(1-c)+b*c}var cs=Object.freeze({__proto__:null,number:cr,color:function(a,b,c){return new bK(cr(a.r,b.r,c),cr(a.g,b.g,c),cr(a.b,b.b,c),cr(a.a,b.a,c))},array:function(a,b,c){return a.map((a,d)=>cr(a,b[d],c))}});const ct=4/29,cu=6/29,cv=3*cu*cu,cw=Math.PI/180,cx=180/Math.PI;function cy(a){return a>.008856451679035631?Math.pow(a,1/3):a/cv+ct}function cz(a){return a>cu?a*a*a:cv*(a-ct)}function cA(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function cB(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function cC(a){const b=cB(a.r),c=cB(a.g),d=cB(a.b),f=cy((.4124564*b+.3575761*c+.1804375*d)/.95047),g=cy((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*g-16,a:500*(f-g),b:200*(g-cy((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function cD(a){let b=(a.l+16)/116,c=isNaN(a.a)?b:b+a.a/500,d=isNaN(a.b)?b:b-a.b/200;return b=1*cz(b),c=.95047*cz(c),d=1.08883*cz(d),new bK(cA(3.2404542*c-1.5371385*b-.4985314*d),cA(-0.969266*c+1.8760108*b+.041556*d),cA(.0556434*c-.2040259*b+1.0572252*d),a.alpha)}const cE={forward:cC,reverse:cD,interpolate:function(a,b,c){return{l:cr(a.l,b.l,c),a:cr(a.a,b.a,c),b:cr(a.b,b.b,c),alpha:cr(a.alpha,b.alpha,c)}}},cF={forward:function(a){const{l:b,a:c,b:d}=cC(a),f=Math.atan2(d,c)*cx;return{h:f<0?f+360:f,c:Math.sqrt(c*c+d*d),l:b,alpha:a.a}},reverse:function(a){const b=a.h*cw,c=a.c;return cD({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){return{h:function(a,b,c){const d=b-a;return a+c*(d>180||d< -180?d-360*Math.round(d/360):d)}(a.h,b.h,c),c:cr(a.c,b.c,c),l:cr(a.l,b.l,c),alpha:cr(a.alpha,b.alpha,c)}}};var cG=Object.freeze({__proto__:null,lab:cE,hcl:cF});class cH{constructor(a,b,c,d,f){for(const[g,h]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],f))this.labels.push(g),this.outputs.push(h)}static interpolationFactor(a,b,d,f){let g=0;if("exponential"===a.name)g=cI(b,a.base,d,f);else if("linear"===a.name)g=cI(b,1,d,f);else if("cubic-bezier"===a.name){const h=a.controlPoints;g=new c(h[0],h[1],h[2],h[3]).solve(cI(b,1,d,f))}return g}static parse(a,b){let[c,d,f,...g]=a;if(!Array.isArray(d)||0===d.length)return b.error("Expected an interpolation type expression.",1);if("linear"===d[0])d={name:"linear"};else if("exponential"===d[0]){const h=d[1];if("number"!=typeof h)return b.error("Exponential interpolation requires a numeric base.",1,1);d={name:"exponential",base:h}}else{if("cubic-bezier"!==d[0])return b.error(`Unknown interpolation type ${String(d[0])}`,1,0);{const i=d.slice(1);if(4!==i.length||i.some(a=>"number"!=typeof a||a<0||a>1))return b.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);d={name:"cubic-bezier",controlPoints:i}}}if(a.length-1<4)return b.error(`Expected at least 4 arguments, but found only ${a.length-1}.`);if((a.length-1)%2!=0)return b.error("Expected an even number of arguments.");if(!(f=b.parse(f,2,bt)))return null;const j=[];let k=null;"interpolate-hcl"===c||"interpolate-lab"===c?k=bw:b.expectedType&&"value"!==b.expectedType.kind&&(k=b.expectedType);for(let l=0;l<g.length;l+=2){const m=g[l],n=g[l+1],o=l+3,p=l+4;if("number"!=typeof m)return b.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',o);if(j.length&&j[j.length-1][0]>=m)return b.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const q=b.parse(n,p,k);if(!q)return null;k=k||q.type,j.push([m,q])}return"number"===k.kind||"color"===k.kind||"array"===k.kind&&"number"===k.itemType.kind&&"number"==typeof k.N?new cH(k,c,d,f,j):b.error(`Type ${bD(k)} is not interpolatable.`)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const f=b.length;if(d>=b[f-1])return c[f-1].evaluate(a);const g=cp(b,d),h=cH.interpolationFactor(this.interpolation,d,b[g],b[g+1]),i=c[g].evaluate(a),j=c[g+1].evaluate(a);return"interpolate"===this.operator?cs[this.type.kind.toLowerCase()](i,j,h):"interpolate-hcl"===this.operator?cF.reverse(cF.interpolate(cF.forward(i),cF.forward(j),h)):cE.reverse(cE.interpolate(cE.forward(i),cE.forward(j),h))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let a;a="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base,]:["cubic-bezier"].concat(this.interpolation.controlPoints);const b=[this.operator,a,this.input.serialize(),];for(let c=0;c<this.labels.length;c++)b.push(this.labels[c],this.outputs[c].serialize());return b}}function cI(a,b,c,d){const f=d-c,g=a-c;return 0===f?0:1===b?g/f:(Math.pow(b,g)-1)/(Math.pow(b,f)-1)}class cJ{constructor(a,b){this.type=a,this.args=b}static parse(a,b){if(a.length<2)return b.error("Expectected at least one argument.");let c=null;const d=b.expectedType;d&&"value"!==d.kind&&(c=d);const f=[];for(const g of a.slice(1)){const h=b.parse(g,1+f.length,c,void 0,{typeAnnotation:"omit"});if(!h)return null;c=c||h.type,f.push(h)}const i=d&&f.some(a=>bF(d,a.type));return new cJ(i?by:c,f)}evaluate(a){let b,c=null,d=0;for(const f of this.args){if(d++,(c=f.evaluate(a))&&c instanceof bO&&!c.available&&(b||(b=c),c=null,d===this.args.length))return b;if(null!==c)break}return c}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cK{constructor(a,b){this.type=b.type,this.bindings=[].concat(a),this.result=b}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const c=[];for(let d=1;d<a.length-1;d+=2){const f=a[d];if("string"!=typeof f)return b.error(`Expected string, but found ${typeof f} instead.`,d);if(/[^a-zA-Z0-9_]/.test(f))return b.error("Variable names must contain only alphanumeric characters or '_'.",d);const g=b.parse(a[d+1],d+1);if(!g)return null;c.push([f,g])}const h=b.parse(a[a.length-1],a.length-1,b.expectedType,c);return h?new cK(c,h):null}outputDefined(){return this.result.outputDefined()}serialize(){const a=["let"];for(const[b,c]of this.bindings)a.push(b,c.serialize());return a.push(this.result.serialize()),a}}class cL{constructor(a,b,c){this.type=a,this.index=b,this.input=c}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,bt),d=b.parse(a[2],2,bC(b.expectedType||by));return c&&d?new cL(d.type.itemType,c,d):null}evaluate(a){const b=this.index.evaluate(a),c=this.input.evaluate(a);if(b<0)throw new bU(`Array index out of bounds: ${b} < 0.`);if(b>=c.length)throw new bU(`Array index out of bounds: ${b} > ${c.length-1}.`);if(b!==Math.floor(b))throw new bU(`Array index must be an integer, but found ${b} instead.`);return c[b]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize(),]}}class cM{constructor(a,b){this.type=bv,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,by),d=b.parse(a[2],2,by);return c&&d?bG(c.type,[bv,bu,bt,bs,by])?new cM(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${bD(c.type)} instead`):null}evaluate(a){const b=this.needle.evaluate(a),c=this.haystack.evaluate(a);if(!c)return!1;if(!bH(b,["boolean","string","number","null",]))throw new bU(`Expected first argument to be of type boolean, string, number or null, but found ${bD(bR(b))} instead.`);if(!bH(c,["string","array"]))throw new bU(`Expected second argument to be of type array or string, but found ${bD(bR(c))} instead.`);return c.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize(),]}}class cN{constructor(a,b,c){this.type=bt,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,by),d=b.parse(a[2],2,by);if(!c||!d)return null;if(!bG(c.type,[bv,bu,bt,bs,by]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${bD(c.type)} instead`);if(4===a.length){const f=b.parse(a[3],3,bt);return f?new cN(c,d,f):null}return new cN(c,d)}evaluate(a){const b=this.needle.evaluate(a),c=this.haystack.evaluate(a);if(!bH(b,["boolean","string","number","null",]))throw new bU(`Expected first argument to be of type boolean, string, number or null, but found ${bD(bR(b))} instead.`);if(!bH(c,["string","array"]))throw new bU(`Expected second argument to be of type array or string, but found ${bD(bR(c))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(a);return c.indexOf(b,d)}return c.indexOf(b)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a,]}return["index-of",this.needle.serialize(),this.haystack.serialize(),]}}class cO{constructor(a,b,c,d,f,g){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=f,this.otherwise=g}static parse(a,b){if(a.length<5)return b.error(`Expected at least 4 arguments, but found only ${a.length-1}.`);if(a.length%2!=1)return b.error("Expected an even number of arguments.");let c,d;b.expectedType&&"value"!==b.expectedType.kind&&(d=b.expectedType);const f={},g=[];for(let h=2;h<a.length-1;h+=2){let i=a[h];const j=a[h+1];Array.isArray(i)||(i=[i]);const k=b.concat(h);if(0===i.length)return k.error("Expected at least one branch label.");for(const l of i){if("number"!=typeof l&&"string"!=typeof l)return k.error("Branch labels must be numbers or strings.");if("number"==typeof l&&Math.abs(l)>Number.MAX_SAFE_INTEGER)return k.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof l&&Math.floor(l)!==l)return k.error("Numeric branch labels must be integer values.");if(c){if(k.checkSubtype(c,bR(l)))return null}else c=bR(l);if(void 0!==f[String(l)])return k.error("Branch labels must be unique.");f[String(l)]=g.length}const m=b.parse(j,h,d);if(!m)return null;d=d||m.type,g.push(m)}const n=b.parse(a[1],1,by);if(!n)return null;const o=b.parse(a[a.length-1],a.length-1,d);return o?"value"!==n.type.kind&&b.concat(1).checkSubtype(c,n.type)?null:new cO(c,d,n,f,g,o):null}evaluate(a){const b=this.input.evaluate(a);return(bR(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["match",this.input.serialize()],b=Object.keys(this.cases).sort(),c=[],d={};for(const f of b){const g=d[this.cases[f]];void 0===g?(d[this.cases[f]]=c.length,c.push([this.cases[f],[f]])):c[g][1].push(f)}const h=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,j]of c)a.push(1===j.length?h(j[0]):j.map(h)),a.push(this.outputs[i].serialize());return a.push(this.otherwise.serialize()),a}}class cP{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const d=[];for(let f=1;f<a.length-1;f+=2){const g=b.parse(a[f],f,bv);if(!g)return null;const h=b.parse(a[f+1],f+1,c);if(!h)return null;d.push([g,h]),c=c||h.type}const i=b.parse(a[a.length-1],a.length-1,c);return i?new cP(c,d,i):null}evaluate(a){for(const[b,c]of this.branches)if(b.evaluate(a))return c.evaluate(a);return this.otherwise.evaluate(a)}eachChild(a){for(const[b,c]of this.branches)a(b),a(c);a(this.otherwise)}outputDefined(){return this.branches.every(([a,b])=>b.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cQ{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,by),d=b.parse(a[2],2,bt);if(!c||!d)return null;if(!bG(c.type,[bC(by),bu,by]))return b.error(`Expected first argument to be of type array or string, but found ${bD(c.type)} instead`);if(4===a.length){const f=b.parse(a[3],3,bt);return f?new cQ(c.type,c,d,f):null}return new cQ(c.type,c,d)}evaluate(a){const b=this.input.evaluate(a),c=this.beginIndex.evaluate(a);if(!bH(b,["string","array"]))throw new bU(`Expected first argument to be of type array or string, but found ${bD(bR(b))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(a);return b.slice(c,d)}return b.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a,]}return["slice",this.input.serialize(),this.beginIndex.serialize(),]}}function cR(a,b){return"=="===a||"!="===a?"boolean"===b.kind||"string"===b.kind||"number"===b.kind||"null"===b.kind||"value"===b.kind:"string"===b.kind||"number"===b.kind||"value"===b.kind}function cS(a,b,c,d){return 0===d.compare(b,c)}function cT(a,b,c){const d="=="!==a&&"!="!==a;return class f{constructor(a,b,c){this.type=bv,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(a,b){if(3!==a.length&&4!==a.length)return b.error("Expected two or three arguments.");const c=a[0];let g=b.parse(a[1],1,by);if(!g)return null;if(!cR(c,g.type))return b.concat(1).error(`"${c}" comparisons are not supported for type '${bD(g.type)}'.`);let h=b.parse(a[2],2,by);if(!h)return null;if(!cR(c,h.type))return b.concat(2).error(`"${c}" comparisons are not supported for type '${bD(h.type)}'.`);if(g.type.kind!==h.type.kind&&"value"!==g.type.kind&&"value"!==h.type.kind)return b.error(`Cannot compare types '${bD(g.type)}' and '${bD(h.type)}'.`);d&&("value"===g.type.kind&&"value"!==h.type.kind?g=new bW(h.type,[g]):"value"!==g.type.kind&&"value"===h.type.kind&&(h=new bW(g.type,[h])));let i=null;if(4===a.length){if("string"!==g.type.kind&&"string"!==h.type.kind&&"value"!==g.type.kind&&"value"!==h.type.kind)return b.error("Cannot use collator to compare non-string types.");if(!(i=b.parse(a[3],3,bz)))return null}return new f(g,h,i)}evaluate(f){const g=this.lhs.evaluate(f),h=this.rhs.evaluate(f);if(d&&this.hasUntypedArgument){const i=bR(g),j=bR(h);if(i.kind!==j.kind||"string"!==i.kind&&"number"!==i.kind)throw new bU(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${i.kind}, ${j.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const k=bR(g),l=bR(h);if("string"!==k.kind||"string"!==l.kind)return b(f,g,h)}return this.collator?c(f,g,h,this.collator.evaluate(f)):b(f,g,h)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const cU=cT("==",function(a,b,c){return b===c},cS),cV=cT("!=",function(a,b,c){return b!==c},function(a,b,c,d){return!cS(0,b,c,d)}),cW=cT("<",function(a,b,c){return b<c},function(a,b,c,d){return 0>d.compare(b,c)}),cX=cT(">",function(a,b,c){return b>c},function(a,b,c,d){return d.compare(b,c)>0}),cY=cT("<=",function(a,b,c){return b<=c},function(a,b,c,d){return 0>=d.compare(b,c)}),cZ=cT(">=",function(a,b,c){return b>=c},function(a,b,c,d){return d.compare(b,c)>=0});class c${constructor(a,b,c,d,f){this.type=bu,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=f}static parse(a,b){if(3!==a.length)return b.error("Expected two arguments.");const c=b.parse(a[1],1,bt);if(!c)return null;const d=a[2];if("object"!=typeof d||Array.isArray(d))return b.error("NumberFormat options argument must be an object.");let f=null;if(d.locale&&!(f=b.parse(d.locale,1,bu)))return null;let g=null;if(d.currency&&!(g=b.parse(d.currency,1,bu)))return null;let h=null;if(d["min-fraction-digits"]&&!(h=b.parse(d["min-fraction-digits"],1,bt)))return null;let i=null;return!d["max-fraction-digits"]||(i=b.parse(d["max-fraction-digits"],1,bt))?new c$(c,f,g,h,i):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a,]}}class c_{constructor(a){this.type=bt,this.input=a}static parse(a,b){if(2!==a.length)return b.error(`Expected 1 argument, but found ${a.length-1} instead.`);const c=b.parse(a[1],1);return c?"array"!==c.type.kind&&"string"!==c.type.kind&&"value"!==c.type.kind?b.error(`Expected argument of type string or array, but found ${bD(c.type)} instead.`):new c_(c):null}evaluate(a){const b=this.input.evaluate(a);if("string"==typeof b||Array.isArray(b))return b.length;throw new bU(`Expected value to be of type string or array, but found ${bD(bR(b))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const c0={"==":cU,"!=":cV,">":cX,"<":cW,">=":cZ,"<=":cY,array:bW,at:cL,boolean:bW,case:cP,coalesce:cJ,collator:b2,format:bX,image:bY,in:cM,"index-of":cN,interpolate:cH,"interpolate-hcl":cH,"interpolate-lab":cH,length:c_,let:cK,literal:bT,match:cO,number:bW,"number-format":c$,object:bW,slice:cQ,step:cq,string:bW,"to-boolean":b$,"to-color":b$,"to-number":b$,"to-string":b$,var:cm,within:ci};function c1(a,[b,c,d,f]){b=b.evaluate(a),c=c.evaluate(a),d=d.evaluate(a);const g=f?f.evaluate(a):1,h=bP(b,c,d,g);if(h)throw new bU(h);return new bK(b/255*g,c/255*g,d/255*g,g)}function c2(a,b){const c=b[a];return void 0===c?null:c}function c3(a){return{type:a}}function c4(a){return{result:"success",value:a}}function c5(a){return{result:"error",value:a}}function c6(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function c7(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function c8(a){return!!a.expression&&a.expression.interpolated}function c9(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function da(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function db(a){return a}function dc(a,b){const c="color"===b.type,d=a.stops&&"object"==typeof a.stops[0][0],f=d||!(d|| void 0!==a.property),g=a.type||(c8(b)?"exponential":"interval");if(c&&((a=bn({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],bK.parse(a[1]),])),a.default=bK.parse(a.default?a.default:b.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!cG[a.colorSpace])throw Error(`Unknown color space: ${a.colorSpace}`);let h,i,j;if("exponential"===g)h=dg;else if("interval"===g)h=df;else if("categorical"===g){for(const k of(h=de,i=Object.create(null),a.stops))i[k[0]]=k[1];j=typeof a.stops[0][0]}else{if("identity"!==g)throw Error(`Unknown function type "${g}"`);h=dh}if(d){const l={},m=[];for(let n=0;n<a.stops.length;n++){const o=a.stops[n],p=o[0].zoom;void 0===l[p]&&(l[p]={zoom:p,type:a.type,property:a.property,default:a.default,stops:[]},m.push(p)),l[p].stops.push([o[0].value,o[1]])}const q=[];for(const r of m)q.push([l[r].zoom,dc(l[r],b)]);const s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:cH.interpolationFactor.bind(void 0,s),zoomStops:q.map(a=>a[0]),evaluate:({zoom:c},d)=>dg({stops:q,base:a.base},b,c).evaluate(c,d)}}if(f){const u="exponential"===g?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:u,interpolationFactor:cH.interpolationFactor.bind(void 0,u),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:c})=>h(a,b,c,i,j)}}return{kind:"source",evaluate(c,d){const f=d&&d.properties?d.properties[a.property]:void 0;return void 0===f?dd(a.default,b.default):h(a,b,f,i,j)}}}function dd(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function de(a,b,c,d,f){return dd(typeof c===f?d[c]:void 0,a.default,b.default)}function df(a,b,c){if("number"!==c9(c))return dd(a.default,b.default);const d=a.stops.length;if(1===d||c<=a.stops[0][0])return a.stops[0][1];if(c>=a.stops[d-1][0])return a.stops[d-1][1];const f=cp(a.stops.map(a=>a[0]),c);return a.stops[f][1]}function dg(a,b,c){const d=void 0!==a.base?a.base:1;if("number"!==c9(c))return dd(a.default,b.default);const f=a.stops.length;if(1===f||c<=a.stops[0][0])return a.stops[0][1];if(c>=a.stops[f-1][0])return a.stops[f-1][1];const g=cp(a.stops.map(a=>a[0]),c),h=function(a,b,c,d){const f=d-c,g=a-c;return 0===f?0:1===b?g/f:(Math.pow(b,g)-1)/(Math.pow(b,f)-1)}(c,d,a.stops[g][0],a.stops[g+1][0]),i=a.stops[g][1],j=a.stops[g+1][1];let k=cs[b.type]||db;if(a.colorSpace&&"rgb"!==a.colorSpace){const l=cG[a.colorSpace];k=(a,b)=>l.reverse(l.interpolate(l.forward(a),l.forward(b),h))}return"function"==typeof i.evaluate?{evaluate(...a){const b=i.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return k(b,c,h)}}:k(i,j,h)}function dh(a,b,c){return"color"===b.type?c=bK.parse(c):"formatted"===b.type?c=bN.fromString(c.toString()):"resolvedImage"===b.type?c=bO.fromString(c.toString()):c9(c)===b.type||"enum"===b.type&&b.values[c]||(c=void 0),dd(c,a.default,b.default)}b1.register(c0,{error:[{kind:"error"},[bu],(a,[b])=>{throw new bU(b.evaluate(a))},],typeof:[bu,[by],(a,[b])=>bD(bR(b.evaluate(a))),],"to-rgba":[bC(bt,4),[bw],(a,[b])=>b.evaluate(a).toArray(),],rgb:[bw,[bt,bt,bt],c1],rgba:[bw,[bt,bt,bt,bt],c1],has:{type:bv,overloads:[[[bu],(a,[b])=>{var c,d;return c=b.evaluate(a),d=a.properties(),c in d},],[[bu,bx],(a,[b,c])=>b.evaluate(a) in c.evaluate(a),],]},get:{type:by,overloads:[[[bu],(a,[b])=>c2(b.evaluate(a),a.properties()),],[[bu,bx],(a,[b,c])=>c2(b.evaluate(a),c.evaluate(a)),],]},"feature-state":[by,[bu],(a,[b])=>c2(b.evaluate(a),a.featureState||{}),],properties:[bx,[],a=>a.properties()],"geometry-type":[bu,[],a=>a.geometryType()],id:[by,[],a=>a.id()],zoom:[bt,[],a=>a.globals.zoom],pitch:[bt,[],a=>a.globals.pitch||0],"distance-from-center":[bt,[],a=>a.distanceFromCenter(),],"heatmap-density":[bt,[],a=>a.globals.heatmapDensity||0,],"line-progress":[bt,[],a=>a.globals.lineProgress||0,],"sky-radial-progress":[bt,[],a=>a.globals.skyRadialProgress||0,],accumulated:[by,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated,],"+":[bt,c3(bt),(a,b)=>{let c=0;for(const d of b)c+=d.evaluate(a);return c},],"*":[bt,c3(bt),(a,b)=>{let c=1;for(const d of b)c*=d.evaluate(a);return c},],"-":{type:bt,overloads:[[[bt,bt],(a,[b,c])=>b.evaluate(a)-c.evaluate(a),],[[bt],(a,[b])=>-b.evaluate(a)],]},"/":[bt,[bt,bt],(a,[b,c])=>b.evaluate(a)/c.evaluate(a),],"%":[bt,[bt,bt],(a,[b,c])=>b.evaluate(a)%c.evaluate(a),],ln2:[bt,[],()=>Math.LN2],pi:[bt,[],()=>Math.PI],e:[bt,[],()=>Math.E],"^":[bt,[bt,bt],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a)),],sqrt:[bt,[bt],(a,[b])=>Math.sqrt(b.evaluate(a)),],log10:[bt,[bt],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10,],ln:[bt,[bt],(a,[b])=>Math.log(b.evaluate(a))],log2:[bt,[bt],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2,],sin:[bt,[bt],(a,[b])=>Math.sin(b.evaluate(a)),],cos:[bt,[bt],(a,[b])=>Math.cos(b.evaluate(a)),],tan:[bt,[bt],(a,[b])=>Math.tan(b.evaluate(a)),],asin:[bt,[bt],(a,[b])=>Math.asin(b.evaluate(a)),],acos:[bt,[bt],(a,[b])=>Math.acos(b.evaluate(a)),],atan:[bt,[bt],(a,[b])=>Math.atan(b.evaluate(a)),],min:[bt,c3(bt),(a,b)=>Math.min(...b.map(b=>b.evaluate(a))),],max:[bt,c3(bt),(a,b)=>Math.max(...b.map(b=>b.evaluate(a))),],abs:[bt,[bt],(a,[b])=>Math.abs(b.evaluate(a)),],round:[bt,[bt],(a,[b])=>{const c=b.evaluate(a);return c<0?-Math.round(-c):Math.round(c)},],floor:[bt,[bt],(a,[b])=>Math.floor(b.evaluate(a)),],ceil:[bt,[bt],(a,[b])=>Math.ceil(b.evaluate(a)),],"filter-==":[bv,[bu,by],(a,[b,c])=>a.properties()[b.value]===c.value,],"filter-id-==":[bv,[by],(a,[b])=>a.id()===b.value,],"filter-type-==":[bv,[bu],(a,[b])=>a.geometryType()===b.value,],"filter-<":[bv,[bu,by],(a,[b,c])=>{const d=a.properties()[b.value],f=c.value;return typeof d==typeof f&&d<f},],"filter-id-<":[bv,[by],(a,[b])=>{const c=a.id(),d=b.value;return typeof c==typeof d&&c<d},],"filter->":[bv,[bu,by],(a,[b,c])=>{const d=a.properties()[b.value],f=c.value;return typeof d==typeof f&&d>f},],"filter-id->":[bv,[by],(a,[b])=>{const c=a.id(),d=b.value;return typeof c==typeof d&&c>d},],"filter-<=":[bv,[bu,by],(a,[b,c])=>{const d=a.properties()[b.value],f=c.value;return typeof d==typeof f&&d<=f},],"filter-id-<=":[bv,[by],(a,[b])=>{const c=a.id(),d=b.value;return typeof c==typeof d&&c<=d},],"filter->=":[bv,[bu,by],(a,[b,c])=>{const d=a.properties()[b.value],f=c.value;return typeof d==typeof f&&d>=f},],"filter-id->=":[bv,[by],(a,[b])=>{const c=a.id(),d=b.value;return typeof c==typeof d&&c>=d},],"filter-has":[bv,[by],(a,[b])=>b.value in a.properties(),],"filter-has-id":[bv,[],a=>null!==a.id()&& void 0!==a.id(),],"filter-type-in":[bv,[bC(bu)],(a,[b])=>b.value.indexOf(a.geometryType())>=0,],"filter-id-in":[bv,[bC(by)],(a,[b])=>b.value.indexOf(a.id())>=0,],"filter-in-small":[bv,[bu,bC(by)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0,],"filter-in-large":[bv,[bu,bC(by)],(a,[b,c])=>(function(a,b,c,d){for(;c<=d;){const f=c+d>>1;if(b[f]===a)return!0;b[f]>a?d=f-1:c=f+1}return!1})(a.properties()[b.value],c.value,0,c.value.length-1),],all:{type:bv,overloads:[[[bv,bv],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a),],[c3(bv),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0},],]},any:{type:bv,overloads:[[[bv,bv],(a,[b,c])=>b.evaluate(a)||c.evaluate(a),],[c3(bv),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1},],]},"!":[bv,[bv],(a,[b])=>!b.evaluate(a)],"is-supported-script":[bv,[bu],(a,[b])=>{const c=a.globals&&a.globals.isSupportedScript;return!c||c(b.evaluate(a))},],upcase:[bu,[bu],(a,[b])=>b.evaluate(a).toUpperCase(),],downcase:[bu,[bu],(a,[b])=>b.evaluate(a).toLowerCase(),],concat:[bu,c3(by),(a,b)=>b.map(b=>bS(b.evaluate(a))).join(""),],"resolved-locale":[bu,[bz],(a,[b])=>b.evaluate(a).resolvedLocale(),]});class di{constructor(a,b){var c;this.expression=a,this._warningHistory={},this._evaluator=new b0,this._defaultValue=b?"color"===(c=b).type&&da(c.default)?new bK(0,0,0,0):"color"===c.type?bK.parse(c.default)||null:void 0===c.default?null:c.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,f,g,h,i){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=f||null,this._evaluator.formattedSection=g,this._evaluator.featureTileCoord=h||null,this._evaluator.featureDistanceData=i||null,this.expression.evaluate(this._evaluator)}evaluate(a,b,c,d,f,g,h,i){this._evaluator.globals=a,this._evaluator.feature=b||null,this._evaluator.featureState=c||null,this._evaluator.canonical=d,this._evaluator.availableImages=f||null,this._evaluator.formattedSection=g||null,this._evaluator.featureTileCoord=h||null,this._evaluator.featureDistanceData=i||null;try{const j=this.expression.evaluate(this._evaluator);if(null==j||"number"==typeof j&&j!=j)return this._defaultValue;if(this._enumValues&&!(j in this._enumValues))throw new bU(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(j)} instead.`);return j}catch(k){return this._warningHistory[k.message]||(this._warningHistory[k.message]=!0,"undefined"!=typeof console&&console.warn(k.message)),this._defaultValue}}}function dj(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in c0}function dk(a,b){const c=new cn(c0,[],b?function(a){const b={color:bw,string:bu,number:bt,enum:bu,boolean:bv,formatted:bA,resolvedImage:bB};return"array"===a.type?bC(b[a.value]||by,a.length):b[a.type]}(b):void 0),d=c.parse(a,void 0,void 0,void 0,b&&"string"===b.type?{typeAnnotation:"coerce"}:void 0);return d?c4(new di(d,b)):c5(c.errors)}class dl{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!ck(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,f,g){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,f,g)}evaluate(a,b,c,d,f,g){return this._styleExpression.evaluate(a,b,c,d,f,g)}}class dm{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!ck(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,f,g){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,f,g)}evaluate(a,b,c,d,f,g){return this._styleExpression.evaluate(a,b,c,d,f,g)}interpolationFactor(a,b,c){return this.interpolationType?cH.interpolationFactor(this.interpolationType,a,b,c):0}}function dn(a,b){if("error"===(a=dk(a,b)).result)return a;const c=a.value.expression,d=cj(c);if(!d&&!c6(b))return c5([new bq("","data expressions not supported"),]);const f=cl(c,["zoom","pitch","distance-from-center",]);if(!f&&!c7(b))return c5([new bq("","zoom expressions not supported"),]);const g=dq(c);return g||f?g instanceof bq?c5([g]):g instanceof cH&&!c8(b)?c5([new bq("",'"interpolate" expressions cannot be used with this property'),]):c4(g?new dm(d?"camera":"composite",a.value,g.labels,g instanceof cH?g.interpolation:void 0):new dl(d?"constant":"source",a.value)):c5([new bq("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'),])}class dp{constructor(a,b){this._parameters=a,this._specification=b,bn(this,dc(this._parameters,this._specification))}static deserialize(a){return new dp(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function dq(a){let b=null;if(a instanceof cK)b=dq(a.result);else if(a instanceof cJ){for(const c of a.args)if(b=dq(c))break}else(a instanceof cq||a instanceof cH)&&a.input instanceof b1&&"zoom"===a.input.name&&(b=a);return b instanceof bq||a.eachChild(a=>{const c=dq(a);c instanceof bq?b=c:!b&&c?b=new bq("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):b&&c&&b!==c&&(b=new bq("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),b}function dr(a){const b=a.key,c=a.value,d=a.valueSpec||{},f=a.objectElementValidators||{},g=a.style,h=a.styleSpec;let i=[];const j=c9(c);if("object"!==j)return[new bl(b,c,`object expected, ${j} found`),];for(const k in c){const l=k.split(".")[0],m=d[l]||d["*"];let n;if(f[l])n=f[l];else if(d[l])n=dY;else if(f["*"])n=f["*"];else{if(!d["*"]){i.push(new bl(b,c[k],`unknown property "${k}"`));continue}n=dY}i=i.concat(n({key:(b?`${b}.`:b)+k,value:c[k],valueSpec:m,style:g,styleSpec:h,object:c,objectKey:k},c))}for(const o in d)f[o]||d[o].required&& void 0===d[o].default&& void 0===c[o]&&i.push(new bl(b,c,`missing required property "${o}"`));return i}function ds(a){const b=a.value,c=a.valueSpec,d=a.style,f=a.styleSpec,g=a.key,h=a.arrayElementValidator||dY;if("array"!==c9(b))return[new bl(g,b,`array expected, ${c9(b)} found`),];if(c.length&&b.length!==c.length)return[new bl(g,b,`array length ${c.length} expected, length ${b.length} found`),];if(c["min-length"]&&b.length<c["min-length"])return[new bl(g,b,`array length at least ${c["min-length"]} expected, length ${b.length} found`),];let i={type:c.value,values:c.values,minimum:c.minimum,maximum:c.maximum};f.$version<7&&(i.function=c.function),"object"===c9(c.value)&&(i=c.value);let j=[];for(let k=0;k<b.length;k++)j=j.concat(h({array:b,arrayIndex:k,value:b[k],valueSpec:i,style:d,styleSpec:f,key:`${g}[${k}]`}));return j}function dt(a){const b=a.key,c=a.value,d=a.valueSpec;let f=c9(c);if("number"===f&&c!=c&&(f="NaN"),"number"!==f)return[new bl(b,c,`number expected, ${f} found`),];if("minimum"in d){let g=d.minimum;if("array"===c9(d.minimum)&&(g=d.minimum[a.arrayIndex]),c<g)return[new bl(b,c,`${c} is less than the minimum value ${g}`),]}if("maximum"in d){let h=d.maximum;if("array"===c9(d.maximum)&&(h=d.maximum[a.arrayIndex]),c>h)return[new bl(b,c,`${c} is greater than the maximum value ${h}`),]}return[]}function du(a){const b=a.valueSpec,c=bo(a.value.type);let d,f,g,h={};const i="categorical"!==c&& void 0===a.value.property,j="array"===c9(a.value.stops)&&"array"===c9(a.value.stops[0])&&"object"===c9(a.value.stops[0][0]),k=dr({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(a){if("identity"===c)return[new bl(a.key,a.value,'identity function may not have a "stops" property'),];let b=[];const d=a.value;return b=b.concat(ds({key:a.key,value:d,valueSpec:a.valueSpec,style:a.style,styleSpec:a.styleSpec,arrayElementValidator:l})),"array"===c9(d)&&0===d.length&&b.push(new bl(a.key,d,"array must have at least one stop")),b},default:function(a){return dY({key:a.key,value:a.value,valueSpec:b,style:a.style,styleSpec:a.styleSpec})}}});return"identity"===c&&i&&k.push(new bl(a.key,a.value,'missing required property "property"')),"identity"===c||a.value.stops||k.push(new bl(a.key,a.value,'missing required property "stops"')),"exponential"===c&&a.valueSpec.expression&&!c8(a.valueSpec)&&k.push(new bl(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(i||c6(a.valueSpec)?i&&!c7(a.valueSpec)&&k.push(new bl(a.key,a.value,"zoom functions not supported")):k.push(new bl(a.key,a.value,"property functions not supported"))),("categorical"===c||j)&& void 0===a.value.property&&k.push(new bl(a.key,a.value,'"property" property is required')),k;function l(a){let c=[];const d=a.value,i=a.key;if("array"!==c9(d))return[new bl(i,d,`array expected, ${c9(d)} found`),];if(2!==d.length)return[new bl(i,d,`array length 2 expected, length ${d.length} found`),];if(j){if("object"!==c9(d[0]))return[new bl(i,d,`object expected, ${c9(d[0])} found`),];if(void 0===d[0].zoom)return[new bl(i,d,"object stop key must have zoom"),];if(void 0===d[0].value)return[new bl(i,d,"object stop key must have value"),];if(g&&g>bo(d[0].zoom))return[new bl(i,d[0].zoom,"stop zoom values must appear in ascending order"),];bo(d[0].zoom)!==g&&(g=bo(d[0].zoom),f=void 0,h={}),c=c.concat(dr({key:`${i}[0]`,value:d[0],valueSpec:{zoom:{}},style:a.style,styleSpec:a.styleSpec,objectElementValidators:{zoom:dt,value:m}}))}else c=c.concat(m({key:`${i}[0]`,value:d[0],valueSpec:{},style:a.style,styleSpec:a.styleSpec},d));return dj(bp(d[1]))?c.concat([new bl(`${i}[1]`,d[1],"expressions are not allowed in function stops."),]):c.concat(dY({key:`${i}[1]`,value:d[1],valueSpec:b,style:a.style,styleSpec:a.styleSpec}))}function m(a,g){const i=c9(a.value),j=bo(a.value),k=null!==a.value?a.value:g;if(d){if(i!==d)return[new bl(a.key,k,`${i} stop domain type must match previous stop domain type ${d}`),]}else d=i;if("number"!==i&&"string"!==i&&"boolean"!==i)return[new bl(a.key,k,"stop domain value must be a number, string, or boolean"),];if("number"!==i&&"categorical"!==c){let l=`number expected, ${i} found`;return c6(b)&& void 0===c&&(l+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new bl(a.key,k,l)]}return"categorical"!==c||"number"!==i||isFinite(j)&&Math.floor(j)===j?"categorical"!==c&&"number"===i&& void 0!==f&&j<f?[new bl(a.key,k,"stop domain values must appear in ascending order"),]:(f=j,"categorical"===c&&j in h?[new bl(a.key,k,"stop domain values must be unique"),]:(h[j]=!0,[])):[new bl(a.key,k,`integer expected, found ${j}`),]}}function dv(a){const b=("property"===a.expressionContext?dn:dk)(bp(a.value),a.valueSpec);if("error"===b.result)return b.value.map(b=>new bl(`${a.key}${b.key}`,a.value,b.message));const c=b.value.expression||b.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!c.outputDefined())return[new bl(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`),];if("property"===a.expressionContext&&"layout"===a.propertyType&&!ck(c))return[new bl(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.'),];if("filter"===a.expressionContext)return dw(c,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!cl(c,["zoom","feature-state"]))return[new bl(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.'),];if("cluster-initial"===a.expressionContext&&!cj(c))return[new bl(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties."),]}return[]}function dw(a,b){const c=new Set(["zoom","feature-state","pitch","distance-from-center",]);for(const d of b.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const f=[];return a instanceof b1&&c.has(a.name)?[new bl(b.key,b.value,`["${a.name}"] expression is not supported in a filter for a ${b.object.type} layer with id: ${b.object.id}`),]:(a.eachChild(a=>{f.push(...dw(a,b))}),f)}function dx(a){const b=a.key,c=a.value,d=a.valueSpec,f=[];return Array.isArray(d.values)?-1===d.values.indexOf(bo(c))&&f.push(new bl(b,c,`expected one of [${d.values.join(", ")}], ${JSON.stringify(c)} found`)):-1===Object.keys(d.values).indexOf(bo(c))&&f.push(new bl(b,c,`expected one of [${Object.keys(d.values).join(", ")}], ${JSON.stringify(c)} found`)),f}function dy(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!dy(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function dz(a,b="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};dy(a)||(a=dG(a));const c=a;let d=!0;try{d=function(a){if(!dC(a))return a;let b=bp(a);return dB(b),b=dA(b)}(c)}catch(f){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
and paste the contents of this message in the report.
Thank you!
Filter Expression:
${JSON.stringify(c,null,2)}
`)}const g=bk[`filter_${b}`],h=dk(d,g);let i=null;if("error"===h.result)throw Error(h.value.map(a=>`${a.key}: ${a.message}`).join(", "));i=(a,b,c)=>h.value.evaluate(a,b,{},c);let j=null,k=null;if(d!==c){const l=dk(c,g);if("error"===l.result)throw Error(l.value.map(a=>`${a.key}: ${a.message}`).join(", "));j=(a,b,c,d,f)=>l.value.evaluate(a,b,{},c,void 0,void 0,d,f),k=!cj(l.value.expression)}return{filter:i,dynamicFilter:j||void 0,needGeometry:dF(d),needFeature:!!k}}function dA(a){if(!Array.isArray(a))return a;const b=function(a){if(dD.has(a[0])){for(let b=1;b<a.length;b++)if(dC(a[b]))return!0}return a}(a);return!0===b?b:b.map(a=>dA(a))}function dB(a){let b=!1;const c=[];if("case"===a[0]){for(let d=1;d<a.length-1;d+=2)b=b||dC(a[d]),c.push(a[d+1]);c.push(a[a.length-1])}else if("match"===a[0]){b=b||dC(a[1]);for(let f=2;f<a.length-1;f+=2)c.push(a[f+1]);c.push(a[a.length-1])}else if("step"===a[0]){b=b||dC(a[1]);for(let g=1;g<a.length-1;g+=2)c.push(a[g+1])}b&&(a.length=0,a.push("any",...c));for(let h=1;h<a.length;h++)dB(a[h])}function dC(a){var b;if(!Array.isArray(a))return!1;if("pitch"===(b=a[0])||"distance-from-center"===b)return!0;for(let c=1;c<a.length;c++)if(dC(a[c]))return!0;return!1}const dD=new Set(["in","==","!=",">",">=","<","<=","to-boolean",]);function dE(a,b){return a<b?-1:a>b?1:0}function dF(a){if(!Array.isArray(a))return!1;if("within"===a[0])return!0;for(let b=1;b<a.length;b++)if(dF(a[b]))return!0;return!1}function dG(a){if(!a)return!0;const b=a[0];return a.length<=1?"any"!==b:"=="===b?dH(a[1],a[2],"=="):"!="===b?dK(dH(a[1],a[2],"==")):"<"===b||">"===b||"<="===b||">="===b?dH(a[1],a[2],b):"any"===b?["any"].concat(a.slice(1).map(dG)):"all"===b?["all"].concat(a.slice(1).map(dG)):"none"===b?["all"].concat(a.slice(1).map(dG).map(dK)):"in"===b?dI(a[1],a.slice(2)):"!in"===b?dK(dI(a[1],a.slice(2))):"has"===b?dJ(a[1]):"!has"===b?dK(dJ(a[1])):"within"!==b||a}function dH(a,b,c){switch(a){case"$type":return[`filter-type-${c}`,b];case"$id":return[`filter-id-${c}`,b];default:return[`filter-${c}`,a,b]}}function dI(a,b){if(0===b.length)return!1;switch(a){case"$type":return["filter-type-in",["literal",b]];case"$id":return["filter-id-in",["literal",b]];default:return b.length>200&&!b.some(a=>typeof a!=typeof b[0])?["filter-in-large",a,["literal",b.sort(dE)],]:["filter-in-small",a,["literal",b],]}}function dJ(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function dK(a){return["!",a]}function dL(a){if(dy(bp(a.value))){const b=bp(a.layerType);return dv(bn({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${b||"fill"}`]}))}return dM(a)}function dM(a){const b=a.value,c=a.key;if("array"!==c9(b))return[new bl(c,b,`array expected, ${c9(b)} found`),];const d=a.styleSpec;let f,g=[];if(b.length<1)return[new bl(c,b,"filter array must have at least 1 element"),];switch(g=g.concat(dx({key:`${c}[0]`,value:b[0],valueSpec:d.filter_operator,style:a.style,styleSpec:a.styleSpec})),bo(b[0])){case"<":case"<=":case">":case">=":b.length>=2&&"$type"===bo(b[1])&&g.push(new bl(c,b,`"$type" cannot be use with operator "${b[0]}"`));case"==":case"!=":3!==b.length&&g.push(new bl(c,b,`filter array for operator "${b[0]}" must have 3 elements`));case"in":case"!in":b.length>=2&&"string"!==(f=c9(b[1]))&&g.push(new bl(`${c}[1]`,b[1],`string expected, ${f} found`));for(let h=2;h<b.length;h++)f=c9(b[h]),"$type"===bo(b[1])?g=g.concat(dx({key:`${c}[${h}]`,value:b[h],valueSpec:d.geometry_type,style:a.style,styleSpec:a.styleSpec})):"string"!==f&&"number"!==f&&"boolean"!==f&&g.push(new bl(`${c}[${h}]`,b[h],`string, number, or boolean expected, ${f} found`));break;case"any":case"all":case"none":for(let i=1;i<b.length;i++)g=g.concat(dM({key:`${c}[${i}]`,value:b[i],style:a.style,styleSpec:a.styleSpec}));break;case"has":case"!has":f=c9(b[1]),2!==b.length?g.push(new bl(c,b,`filter array for "${b[0]}" operator must have 2 elements`)):"string"!==f&&g.push(new bl(`${c}[1]`,b[1],`string expected, ${f} found`));break;case"within":f=c9(b[1]),2!==b.length?g.push(new bl(c,b,`filter array for "${b[0]}" operator must have 2 elements`)):"object"!==f&&g.push(new bl(`${c}[1]`,b[1],`object expected, ${f} found`))}return g}function dN(a,b){const c=a.key,d=a.style,f=a.styleSpec,g=a.value,h=a.objectKey,i=f[`${b}_${a.layerType}`];if(!i)return[];const j=h.match(/^(.*)-transition$/);if("paint"===b&&j&&i[j[1]]&&i[j[1]].transition)return dY({key:c,value:g,valueSpec:f.transition,style:d,styleSpec:f});const k=a.valueSpec||i[h];if(!k)return[new bl(c,g,`unknown property "${h}"`),];let l;if("string"===c9(g)&&c6(k)&&!k.tokens&&(l=/^{([^}]+)}$/.exec(g)))return[new bl(c,g,`"${h}" does not support interpolation syntax
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(l[1])} }\`.`),];const m=[];return"symbol"===a.layerType&&("text-field"===h&&d&&!d.glyphs&&m.push(new bl(c,g,'use of "text-field" requires a style "glyphs" property')),"text-font"===h&&da(bp(g))&&"identity"===bo(g.type)&&m.push(new bl(c,g,'"text-font" does not support identity functions'))),m.concat(dY({key:a.key,value:g,valueSpec:k,style:d,styleSpec:f,expressionContext:"property",propertyType:b,propertyKey:h}))}function dO(a){return dN(a,"paint")}function dP(a){return dN(a,"layout")}function dQ(a){let b=[];const c=a.value,d=a.key,f=a.style,g=a.styleSpec;c.type||c.ref||b.push(new bl(d,c,'either "type" or "ref" is required'));let h=bo(c.type);const i=bo(c.ref);if(c.id){const j=bo(c.id);for(let k=0;k<a.arrayIndex;k++){const l=f.layers[k];bo(l.id)===j&&b.push(new bl(d,c.id,`duplicate layer id "${c.id}", previously used at line ${l.id.__line__}`))}}if("ref"in c){let m;["type","source","source-layer","filter","layout",].forEach(a=>{a in c&&b.push(new bl(d,c[a],`"${a}" is prohibited for ref layers`))}),f.layers.forEach(a=>{bo(a.id)===i&&(m=a)}),m?m.ref?b.push(new bl(d,c.ref,"ref cannot reference another ref layer")):h=bo(m.type):b.push(new bl(d,c.ref,`ref layer "${i}" not found`))}else if("background"!==h&&"sky"!==h){if(c.source){const n=f.sources&&f.sources[c.source],o=n&&bo(n.type);n?"vector"===o&&"raster"===h?b.push(new bl(d,c.source,`layer "${c.id}" requires a raster source`)):"raster"===o&&"raster"!==h?b.push(new bl(d,c.source,`layer "${c.id}" requires a vector source`)):"vector"!==o||c["source-layer"]?"raster-dem"===o&&"hillshade"!==h?b.push(new bl(d,c.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===h&&c.paint&&c.paint["line-gradient"]&&("geojson"!==o||!n.lineMetrics)&&b.push(new bl(d,c,`layer "${c.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):b.push(new bl(d,c,`layer "${c.id}" must specify a "source-layer"`)):b.push(new bl(d,c.source,`source "${c.source}" not found`))}else b.push(new bl(d,c,'missing required property "source"'))}return b=b.concat(dr({key:d,value:c,valueSpec:g.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>dY({key:`${d}.type`,value:c.type,valueSpec:g.layer.type,style:a.style,styleSpec:a.styleSpec,object:c,objectKey:"type"}),filter:a=>dL(bn({layerType:h},a)),layout:a=>dr({layer:c,key:a.key,value:a.value,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":a=>dP(bn({layerType:h},a))}}),paint:a=>dr({layer:c,key:a.key,value:a.value,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":a=>dO(bn({layerType:h},a))}})}}))}function dR(a){const b=a.value,c=a.key,d=c9(b);return"string"!==d?[new bl(c,b,`string expected, ${d} found`)]:[]}const dS={promoteId:function({key:a,value:b}){if("string"===c9(b))return dR({key:a,value:b});{const c=[];for(const d in b)c.push(...dR({key:`${a}.${d}`,value:b[d]}));return c}}};function dT(a){const b=a.value,c=a.key,d=a.styleSpec,f=a.style;if(!b.type)return[new bl(c,b,'"type" is required')];const g=bo(b.type);let h;switch(g){case"vector":case"raster":case"raster-dem":return dr({key:c,value:b,valueSpec:d[`source_${g.replace("-","_")}`],style:a.style,styleSpec:d,objectElementValidators:dS});case"geojson":if(h=dr({key:c,value:b,valueSpec:d.source_geojson,style:f,styleSpec:d,objectElementValidators:dS}),b.cluster)for(const i in b.clusterProperties){const[j,k]=b.clusterProperties[i],l="string"==typeof j?[j,["accumulated"],["get",i],]:j;h.push(...dv({key:`${c}.${i}.map`,value:k,expressionContext:"cluster-map"})),h.push(...dv({key:`${c}.${i}.reduce`,value:l,expressionContext:"cluster-reduce"}))}return h;case"video":return dr({key:c,value:b,valueSpec:d.source_video,style:f,styleSpec:d});case"image":return dr({key:c,value:b,valueSpec:d.source_image,style:f,styleSpec:d});case"canvas":return[new bl(c,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas"),];default:return dx({key:`${c}.type`,value:b.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image",]},style:f,styleSpec:d})}}function dU(a){const b=a.value,c=a.styleSpec,d=c.light,f=a.style;let g=[];const h=c9(b);if(void 0===b)return g;if("object"!==h)return g.concat([new bl("light",b,`object expected, ${h} found`),]);for(const i in b){const j=i.match(/^(.*)-transition$/);g=g.concat(j&&d[j[1]]&&d[j[1]].transition?dY({key:i,value:b[i],valueSpec:c.transition,style:f,styleSpec:c}):d[i]?dY({key:i,value:b[i],valueSpec:d[i],style:f,styleSpec:c}):[new bl(i,b[i],`unknown property "${i}"`),])}return g}function dV(a){const b=a.value,c=a.key,d=a.style,f=a.styleSpec,g=f.terrain;let h=[];const i=c9(b);if(void 0===b)return h;if("object"!==i)return h.concat([new bl("terrain",b,`object expected, ${i} found`),]);for(const j in b){const k=j.match(/^(.*)-transition$/);h=h.concat(k&&g[k[1]]&&g[k[1]].transition?dY({key:j,value:b[j],valueSpec:f.transition,style:d,styleSpec:f}):g[j]?dY({key:j,value:b[j],valueSpec:g[j],style:d,styleSpec:f}):[new bl(j,b[j],`unknown property "${j}"`),])}if(b.source){const l=d.sources&&d.sources[b.source],m=l&&bo(l.type);l?"raster-dem"!==m&&h.push(new bl(c,b.source,`terrain cannot be used with a source of type ${m}, it only be used with a "raster-dem" source type`)):h.push(new bl(c,b.source,`source "${b.source}" not found`))}else h.push(new bl(c,b,'terrain is missing required property "source"'));return h}function dW(a){const b=a.value,c=a.style,d=a.styleSpec,f=d.fog;let g=[];const h=c9(b);if(void 0===b)return g;if("object"!==h)return g.concat([new bl("fog",b,`object expected, ${h} found`),]);for(const i in b){const j=i.match(/^(.*)-transition$/);g=g.concat(j&&f[j[1]]&&f[j[1]].transition?dY({key:i,value:b[i],valueSpec:d.transition,style:c,styleSpec:d}):f[i]?dY({key:i,value:b[i],valueSpec:f[i],style:c,styleSpec:d}):[new bl(i,b[i],`unknown property "${i}"`),])}return g}const dX={"*":()=>[],array:ds,boolean:function(a){const b=a.value,c=a.key,d=c9(b);return"boolean"!==d?[new bl(c,b,`boolean expected, ${d} found`),]:[]},number:dt,color:function(a){const b=a.key,c=a.value,d=c9(c);return"string"!==d?[new bl(b,c,`color expected, ${d} found`),]:null===bJ.parseCSSColor(c)?[new bl(b,c,`color expected, "${c}" found`),]:[]},constants:bm,enum:dx,filter:dL,function:du,layer:dQ,object:dr,source:dT,light:dU,terrain:dV,fog:dW,string:dR,formatted:function(a){return 0===dR(a).length?[]:dv(a)},resolvedImage:function(a){return 0===dR(a).length?[]:dv(a)},projection:function(a){const b=a.value,c=a.styleSpec,d=c.projection,f=a.style;let g=[];const h=c9(b);if("object"===h)for(const i in b)g=g.concat(dY({key:i,value:b[i],valueSpec:d[i],style:f,styleSpec:c}));else"string"!==h&&(g=g.concat([new bl("projection",b,`object or string expected, ${h} found`),]));return g}};function dY(a){const b=a.value,c=a.valueSpec,d=a.styleSpec;return c.expression&&da(bo(b))?du(a):c.expression&&dj(bp(b))?dv(a):c.type&&dX[c.type]?dX[c.type](a):dr(bn({},a,{valueSpec:c.type?d[c.type]:c}))}function dZ(a){const b=a.value,c=a.key,d=dR(a);return d.length||(-1===b.indexOf("{fontstack}")&&d.push(new bl(c,b,'"glyphs" url must include a "{fontstack}" token')),-1===b.indexOf("{range}")&&d.push(new bl(c,b,'"glyphs" url must include a "{range}" token'))),d}function d$(a,b=bk){let c=[];return c=c.concat(dY({key:"",value:a,valueSpec:b.$root,styleSpec:b,style:a,objectElementValidators:{glyphs:dZ,"*":()=>[]}})),a.constants&&(c=c.concat(bm({key:"constants",value:a.constants,style:a,styleSpec:b}))),d_(c)}function d_(a){return[].concat(a).sort((a,b)=>a.line-b.line)}function d0(a){return function(...b){return d_(a.apply(this,b))}}d$.source=d0(dT),d$.light=d0(dU),d$.terrain=d0(dV),d$.fog=d0(dW),d$.layer=d0(dQ),d$.filter=d0(dL),d$.paintProperty=d0(dO),d$.layoutProperty=d0(dP);const d1=d$,d2=d1.light,d3=d1.fog,d4=d1.paintProperty,d5=d1.layoutProperty;function d6(a,b){let c=!1;if(b&&b.length)for(const d of b)a.fire(new bi(Error(d.message))),c=!0;return c}var d7=d8;function d8(a,b,c){var d=this.cells=[];if(a instanceof ArrayBuffer){this.arrayBuffer=a;var f=new Int32Array(this.arrayBuffer);a=f[0],this.d=(b=f[1])+2*(c=f[2]);for(var g=0;g<this.d*this.d;g++){var h=f[3+g],i=f[3+g+1];d.push(h===i?null:f.subarray(h,i))}var j=f[3+d.length+1];this.keys=f.subarray(f[3+d.length],j),this.bboxes=f.subarray(j),this.insert=this._insertReadonly}else{this.d=b+2*c;for(var k=0;k<this.d*this.d;k++)d.push([]);this.keys=[],this.bboxes=[]}this.n=b,this.extent=a,this.padding=c,this.scale=b/a,this.uid=0;var l=c/b*a;this.min=-l,this.max=a+l}d8.prototype.insert=function(a,b,c,d,f){this._forEachCell(b,c,d,f,this._insertCell,this.uid++),this.keys.push(a),this.bboxes.push(b),this.bboxes.push(c),this.bboxes.push(d),this.bboxes.push(f)},d8.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},d8.prototype._insertCell=function(a,b,c,d,f,g){this.cells[f].push(g)},d8.prototype.query=function(a,b,c,d,f){var g=this.min,h=this.max;if(a<=g&&b<=g&&h<=c&&h<=d&&!f)return Array.prototype.slice.call(this.keys);var i=[];return this._forEachCell(a,b,c,d,this._queryCell,i,{},f),i},d8.prototype._queryCell=function(a,b,c,d,f,g,h,i){var j=this.cells[f];if(null!==j)for(var k=this.keys,l=this.bboxes,m=0;m<j.length;m++){var n=j[m];if(void 0===h[n]){var o=4*n;(i?i(l[o+0],l[o+1],l[o+2],l[o+3]):a<=l[o+2]&&b<=l[o+3]&&c>=l[o+0]&&d>=l[o+1])?(h[n]=!0,g.push(k[n])):h[n]=!1}}},d8.prototype._forEachCell=function(a,b,c,d,f,g,h,i){for(var j=this._convertToCellCoord(a),k=this._convertToCellCoord(b),l=this._convertToCellCoord(c),m=this._convertToCellCoord(d),n=j;n<=l;n++)for(var o=k;o<=m;o++){var p=this.d*o+n;if((!i||i(this._convertFromCellCoord(n),this._convertFromCellCoord(o),this._convertFromCellCoord(n+1),this._convertFromCellCoord(o+1)))&&f.call(this,a,b,c,d,p,g,h,i))return}},d8.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},d8.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},d8.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var a=this.cells,b=3+this.cells.length+1+1,c=0,d=0;d<this.cells.length;d++)c+=this.cells[d].length;var f=new Int32Array(b+c+this.keys.length+this.bboxes.length);f[0]=this.extent,f[1]=this.n,f[2]=this.padding;for(var g=b,h=0;h<a.length;h++){var i=a[h];f[3+h]=g,f.set(i,g),g+=i.length}return f[3+a.length]=g,f.set(this.keys,g),f[3+a.length+1]=g+=this.keys.length,f.set(this.bboxes,g),g+=this.bboxes.length,f.buffer};const{ImageData:d9,ImageBitmap:ea}=i,eb={};function ec(a,b,c={}){Object.defineProperty(b,"_classRegistryKey",{value:a,writeable:!1}),eb[a]={klass:b,omit:c.omit||[],shallow:c.shallow||[]}}for(const ed in ec("Object",Object),d7.serialize=function(a,b){const c=a.toArrayBuffer();return b&&b.push(c),{buffer:c}},d7.deserialize=function(a){return new d7(a.buffer)},ec("Grid",d7),ec("Color",bK),ec("Error",Error),ec("ResolvedImage",bO),ec("StylePropertyFunction",dp),ec("StyleExpression",di,{omit:["_evaluator"]}),ec("ZoomDependentExpression",dm),ec("ZoomConstantExpression",dl),ec("CompoundExpression",b1,{omit:["_evaluate"]}),c0)c0[ed]._classRegistryKey||ec(`Expression_${ed}`,c0[ed]);function ee(a){return a&&"undefined"!=typeof ArrayBuffer&&(a instanceof ArrayBuffer||a.constructor&&"ArrayBuffer"===a.constructor.name)}function ef(a){return ea&&a instanceof ea}function eg(a,b){if(null==a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp)return a;if(ee(a)||ef(a))return b&&b.push(a),a;if(ArrayBuffer.isView(a)){const c=a;return b&&b.push(c.buffer),c}if(a instanceof d9)return b&&b.push(a.data.buffer),a;if(Array.isArray(a)){const d=[];for(const f of a)d.push(eg(f,b));return d}if("object"==typeof a){const g=a.constructor,h=g._classRegistryKey;if(!h)throw Error("can't serialize object of unregistered class");const i=g.serialize?g.serialize(a,b):{};if(!g.serialize){for(const j in a){if(!a.hasOwnProperty(j)||eb[h].omit.indexOf(j)>=0)continue;const k=a[j];i[j]=eb[h].shallow.indexOf(j)>=0?k:eg(k,b)}a instanceof Error&&(i.message=a.message)}if(i.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==h&&(i.$name=h),i}throw Error("can't serialize object of type "+typeof a)}function eh(a){if(null==a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||ee(a)||ef(a)||ArrayBuffer.isView(a)||a instanceof d9)return a;if(Array.isArray(a))return a.map(eh);if("object"==typeof a){const b=a.$name||"Object",{klass:c}=eb[b];if(!c)throw Error(`can't deserialize unregistered class ${b}`);if(c.deserialize)return c.deserialize(a);const d=Object.create(c.prototype);for(const f of Object.keys(a)){if("$name"===f)continue;const g=a[f];d[f]=eb[b].shallow.indexOf(f)>=0?g:eh(g)}return d}throw Error("can't deserialize object of type "+typeof a)}class ei{constructor(){this.first=!0}update(a,b){const c=Math.floor(a);return this.first?(this.first=!1,this.lastIntegerZoom=c,this.lastIntegerZoomTime=0,this.lastZoom=a,this.lastFloorZoom=c,!0):(this.lastFloorZoom>c?(this.lastIntegerZoom=c+1,this.lastIntegerZoomTime=b):this.lastFloorZoom<c&&(this.lastIntegerZoom=c,this.lastIntegerZoomTime=b),a!==this.lastZoom&&(this.lastZoom=a,this.lastFloorZoom=c,!0))}}const ej=a=>a>=1536&&a<=1791,ek=a=>a>=1872&&a<=1919,el=a=>a>=2208&&a<=2303,em=a=>a>=11904&&a<=12031,en=a=>a>=12032&&a<=12255,eo=a=>a>=12272&&a<=12287,ep=a=>a>=12288&&a<=12351,eq=a=>a>=12352&&a<=12447,er=a=>a>=12448&&a<=12543,es=a=>a>=12544&&a<=12591,et=a=>a>=12704&&a<=12735,eu=a=>a>=12736&&a<=12783,ev=a=>a>=12784&&a<=12799,ew=a=>a>=12800&&a<=13055,ex=a=>a>=13056&&a<=13311,ey=a=>a>=13312&&a<=19903,ez=a=>a>=19968&&a<=40959,eA=a=>a>=40960&&a<=42127,eB=a=>a>=42128&&a<=42191,eC=a=>a>=44032&&a<=55215,eD=a=>a>=63744&&a<=64255,eE=a=>a>=64336&&a<=65023,eF=a=>a>=65040&&a<=65055,eG=a=>a>=65072&&a<=65103,eH=a=>a>=65104&&a<=65135,eI=a=>a>=65136&&a<=65279,eJ=a=>a>=65280&&a<=65519;function eK(a){for(const b of a)if(eN(b.charCodeAt(0)))return!0;return!1}function eL(a){for(const b of a)if(!eM(b.charCodeAt(0)))return!1;return!0}function eM(a){return!(ej(a)||ek(a)||el(a)||eE(a)||eI(a))}function eN(a){var b,c,d,f,g,h,i,j;return!(746!==a&&747!==a&&(a<4352||!(et(a)||es(a)||eG(a)&&!(a>=65097&&a<=65103)||eD(a)||ex(a)||em(a)||eu(a)||!(!ep(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||12336===a)||ey(a)||ez(a)||ew(a)||(b=a)>=12592&&b<=12687||(c=a)>=43360&&c<=43391||(d=a)>=55216&&d<=55295||(f=a)>=4352&&f<=4607||eC(a)||eq(a)||eo(a)||(g=a)>=12688&&g<=12703||en(a)||ev(a)||er(a)&&12540!==a||!(!eJ(a)||65288===a||65289===a||65293===a||a>=65306&&a<=65310||65339===a||65341===a||65343===a||a>=65371&&a<=65503||65507===a||a>=65512&&a<=65519)||!(!eH(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(h=a)>=5120&&h<=5759||(i=a)>=6320&&i<=6399||eF(a)||(j=a)>=19904&&j<=19967||eA(a)||eB(a))))}function eO(a){var b,c,d,f,g,h,i,j,k,l,m,n,o;return!(eN(a)||(c=b=a)>=128&&c<=255&&(167===b||169===b||174===b||177===b||188===b||189===b||190===b||215===b||247===b)||(d=b)>=8192&&d<=8303&&(8214===b||8224===b||8225===b||8240===b||8241===b||8251===b||8252===b||8258===b||8263===b||8264===b||8265===b||8273===b)||(f=b)>=8448&&f<=8527||(g=b)>=8528&&g<=8591||(h=b)>=8960&&h<=9215&&(b>=8960&&b<=8967||b>=8972&&b<=8991||b>=8996&&b<=9e3||9003===b||b>=9085&&b<=9114||b>=9150&&b<=9165||9167===b||b>=9169&&b<=9179||b>=9186&&b<=9215)||(i=b)>=9216&&i<=9279&&9251!==b||(j=b)>=9280&&j<=9311||(k=b)>=9312&&k<=9471||(l=b)>=9632&&l<=9727||(m=b)>=9728&&m<=9983&&!(b>=9754&&b<=9759)||(n=b)>=11008&&n<=11263&&(b>=11026&&b<=11055||b>=11088&&b<=11097||b>=11192&&b<=11243)||ep(b)||er(b)||(o=b)>=57344&&o<=63743||eG(b)||eH(b)||eJ(b)||8734===b||8756===b||8757===b||b>=9984&&b<=10087||b>=10102&&b<=10131||65532===b||65533===b)}function eP(a){return a>=1424&&a<=2303||eE(a)||eI(a)}function eQ(a,b){var c;return!(!b&&eP(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(c=a)>=6016&&c<=6143)}function eR(a){for(const b of a)if(eP(b.charCodeAt(0)))return!0;return!1}const eS="deferred",eT="loading",eU="loaded";let eV=null,eW="unavailable",eX=null;const eY=function(a){a&&"string"==typeof a&&a.indexOf("NetworkError")> -1&&(eW="error"),eV&&eV(a)};function eZ(){e$.fire(new bh("pluginStateChange",{pluginStatus:eW,pluginURL:eX}))}const e$=new bj,e_=function(){return eW},e0=function(){if(eW!==eS||!eX)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");eW=eT,eZ(),eX&&a7({url:eX},a=>{a?eY(a):(eW=eU,eZ())})},e1={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>eW===eU||null!=e1.applyArabicShaping,isLoading:()=>eW===eT,setState(a){eW=a.pluginStatus,eX=a.pluginURL},isParsed:()=>null!=e1.applyArabicShaping&&null!=e1.processBidirectionalText&&null!=e1.processStyledBidirectionalText,getPluginURL:()=>eX};class e2{constructor(a,b){this.zoom=a,b?(this.now=b.now,this.fadeDuration=b.fadeDuration,this.zoomHistory=b.zoomHistory,this.transition=b.transition,this.pitch=b.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ei,this.transition={},this.pitch=0)}isSupportedScript(a){return function(a,b){for(const c of a)if(!eQ(c.charCodeAt(0),b))return!1;return!0}(a,e1.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const a=this.zoom,b=a-Math.floor(a),c=this.crossFadingFactor();return a>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:b+(1-b)*c}:{fromScale:.5,toScale:1,t:1-(1-c)*b}}}class e3{constructor(a,b){this.property=a,this.value=b,this.expression=function(a,b){if(da(a))return new dp(a,b);if(dj(a)){const c=dn(a,b);if("error"===c.result)throw Error(c.value.map(a=>`${a.key}: ${a.message}`).join(", "));return c.value}{let d=a;return"string"==typeof a&&"color"===b.type&&(d=bK.parse(a)),{kind:"constant",evaluate:()=>d}}}(void 0===b?a.specification.default:b,a.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(a,b,c){return this.property.possiblyEvaluate(this,a,b,c)}}class e4{constructor(a){this.property=a,this.value=new e3(a,void 0)}transitioned(a,b){return new e6(this.property,this.value,b,aa({},a.transition,this.transition),a.now)}untransitioned(){return new e6(this.property,this.value,null,{},0)}}class e5{constructor(a){this._properties=a,this._values=Object.create(a.defaultTransitionablePropertyValues)}getValue(a){return ak(this._values[a].value.value)}setValue(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new e4(this._values[a].property)),this._values[a].value=new e3(this._values[a].property,null===b?void 0:ak(b))}getTransition(a){return ak(this._values[a].transition)}setTransition(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new e4(this._values[a].property)),this._values[a].transition=ak(b)||void 0}serialize(){const a={};for(const b of Object.keys(this._values)){const c=this.getValue(b);void 0!==c&&(a[b]=c);const d=this.getTransition(b);void 0!==d&&(a[`${b}-transition`]=d)}return a}transitioned(a,b){const c=new e7(this._properties);for(const d of Object.keys(this._values))c._values[d]=this._values[d].transitioned(a,b._values[d]);return c}untransitioned(){const a=new e7(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].untransitioned();return a}}class e6{constructor(a,b,c,d,f){const g=d.delay||0,h=d.duration||0;f=f||0,this.property=a,this.value=b,this.begin=f+g,this.end=this.begin+h,a.specification.transition&&(d.delay||d.duration)&&(this.prior=c)}possiblyEvaluate(a,b,c){const d=a.now||0,f=this.value.possiblyEvaluate(a,b,c),g=this.prior;if(g){if(d>this.end||this.value.isDataDriven())return this.prior=null,f;if(d<this.begin)return g.possiblyEvaluate(a,b,c);{const h=(d-this.begin)/(this.end-this.begin);return this.property.interpolate(g.possiblyEvaluate(a,b,c),f,U(h))}}return f}}class e7{constructor(a){this._properties=a,this._values=Object.create(a.defaultTransitioningPropertyValues)}possiblyEvaluate(a,b,c){const d=new e9(this._properties);for(const f of Object.keys(this._values))d._values[f]=this._values[f].possiblyEvaluate(a,b,c);return d}hasTransition(){for(const a of Object.keys(this._values))if(this._values[a].prior)return!0;return!1}}class e8{constructor(a,b,c){this.property=a,this.value=b,this.parameters=c}isConstant(){return"constant"===this.value.kind}constantOr(a){return"constant"===this.value.kind?this.value.value:a}evaluate(a,b,c,d){return this.property.evaluate(this.value,this.parameters,a,b,c,d)}}class e9{constructor(a){this._properties=a,this._values=Object.create(a.defaultPossiblyEvaluatedValues)}get(a){return this._values[a]}}class fa{constructor(a){this.specification=a}possiblyEvaluate(a,b){return a.expression.evaluate(b)}interpolate(a,b,c){const d=cs[this.specification.type];return d?d(a,b,c):a}}class fb{constructor(a,b){this.specification=a,this.overrides=b}possiblyEvaluate(a,b,c,d){return new e8(this,"constant"===a.expression.kind||"camera"===a.expression.kind?{kind:"constant",value:a.expression.evaluate(b,null,{},c,d)}:a.expression,b)}interpolate(a,b,c){if("constant"!==a.value.kind||"constant"!==b.value.kind)return a;if(void 0===a.value.value|| void 0===b.value.value)return new e8(this,{kind:"constant",value:void 0},a.parameters);const d=cs[this.specification.type];return d?new e8(this,{kind:"constant",value:d(a.value.value,b.value.value,c)},a.parameters):a}evaluate(a,b,c,d,f,g){return"constant"===a.kind?a.value:a.evaluate(b,c,d,f,g)}}class fc extends fb{possiblyEvaluate(a,b,c,d){if(void 0===a.value)return new e8(this,{kind:"constant",value:void 0},b);if("constant"===a.expression.kind){const f=a.expression.evaluate(b,null,{},c,d),g="resolvedImage"===a.property.specification.type&&"string"!=typeof f?f.name:f,h=this._calculate(g,g,g,b);return new e8(this,{kind:"constant",value:h},b)}if("camera"===a.expression.kind){const i=this._calculate(a.expression.evaluate({zoom:b.zoom-1}),a.expression.evaluate({zoom:b.zoom}),a.expression.evaluate({zoom:b.zoom+1}),b);return new e8(this,{kind:"constant",value:i},b)}return new e8(this,a.expression,b)}evaluate(a,b,c,d,f,g){if("source"===a.kind){const h=a.evaluate(b,c,d,f,g);return this._calculate(h,h,h,b)}return"composite"===a.kind?this._calculate(a.evaluate({zoom:Math.floor(b.zoom)-1},c,d),a.evaluate({zoom:Math.floor(b.zoom)},c,d),a.evaluate({zoom:Math.floor(b.zoom)+1},c,d),b):a.value}_calculate(a,b,c,d){return d.zoom>d.zoomHistory.lastIntegerZoom?{from:a,to:b,other:c}:{from:c,to:b,other:a}}interpolate(a){return a}}class fd{constructor(a){this.specification=a}possiblyEvaluate(a,b,c,d){if(void 0!==a.value){if("constant"===a.expression.kind){const f=a.expression.evaluate(b,null,{},c,d);return this._calculate(f,f,f,b)}return this._calculate(a.expression.evaluate(new e2(Math.floor(b.zoom-1),b)),a.expression.evaluate(new e2(Math.floor(b.zoom),b)),a.expression.evaluate(new e2(Math.floor(b.zoom+1),b)),b)}}_calculate(a,b,c,d){return d.zoom>d.zoomHistory.lastIntegerZoom?{from:a,to:b}:{from:c,to:b}}interpolate(a){return a}}class fe{constructor(a){this.specification=a}possiblyEvaluate(a,b,c,d){return!!a.expression.evaluate(b,null,{},c,d)}interpolate(){return!1}}class ff{constructor(a){for(const b in this.properties=a,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],a){const c=a[b];c.specification.overridable&&this.overridableProperties.push(b);const d=this.defaultPropertyValues[b]=new e3(c,void 0),f=this.defaultTransitionablePropertyValues[b]=new e4(c);this.defaultTransitioningPropertyValues[b]=f.untransitioned(),this.defaultPossiblyEvaluatedValues[b]=d.possiblyEvaluate({})}}}function fg(a,b){return 256*(a=X(Math.floor(a),0,255))+X(Math.floor(b),0,255)}ec("DataDrivenProperty",fb),ec("DataConstantProperty",fa),ec("CrossFadedDataDrivenProperty",fc),ec("CrossFadedProperty",fd),ec("ColorRampProperty",fe);const fh={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class fi{constructor(a,b){this._structArray=a,this._pos1=b*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class fj{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(a,b){return a._trim(),b&&(a.isTransferred=!0,b.push(a.arrayBuffer)),{length:a.length,arrayBuffer:a.arrayBuffer}}static deserialize(a){const b=Object.create(this.prototype);return b.arrayBuffer=a.arrayBuffer,b.length=a.length,b.capacity=a.arrayBuffer.byteLength/b.bytesPerElement,b._refreshViews(),b}_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(a){this.reserve(a),this.length=a}reserve(a){if(a>this.capacity){this.capacity=Math.max(a,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const b=this.uint8;this._refreshViews(),b&&this.uint8.set(b)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function fk(a,b=1){let c=0,d=0;return{members:a.map(a=>{const f=fh[a.type].BYTES_PER_ELEMENT,g=c=fl(c,Math.max(b,f)),h=a.components||1;return d=Math.max(d,f),c+=f*h,{name:a.name,type:a.type,components:h,offset:g}}),size:fl(c,Math.max(d,b)),alignment:b}}function fl(a,b){return Math.ceil(a/b)*b}class fm extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(a,b){const c=this.length;return this.resize(c+1),this.emplace(c,a,b)}emplace(a,b,c){const d=2*a;return this.int16[d+0]=b,this.int16[d+1]=c,a}}fm.prototype.bytesPerElement=4,ec("StructArrayLayout2i4",fm);class fn extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(a,b,c,d){const f=this.length;return this.resize(f+1),this.emplace(f,a,b,c,d)}emplace(a,b,c,d,f){const g=4*a;return this.int16[g+0]=b,this.int16[g+1]=c,this.int16[g+2]=d,this.int16[g+3]=f,a}}fn.prototype.bytesPerElement=8,ec("StructArrayLayout4i8",fn);class fo extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(a,b,c,d,f,g,h){const i=this.length;return this.resize(i+1),this.emplace(i,a,b,c,d,f,g,h)}emplace(a,b,c,d,f,g,h,i){const j=6*a,k=12*a,l=3*a;return this.int16[j+0]=b,this.int16[j+1]=c,this.uint8[k+4]=d,this.uint8[k+5]=f,this.uint8[k+6]=g,this.uint8[k+7]=h,this.float32[l+2]=i,a}}fo.prototype.bytesPerElement=12,ec("StructArrayLayout2i4ub1f12",fo);class fp extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(a,b,c){const d=this.length;return this.resize(d+1),this.emplace(d,a,b,c)}emplace(a,b,c,d){const f=3*a;return this.float32[f+0]=b,this.float32[f+1]=c,this.float32[f+2]=d,a}}fp.prototype.bytesPerElement=12,ec("StructArrayLayout3f12",fp);class fq extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(a,b,c,d,f,g,h,i,j,k){const l=this.length;return this.resize(l+1),this.emplace(l,a,b,c,d,f,g,h,i,j,k)}emplace(a,b,c,d,f,g,h,i,j,k,l){const m=10*a;return this.uint16[m+0]=b,this.uint16[m+1]=c,this.uint16[m+2]=d,this.uint16[m+3]=f,this.uint16[m+4]=g,this.uint16[m+5]=h,this.uint16[m+6]=i,this.uint16[m+7]=j,this.uint16[m+8]=k,this.uint16[m+9]=l,a}}fq.prototype.bytesPerElement=20,ec("StructArrayLayout10ui20",fq);class fr extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(a,b,c,d,f,g,h,i){const j=this.length;return this.resize(j+1),this.emplace(j,a,b,c,d,f,g,h,i)}emplace(a,b,c,d,f,g,h,i,j){const k=8*a;return this.uint16[k+0]=b,this.uint16[k+1]=c,this.uint16[k+2]=d,this.uint16[k+3]=f,this.uint16[k+4]=g,this.uint16[k+5]=h,this.uint16[k+6]=i,this.uint16[k+7]=j,a}}fr.prototype.bytesPerElement=16,ec("StructArrayLayout8ui16",fr);class fs extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q){const r=this.length;return this.resize(r+1),this.emplace(r,a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q)}emplace(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r){const s=16*a;return this.int16[s+0]=b,this.int16[s+1]=c,this.int16[s+2]=d,this.int16[s+3]=f,this.uint16[s+4]=g,this.uint16[s+5]=h,this.uint16[s+6]=i,this.uint16[s+7]=j,this.int16[s+8]=k,this.int16[s+9]=l,this.int16[s+10]=m,this.int16[s+11]=n,this.int16[s+12]=o,this.int16[s+13]=p,this.int16[s+14]=q,this.int16[s+15]=r,a}}fs.prototype.bytesPerElement=32,ec("StructArrayLayout4i4ui4i4i32",fs);class ft extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(a){const b=this.length;return this.resize(b+1),this.emplace(b,a)}emplace(a,b){return this.uint32[1*a+0]=b,a}}ft.prototype.bytesPerElement=4,ec("StructArrayLayout1ul4",ft);class fu extends fj{_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(a,b,c,d,f,g,h,i,j,k,l,m,n){const o=this.length;return this.resize(o+1),this.emplace(o,a,b,c,d,f,g,h,i,j,k,l,m,n)}emplace(a,b,c,d,f,g,h,i,j,k,l,m,n,o){const p=20*a,q=10*a;return this.int16[p+0]=b,this.int16[p+1]=c,this.int16[p+2]=d,this.int16[p+3]=f,this.int16[p+4]=g,this.float32[q+3]=h,this.float32[q+4]=i,this.float32[q+5]=j,this.float32[q+6]=k,this.int16[p+14]=l,this.uint32[q+8]=m,this.uint16[p+18]=n,this.uint16[p+19]=o,a}}fu.prototype.bytesPerElement=40,ec("StructArrayLayout5i4f1i1ul2ui40",fu);class fv extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(a,b,c,d,f,g,h){const i=this.length;return this.resize(i+1),this.emplace(i,a,b,c,d,f,g,h)}emplace(a,b,c,d,f,g,h,i){const j=8*a;return this.int16[j+0]=b,this.int16[j+1]=c,this.int16[j+2]=d,this.int16[j+4]=f,this.int16[j+5]=g,this.int16[j+6]=h,this.int16[j+7]=i,a}}fv.prototype.bytesPerElement=16,ec("StructArrayLayout3i2i2i16",fv);class fw extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(a,b,c,d,f){const g=this.length;return this.resize(g+1),this.emplace(g,a,b,c,d,f)}emplace(a,b,c,d,f,g){const h=4*a,i=8*a;return this.float32[h+0]=b,this.float32[h+1]=c,this.float32[h+2]=d,this.int16[i+6]=f,this.int16[i+7]=g,a}}fw.prototype.bytesPerElement=16,ec("StructArrayLayout2f1f2i16",fw);class fx extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(a,b,c,d){const f=this.length;return this.resize(f+1),this.emplace(f,a,b,c,d)}emplace(a,b,c,d,f){const g=12*a,h=3*a;return this.uint8[g+0]=b,this.uint8[g+1]=c,this.float32[h+1]=d,this.float32[h+2]=f,a}}fx.prototype.bytesPerElement=12,ec("StructArrayLayout2ub2f12",fx);class fy extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(a,b,c){const d=this.length;return this.resize(d+1),this.emplace(d,a,b,c)}emplace(a,b,c,d){const f=3*a;return this.uint16[f+0]=b,this.uint16[f+1]=c,this.uint16[f+2]=d,a}}fy.prototype.bytesPerElement=6,ec("StructArrayLayout3ui6",fy);class fz extends fj{_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(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w){const x=this.length;return this.resize(x+1),this.emplace(x,a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w)}emplace(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w,x){const y=30*a,z=15*a,A=60*a;return this.int16[y+0]=b,this.int16[y+1]=c,this.int16[y+2]=d,this.float32[z+2]=f,this.float32[z+3]=g,this.uint16[y+8]=h,this.uint16[y+9]=i,this.uint32[z+5]=j,this.uint32[z+6]=k,this.uint32[z+7]=l,this.uint16[y+16]=m,this.uint16[y+17]=n,this.uint16[y+18]=o,this.float32[z+10]=p,this.float32[z+11]=q,this.uint8[A+48]=r,this.uint8[A+49]=s,this.uint8[A+50]=u,this.uint32[z+13]=v,this.int16[y+28]=w,this.uint8[A+58]=x,a}}fz.prototype.bytesPerElement=60,ec("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",fz);class fA extends fj{_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(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w,x,y,z,A,B,C,D,E,F){const G=this.length;return this.resize(G+1),this.emplace(G,a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w,x,y,z,A,B,C,D,E,F)}emplace(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w,x,y,z,A,B,C,D,E,F,G){const H=38*a,I=19*a;return this.int16[H+0]=b,this.int16[H+1]=c,this.int16[H+2]=d,this.float32[I+2]=f,this.float32[I+3]=g,this.int16[H+8]=h,this.int16[H+9]=i,this.int16[H+10]=j,this.int16[H+11]=k,this.int16[H+12]=l,this.int16[H+13]=m,this.uint16[H+14]=n,this.uint16[H+15]=o,this.uint16[H+16]=p,this.uint16[H+17]=q,this.uint16[H+18]=r,this.uint16[H+19]=s,this.uint16[H+20]=u,this.uint16[H+21]=v,this.uint16[H+22]=w,this.uint16[H+23]=x,this.uint16[H+24]=y,this.uint16[H+25]=z,this.uint16[H+26]=A,this.uint16[H+27]=B,this.uint16[H+28]=C,this.uint32[I+15]=D,this.float32[I+16]=E,this.float32[I+17]=F,this.float32[I+18]=G,a}}fA.prototype.bytesPerElement=76,ec("StructArrayLayout3i2f6i15ui1ul3f76",fA);class fB extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(a){const b=this.length;return this.resize(b+1),this.emplace(b,a)}emplace(a,b){return this.float32[1*a+0]=b,a}}fB.prototype.bytesPerElement=4,ec("StructArrayLayout1f4",fB);class fC extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(a,b,c){const d=this.length;return this.resize(d+1),this.emplace(d,a,b,c)}emplace(a,b,c,d){const f=3*a;return this.int16[f+0]=b,this.int16[f+1]=c,this.int16[f+2]=d,a}}fC.prototype.bytesPerElement=6,ec("StructArrayLayout3i6",fC);class fD extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(a,b,c,d,f,g,h){const i=this.length;return this.resize(i+1),this.emplace(i,a,b,c,d,f,g,h)}emplace(a,b,c,d,f,g,h,i){const j=7*a;return this.float32[j+0]=b,this.float32[j+1]=c,this.float32[j+2]=d,this.float32[j+3]=f,this.float32[j+4]=g,this.float32[j+5]=h,this.float32[j+6]=i,a}}fD.prototype.bytesPerElement=28,ec("StructArrayLayout7f28",fD);class fE extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(a,b,c,d){const f=this.length;return this.resize(f+1),this.emplace(f,a,b,c,d)}emplace(a,b,c,d,f){const g=6*a;return this.uint32[3*a+0]=b,this.uint16[g+2]=c,this.uint16[g+3]=d,this.uint16[g+4]=f,a}}fE.prototype.bytesPerElement=12,ec("StructArrayLayout1ul3ui12",fE);class fF extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(a,b){const c=this.length;return this.resize(c+1),this.emplace(c,a,b)}emplace(a,b,c){const d=2*a;return this.uint16[d+0]=b,this.uint16[d+1]=c,a}}fF.prototype.bytesPerElement=4,ec("StructArrayLayout2ui4",fF);class fG extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(a){const b=this.length;return this.resize(b+1),this.emplace(b,a)}emplace(a,b){return this.uint16[1*a+0]=b,a}}fG.prototype.bytesPerElement=2,ec("StructArrayLayout1ui2",fG);class fH extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(a,b){const c=this.length;return this.resize(c+1),this.emplace(c,a,b)}emplace(a,b,c){const d=2*a;return this.float32[d+0]=b,this.float32[d+1]=c,a}}fH.prototype.bytesPerElement=8,ec("StructArrayLayout2f8",fH);class fI extends fj{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(a,b,c,d){const f=this.length;return this.resize(f+1),this.emplace(f,a,b,c,d)}emplace(a,b,c,d,f){const g=4*a;return this.float32[g+0]=b,this.float32[g+1]=c,this.float32[g+2]=d,this.float32[g+3]=f,a}}fI.prototype.bytesPerElement=16,ec("StructArrayLayout4f16",fI);class fJ extends fi{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]}}fJ.prototype.size=40;class fK extends fu{get(a){return new fJ(this,a)}}ec("CollisionBoxArray",fK);class fL extends fi{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(a){this._structArray.uint8[this._pos1+49]=a}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(a){this._structArray.uint8[this._pos1+50]=a}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(a){this._structArray.uint32[this._pos4+13]=a}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(a){this._structArray.uint8[this._pos1+58]=a}}fL.prototype.size=60;class fM extends fz{get(a){return new fL(this,a)}}ec("PlacedSymbolArray",fM);class fN extends fi{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(a){this._structArray.uint32[this._pos4+15]=a}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]}}fN.prototype.size=76;class fO extends fA{get(a){return new fN(this,a)}}ec("SymbolInstanceArray",fO);class fP extends fB{getoffsetX(a){return this.float32[1*a+0]}}ec("GlyphOffsetArray",fP);class fQ extends fC{getx(a){return this.int16[3*a+0]}gety(a){return this.int16[3*a+1]}gettileUnitDistanceFromAnchor(a){return this.int16[3*a+2]}}ec("SymbolLineVertexArray",fQ);class fR extends fi{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]}}fR.prototype.size=12;class fS extends fE{get(a){return new fR(this,a)}}ec("FeatureIndexArray",fS);class fT extends fi{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}fT.prototype.size=4;class fU extends fF{get(a){return new fT(this,a)}}ec("FillExtrusionCentroidArray",fU);const fV=fk([{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"},]),fW=fk([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"},]);var fX=bI(function(a){a.exports=function(a,b){var c,d,f,g,h,i,j,k;for(d=a.length-(c=3&a.length),f=b,h=3432918353,i=461845907,k=0;k<d;)j=255&a.charCodeAt(k)|(255&a.charCodeAt(++k))<<8|(255&a.charCodeAt(++k))<<16|(255&a.charCodeAt(++k))<<24,++k,f=27492+(65535&(g=5*(65535&(f=(f^=j=(65535&(j=(j=(65535&j)*h+(((j>>>16)*h&65535)<<16)&4294967295)<<15|j>>>17))*i+(((j>>>16)*i&65535)<<16)&4294967295)<<13|f>>>19))+((5*(f>>>16)&65535)<<16)&4294967295))+((58964+(g>>>16)&65535)<<16);switch(j=0,c){case 3:j^=(255&a.charCodeAt(k+2))<<16;case 2:j^=(255&a.charCodeAt(k+1))<<8;case 1:f^=j=(65535&(j=(j=(65535&(j^=255&a.charCodeAt(k)))*h+(((j>>>16)*h&65535)<<16)&4294967295)<<15|j>>>17))*i+(((j>>>16)*i&65535)<<16)&4294967295}return f^=a.length,f=2246822507*(65535&(f^=f>>>16))+((2246822507*(f>>>16)&65535)<<16)&4294967295,f=3266489909*(65535&(f^=f>>>13))+((3266489909*(f>>>16)&65535)<<16)&4294967295,(f^=f>>>16)>>>0}}),fY=bI(function(a){a.exports=function(a,b){for(var c,d=a.length,f=b^d,g=0;d>=4;)c=1540483477*(65535&(c=255&a.charCodeAt(g)|(255&a.charCodeAt(++g))<<8|(255&a.charCodeAt(++g))<<16|(255&a.charCodeAt(++g))<<24))+((1540483477*(c>>>16)&65535)<<16),f=1540483477*(65535&f)+((1540483477*(f>>>16)&65535)<<16)^(c=1540483477*(65535&(c^=c>>>24))+((1540483477*(c>>>16)&65535)<<16)),d-=4,++g;switch(d){case 3:f^=(255&a.charCodeAt(g+2))<<16;case 2:f^=(255&a.charCodeAt(g+1))<<8;case 1:f=1540483477*(65535&(f^=255&a.charCodeAt(g)))+((1540483477*(f>>>16)&65535)<<16)}return f=1540483477*(65535&(f^=f>>>13))+((1540483477*(f>>>16)&65535)<<16),(f^=f>>>15)>>>0}}),fZ=fX;fZ.murmur3=fX,fZ.murmur2=fY;class f${constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(a,b,c,d){this.ids.push(f_(a)),this.positions.push(b,c,d)}getPositions(a){const b=f_(a);let c=0,d=this.ids.length-1;for(;c<d;){const f=c+d>>1;this.ids[f]>=b?d=f:c=f+1}const g=[];for(;this.ids[c]===b;)g.push({index:this.positions[3*c],start:this.positions[3*c+1],end:this.positions[3*c+2]}),c++;return g}static serialize(a,b){const c=new Float64Array(a.ids),d=new Uint32Array(a.positions);return f0(c,d,0,c.length-1),b&&b.push(c.buffer,d.buffer),{ids:c,positions:d}}static deserialize(a){const b=new f$;return b.ids=a.ids,b.positions=a.positions,b.indexed=!0,b}}function f_(a){const b=+a;return!isNaN(b)&&Number.MIN_SAFE_INTEGER<=b&&b<=Number.MAX_SAFE_INTEGER?b:fZ(String(a))}function f0(a,b,c,d){for(;c<d;){const f=a[c+d>>1];let g=c-1,h=d+1;for(;;){do g++;while(a[g]<f)do h--;while(a[h]>f)if(g>=h)break;f1(a,g,h),f1(b,3*g,3*h),f1(b,3*g+1,3*h+1),f1(b,3*g+2,3*h+2)}h-c<d-h?(f0(a,b,c,h),c=h+1):(f0(a,b,h+1,d),d=h)}}function f1(a,b,c){const d=a[b];a[b]=a[c],a[c]=d}ec("FeaturePositionMap",f$);class f2{constructor(a,b){this.gl=a.gl,this.location=b}}class f3 extends f2{constructor(a,b){super(a,b),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1f(this.location,a))}}class f4 extends f2{constructor(a,b){super(a,b),this.current=[0,0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]&&a[3]===this.current[3]||(this.current=a,this.gl.uniform4f(this.location,a[0],a[1],a[2],a[3]))}}class f5 extends f2{constructor(a,b){super(a,b),this.current=bK.transparent}set(a){a.r===this.current.r&&a.g===this.current.g&&a.b===this.current.b&&a.a===this.current.a||(this.current=a,this.gl.uniform4f(this.location,a.r,a.g,a.b,a.a))}}const f6=new Float32Array(16),f7=new Float32Array(9),f8=new Float32Array(4);function f9(a){return[fg(255*a.r,255*a.g),fg(255*a.b,255*a.a),]}class ga{constructor(a,b,c){this.value=a,this.uniformNames=b.map(a=>`u_${a}`),this.type=c}setUniform(a,b,c){a.set(c.constantOr(this.value))}getBinding(a,b,c){return"color"===this.type?new f5(a,b):new f3(a,b)}}class gb{constructor(a,b){this.uniformNames=b.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(a,b){this.pixelRatioFrom=b.pixelRatio,this.pixelRatioTo=a.pixelRatio,this.patternFrom=b.tl.concat(b.br),this.patternTo=a.tl.concat(a.br)}setUniform(a,b,c,d){const f="u_pattern_to"===d||"u_dash_to"===d?this.patternTo:"u_pattern_from"===d||"u_dash_from"===d?this.patternFrom:"u_pixel_ratio_to"===d?this.pixelRatioTo:"u_pixel_ratio_from"===d?this.pixelRatioFrom:null;f&&a.set(f)}getBinding(a,b,c){return"u_pattern_from"===c||"u_pattern_to"===c||"u_dash_from"===c||"u_dash_to"===c?new f4(a,b):new f3(a,b)}}class gc{constructor(a,b,c,d){this.expression=a,this.type=c,this.maxValue=0,this.paintVertexAttributes=b.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?2:1,offset:0})),this.paintVertexArray=new d}populatePaintArray(a,b,c,d,f,g){const h=this.paintVertexArray.length,i=this.expression.evaluate(new e2(0),b,{},f,d,g);this.paintVertexArray.resize(a),this._setPaintValue(h,a,i)}updatePaintArray(a,b,c,d,f){const g=this.expression.evaluate({zoom:0},c,d,void 0,f);this._setPaintValue(a,b,g)}_setPaintValue(a,b,c){if("color"===this.type){const d=f9(c);for(let f=a;f<b;f++)this.paintVertexArray.emplace(f,d[0],d[1])}else{for(let g=a;g<b;g++)this.paintVertexArray.emplace(g,c);this.maxValue=Math.max(this.maxValue,Math.abs(c))}}upload(a){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=a.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class gd{constructor(a,b,c,d,f,g){this.expression=a,this.uniformNames=b.map(a=>`u_${a}_t`),this.type=c,this.useIntegerZoom=d,this.zoom=f,this.maxValue=0,this.paintVertexAttributes=b.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?4:2,offset:0})),this.paintVertexArray=new g}populatePaintArray(a,b,c,d,f,g){const h=this.expression.evaluate(new e2(this.zoom),b,{},f,d,g),i=this.expression.evaluate(new e2(this.zoom+1),b,{},f,d,g),j=this.paintVertexArray.length;this.paintVertexArray.resize(a),this._setPaintValue(j,a,h,i)}updatePaintArray(a,b,c,d,f){const g=this.expression.evaluate({zoom:this.zoom},c,d,void 0,f),h=this.expression.evaluate({zoom:this.zoom+1},c,d,void 0,f);this._setPaintValue(a,b,g,h)}_setPaintValue(a,b,c,d){if("color"===this.type){const f=f9(c),g=f9(d);for(let h=a;h<b;h++)this.paintVertexArray.emplace(h,f[0],f[1],g[0],g[1])}else{for(let i=a;i<b;i++)this.paintVertexArray.emplace(i,c,d);this.maxValue=Math.max(this.maxValue,Math.abs(c),Math.abs(d))}}upload(a){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=a.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(a,b){const c=this.useIntegerZoom?Math.floor(b.zoom):b.zoom,d=X(this.expression.interpolationFactor(c,this.zoom,this.zoom+1),0,1);a.set(d)}getBinding(a,b,c){return new f3(a,b)}}class ge{constructor(a,b,c,d,f,g,h){this.expression=a,this.type=c,this.useIntegerZoom=d,this.zoom=f,this.layerId=h,this.paintVertexAttributes=("array"===c?fW:fV).members;for(let i=0;i<b.length;++i);this.zoomInPaintVertexArray=new g,this.zoomOutPaintVertexArray=new g}populatePaintArray(a,b,c){const d=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(a),this.zoomOutPaintVertexArray.resize(a),this._setPaintValues(d,a,b.patterns&&b.patterns[this.layerId],c)}updatePaintArray(a,b,c,d,f,g){this._setPaintValues(a,b,c.patterns&&c.patterns[this.layerId],g)}_setPaintValues(a,b,c,d){if(!d||!c)return;const{min:f,mid:g,max:h}=c,i=d[f],j=d[g],k=d[h];if(i&&j&&k)for(let l=a;l<b;l++)this._setPaintValue(this.zoomInPaintVertexArray,l,j,i),this._setPaintValue(this.zoomOutPaintVertexArray,l,j,k)}_setPaintValue(a,b,c,d){a.emplace(b,c.tl[0],c.tl[1],c.br[0],c.br[1],d.tl[0],d.tl[1],d.br[0],d.br[1],c.pixelRatio,d.pixelRatio)}upload(a){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=a.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=a.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class gf{constructor(a,b,c=()=>!0){this.binders={},this._buffers=[];const d=[];for(const f in a.paint._values){if(!c(f))continue;const g=a.paint.get(f);if(!(g instanceof e8&&c6(g.property.specification)))continue;const h=gi(f,a.type),i=g.value,j=g.property.specification.type,k=g.property.useIntegerZoom,l=g.property.specification["property-type"],m="cross-faded"===l||"cross-faded-data-driven"===l,n="line-dasharray"===String(f)&&"constant"!==a.layout.get("line-cap").value.kind;if("constant"!==i.kind||n){if("source"===i.kind||n||m){const o=gl(f,j,"source");this.binders[f]=m?new ge(i,h,j,k,b,o,a.id):new gc(i,h,j,o),d.push(`/a_${f}`)}else{const p=gl(f,j,"composite");this.binders[f]=new gd(i,h,j,k,b,p),d.push(`/z_${f}`)}}else this.binders[f]=m?new gb(i.value,h):new ga(i.value,h,j),d.push(`/u_${f}`)}this.cacheKey=d.sort().join("")}getMaxValue(a){const b=this.binders[a];return b instanceof gc||b instanceof gd?b.maxValue:0}populatePaintArrays(a,b,c,d,f,g){for(const h in this.binders){const i=this.binders[h];(i instanceof gc||i instanceof gd||i instanceof ge)&&i.populatePaintArray(a,b,c,d,f,g)}}setConstantPatternPositions(a,b){for(const c in this.binders){const d=this.binders[c];d instanceof gb&&d.setConstantPatternPositions(a,b)}}updatePaintArrays(a,b,c,d,f,g){let h=!1;for(const i in a){const j=b.getPositions(i);for(const k of j){const l=c.feature(k.index);for(const m in this.binders){const n=this.binders[m];if((n instanceof gc||n instanceof gd||n instanceof ge)&& !0===n.expression.isStateDependent){const o=d.paint.get(m);n.expression=o.value,n.updatePaintArray(k.start,k.end,l,a[i],f,g),h=!0}}}}return h}defines(){const a=[];for(const b in this.binders){const c=this.binders[b];(c instanceof ga||c instanceof gb)&&a.push(...c.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return a}getBinderAttributes(){const a=[];for(const b in this.binders){const c=this.binders[b];if(c instanceof gc||c instanceof gd||c instanceof ge)for(let d=0;d<c.paintVertexAttributes.length;d++)a.push(c.paintVertexAttributes[d].name)}return a}getBinderUniforms(){const a=[];for(const b in this.binders){const c=this.binders[b];if(c instanceof ga||c instanceof gb||c instanceof gd)for(const d of c.uniformNames)a.push(d)}return a}getPaintVertexBuffers(){return this._buffers}getUniforms(a,b){const c=[];for(const d in this.binders){const f=this.binders[d];if(f instanceof ga||f instanceof gb||f instanceof gd){for(const g of f.uniformNames)if(b[g]){const h=f.getBinding(a,b[g],g);c.push({name:g,property:d,binding:h})}}}return c}setUniforms(a,b,c,d){for(const{name:f,property:g,binding:h}of b)this.binders[g].setUniform(h,d,c.get(g),f)}updatePaintBuffers(a){for(const b in this._buffers=[],this.binders){const c=this.binders[b];if(a&&c instanceof ge){const d=2===a.fromScale?c.zoomInPaintVertexBuffer:c.zoomOutPaintVertexBuffer;d&&this._buffers.push(d)}else(c instanceof gc||c instanceof gd)&&c.paintVertexBuffer&&this._buffers.push(c.paintVertexBuffer)}}upload(a){for(const b in this.binders){const c=this.binders[b];(c instanceof gc||c instanceof gd||c instanceof ge)&&c.upload(a)}this.updatePaintBuffers()}destroy(){for(const a in this.binders){const b=this.binders[a];(b instanceof gc||b instanceof gd||b instanceof ge)&&b.destroy()}}}class gg{constructor(a,b,c=()=>!0){for(const d of(this.programConfigurations={},a))this.programConfigurations[d.id]=new gf(d,b,c);this.needsUpload=!1,this._featureMap=new f$,this._bufferOffset=0}populatePaintArrays(a,b,c,d,f,g,h){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(a,b,d,f,g,h);void 0!==b.id&&this._featureMap.add(b.id,c,this._bufferOffset,a),this._bufferOffset=a,this.needsUpload=!0}updatePaintArrays(a,b,c,d,f){for(const g of c)this.needsUpload=this.programConfigurations[g.id].updatePaintArrays(a,this._featureMap,b,g,d,f)||this.needsUpload}get(a){return this.programConfigurations[a]}upload(a){if(this.needsUpload){for(const b in this.programConfigurations)this.programConfigurations[b].upload(a);this.needsUpload=!1}}destroy(){for(const a in this.programConfigurations)this.programConfigurations[a].destroy()}}const gh={"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 gi(a,b){return gh[a]||[a.replace(`${b}-`,"").replace(/-/g,"_"),]}const gj={"line-pattern":{source:fq,composite:fq},"fill-pattern":{source:fq,composite:fq},"fill-extrusion-pattern":{source:fq,composite:fq},"line-dasharray":{source:fr,composite:fr}},gk={color:{source:fH,composite:fI},number:{source:fB,composite:fH}};function gl(a,b,c){const d=gj[a];return d&&d[c]||gk[b][c]}ec("ConstantBinder",ga),ec("CrossFadedConstantBinder",gb),ec("SourceExpressionBinder",gc),ec("CrossFadedCompositeBinder",ge),ec("CompositeExpressionBinder",gd),ec("ProgramConfiguration",gf,{omit:["_buffers"]}),ec("ProgramConfigurationSet",gg);const gm="-transition";class gn extends bj{constructor(a,b){if(super(),this.id=a.id,this.type=a.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==a.type&&(this.metadata=a.metadata,this.minzoom=a.minzoom,this.maxzoom=a.maxzoom,"background"!==a.type&&"sky"!==a.type&&(this.source=a.source,this.sourceLayer=a["source-layer"],this.filter=a.filter),b.layout&&(this._unevaluatedLayout=new class{constructor(a){this._properties=a,this._values=Object.create(a.defaultPropertyValues)}getValue(a){return ak(this._values[a].value)}setValue(a,b){this._values[a]=new e3(this._values[a].property,null===b?void 0:ak(b))}serialize(){const a={};for(const b of Object.keys(this._values)){const c=this.getValue(b);void 0!==c&&(a[b]=c)}return a}possiblyEvaluate(a,b,c){const d=new e9(this._properties);for(const f of Object.keys(this._values))d._values[f]=this._values[f].possiblyEvaluate(a,b,c);return d}}(b.layout)),b.paint)){for(const c in this._transitionablePaint=new e5(b.paint),a.paint)this.setPaintProperty(c,a.paint[c],{validate:!1});for(const d in a.layout)this.setLayoutProperty(d,a.layout[d],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new e9(b.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(a){return"visibility"===a?this.visibility:this._unevaluatedLayout.getValue(a)}setLayoutProperty(a,b,c={}){null!=b&&this._validate(d5,`layers.${this.id}.layout.${a}`,a,b,c)||("visibility"!==a?this._unevaluatedLayout.setValue(a,b):this.visibility=b)}getPaintProperty(a){return ah(a,gm)?this._transitionablePaint.getTransition(a.slice(0,-gm.length)):this._transitionablePaint.getValue(a)}setPaintProperty(a,b,c={}){if(null!=b&&this._validate(d4,`layers.${this.id}.paint.${a}`,a,b,c))return!1;if(ah(a,gm))return this._transitionablePaint.setTransition(a.slice(0,-gm.length),b||void 0),!1;{const d=this._transitionablePaint._values[a],f="cross-faded-data-driven"===d.property.specification["property-type"],g=d.value.isDataDriven(),h=d.value;this._transitionablePaint.setValue(a,b),this._handleSpecialPaintPropertyUpdate(a);const i=this._transitionablePaint._values[a].value;return i.isDataDriven()||g||f||this._handleOverridablePaintPropertyUpdate(a,h,i)}}_handleSpecialPaintPropertyUpdate(a){}getProgramIds(){return null}getProgramConfiguration(a){return null}_handleOverridablePaintPropertyUpdate(a,b,c){return!1}isHidden(a){return!!(this.minzoom&&a<this.minzoom)||!!(this.maxzoom&&a>=this.maxzoom)||"none"===this.visibility}updateTransitions(a){this._transitioningPaint=this._transitionablePaint.transitioned(a,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(a,b){a.getCrossfadeParameters&&(this._crossfadeParameters=a.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(a,void 0,b)),this.paint=this._transitioningPaint.possiblyEvaluate(a,void 0,b)}serialize(){const a={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&&(a.layout=a.layout||{},a.layout.visibility=this.visibility),aj(a,(a,b)=>!(void 0===a||"layout"===b&&!Object.keys(a).length||"paint"===b&&!Object.keys(a).length))}_validate(a,b,c,d,f={}){return(!f|| !1!==f.validate)&&d6(this,a.call(d1,{key:b,layerType:this.type,objectKey:c,value:d,styleSpec:bk,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const a in this.paint._values){const b=this.paint.get(a);if(b instanceof e8&&c6(b.property.specification)&&("source"===b.value.kind||"composite"===b.value.kind)&&b.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=dz(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const go=fk([{name:"a_pos",components:2,type:"Int16"},],4),{members:gp}=go;class gq{constructor(a=[]){this.segments=a}prepareSegment(a,b,c,d){let f=this.segments[this.segments.length-1];return a>gq.MAX_VERTEX_ARRAY_LENGTH&&am(`Max vertices per segment is ${gq.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${a}`),(!f||f.vertexLength+a>gq.MAX_VERTEX_ARRAY_LENGTH||f.sortKey!==d)&&(f={vertexOffset:b.length,primitiveOffset:c.length,vertexLength:0,primitiveLength:0},void 0!==d&&(f.sortKey=d),this.segments.push(f)),f}get(){return this.segments}destroy(){for(const a of this.segments)for(const b in a.vaos)a.vaos[b].destroy()}static simpleSegment(a,b,c,d){return new gq([{vertexOffset:a,primitiveOffset:b,vertexLength:c,primitiveLength:d,vaos:{},sortKey:0},])}}gq.MAX_VERTEX_ARRAY_LENGTH=65535,ec("SegmentVector",gq);class gr{constructor(a,b){a&&(b?this.setSouthWest(a).setNorthEast(b):4===a.length?this.setSouthWest([a[0],a[1],]).setNorthEast([a[2],a[3]]):this.setSouthWest(a[0]).setNorthEast(a[1]))}setNorthEast(a){return this._ne=a instanceof gs?new gs(a.lng,a.lat):gs.convert(a),this}setSouthWest(a){return this._sw=a instanceof gs?new gs(a.lng,a.lat):gs.convert(a),this}extend(a){const b=this._sw,c=this._ne;let d,f;if(a instanceof gs)d=a,f=a;else{if(!(a instanceof gr))return Array.isArray(a)?4===a.length||a.every(Array.isArray)?this.extend(gr.convert(a)):this.extend(gs.convert(a)):this;if(d=a._sw,f=a._ne,!d||!f)return this}return b||c?(b.lng=Math.min(d.lng,b.lng),b.lat=Math.min(d.lat,b.lat),c.lng=Math.max(f.lng,c.lng),c.lat=Math.max(f.lat,c.lat)):(this._sw=new gs(d.lng,d.lat),this._ne=new gs(f.lng,f.lat)),this}getCenter(){return new gs((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 gs(this.getWest(),this.getNorth())}getSouthEast(){return new gs(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(a){const{lng:b,lat:c}=gs.convert(a);let d=this._sw.lng<=b&&b<=this._ne.lng;return this._sw.lng>this._ne.lng&&(d=this._sw.lng>=b&&b>=this._ne.lng),this._sw.lat<=c&&c<=this._ne.lat&&d}static convert(a){return!a||a instanceof gr?a:new gr(a)}}class gs{constructor(a,b){if(isNaN(a)||isNaN(b))throw Error(`Invalid LngLat object: (${a}, ${b})`);if(this.lng=+a,this.lat=+b,this.lat>90||this.lat< -90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new gs(Z(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(a){const b=Math.PI/180,c=this.lat*b,d=a.lat*b,f=Math.sin(c)*Math.sin(d)+Math.cos(c)*Math.cos(d)*Math.cos((a.lng-this.lng)*b);return 6371008.8*Math.acos(Math.min(f,1))}toBounds(a=0){const b=360*a/40075017,c=b/Math.cos(Math.PI/180*this.lat);return new gr(new gs(this.lng-c,this.lat-b),new gs(this.lng+c,this.lat+b))}static convert(a){if(a instanceof gs)return a;if(Array.isArray(a)&&(2===a.length||3===a.length))return new gs(Number(a[0]),Number(a[1]));if(!Array.isArray(a)&&"object"==typeof a&&null!==a)return new gs(Number("lng"in a?a.lng:a.lon),Number(a.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const gt=2*Math.PI*6371008.8;function gu(a){return gt*Math.cos(a*Math.PI/180)}function gv(a){return(180+a)/360}function gw(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function gx(a,b){return a/gu(b)}function gy(a){return 360*a-180}function gz(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function gA(a,b){return a*gu(gz(b))}class gB{constructor(a,b,c=0){this.x=+a,this.y=+b,this.z=+c}static fromLngLat(a,b=0){const c=gs.convert(a);return new gB(gv(c.lng),gw(c.lat),gx(b,c.lat))}toLngLat(){return new gs(gy(this.x),gz(this.y))}toAltitude(){return gA(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/gt*(1/Math.cos(gz(this.y)*Math.PI/180))}}function gC(a,b,c,d,f,h,i,j,k){const l=(b+d)/2,m=(c+f)/2,n=new g(l,m);j(n),function(a,b,c,d,f,g){const h=c-f,i=d-g;return Math.abs((d-b)*h-(c-a)*i)/Math.hypot(h,i)}(n.x,n.y,h.x,h.y,i.x,i.y)>=k?(gC(a,b,c,l,m,h,n,j,k),gC(a,l,m,d,f,n,i,j,k)):a.push(i)}function gD(a,b,c){const d=[];let f,g,h;for(const i of a){const{x:j,y:k}=i;b(i),h?gC(d,f,g,j,k,h,i,b,c):d.push(i),f=j,g=k,h=i}return d}function gE(a,b){const c=Math.round(a.x*b),d=Math.round(a.y*b);return a.x=X(c,-16384,16383),a.y=X(d,-16384,16383),(c<a.x||c>a.x+1||d<a.y||d>a.y+1)&&am("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function gF(a,b,c){const d=a.loadGeometry(),f=a.extent,g=8192/f;if(b&&c&&c.projection.isReprojectedInTileSpace){const h=1<<b.z,{scale:i,x:j,y:k,projection:l}=c,m=a=>{const c=gy((b.x+a.x/f)/h),d=gz((b.y+a.y/f)/h),g=l.project(c,d);a.x=(g.x*i-j)*f,a.y=(g.y*i-k)*f};for(let n=0;n<d.length;n++)if(1!==a.type)d[n]=gD(d[n],m,1);else{const o=[];for(const p of d[n])p.x<0||p.x>=f||p.y<0||p.y>=f||(m(p),o.push(p));d[n]=o}}for(const q of d)for(const r of q)gE(r,g);return d}function gG(a,b){return{type:a.type,id:a.id,properties:a.properties,geometry:b?gF(a):[]}}function gH(a,b,c,d,f){a.emplaceBack(2*b+(d+1)/2,2*c+(f+1)/2)}class gI{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new fm,this.indexArray=new fy,this.segments=new gq,this.programConfigurations=new gg(a.layers,a.zoom),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(a,b,c,d){const f=this.layers[0],g=[];let h=null;for(const{feature:i,id:j,index:k,sourceLayerIndex:l}of("circle"===f.type&&(h=f.layout.get("circle-sort-key")),a)){const m=this.layers[0]._featureFilter.needGeometry,n=gG(i,m);if(!this.layers[0]._featureFilter.filter(new e2(this.zoom),n,c))continue;const o=h?h.evaluate(n,{},c):void 0,p={id:j,properties:i.properties,type:i.type,sourceLayerIndex:l,index:k,geometry:m?n.geometry:gF(i,c,d),patterns:{},sortKey:o};g.push(p)}for(const q of(h&&g.sort((a,b)=>a.sortKey-b.sortKey),g)){const{geometry:r,index:s,sourceLayerIndex:u}=q,v=a[s].feature;this.addFeature(q,r,s,b.availableImages,c),b.featureIndex.insert(v,r,s,u,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,gp),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(a,b,c,d,f){for(const g of b)for(const h of g){const i=h.x,j=h.y;if(i<0||i>=8192||j<0||j>=8192)continue;const k=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,a.sortKey),l=k.vertexLength;gH(this.layoutVertexArray,i,j,-1,-1),gH(this.layoutVertexArray,i,j,1,-1),gH(this.layoutVertexArray,i,j,1,1),gH(this.layoutVertexArray,i,j,-1,1),this.indexArray.emplaceBack(l,l+1,l+2),this.indexArray.emplaceBack(l,l+3,l+2),k.vertexLength+=4,k.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,a,c,{},d,f)}}function gJ(a,b){for(let c=0;c<a.length;c++)if(gS(b,a[c]))return!0;for(let d=0;d<b.length;d++)if(gS(a,b[d]))return!0;return!!gN(a,b)}function gK(a,b,c){return!!gS(a,b)||!!gP(b,a,c)}function gL(a,b){if(1===a.length)return gR(b,a[0]);for(let c=0;c<b.length;c++){const d=b[c];for(let f=0;f<d.length;f++)if(gS(a,d[f]))return!0}for(let g=0;g<a.length;g++)if(gR(b,a[g]))return!0;for(let h=0;h<b.length;h++)if(gN(a,b[h]))return!0;return!1}function gM(a,b,c){if(a.length>1){if(gN(a,b))return!0;for(let d=0;d<b.length;d++)if(gP(b[d],a,c))return!0}for(let f=0;f<a.length;f++)if(gP(a[f],b,c))return!0;return!1}function gN(a,b){if(0===a.length||0===b.length)return!1;for(let c=0;c<a.length-1;c++){const d=a[c],f=a[c+1];for(let g=0;g<b.length-1;g++)if(gO(d,f,b[g],b[g+1]))return!0}return!1}function gO(a,b,c,d){return an(a,c,d)!==an(b,c,d)&&an(a,b,c)!==an(a,b,d)}function gP(a,b,c){const d=c*c;if(1===b.length)return a.distSqr(b[0])<d;for(let f=1;f<b.length;f++)if(gQ(a,b[f-1],b[f])<d)return!0;return!1}function gQ(a,b,c){const d=b.distSqr(c);if(0===d)return a.distSqr(b);const f=((a.x-b.x)*(c.x-b.x)+(a.y-b.y)*(c.y-b.y))/d;return a.distSqr(f<0?b:f>1?c:c.sub(b)._mult(f)._add(b))}function gR(a,b){let c,d,f,g=!1;for(let h=0;h<a.length;h++){c=a[h];for(let i=0,j=c.length-1;i<c.length;j=i++)d=c[i],f=c[j],d.y>b.y!=f.y>b.y&&b.x<(f.x-d.x)*(b.y-d.y)/(f.y-d.y)+d.x&&(g=!g)}return g}function gS(a,b){let c=!1;for(let d=0,f=a.length-1;d<a.length;f=d++){const g=a[d],h=a[f];g.y>b.y!=h.y>b.y&&b.x<(h.x-g.x)*(b.y-g.y)/(h.y-g.y)+g.x&&(c=!c)}return c}function gT(a,b,c,d,f){for(const h of a)if(b<=h.x&&c<=h.y&&d>=h.x&&f>=h.y)return!0;const i=[new g(b,c),new g(b,f),new g(d,f),new g(d,c),];if(a.length>2){for(const j of i)if(gS(a,j))return!0}for(let k=0;k<a.length-1;k++)if(gU(a[k],a[k+1],i))return!0;return!1}function gU(a,b,c){const d=c[0],f=c[2];if(a.x<d.x&&b.x<d.x||a.x>f.x&&b.x>f.x||a.y<d.y&&b.y<d.y||a.y>f.y&&b.y>f.y)return!1;const g=an(a,b,c[0]);return g!==an(a,b,c[1])||g!==an(a,b,c[2])||g!==an(a,b,c[3])}function gV(a,b,c){const d=b.paint.get(a).value;return"constant"===d.kind?d.value:c.programConfigurations.get(b.id).getMaxValue(a)}function gW(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function gX(a,b,c,d,f){if(!b[0]&&!b[1])return a;const h=g.convert(b)._mult(f);"viewport"===c&&h._rotate(-d);const i=[];for(let j=0;j<a.length;j++)i.push(a[j].sub(h));return i}function gY(a,b,c,d){const f=g.convert(a)._mult(d);return"viewport"===b&&f._rotate(-c),f}ec("CircleBucket",gI,{omit:["layers"]});const gZ=new ff({"circle-sort-key":new fb(bk.layout_circle["circle-sort-key"])});var g$={paint:new ff({"circle-radius":new fb(bk.paint_circle["circle-radius"]),"circle-color":new fb(bk.paint_circle["circle-color"]),"circle-blur":new fb(bk.paint_circle["circle-blur"]),"circle-opacity":new fb(bk.paint_circle["circle-opacity"]),"circle-translate":new fa(bk.paint_circle["circle-translate"]),"circle-translate-anchor":new fa(bk.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new fa(bk.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new fa(bk.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new fb(bk.paint_circle["circle-stroke-width"]),"circle-stroke-color":new fb(bk.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new fb(bk.paint_circle["circle-stroke-opacity"])}),layout:gZ};class g_{constructor(a,b){this.points=a,this.planes=b}static fromInvProjectionMatrix(a,b,c,d){const f=Math.pow(2,c),g=[[-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(c=>{var g,h,i;const j=K([],c,a),k=1/j[3]/b*f;return g=j,h=j,i=[k,k,d?1/j[3]:k,k],g[0]=h[0]*i[0],g[1]=h[1]*i[1],g[2]=h[2]*i[2],g[3]=h[3]*i[3],g}),h=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5],].map(a=>{const b=D([],F([],J([],g[a[0]],g[a[1]]),J([],g[a[2]],g[a[1]]))),c=-E(b,g[a[1]]);return b.concat(c)});return new g_(g,h)}}class g0{constructor(a,b){this.min=a,this.max=b,this.center=B([],x([],this.min,this.max),.5)}quadrant(a){const b=[a%2==0,a<2],c=u(this.min),d=u(this.max);for(let f=0;f<b.length;f++)c[f]=b[f]?this.min[f]:this.center[f],d[f]=b[f]?this.center[f]:this.max[f];return d[2]=this.max[2],new g0(c,d)}distanceX(a){return Math.max(Math.min(this.max[0],a[0]),this.min[0])-a[0]}distanceY(a){return Math.max(Math.min(this.max[1],a[1]),this.min[1])-a[1]}distanceZ(a){return Math.max(Math.min(this.max[2],a[2]),this.min[2])-a[2]}getCorners(){const a=this.min,b=this.max;return[[a[0],a[1],a[2]],[b[0],a[1],a[2]],[b[0],b[1],a[2]],[a[0],b[1],a[2]],[a[0],a[1],b[2]],[b[0],a[1],b[2]],[b[0],b[1],b[2]],[a[0],b[1],b[2]],]}intersects(a){const b=this.getCorners();let c=!0;for(let d=0;d<a.planes.length;d++){const f=a.planes[d];let g=0;for(let h=0;h<b.length;h++)g+=E(f,b[h])+f[3]>=0;if(0===g)return 0;g!==b.length&&(c=!1)}if(c)return 2;for(let i=0;i<3;i++){let j=Number.MAX_VALUE,k=-Number.MAX_VALUE;for(let l=0;l<a.points.length;l++){const m=a.points[l][i]-this.min[i];j=Math.min(j,m),k=Math.max(k,m)}if(k<0||j>this.max[i]-this.min[i])return 0}return 1}}function g1(a,b,c,d,f,g,h,i,j){if(g&&a.queryGeometry.isAboveHorizon)return!1;for(const k of(g&&(j*=a.pixelToTileUnitsFactor),b))for(const l of k){const m=l.add(i),n=f&&c.elevation?c.elevation.exaggeration()*f.getElevationAt(m.x,m.y,!0):0,o=g?m:g2(m,n,d),p=g?a.tilespaceRays.map(a=>g5(a,n)):a.queryGeometry.screenGeometry,q=K([],[l.x,l.y,n,1],d);if(!h&&g?j*=q[3]/c.cameraToCenterDistance:h&&!g&&(j*=c.cameraToCenterDistance/q[3]),gK(p,o,j))return!0}return!1}function g2(a,b,c){const d=K([],[a.x,a.y,b,1],c);return new g(d[0]/d[3],d[1]/d[3])}const g3=w(0,0,0),g4=w(0,0,1);function g5(a,b){const c=s();return g3[2]=b,a.intersectsPlane(g3,g4,c),new g(c[0],c[1])}class g6 extends gI{}function g7(a,{width:b,height:c},d,f){if(f){if(f instanceof Uint8ClampedArray)f=new Uint8Array(f.buffer);else if(f.length!==b*c*d)throw RangeError("mismatched image size")}else f=new Uint8Array(b*c*d);return a.width=b,a.height=c,a.data=f,a}function g8(a,{width:b,height:c},d){if(b===a.width&&c===a.height)return;const f=g7({},{width:b,height:c},d);g9(a,f,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,b),height:Math.min(a.height,c)},d),a.width=b,a.height=c,a.data=f.data}function g9(a,b,c,d,f,g){if(0===f.width||0===f.height)return b;if(f.width>a.width||f.height>a.height||c.x>a.width-f.width||c.y>a.height-f.height)throw RangeError("out of range source coordinates for image copy");if(f.width>b.width||f.height>b.height||d.x>b.width-f.width||d.y>b.height-f.height)throw RangeError("out of range destination coordinates for image copy");const h=a.data,i=b.data;for(let j=0;j<f.height;j++){const k=((c.y+j)*a.width+c.x)*g,l=((d.y+j)*b.width+d.x)*g;for(let m=0;m<f.width*g;m++)i[l+m]=h[k+m]}return b}ec("HeatmapBucket",g6,{omit:["layers"]});class ha{constructor(a,b){g7(this,a,1,b)}resize(a){g8(this,a,1)}clone(){return new ha({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(a,b,c,d,f){g9(a,b,c,d,f,1)}}class hb{constructor(a,b){g7(this,a,4,b)}resize(a){g8(this,a,4)}replace(a,b){b?this.data.set(a):this.data=a instanceof Uint8ClampedArray?new Uint8Array(a.buffer):a}clone(){return new hb({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(a,b,c,d,f){g9(a,b,c,d,f,4)}}ec("AlphaImage",ha),ec("RGBAImage",hb);var hc={paint:new ff({"heatmap-radius":new fb(bk.paint_heatmap["heatmap-radius"]),"heatmap-weight":new fb(bk.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new fa(bk.paint_heatmap["heatmap-intensity"]),"heatmap-color":new fe(bk.paint_heatmap["heatmap-color"]),"heatmap-opacity":new fa(bk.paint_heatmap["heatmap-opacity"])})};function hd(a){const b={},c=a.resolution||256,d=a.clips?a.clips.length:1,f=a.image||new hb({width:c,height:d}),g=(c,d,g)=>{b[a.evaluationKey]=g;const h=a.expression.evaluate(b);f.data[c+d+0]=Math.floor(255*h.r/h.a),f.data[c+d+1]=Math.floor(255*h.g/h.a),f.data[c+d+2]=Math.floor(255*h.b/h.a),f.data[c+d+3]=Math.floor(255*h.a)};if(a.clips)for(let h=0,i=0;h<d;++h,i+=4*c)for(let j=0,k=0;j<c;j++,k+=4){const l=j/(c-1),{start:m,end:n}=a.clips[h];g(i,k,m*(1-l)+n*l)}else for(let o=0,p=0;o<c;o++,p+=4)g(0,p,o/(c-1));return f}var he={paint:new ff({"hillshade-illumination-direction":new fa(bk.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new fa(bk.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new fa(bk.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new fa(bk.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new fa(bk.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new fa(bk.paint_hillshade["hillshade-accent-color"])})};const hf=fk([{name:"a_pos",components:2,type:"Int16"},],4),{members:hg}=hf;var hh=hi;function hi(a,b,c){c=c||2;var d,f,g,h,i,j,k,l=b&&b.length,m=l?b[0]*c:a.length,n=hj(a,0,m,c,!0),o=[];if(!n||n.next===n.prev)return o;if(l&&(n=function(a,b,c,d){var f,g,h,i=[];for(f=0,g=b.length;f<g;f++)(h=hj(a,b[f]*d,f<g-1?b[f+1]*d:a.length,d,!1))===h.next&&(h.steiner=!0),i.push(hu(h));for(i.sort(hq),f=0;f<i.length;f++)c=hk(c=hr(i[f],c),c.next);return c}(a,b,n,c)),a.length>80*c){d=g=a[0],f=h=a[1];for(var p=c;p<m;p+=c)(i=a[p])<d&&(d=i),(j=a[p+1])<f&&(f=j),i>g&&(g=i),j>h&&(h=j);k=0!==(k=Math.max(g-d,h-f))?1/k:0}return hl(n,o,c,d,f,k),o}function hj(a,b,c,d,f){var g,h;if(f===hH(a,b,c,d)>0)for(g=b;g<c;g+=d)h=hE(g,a[g],a[g+1],h);else for(g=c-d;g>=b;g-=d)h=hE(g,a[g],a[g+1],h);return h&&hy(h,h.next)&&(hF(h),h=h.next),h}function hk(a,b){if(!a)return a;b||(b=a);var c,d=a;do if(c=!1,d.steiner|| !hy(d,d.next)&&0!==hx(d.prev,d,d.next))d=d.next;else{if(hF(d),(d=b=d.prev)===d.next)break;c=!0}while(c||d!==b)return b}function hl(a,b,c,d,f,g,h){if(a){!h&&g&&function(a,b,c,d){var f=a;do null===f.z&&(f.z=ht(f.x,f.y,b,c,d)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==a)f.prevZ.nextZ=null,f.prevZ=null,function(a){var b,c,d,f,g,h,i,j,k=1;do{for(c=a,a=null,g=null,h=0;c;){for(h++,d=c,i=0,b=0;b<k&&(i++,d=d.nextZ);b++);for(j=k;i>0||j>0&&d;)0!==i&&(0===j||!d||c.z<=d.z)?(f=c,c=c.nextZ,i--):(f=d,d=d.nextZ,j--),g?g.nextZ=f:a=f,f.prevZ=g,g=f;c=d}g.nextZ=null,k*=2}while(h>1)}(f)}(a,d,f,g);for(var i,j,k=a;a.prev!==a.next;)if(i=a.prev,j=a.next,g?hn(a,d,f,g):hm(a))b.push(i.i/c),b.push(a.i/c),b.push(j.i/c),hF(a),a=j.next,k=j.next;else if((a=j)===k){h?1===h?hl(a=ho(hk(a),b,c),b,c,d,f,g,2):2===h&&hp(a,b,c,d,f,g):hl(hk(a),b,c,d,f,g,1);break}}}function hm(a){var b=a.prev,c=a,d=a.next;if(hx(b,c,d)>=0)return!1;for(var f=a.next.next;f!==a.prev;){if(hv(b.x,b.y,c.x,c.y,d.x,d.y,f.x,f.y)&&hx(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function hn(a,b,c,d){var f=a.prev,g=a,h=a.next;if(hx(f,g,h)>=0)return!1;for(var i=f.x>g.x?f.x>h.x?f.x:h.x:g.x>h.x?g.x:h.x,j=f.y>g.y?f.y>h.y?f.y:h.y:g.y>h.y?g.y:h.y,k=ht(f.x<g.x?f.x<h.x?f.x:h.x:g.x<h.x?g.x:h.x,f.y<g.y?f.y<h.y?f.y:h.y:g.y<h.y?g.y:h.y,b,c,d),l=ht(i,j,b,c,d),m=a.prevZ,n=a.nextZ;m&&m.z>=k&&n&&n.z<=l;){if(m!==a.prev&&m!==a.next&&hv(f.x,f.y,g.x,g.y,h.x,h.y,m.x,m.y)&&hx(m.prev,m,m.next)>=0||(m=m.prevZ,n!==a.prev&&n!==a.next&&hv(f.x,f.y,g.x,g.y,h.x,h.y,n.x,n.y)&&hx(n.prev,n,n.next)>=0))return!1;n=n.nextZ}for(;m&&m.z>=k;){if(m!==a.prev&&m!==a.next&&hv(f.x,f.y,g.x,g.y,h.x,h.y,m.x,m.y)&&hx(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;n&&n.z<=l;){if(n!==a.prev&&n!==a.next&&hv(f.x,f.y,g.x,g.y,h.x,h.y,n.x,n.y)&&hx(n.prev,n,n.next)>=0)return!1;n=n.nextZ}return!0}function ho(a,b,c){var d=a;do{var f=d.prev,g=d.next.next;!hy(f,g)&&hz(f,d,d.next,g)&&hC(f,g)&&hC(g,f)&&(b.push(f.i/c),b.push(d.i/c),b.push(g.i/c),hF(d),hF(d.next),d=a=g),d=d.next}while(d!==a)return hk(d)}function hp(a,b,c,d,f,g){var h=a;do{for(var i=h.next.next;i!==h.prev;){if(h.i!==i.i&&hw(h,i)){var j=hD(h,i);return h=hk(h,h.next),j=hk(j,j.next),hl(h,b,c,d,f,g),void hl(j,b,c,d,f,g)}i=i.next}h=h.next}while(h!==a)}function hq(a,b){return a.x-b.x}function hr(a,b){var c=function(a,b){var c,d=b,f=a.x,g=a.y,h=-1/0;do{if(g<=d.y&&g>=d.next.y&&d.next.y!==d.y){var i=d.x+(g-d.y)*(d.next.x-d.x)/(d.next.y-d.y);if(i<=f&&i>h){if(h=i,i===f){if(g===d.y)return d;if(g===d.next.y)return d.next}c=d.x<d.next.x?d:d.next}}d=d.next}while(d!==b)if(!c)return null;if(f===h)return c;var j,k=c,l=c.x,m=c.y,n=1/0;d=c;do f>=d.x&&d.x>=l&&f!==d.x&&hv(g<m?f:h,g,l,m,g<m?h:f,g,d.x,d.y)&&(j=Math.abs(g-d.y)/(f-d.x),hC(d,a)&&(j<n||j===n&&(d.x>c.x||d.x===c.x&&hs(c,d)))&&(c=d,n=j)),d=d.next;while(d!==k)return c}(a,b);if(!c)return b;var d=hD(c,a),f=hk(c,c.next);return hk(d,d.next),b===c?f:b}function hs(a,b){return 0>hx(a.prev,a,b.prev)&&0>hx(b.next,a,a.next)}function ht(a,b,c,d,f){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-c)*f)|a<<8))|a<<4))|a<<2))|a<<1))|(b=1431655765&((b=858993459&((b=252645135&((b=16711935&((b=32767*(b-d)*f)|b<<8))|b<<4))|b<<2))|b<<1))<<1}function hu(a){var b=a,c=a;do(b.x<c.x||b.x===c.x&&b.y<c.y)&&(c=b),b=b.next;while(b!==a)return c}function hv(a,b,c,d,f,g,h,i){return(f-h)*(b-i)-(a-h)*(g-i)>=0&&(a-h)*(d-i)-(c-h)*(b-i)>=0&&(c-h)*(g-i)-(f-h)*(d-i)>=0}function hw(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(a,b){var c=a;do{if(c.i!==a.i&&c.next.i!==a.i&&c.i!==b.i&&c.next.i!==b.i&&hz(c,c.next,a,b))return!0;c=c.next}while(c!==a)return!1}(a,b)&&(hC(a,b)&&hC(b,a)&&function(a,b){var c=a,d=!1,f=(a.x+b.x)/2,g=(a.y+b.y)/2;do c.y>g!=c.next.y>g&&c.next.y!==c.y&&f<(c.next.x-c.x)*(g-c.y)/(c.next.y-c.y)+c.x&&(d=!d),c=c.next;while(c!==a)return d}(a,b)&&(hx(a.prev,a,b.prev)||hx(a,b.prev,b))||hy(a,b)&&hx(a.prev,a,a.next)>0&&hx(b.prev,b,b.next)>0)}function hx(a,b,c){return(b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y)}function hy(a,b){return a.x===b.x&&a.y===b.y}function hz(a,b,c,d){var f=hB(hx(a,b,c)),g=hB(hx(a,b,d)),h=hB(hx(c,d,a)),i=hB(hx(c,d,b));return f!==g&&h!==i||!(0!==f||!hA(a,c,b))||!(0!==g||!hA(a,d,b))||!(0!==h||!hA(c,a,d))||!(0!==i||!hA(c,b,d))}function hA(a,b,c){return b.x<=Math.max(a.x,c.x)&&b.x>=Math.min(a.x,c.x)&&b.y<=Math.max(a.y,c.y)&&b.y>=Math.min(a.y,c.y)}function hB(a){return a>0?1:a<0?-1:0}function hC(a,b){return 0>hx(a.prev,a,a.next)?hx(a,b,a.next)>=0&&hx(a,a.prev,b)>=0:0>hx(a,b,a.prev)||0>hx(a,a.next,b)}function hD(a,b){var c=new hG(a.i,a.x,a.y),d=new hG(b.i,b.x,b.y),f=a.next,g=b.prev;return a.next=b,b.prev=a,c.next=f,f.prev=c,d.next=c,c.prev=d,g.next=d,d.prev=g,d}function hE(a,b,c,d){var f=new hG(a,b,c);return d?(f.next=d.next,f.prev=d,d.next.prev=f,d.next=f):(f.prev=f,f.next=f),f}function hF(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function hG(a,b,c){this.i=a,this.x=b,this.y=c,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function hH(a,b,c,d){for(var f=0,g=b,h=c-d;g<c;g+=d)f+=(a[h]-a[g])*(a[g+1]+a[h+1]),h=g;return f}function hI(a,b,c,d,f){hJ(a,b,c||0,d||a.length-1,f||hL)}function hJ(a,b,c,d,f){for(;d>c;){if(d-c>600){var g=d-c+1,h=b-c+1,i=Math.log(g),j=.5*Math.exp(2*i/3),k=.5*Math.sqrt(i*j*(g-j)/g)*(h-g/2<0?-1:1);hJ(a,b,Math.max(c,Math.floor(b-h*j/g+k)),Math.min(d,Math.floor(b+(g-h)*j/g+k)),f)}var l=a[b],m=c,n=d;for(hK(a,c,b),f(a[d],l)>0&&hK(a,c,d);m<n;){for(hK(a,m,n),m++,n--;0>f(a[m],l);)m++;for(;f(a[n],l)>0;)n--}0===f(a[c],l)?hK(a,c,n):hK(a,++n,d),n<=b&&(c=n+1),b<=n&&(d=n-1)}}function hK(a,b,c){var d=a[b];a[b]=a[c],a[c]=d}function hL(a,b){return a<b?-1:a>b?1:0}function hM(a,b){const c=a.length;if(c<=1)return[a];const d=[];let f,g;for(let h=0;h<c;h++){const i=ao(a[h]);0!==i&&(a[h].area=Math.abs(i),void 0===g&&(g=i<0),g===i<0?(f&&d.push(f),f=[a[h]]):f.push(a[h]))}if(f&&d.push(f),b>1)for(let j=0;j<d.length;j++)d[j].length<=b||(hI(d[j],b,1,d[j].length-1,hN),d[j]=d[j].slice(0,b));return d}function hN(a,b){return b.area-a.area}function hO(a,b,c){const d=c.patternDependencies;let f=!1;for(const g of b){const h=g.paint.get(`${a}-pattern`);h.isConstant()||(f=!0);const i=h.constantOr(null);i&&(f=!0,d[i.to]=!0,d[i.from]=!0)}return f}function hP(a,b,c,d,f){const g=f.patternDependencies;for(const h of b){const i=h.paint.get(`${a}-pattern`).value;if("constant"!==i.kind){let j=i.evaluate({zoom:d-1},c,{},f.availableImages),k=i.evaluate({zoom:d},c,{},f.availableImages),l=i.evaluate({zoom:d+1},c,{},f.availableImages);j=j&&j.name?j.name:j,k=k&&k.name?k.name:k,l=l&&l.name?l.name:l,g[j]=!0,g[k]=!0,g[l]=!0,c.patterns[h.id]={min:j,mid:k,max:l}}}return c}hi.deviation=function(a,b,c,d){var f=b&&b.length,g=Math.abs(hH(a,0,f?b[0]*c:a.length,c));if(f)for(var h=0,i=b.length;h<i;h++)g-=Math.abs(hH(a,b[h]*c,h<i-1?b[h+1]*c:a.length,c));var j=0;for(h=0;h<d.length;h+=3){var k=d[h]*c,l=d[h+1]*c,m=d[h+2]*c;j+=Math.abs((a[k]-a[m])*(a[l+1]-a[k+1])-(a[k]-a[l])*(a[m+1]-a[k+1]))}return 0===g&&0===j?0:Math.abs((j-g)/g)},hi.flatten=function(a){for(var b=a[0][0].length,c={vertices:[],holes:[],dimensions:b},d=0,f=0;f<a.length;f++){for(var g=0;g<a[f].length;g++)for(var h=0;h<b;h++)c.vertices.push(a[f][g][h]);f>0&&c.holes.push(d+=a[f-1].length)}return c},hh.default=hi;class hQ{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new fm,this.indexArray=new fy,this.indexArray2=new fF,this.programConfigurations=new gg(a.layers,a.zoom),this.segments=new gq,this.segments2=new gq,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(a,b,c,d){this.hasPattern=hO("fill",this.layers,b);const f=this.layers[0].layout.get("fill-sort-key"),g=[];for(const{feature:h,id:i,index:j,sourceLayerIndex:k}of a){const l=this.layers[0]._featureFilter.needGeometry,m=gG(h,l);if(!this.layers[0]._featureFilter.filter(new e2(this.zoom),m,c))continue;const n=f?f.evaluate(m,{},c,b.availableImages):void 0,o={id:i,properties:h.properties,type:h.type,sourceLayerIndex:k,index:j,geometry:l?m.geometry:gF(h,c,d),patterns:{},sortKey:n};g.push(o)}for(const p of(f&&g.sort((a,b)=>a.sortKey-b.sortKey),g)){const{geometry:q,index:r,sourceLayerIndex:s}=p;if(this.hasPattern){const u=hP("fill",this.layers,p,this.zoom,b);this.patternFeatures.push(u)}else this.addFeature(p,q,r,c,{},b.availableImages);b.featureIndex.insert(a[r].feature,q,r,s,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(a,b,c,d){for(const f of this.patternFeatures)this.addFeature(f,f.geometry,f.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,hg),this.indexBuffer=a.createIndexBuffer(this.indexArray),this.indexBuffer2=a.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(a),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(a,b,c,d,f,g=[]){for(const h of hM(b,500)){let i=0;for(const j of h)i+=j.length;const k=this.segments.prepareSegment(i,this.layoutVertexArray,this.indexArray),l=k.vertexLength,m=[],n=[];for(const o of h){if(0===o.length)continue;o!==h[0]&&n.push(m.length/2);const p=this.segments2.prepareSegment(o.length,this.layoutVertexArray,this.indexArray2),q=p.vertexLength;this.layoutVertexArray.emplaceBack(o[0].x,o[0].y),this.indexArray2.emplaceBack(q+o.length-1,q),m.push(o[0].x),m.push(o[0].y);for(let r=1;r<o.length;r++)this.layoutVertexArray.emplaceBack(o[r].x,o[r].y),this.indexArray2.emplaceBack(q+r-1,q+r),m.push(o[r].x),m.push(o[r].y);p.vertexLength+=o.length,p.primitiveLength+=o.length}const s=hh(m,n);for(let u=0;u<s.length;u+=3)this.indexArray.emplaceBack(l+s[u],l+s[u+1],l+s[u+2]);k.vertexLength+=i,k.primitiveLength+=s.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,a,c,f,g,d)}}ec("FillBucket",hQ,{omit:["layers","patternFeatures"]});const hR=new ff({"fill-sort-key":new fb(bk.layout_fill["fill-sort-key"])});var hS={paint:new ff({"fill-antialias":new fa(bk.paint_fill["fill-antialias"]),"fill-opacity":new fb(bk.paint_fill["fill-opacity"]),"fill-color":new fb(bk.paint_fill["fill-color"]),"fill-outline-color":new fb(bk.paint_fill["fill-outline-color"]),"fill-translate":new fa(bk.paint_fill["fill-translate"]),"fill-translate-anchor":new fa(bk.paint_fill["fill-translate-anchor"]),"fill-pattern":new fc(bk.paint_fill["fill-pattern"])}),layout:hR};const hT=fk([{name:"a_pos_normal_ed",components:4,type:"Int16"},]),hU=fk([{name:"a_centroid_pos",components:2,type:"Uint16"},]),{members:hV}=hT;var hW=hX;function hX(a,b,c,d,f){this.properties={},this.extent=c,this.type=0,this._pbf=a,this._geometry=-1,this._keys=d,this._values=f,a.readFields(hY,this,b)}function hY(a,b,c){1==a?b.id=c.readVarint():2==a?function(a,b){for(var c=a.readVarint()+a.pos;a.pos<c;){var d=b._keys[a.readVarint()],f=b._values[a.readVarint()];b.properties[d]=f}}(c,b):3==a?b.type=c.readVarint():4==a&&(b._geometry=c.pos)}function hZ(a){for(var b,c,d=0,f=0,g=a.length,h=g-1;f<g;h=f++)d+=((c=a[h]).x-(b=a[f]).x)*(b.y+c.y);return d}hX.types=["Unknown","Point","LineString","Polygon",],hX.prototype.loadGeometry=function(){var a=this._pbf;a.pos=this._geometry;for(var b,c=a.readVarint()+a.pos,d=1,f=0,h=0,i=0,j=[];a.pos<c;){if(f<=0){var k=a.readVarint();d=7&k,f=k>>3}if(f--,1===d||2===d)h+=a.readSVarint(),i+=a.readSVarint(),1===d&&(b&&j.push(b),b=[]),b.push(new g(h,i));else{if(7!==d)throw Error("unknown command "+d);b&&b.push(b[0].clone())}}return b&&j.push(b),j},hX.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var b=a.readVarint()+a.pos,c=1,d=0,f=0,g=0,h=1/0,i=-1/0,j=1/0,k=-1/0;a.pos<b;){if(d<=0){var l=a.readVarint();c=7&l,d=l>>3}if(d--,1===c||2===c)(f+=a.readSVarint())<h&&(h=f),f>i&&(i=f),(g+=a.readSVarint())<j&&(j=g),g>k&&(k=g);else if(7!==c)throw Error("unknown command "+c)}return[h,j,i,k]},hX.prototype.toGeoJSON=function(a,b,c){var d,f,g=this.extent*Math.pow(2,c),h=this.extent*a,i=this.extent*b,j=this.loadGeometry(),k=hX.types[this.type];function l(a){for(var b=0;b<a.length;b++){var c=a[b];a[b]=[360*(c.x+h)/g-180,360/Math.PI*Math.atan(Math.exp((180-360*(c.y+i)/g)*Math.PI/180))-90,]}}switch(this.type){case 1:var m=[];for(d=0;d<j.length;d++)m[d]=j[d][0];l(j=m);break;case 2:for(d=0;d<j.length;d++)l(j[d]);break;case 3:for(j=function(a){var b=a.length;if(b<=1)return[a];for(var c,d,f=[],g=0;g<b;g++){var h=hZ(a[g]);0!==h&&(void 0===d&&(d=h<0),d===h<0?(c&&f.push(c),c=[a[g]]):c.push(a[g]))}return c&&f.push(c),f}(j),d=0;d<j.length;d++)for(f=0;f<j[d].length;f++)l(j[d][f])}1===j.length?j=j[0]:k="Multi"+k;var n={type:"Feature",geometry:{type:k,coordinates:j},properties:this.properties};return"id"in this&&(n.id=this.id),n};var h$=h_;function h_(a,b){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=a,this._keys=[],this._values=[],this._features=[],a.readFields(h0,this,b),this.length=this._features.length}function h0(a,b,c){15===a?b.version=c.readVarint():1===a?b.name=c.readString():5===a?b.extent=c.readVarint():2===a?b._features.push(c.pos):3===a?b._keys.push(c.readString()):4===a&&b._values.push(function(a){for(var b=null,c=a.readVarint()+a.pos;a.pos<c;){var d=a.readVarint()>>3;b=1===d?a.readString():2===d?a.readFloat():3===d?a.readDouble():4===d?a.readVarint64():5===d?a.readVarint():6===d?a.readSVarint():7===d?a.readBoolean():null}return b}(c))}function h1(a,b,c){if(3===a){var d=new h$(c,c.readVarint()+c.pos);d.length&&(b[d.name]=d)}}h_.prototype.feature=function(a){if(a<0||a>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[a];var b=this._pbf.readVarint()+this._pbf.pos;return new hW(this._pbf,b,this.extent,this._keys,this._values)};var h2={VectorTile:function(a,b){this.layers=a.readFields(h1,{},b)},VectorTileFeature:hW,VectorTileLayer:h$};const h3=h2.VectorTileFeature.types;function h4(a,b,c,d,f,g,h,i){a.emplaceBack((b<<1)+h,(c<<1)+g,(Math.floor(8192*d)<<1)+f,Math.round(i))}class h5{constructor(){this.acc=new g(0,0),this.polyCount=[]}startRing(a){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new g(a.x,a.y),this.max=new g(a.x,a.y))}append(a,b){this.currentPolyCount.edges++,this.acc._add(a);let c=!!this.borders;const d=this.min,f=this.max;a.x<d.x?(d.x=a.x,c=!0):a.x>f.x&&(f.x=a.x,c=!0),a.y<d.y?(d.y=a.y,c=!0):a.y>f.y&&(f.y=a.y,c=!0),((0===a.x||8192===a.x)&&a.x===b.x)!=((0===a.y||8192===a.y)&&a.y===b.y)&&this.processBorderOverlap(a,b),c&&this.checkBorderIntersection(a,b)}checkBorderIntersection(a,b){b.x<0!=a.x<0&&this.addBorderIntersection(0,cr(b.y,a.y,(0-b.x)/(a.x-b.x))),b.x>8192!=a.x>8192&&this.addBorderIntersection(1,cr(b.y,a.y,(8192-b.x)/(a.x-b.x))),b.y<0!=a.y<0&&this.addBorderIntersection(2,cr(b.x,a.x,(0-b.y)/(a.y-b.y))),b.y>8192!=a.y>8192&&this.addBorderIntersection(3,cr(b.x,a.x,(8192-b.y)/(a.y-b.y)))}addBorderIntersection(a,b){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],]);const c=this.borders[a];b<c[0]&&(c[0]=b),b>c[1]&&(c[1]=b)}processBorderOverlap(a,b){if(a.x===b.x){if(a.y===b.y)return;const c=0===a.x?0:1;this.addBorderIntersection(c,b.y),this.addBorderIntersection(c,a.y)}else{const d=0===a.y?2:3;this.addBorderIntersection(d,b.x),this.addBorderIntersection(d,a.x)}}centroid(){const a=this.polyCount.reduce((a,b)=>a+b.edges,0);return 0!==a?this.acc.div(a)._round():new g(0,0)}span(){return new g(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((a,b)=>a+ +(b[0]!==Number.MAX_VALUE),0)}}class h6{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new fn,this.centroidVertexArray=new fU,this.indexArray=new fy,this.programConfigurations=new gg(a.layers,a.zoom),this.segments=new gq,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.enableTerrain=a.enableTerrain}populate(a,b,c,d){for(const{feature:f,id:g,index:h,sourceLayerIndex:i}of(this.features=[],this.hasPattern=hO("fill-extrusion",this.layers,b),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(a){const b=Math.exp(Math.PI*(1-a.y/(1<<a.z)*2));return 80150034*b/(b*b+1)/8192/(1<<a.z)}(c),a)){const j=this.layers[0]._featureFilter.needGeometry,k=gG(f,j);if(!this.layers[0]._featureFilter.filter(new e2(this.zoom),k,c))continue;const l={id:g,sourceLayerIndex:i,index:h,geometry:j?k.geometry:gF(f,c,d),properties:f.properties,type:f.type,patterns:{}},m=this.layoutVertexArray.length;this.hasPattern?this.features.push(hP("fill-extrusion",this.layers,l,this.zoom,b)):this.addFeature(l,l.geometry,h,c,{},b.availableImages),b.featureIndex.insert(f,l.geometry,h,i,this.index,m)}this.sortBorders()}addFeatures(a,b,c,d){for(const f of this.features){const{geometry:g}=f;this.addFeature(f,g,f.index,b,c,d)}this.sortBorders()}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,hV),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}uploadCentroid(a){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=a.createVertexBuffer(this.centroidVertexArray,hU.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(a,b,c,d,f,g){var h;const i=this.enableTerrain?new h5:null;for(const j of hM(b,500)){let k=0,l=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);if(0===j.length||(h=j[0]).every(a=>a.x<=0)||h.every(a=>a.x>=8192)||h.every(a=>a.y<=0)||h.every(a=>a.y>=8192))continue;for(let m=0;m<j.length;m++){const n=j[m];if(0===n.length)continue;k+=n.length;let o=0;i&&i.startRing(n[0]);for(let p=0;p<n.length;p++){const q=n[p];if(p>=1){const r=n[p-1];if(!h7(q,r)){i&&i.append(q,r),l.vertexLength+4>gq.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=q.sub(r)._perp(),u=s.x/(Math.abs(s.x)+Math.abs(s.y)),v=s.y>0?1:0,w=r.dist(q);o+w>32768&&(o=0),h4(this.layoutVertexArray,q.x,q.y,u,v,0,0,o),h4(this.layoutVertexArray,q.x,q.y,u,v,0,1,o),o+=w,h4(this.layoutVertexArray,r.x,r.y,u,v,0,0,o),h4(this.layoutVertexArray,r.x,r.y,u,v,0,1,o);const x=l.vertexLength;this.indexArray.emplaceBack(x,x+2,x+1),this.indexArray.emplaceBack(x+1,x+2,x+3),l.vertexLength+=4,l.primitiveLength+=2}}}}if(l.vertexLength+k>gq.MAX_VERTEX_ARRAY_LENGTH&&(l=this.segments.prepareSegment(k,this.layoutVertexArray,this.indexArray)),"Polygon"!==h3[a.type])continue;const y=[],z=[],A=l.vertexLength;for(let B=0;B<j.length;B++){const C=j[B];if(0!==C.length){C!==j[0]&&z.push(y.length/2);for(let D=0;D<C.length;D++){const E=C[D];h4(this.layoutVertexArray,E.x,E.y,0,0,1,1,0),y.push(E.x),y.push(E.y),i&&i.currentPolyCount.top++}}}const F=hh(y,z);for(let G=0;G<F.length;G+=3)this.indexArray.emplaceBack(A+F[G],A+F[G+2],A+F[G+1]);l.primitiveLength+=F.length/3,l.vertexLength+=k}if(i&&i.polyCount.length>0){if(i.borders){i.vertexArrayOffset=this.centroidVertexArray.length;const H=i.borders,I=this.featuresOnBorder.push(i)-1;for(let J=0;J<4;J++)H[J][0]!==Number.MAX_VALUE&&this.borders[J].push(I)}this.encodeCentroid(i.borders?void 0:i.centroid(),i)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,a,c,f,g,d)}sortBorders(){for(let a=0;a<4;a++)this.borders[a].sort((b,c)=>this.featuresOnBorder[b].borders[a][0]-this.featuresOnBorder[c].borders[a][0])}encodeCentroid(a,b,c=!0){let d,f;if(a){if(0!==a.y){const g=b.span()._mult(this.tileToMeter);d=(Math.max(a.x,1)<<3)+Math.min(7,Math.round(g.x/10)),f=(Math.max(a.y,1)<<3)+Math.min(7,Math.round(g.y/10))}else d=Math.ceil(7*(a.x+450)),f=0}else d=0,f=+c;let h=c?this.centroidVertexArray.length:b.vertexArrayOffset;for(const i of b.polyCount){c&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*i.edges+i.top);for(let j=0;j<2*i.edges;j++)this.centroidVertexArray.emplace(h++,0,f),this.centroidVertexArray.emplace(h++,d,f);for(let k=0;k<i.top;k++)this.centroidVertexArray.emplace(h++,d,f)}}}function h7(a,b){return a.x===b.x&&(a.x<0||a.x>8192)||a.y===b.y&&(a.y<0||a.y>8192)}ec("FillExtrusionBucket",h6,{omit:["layers","features"]}),ec("PartMetadata",h5);var h8={paint:new ff({"fill-extrusion-opacity":new fa(bk["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new fb(bk["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new fa(bk["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new fa(bk["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new fc(bk["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new fb(bk["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new fb(bk["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new fa(bk["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function h9(a,b){return a.x*b.x+a.y*b.y}function ia(a,b){if(1===a.length){let c=0;const d=b[c++];let f;for(;!f||d.equals(f);)if(!(f=b[c++]))return 1/0;for(;c<b.length;c++){const g=b[c],h=a[0],i=f.sub(d),j=g.sub(d),k=h.sub(d),l=h9(i,i),m=h9(i,j),n=h9(j,j),o=h9(k,i),p=h9(k,j),q=l*n-m*m,r=(n*o-m*p)/q,s=(l*p-m*o)/q,u=d.z*(1-r-s)+f.z*r+g.z*s;if(isFinite(u))return u}return 1/0}{let v=1/0;for(const w of b)v=Math.min(v,w.z);return v}}function ib(a){const b=new g(a[0],a[1]);return b.z=a[2],b}function ic(a,b,c,d,f,g,h,i){const j=h*f.getElevationAt(a,b,!0,!0),k=0!==g[0],l=k?0===g[1]?h*(g[0]/7-450):h*function(a,b,c){var d,f,g,h,i;const j=Math.floor(b[0]/8),k=Math.floor(b[1]/8),l=10*(b[0]-8*j),m=10*(b[1]-8*k),n=a.getElevationAt(j,k,!0,!0),o=a.getMeterToDEM(c),p=Math.floor(.5*(l*o-1)),q=Math.floor(.5*(m*o-1)),r=a.tileCoordToPixel(j,k),s=2*p+1,u=2*q+1,v=(d=a,f=r.x-p,g=r.y-q,h=s,i=u,[d.getElevationAtPixel(f,g,!0),d.getElevationAtPixel(f+i,g,!0),d.getElevationAtPixel(f,g+i,!0),d.getElevationAtPixel(f+h,g+i,!0),]),w=Math.abs(v[0]-v[1]),x=Math.abs(v[2]-v[3]),y=Math.abs(v[0]-v[2])+Math.abs(v[1]-v[3]),z=Math.min(.25,.5*o*(w+x)/s),A=Math.min(.25,.5*o*y/u);return n+Math.max(z*l,A*m)}(f,g,i):j;return{base:j+(0===c)?-1:c,top:k?Math.max(l+d,j+c+2):j+d}}const id=fk([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"},],4),{members:ie}=id,ig=fk([{name:"a_packed",components:3,type:"Float32"},]),{members:ih}=ig,ii=h2.VectorTileFeature.types,ij=Math.cos(Math.PI/180*37.5);class ik{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(a=>{this.gradients[a.id]={}}),this.layoutVertexArray=new fo,this.layoutVertexArray2=new fp,this.indexArray=new fy,this.programConfigurations=new gg(a.layers,a.zoom),this.segments=new gq,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(a,b,c,d){this.hasPattern=hO("line",this.layers,b);const f=this.layers[0].layout.get("line-sort-key"),g=[];for(const{feature:h,id:i,index:j,sourceLayerIndex:k}of a){const l=this.layers[0]._featureFilter.needGeometry,m=gG(h,l);if(!this.layers[0]._featureFilter.filter(new e2(this.zoom),m,c))continue;const n=f?f.evaluate(m,{},c):void 0,o={id:i,properties:h.properties,type:h.type,sourceLayerIndex:k,index:j,geometry:l?m.geometry:gF(h,c,d),patterns:{},sortKey:n};g.push(o)}f&&g.sort((a,b)=>a.sortKey-b.sortKey);const{lineAtlas:p,featureIndex:q}=b,r=this.addConstantDashes(p);for(const s of g){const{geometry:u,index:v,sourceLayerIndex:w}=s;if(r&&this.addFeatureDashes(s,p),this.hasPattern){const x=hP("line",this.layers,s,this.zoom,b);this.patternFeatures.push(x)}else this.addFeature(s,u,v,c,p.positions,b.availableImages);q.insert(a[v].feature,u,v,w,this.index)}}addConstantDashes(a){let b=!1;for(const c of this.layers){const d=c.paint.get("line-dasharray").value,f=c.layout.get("line-cap").value;if("constant"!==d.kind||"constant"!==f.kind)b=!0;else{const g=f.value,h=d.value;if(!h)continue;a.addDash(h.from,g),a.addDash(h.to,g),h.other&&a.addDash(h.other,g)}}return b}addFeatureDashes(a,b){const c=this.zoom;for(const d of this.layers){const f=d.paint.get("line-dasharray").value,g=d.layout.get("line-cap").value;if("constant"===f.kind&&"constant"===g.kind)continue;let h,i,j,k,l,m;if("constant"===f.kind){const n=f.value;if(!n)continue;h=n.other||n.to,i=n.to,j=n.from}else h=f.evaluate({zoom:c-1},a),i=f.evaluate({zoom:c},a),j=f.evaluate({zoom:c+1},a);"constant"===g.kind?k=l=m=g.value:(k=g.evaluate({zoom:c-1},a),l=g.evaluate({zoom:c},a),m=g.evaluate({zoom:c+1},a)),b.addDash(h,k),b.addDash(i,l),b.addDash(j,m);const o=b.getKey(h,k),p=b.getKey(i,l),q=b.getKey(j,m);a.patterns[d.id]={min:o,mid:p,max:q}}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(a,b,c,d){for(const f of this.patternFeatures)this.addFeature(f,f.geometry,f.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=a.createVertexBuffer(this.layoutVertexArray2,ih)),this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,ie),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(a){if(a.properties&&a.properties.hasOwnProperty("mapbox_clip_start")&&a.properties.hasOwnProperty("mapbox_clip_end"))return{start:+a.properties.mapbox_clip_start,end:+a.properties.mapbox_clip_end}}addFeature(a,b,c,d,f,g){const h=this.layers[0].layout,i=h.get("line-join").evaluate(a,{}),j=h.get("line-cap").evaluate(a,{}),k=h.get("line-miter-limit"),l=h.get("line-round-limit");for(const m of(this.lineClips=this.lineFeatureClips(a),b))this.addLine(m,a,i,j,k,l);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,a,c,f,g,d)}addLine(a,b,c,d,f,g){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let h=0;h<a.length-1;h++)this.totalDistance+=a[h].dist(a[h+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const i="Polygon"===ii[b.type];let j=a.length;for(;j>=2&&a[j-1].equals(a[j-2]);)j--;let k=0;for(;k<j-1&&a[k].equals(a[k+1]);)k++;if(j<(i?3:2))return;"bevel"===c&&(f=1.05);const l=this.overscaling<=16?122880/(512*this.overscaling):0,m=this.segments.prepareSegment(10*j,this.layoutVertexArray,this.indexArray);let n,o,p,q,r;this.e1=this.e2=-1,i&&(n=a[j-2],r=a[k].sub(n)._unit()._perp());for(let s=k;s<j;s++){if((p=s===j-1?i?a[k+1]:void 0:a[s+1])&&a[s].equals(p))continue;r&&(q=r),n&&(o=n),n=a[s],r=p?p.sub(n)._unit()._perp():q;let u=(q=q||r).add(r);0===u.x&&0===u.y||u._unit();const v=q.x*r.x+q.y*r.y,w=u.x*r.x+u.y*r.y,x=0!==w?1/w:1/0,y=2*Math.sqrt(2-2*w),z=w<ij&&o&&p,A=q.x*r.y-q.y*r.x>0;if(z&&s>k){const B=n.dist(o);if(B>2*l){const C=n.sub(n.sub(o)._mult(l/B)._round());this.updateDistance(o,C),this.addCurrentVertex(C,q,0,0,m),o=C}}const D=o&&p;let E=D?c:i?"butt":d;if(D&&"round"===E&&(x<g?E="miter":x<=2&&(E="fakeround")),"miter"===E&&x>f&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x<f&&(E="miter")),o&&this.updateDistance(o,n),"miter"===E)u._mult(x),this.addCurrentVertex(n,u,0,0,m);else if("flipbevel"===E){if(x>100)u=r.mult(-1);else{const F=x*q.add(r).mag()/q.sub(r).mag();u._perp()._mult(F*(A?-1:1))}this.addCurrentVertex(n,u,0,0,m),this.addCurrentVertex(n,u.mult(-1),0,0,m)}else if("bevel"===E||"fakeround"===E){const G=-Math.sqrt(x*x-1),H=A?G:0,I=A?0:G;if(o&&this.addCurrentVertex(n,q,H,I,m),"fakeround"===E){const J=Math.round(180*y/Math.PI/20);for(let K=1;K<J;K++){let L=K/J;if(.5!==L){const M=L-.5;L+=L*M*(L-1)*((1.0904+v*(v*(3.55645-1.43519*v)-3.2452))*M*M+(.848013+v*(.215638*v-1.06021)))}const N=r.sub(q)._mult(L)._add(q)._unit()._mult(A?-1:1);this.addHalfVertex(n,N.x,N.y,!1,A,0,m)}}p&&this.addCurrentVertex(n,r,-H,-I,m)}else if("butt"===E)this.addCurrentVertex(n,u,0,0,m);else if("square"===E){const O=o?1:-1;o||this.addCurrentVertex(n,u,O,O,m),this.addCurrentVertex(n,u,0,0,m),o&&this.addCurrentVertex(n,u,O,O,m)}else"round"===E&&(o&&(this.addCurrentVertex(n,q,0,0,m),this.addCurrentVertex(n,q,1,1,m,!0)),p&&(this.addCurrentVertex(n,r,-1,-1,m,!0),this.addCurrentVertex(n,r,0,0,m)));if(z&&s<j-1){const P=n.dist(p);if(P>2*l){const Q=n.add(p.sub(n)._mult(l/P)._round());this.updateDistance(n,Q),this.addCurrentVertex(Q,r,0,0,m),n=Q}}}}addCurrentVertex(a,b,c,d,f,g=!1){const h=b.y*d-b.x,i=-b.y-b.x*d;this.addHalfVertex(a,b.x+b.y*c,b.y-b.x*c,g,!1,c,f),this.addHalfVertex(a,h,i,g,!0,-d,f)}addHalfVertex({x:a,y:b},c,d,f,g,h,i){this.layoutVertexArray.emplaceBack((a<<1)+(f?1:0),(b<<1)+(g?1:0),Math.round(63*c)+128,Math.round(63*d)+128,1+(0===h?0:h<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const j=i.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,j),i.primitiveLength++),g?this.e2=j:this.e1=j}updateScaledDistance(){if(this.lineClips){const a=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=a*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(a,b){this.distance+=a.dist(b),this.updateScaledDistance()}}ec("LineBucket",ik,{omit:["layers","patternFeatures"]});const il=new ff({"line-cap":new fb(bk.layout_line["line-cap"]),"line-join":new fb(bk.layout_line["line-join"]),"line-miter-limit":new fa(bk.layout_line["line-miter-limit"]),"line-round-limit":new fa(bk.layout_line["line-round-limit"]),"line-sort-key":new fb(bk.layout_line["line-sort-key"])});var im={paint:new ff({"line-opacity":new fb(bk.paint_line["line-opacity"]),"line-color":new fb(bk.paint_line["line-color"]),"line-translate":new fa(bk.paint_line["line-translate"]),"line-translate-anchor":new fa(bk.paint_line["line-translate-anchor"]),"line-width":new fb(bk.paint_line["line-width"]),"line-gap-width":new fb(bk.paint_line["line-gap-width"]),"line-offset":new fb(bk.paint_line["line-offset"]),"line-blur":new fb(bk.paint_line["line-blur"]),"line-dasharray":new fc(bk.paint_line["line-dasharray"]),"line-pattern":new fc(bk.paint_line["line-pattern"]),"line-gradient":new fe(bk.paint_line["line-gradient"])}),layout:il};const io=new class extends fb{possiblyEvaluate(a,b){return b=new e2(Math.floor(b.zoom),{now:b.now,fadeDuration:b.fadeDuration,zoomHistory:b.zoomHistory,transition:b.transition}),super.possiblyEvaluate(a,b)}evaluate(a,b,c,d){return b=aa({},b,{zoom:Math.floor(b.zoom)}),super.evaluate(a,b,c,d)}}(im.paint.properties["line-width"].specification);function ip(a,b){return b>0?b+2*a:a}io.useIntegerZoom=!0;const iq=fk([{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),ir=fk([{name:"a_projected_pos",components:3,type:"Float32"},],4);fk([{name:"a_fade_opacity",components:1,type:"Uint32"},],4);const is=fk([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},]),it=fk([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},]);fk([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},]);const iu=fk([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"},],4),iv=fk([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"},],4);function iw(a,b){const{expression:c}=b;if("constant"===c.kind)return{kind:"constant",layoutSize:c.evaluate(new e2(a+1))};if("source"===c.kind)return{kind:"source"};{const{zoomStops:d,interpolationType:f}=c;let g=0;for(;g<d.length&&d[g]<=a;)g++;let h=g=Math.max(0,g-1);for(;h<d.length&&d[h]<a+1;)h++;h=Math.min(d.length-1,h);const i=d[g],j=d[h];return"composite"===c.kind?{kind:"composite",minZoom:i,maxZoom:j,interpolationType:f}:{kind:"camera",minZoom:i,maxZoom:j,minSize:c.evaluate(new e2(i)),maxSize:c.evaluate(new e2(j)),interpolationType:f}}}function ix(a,{uSize:b,uSizeT:c},{lowerSize:d,upperSize:f}){return"source"===a.kind?d/128:"composite"===a.kind?cr(d/128,f/128,c):b}function iy(a,b){let c=0,d=0;if("constant"===a.kind)d=a.layoutSize;else if("source"!==a.kind){const{interpolationType:f,minZoom:g,maxZoom:h}=a,i=f?X(cH.interpolationFactor(f,b,g,h),0,1):0;"camera"===a.kind?d=cr(a.minSize,a.maxSize,i):c=i}return{uSizeT:c,uSize:d}}fk([{name:"triangle",components:3,type:"Uint16"},]),fk([{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"},]),fk([{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"},]),fk([{type:"Float32",name:"offsetX"},]),fk([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"},]);var iz=Object.freeze({__proto__:null,getSizeData:iw,evaluateSizeForFeature:ix,evaluateSizeForZoom:iy,SIZE_PACK_FACTOR:128});function iA(a,b,c){return a.sections.forEach(a=>{a.text=function(a,b,c){const d=b.layout.get("text-transform").evaluate(c,{});return"uppercase"===d?a=a.toLocaleUpperCase():"lowercase"===d&&(a=a.toLocaleLowerCase()),e1.applyArabicShaping&&(a=e1.applyArabicShaping(a)),a}(a.text,b,c)}),a}const iB={"!":"\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 iC(a){return"\uFE36"===a||"\uFE48"===a||"\uFE38"===a||"\uFE44"===a||"\uFE42"===a||"\uFE3E"===a||"\uFE3C"===a||"\uFE3A"===a||"\uFE18"===a||"\uFE40"===a||"\uFE10"===a||"\uFE13"===a||"\uFE14"===a||"\uFF40"===a||"\uFFE3"===a||"\uFE11"===a||"\uFE12"===a}function iD(a){return"\uFE35"===a||"\uFE47"===a||"\uFE37"===a||"\uFE43"===a||"\uFE41"===a||"\uFE3D"===a||"\uFE3B"===a||"\uFE39"===a||"\uFE17"===a||"\uFE3F"===a}var iE=function(a,b,c,d,f){var g,h,i=8*f-d-1,j=(1<<i)-1,k=j>>1,l=-7,m=c?f-1:0,n=c?-1:1,o=a[b+m];for(m+=n,g=o&(1<< -l)-1,o>>=-l,l+=i;l>0;g=256*g+a[b+m],m+=n,l-=8);for(h=g&(1<< -l)-1,g>>=-l,l+=d;l>0;h=256*h+a[b+m],m+=n,l-=8);if(0===g)g=1-k;else{if(g===j)return h?NaN:1/0*(o?-1:1);h+=Math.pow(2,d),g-=k}return(o?-1:1)*h*Math.pow(2,g-d)},iF=function(a,b,c,d,f,g){var h,i,j,k=8*g-f-1,l=(1<<k)-1,m=l>>1,n=23===f?5960464477539062e-23:0,o=d?0:g-1,p=d?1:-1,q=b<0||0===b&&1/b<0?1:0;for(isNaN(b=Math.abs(b))||b===1/0?(i=isNaN(b)?1:0,h=l):(h=Math.floor(Math.log(b)/Math.LN2),b*(j=Math.pow(2,-h))<1&&(h--,j*=2),(b+=h+m>=1?n/j:n*Math.pow(2,1-m))*j>=2&&(h++,j/=2),h+m>=l?(i=0,h=l):h+m>=1?(i=(b*j-1)*Math.pow(2,f),h+=m):(i=b*Math.pow(2,m-1)*Math.pow(2,f),h=0));f>=8;a[c+o]=255&i,o+=p,i/=256,f-=8);for(h=h<<f|i,k+=f;k>0;a[c+o]=255&h,o+=p,h/=256,k-=8);a[c+o-p]|=128*q},iG=iH;function iH(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}iH.Varint=0,iH.Fixed64=1,iH.Bytes=2,iH.Fixed32=5;var iI="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function iJ(a){return a.type===iH.Bytes?a.readVarint()+a.pos:a.pos+1}function iK(a,b,c){var d=b<=16383?1:b<=2097151?2:b<=268435455?3:Math.floor(Math.log(b)/(7*Math.LN2));c.realloc(d);for(var f=c.pos-1;f>=a;f--)c.buf[f+d]=c.buf[f]}function iL(a,b){for(var c=0;c<a.length;c++)b.writeVarint(a[c])}function iM(a,b){for(var c=0;c<a.length;c++)b.writeSVarint(a[c])}function iN(a,b){for(var c=0;c<a.length;c++)b.writeFloat(a[c])}function iO(a,b){for(var c=0;c<a.length;c++)b.writeDouble(a[c])}function iP(a,b){for(var c=0;c<a.length;c++)b.writeBoolean(a[c])}function iQ(a,b){for(var c=0;c<a.length;c++)b.writeFixed32(a[c])}function iR(a,b){for(var c=0;c<a.length;c++)b.writeSFixed32(a[c])}function iS(a,b){for(var c=0;c<a.length;c++)b.writeFixed64(a[c])}function iT(a,b){for(var c=0;c<a.length;c++)b.writeSFixed64(a[c])}function iU(a,b){return(a[b]|a[b+1]<<8|a[b+2]<<16)+16777216*a[b+3]}function iV(a,b,c){a[c]=b,a[c+1]=b>>>8,a[c+2]=b>>>16,a[c+3]=b>>>24}function iW(a,b){return(a[b]|a[b+1]<<8|a[b+2]<<16)+(a[b+3]<<24)}function iX(a,b,c){b.glyphs=[],1===a&&c.readMessage(iY,b)}function iY(a,b,c){if(3===a){const{id:d,bitmap:f,width:g,height:h,left:i,top:j,advance:k}=c.readMessage(iZ,{});b.glyphs.push({id:d,bitmap:new ha({width:g+6,height:h+6},f),metrics:{width:g,height:h,left:i,top:j,advance:k}})}else 4===a?b.ascender=c.readSVarint():5===a&&(b.descender=c.readSVarint())}function iZ(a,b,c){1===a?b.id=c.readVarint():2===a?b.bitmap=c.readBytes():3===a?b.width=c.readVarint():4===a?b.height=c.readVarint():5===a?b.left=c.readSVarint():6===a?b.top=c.readSVarint():7===a&&(b.advance=c.readVarint())}function i$(a){let b=0,c=0;for(const d of a)b+=d.w*d.h,c=Math.max(c,d.w);a.sort((a,b)=>b.h-a.h);const f=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(b/.95)),c),h:1/0},];let g=0,h=0;for(const i of a)for(let j=f.length-1;j>=0;j--){const k=f[j];if(!(i.w>k.w||i.h>k.h)){if(i.x=k.x,i.y=k.y,h=Math.max(h,i.y+i.h),g=Math.max(g,i.x+i.w),i.w===k.w&&i.h===k.h){const l=f.pop();j<f.length&&(f[j]=l)}else i.h===k.h?(k.x+=i.w,k.w-=i.w):i.w===k.w?(k.y+=i.h,k.h-=i.h):(f.push({x:k.x+i.w,y:k.y,w:k.w-i.w,h:i.h}),k.y+=i.h,k.h-=i.h);break}}return{w:g,h:h,fill:b/(g*h)||0}}iH.prototype={destroy:function(){this.buf=null},readFields:function(a,b,c){for(c=c||this.length;this.pos<c;){var d=this.readVarint(),f=d>>3,g=this.pos;this.type=7&d,a(f,b,this),this.pos===g&&this.skip(d)}return b},readMessage:function(a,b){return this.readFields(a,b,this.readVarint()+this.pos)},readFixed32:function(){var a=iU(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=iW(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=iU(this.buf,this.pos)+4294967296*iU(this.buf,this.pos+4);return this.pos+=8,a},readSFixed64:function(){var a=iU(this.buf,this.pos)+4294967296*iW(this.buf,this.pos+4);return this.pos+=8,a},readFloat:function(){var a=iE(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=iE(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(a){var b,c,d=this.buf;return b=127&(c=d[this.pos++]),c<128?b:(b|=(127&(c=d[this.pos++]))<<7,c<128?b:(b|=(127&(c=d[this.pos++]))<<14,c<128?b:(b|=(127&(c=d[this.pos++]))<<21,c<128?b:function(a,b,c){var d,f,g,h,i=c.buf;if(g=(112&(h=i[c.pos++]))>>4,h<128||(g|=(127&(h=i[c.pos++]))<<3,h<128)||(g|=(127&(h=i[c.pos++]))<<10,h<128)||(g|=(127&(h=i[c.pos++]))<<17,h<128)||(g|=(127&(h=i[c.pos++]))<<24,h<128)||(g|=(1&(h=i[c.pos++]))<<31,h<128))return d=a,f=g,b?4294967296*f+(d>>>0):4294967296*(f>>>0)+(d>>>0);throw Error("Expected varint not more than 10 bytes")}(b|=(15&(c=d[this.pos]))<<28,a,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?-((a+1)/2):a/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var a,b,c,d=this.readVarint()+this.pos,f=this.pos;return this.pos=d,d-f>=12&&iI?(a=this.buf,b=f,c=d,iI.decode(a.subarray(b,c))):function(a,b,c){for(var d="",f=b;f<c;){var g,h,i,j=a[f],k=null,l=j>239?4:j>223?3:j>191?2:1;if(f+l>c)break;1===l?j<128&&(k=j):2===l?128==(192&(g=a[f+1]))&&(k=(31&j)<<6|63&g)<=127&&(k=null):3===l?(h=a[f+2],128==(192&(g=a[f+1]))&&128==(192&h)&&((k=(15&j)<<12|(63&g)<<6|63&h)<=2047||k>=55296&&k<=57343)&&(k=null)):4===l&&(h=a[f+2],i=a[f+3],128==(192&(g=a[f+1]))&&128==(192&h)&&128==(192&i)&&((k=(15&j)<<18|(63&g)<<12|(63&h)<<6|63&i)<=65535||k>=1114112)&&(k=null)),null===k?(k=65533,l=1):k>65535&&(k-=65536,d+=String.fromCharCode(k>>>10&1023|55296),k=56320|1023&k),d+=String.fromCharCode(k),f+=l}return d}(this.buf,f,d)},readBytes:function(){var a=this.readVarint()+this.pos,b=this.buf.subarray(this.pos,a);return this.pos=a,b},readPackedVarint:function(a,b){if(this.type!==iH.Bytes)return a.push(this.readVarint(b));var c=iJ(this);for(a=a||[];this.pos<c;)a.push(this.readVarint(b));return a},readPackedSVarint:function(a){if(this.type!==iH.Bytes)return a.push(this.readSVarint());var b=iJ(this);for(a=a||[];this.pos<b;)a.push(this.readSVarint());return a},readPackedBoolean:function(a){if(this.type!==iH.Bytes)return a.push(this.readBoolean());var b=iJ(this);for(a=a||[];this.pos<b;)a.push(this.readBoolean());return a},readPackedFloat:function(a){if(this.type!==iH.Bytes)return a.push(this.readFloat());var b=iJ(this);for(a=a||[];this.pos<b;)a.push(this.readFloat());return a},readPackedDouble:function(a){if(this.type!==iH.Bytes)return a.push(this.readDouble());var b=iJ(this);for(a=a||[];this.pos<b;)a.push(this.readDouble());return a},readPackedFixed32:function(a){if(this.type!==iH.Bytes)return a.push(this.readFixed32());var b=iJ(this);for(a=a||[];this.pos<b;)a.push(this.readFixed32());return a},readPackedSFixed32:function(a){if(this.type!==iH.Bytes)return a.push(this.readSFixed32());var b=iJ(this);for(a=a||[];this.pos<b;)a.push(this.readSFixed32());return a},readPackedFixed64:function(a){if(this.type!==iH.Bytes)return a.push(this.readFixed64());var b=iJ(this);for(a=a||[];this.pos<b;)a.push(this.readFixed64());return a},readPackedSFixed64:function(a){if(this.type!==iH.Bytes)return a.push(this.readSFixed64());var b=iJ(this);for(a=a||[];this.pos<b;)a.push(this.readSFixed64());return a},skip:function(a){var b=7&a;if(b===iH.Varint)for(;this.buf[this.pos++]>127;);else if(b===iH.Bytes)this.pos=this.readVarint()+this.pos;else if(b===iH.Fixed32)this.pos+=4;else{if(b!==iH.Fixed64)throw Error("Unimplemented type: "+b);this.pos+=8}},writeTag:function(a,b){this.writeVarint(a<<3|b)},realloc:function(a){for(var b=this.length||16;b<this.pos+a;)b*=2;if(b!==this.length){var c=new Uint8Array(b);c.set(this.buf),this.buf=c,this.length=b}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(a){this.realloc(4),iV(this.buf,a,this.pos),this.pos+=4},writeSFixed32:function(a){this.realloc(4),iV(this.buf,a,this.pos),this.pos+=4},writeFixed64:function(a){this.realloc(8),iV(this.buf,-1&a,this.pos),iV(this.buf,Math.floor(23283064365386963e-26*a),this.pos+4),this.pos+=8},writeSFixed64:function(a){this.realloc(8),iV(this.buf,-1&a,this.pos),iV(this.buf,Math.floor(23283064365386963e-26*a),this.pos+4),this.pos+=8},writeVarint:function(a){(a=+a||0)>268435455||a<0?function(a,b){var c,d,f,g,h,i,j;if(a>=0?(c=a%4294967296|0,d=a/4294967296|0):(d=~(-a/4294967296),4294967295^(c=~(-a%4294967296))?c=c+1|0:(c=0,d=d+1|0)),a>=18446744073709552e3||a< -18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");b.realloc(10),f=c,(g=b).buf[g.pos++]=127&f|128,f>>>=7,g.buf[g.pos++]=127&f|128,f>>>=7,g.buf[g.pos++]=127&f|128,f>>>=7,g.buf[g.pos++]=127&f|128,g.buf[g.pos]=127&(f>>>=7),h=d,i=b,j=(7&h)<<4,i.buf[i.pos++]|=j|((h>>>=3)?128:0),h&&(i.buf[i.pos++]=127&h|((h>>>=7)?128:0),h&&(i.buf[i.pos++]=127&h|((h>>>=7)?128:0),h&&(i.buf[i.pos++]=127&h|((h>>>=7)?128:0),h&&(i.buf[i.pos++]=127&h|((h>>>=7)?128:0),h&&(i.buf[i.pos++]=127&h)))))}(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?-(2*a)-1:2*a)},writeBoolean:function(a){this.writeVarint(Boolean(a))},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var b=this.pos;this.pos=function(a,b,c){for(var d,f,g=0;g<b.length;g++){if((d=b.charCodeAt(g))>55295&&d<57344){if(!f){d>56319||g+1===b.length?(a[c++]=239,a[c++]=191,a[c++]=189):f=d;continue}if(d<56320){a[c++]=239,a[c++]=191,a[c++]=189,f=d;continue}d=f-55296<<10|d-56320|65536,f=null}else f&&(a[c++]=239,a[c++]=191,a[c++]=189,f=null);d<128?a[c++]=d:(d<2048?a[c++]=d>>6|192:(d<65536?a[c++]=d>>12|224:(a[c++]=d>>18|240,a[c++]=d>>12&63|128),a[c++]=d>>6&63|128),a[c++]=63&d|128)}return c}(this.buf,a,this.pos);var c=this.pos-b;c>=128&&iK(b,c,this),this.pos=b-1,this.writeVarint(c),this.pos+=c},writeFloat:function(a){this.realloc(4),iF(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),iF(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(a){var b=a.length;this.writeVarint(b),this.realloc(b);for(var c=0;c<b;c++)this.buf[this.pos++]=a[c]},writeRawMessage:function(a,b){this.pos++;var c=this.pos;a(b,this);var d=this.pos-c;d>=128&&iK(c,d,this),this.pos=c-1,this.writeVarint(d),this.pos+=d},writeMessage:function(a,b,c){this.writeTag(a,iH.Bytes),this.writeRawMessage(b,c)},writePackedVarint:function(a,b){b.length&&this.writeMessage(a,iL,b)},writePackedSVarint:function(a,b){b.length&&this.writeMessage(a,iM,b)},writePackedBoolean:function(a,b){b.length&&this.writeMessage(a,iP,b)},writePackedFloat:function(a,b){b.length&&this.writeMessage(a,iN,b)},writePackedDouble:function(a,b){b.length&&this.writeMessage(a,iO,b)},writePackedFixed32:function(a,b){b.length&&this.writeMessage(a,iQ,b)},writePackedSFixed32:function(a,b){b.length&&this.writeMessage(a,iR,b)},writePackedFixed64:function(a,b){b.length&&this.writeMessage(a,iS,b)},writePackedSFixed64:function(a,b){b.length&&this.writeMessage(a,iT,b)},writeBytesField:function(a,b){this.writeTag(a,iH.Bytes),this.writeBytes(b)},writeFixed32Field:function(a,b){this.writeTag(a,iH.Fixed32),this.writeFixed32(b)},writeSFixed32Field:function(a,b){this.writeTag(a,iH.Fixed32),this.writeSFixed32(b)},writeFixed64Field:function(a,b){this.writeTag(a,iH.Fixed64),this.writeFixed64(b)},writeSFixed64Field:function(a,b){this.writeTag(a,iH.Fixed64),this.writeSFixed64(b)},writeVarintField:function(a,b){this.writeTag(a,iH.Varint),this.writeVarint(b)},writeSVarintField:function(a,b){this.writeTag(a,iH.Varint),this.writeSVarint(b)},writeStringField:function(a,b){this.writeTag(a,iH.Bytes),this.writeString(b)},writeFloatField:function(a,b){this.writeTag(a,iH.Fixed32),this.writeFloat(b)},writeDoubleField:function(a,b){this.writeTag(a,iH.Fixed64),this.writeDouble(b)},writeBooleanField:function(a,b){this.writeVarintField(a,Boolean(b))}};class i_{constructor(a,{pixelRatio:b,version:c,stretchX:d,stretchY:f,content:g}){this.paddedRect=a,this.pixelRatio=b,this.stretchX=d,this.stretchY=f,this.content=g,this.version=c}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 i0{constructor(a,b){const c={},d={};this.haveRenderCallbacks=[];const f=[];this.addImages(a,c,f),this.addImages(b,d,f);const{w:g,h:h}=i$(f),i=new hb({width:g||1,height:h||1});for(const j in a){const k=a[j],l=c[j].paddedRect;hb.copy(k.data,i,{x:0,y:0},{x:l.x+1,y:l.y+1},k.data)}for(const m in b){const n=b[m],o=d[m].paddedRect,p=o.x+1,q=o.y+1,r=n.data.width,s=n.data.height;hb.copy(n.data,i,{x:0,y:0},{x:p,y:q},n.data),hb.copy(n.data,i,{x:0,y:s-1},{x:p,y:q-1},{width:r,height:1}),hb.copy(n.data,i,{x:0,y:0},{x:p,y:q+s},{width:r,height:1}),hb.copy(n.data,i,{x:r-1,y:0},{x:p-1,y:q},{width:1,height:s}),hb.copy(n.data,i,{x:0,y:0},{x:p+r,y:q},{width:1,height:s})}this.image=i,this.iconPositions=c,this.patternPositions=d}addImages(a,b,c){for(const d in a){const f=a[d],g={x:0,y:0,w:f.data.width+2,h:f.data.height+2};c.push(g),b[d]=new i_(g,f),f.hasRenderCallback&&this.haveRenderCallbacks.push(d)}}patchUpdatedImages(a,b){for(const c in a.dispatchRenderCallbacks(this.haveRenderCallbacks),a.updatedImages)this.patchUpdatedImage(this.iconPositions[c],a.getImage(c),b),this.patchUpdatedImage(this.patternPositions[c],a.getImage(c),b)}patchUpdatedImage(a,b,c){if(!a||!b||a.version===b.version)return;a.version=b.version;const[d,f]=a.tl;c.update(b.data,void 0,{x:d,y:f})}}ec("ImagePosition",i_),ec("ImageAtlas",i0);const i1={horizontal:1,vertical:2,horizontalOnly:3};class i2{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(a,b){const c=new i2;return c.scale=a||1,c.fontStack=b,c}static forImage(a){const b=new i2;return b.imageName=a,b}}class i3{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(a,b){const c=new i3;for(let d=0;d<a.sections.length;d++){const f=a.sections[d];f.image?c.addImageSection(f):c.addTextSection(f,b)}return c}length(){return this.text.length}getSection(a){return this.sections[this.sectionIndex[a]]}getSections(){return this.sections}getSectionIndex(a){return this.sectionIndex[a]}getCharCode(a){return this.text.charCodeAt(a)}verticalizePunctuation(a){this.text=function(a,b){let c="";for(let d=0;d<a.length;d++){const f=a.charCodeAt(d+1)||null,g=a.charCodeAt(d-1)||null;c+=!b&&(f&&eO(f)&&!iB[a[d+1]]||g&&eO(g)&&!iB[a[d-1]])||!iB[a[d]]?a[d]:iB[a[d]]}return c}(this.text,a)}trim(){let a=0;for(let b=0;b<this.text.length&&i5[this.text.charCodeAt(b)];b++)a++;let c=this.text.length;for(let d=this.text.length-1;d>=0&&d>=a&&i5[this.text.charCodeAt(d)];d--)c--;this.text=this.text.substring(a,c),this.sectionIndex=this.sectionIndex.slice(a,c)}substring(a,b){const c=new i3;return c.text=this.text.substring(a,b),c.sectionIndex=this.sectionIndex.slice(a,b),c.sections=this.sections,c}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((a,b)=>Math.max(a,this.sections[b].scale),0)}addTextSection(a,b){this.text+=a.text,this.sections.push(i2.forText(a.scale,a.fontStack||b));const c=this.sections.length-1;for(let d=0;d<a.text.length;++d)this.sectionIndex.push(c)}addImageSection(a){const b=a.image?a.image.name:"";if(0===b.length)return void am("Can't add FormattedSection with an empty image.");const c=this.getNextImageSectionCharCode();c?(this.text+=String.fromCharCode(c),this.sections.push(i2.forImage(b)),this.sectionIndex.push(this.sections.length-1)):am("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function i4(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q){const r=i3.fromFeature(a,f);let s;m===i1.vertical&&r.verticalizePunctuation(n);const{processBidirectionalText:u,processStyledBidirectionalText:v}=e1;if(u&&1===r.sections.length){s=[];const w=u(r.toString(),jc(r,k,g,b,d,o,p));for(const x of w){const y=new i3;y.text=x,y.sections=r.sections;for(let z=0;z<x.length;z++)y.sectionIndex.push(0);s.push(y)}}else if(v){s=[];const A=v(r.text,r.sectionIndex,jc(r,k,g,b,d,o,p));for(const B of A){const C=new i3;C.text=B[0],C.sectionIndex=B[1],C.sections=r.sections,s.push(C)}}else s=function(a,b){const c=[],d=a.text;let f=0;for(const g of b)c.push(a.substring(f,g)),f=g;return f<d.length&&c.push(a.substring(f,d.length)),c}(r,jc(r,k,g,b,d,o,p));const D=[],E={positionedLines:D,text:r.toString(),top:l[1],bottom:l[1],left:l[0],right:l[0],writingMode:m,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(a,b,c,d,f,g,h,i,j,k,l,m){var n;let o=0,p=0,q=0;const r="right"===i?1:"left"===i?0:.5;let s=!1;for(const u of f){const v=u.getSections();for(const w of v){if(w.imageName)continue;const x=b[w.fontStack];if(x&&!(s=void 0!==x.ascender&& void 0!==x.descender))break}if(!s)break}let y=0;for(const z of f){z.trim();const A=z.getMaxScale(),B=(A-1)*24,C={positionedGlyphs:[],lineOffset:0};a.positionedLines[y]=C;const D=C.positionedGlyphs;let E=0;if(!z.length()){p+=g,++y;continue}let F=0,G=0;for(let H=0;H<z.length();H++){const I=z.getSection(H),J=z.getSectionIndex(H),K=z.getCharCode(H);let L=I.scale,M=null,N=null,O=null,P=24,Q=0;const R=!(j===i1.horizontal|| !l&&!eN(K)||l&&(i5[K]||ej(n=K)||ek(n)||el(n)||eE(n)||eI(n)));if(I.imageName){const S=d[I.imageName];if(!S)continue;O=I.imageName,a.iconsInText=a.iconsInText||!0,N=S.paddedRect;const T=S.displaySize;L=24*L/m,M={width:T[0],height:T[1],left:1,top:-3,advance:R?T[1]:T[0],localGlyph:!1},Q=s?-M.height*L:24*A-17-T[1]*L,P=M.advance;const U=(R?T[0]:T[1])*L-24*A;U>0&&U>E&&(E=U)}else{const V=c[I.fontStack];if(!V)continue;V[K]&&(N=V[K]);const W=b[I.fontStack];if(!W)continue;const X=W.glyphs[K];if(!X)continue;if(M=X.metrics,P=8203!==K?24:0,s){const Y=void 0!==W.ascender?Math.abs(W.ascender):0,Z=void 0!==W.descender?Math.abs(W.descender):0,$=(Y+Z)*L;F<$&&(F=$,G=(Y-Z)/2*L),Q=-Y*L}else Q=(A-L)*24-17}R?(a.verticalizable=!0,D.push({glyph:K,imageName:O,x:o,y:p+Q,vertical:R,scale:L,localGlyph:M.localGlyph,fontStack:I.fontStack,sectionIndex:J,metrics:M,rect:N}),o+=P*L+k):(D.push({glyph:K,imageName:O,x:o,y:p+Q,vertical:R,scale:L,localGlyph:M.localGlyph,fontStack:I.fontStack,sectionIndex:J,metrics:M,rect:N}),o+=M.advance*L+k)}0!==D.length&&(q=Math.max(o-k,q),s?je(D,r,E,G,g*A/2):je(D,r,E,0,g/2)),o=0;const _=g*A+E;C.lineOffset=Math.max(E,B),p+=_,++y}const aa=p,{horizontalAlign:ab,verticalAlign:ac}=jd(h);(function(a,b,c,d,f,g){const h=(b-c)*f,i=-g*d;for(const j of a)for(const k of j.positionedGlyphs)k.x+=h,k.y+=i})(a.positionedLines,r,ab,ac,q,aa),a.top+=-ac*aa,a.bottom=a.top+aa,a.left+=-ab*q,a.right=a.left+q,a.hasBaseline=s}(E,b,c,d,s,h,i,j,m,k,n,q),!function(a){for(const b of a)if(0!==b.positionedGlyphs.length)return!1;return!0}(D)&&E}const i5={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},i6={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 i7(a,b,c,d,f,g){if(b.imageName){const h=d[b.imageName];return h?h.displaySize[0]*b.scale*24/g+f:0}{const i=c[b.fontStack],j=i&&i.glyphs[a];return j?j.metrics.advance*b.scale+f:0}}function i8(a,b,c,d){const f=Math.pow(a-b,2);return d?a<b?f/2:2*f:f+Math.abs(c)*c}function i9(a,b,c){let d=0;return 10===a&&(d-=1e4),c&&(d+=150),40!==a&&65288!==a||(d+=50),41!==b&&65289!==b||(d+=50),d}function ja(a,b,c,d,f,g){let h=null,i=i8(b,c,f,g);for(const j of d){const k=i8(b-j.x,c,f,g)+j.badness;k<=i&&(h=j,i=k)}return{index:a,x:b,priorBreak:h,badness:i}}function jb(a){return a?jb(a.priorBreak).concat(a.index):[]}function jc(a,b,c,d,f,g,h){var i;if("point"!==g||!a)return[];const j=[],k=function(a,b,c,d,f,g){let h=0;for(let i=0;i<a.length();i++){const j=a.getSection(i);h+=i7(a.getCharCode(i),j,d,f,b,g)}return h/Math.max(1,Math.ceil(h/c))}(a,b,c,d,f,h),l=a.text.indexOf("\u200B")>=0;let m=0;for(let n=0;n<a.length();n++){const o=a.getSection(n),p=a.getCharCode(n);if(i5[p]||(m+=i7(p,o,d,f,b,h)),n<a.length()-1){const q=!((i=p)<11904||!(et(i)||es(i)||eG(i)||eD(i)||ex(i)||em(i)||eu(i)||ep(i)||ey(i)||ez(i)||ew(i)||eJ(i)||eq(i)||eo(i)||en(i)||ev(i)||er(i)||eF(i)||eB(i)||eA(i)));(i6[p]||q||o.imageName)&&j.push(ja(n+1,m,k,j,i9(p,a.getCharCode(n+1),q&&l),!1))}}return jb(ja(a.length(),m,k,j,0,!0))}function jd(a){let b=.5,c=.5;switch(a){case"right":case"top-right":case"bottom-right":b=1;break;case"left":case"top-left":case"bottom-left":b=0}switch(a){case"bottom":case"bottom-right":case"bottom-left":c=1;break;case"top":case"top-right":case"top-left":c=0}return{horizontalAlign:b,verticalAlign:c}}function je(a,b,c,d,f){if(!(b||c||d||f))return;const g=a.length-1,h=a[g],i=(h.x+h.metrics.advance*h.scale)*b;for(let j=0;j<=g;j++)a[j].x-=i,a[j].y+=c+d+f}function jf(a,b,c){const{horizontalAlign:d,verticalAlign:f}=jd(c),g=b[0]-a.displaySize[0]*d,h=b[1]-a.displaySize[1]*f;return{image:a,top:h,bottom:h+a.displaySize[1],left:g,right:g+a.displaySize[0]}}function jg(a,b,c,d,f,g){const h=a.image;let i;if(h.content){const j=h.content,k=h.pixelRatio||1;i=[j[0]/k,j[1]/k,h.displaySize[0]-j[2]/k,h.displaySize[1]-j[3]/k,]}const l=b.left*g,m=b.right*g;let n,o,p,q;"width"===c||"both"===c?(q=f[0]+l-d[3],o=f[0]+m+d[1]):o=(q=f[0]+(l+m-h.displaySize[0])/2)+h.displaySize[0];const r=b.top*g,s=b.bottom*g;return"height"===c||"both"===c?(n=f[1]+r-d[0],p=f[1]+s+d[2]):p=(n=f[1]+(r+s-h.displaySize[1])/2)+h.displaySize[1],{image:h,top:n,right:o,bottom:p,left:q,collisionPadding:i}}class jh extends g{constructor(a,b,c,d,f){super(a,b),this.angle=d,this.z=c,void 0!==f&&(this.segment=f)}clone(){return new jh(this.x,this.y,this.z,this.angle,this.segment)}}function ji(a,b,c,d,f){if(void 0===b.segment)return!0;let g=b,h=b.segment+1,i=0;for(;i> -c/2;){if(--h<0)return!1;i-=a[h].dist(g),g=a[h]}i+=a[h].dist(a[h+1]),h++;const j=[];let k=0;for(;i<c/2;){const l=a[h],m=a[h+1];if(!m)return!1;let n=a[h-1].angleTo(l)-l.angleTo(m);for(n=Math.abs((n+3*Math.PI)%(2*Math.PI)-Math.PI),j.push({distance:i,angleDelta:n}),k+=n;i-j[0].distance>d;)k-=j.shift().angleDelta;if(k>f)return!1;h++,i+=l.dist(m)}return!0}function jj(a){let b=0;for(let c=0;c<a.length-1;c++)b+=a[c].dist(a[c+1]);return b}function jk(a,b,c){return a?.6*b*c:0}function jl(a,b){return Math.max(a?a.right-a.left:0,b?b.right-b.left:0)}function jm(a,b,c,d,f,g){const h=jk(c,f,g),i=jl(c,d)*g;let j=0;const k=jj(a)/2;for(let l=0;l<a.length-1;l++){const m=a[l],n=a[l+1],o=m.dist(n);if(j+o>k){const p=(k-j)/o,q=cr(m.x,n.x,p),r=cr(m.y,n.y,p),s=new jh(q,r,0,n.angleTo(m),l);return!h||ji(a,s,i,h,b)?s:void 0}j+=o}}function jn(a,b,c,d,f,g,h,i,j){const k=jk(d,g,h),l=jl(d,f),m=l*h,n=0===a[0].x||a[0].x===j||0===a[0].y||a[0].y===j;return b-m<b/4&&(b=m+b/4),jo(a,n?b/2*i%b:(l/2+2*g)*h*i%b,b,k,c,m,n,!1,j)}function jo(a,b,c,d,f,g,h,i,j){const k=g/2,l=jj(a);let m=0,n=b-c,o=[];for(let p=0;p<a.length-1;p++){const q=a[p],r=a[p+1],s=q.dist(r),u=r.angleTo(q);for(;n+c<m+s;){n+=c;const v=(n-m)/s,w=cr(q.x,r.x,v),x=cr(q.y,r.y,v);if(w>=0&&w<j&&x>=0&&x<j&&n-k>=0&&n+k<=l){const y=new jh(w,x,0,u,p);y._round(),d&&!ji(a,y,g,d,f)||o.push(y)}}m+=s}return i||o.length||h||(o=jo(a,m/2,c,d,f,g,h,!0,j)),o}function jp(a,b,c,d,f){const h=[];for(let i=0;i<a.length;i++){const j=a[i];let k;for(let l=0;l<j.length-1;l++){let m=j[l],n=j[l+1];m.x<b&&n.x<b||(m.x<b?m=new g(b,m.y+(b-m.x)/(n.x-m.x)*(n.y-m.y))._round():n.x<b&&(n=new g(b,m.y+(b-m.x)/(n.x-m.x)*(n.y-m.y))._round()),m.y<c&&n.y<c||(m.y<c?m=new g(m.x+(c-m.y)/(n.y-m.y)*(n.x-m.x),c)._round():n.y<c&&(n=new g(m.x+(c-m.y)/(n.y-m.y)*(n.x-m.x),c)._round()),m.x>=d&&n.x>=d||(m.x>=d?m=new g(d,m.y+(d-m.x)/(n.x-m.x)*(n.y-m.y))._round():n.x>=d&&(n=new g(d,m.y+(d-m.x)/(n.x-m.x)*(n.y-m.y))._round()),m.y>=f&&n.y>=f||(m.y>=f?m=new g(m.x+(f-m.y)/(n.y-m.y)*(n.x-m.x),f)._round():n.y>=f&&(n=new g(m.x+(f-m.y)/(n.y-m.y)*(n.x-m.x),f)._round()),k&&m.equals(k[k.length-1])||(k=[m],h.push(k)),k.push(n)))))}}return h}function jq(a,b,c,d,f,g,h,i,j){for(let k=b;k<b+d;k++)jr(a,c*g+k,g,f,h,i,j);for(let l=c;l<c+f;l++)jr(a,l*g+b,1,d,h,i,j)}function jr(a,b,c,d,f,g,h){g[0]=0,h[0]=-1e20,h[1]=1e20,f[0]=a[b];for(let i=1,j=0,k=0;i<d;i++){f[i]=a[b+i*c];const l=i*i;do{const m=g[j];k=(f[i]-f[m]+l-m*m)/(i-m)/2}while(k<=h[j]&& --j> -1)g[++j]=i,h[j]=k,h[j+1]=1e20}for(let n=0,o=0;n<d;n++){for(;h[o+1]<n;)o++;const p=g[o],q=n-p;a[b+n*c]=f[p]+q*q}}ec("Anchor",jh);const js={none:0,ideographs:1,all:2};class jt{constructor(a,b,c){this.requestManager=a,this.localGlyphMode=b,this.localFontFamily=c,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(a){this.url=a}getGlyphs(a,b){const c=[];for(const d in a)for(const f of a[d])c.push({stack:d,id:f});$(c,({stack:a,id:b},c)=>{let d=this.entries[a];d||(d=this.entries[a]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let f=d.glyphs[b];if(void 0!==f)return void c(null,{stack:a,id:b,glyph:f});if(f=this._tinySDF(d,a,b))return d.glyphs[b]=f,void c(null,{stack:a,id:b,glyph:f});const g=Math.floor(b/256);if(256*g>65535)return void c(Error("glyphs > 65535 not supported"));if(d.ranges[g])return void c(null,{stack:a,id:b,glyph:f});let h=d.requests[g];h||(h=d.requests[g]=[],jt.loadGlyphRange(a,g,this.url,this.requestManager,(a,b)=>{if(b){for(const c in d.ascender=b.ascender,d.descender=b.descender,b.glyphs)this._doesCharSupportLocalGlyph(+c)||(d.glyphs[+c]=b.glyphs[+c]);d.ranges[g]=!0}for(const f of h)f(a,b);delete d.requests[g]})),h.push((d,f)=>{d?c(d):f&&c(null,{stack:a,id:b,glyph:f.glyphs[b]||null})})},(a,c)=>{if(a)b(a);else if(c){const d={};for(const{stack:f,id:g,glyph:h}of c)void 0===d[f]&&(d[f]={}),void 0===d[f].glyphs&&(d[f].glyphs={}),d[f].glyphs[g]=h&&{id:h.id,bitmap:h.bitmap.clone(),metrics:h.metrics},d[f].ascender=this.entries[f].ascender,d[f].descender=this.entries[f].descender;b(null,d)}})}_doesCharSupportLocalGlyph(a){return this.localGlyphMode!==js.none&&(this.localGlyphMode===js.all?!!this.localFontFamily:!!this.localFontFamily&&(ez(a)||eC(a)||eq(a)||er(a))||ep(a))}_tinySDF(a,b,c){const d=this.localFontFamily;if(!d||!this._doesCharSupportLocalGlyph(c))return;let f=a.tinySDF;if(!f){let g="400";/bold/i.test(b)?g="900":/medium/i.test(b)?g="500":/light/i.test(b)&&(g="200"),(f=a.tinySDF=new jt.TinySDF({fontFamily:d,fontWeight:g,fontSize:48,buffer:6,radius:16})).fontWeight=g}if(this.localGlyphs[f.fontWeight][c])return this.localGlyphs[f.fontWeight][c];const h=String.fromCharCode(c),{data:i,width:j,height:k,glyphWidth:l,glyphHeight:m,glyphLeft:n,glyphTop:o,glyphAdvance:p}=f.draw(h);return this.localGlyphs[f.fontWeight][c]={id:c,bitmap:new ha({width:j,height:k},i),metrics:{width:l/2,height:m/2,left:n/2,top:o/2-27,advance:p/2,localGlyph:!0}}}}function ju(a,b,c,d){const f=[],h=a.image,i=h.pixelRatio,j=h.paddedRect.w-2,k=h.paddedRect.h-2,l=a.right-a.left,m=a.bottom-a.top,n=h.stretchX||[[0,j]],o=h.stretchY||[[0,k]],p=(a,b)=>a+b[1]-b[0],q=n.reduce(p,0),r=o.reduce(p,0),s=j-q,u=k-r;let v=0,w=q,x=0,y=r,z=0,A=s,B=0,C=u;if(h.content&&d){const D=h.content;v=jv(n,0,D[0]),x=jv(o,0,D[1]),w=jv(n,D[0],D[2]),y=jv(o,D[1],D[3]),z=D[0]-v,B=D[1]-x,A=D[2]-D[0]-w,C=D[3]-D[1]-y}const E=(d,f,j,k)=>{const n=(d.stretch-v)/w*l+a.left,o=d.fixed-z-A*d.stretch/q,p=(f.stretch-x)/y*m+a.top,s=f.fixed-B-C*f.stretch/r,u=(j.stretch-v)/w*l+a.left,D=j.fixed-z-A*j.stretch/q,E=(k.stretch-x)/y*m+a.top,F=k.fixed-B-C*k.stretch/r,G=new g(n,p),H=new g(u,p),I=new g(u,E),J=new g(n,E),K=new g(o/i,s/i),L=new g(D/i,F/i),M=b*Math.PI/180;if(M){const N=Math.sin(M),O=Math.cos(M),P=[O,-N,N,O];G._matMult(P),H._matMult(P),J._matMult(P),I._matMult(P)}const Q=d.stretch+d.fixed,R=f.stretch+f.fixed;return{tl:G,tr:H,bl:J,br:I,tex:{x:h.paddedRect.x+1+Q,y:h.paddedRect.y+1+R,w:j.stretch+j.fixed-Q,h:k.stretch+k.fixed-R},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:K,pixelOffsetBR:L,minFontScaleX:A/i/l,minFontScaleY:C/i/m,isSDF:c}};if(d&&(h.stretchX||h.stretchY)){const F=jw(n,s,q),G=jw(o,u,r);for(let H=0;H<F.length-1;H++){const I=F[H],J=F[H+1];for(let K=0;K<G.length-1;K++)f.push(E(I,G[K],J,G[K+1]))}}else f.push(E({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:j+1},{fixed:0,stretch:k+1}));return f}function jv(a,b,c){let d=0;for(const f of a)d+=Math.max(b,Math.min(c,f[1]))-Math.max(b,Math.min(c,f[0]));return d}function jw(a,b,c){const d=[{fixed:-1,stretch:0},];for(const[f,g]of a){const h=d[d.length-1];d.push({fixed:f-h.stretch,stretch:h.stretch}),d.push({fixed:f-h.stretch,stretch:h.stretch+(g-f)})}return d.push({fixed:b+1,stretch:c}),d}function jx(a,b,c,d){const f=b+a.positionedLines[d].lineOffset;return 0===d?c+f/2:c+(f+(b+a.positionedLines[d-1].lineOffset))/2}jt.loadGlyphRange=function(a,b,c,d,f){const g=256*b,h=d.transformRequest(d.normalizeGlyphsURL(c).replace("{fontstack}",a).replace("{range}",`${g}-${g+255}`),a3.Glyphs);a7(h,(a,b)=>{if(a)f(a);else if(b){var c;const d={},g=(c=b,new iG(c).readFields(iX,{}));for(const h of g.glyphs)d[h.id]=h;f(null,{glyphs:d,ascender:g.ascender,descender:g.descender})}})},jt.TinySDF=class{constructor({fontSize:a=24,buffer:b=3,radius:c=8,cutoff:d=.25,fontFamily:f="sans-serif",fontWeight:g="normal",fontStyle:h="normal"}){this.buffer=b,this.cutoff=d,this.radius=c;const i=this.size=a+4*b,j=this._createCanvas(i),k=this.ctx=j.getContext("2d",{willReadFrequently:!0});k.font=`${h} ${g} ${a}px ${f}`,k.textBaseline="alphabetic",k.textAlign="left",k.fillStyle="black",this.gridOuter=new Float64Array(i*i),this.gridInner=new Float64Array(i*i),this.f=new Float64Array(i),this.z=new Float64Array(i+1),this.v=new Uint16Array(i)}_createCanvas(a){const b=document.createElement("canvas");return b.width=b.height=a,b}draw(a){const{width:b,actualBoundingBoxAscent:c,actualBoundingBoxDescent:d,actualBoundingBoxLeft:f,actualBoundingBoxRight:g}=this.ctx.measureText(a),h=Math.floor(c),i=Math.min(this.size-this.buffer,Math.ceil(g-f)),j=Math.min(this.size-this.buffer,Math.ceil(c)+Math.ceil(d)),k=i+2*this.buffer,l=j+2*this.buffer,m=k*l,n=new Uint8ClampedArray(m),o={data:n,width:k,height:l,glyphWidth:i,glyphHeight:j,glyphTop:h,glyphLeft:0,glyphAdvance:b};if(0===i||0===j)return o;const{ctx:p,buffer:q,gridInner:r,gridOuter:s}=this;p.clearRect(q,q,i,j),p.fillText(a,q,q+h+1);const u=p.getImageData(q,q,i,j);s.fill(1e20,0,m),r.fill(0,0,m);for(let v=0;v<j;v++)for(let w=0;w<i;w++){const x=u.data[4*(v*i+w)+3]/255;if(0===x)continue;const y=(v+q)*k+w+q;if(1===x)s[y]=0,r[y]=1e20;else{const z=.5-x;s[y]=z>0?z*z:0,r[y]=z<0?z*z:0}}jq(s,0,0,k,l,k,this.f,this.v,this.z),jq(r,q,q,i,j,k,this.f,this.v,this.z);for(let A=0;A<m;A++){const B=Math.sqrt(s[A])-Math.sqrt(r[A]);n[A]=Math.round(255-255*(B/this.radius+this.cutoff))}return o}};class jy{constructor(a=[],b=function(a,b){return a<b?-1:a>b?1:0}){if(this.data=a,this.length=this.data.length,this.compare=b,this.length>0)for(let c=(this.length>>1)-1;c>=0;c--)this._down(c)}push(a){this.data.push(a),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const a=this.data[0],b=this.data.pop();return this.length--,this.length>0&&(this.data[0]=b,this._down(0)),a}peek(){return this.data[0]}_up(a){const{data:b,compare:c}=this,d=b[a];for(;a>0;){const f=a-1>>1,g=b[f];if(c(d,g)>=0)break;b[a]=g,a=f}b[a]=d}_down(a){const{data:b,compare:c}=this,d=this.length>>1,f=b[a];for(;a<d;){let g=1+(a<<1),h=b[g];const i=g+1;if(i<this.length&&0>c(b[i],h)&&(g=i,h=b[i]),c(h,f)>=0)break;b[a]=h,a=g}b[a]=f}}function jz(a,b=1,c=!1){let d=1/0,f=1/0,h=-1/0,i=-1/0;const j=a[0];for(let k=0;k<j.length;k++){const l=j[k];(!k||l.x<d)&&(d=l.x),(!k||l.y<f)&&(f=l.y),(!k||l.x>h)&&(h=l.x),(!k||l.y>i)&&(i=l.y)}const m=Math.min(h-d,i-f);let n=m/2;const o=new jy([],jA);if(0===m)return new g(d,f);for(let p=d;p<h;p+=m)for(let q=f;q<i;q+=m)o.push(new jB(p+n,q+n,n,a));let r=function(a){let b=0,c=0,d=0;const f=a[0];for(let g=0,h=f.length,i=h-1;g<h;i=g++){const j=f[g],k=f[i],l=j.x*k.y-k.x*j.y;c+=(j.x+k.x)*l,d+=(j.y+k.y)*l,b+=3*l}return new jB(c/b,d/b,0,a)}(a),s=o.length;for(;o.length;){const u=o.pop();(u.d>r.d||!r.d)&&(r=u,c&&console.log("found best %d after %d probes",Math.round(1e4*u.d)/1e4,s)),u.max-r.d<=b||(n=u.h/2,o.push(new jB(u.p.x-n,u.p.y-n,n,a)),o.push(new jB(u.p.x+n,u.p.y-n,n,a)),o.push(new jB(u.p.x-n,u.p.y+n,n,a)),o.push(new jB(u.p.x+n,u.p.y+n,n,a)),s+=4)}return c&&(console.log(`num probes: ${s}`),console.log(`best distance: ${r.d}`)),r.p}function jA(a,b){return b.max-a.max}function jB(a,b,c,d){this.p=new g(a,b),this.h=c,this.d=function(a,b){let c=!1,d=1/0;for(let f=0;f<b.length;f++){const g=b[f];for(let h=0,i=g.length,j=i-1;h<i;j=h++){const k=g[h],l=g[j];k.y>a.y!=l.y>a.y&&a.x<(l.x-k.x)*(a.y-k.y)/(l.y-k.y)+k.x&&(c=!c),d=Math.min(d,gQ(a,k,l))}}return(c?1:-1)*Math.sqrt(d)}(this.p,d),this.max=this.d+this.h*Math.SQRT2}const jC=Number.POSITIVE_INFINITY,jD=Math.sqrt(2);function jE(a,b){return b[1]!==jC?function(a,b,c){let d=0,f=0;switch(b=Math.abs(b),c=Math.abs(c),a){case"top-right":case"top-left":case"top":f=c-7;break;case"bottom-right":case"bottom-left":case"bottom":f=7-c}switch(a){case"top-right":case"bottom-right":case"right":d=-b;break;case"top-left":case"bottom-left":case"left":d=b}return[d,f]}(a,b[0],b[1]):function(a,b){let c=0,d=0;b<0&&(b=0);const f=b/jD;switch(a){case"top-right":case"top-left":d=f-7;break;case"bottom-right":case"bottom-left":d=7-f;break;case"bottom":d=7-b;break;case"top":d=b-7}switch(a){case"top-right":case"bottom-right":c=-f;break;case"top-left":case"bottom-left":c=f;break;case"left":c=b;break;case"right":c=-b}return[c,d]}(a,b[0])}function jF(a,b,c,d,f,g,h,i,j,k){a.createArrays(),a.tilePixelRatio=8192/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const l=a.layers[0].layout,m=a.layers[0]._unevaluatedLayout._values,n={};if("composite"===a.textSizeData.kind){const{minZoom:o,maxZoom:p}=a.textSizeData;n.compositeTextSizes=[m["text-size"].possiblyEvaluate(new e2(o),i),m["text-size"].possiblyEvaluate(new e2(p),i),]}if("composite"===a.iconSizeData.kind){const{minZoom:q,maxZoom:r}=a.iconSizeData;n.compositeIconSizes=[m["icon-size"].possiblyEvaluate(new e2(q),i),m["icon-size"].possiblyEvaluate(new e2(r),i),]}n.layoutTextSize=m["text-size"].possiblyEvaluate(new e2(j+1),i),n.layoutIconSize=m["icon-size"].possiblyEvaluate(new e2(j+1),i),n.textMaxSize=m["text-size"].possiblyEvaluate(new e2(18),i);const s="map"===l.get("text-rotation-alignment")&&"point"!==l.get("symbol-placement"),u=l.get("text-size");for(const v of a.features){const w=l.get("text-font").evaluate(v,{},i).join(","),x=u.evaluate(v,{},i),y=n.layoutTextSize.evaluate(v,{},i),z=(n.layoutIconSize.evaluate(v,{},i),{horizontal:{},vertical:void 0}),A=v.text;let B,C=[0,0];if(A){const D=A.toString(),E=24*l.get("text-letter-spacing").evaluate(v,{},i),F=24*l.get("text-line-height").evaluate(v,{},i),G=eL(D)?E:0,H=l.get("text-anchor").evaluate(v,{},i),I=l.get("text-variable-anchor");if(!I){const J=l.get("text-radial-offset").evaluate(v,{},i);C=J?jE(H,[24*J,jC]):l.get("text-offset").evaluate(v,{},i).map(a=>24*a)}let K=s?"center":l.get("text-justify").evaluate(v,{},i);const L=l.get("symbol-placement"),M="point"===L,N="point"===L?24*l.get("text-max-width").evaluate(v,{},i):0,O=d=>{a.allowVerticalPlacement&&eK(D)&&(z.vertical=i4(A,b,c,f,w,N,F,H,d,G,C,i1.vertical,!0,L,y,x))};if(!s&&I){const P="auto"===K?I.map(a=>jG(a)):[K];let Q=!1;for(let R=0;R<P.length;R++){const S=P[R];if(!z.horizontal[S]){if(Q)z.horizontal[S]=z.horizontal[0];else{const T=i4(A,b,c,f,w,N,F,"center",S,G,C,i1.horizontal,!1,L,y,x);T&&(z.horizontal[S]=T,Q=1===T.positionedLines.length)}}}O("left")}else{if("auto"===K&&(K=jG(H)),M||l.get("text-writing-mode").indexOf("horizontal")>=0||!eK(D)){const U=i4(A,b,c,f,w,N,F,H,K,G,C,i1.horizontal,!1,L,y,x);U&&(z.horizontal[K]=U)}O("point"===L?"left":K)}}let V=!1;if(v.icon&&v.icon.name){const W=d[v.icon.name];W&&(B=jf(f[v.icon.name],l.get("icon-offset").evaluate(v,{},i),l.get("icon-anchor").evaluate(v,{},i)),V=W.sdf,void 0===a.sdfIcons?a.sdfIcons=W.sdf:a.sdfIcons!==W.sdf&&am("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(W.pixelRatio!==a.pixelRatio||0!==l.get("icon-rotate").constantOr(1))&&(a.iconsNeedLinear=!0))}const X=jK(z.horizontal)||z.vertical;a.iconsInText||(a.iconsInText=!!X&&X.iconsInText),(X||B)&&jH(a,v,z,B,d,n,y,0,C,V,h,i,k)}g&&a.generateCollisionDebugBuffers(j,a.collisionBoxArray)}function jG(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function jH(a,b,c,d,f,g,h,i,j,k,l,m,n){let o=g.textMaxSize.evaluate(b,{},m);void 0===o&&(o=h);const p=a.layers[0].layout,q=p.get("icon-offset").evaluate(b,{},m),r=jK(c.horizontal)||c.vertical,s=h/24,u=a.tilePixelRatio*o/24,v=a.tilePixelRatio*p.get("symbol-spacing"),w=p.get("text-padding")*a.tilePixelRatio,x=p.get("icon-padding")*a.tilePixelRatio,y=p.get("text-max-angle")*P,z="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),A="map"===p.get("icon-rotation-alignment")&&"point"!==p.get("symbol-placement"),B=p.get("symbol-placement"),C=v/2,D=p.get("icon-text-fit");let E;d&&"none"!==D&&(a.allowVerticalPlacement&&c.vertical&&(E=jg(d,c.vertical,D,p.get("icon-text-fit-padding"),q,s)),r&&(d=jg(d,r,D,p.get("icon-text-fit-padding"),q,s)));const F=(h,i,o)=>{if(i.x<0||i.x>=8192||i.y<0||i.y>=8192)return;const{x:p,y:r,z:s}=n.projectTilePoint(i.x,i.y,o),u=new jh(p,r,s,0,void 0);!function(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w,x,y,z,A){const B=a.addToLineVertexArray(b,d);let C,D,E,F,G,H,I,J=0,K=0,L=0,M=0,N=-1,O=-1;const P={};let Q=fZ(""),R=0,S=0;if(void 0===j._unevaluatedLayout.getValue("text-radial-offset")?[R,S]=j.layout.get("text-offset").evaluate(w,{},A).map(a=>24*a):(R=24*j.layout.get("text-radial-offset").evaluate(w,{},A),S=jC),a.allowVerticalPlacement&&f.vertical){const T=f.vertical;if(p)H=jM(T),i&&(I=jM(i));else{const U=j.layout.get("text-rotate").evaluate(w,{},A)+90;E=jL(k,c,b,l,m,n,T,o,U,q),i&&(F=jL(k,c,b,l,m,n,i,s,U))}}if(g){const V=j.layout.get("icon-rotate").evaluate(w,{},A),W="none"!==j.layout.get("icon-text-fit"),X=ju(g,V,y,W),Y=i?ju(i,V,y,W):void 0;D=jL(k,c,b,l,m,n,g,s,V),J=4*X.length;const Z=a.iconSizeData;let $=null;"source"===Z.kind?($=[128*j.layout.get("icon-size").evaluate(w,{},A),])[0]>jI&&am(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Z.kind&&(($=[128*x.compositeIconSizes[0].evaluate(w,{},A),128*x.compositeIconSizes[1].evaluate(w,{},A),])[0]>jI||$[1]>jI)&&am(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),a.addSymbols(a.icon,X,$,v,u,w,!1,c,b,B.lineStartIndex,B.lineLength,-1,z,A),N=a.icon.placedSymbolArray.length-1,Y&&(K=4*Y.length,a.addSymbols(a.icon,Y,$,v,u,w,i1.vertical,c,b,B.lineStartIndex,B.lineLength,-1,z,A),O=a.icon.placedSymbolArray.length-1)}for(const _ in f.horizontal){const aa=f.horizontal[_];C||(Q=fZ(aa.text),p?G=jM(aa):C=jL(k,c,b,l,m,n,aa,o,j.layout.get("text-rotate").evaluate(w,{},A),q));const ab=1===aa.positionedLines.length;if(L+=jJ(a,c,b,aa,h,j,p,w,q,B,f.vertical?i1.horizontal:i1.horizontalOnly,ab?Object.keys(f.horizontal):[_],P,N,x,z,A),ab)break}f.vertical&&(M+=jJ(a,c,b,f.vertical,h,j,p,w,q,B,i1.vertical,["vertical"],P,O,x,z,A));let ac=-1;const ad=(a,b)=>a?Math.max(a,b):b;ac=ad(G,ac),ac=ad(H,ac),ac=ad(I,ac);const ae=ac> -1?1:0;a.glyphOffsetArray.length>=jV.MAX_GLYPHS&&am("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&a.addToSortKeyRanges(a.symbolInstances.length,w.sortKey),a.symbolInstances.emplaceBack(c.x,c.y,c.z,b.x,b.y,P.right>=0?P.right:-1,P.center>=0?P.center:-1,P.left>=0?P.left:-1,P.vertical>=0?P.vertical:-1,N,O,Q,void 0!==C?C:a.collisionBoxArray.length,void 0!==C?C+1:a.collisionBoxArray.length,void 0!==E?E:a.collisionBoxArray.length,void 0!==E?E+1:a.collisionBoxArray.length,void 0!==D?D:a.collisionBoxArray.length,void 0!==D?D+1:a.collisionBoxArray.length,F||a.collisionBoxArray.length,F?F+1:a.collisionBoxArray.length,l,L,M,J,K,ae,0,R,S,ac)}(a,i,u,h,c,d,f,E,a.layers[0],a.collisionBoxArray,b.index,b.sourceLayerIndex,a.index,w,z,j,0,x,A,q,b,g,k,l,m)};if("line"===B)for(const G of jp(b.geometry,0,0,8192,8192)){const H=jn(G,v,y,c.vertical||r,d,24,u,a.overscaling,8192);for(const I of H){const J=r;J&&jN(a,J.text,C,I)||F(G,I,m)}}else if("line-center"===B){for(const K of b.geometry)if(K.length>1){const L=jm(K,y,c.vertical||r,d,24,u);L&&F(K,L,m)}}else if("Polygon"===b.type)for(const M of hM(b.geometry,0)){const N=jz(M,16);F(M[0],new jh(N.x,N.y,0,0,void 0),m)}else if("LineString"===b.type)for(const O of b.geometry)F(O,new jh(O[0].x,O[0].y,0,0,void 0),m);else if("Point"===b.type)for(const Q of b.geometry)for(const R of Q)F([R],new jh(R.x,R.y,0,0,void 0),m)}const jI=32640;function jJ(a,b,c,d,f,h,i,j,k,l,m,n,o,p,q,r,s){const u=function(a,b,c,d,f,h,i,j){const k=[];if(0===b.positionedLines.length)return k;const l=d.layout.get("text-rotate").evaluate(h,{})*Math.PI/180,m=function(a){const b=a[0],c=a[1],d=b*c;return d>0?[b,-c]:d<0?[-b,c]:0===b?[c,b]:[c,-b]}(c);let n=Math.abs(b.top-b.bottom);for(const o of b.positionedLines)n-=o.lineOffset;const p=b.positionedLines.length,q=n/p;let r=b.top-c[1];for(let s=0;s<p;++s){const u=b.positionedLines[s];for(const v of(r=jx(b,q,r,s),u.positionedGlyphs)){if(!v.rect)continue;const w=v.rect||{};let x=4,y=!0,z=1,A=0;if(v.imageName){const B=i[v.imageName];if(!B)continue;if(B.sdf){am("SDF images are not supported in formatted text and will be ignored.");continue}y=!1,x=1/(z=B.pixelRatio)}const C=(f||j)&&v.vertical,D=v.metrics.advance*v.scale/2,E=v.metrics,F=v.rect;if(null===F)continue;j&&b.verticalizable&&(A=v.imageName?D-v.metrics.width*v.scale/2:0);const G=f?[v.x+D,v.y]:[0,0];let H=[0,0],I=[0,0],J=!1;f||(C?(I=[v.x+D+m[0],v.y+m[1]-A,],J=!0):H=[v.x+D+c[0],v.y+c[1]-A,]);const K=F.w*v.scale/(z*(v.localGlyph?2:1)),L=F.h*v.scale/(z*(v.localGlyph?2:1));let M,N,O,P;if(C){const Q=v.y-r,R=new g(-D,D-Q),S=-Math.PI/2,T=new g(...I);(M=new g(-D+H[0],H[1]))._rotateAround(S,R)._add(T),M.x+=-Q+D,M.y-=(E.left-x)*v.scale;const U=v.imageName?E.advance*v.scale:24*v.scale,V=String.fromCharCode(v.glyph);iC(V)?M.x+=(1-x)*v.scale:iD(V)?M.x+=U-E.height*v.scale+(-x-1)*v.scale:M.x+=v.imageName||E.width+2*x===F.w&&E.height+2*x===F.h?(U-L)/2:(U-(E.height+2*x)*v.scale)/2,N=new g(M.x,M.y-K),O=new g(M.x+L,M.y),P=new g(M.x+L,M.y-K)}else{const W=(E.left-x)*v.scale-D+H[0],X=(-E.top-x)*v.scale+H[1],Y=W+K,Z=X+L;M=new g(W,X),N=new g(Y,X),O=new g(W,Z),P=new g(Y,Z)}if(l){let $;$=f?new g(0,0):J?new g(m[0],m[1]):new g(c[0],c[1]),M._rotateAround(l,$),N._rotateAround(l,$),O._rotateAround(l,$),P._rotateAround(l,$)}const _=new g(0,0),aa=new g(0,0);k.push({tl:M,tr:N,bl:O,br:P,tex:w,writingMode:b.writingMode,glyphOffset:G,sectionIndex:v.sectionIndex,isSDF:y,pixelOffsetTL:_,pixelOffsetBR:aa,minFontScaleX:0,minFontScaleY:0})}}return k}(0,d,k,h,i,j,f,a.allowVerticalPlacement),v=a.textSizeData;let w=null;for(const x of("source"===v.kind?(w=[128*h.layout.get("text-size").evaluate(j,{},s),])[0]>jI&&am(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===v.kind&&((w=[128*q.compositeTextSizes[0].evaluate(j,{},s),128*q.compositeTextSizes[1].evaluate(j,{},s),])[0]>jI||w[1]>jI)&&am(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),a.addSymbols(a.text,u,w,k,i,j,m,b,c,l.lineStartIndex,l.lineLength,p,r,s),n))o[x]=a.text.placedSymbolArray.length-1;return 4*u.length}function jK(a){for(const b in a)return a[b];return null}function jL(a,b,c,d,f,h,i,j,k,l){let m=i.top,n=i.bottom,o=i.left,p=i.right;const q=i.collisionPadding;if(q&&(o-=q[0],m-=q[1],p+=q[2],n+=q[3]),k){const r=new g(o,m),s=new g(p,m),u=new g(o,n),v=new g(p,n),w=k*P;let x=new g(0,0);l&&(x=new g(l[0],l[1])),r._rotateAround(w,x),s._rotateAround(w,x),u._rotateAround(w,x),v._rotateAround(w,x),o=Math.min(r.x,s.x,u.x,v.x),p=Math.max(r.x,s.x,u.x,v.x),m=Math.min(r.y,s.y,u.y,v.y),n=Math.max(r.y,s.y,u.y,v.y)}return a.emplaceBack(b.x,b.y,b.z,c.x,c.y,o,m,p,n,j,d,f,h),a.length-1}function jM(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const b=a.bottom-a.top;return b>0?Math.max(10,b):null}function jN(a,b,c,d){const f=a.compareText;if(b in f){const g=f[b];for(let h=g.length-1;h>=0;h--)if(d.dist(g[h])<c)return!0}else f[b]=[];return f[b].push(d),!1}const jO=h2.VectorTileFeature.types,jP=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0},];function jQ(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q){const r=l?Math.min(jI,Math.round(l[0])):0,s=l?Math.min(jI,Math.round(l[1])):0;a.emplaceBack(b,c,Math.round(32*h),Math.round(32*i),j,k,(r<<1)+(m?1:0),s,16*n,16*o,256*p,256*q,d,f,g,0)}function jR(a,b,c){a.emplaceBack(b.x,b.y,c),a.emplaceBack(b.x,b.y,c),a.emplaceBack(b.x,b.y,c),a.emplaceBack(b.x,b.y,c)}function jS(a){for(const b of a.sections)if(eR(b.text))return!0;return!1}class jT{constructor(a){this.layoutVertexArray=new fs,this.indexArray=new fy,this.programConfigurations=a,this.segments=new gq,this.dynamicLayoutVertexArray=new fp,this.opacityVertexArray=new ft,this.placedSymbolArray=new fM}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(a,b,c,d){this.isEmpty()||(c&&(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,iq.members),this.indexBuffer=a.createIndexBuffer(this.indexArray,b),this.dynamicLayoutVertexBuffer=a.createVertexBuffer(this.dynamicLayoutVertexArray,ir.members,!0),this.opacityVertexBuffer=a.createVertexBuffer(this.opacityVertexArray,jP,!0),this.opacityVertexBuffer.itemSize=1),(c||d)&&this.programConfigurations.upload(a))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ec("SymbolBuffers",jT);class jU{constructor(a,b,c){this.layoutVertexArray=new a,this.layoutAttributes=b,this.indexArray=new c,this.segments=new gq,this.collisionVertexArray=new fx,this.collisionVertexArrayExt=new fp}upload(a){this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=a.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=a.createVertexBuffer(this.collisionVertexArray,is.members,!0),this.collisionVertexBufferExt=a.createVertexBuffer(this.collisionVertexArrayExt,it.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ec("CollisionBuffers",jU);class jV{constructor(a){this.collisionBoxArray=a.collisionBoxArray,this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.pixelRatio=a.pixelRatio,this.sourceLayerIndex=a.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=l([]),this.placementViewportMatrix=l([]);const b=this.layers[0]._unevaluatedLayout._values;this.textSizeData=iw(this.zoom,b["text-size"]),this.iconSizeData=iw(this.zoom,b["icon-size"]);const c=this.layers[0].layout,d=c.get("symbol-sort-key"),f=c.get("symbol-z-order");this.canOverlap=c.get("text-allow-overlap")||c.get("icon-allow-overlap")||c.get("text-ignore-placement")||c.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==f&& void 0!==d.constantOr(1),this.sortFeaturesByY=("viewport-y"===f||"auto"===f&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=c.get("text-writing-mode").map(a=>i1[a]),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.sourceID=a.sourceID}createArrays(){this.text=new jT(new gg(this.layers,this.zoom,a=>/^text/.test(a))),this.icon=new jT(new gg(this.layers,this.zoom,a=>/^icon/.test(a))),this.glyphOffsetArray=new fP,this.lineVertexArray=new fQ,this.symbolInstances=new fO}calculateGlyphDependencies(a,b,c,d,f){for(let g=0;g<a.length;g++)if(b[a.charCodeAt(g)]=!0,d&&f){const h=iB[a.charAt(g)];h&&(b[h.charCodeAt(0)]=!0)}}populate(a,b,c,d){const f=this.layers[0],g=f.layout,h=g.get("text-font"),i=g.get("text-field"),j=g.get("icon-image"),k=("constant"!==i.value.kind||i.value.value instanceof bN&&!i.value.value.isEmpty()||i.value.value.toString().length>0)&&("constant"!==h.value.kind||h.value.value.length>0),l="constant"!==j.value.kind||!!j.value.value||Object.keys(j.parameters).length>0,m=g.get("symbol-sort-key");if(this.features=[],!k&&!l)return;const n=b.iconDependencies,o=b.glyphDependencies,p=b.availableImages,q=new e2(this.zoom);for(const{feature:r,id:s,index:u,sourceLayerIndex:v}of a){const w=f._featureFilter.needGeometry,x=gG(r,w);if(!f._featureFilter.filter(q,x,c))continue;let y,z;if(w||(x.geometry=gF(r,c,d)),k){const A=f.getValueAndResolveTokens("text-field",x,c,p),B=bN.factory(A);jS(B)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===e_()||this.hasRTLText&&e1.isParsed())&&(y=iA(B,f,x))}if(l){const C=f.getValueAndResolveTokens("icon-image",x,c,p);z=C instanceof bO?C:bO.fromString(C)}if(!y&&!z)continue;const D=this.sortFeaturesByKey?m.evaluate(x,{},c):void 0;if(this.features.push({id:s,text:y,icon:z,index:u,sourceLayerIndex:v,geometry:x.geometry,properties:r.properties,type:jO[r.type],sortKey:D}),z&&(n[z.name]=!0),y){const E=h.evaluate(x,{},c).join(","),F="map"===g.get("text-rotation-alignment")&&"point"!==g.get("symbol-placement");for(const G of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(i1.vertical)>=0,y.sections))if(G.image)n[G.image.name]=!0;else{const H=eK(y.toString()),I=G.fontStack||E,J=o[I]=o[I]||{};this.calculateGlyphDependencies(G.text,J,F,this.allowVerticalPlacement,H)}}}"line"===g.get("symbol-placement")&&(this.features=function(a){const b={},c={},d=[];let f=0;function g(b){d.push(a[b]),f++}function h(a,b,f){const g=c[a];return delete c[a],c[b]=g,d[g].geometry[0].pop(),d[g].geometry[0]=d[g].geometry[0].concat(f[0]),g}function i(a,c,f){const g=b[c];return delete b[c],b[a]=g,d[g].geometry[0].shift(),d[g].geometry[0]=f[0].concat(d[g].geometry[0]),g}function j(a,b,c){const d=c?b[0][b[0].length-1]:b[0][0];return`${a}:${d.x}:${d.y}`}for(let k=0;k<a.length;k++){const l=a[k],m=l.geometry,n=l.text?l.text.toString():null;if(!n){g(k);continue}const o=j(n,m),p=j(n,m,!0);if(o in c&&p in b&&c[o]!==b[p]){const q=i(o,p,m),r=h(o,p,d[q].geometry);delete b[o],delete c[p],c[j(n,d[r].geometry,!0)]=r,d[q].geometry=null}else o in c?h(o,p,m):p in b?i(o,p,m):(g(k),b[o]=f-1,c[p]=f-1)}return d.filter(a=>a.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((a,b)=>a.sortKey-b.sortKey)}update(a,b,c,d){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(a,b,this.layers,c,d),this.icon.programConfigurations.updatePaintArrays(a,b,this.layers,c,d))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(a){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(a),this.iconCollisionBox.upload(a)),this.text.upload(a,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(a,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(a,b){const c=this.lineVertexArray.length;if(void 0!==a.segment){let d=a.dist(b[a.segment+1]),f=a.dist(b[a.segment]);const g={};for(let h=a.segment+1;h<b.length;h++)g[h]={x:b[h].x,y:b[h].y,tileUnitDistanceFromAnchor:d},h<b.length-1&&(d+=b[h+1].dist(b[h]));for(let i=a.segment||0;i>=0;i--)g[i]={x:b[i].x,y:b[i].y,tileUnitDistanceFromAnchor:f},i>0&&(f+=b[i-1].dist(b[i]));for(let j=0;j<b.length;j++){const k=g[j];this.lineVertexArray.emplaceBack(k.x,k.y,k.tileUnitDistanceFromAnchor)}}return{lineStartIndex:c,lineLength:this.lineVertexArray.length-c}}addSymbols(a,b,c,d,f,g,h,i,j,k,l,m,n,o){const p=a.indexArray,q=a.layoutVertexArray,r=a.segments.prepareSegment(4*b.length,q,p,this.canOverlap?g.sortKey:void 0),s=this.glyphOffsetArray.length,u=r.vertexLength,v=this.allowVerticalPlacement&&h===i1.vertical?Math.PI/2:0,w=g.text&&g.text.sections;for(let x=0;x<b.length;x++){const{tl:y,tr:z,bl:A,br:B,tex:C,pixelOffsetTL:D,pixelOffsetBR:E,minFontScaleX:F,minFontScaleY:G,glyphOffset:H,isSDF:I,sectionIndex:J}=b[x],K=r.vertexLength,L=H[1];jQ(q,i.x,i.y,i.z,j.x,j.y,y.x,L+y.y,C.x,C.y,c,I,D.x,D.y,F,G),jQ(q,i.x,i.y,i.z,j.x,j.y,z.x,L+z.y,C.x+C.w,C.y,c,I,E.x,D.y,F,G),jQ(q,i.x,i.y,i.z,j.x,j.y,A.x,L+A.y,C.x,C.y+C.h,c,I,D.x,E.y,F,G),jQ(q,i.x,i.y,i.z,j.x,j.y,B.x,L+B.y,C.x+C.w,C.y+C.h,c,I,E.x,E.y,F,G),jR(a.dynamicLayoutVertexArray,i,v),p.emplaceBack(K,K+1,K+2),p.emplaceBack(K+1,K+2,K+3),r.vertexLength+=4,r.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(H[0]),x!==b.length-1&&J===b[x+1].sectionIndex||a.programConfigurations.populatePaintArrays(q.length,g,g.index,{},n,o,w&&w[J])}a.placedSymbolArray.emplaceBack(i.x,i.y,i.z,j.x,j.y,s,this.glyphOffsetArray.length-s,u,k,l,j.segment,c?c[0]:0,c?c[1]:0,d[0],d[1],h,0,!1,0,m,0)}_commitLayoutVertex(a,b,c,d,f,g,h){a.emplaceBack(b,c,d,f,g,Math.round(h.x),Math.round(h.y))}_addCollisionDebugVertices(a,b,c,d,f,h,i){const j=c.segments.prepareSegment(4,c.layoutVertexArray,c.indexArray),k=j.vertexLength,l=i.tileAnchorX,m=i.tileAnchorY;for(let n=0;n<4;n++)c.collisionVertexArray.emplaceBack(0,0,0,0);c.collisionVertexArrayExt.emplaceBack(b,-a.padding,-a.padding),c.collisionVertexArrayExt.emplaceBack(b,a.padding,-a.padding),c.collisionVertexArrayExt.emplaceBack(b,a.padding,a.padding),c.collisionVertexArrayExt.emplaceBack(b,-a.padding,a.padding),this._commitLayoutVertex(c.layoutVertexArray,d,f,h,l,m,new g(a.x1,a.y1)),this._commitLayoutVertex(c.layoutVertexArray,d,f,h,l,m,new g(a.x2,a.y1)),this._commitLayoutVertex(c.layoutVertexArray,d,f,h,l,m,new g(a.x2,a.y2)),this._commitLayoutVertex(c.layoutVertexArray,d,f,h,l,m,new g(a.x1,a.y2)),j.vertexLength+=4;const o=c.indexArray;o.emplaceBack(k,k+1),o.emplaceBack(k+1,k+2),o.emplaceBack(k+2,k+3),o.emplaceBack(k+3,k),j.primitiveLength+=4}_addTextDebugCollisionBoxes(a,b,c,d,f,g){for(let h=d;h<f;h++){const i=c.get(h),j=this.getSymbolInstanceTextSize(a,g,b,h);this._addCollisionDebugVertices(i,j,this.textCollisionBox,i.projectedAnchorX,i.projectedAnchorY,i.projectedAnchorZ,g)}}_addIconDebugCollisionBoxes(a,b,c,d,f,g){for(let h=d;h<f;h++){const i=c.get(h),j=this.getSymbolInstanceIconSize(a,b,h);this._addCollisionDebugVertices(i,j,this.iconCollisionBox,i.projectedAnchorX,i.projectedAnchorY,i.projectedAnchorZ,g)}}generateCollisionDebugBuffers(a,b){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new jU(fv,iu.members,fF),this.iconCollisionBox=new jU(fv,iu.members,fF);const c=iy(this.iconSizeData,a),d=iy(this.textSizeData,a);for(let f=0;f<this.symbolInstances.length;f++){const g=this.symbolInstances.get(f);this._addTextDebugCollisionBoxes(d,a,b,g.textBoxStartIndex,g.textBoxEndIndex,g),this._addTextDebugCollisionBoxes(d,a,b,g.verticalTextBoxStartIndex,g.verticalTextBoxEndIndex,g),this._addIconDebugCollisionBoxes(c,a,b,g.iconBoxStartIndex,g.iconBoxEndIndex,g),this._addIconDebugCollisionBoxes(c,a,b,g.verticalIconBoxStartIndex,g.verticalIconBoxEndIndex,g)}}getSymbolInstanceTextSize(a,b,c,d){const f=this.text.placedSymbolArray.get(b.rightJustifiedTextSymbolIndex>=0?b.rightJustifiedTextSymbolIndex:b.centerJustifiedTextSymbolIndex>=0?b.centerJustifiedTextSymbolIndex:b.leftJustifiedTextSymbolIndex>=0?b.leftJustifiedTextSymbolIndex:b.verticalPlacedTextSymbolIndex>=0?b.verticalPlacedTextSymbolIndex:d),g=ix(this.textSizeData,a,f)/24;return this.tilePixelRatio*g}getSymbolInstanceIconSize(a,b,c){const d=this.icon.placedSymbolArray.get(c),f=ix(this.iconSizeData,a,d);return this.tilePixelRatio*f}_commitDebugCollisionVertexUpdate(a,b,c){a.emplaceBack(b,-c,-c),a.emplaceBack(b,c,-c),a.emplaceBack(b,c,c),a.emplaceBack(b,-c,c)}_updateTextDebugCollisionBoxes(a,b,c,d,f,g){for(let h=d;h<f;h++){const i=c.get(h),j=this.getSymbolInstanceTextSize(a,g,b,h);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,j,i.padding)}}_updateIconDebugCollisionBoxes(a,b,c,d,f){for(let g=d;g<f;g++){const h=c.get(g),i=this.getSymbolInstanceIconSize(a,b,g);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,i,h.padding)}}updateCollisionDebugBuffers(a,b){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const c=iy(this.iconSizeData,a),d=iy(this.textSizeData,a);for(let f=0;f<this.symbolInstances.length;f++){const g=this.symbolInstances.get(f);this._updateTextDebugCollisionBoxes(d,a,b,g.textBoxStartIndex,g.textBoxEndIndex,g),this._updateTextDebugCollisionBoxes(d,a,b,g.verticalTextBoxStartIndex,g.verticalTextBoxEndIndex,g),this._updateIconDebugCollisionBoxes(c,a,b,g.iconBoxStartIndex,g.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(c,a,b,g.verticalIconBoxStartIndex,g.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(a,b,c,d,f,g,h,i,j){const k={};for(let l=b;l<c;l++){const m=a.get(l);k.textBox={x1:m.x1,y1:m.y1,x2:m.x2,y2:m.y2,padding:m.padding,projectedAnchorX:m.projectedAnchorX,projectedAnchorY:m.projectedAnchorY,projectedAnchorZ:m.projectedAnchorZ,tileAnchorX:m.tileAnchorX,tileAnchorY:m.tileAnchorY},k.textFeatureIndex=m.featureIndex;break}for(let n=d;n<f;n++){const o=a.get(n);k.verticalTextBox={x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2,padding:o.padding,projectedAnchorX:o.projectedAnchorX,projectedAnchorY:o.projectedAnchorY,projectedAnchorZ:o.projectedAnchorZ,tileAnchorX:o.tileAnchorX,tileAnchorY:o.tileAnchorY},k.verticalTextFeatureIndex=o.featureIndex;break}for(let p=g;p<h;p++){const q=a.get(p);k.iconBox={x1:q.x1,y1:q.y1,x2:q.x2,y2:q.y2,padding:q.padding,projectedAnchorX:q.projectedAnchorX,projectedAnchorY:q.projectedAnchorY,projectedAnchorZ:q.projectedAnchorZ,tileAnchorX:q.tileAnchorX,tileAnchorY:q.tileAnchorY},k.iconFeatureIndex=q.featureIndex;break}for(let r=i;r<j;r++){const s=a.get(r);k.verticalIconBox={x1:s.x1,y1:s.y1,x2:s.x2,y2:s.y2,padding:s.padding,projectedAnchorX:s.projectedAnchorX,projectedAnchorY:s.projectedAnchorY,projectedAnchorZ:s.projectedAnchorZ,tileAnchorX:s.tileAnchorX,tileAnchorY:s.tileAnchorY},k.verticalIconFeatureIndex=s.featureIndex;break}return k}deserializeCollisionBoxes(a){this.collisionArrays=[];for(let b=0;b<this.symbolInstances.length;b++){const c=this.symbolInstances.get(b);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(a,c.textBoxStartIndex,c.textBoxEndIndex,c.verticalTextBoxStartIndex,c.verticalTextBoxEndIndex,c.iconBoxStartIndex,c.iconBoxEndIndex,c.verticalIconBoxStartIndex,c.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(a,b){const c=a.placedSymbolArray.get(b),d=c.vertexStartIndex+4*c.numGlyphs;for(let f=c.vertexStartIndex;f<d;f+=4)a.indexArray.emplaceBack(f,f+1,f+2),a.indexArray.emplaceBack(f+1,f+2,f+3)}getSortedSymbolIndexes(a){if(this.sortedAngle===a&& void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const b=Math.sin(a),c=Math.cos(a),d=[],f=[],g=[];for(let h=0;h<this.symbolInstances.length;++h){g.push(h);const i=this.symbolInstances.get(h);d.push(0|Math.round(b*i.tileAnchorX+c*i.tileAnchorY)),f.push(i.featureIndex)}return g.sort((a,b)=>d[a]-d[b]||f[b]-f[a]),g}addToSortKeyRanges(a,b){const c=this.sortKeyRanges[this.sortKeyRanges.length-1];c&&c.sortKey===b?c.symbolInstanceEnd=a+1:this.sortKeyRanges.push({sortKey:b,symbolInstanceStart:a,symbolInstanceEnd:a+1})}sortFeatures(a){if(this.sortFeaturesByY&&this.sortedAngle!==a&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const b of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(a),this.sortedAngle=a,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const c=this.symbolInstances.get(b);this.featureSortOrder.push(c.featureIndex),[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex,].forEach((a,b,c)=>{a>=0&&c.indexOf(a)===b&&this.addIndicesForPlacedSymbol(this.text,a)}),c.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,c.verticalPlacedTextSymbolIndex),c.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.placedIconSymbolIndex),c.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,c.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ec("SymbolBucket",jV,{omit:["layers","collisionBoxArray","features","compareText",]}),jV.MAX_GLYPHS=65535,jV.addDynamicAttributes=jR;const jW=new ff({"symbol-placement":new fa(bk.layout_symbol["symbol-placement"]),"symbol-spacing":new fa(bk.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new fa(bk.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new fb(bk.layout_symbol["symbol-sort-key"]),"symbol-z-order":new fa(bk.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new fa(bk.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new fa(bk.layout_symbol["icon-ignore-placement"]),"icon-optional":new fa(bk.layout_symbol["icon-optional"]),"icon-rotation-alignment":new fa(bk.layout_symbol["icon-rotation-alignment"]),"icon-size":new fb(bk.layout_symbol["icon-size"]),"icon-text-fit":new fa(bk.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new fa(bk.layout_symbol["icon-text-fit-padding"]),"icon-image":new fb(bk.layout_symbol["icon-image"]),"icon-rotate":new fb(bk.layout_symbol["icon-rotate"]),"icon-padding":new fa(bk.layout_symbol["icon-padding"]),"icon-keep-upright":new fa(bk.layout_symbol["icon-keep-upright"]),"icon-offset":new fb(bk.layout_symbol["icon-offset"]),"icon-anchor":new fb(bk.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new fa(bk.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new fa(bk.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new fa(bk.layout_symbol["text-rotation-alignment"]),"text-field":new fb(bk.layout_symbol["text-field"]),"text-font":new fb(bk.layout_symbol["text-font"]),"text-size":new fb(bk.layout_symbol["text-size"]),"text-max-width":new fb(bk.layout_symbol["text-max-width"]),"text-line-height":new fb(bk.layout_symbol["text-line-height"]),"text-letter-spacing":new fb(bk.layout_symbol["text-letter-spacing"]),"text-justify":new fb(bk.layout_symbol["text-justify"]),"text-radial-offset":new fb(bk.layout_symbol["text-radial-offset"]),"text-variable-anchor":new fa(bk.layout_symbol["text-variable-anchor"]),"text-anchor":new fb(bk.layout_symbol["text-anchor"]),"text-max-angle":new fa(bk.layout_symbol["text-max-angle"]),"text-writing-mode":new fa(bk.layout_symbol["text-writing-mode"]),"text-rotate":new fb(bk.layout_symbol["text-rotate"]),"text-padding":new fa(bk.layout_symbol["text-padding"]),"text-keep-upright":new fa(bk.layout_symbol["text-keep-upright"]),"text-transform":new fb(bk.layout_symbol["text-transform"]),"text-offset":new fb(bk.layout_symbol["text-offset"]),"text-allow-overlap":new fa(bk.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new fa(bk.layout_symbol["text-ignore-placement"]),"text-optional":new fa(bk.layout_symbol["text-optional"])});var jX={paint:new ff({"icon-opacity":new fb(bk.paint_symbol["icon-opacity"]),"icon-color":new fb(bk.paint_symbol["icon-color"]),"icon-halo-color":new fb(bk.paint_symbol["icon-halo-color"]),"icon-halo-width":new fb(bk.paint_symbol["icon-halo-width"]),"icon-halo-blur":new fb(bk.paint_symbol["icon-halo-blur"]),"icon-translate":new fa(bk.paint_symbol["icon-translate"]),"icon-translate-anchor":new fa(bk.paint_symbol["icon-translate-anchor"]),"text-opacity":new fb(bk.paint_symbol["text-opacity"]),"text-color":new fb(bk.paint_symbol["text-color"],{runtimeType:bw,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new fb(bk.paint_symbol["text-halo-color"]),"text-halo-width":new fb(bk.paint_symbol["text-halo-width"]),"text-halo-blur":new fb(bk.paint_symbol["text-halo-blur"]),"text-translate":new fa(bk.paint_symbol["text-translate"]),"text-translate-anchor":new fa(bk.paint_symbol["text-translate-anchor"])}),layout:jW};class jY{constructor(a){this.type=a.property.overrides?a.property.overrides.runtimeType:bs,this.defaultValue=a}evaluate(a){if(a.formattedSection){const b=this.defaultValue.property.overrides;if(b&&b.hasOverride(a.formattedSection))return b.getOverride(a.formattedSection)}return a.feature&&a.featureState?this.defaultValue.evaluate(a.feature,a.featureState):this.defaultValue.property.specification.default}eachChild(a){this.defaultValue.isConstant()||a(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ec("FormatSectionOverride",jY,{omit:["defaultValue"]});class jZ extends gn{constructor(a){super(a,jX)}recalculate(a,b){super.recalculate(a,b),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const c=this.layout.get("text-writing-mode");if(c){const d=[];for(const f of c)0>d.indexOf(f)&&d.push(f);this.layout._values["text-writing-mode"]=d}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(a,b,c,d){var f;const g=this.layout.get(a).evaluate(b,{},c,d),h=this._unevaluatedLayout._values[a];return h.isDataDriven()||dj(h.value)||!g?g:(f=b.properties,g.replace(/{([^{}]+)}/g,(a,b)=>b in f?String(f[b]):""))}createBucket(a){return new jV(a)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const a of jX.paint.overridableProperties){if(!jZ.hasPaintOverride(this.layout,a))continue;const b=this.paint.get(a),c=new jY(b),d=new di(c,b.property.specification);let f=null;f="constant"===b.value.kind||"source"===b.value.kind?new dl("source",d):new dm("composite",d,b.value.zoomStops,b.value._interpolationType),this.paint._values[a]=new e8(b.property,f,b.parameters)}}_handleOverridablePaintPropertyUpdate(a,b,c){return!(!this.layout||b.isDataDriven()||c.isDataDriven())&&jZ.hasPaintOverride(this.layout,a)}static hasPaintOverride(a,b){const c=a.get("text-field"),d=jX.paint.properties[b];let f=!1;const g=a=>{for(const b of a)if(d.overrides&&d.overrides.hasOverride(b))return void(f=!0)};if("constant"===c.value.kind&&c.value.value instanceof bN)g(c.value.value.sections);else if("source"===c.value.kind){const h=a=>{f||(a instanceof bT&&bR(a.value)===bA?g(a.value.sections):a instanceof bX?g(a.sections):a.eachChild(h))},i=c.value;i._styleExpression&&h(i._styleExpression.expression)}return f}getProgramConfiguration(a){return new gf(this,a)}}var j$={paint:new ff({"background-color":new fa(bk.paint_background["background-color"]),"background-pattern":new fd(bk.paint_background["background-pattern"]),"background-opacity":new fa(bk.paint_background["background-opacity"])})},j_={paint:new ff({"raster-opacity":new fa(bk.paint_raster["raster-opacity"]),"raster-hue-rotate":new fa(bk.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new fa(bk.paint_raster["raster-brightness-min"]),"raster-brightness-max":new fa(bk.paint_raster["raster-brightness-max"]),"raster-saturation":new fa(bk.paint_raster["raster-saturation"]),"raster-contrast":new fa(bk.paint_raster["raster-contrast"]),"raster-resampling":new fa(bk.paint_raster["raster-resampling"]),"raster-fade-duration":new fa(bk.paint_raster["raster-fade-duration"])})};class j0 extends gn{constructor(a){super(a,{}),this.implementation=a}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(a){this.implementation.onAdd&&this.implementation.onAdd(a,a.painter.context.gl)}onRemove(a){this.implementation.onRemove&&this.implementation.onRemove(a,a.painter.context.gl)}}var j1={paint:new ff({"sky-type":new fa(bk.paint_sky["sky-type"]),"sky-atmosphere-sun":new fa(bk.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new fa(bk.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new fa(bk.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new fa(bk.paint_sky["sky-gradient-radius"]),"sky-gradient":new fe(bk.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new fa(bk.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new fa(bk.paint_sky["sky-atmosphere-color"]),"sky-opacity":new fa(bk.paint_sky["sky-opacity"])})};function j2(a,b,c){var d,f,g,h,i,j,k,l,m;const n=w(0,0,1),o=M(L());return d=o,f=o,g=c?-(a*P)+Math.PI:a*P,g*=.5,h=f[0],i=f[1],j=f[2],k=f[3],l=Math.sin(g),m=Math.cos(g),d[0]=h*m-j*l,d[1]=i*m+k*l,d[2]=j*m+h*l,d[3]=k*m-i*l,N(o,o,-(b*P)),H(n,n,o),D(n,n)}const j3={circle:class extends gn{constructor(a){super(a,g$)}createBucket(a){return new gI(a)}queryRadius(a){const b=a;return gV("circle-radius",this,b)+gV("circle-stroke-width",this,b)+gW(this.paint.get("circle-translate"))}queryIntersectsFeature(a,b,c,d,f,g,h,i){const j=gY(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),k=this.paint.get("circle-radius").evaluate(b,c)+this.paint.get("circle-stroke-width").evaluate(b,c);return g1(a,d,g,h,i,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),j,k)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new gf(this,a)}},heatmap:class extends gn{createBucket(a){return new g6(a)}constructor(a){super(a,hc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){"heatmap-color"===a&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=hd({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(a){return gV("heatmap-radius",this,a)}queryIntersectsFeature(a,b,c,d,f,h,i,j){const k=this.paint.get("heatmap-radius").evaluate(b,c);return g1(a,d,h,i,j,!0,!0,new g(0,0),k)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new gf(this,a)}},hillshade:class extends gn{constructor(a){super(a,he)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare",]}getProgramConfiguration(a){return new gf(this,a)}},fill:class extends gn{constructor(a){super(a,hS)}getProgramIds(){const a=this.paint.get("fill-pattern"),b=a&&a.constantOr(1),c=[b?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&c.push(b&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),c}getProgramConfiguration(a){return new gf(this,a)}recalculate(a,b){super.recalculate(a,b);const c=this.paint._values["fill-outline-color"];"constant"===c.value.kind&& void 0===c.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new hQ(a)}queryRadius(){return gW(this.paint.get("fill-translate"))}queryIntersectsFeature(a,b,c,d,f,g){return!a.queryGeometry.isAboveHorizon&&gL(gX(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),g.angle,a.pixelToTileUnitsFactor),d)}isTileClipped(){return!0}},"fill-extrusion":class extends gn{constructor(a){super(a,h8)}createBucket(a){return new h6(a)}queryRadius(){return gW(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion",]}getProgramConfiguration(a){return new gf(this,a)}queryIntersectsFeature(a,b,c,d,f,h,i,j,k){var l,m,n,o,p,q,r,s,u;const v=gY(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),h.angle,a.pixelToTileUnitsFactor),w=this.paint.get("fill-extrusion-height").evaluate(b,c),x=this.paint.get("fill-extrusion-base").evaluate(b,c),y=[0,0],z=j&&h.elevation,A=h.elevation?h.elevation.exaggeration():1;if(z){const B=a.tile.getBucket(this).centroidVertexArray,C=k+1;if(C<B.length){const D=B.get(C);y[0]=D.a_centroid_pos0,y[1]=D.a_centroid_pos1}}if(0===y[0]&&1===y[1])return!1;const E=(l=d,m=x,n=w,o=v,p=i,q=z?j:null,r=y,s=A,u=h.center.lat,q?function(a,b,c,d,f,g,h,i,j){const k=[],l=[],m=[0,0,0,1];for(const n of a){const o=[],p=[];for(const q of n){const r=q.x+d.x,s=q.y+d.y,u=ic(r,s,b,c,g,h,i,j);m[0]=r,m[1]=s,m[2]=u.base,m[3]=1,K(m,m,f),m[3]=Math.max(m[3],1e-5);const v=ib([m[0]/m[3],m[1]/m[3],m[2]/m[3],]);m[0]=r,m[1]=s,m[2]=u.top,m[3]=1,K(m,m,f),m[3]=Math.max(m[3],1e-5);const w=ib([m[0]/m[3],m[1]/m[3],m[2]/m[3],]);o.push(v),p.push(w)}k.push(o),l.push(p)}return[k,l]}(l,m,n,o,p,q,r,s,u):function(a,b,c,d,f){const h=[],i=[],j=f[8]*b,k=f[9]*b,l=f[10]*b,m=f[11]*b,n=f[8]*c,o=f[9]*c,p=f[10]*c,q=f[11]*c;for(const r of a){const s=[],u=[];for(const v of r){const w=v.x+d.x,x=v.y+d.y,y=f[0]*w+f[4]*x+f[12],z=f[1]*w+f[5]*x+f[13],A=f[2]*w+f[6]*x+f[14],B=f[3]*w+f[7]*x+f[15],C=y+j,D=z+k,E=A+l,F=Math.max(B+m,1e-5),G=y+n,H=z+o,I=A+p,J=Math.max(B+q,1e-5),K=new g(C/F,D/F);K.z=E/F,s.push(K);const L=new g(G/J,H/J);L.z=I/J,u.push(L)}h.push(s),i.push(u)}return[h,i]}(l,m,n,o,p)),F=a.queryGeometry;return function(a,b,c){let d=1/0;gL(c,b)&&(d=ia(c,b[0]));for(let f=0;f<b.length;f++){const g=b[f],h=a[f];for(let i=0;i<g.length-1;i++){const j=g[i],k=[j,g[i+1],h[i+1],h[i],j,];gJ(c,k)&&(d=Math.min(d,ia(c,k)))}}return d!==1/0&&d}(E[0],E[1],F.isPointQuery()?F.screenBounds:F.screenGeometry)}},line:class extends gn{constructor(a){super(a,im),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(a){if("line-gradient"===a){const b=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=b._styleExpression&&b._styleExpression.expression instanceof cq,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(a,b){super.recalculate(a,b),this.paint._values["line-floorwidth"]=io.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,a)}createBucket(a){return new ik(a)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line",]}getProgramConfiguration(a){return new gf(this,a)}queryRadius(a){const b=a,c=ip(gV("line-width",this,b),gV("line-gap-width",this,b)),d=gV("line-offset",this,b);return c/2+Math.abs(d)+gW(this.paint.get("line-translate"))}queryIntersectsFeature(a,b,c,d,f,h){if(a.queryGeometry.isAboveHorizon)return!1;const i=gX(a.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),h.angle,a.pixelToTileUnitsFactor),j=a.pixelToTileUnitsFactor/2*ip(this.paint.get("line-width").evaluate(b,c),this.paint.get("line-gap-width").evaluate(b,c)),k=this.paint.get("line-offset").evaluate(b,c);return k&&(d=function(a,b){const c=[],d=new g(0,0);for(let f=0;f<a.length;f++){const h=a[f],i=[];for(let j=0;j<h.length;j++){const k=h[j-1],l=h[j],m=h[j+1],n=0===j?d:l.sub(k)._unit()._perp(),o=j===h.length-1?d:m.sub(l)._unit()._perp(),p=n._add(o)._unit();p._mult(1/(p.x*o.x+p.y*o.y)),i.push(p._mult(b)._add(l))}c.push(i)}return c}(d,k*a.pixelToTileUnitsFactor)),function(a,b,c){for(let d=0;d<b.length;d++){const f=b[d];if(a.length>=3){for(let g=0;g<f.length;g++)if(gS(a,f[g]))return!0}if(gM(a,f,c))return!0}return!1}(i,d,j)}isTileClipped(){return!0}},symbol:jZ,background:class extends gn{constructor(a){super(a,j$)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background",]}},raster:class extends gn{constructor(a){super(a,j_)}getProgramIds(){return["raster"]}},sky:class extends gn{constructor(a){super(a,j1),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){"sky-gradient"===a?this._updateColorRamp():"sky-atmosphere-sun"!==a&&"sky-atmosphere-halo-color"!==a&&"sky-atmosphere-color"!==a&&"sky-atmosphere-sun-intensity"!==a||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=hd({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(a){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const b=a.style.light.properties.get("position");return this._lightPosition.azimuthal!==b.azimuthal||this._lightPosition.polar!==b.polar}}getCenter(a,b){const c=this.paint.get("sky-type");if("atmosphere"===c){const d=this.paint.get("sky-atmosphere-sun"),f=!d,g=a.style.light,h=g.properties.get("position");return f&&"viewport"===g.properties.get("anchor")&&am("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),f?j2(h.azimuthal,90-h.polar,b):j2(d[0],90-d[1],b)}if("gradient"===c){const i=this.paint.get("sky-gradient-center");return j2(i[0],90-i[1],b)}}is3D(){return!1}isSky(){return!0}markSkyboxValid(a){this._skyboxInvalidated=!1,this._lightPosition=a.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const a=this.paint.get("sky-type");return"atmosphere"===a?["skyboxCapture","skybox"]:"gradient"===a?["skyboxGradient"]:null}}},{HTMLImageElement:j4,HTMLCanvasElement:j5,HTMLVideoElement:j6,ImageData:j7,ImageBitmap:j8}=i;class j9{constructor(a,b,c,d){this.context=a,this.format=c,this.texture=a.gl.createTexture(),this.update(b,d)}update(a,b,c){const{width:d,height:f}=a,{context:g}=this,{gl:h}=g;if(h.bindTexture(h.TEXTURE_2D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(this.format===h.RGBA&&(!b|| !1!==b.premultiply)),c||this.size&&this.size[0]===d&&this.size[1]===f){const{x:i,y:j}=c||{x:0,y:0};a instanceof j4||a instanceof j5||a instanceof j6||a instanceof j7||j8&&a instanceof j8?h.texSubImage2D(h.TEXTURE_2D,0,i,j,h.RGBA,h.UNSIGNED_BYTE,a):h.texSubImage2D(h.TEXTURE_2D,0,i,j,d,f,h.RGBA,h.UNSIGNED_BYTE,a.data)}else this.size=[d,f],a instanceof j4||a instanceof j5||a instanceof j6||a instanceof j7||j8&&a instanceof j8?h.texImage2D(h.TEXTURE_2D,0,this.format,this.format,h.UNSIGNED_BYTE,a):h.texImage2D(h.TEXTURE_2D,0,this.format,d,f,0,this.format,h.UNSIGNED_BYTE,a.data);this.useMipmap=Boolean(b&&b.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&h.generateMipmap(h.TEXTURE_2D)}bind(a,b){const{context:c}=this,{gl:d}=c;d.bindTexture(d.TEXTURE_2D,this.texture),a!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,a),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,this.useMipmap?a===d.NEAREST?d.NEAREST_MIPMAP_NEAREST:d.LINEAR_MIPMAP_NEAREST:a),this.filter=a),b!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,b),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,b),this.wrap=b)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:a}=this.context;a.deleteTexture(this.texture),this.texture=null}}class ka{constructor(a,b){this.width=a,this.height=b,this.nextRow=0,this.image=new ha({width:a,height:b}),this.positions={},this.uploaded=!1}getDash(a,b){const c=this.getKey(a,b);return this.positions[c]}trim(){const a=this.width,b=this.height=ae(this.nextRow);this.image.resize({width:a,height:b})}getKey(a,b){return a.join(",")+b}getDashRanges(a,b,c){const d=[];let f=a.length%2==1?-a[a.length-1]*c:0,g=a[0]*c,h=!0;d.push({left:f,right:g,isDash:h,zeroLength:0===a[0]});let i=a[0];for(let j=1;j<a.length;j++){h=!h;const k=a[j];f=i*c,i+=k,g=i*c,d.push({left:f,right:g,isDash:h,zeroLength:0===k})}return d}addRoundDash(a,b,c){const d=b/2;for(let f=-c;f<=c;f++){const g=this.width*(this.nextRow+c+f);let h=0,i=a[h];for(let j=0;j<this.width;j++){j/i.right>1&&(i=a[++h]);const k=Math.abs(j-i.left),l=Math.abs(j-i.right),m=Math.min(k,l);let n;const o=f/c*(d+1);if(i.isDash){const p=d-Math.abs(o);n=Math.sqrt(m*m+p*p)}else n=d-Math.sqrt(m*m+o*o);this.image.data[g+j]=Math.max(0,Math.min(255,n+128))}}}addRegularDash(a,b){for(let c=a.length-1;c>=0;--c){const d=a[c],f=a[c+1];d.zeroLength?a.splice(c,1):f&&f.isDash===d.isDash&&(f.left=d.left,a.splice(c,1))}const g=a[0],h=a[a.length-1];g.isDash===h.isDash&&(g.left=h.left-this.width,h.right=g.right+this.width);const i=this.width*this.nextRow;let j=0,k=a[j];for(let l=0;l<this.width;l++){l/k.right>1&&(k=a[++j]);const m=Math.abs(l-k.left),n=Math.abs(l-k.right),o=Math.min(m,n);this.image.data[i+l]=Math.max(0,Math.min(255,(k.isDash?o:-o)+b+128))}}addDash(a,b){const c=this.getKey(a,b);if(this.positions[c])return this.positions[c];const d="round"===b,f=d?7:0,g=2*f+1;if(this.nextRow+g>this.height)return am("LineAtlas out of space"),null;0===a.length&&a.push(1);let h=0;for(let i=0;i<a.length;i++)a[i]<0&&(am("Negative value is found in line dasharray, replacing values with 0"),a[i]=0),h+=a[i];if(0!==h){const j=this.width/h,k=this.getDashRanges(a,this.width,j);d?this.addRoundDash(k,j,f):this.addRegularDash(k,"square"===b?.5*j:0)}const l=this.nextRow+f;this.nextRow+=g;const m={tl:[l,f],br:[h,0]};return this.positions[c]=m,m}}ec("LineAtlas",ka);const kb=i.performance;function kc(a){const b=a?a.url.toString():void 0;return kb.getEntriesByName(b)}function kd(a,b,c){var d=2*Math.PI*6378137/256/Math.pow(2,c);return[a*d-2*Math.PI*6378137/2,b*d-2*Math.PI*6378137/2,]}class ke{constructor(a,b,c){this.z=a,this.x=b,this.y=c,this.key=kh(0,a,a,b,c)}equals(a){return this.z===a.z&&this.x===a.x&&this.y===a.y}url(a,b){var c,d,f,g,h;const i=(c=this.x,d=this.y,g=kd(256*c,256*(d=Math.pow(2,f=this.z)-d-1),f),h=kd(256*(c+1),256*(d+1),f),g[0]+","+g[1]+","+h[0]+","+h[1]),j=function(a,b,c){let d,f="";for(let g=a;g>0;g--)f+=(b&(d=1<<g-1)?1:0)+(c&d?2:0);return f}(this.z,this.x,this.y);return a[(this.x+this.y)%a.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("tms"===b?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",j).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class kf{constructor(a,b){this.wrap=a,this.canonical=b,this.key=kh(a,b.z,b.z,b.x,b.y)}}class kg{constructor(a,b,c,d,f){this.overscaledZ=a,this.wrap=b,this.canonical=new ke(c,+d,+f),this.key=0===b&&a===c?this.canonical.key:kh(b,a,c,d,f)}equals(a){return this.overscaledZ===a.overscaledZ&&this.wrap===a.wrap&&this.canonical.equals(a.canonical)}scaledTo(a){const b=this.canonical.z-a;return a>this.canonical.z?new kg(a,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new kg(a,this.wrap,a,this.canonical.x>>b,this.canonical.y>>b)}calculateScaledKey(a,b=!0){if(this.overscaledZ===a&&b)return this.key;if(a>this.canonical.z)return kh(this.wrap*+b,a,this.canonical.z,this.canonical.x,this.canonical.y);{const c=this.canonical.z-a;return kh(this.wrap*+b,a,a,this.canonical.x>>c,this.canonical.y>>c)}}isChildOf(a){if(a.wrap!==this.wrap)return!1;const b=this.canonical.z-a.canonical.z;return 0===a.overscaledZ||a.overscaledZ<this.overscaledZ&&a.canonical.x===this.canonical.x>>b&&a.canonical.y===this.canonical.y>>b}children(a){if(this.overscaledZ>=a)return[new kg(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y),];const b=this.canonical.z+1,c=2*this.canonical.x,d=2*this.canonical.y;return[new kg(b,this.wrap,b,c,d),new kg(b,this.wrap,b,c+1,d),new kg(b,this.wrap,b,c,d+1),new kg(b,this.wrap,b,c+1,d+1),]}isLessThan(a){return this.wrap<a.wrap|| !(this.wrap>a.wrap)&&(this.overscaledZ<a.overscaledZ|| !(this.overscaledZ>a.overscaledZ)&&(this.canonical.x<a.canonical.x|| !(this.canonical.x>a.canonical.x)&&this.canonical.y<a.canonical.y))}wrapped(){return new kg(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(a){return new kg(this.overscaledZ,a,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new kf(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function kh(a,b,c,d,f){const g=1<<Math.min(c,22);let h=g*(f%g)+d%g;return a&&c<22&&(h+=g*g*((a<0?-2*a-1:2*a)%(1<<2*(22-c)))),16*(32*h+c)+(b-c)}ec("CanonicalTileID",ke),ec("OverscaledTileID",kg,{omit:["projMatrix"]});class ki{constructor(a,b,c){this.func=a,this.mask=b,this.range=c}}ki.ReadOnly=!1,ki.ReadWrite=!0,ki.disabled=new ki(519,ki.ReadOnly,[0,1]);class kj{constructor(a,b,c,d,f,g){this.test=a,this.ref=b,this.mask=c,this.fail=d,this.depthFail=f,this.pass=g}}kj.disabled=new kj({func:519,mask:0},0,0,7680,7680,7680);class kk{constructor(a,b,c){this.blendFunction=a,this.blendColor=b,this.mask=c}}kk.Replace=[1,0],kk.disabled=new kk(kk.Replace,bK.transparent,[!1,!1,!1,!1,]),kk.unblended=new kk(kk.Replace,bK.transparent,[!0,!0,!0,!0,]),kk.alphaBlended=new kk([1,771],bK.transparent,[!0,!0,!0,!0]);class kl{constructor(a,b,c){this.enable=a,this.mode=b,this.frontFace=c}}kl.disabled=new kl(!1,1029,2305),kl.backCCW=new kl(!0,1029,2305),kl.backCW=new kl(!0,1029,2304),kl.frontCW=new kl(!0,1028,2304),kl.frontCCW=new kl(!0,1028,2305);class km{constructor(a){this._stringToNumber={},this._numberToString=[];for(let b=0;b<a.length;b++){const c=a[b];this._stringToNumber[c]=b,this._numberToString[b]=c}}encode(a){return this._stringToNumber[a]}decode(a){return this._numberToString[a]}}class kn{constructor(a,b,c,d,f){this.type="Feature",this._vectorTileFeature=a,a._z=b,a._x=c,a._y=d,this.properties=a.properties,this.id=f}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(a){this._geometry=a}toJSON(){const a={geometry:this.geometry};for(const b in this)"_geometry"!==b&&"_vectorTileFeature"!==b&&(a[b]=this[b]);return a}}class ko{constructor(a){this.size=a,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(a,b){const c=this.toIdx(a,b);return{min:this.minimums[c],max:this.maximums[c]}}isLeaf(a,b){return this.leaves[this.toIdx(a,b)]}toIdx(a,b){return b*this.size+a}}function kp(a,b,c,d){let f=0,g=Number.MAX_VALUE;for(let h=0;h<3;h++)if(1e-15>Math.abs(d[h])){if(c[h]<a[h]||c[h]>b[h])return null}else{const i=1/d[h];let j=(a[h]-c[h])*i,k=(b[h]-c[h])*i;if(j>k){const l=j;j=k,k=l}if(j>f&&(f=j),k<g&&(g=k),f>g)return null}return f}function kq(a,b,c,d,f,g,h,i,j,k,l){const m=d-a,n=f-b,o=g-c,p=h-a,q=i-b,r=j-c,s=l[1]*r-l[2]*q,u=l[2]*p-l[0]*r,v=l[0]*q-l[1]*p,w=m*s+n*u+o*v;if(1e-15>Math.abs(w))return null;const x=1/w,y=k[0]-a,z=k[1]-b,A=k[2]-c,B=(y*s+z*u+A*v)*x;if(B<0||B>1)return null;const C=z*o-A*n,D=A*m-y*o,E=y*n-z*m,F=(l[0]*C+l[1]*D+l[2]*E)*x;return F<0||B+F>1?null:(p*C+q*D+r*E)*x}function kr(a,b,c,d,f,g,h,i,j){const k=1<<c,l=g-d,m=h-f;i[0]=(a+0)/k*l+d,i[1]=(b+0)/k*m+f,j[0]=(a+1)/k*l+d,j[1]=(b+1)/k*m+f}class ks{constructor(a){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=a,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1],],!this.dem)return;const b=function(a){const b=Math.ceil(Math.log2(a.dim/8)),c=[];let d=Math.ceil(Math.pow(2,b));const f=1/d,g=(a,b,c,d,f)=>{const g=d?1:0,h=(a+1)*c-g,i=b*c,j=(b+1)*c-g;f[0]=a*c,f[1]=i,f[2]=h,f[3]=j};let h=new ko(d);const i=[];for(let j=0;j<d*d;j++){g(j%d,Math.floor(j/d),f,!1,i);const k=ku(i[0],i[1],a),l=ku(i[2],i[1],a),m=ku(i[2],i[3],a),n=ku(i[0],i[3],a);h.minimums.push(Math.min(k,l,m,n)),h.maximums.push(Math.max(k,l,m,n)),h.leaves.push(1)}for(c.push(h),d/=2;d>=1;d/=2){const o=c[c.length-1];h=new ko(d);for(let p=0;p<d*d;p++){g(p%d,Math.floor(p/d),2,!0,i);const q=o.getElevation(i[0],i[1]),r=o.getElevation(i[2],i[1]),s=o.getElevation(i[2],i[3]),u=o.getElevation(i[0],i[3]),v=o.isLeaf(i[0],i[1]),w=o.isLeaf(i[2],i[1]),x=o.isLeaf(i[2],i[3]),y=o.isLeaf(i[0],i[3]),z=Math.min(q.min,r.min,s.min,u.min),A=Math.max(q.max,r.max,s.max,u.max),B=v&&w&&x&&y;h.maximums.push(A),h.minimums.push(z),h.leaves.push(A-z<=5&&B?1:0)}c.push(h)}return c}(this.dem),c=b.length-1,d=b[c];this._addNode(d.minimums[0],d.maximums[0],d.leaves[0]),this._construct(b,0,0,c,0)}raycastRoot(a,b,c,d,f,g,h=1){return kp([a,b,-100],[c,d,this.maximums[0]*h],f,g)}raycast(a,b,c,d,f,g,h=1){if(!this.nodeCount)return null;const i=this.raycastRoot(a,b,c,d,f,g,h);if(null==i)return null;const j=[],k=[],l=[],m=[],n=[{idx:0,t:i,nodex:0,nodey:0,depth:0},];for(;n.length>0;){const{idx:o,t:p,nodex:q,nodey:r,depth:s}=n.pop();if(this.leaves[o]){kr(q,r,s,a,b,c,d,l,m);const u=1<<s,v=(q+0)/u,w=(q+1)/u,x=(r+0)/u,y=(r+1)/u,z=ku(v,x,this.dem)*h,A=ku(w,x,this.dem)*h,B=ku(w,y,this.dem)*h,D=ku(v,y,this.dem)*h,E=kq(l[0],l[1],z,m[0],l[1],A,m[0],m[1],B,f,g),F=kq(m[0],m[1],B,l[0],m[1],D,l[0],l[1],z,f,g),G=Math.min(null!==E?E:Number.MAX_VALUE,null!==F?F:Number.MAX_VALUE);if(G!==Number.MAX_VALUE)return G;{var H,I;const J=C([],f,g,p);if(kt(z,A,D,B,(J[0]-(H=l[0]))/(m[0]-H),(J[1]-(I=l[1]))/(m[1]-I))>=J[2])return p}continue}let K=0;for(let L=0;L<this._siblingOffset.length;L++){kr((q<<1)+this._siblingOffset[L][0],(r<<1)+this._siblingOffset[L][1],s+1,a,b,c,d,l,m),l[2]=-100,m[2]=this.maximums[this.childOffsets[o]+L]*h;const M=kp(l,m,f,g);if(null!=M){const N=M;j[L]=N;let O=!1;for(let P=0;P<K&&!O;P++)N>=j[k[P]]&&(k.splice(P,0,L),O=!0);O||(k[K]=L),K++}}for(let Q=0;Q<K;Q++){const R=k[Q];n.push({idx:this.childOffsets[o]+R,t:j[R],nodex:(q<<1)+this._siblingOffset[R][0],nodey:(r<<1)+this._siblingOffset[R][1],depth:s+1})}}return null}_addNode(a,b,c){return this.minimums.push(a),this.maximums.push(b),this.leaves.push(c),this.childOffsets.push(0),this.nodeCount++}_construct(a,b,c,d,f){if(1===a[d].isLeaf(b,c))return;this.childOffsets[f]||(this.childOffsets[f]=this.nodeCount);const g=d-1,h=a[g];let i,j=0;for(let k=0;k<this._siblingOffset.length;k++){const l=2*b+this._siblingOffset[k][0],m=2*c+this._siblingOffset[k][1],n=h.getElevation(l,m),o=h.isLeaf(l,m),p=this._addNode(n.min,n.max,o);o&&(j|=1<<k),i||(i=p)}for(let q=0;q<this._siblingOffset.length;q++)j&1<<q||this._construct(a,2*b+this._siblingOffset[q][0],2*c+this._siblingOffset[q][1],g,i+q)}}function kt(a,b,c,d,f,g){return cr(cr(a,c,g),cr(b,d,g),f)}function ku(a,b,c){const d=c.dim,f=X(a*d-.5,0,d-1),g=X(b*d-.5,0,d-1),h=Math.floor(f),i=Math.floor(g),j=Math.min(h+1,d-1),k=Math.min(i+1,d-1);return kt(c.get(h,i),c.get(j,i),c.get(h,k),c.get(j,k),f-h,g-i)}const kv={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class kw{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(a,b,c,d=!1,f=!1){if(this.uid=a,b.height!==b.width)throw RangeError("DEM tiles must be square");if(c&&"mapbox"!==c&&"terrarium"!==c)return am(`"${c}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=b.height;const g=this.dim=b.height-2;if(this.data=new Uint32Array(b.data.buffer),this.encoding=c||"mapbox",this.borderReady=d,!d){for(let h=0;h<g;h++)this.data[this._idx(-1,h)]=this.data[this._idx(0,h)],this.data[this._idx(g,h)]=this.data[this._idx(g-1,h)],this.data[this._idx(h,-1)]=this.data[this._idx(h,0)],this.data[this._idx(h,g)]=this.data[this._idx(h,g-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(g,-1)]=this.data[this._idx(g-1,0)],this.data[this._idx(-1,g)]=this.data[this._idx(0,g-1)],this.data[this._idx(g,g)]=this.data[this._idx(g-1,g-1)],f&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new ks(this)}get(a,b,c=!1){const d=new Uint8Array(this.data.buffer);c&&(a=X(a,-1,this.dim),b=X(b,-1,this.dim));const f=4*this._idx(a,b);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(d[f],d[f+1],d[f+2])}static getUnpackVector(a){return kv[a]}get unpackVector(){return kv[this.encoding]}_idx(a,b){if(a< -1||a>=this.dim+1||b< -1||b>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(b+1)*this.stride+(a+1)}_unpackMapbox(a,b,c){return(256*a*256+256*b+c)/10-1e4}_unpackTerrarium(a,b,c){return 256*a+b+c/256-32768}static pack(a,b){const c=[0,0,0,0],d=kw.getUnpackVector(b);let f=Math.floor((a+d[3])/d[2]);return c[2]=f%256,f=Math.floor(f/256),c[1]=f%256,f=Math.floor(f/256),c[0]=f,c}getPixels(){return new hb({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(a,b,c){if(this.dim!==a.dim)throw Error("dem dimension mismatch");let d=b*this.dim,f=b*this.dim+this.dim,g=c*this.dim,h=c*this.dim+this.dim;switch(b){case -1:d=f-1;break;case 1:f=d+1}switch(c){case -1:g=h-1;break;case 1:h=g+1}const i=-b*this.dim,j=-c*this.dim;for(let k=g;k<h;k++)for(let l=d;l<f;l++)this.data[this._idx(l,k)]=a.data[this._idx(l+i,k+j)]}onDeserialize(){this._tree&&(this._tree.dem=this)}}ec("DEMData",kw),ec("DemMinMaxQuadTree",ks,{omit:["dem"]});class kx extends bj{constructor(a,b,c){super(),this.id=a,this._onlySymbols=c,b.on("data",a=>{"source"===a.dataType&&"metadata"===a.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===a.dataType&&"content"===a.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),b.on("error",()=>{this._sourceErrored=!0}),this._source=b,this._tiles={},this._cache=new class{constructor(a,b){this.max=a,this.onRemove=b,this.reset()}reset(){for(const a in this.data)for(const b of this.data[a])b.timeout&&clearTimeout(b.timeout),this.onRemove(b.value);return this.data={},this.order=[],this}add(a,b,c){const d=a.wrapped().key;void 0===this.data[d]&&(this.data[d]=[]);const f={value:b,timeout:void 0};if(void 0!==c&&(f.timeout=setTimeout(()=>{this.remove(a,f)},c)),this.data[d].push(f),this.order.push(d),this.order.length>this.max){const g=this._getAndRemoveByKey(this.order[0]);g&&this.onRemove(g)}return this}has(a){return a.wrapped().key in this.data}getAndRemove(a){return this.has(a)?this._getAndRemoveByKey(a.wrapped().key):null}_getAndRemoveByKey(a){const b=this.data[a].shift();return b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.order.splice(this.order.indexOf(a),1),b.value}getByKey(a){const b=this.data[a];return b?b[0].value:null}get(a){return this.has(a)?this.data[a.wrapped().key][0].value:null}remove(a,b){if(!this.has(a))return this;const c=a.wrapped().key,d=void 0===b?0:this.data[c].indexOf(b),f=this.data[c][d];return this.data[c].splice(d,1),f.timeout&&clearTimeout(f.timeout),0===this.data[c].length&&delete this.data[c],this.onRemove(f.value),this.order.splice(this.order.indexOf(c),1),this}setMaxSize(a){for(this.max=a;this.order.length>this.max;){const b=this._getAndRemoveByKey(this.order[0]);b&&this.onRemove(b)}return this}filter(a){const b=[];for(const c in this.data)for(const d of this.data[c])a(d.value)||b.push(d);for(const f of b)this.remove(f.value.tileID,f)}}(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new class{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(a,b,c){const d=String(b);if(this.stateChanges[a]=this.stateChanges[a]||{},this.stateChanges[a][d]=this.stateChanges[a][d]||{},aa(this.stateChanges[a][d],c),null===this.deletedStates[a])for(const f in this.deletedStates[a]={},this.state[a])f!==d&&(this.deletedStates[a][f]=null);else if(this.deletedStates[a]&&null===this.deletedStates[a][d])for(const g in this.deletedStates[a][d]={},this.state[a][d])c[g]||(this.deletedStates[a][d][g]=null);else for(const h in c)this.deletedStates[a]&&this.deletedStates[a][d]&&null===this.deletedStates[a][d][h]&&delete this.deletedStates[a][d][h]}removeFeatureState(a,b,c){if(null===this.deletedStates[a])return;const d=String(b);if(this.deletedStates[a]=this.deletedStates[a]||{},c&& void 0!==b)null!==this.deletedStates[a][d]&&(this.deletedStates[a][d]=this.deletedStates[a][d]||{},this.deletedStates[a][d][c]=null);else if(void 0!==b){if(this.stateChanges[a]&&this.stateChanges[a][d])for(c in this.deletedStates[a][d]={},this.stateChanges[a][d])this.deletedStates[a][d][c]=null;else this.deletedStates[a][d]=null}else this.deletedStates[a]=null}getState(a,b){const c=String(b),d=aa({},(this.state[a]||{})[c],(this.stateChanges[a]||{})[c]);if(null===this.deletedStates[a])return{};if(this.deletedStates[a]){const f=this.deletedStates[a][b];if(null===f)return{};for(const g in f)delete d[g]}return d}initializeTileState(a,b){a.setFeatureState(this.state,b)}coalesceChanges(a,b){const c={};for(const d in this.stateChanges){this.state[d]=this.state[d]||{};const f={};for(const g in this.stateChanges[d])this.state[d][g]||(this.state[d][g]={}),aa(this.state[d][g],this.stateChanges[d][g]),f[g]=this.state[d][g];c[d]=f}for(const h in this.deletedStates){this.state[h]=this.state[h]||{};const i={};if(null===this.deletedStates[h])for(const j in this.state[h])i[j]={},this.state[h][j]={};else for(const k in this.deletedStates[h]){if(null===this.deletedStates[h][k])this.state[h][k]={};else for(const l of Object.keys(this.deletedStates[h][k]))delete this.state[h][k][l];i[k]=this.state[h][k]}c[h]=c[h]||{},aa(c[h],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(c).length)for(const m in a)a[m].setFeatureState(c,b)}}}onAdd(a){this.map=a,this._minTileCacheSize=a?a._minTileCacheSize:null,this._maxTileCacheSize=a?a._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const a in this._tiles){const b=this._tiles[a];if("loaded"!==b.state&&"errored"!==b.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const a=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,a&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(a,b){return a.isSymbolTile=this._onlySymbols,this._source.loadTile(a,b)}_unloadTile(a){if(this._source.unloadTile)return this._source.unloadTile(a,()=>{})}_abortTile(a){if(this._source.abortTile)return this._source.abortTile(a,()=>{})}serialize(){return this._source.serialize()}prepare(a){for(const b in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const c=this._tiles[b];c.upload(a),c.prepare(this.map.style.imageManager)}}getIds(){return _(this._tiles).map(a=>a.tileID).sort(ky).map(a=>a.key)}getRenderableIds(a){const b=[];for(const c in this._tiles)this._isIdRenderable(+c,a)&&b.push(this._tiles[c]);return a?b.sort((a,b)=>{const c=a.tileID,d=b.tileID,f=new g(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),h=new g(d.canonical.x,d.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-d.overscaledZ||h.y-f.y||h.x-f.x}).map(a=>a.tileID.key):b.map(a=>a.tileID).sort(ky).map(a=>a.key)}hasRenderableParent(a){const b=this.findLoadedParent(a,0);return!!b&&this._isIdRenderable(b.tileID.key)}_isIdRenderable(a,b){return this._tiles[a]&&this._tiles[a].hasData()&&!this._coveredTiles[a]&&(b||!this._tiles[a].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const a in this._cache.reset(),this._tiles)"errored"!==this._tiles[a].state&&this._reloadTile(+a,"reloading")}_reloadTile(a,b){const c=this._tiles[a];c&&("loading"!==c.state&&(c.state=b),this._loadTile(c,this._tileLoaded.bind(this,c,a,b)))}_tileLoaded(a,b,c,d){if(d){if(a.state="errored",404!==d.status)this._source.fire(new bi(d,{tile:a}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const f=this.map.painter.terrain;this.update(this.transform,f.getScaledDemTileSize(),!0),f.resetTileLookupCache(this.id)}else this.update(this.transform)}else a.timeAdded=ax.now(),"expired"===c&&(a.refreshedUponExpiration=!0),this._setTileReloadTimer(b,a),"raster-dem"===this._source.type&&a.dem&&this._backfillDEM(a),this._state.initializeTileState(a,this.map?this.map.painter:null),this._source.fire(new bh("data",{dataType:"source",tile:a,coord:a.tileID,sourceCacheId:this.id}))}_backfillDEM(a){const b=this.getRenderableIds();for(let c=0;c<b.length;c++){const d=b[c];if(a.neighboringTiles&&a.neighboringTiles[d]){const f=this.getTileByID(d);g(a,f),g(f,a)}}function g(a,b){if(!a.dem||a.dem.borderReady)return;a.needsHillshadePrepare=!0,a.needsDEMTextureUpload=!0;let c=b.tileID.canonical.x-a.tileID.canonical.x;const d=b.tileID.canonical.y-a.tileID.canonical.y,f=Math.pow(2,a.tileID.canonical.z),g=b.tileID.key;0===c&&0===d||Math.abs(d)>1||(Math.abs(c)>1&&(1===Math.abs(c+f)?c+=f:1===Math.abs(c-f)&&(c-=f)),b.dem&&a.dem&&(a.dem.backfillBorder(b.dem,c,d),a.neighboringTiles&&a.neighboringTiles[g]&&(a.neighboringTiles[g].backfilled=!0)))}}getTile(a){return this.getTileByID(a.key)}getTileByID(a){return this._tiles[a]}_retainLoadedChildren(a,b,c,d){for(const f in this._tiles){let g=this._tiles[f];if(d[f]||!g.hasData()||g.tileID.overscaledZ<=b||g.tileID.overscaledZ>c)continue;let h=g.tileID;for(;g&&g.tileID.overscaledZ>b+1;){const i=g.tileID.scaledTo(g.tileID.overscaledZ-1);(g=this._tiles[i.key])&&g.hasData()&&(h=i)}let j=h;for(;j.overscaledZ>b;)if(a[(j=j.scaledTo(j.overscaledZ-1)).key]){d[h.key]=h;break}}}findLoadedParent(a,b){if(a.key in this._loadedParentTiles){const c=this._loadedParentTiles[a.key];return c&&c.tileID.overscaledZ>=b?c:null}for(let d=a.overscaledZ-1;d>=b;d--){const f=a.scaledTo(d),g=this._getLoadedTile(f);if(g)return g}}_getLoadedTile(a){const b=this._tiles[a.key];return b&&b.hasData()?b:this._cache.getByKey(this._source.reparseOverscaled?a.wrapped().key:a.canonical.key)}updateCacheSize(a,b){b=b||this._source.tileSize;const c=Math.ceil(a.width/b)+1,d=Math.ceil(a.height/b)+1,f=Math.floor(c*d*5),g="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,f):f,h="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,g):g;this._cache.setMaxSize(h)}handleWrapJump(a){const b=Math.round((a-(void 0===this._prevLng?a:this._prevLng))/360);if(this._prevLng=a,b){const c={};for(const d in this._tiles){const f=this._tiles[d];f.tileID=f.tileID.unwrapTo(f.tileID.wrap+b),c[f.tileID.key]=f}for(const g in this._tiles=c,this._timers)clearTimeout(this._timers[g]),delete this._timers[g];for(const h in this._tiles)this._setTileReloadTimer(+h,this._tiles[h])}}update(a,b,c){if(this.transform=a,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!c)return;let d;this.updateCacheSize(a,b),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?d=a.getVisibleUnwrappedCoordinates(this._source.tileID).map(a=>new kg(a.canonical.z,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y)):(d=a.coveringTiles({tileSize:b||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(d=d.filter(a=>this._source.hasTile(a)))):d=[];const f=this._updateRetainedTiles(d);if(kz(this._source.type)&&0!==d.length){const g={},h={},i=Object.keys(f);for(const j of i){const k=f[j],l=this._tiles[j];if(!l||l.fadeEndTime&&l.fadeEndTime<=ax.now())continue;const m=this.findLoadedParent(k,Math.max(k.overscaledZ-kx.maxOverzooming,this._source.minzoom));m&&(this._addTile(m.tileID),g[m.tileID.key]=m.tileID),h[j]=k}const n=d[d.length-1].overscaledZ;for(const o in this._tiles){const p=this._tiles[o];if(f[o]||!p.hasData())continue;let q=p.tileID;for(;q.overscaledZ>n;){q=q.scaledTo(q.overscaledZ-1);const r=this._tiles[q.key];if(r&&r.hasData()&&h[q.key]){f[o]=p.tileID;break}}}for(const s in g)f[s]||(this._coveredTiles[s]=!0,f[s]=g[s])}for(const u in f)this._tiles[u].clearFadeHold();const v=function(a,b){const c=[];for(const d in a)d in b||c.push(d);return c}(this._tiles,f);for(const w of v){const x=this._tiles[w];x.hasSymbolBuckets&&!x.holdingForFade()?x.setHoldDuration(this.map._fadeDuration):x.hasSymbolBuckets&&!x.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const a in this._tiles)this._tiles[a].holdingForFade()&&this._removeTile(+a)}_updateRetainedTiles(a){const b={};if(0===a.length)return b;const c={},d=a.reduce((a,b)=>Math.min(a,b.overscaledZ),1/0),f=a[0].overscaledZ,g=Math.max(f-kx.maxOverzooming,this._source.minzoom),h=Math.max(f+kx.maxUnderzooming,this._source.minzoom),i={};for(const j of a){const k=this._addTile(j);b[j.key]=j,k.hasData()||d<this._source.maxzoom&&(i[j.key]=j)}for(const l of(this._retainLoadedChildren(i,d,h,b),a)){let m=this._tiles[l.key];if(m.hasData())continue;if(l.canonical.z>=this._source.maxzoom){const n=l.children(this._source.maxzoom)[0],o=this.getTile(n);if(o&&o.hasData()){b[n.key]=n;continue}}else{const p=l.children(this._source.maxzoom);if(b[p[0].key]&&b[p[1].key]&&b[p[2].key]&&b[p[3].key])continue}let q=m.wasRequested();for(let r=l.overscaledZ-1;r>=g;--r){const s=l.scaledTo(r);if(c[s.key]||(c[s.key]=!0,(m=this.getTile(s))||!q||(m=this._addTile(s)),m&&(b[s.key]=s,q=m.wasRequested(),m.hasData())))break}}return b}_updateLoadedParentTileCache(){for(const a in this._loadedParentTiles={},this._tiles){const b=[];let c,d=this._tiles[a].tileID;for(;d.overscaledZ>0;){if(d.key in this._loadedParentTiles){c=this._loadedParentTiles[d.key];break}b.push(d.key);const f=d.scaledTo(d.overscaledZ-1);if(c=this._getLoadedTile(f))break;d=f}for(const g of b)this._loadedParentTiles[g]=c}}_addTile(a){let b=this._tiles[a.key];if(b)return b;(b=this._cache.getAndRemove(a))&&(this._setTileReloadTimer(a.key,b),b.tileID=a,this._state.initializeTileState(b,this.map?this.map.painter:null),this._cacheTimers[a.key]&&(clearTimeout(this._cacheTimers[a.key]),delete this._cacheTimers[a.key],this._setTileReloadTimer(a.key,b)));const c=Boolean(b);if(!c){const d=this.map?this.map.painter:null,f="raster"===this._source.type||"raster-dem"===this._source.type;b=new kX(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,d,f),this._loadTile(b,this._tileLoaded.bind(this,b,a.key,b.state))}return b?(b.uses++,this._tiles[a.key]=b,c||this._source.fire(new bh("dataloading",{tile:b,coord:b.tileID,dataType:"source"})),b):null}_setTileReloadTimer(a,b){a in this._timers&&(clearTimeout(this._timers[a]),delete this._timers[a]);const c=b.getExpiryTimeout();c&&(this._timers[a]=setTimeout(()=>{this._reloadTile(a,"expired"),delete this._timers[a]},c))}_removeTile(a){const b=this._tiles[a];b&&(b.uses--,delete this._tiles[a],this._timers[a]&&(clearTimeout(this._timers[a]),delete this._timers[a]),b.uses>0||(b.hasData()&&"reloading"!==b.state?this._cache.add(b.tileID,b,b.getExpiryTimeout()):(b.aborted=!0,this._abortTile(b),this._unloadTile(b))))}clearTiles(){for(const a in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+a);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(a,b,c){const d=[],f=this.transform;if(!f)return d;for(const g in this._tiles){const h=this._tiles[g];if(c&&h.clearQueryDebugViz(),h.holdingForFade())continue;const i=a.containsTile(h,f,b);i&&d.push(i)}return d}getVisibleCoordinates(a){const b=this.getRenderableIds(a).map(a=>this._tiles[a].tileID);for(const c of b)c.projMatrix=this.transform.calculateProjMatrix(c.toUnwrapped());return b}hasTransition(){if(this._source.hasTransition())return!0;if(kz(this._source.type))for(const a in this._tiles){const b=this._tiles[a];if(void 0!==b.fadeEndTime&&b.fadeEndTime>=ax.now())return!0}return!1}setFeatureState(a,b,c){this._state.updateState(a=a||"_geojsonTileLayer",b,c)}removeFeatureState(a,b,c){this._state.removeFeatureState(a=a||"_geojsonTileLayer",b,c)}getFeatureState(a,b){return this._state.getState(a=a||"_geojsonTileLayer",b)}setDependencies(a,b,c){const d=this._tiles[a];d&&d.setDependencies(b,c)}reloadTilesForDependencies(a,b){for(const c in this._tiles)this._tiles[c].hasDependency(a,b)&&this._reloadTile(+c,"reloading");this._cache.filter(c=>!c.hasDependency(a,b))}_preloadTiles(a,b){const c=new Map,d=Array.isArray(a)?a:[a],f=this.map.painter.terrain,g=this.usedForTerrain&&f?f.getScaledDemTileSize():this._source.tileSize;for(const h of d){const i=h.coveringTiles({tileSize:g,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const j of i)c.set(j.key,j);this.usedForTerrain&&h.updateElevation(!1)}const k=Array.from(c.values()),l="raster"===this._source.type||"raster-dem"===this._source.type;$(k,(a,b)=>{const c=new kX(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,this.map.painter,l);this._loadTile(c,a=>{"raster-dem"===this._source.type&&c.dem&&this._backfillDEM(c),b(a,c)})},b)}}function ky(a,b){const c=Math.abs(2*a.wrap)- +(a.wrap<0),d=Math.abs(2*b.wrap)- +(b.wrap<0);return a.overscaledZ-b.overscaledZ||d-c||b.canonical.y-a.canonical.y||b.canonical.x-a.canonical.x}function kz(a){return"raster"===a||"image"===a||"video"===a}kx.maxOverzooming=10,kx.maxUnderzooming=3;class kA{constructor(a,b,c){this._demTile=a,this._dem=this._demTile.dem,this._scale=b,this._offset=c}static create(a,b,c){const d=c||a.findDEMTileFor(b);if(!d||!d.dem)return;const f=d.dem,g=d.tileID,h=1<<b.canonical.z-g.canonical.z;return new kA(d,d.tileSize/8192/h,[(b.canonical.x/h-g.canonical.x)*f.dim,(b.canonical.y/h-g.canonical.y)*f.dim,])}tileCoordToPixel(a,b){const c=b*this._scale+this._offset[1],d=Math.floor(a*this._scale+this._offset[0]);return new g(d,Math.floor(c))}getElevationAt(a,b,c,d){const f=a*this._scale+this._offset[0],g=b*this._scale+this._offset[1],h=Math.floor(f),i=Math.floor(g),j=this._dem;return d=!!d,c?cr(cr(j.get(h,i,d),j.get(h,i+1,d),g-i),cr(j.get(h+1,i,d),j.get(h+1,i+1,d),g-i),f-h):j.get(h,i,d)}getElevationAtPixel(a,b,c){return this._dem.get(a,b,!!c)}getMeterToDEM(a){return(1<<this._demTile.tileID.canonical.z)*gx(1,a)*this._dem.stride}}class kB{constructor(a,b){this.tileID=a,this.x=a.canonical.x,this.y=a.canonical.y,this.z=a.canonical.z,this.grid=new d7(8192,16,0),this.featureIndexArray=new fS,this.promoteId=b}insert(a,b,c,d,f,g=0){const h=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(c,d,f,g);const i=this.grid;for(let j=0;j<b.length;j++){const k=b[j],l=[1/0,1/0,-1/0,-1/0];for(let m=0;m<k.length;m++){const n=k[m];l[0]=Math.min(l[0],n.x),l[1]=Math.min(l[1],n.y),l[2]=Math.max(l[2],n.x),l[3]=Math.max(l[3],n.y)}l[0]<8192&&l[1]<8192&&l[2]>=0&&l[3]>=0&&i.insert(h,l[0],l[1],l[2],l[3])}}loadVTLayers(){if(!this.vtLayers)for(const a in this.vtLayers=new h2.VectorTile(new iG(this.rawTileData)).layers,this.sourceLayerCoder=new km(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[a]=[];return this.vtLayers}query(a,b,c,d){this.loadVTLayers();const f=a.params||{},g=dz(f.filter),h=a.tileResult,i=a.transform,j=h.bufferedTilespaceBounds,k=this.grid.query(j.min.x,j.min.y,j.max.x,j.max.y,(a,b,c,d)=>gT(h.bufferedTilespaceGeometry,a,b,c,d));k.sort(kD);let l=null;i.elevation&&k.length>0&&(l=kA.create(i.elevation,this.tileID));const m={};let n;for(let o=0;o<k.length;o++){const p=k[o];if(p===n)continue;n=p;const q=this.featureIndexArray.get(p);let r=null;this.loadMatchingFeature(m,q,g,f.layers,f.availableImages,b,c,d,(b,c,d,f=0)=>(r||(r=gF(b,this.tileID.canonical,a.tileTransform)),c.queryIntersectsFeature(h,b,d,r,this.z,a.transform,a.pixelPosMatrix,l,f)))}return m}loadMatchingFeature(a,b,c,d,f,g,h,i,j){const{featureIndex:k,bucketIndex:l,sourceLayerIndex:m,layoutVertexArrayOffset:n}=b,o=this.bucketLayerIDs[l];if(d&&!function(a,b){for(let c=0;c<a.length;c++)if(b.indexOf(a[c])>=0)return!0;return!1}(d,o))return;const p=this.sourceLayerCoder.decode(m),q=this.vtLayers[p].feature(k);if(c.needGeometry){const r=gG(q,!0);if(!c.filter(new e2(this.tileID.overscaledZ),r,this.tileID.canonical))return}else if(!c.filter(new e2(this.tileID.overscaledZ),q))return;const s=this.getId(q,p);for(let u=0;u<o.length;u++){const v=o[u];if(d&&0>d.indexOf(v))continue;const w=g[v];if(!w)continue;let x={};void 0!==s&&i&&(x=i.getState(w.sourceLayer||"_geojsonTileLayer",s));const y=aa({},h[v]);y.paint=kC(y.paint,w.paint,q,x,f),y.layout=kC(y.layout,w.layout,q,x,f);const z=!j||j(q,w,x,n);if(!z)continue;const A=new kn(q,this.z,this.x,this.y,s);A.layer=y;let B=a[v];void 0===B&&(B=a[v]=[]),B.push({featureIndex:k,feature:A,intersectionZ:z})}}lookupSymbolFeatures(a,b,c,d,f,g,h,i){const j={};this.loadVTLayers();const k=dz(f);for(const l of a)this.loadMatchingFeature(j,{bucketIndex:c,sourceLayerIndex:d,featureIndex:l,layoutVertexArrayOffset:0},k,g,h,i,b);return j}loadFeature(a){const{featureIndex:b,sourceLayerIndex:c}=a;this.loadVTLayers();const d=this.sourceLayerCoder.decode(c),f=this.vtFeatures[d];if(f[b])return f[b];const g=this.vtLayers[d].feature(b);return f[b]=g,g}hasLayer(a){for(const b of this.bucketLayerIDs)for(const c of b)if(a===c)return!0;return!1}getId(a,b){let c=a.id;return this.promoteId&&"boolean"==typeof(c=a.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[b]])&&(c=Number(c)),c}}function kC(a,b,c,d,f){return ai(a,(a,g)=>{const h=b instanceof e9?b.get(g):null;return h&&h.evaluate?h.evaluate(c,d,f):h})}function kD(a,b){return b-a}ec("FeatureIndex",kB,{omit:["rawTileData","sourceLayerCoder"]});var kE=fk([{name:"a_pos",type:"Int16",components:2},]);const kF=new Uint16Array(8184);for(let kG=0;kG<2046;kG++){let kH=kG+2,kI=0,kJ=0,kK=0,kL=0,kM=0,kN=0;for(1&kH?kK=kL=kM=32:kI=kJ=kN=32;(kH>>=1)>1;){const kO=kI+kK>>1,kP=kJ+kL>>1;1&kH?(kK=kI,kL=kJ,kI=kM,kJ=kN):(kI=kK,kJ=kL,kK=kM,kL=kN),kM=kO,kN=kP}const kQ=4*kG;kF[kQ+0]=kI,kF[kQ+1]=kJ,kF[kQ+2]=kK,kF[kQ+3]=kL}const kR=new Uint16Array(2178),kS=new Uint8Array(1089),kT=new Uint16Array(1089);function kU(a){return 0===a?-0.03125:32===a?.03125:0}var kV=fk([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2},]);const kW={type:2,extent:8192,loadGeometry:()=>[[new g(0,0),new g(8193,0),new g(8193,8193),new g(0,8193),new g(0,0),],]};class kX{constructor(a,b,c,d,f){this.tileID=a,this.uid=ac(),this.uses=0,this.tileSize=b,this.tileZoom=c,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=f,this.expiredRequestCount=0,this.state="loading",d&&d.transform&&(this.projection=d.transform.projection)}registerFadeDuration(a){const b=a+this.timeAdded;b<ax.now()||this.fadeEndTime&&b<this.fadeEndTime||(this.fadeEndTime=b)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=lc(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(a,b,c){if(this.unloadVectorData(),this.state="loaded",a){for(const d in a.featureIndex&&(this.latestFeatureIndex=a.featureIndex,a.rawTileData?(this.latestRawTileData=a.rawTileData,this.latestFeatureIndex.rawTileData=a.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=a.collisionBoxArray,this.buckets=function(a,b){const c={};if(!b)return c;for(const d of a){const f=d.layerIds.map(a=>b.getLayer(a)).filter(Boolean);if(0!==f.length)for(const g of(d.layers=f,d.stateDependentLayerIds&&(d.stateDependentLayers=d.stateDependentLayerIds.map(a=>f.filter(b=>b.id===a)[0])),f))c[g.id]=d}return c}(a.buckets,b.style),this.hasSymbolBuckets=!1,this.buckets){const f=this.buckets[d];if(f instanceof jV){if(this.hasSymbolBuckets=!0,!c)break;f.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const g in this.buckets){const h=this.buckets[g];if(h instanceof jV&&h.hasRTLText){this.hasRTLText=!0,e1.isLoading()||e1.isLoaded()||"deferred"!==e_()||e0();break}}for(const i in this.queryPadding=0,this.buckets){const j=this.buckets[i];this.queryPadding=Math.max(this.queryPadding,b.style.getLayer(i).queryRadius(j))}a.imageAtlas&&(this.imageAtlas=a.imageAtlas),a.glyphAtlasImage&&(this.glyphAtlasImage=a.glyphAtlasImage),a.lineAtlas&&(this.lineAtlas=a.lineAtlas)}else this.collisionBoxArray=new fK}unloadVectorData(){if(this.hasData()){for(const a in this.buckets)this.buckets[a].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.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(a){return this.buckets[a.id]}upload(a){for(const b in this.buckets){const c=this.buckets[b];c.uploadPending()&&c.upload(a)}const d=a.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new j9(a,this.imageAtlas.image,d.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new j9(a,this.glyphAtlasImage,d.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new j9(a,this.lineAtlas.image,d.ALPHA),this.lineAtlas.uploaded=!0)}prepare(a){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(a,this.imageAtlasTexture)}queryRenderedFeatures(a,b,c,d,f,g,h,i){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:h,transform:g,params:f,tileTransform:this.tileTransform},a,b,c):{}}querySourceFeatures(a,b){const c=this.latestFeatureIndex;if(!c||!c.rawTileData)return;const d=c.loadVTLayers(),f=b?b.sourceLayer:"",g=d._geojsonTileLayer||d[f];if(!g)return;const h=dz(b&&b.filter),{z:i,x:j,y:k}=this.tileID.canonical,l={z:i,x:j,y:k};for(let m=0;m<g.length;m++){const n=g.feature(m);if(h.needGeometry){const o=gG(n,!0);if(!h.filter(new e2(this.tileID.overscaledZ),o,this.tileID.canonical))continue}else if(!h.filter(new e2(this.tileID.overscaledZ),n))continue;const p=c.getId(n,f),q=new kn(n,i,j,k,p);q.tile=l,a.push(q)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(a){const b=this.expirationTime;if(a.cacheControl){const c=aq(a.cacheControl);c["max-age"]&&(this.expirationTime=Date.now()+1e3*c["max-age"])}else a.expires&&(this.expirationTime=new Date(a.expires).getTime());if(this.expirationTime){const d=Date.now();let f=!1;if(this.expirationTime>d)f=!1;else if(b){if(this.expirationTime<b)f=!0;else{const g=this.expirationTime-b;g?this.expirationTime=d+Math.max(g,3e4):f=!0}}else f=!0;f?(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(),2147483647)}setFeatureState(a,b){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(a).length||!b)return;const c=this.latestFeatureIndex.loadVTLayers(),d=b.style.listImages();for(const f in this.buckets){if(!b.style.hasLayer(f))continue;const g=this.buckets[f],h=g.layers[0].sourceLayer||"_geojsonTileLayer",i=c[h],j=a[h];if(!i||!j||0===Object.keys(j).length)continue;if(g.update(j,i,d,this.imageAtlas&&this.imageAtlas.patternPositions||{}),g instanceof ik||g instanceof hQ){const k=b.style._getSourceCache(g.layers[0].source);b._terrain&&b._terrain.enabled&&k&&g.programConfigurations.needsUpload&&b._terrain._clearRenderCacheForTile(k.id,this.tileID)}const l=b&&b.style&&b.style.getLayer(f);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(g)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<ax.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(a){this.symbolFadeHoldUntil=ax.now()+a}setDependencies(a,b){const c={};for(const d of b)c[d]=!0;this.dependencies[a]=c}hasDependency(a,b){for(const c of a){const d=this.dependencies[c];if(d){for(const f of b)if(d[f])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(a,b){if(!b||"mercator"===b.name||this._tileDebugBuffer)return;const c=gF(kW,this.tileID.canonical,this.tileTransform)[0],d=new fm,f=new fG;for(let g=0;g<c.length;g++){const{x:h,y:i}=c[g];d.emplaceBack(h,i),f.emplaceBack(g)}f.emplaceBack(0),this._tileDebugIndexBuffer=a.createIndexBuffer(f),this._tileDebugBuffer=a.createVertexBuffer(d,kV.members),this._tileDebugSegments=gq.simpleSegment(0,0,d.length,f.length)}_makeTileBoundsBuffers(a,b){if(this._tileBoundsBuffer||!b||"mercator"===b.name)return;const c=gF(kW,this.tileID.canonical,this.tileTransform)[0];let d,f;if(this.isRaster){const g=function(a,b){const c=lc(a,b),d=Math.pow(2,a.z);for(let f=0;f<33;f++)for(let g=0;g<33;g++){const h=gy((a.x+(g+kU(g))/32)/d),i=gz((a.y+(f+kU(f))/32)/d),j=b.project(h,i),k=33*f+g;kR[2*k+0]=Math.round((j.x*c.scale-c.x)*8192),kR[2*k+1]=Math.round((j.y*c.scale-c.y)*8192)}kS.fill(0),kT.fill(0);for(let l=2045;l>=0;l--){const m=4*l,n=kF[m+0],o=kF[m+1],p=kF[m+2],q=kF[m+3],r=n+p>>1,s=o+q>>1,u=r+s-o,v=s+n-r,w=33*o+n,x=33*q+p,y=33*s+r,z=Math.hypot((kR[2*w+0]+kR[2*x+0])/2-kR[2*y+0],(kR[2*w+1]+kR[2*x+1])/2-kR[2*y+1])>=16;if(kS[y]=kS[y]||(z?1:0),l<1022){const A=(o+v>>1)*33+(n+u>>1),B=(q+v>>1)*33+(p+u>>1);kS[y]=kS[y]||kS[A]||kS[B]}}const C=new fn,D=new fy;let E=0;function F(a,b){const c=33*b+a;return 0===kT[c]&&(C.emplaceBack(kR[2*c+0],kR[2*c+1],8192*a/32,8192*b/32),kT[c]=++E),kT[c]-1}function G(a,b,c,d,f,g){const h=a+c>>1,i=b+d>>1;if(Math.abs(a-f)+Math.abs(b-g)>1&&kS[33*i+h])G(f,g,a,b,h,i),G(c,d,f,g,h,i);else{const j=F(a,b),k=F(c,d),l=F(f,g);D.emplaceBack(j,k,l)}}return G(0,0,32,32,32,0),G(32,32,0,0,0,32),{vertices:C,indices:D}}(this.tileID.canonical,b);d=g.vertices,f=g.indices}else{for(const{x:h,y:i}of(d=new fn,f=new fy,c))d.emplaceBack(h,i,0,0);const j=hh(d.int16,void 0,4);for(let k=0;k<j.length;k+=3)f.emplaceBack(j[k],j[k+1],j[k+2])}this._tileBoundsBuffer=a.createVertexBuffer(d,kV.members),this._tileBoundsIndexBuffer=a.createIndexBuffer(f),this._tileBoundsSegments=gq.simpleSegment(0,0,d.length,f.length)}}const kY=fk([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2},]),kZ=fk([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2},]),{members:k$}=kY;function k_(a,b){const c=a.fovAboveCenter,d=a.elevation?a.elevation.getMinElevationBelowMSL()*b:0,f=(a._camera.position[2]*a.worldSize-d)/Math.cos(a._pitch),g=Math.sin(c)*f/Math.sin(Math.max(Math.PI/2-a._pitch-c,.01)),h=Math.sin(a._pitch)*g+f;return Math.min(1.01*h,f*(1/a._horizonShift))}const k0=8192/Math.PI/2,k1=-k0,k2=k0,k3=[new g0([k1,k1,k1],[k2,k2,k2]),new g0([k1,k1,k1],[0,0,k2]),new g0([0,k1,k1],[k2,0,k2]),new g0([k1,0,k1],[0,k2,k2]),new g0([0,0,k1],[k2,k2,k2]),];function k4(a){if(a.z<=1)return k3[a.z+2*a.y+a.x];const[b,c]=k5(a),d=[k7(b[0],b[1]),k7(b[0],c[1]),k7(c[0],b[1]),k7(c[0],c[1]),],f=[k2,k2,k2],g=[k1,k1,k1];for(const h of d)f[0]=Math.min(f[0],h[0]),f[1]=Math.min(f[1],h[1]),f[2]=Math.min(f[2],h[2]),g[0]=Math.max(g[0],h[0]),g[1]=Math.max(g[1],h[1]),g[2]=Math.max(g[2],h[2]);return new g0(f,g)}function k5(a){const b=Math.pow(2,a.z),c=a.x/b,d=(a.x+1)/b,f=(a.y+1)/b;return[[gz(a.y/b),gy(c)],[gz(f),gy(d)],]}function k6(a,b,c,d){return c*=P,d||(d=k0),[a*Math.sin(c)*d,-b*d,a*Math.cos(c)*d,]}function k7(a,b,c){return k6(Math.cos(a*P),Math.sin(a*P),b,c)}function k8(a){return 16383/Math.max(...J([],a.max,a.min))}function k9(a){const b=l(new Float64Array(16)),c=1/k8(a);return n(b,b,a.min),o(b,b,[c,c,c]),b}function la(a,b,c){const d=b/(2*Math.PI)/(8192/(2*Math.PI));if(!c){const f=X(a.center.lat,-85.051129,85.051129);c=[gv(a.center.lng)*b,gw(f)*b]}const g=l(new Float64Array(16));return n(g,g,[c[0],c[1],-(b/(2*Math.PI))]),o(g,g,[d,d,d]),p(g,g,-a._center.lat*P),q(g,g,-a._center.lng*P),g}class lb{constructor(a){const b=this._createGridIndices();this.gridIndexBuffer=a.createIndexBuffer(b,!0),this.gridSegments=gq.simpleSegment(0,0,4225,8192);const c=this._createPoleTriangleIndices();this.poleIndexBuffer=a.createIndexBuffer(c,!0),this.poleSegments=gq.simpleSegment(0,0,66,64);const d=new fD;d.emplaceBack(-1,1,1,0,0,0,0),d.emplaceBack(1,1,1,0,0,1,0),d.emplaceBack(1,-1,1,0,0,1,1),d.emplaceBack(-1,-1,1,0,0,0,1);const f=new fy;f.emplaceBack(0,1,2),f.emplaceBack(2,3,0),this.atmosphereVertexBuffer=a.createVertexBuffer(d,kZ.members),this.atmosphereIndexBuffer=a.createIndexBuffer(f),this.atmosphereSegments=gq.simpleSegment(0,0,4,2)}destroy(){this.poleIndexBuffer.destroy(),this.gridIndexBuffer.destroy(),this.poleSegments.destroy(),this.gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this.wireframeIndexBuffer&&(this.wireframeIndexBuffer.destroy(),this.wireframeSegments.destroy())}static createPoleTriangleVertices(a,b,c){var d;const f=new fD,g=b/Math.PI/2;f.emplaceBack(0,-g,0,0,0,.5,c?0:1);const h=360/a,i=Math.cos(85*P),j=Math.sin(85*P);for(let k=0;k<=64;k++){const l=k/64,m=k6(i,j,0*(1-(d=l))+h*d,g);f.emplaceBack(m[0],m[1],m[2],0,0,l,c?0:1)}return f}_createPoleTriangleIndices(){const a=new fy;for(let b=0;b<=64;b++)a.emplaceBack(0,b+1,b+2);return a}static createGridVertices(a){const b=Math.pow(2,a.z),[c,d]=k5(a),f=new fD,g=function(a){var b,c;const d=l(new Float64Array(16)),f=k8(a);return o(d,d,[f,f,f]),n(d,d,((b=[])[0]=-(c=a.min)[0],b[1]=-c[1],b[2]=-c[2],b)),d}(k4(a));f.reserve(4096);for(let h=0;h<65;h++){var i,j,k,m,p,q;const r=(i=c[0],j=d[0],i*(1-(k=h/64))+j*k),s=gw(r),u=s*b-a.y,v=Math.sin(r*P),w=Math.cos(r*P);for(let x=0;x<65;x++){const y=x/64,z=(m=c[1],p=d[1],m*(1-(q=y))+p*q),A=k6(w,v,z);G(A,A,g);const B=gv(z);f.emplaceBack(A[0],A[1],A[2],B,s,y,u)}}return f}_createGridIndices(){const a=new fy,b=(b,c)=>{const d=65*c+b;a.emplaceBack(d+1,d,d+65),a.emplaceBack(d+65,d+65+1,d+1)};for(let c=0;c<64;c++)for(let d=0;d<64;d++)b(d,c);return a}getWirefameBuffer(a){if(!this.wireframeSegments){const b=this._createWireframeGrid();this.wireframeIndexBuffer=a.createIndexBuffer(b),this.wireframeSegments=gq.simpleSegment(0,0,4096,b.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}_createWireframeGrid(){const a=new fF,b=(b,c)=>{const d=65*c+b;a.emplaceBack(d,d+1),a.emplaceBack(d,d+65),a.emplaceBack(d,d+65+1)};for(let c=0;c<64;c++)for(let d=0;d<64;d++)b(d,c);return a}}function lc(a,b){if(!b.isReprojectedInTileSpace)return{scale:1<<a.z,x:a.x,y:a.y,x2:a.x+1,y2:a.y+1,projection:b};const c=Math.pow(2,-a.z),d=a.x*c,f=(a.x+1)*c,g=a.y*c,h=(a.y+1)*c,i=gy(d),j=gy(f),k=gz(g),l=gz(h),m=b.project(i,k),n=b.project(j,k),o=b.project(j,l),p=b.project(i,l);let q=Math.min(m.x,n.x,o.x,p.x),r=Math.min(m.y,n.y,o.y,p.y),s=Math.max(m.x,n.x,o.x,p.x),u=Math.max(m.y,n.y,o.y,p.y);const v=c/16;function w(a,c,d,f,g,h){const i=(d+g)/2,j=(f+h)/2,k=b.project(gy(i),gz(j)),l=Math.max(0,q-k.x,r-k.y,k.x-s,k.y-u);q=Math.min(q,k.x),s=Math.max(s,k.x),r=Math.min(r,k.y),u=Math.max(u,k.y),l>v&&(w(a,k,d,f,i,j),w(k,c,i,j,g,h))}w(m,n,d,g,f,g),w(n,o,f,g,f,h),w(o,p,f,h,d,h),w(p,m,d,h,d,g),q-=v,r-=v,s+=v,u+=v;const x=1/Math.max(s-q,u-r);return{scale:x,x:q*x,y:r*x,x2:s*x,y2:u*x,projection:b}}class ld{constructor(a){const b={},c=[];for(const d in a){const f=a[d],g=b[d]={};for(const h in f.glyphs){const i=f.glyphs[+h];if(!i||0===i.bitmap.width||0===i.bitmap.height)continue;const j=i.metrics.localGlyph?2:1,k={x:0,y:0,w:i.bitmap.width+2*j,h:i.bitmap.height+2*j};c.push(k),g[h]=k}}const{w:l,h:m}=i$(c),n=new ha({width:l||1,height:m||1});for(const o in a){const p=a[o];for(const q in p.glyphs){const r=p.glyphs[+q];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const s=b[o][q],u=r.metrics.localGlyph?2:1;ha.copy(r.bitmap,n,{x:0,y:0},{x:s.x+u,y:s.y+u},r.bitmap)}}this.image=n,this.positions=b}}ec("GlyphAtlas",ld);class le{constructor(a){this.tileID=new kg(a.tileID.overscaledZ,a.tileID.wrap,a.tileID.canonical.z,a.tileID.canonical.x,a.tileID.canonical.y),this.tileZoom=a.tileZoom,this.uid=a.uid,this.zoom=a.zoom,this.canonical=a.tileID.canonical,this.pixelRatio=a.pixelRatio,this.tileSize=a.tileSize,this.source=a.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=a.showCollisionBoxes,this.collectResourceTiming=!!a.collectResourceTiming,this.returnDependencies=!!a.returnDependencies,this.promoteId=a.promoteId,this.enableTerrain=!!a.enableTerrain,this.isSymbolTile=a.isSymbolTile,this.tileTransform=lc(a.tileID.canonical,a.projection),this.projection=a.projection}parse(a,b,c,d,f){this.status="parsing",this.data=a,this.collisionBoxArray=new fK;const g=new km(Object.keys(a.layers).sort()),h=new kB(this.tileID,this.promoteId);h.bucketLayerIDs=[];const i={},j=new ka(256,256),k={featureIndex:h,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:j,availableImages:c},l=b.familiesBySource[this.source];for(const m in l){const n=a.layers[m];if(!n)continue;let o=!1,p=!1;for(const q of l[m])"symbol"===q[0].type?o=!0:p=!0;if(!0===this.isSymbolTile&&!o|| !1===this.isSymbolTile&&!p)continue;1===n.version&&am(`Vector tile source "${this.source}" layer "${m}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const r=g.encode(m),s=[];for(let u=0;u<n.length;u++){const v=n.feature(u),w=h.getId(v,m);s.push({feature:v,id:w,index:u,sourceLayerIndex:r})}for(const x of l[m]){const y=x[0];void 0!==this.isSymbolTile&&"symbol"===y.type!==this.isSymbolTile||y.minzoom&&this.zoom<Math.floor(y.minzoom)||y.maxzoom&&this.zoom>=y.maxzoom||"none"!==y.visibility&&(lf(x,this.zoom,c),(i[y.id]=y.createBucket({index:h.bucketLayerIDs.length,layers:x,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:r,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:c})).populate(s,k,this.tileID.canonical,this.tileTransform),h.bucketLayerIDs.push(x.map(a=>a.id)))}}let z,A,B,C;j.trim();const D={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},E=ai(k.glyphDependencies,a=>Object.keys(a).map(Number));Object.keys(E).length?d.send("getGlyphs",{uid:this.uid,stacks:E},(a,b)=>{z||(z=a,A=b,H.call(this))},void 0,!1,D):A={};const F=Object.keys(k.iconDependencies);F.length?d.send("getImages",{icons:F,source:this.source,tileID:this.tileID,type:"icons"},(a,b)=>{z||(z=a,B=b,H.call(this))},void 0,!1,D):B={};const G=Object.keys(k.patternDependencies);function H(){if(z)return f(z);if(A&&B&&C){const a=new ld(A),b=new i0(B,C);for(const d in i){const g=i[d];g instanceof jV?(lf(g.layers,this.zoom,c),jF(g,A,a.positions,B,b.iconPositions,this.showCollisionBoxes,c,this.tileID.canonical,this.tileZoom,this.projection),g.projection=this.projection.name):g.hasPattern&&(g instanceof ik||g instanceof hQ||g instanceof h6)&&(lf(g.layers,this.zoom,c),g.addFeatures(k,this.tileID.canonical,b.patternPositions,c))}this.status="done",f(null,{buckets:_(i).filter(a=>!a.isEmpty()),featureIndex:h,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:a.image,lineAtlas:j,imageAtlas:b,glyphMap:this.returnDependencies?A:null,iconMap:this.returnDependencies?B:null,glyphPositions:this.returnDependencies?a.positions:null})}}G.length?d.send("getImages",{icons:G,source:this.source,tileID:this.tileID,type:"patterns"},(a,b)=>{z||(z=a,C=b,H.call(this))},void 0,!1,D):C={},H.call(this)}}function lf(a,b,c){const d=new e2(b);for(const f of a)f.recalculate(d,c)}class lg{constructor(a){this.entries={},this.scheduler=a}request(a,b,c,d){const f=this.entries[a]=this.entries[a]||{callbacks:[]};if(f.result){const[g,h]=f.result;return this.scheduler?this.scheduler.add(()=>{d(g,h)},b):d(g,h),()=>{}}return f.callbacks.push(d),f.cancel||(f.cancel=c((c,d)=>{for(const g of(f.result=[c,d],f.callbacks))this.scheduler?this.scheduler.add(()=>{g(c,d)},b):g(c,d);setTimeout(()=>delete this.entries[a],3e3)})),()=>{f.result||(f.callbacks=f.callbacks.filter(a=>a!==d),f.callbacks.length||(f.cancel(),delete this.entries[a]))}}}function lh(a,b,c){const d=JSON.stringify(a.request);return a.data&&(this.deduped.entries[d]={result:[null,a.data]}),this.deduped.request(d,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},b=>{const d=a7(a.request,(a,d,f,g)=>{a?b(a):d&&b(null,{vectorTile:c?void 0:new h2.VectorTile(new iG(d)),rawData:d,cacheControl:f,expires:g})});return()=>{d.cancel(),b()}},b)}const li=l(new Float64Array(16));class lj{constructor(a,b){this._tr=a,this._worldSize=b}createInversionMatrix(){return li}createTileMatrix(a){let b,c,d;const f=a.canonical,g=l(new Float64Array(16)),h=this._tr.projection;if(h.isReprojectedInTileSpace){const i=lc(f,h);b=1,c=i.x+a.wrap*i.scale,d=i.y,o(g,g,[b/i.scale,b/i.scale,this._tr.pixelsPerMeter/this._worldSize,])}else b=this._worldSize/this._tr.zoomScale(f.z),c=(f.x+Math.pow(2,f.z)*a.wrap)*b,d=f.y*b;return n(g,g,[c,d,0]),o(g,g,[b/8192,b/8192,1]),g}pointCoordinate(a,b,c){const d=this._tr.horizonLineFromTop(!1),f=new g(a,Math.max(d,b));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(f,c))}upVector(){return[0,0,1]}upVectorScale(){return 1}}var lk={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&O(this.parallels,this.constants.parallels))return;const a=Math.sin(this.parallels[0]*P),b=(a+Math.sin(this.parallels[1]*P))/2,c=1+a*(2*b-a),d=Math.sqrt(c)/b;this.constants={n:b,c:c,r0:d,parallels:this.parallels}},project(a,b){this.initializeConstants();const c=(a-this.center[0])*P,{n:d,c:f,r0:g}=this.constants,h=Math.sqrt(f-2*d*Math.sin(b*P))/d;return{x:h*Math.sin(c*d),y:h*Math.cos(c*d)-g,z:0}},unproject(a,b){this.initializeConstants();const{n:c,c:d,r0:f}=this.constants,g=f+b;let h=Math.atan2(a,Math.abs(g))*Math.sign(g);g*c<0&&(h-=Math.PI*Math.sign(a)*Math.sign(g));const i=this.center[0]*P*c;h=Z(h,-Math.PI-i,Math.PI-i);const j=h/c*Q+this.center[0],k=Math.asin(X((d-(a*a+g*g)*c*c)/(2*c),-1,1)),l=X(k*Q,-85.051129,85.051129);return new gs(j,l)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>gx(1,a)*b,farthestPixelDistance(a){return k_(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lj(a,b)};const ll=Math.sqrt(3)/2;var lm={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(a,b){b=b/180*Math.PI,a=a/180*Math.PI;const c=Math.asin(ll*Math.sin(b)),d=c*c,f=d*d*d;return{x:.5*(a*Math.cos(c)/(ll*(1.340264+ -0.24331799999999998*d+f*(.0062510000000000005+.034164*d)))/Math.PI+.5),y:1-.5*(c*(1.340264+ -0.081106*d+f*(893e-6+.003796*d))/Math.PI+1),z:0}},unproject(a,b){a=(2*a-.5)*Math.PI;let c=b=(2*(1-b)-1)*Math.PI,d=c*c,f=d*d*d;for(let g,h,i,j=0;j<12&&(h=c*(1.340264+ -0.081106*d+f*(893e-6+.003796*d))-b,i=1.340264+ -0.24331799999999998*d+f*(.0062510000000000005+.034164*d),g=h/i,c=X(c-g,-Math.PI/3,Math.PI/3),d=c*c,f=d*d*d,!(1e-12>Math.abs(g)));++j);const k=ll*a*(1.340264+ -0.24331799999999998*d+f*(.0062510000000000005+.034164*d))/Math.cos(c),l=Math.asin(Math.sin(c)/ll),m=X(180*k/Math.PI,-180,180),n=X(180*l/Math.PI,-85.051129,85.051129);return new gs(m,n)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>gx(1,a)*b,farthestPixelDistance(a){return k_(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lj(a,b)},ln={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(a,b)=>({x:.5+a/360,y:.5-b/360,z:0}),unproject(a,b){const c=X(360*(.5-b),-85.051129,85.051129);return new gs(360*(a-.5),c)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>gx(1,a)*b,farthestPixelDistance(a){return k_(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lj(a,b)};const lo=Math.PI/2;function lp(a){return Math.tan((lo+a)/2)}var lq,lr={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&O(this.parallels,this.constants.parallels))return;const a=this.parallels[0]*P,b=this.parallels[1]*P,c=Math.cos(a),d=a===b?Math.sin(a):Math.log(c/Math.cos(b))/Math.log(lp(b)/lp(a)),f=c*Math.pow(lp(a),d)/d;this.constants={n:d,f:f,parallels:this.parallels}},project(a,b){this.initializeConstants(),b*=P,a=(a-this.center[0])*P;const{n:c,f:d}=this.constants;d>0?b< -lo+1e-6&&(b=-lo+1e-6):b>lo-1e-6&&(b=lo-1e-6);const f=d/Math.pow(lp(b),c),g=f*Math.sin(c*a),h=d-f*Math.cos(c*a);return{x:.5*(g/Math.PI+.5),y:1-.5*(h/Math.PI+.5),z:0}},unproject(a,b){this.initializeConstants(),a=(2*a-.5)*Math.PI,b=(2*(1-b)-.5)*Math.PI;const{n:c,f:d}=this.constants,f=d-b,g=Math.sign(f),h=Math.sign(c)*Math.sqrt(a*a+f*f);let i=Math.atan2(a,Math.abs(f))*g;f*c<0&&(i-=Math.PI*Math.sign(a)*g);const j=X(i/c*Q+this.center[0],-180,180),k=X((2*Math.atan(Math.pow(d/h,1/c))-lo)*Q,-85.051129,85.051129);return new gs(j,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>gx(1,a)*b,farthestPixelDistance(a){return k_(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lj(a,b)},ls={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(a,b)=>({x:gv(a),y:gw(b),z:0}),unproject(a,b){const c=gy(a),d=gz(b);return new gs(c,d)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>gx(1,a)*b,farthestPixelDistance(a){return k_(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lj(a,b)};const lt=85.051129*P;var lu={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(a,b){const c=(b*=P)*b,d=c*c;return{x:.5*((a*=P)*(.8707-.131979*c+d*(d*(.003971*c-.001529*d)-.013791))/Math.PI+.5),y:1-.5*(b*(1.007226+c*(.015085+d*(.028874*c-.044475-.005916*d)))/Math.PI+1),z:0}},unproject(a,b){a=(2*a-.5)*Math.PI;let c=b=(2*(1-b)-1)*Math.PI,d=25,f=0,g=c*c;do{g=c*c;const h=g*g;f=(c*(1.007226+g*(.015085+h*(.028874*g-.044475-.005916*h)))-b)/(1.007226+g*(.045255+h*(.259866*g-.311325-.06507600000000001*h))),c=X(c-f,-lt,lt)}while(Math.abs(f)>1e-6&& --d>0)g=c*c;const i=X(a/(.8707+g*(g*(g*g*g*(.003971-.001529*g)-.013791)-.131979))*Q,-180,180),j=c*Q;return new gs(i,j)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>gx(1,a)*b,farthestPixelDistance(a){return k_(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lj(a,b)};const lv=85.051129*P,lw={albers:lk,equalEarth:lm,equirectangular:ln,lambertConformalConic:lr,mercator:ls,naturalEarth:lu,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(a,b){b*=P,a*=P;const c=Math.cos(b),d=Math.acos(c*Math.cos(a/2)),f=Math.sin(d)/d,g=.5*(a*(2/Math.PI)+2*c*Math.sin(a/2)/f)||0,h=.5*(b+Math.sin(b)/f)||0;return{x:.5*(g/Math.PI+.5),y:1-.5*(h/Math.PI+1),z:0}},unproject(a,b){let c=a=(2*a-.5)*Math.PI,d=b=(2*(1-b)-1)*Math.PI,f=25,g=0,h=0;do{const i=Math.cos(d),j=Math.sin(d),k=2*j*i,l=j*j,m=i*i,n=Math.cos(c/2),o=Math.sin(c/2),p=2*n*o,q=o*o,r=1-m*n*n,s=r?1/r:0,u=r?Math.acos(i*n)*Math.sqrt(1/r):0,v=.5*(2*u*i*o+2*c/Math.PI)-a,w=.5*(u*j+d)-b,x=.5*s*(m*q+u*i*n*l)+1/Math.PI,y=s*(p*k/4-u*j*o),z=.125*s*(k*o-u*j*m*p),A=.5*s*(l*n+u*q*i)+.5,B=y*z-A*x;g=(w*y-v*A)/B,h=(v*z-w*x)/B,c=X(c-g,-Math.PI,Math.PI),d=X(d-h,-lv,lv)}while((Math.abs(g)>1e-6||Math.abs(h)>1e-6)&& --f>0)return new gs(c*Q,d*Q)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>gx(1,a)*b,farthestPixelDistance(a){return k_(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new lj(a,b)}};a.ARRAY_TYPE=j,a.AUTH_ERR_MSG=aI,a.Aabb=g0,a.Actor=class{constructor(a,b,c){this.target=a,this.parent=b,this.mapId=c,this.callbacks={},this.cancelCallbacks={},ag(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ap()?a:i,this.scheduler=new class{constructor(){this.tasks={},this.taskQueue=[],ag(["process"],this),this.invoker=new class{constructor(a){this._callback=a,this._triggered=!1,"undefined"!=typeof MessageChannel&&(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(){delete this._channel,this._callback=()=>{}}}(this.process),this.nextId=0}add(a,b){const c=this.nextId++,d=function({type:a,isSymbolTile:b,zoom:c}){return c=c||0,"message"===a?0:"maybePrepare"!==a||b?"parseTile"!==a||b?"parseTile"===a&&b?300-c:"maybePrepare"===a&&b?400-c:500:200-c:100-c}(b);return 0===d?(ap(),a(),{cancel(){}}):(this.tasks[c]={fn:a,metadata:b,priority:d,id:c},this.taskQueue.push(c),this.invoker.trigger(),{cancel:()=>{delete this.tasks[c]}})}process(){ap();{if(this.taskQueue=this.taskQueue.filter(a=>!!this.tasks[a]),!this.taskQueue.length)return;const a=this.pick();if(null===a)return;const b=this.tasks[a];if(delete this.tasks[a],this.taskQueue.length&&this.invoker.trigger(),!b)return;b.fn()}}pick(){let a=null,b=1/0;for(let c=0;c<this.taskQueue.length;c++){const d=this.tasks[this.taskQueue[c]];d.priority<b&&(b=d.priority,a=c)}if(null===a)return null;const f=this.taskQueue[a];return this.taskQueue.splice(a,1),f}remove(){this.invoker.remove()}}}send(a,b,c,d,f=!1,g){const h=Math.round(1e18*Math.random()).toString(36).substring(0,10);c&&(c.metadata=g,this.callbacks[h]=c);const i=av(this.globalScope)?void 0:[];return this.target.postMessage({id:h,type:a,hasCallback:!!c,targetMapId:d,mustQueue:f,sourceMapId:this.mapId,data:eg(b,i)},i),{cancel:()=>{c&&delete this.callbacks[h],this.target.postMessage({id:h,type:"<cancel>",targetMapId:d,sourceMapId:this.mapId})}}}receive(a){const b=a.data,c=b.id;if(c&&(!b.targetMapId||this.mapId===b.targetMapId)){if("<cancel>"===b.type){const d=this.cancelCallbacks[c];delete this.cancelCallbacks[c],d&&d.cancel()}else if(b.mustQueue||ap()){const f=this.callbacks[c];this.cancelCallbacks[c]=this.scheduler.add(()=>this.processTask(c,b),f&&f.metadata||{type:"message"})}else this.processTask(c,b)}}processTask(a,b){if("<response>"===b.type){const c=this.callbacks[a];delete this.callbacks[a],c&&(b.error?c(eh(b.error)):c(null,eh(b.data)))}else{const d=av(this.globalScope)?void 0:[],f=b.hasCallback?(b,c)=>{delete this.cancelCallbacks[a],this.target.postMessage({id:a,type:"<response>",sourceMapId:this.mapId,error:b?eg(b):null,data:eg(c,d)},d)}:a=>{},g=eh(b.data);if(this.parent[b.type])this.parent[b.type](b.sourceMapId,g,f);else if(this.parent.getWorkerSource){const h=b.type.split(".");this.parent.getWorkerSource(b.sourceMapId,h[0],g.source)[h[1]](g,f)}else f(Error(`Could not find function ${b.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=ke,a.Color=bK,a.ColorMode=kk,a.CullFaceMode=kl,a.DEMData=kw,a.DataConstantProperty=fa,a.DedupedRequest=lg,a.DepthMode=ki,a.EXTENT=8192,a.Elevation=class{getAtPointOrZero(a,b=0){return this.getAtPoint(a,b)||0}getAtPoint(a,b,c=!0){null==b&&(b=null);const d=this._source();if(!d||a.y<0||a.y>1)return b;const f=d.getSource().maxzoom,g=1<<f,h=Math.floor(a.x),i=a.x-h,j=new kg(f,h,f,Math.floor(i*g),Math.floor(a.y*g)),k=this.findDEMTileFor(j);if(!k||!k.dem)return b;const l=k.dem,m=1<<k.tileID.canonical.z,n=(i*m-k.tileID.canonical.x)*l.dim,o=(a.y*m-k.tileID.canonical.y)*l.dim,p=Math.floor(n),q=Math.floor(o);return(c?this.exaggeration():1)*cr(cr(l.get(p,q),l.get(p,q+1),o-q),cr(l.get(p+1,q),l.get(p+1,q+1),o-q),n-p)}getAtTileOffset(a,b,c){const d=1<<a.canonical.z;return this.getAtPointOrZero(new gB(a.wrap+(a.canonical.x+b/8192)/d,(a.canonical.y+c/8192)/d))}getAtTileOffsetFunc(a,b){return c=>{const d=this.getAtTileOffset(a,c.x,c.y),f=b.upVector(a.canonical,c.x,c.y);return B(f,f,d*b.upVectorScale(a.canonical)),f}}getForTilePoints(a,b,c,d){const f=kA.create(this,a,d);return!!f&&(b.forEach(a=>{a[2]=this.exaggeration()*f.getElevationAt(a[0],a[1],c)}),!0)}getMinMaxForTile(a){const b=this.findDEMTileFor(a);if(!b||!b.dem)return null;const c=b.dem.tree,d=b.tileID,f=1<<a.canonical.z-d.canonical.z;let g=a.canonical.x/f-d.canonical.x,h=a.canonical.y/f-d.canonical.y,i=0;for(let j=0;j<a.canonical.z-d.canonical.z&&!c.leaves[i];j++){g*=2,h*=2;const k=2*Math.floor(h)+Math.floor(g);i=c.childOffsets[i]+k,g%=1,h%=1}return{min:this.exaggeration()*c.minimums[i],max:this.exaggeration()*c.maximums[i]}}getMinElevationBelowMSL(){throw Error("Pure virtual method called.")}raycast(a,b,c){throw Error("Pure virtual method called.")}pointCoordinate(a){throw Error("Pure virtual method called.")}_source(){throw Error("Pure virtual method called.")}exaggeration(){throw Error("Pure virtual method called.")}findDEMTileFor(a){throw Error("Pure virtual method called.")}get visibleDemTiles(){throw Error("Getter must be implemented in subclass.")}},a.ErrorEvent=bi,a.EvaluationParameters=e2,a.Event=bh,a.Evented=bj,a.Frustum=g_,a.GLOBE_ZOOM_THRESHOLD_MAX=6,a.GlobeSharedBuffers=lb,a.GlyphManager=jt,a.ImagePosition=i_,a.LineAtlas=ka,a.LngLat=gs,a.LngLatBounds=gr,a.LocalGlyphMode=js,a.MAX_MERCATOR_LATITUDE=85.051129,a.MercatorCoordinate=gB,a.ONE_EM=24,a.OverscaledTileID=kg,a.Properties=ff,a.RGBAImage=hb,a.Ray=class{constructor(a,b){this.pos=a,this.dir=b}intersectsPlane(a,b,c){const d=E(b,this.dir);if(1e-6>Math.abs(d))return!1;const f=((a[0]-this.pos[0])*b[0]+(a[1]-this.pos[1])*b[1]+(a[2]-this.pos[2])*b[2])/d;return c[0]=this.pos[0]+this.dir[0]*f,c[1]=this.pos[1]+this.dir[1]*f,c[2]=this.pos[2]+this.dir[2]*f,!0}closestPointOnSphere(a,b,c){var d,f,g,h,i,j,k,l;if(d=this.pos,f=a,g=d[0],h=d[1],i=d[2],j=f[0],k=f[1],l=f[2],Math.abs(g-j)<=1e-6*Math.max(1,Math.abs(g),Math.abs(j))&&Math.abs(h-k)<=1e-6*Math.max(1,Math.abs(h),Math.abs(k))&&Math.abs(i-l)<=1e-6*Math.max(1,Math.abs(i),Math.abs(l))||0===b)return c[0]=c[1]=c[2]=0,!1;const[m,n,o]=this.dir,p=this.pos[0]-a[0],q=this.pos[1]-a[1],r=this.pos[2]-a[2],s=m*m+n*n+o*o,u=2*(p*m+q*n+r*o),v=u*u-4*s*(p*p+q*q+r*r-b*b);if(v<0){const w=Math.max(-u/2,0),x=p+m*w,y=q+n*w,z=r+o*w,A=Math.hypot(x,y,z);return c[0]=x*b/A,c[1]=y*b/A,c[2]=z*b/A,!1}{const B=(-u-Math.sqrt(v))/(2*s);if(B<0){const C=Math.hypot(p,q,r);return c[0]=p*b/C,c[1]=q*b/C,c[2]=r*b/C,!1}return c[0]=p+m*B,c[1]=q+n*B,c[2]=r+o*B,!0}}},a.RequestManager=class{constructor(a,b,c){this._transformRequestFn=a,this._customAccessToken=b,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){const a=function(){let a="";for(let b=0;b<10;b++)a+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",a].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=a.token,this._skuTokenExpiresAt=a.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(a,b){return this._transformRequestFn&&this._transformRequestFn(a,b)||{url:a}}normalizeStyleURL(a,b){if(!aJ(a))return a;const c=aM(a);return c.path=`/styles/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||b)}normalizeGlyphsURL(a,b){if(!aJ(a))return a;const c=aM(a);return c.path=`/fonts/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||b)}normalizeSourceURL(a,b){if(!aJ(a))return a;const c=aM(a);return c.path=`/v4/${c.authority}.json`,c.params.push("secure"),this._makeAPIURL(c,this._customAccessToken||b)}normalizeSpriteURL(a,b,c,d){const f=aM(a);return aJ(a)?(f.path=`/styles/v1${f.path}/sprite${b}${c}`,this._makeAPIURL(f,this._customAccessToken||d)):(f.path+=`${b}${c}`,aN(f))}normalizeTileURL(a,b,c){if(this._isSkuTokenExpired()&&this._createSkuToken(),a&&!aJ(a))return a;const d=aM(a);d.path=d.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${b||c&&"raster"!==d.authority&&512===c?"@2x":""}${aC.supported?".webp":"$1"}`),"raster"===d.authority?d.path=`/${az.RASTER_URL_PREFIX}${d.path}`:(d.path=d.path.replace(/^.+\/v4\//,"/"),d.path=`/${az.TILE_URL_VERSION}${d.path}`);const f=this._customAccessToken||function(a){for(const b of a){const c=b.match(/^access_token=(.*)$/);if(c)return c[1]}return null}(d.params)||az.ACCESS_TOKEN;return az.REQUIRE_ACCESS_TOKEN&&f&&this._skuToken&&d.params.push(`sku=${this._skuToken}`),this._makeAPIURL(d,f)}canonicalizeTileURL(a,b){const c=aM(a);if(!c.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!c.path.match(/\.[\w]+$/))return a;let d="mapbox://";c.path.match(/^\/raster\/v1\//)?d+=`raster/${c.path.replace(`/${az.RASTER_URL_PREFIX}/`,"")}`:d+=`tiles/${c.path.replace(`/${az.TILE_URL_VERSION}/`,"")}`;let f=c.params;return b&&(f=f.filter(a=>!a.match(/^access_token=/))),f.length&&(d+=`?${f.join("&")}`),d}canonicalizeTileset(a,b){const c=!!b&&aJ(b),d=[];for(const f of a.tiles||[])aK(f)?d.push(this.canonicalizeTileURL(f,c)):d.push(f);return d}_makeAPIURL(a,b){const c="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",d=aM(az.API_URL);if(a.protocol=d.protocol,a.authority=d.authority,"http"===a.protocol){const f=a.params.indexOf("secure");f>=0&&a.params.splice(f,1)}if("/"!==d.path&&(a.path=`${d.path}${a.path}`),!az.REQUIRE_ACCESS_TOKEN)return aN(a);if(b=b||az.ACCESS_TOKEN,!this._silenceAuthErrors){if(!b)throw Error(`An API access token is required to use Mapbox GL. ${c}`);if("s"===b[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${c}`)}return a.params=a.params.filter(a=>-1===a.indexOf("access_token")),a.params.push(`access_token=${b||""}`),aN(a)}},a.ResourceType=a3,a.SegmentVector=gq,a.SourceCache=kx,a.StencilMode=kj,a.StructArrayLayout1ui2=fG,a.StructArrayLayout2f1f2i16=fw,a.StructArrayLayout2i4=fm,a.StructArrayLayout2ui4=fF,a.StructArrayLayout3f12=fp,a.StructArrayLayout3ui6=fy,a.StructArrayLayout4i8=fn,a.Texture=j9,a.Tile=kX,a.Transitionable=e5,a.Uniform1f=f3,a.Uniform1i=class extends f2{constructor(a,b){super(a,b),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},a.Uniform2f=class extends f2{constructor(a,b){super(a,b),this.current=[0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]||(this.current=a,this.gl.uniform2f(this.location,a[0],a[1]))}},a.Uniform3f=class extends f2{constructor(a,b){super(a,b),this.current=[0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]||(this.current=a,this.gl.uniform3f(this.location,a[0],a[1],a[2]))}},a.Uniform4f=f4,a.UniformColor=f5,a.UniformMatrix2f=class extends f2{constructor(a,b){super(a,b),this.current=f8}set(a){for(let b=0;b<4;b++)if(a[b]!==this.current[b]){this.current=a,this.gl.uniformMatrix2fv(this.location,!1,a);break}}},a.UniformMatrix3f=class extends f2{constructor(a,b){super(a,b),this.current=f7}set(a){for(let b=0;b<9;b++)if(a[b]!==this.current[b]){this.current=a,this.gl.uniformMatrix3fv(this.location,!1,a);break}}},a.UniformMatrix4f=class extends f2{constructor(a,b){super(a,b),this.current=f6}set(a){if(a[12]!==this.current[12]||a[0]!==this.current[0])return this.current=a,void this.gl.uniformMatrix4fv(this.location,!1,a);for(let b=1;b<16;b++)if(a[b]!==this.current[b]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},a.UnwrappedTileID=kf,a.ValidationError=bl,a.VectorTileWorkerSource=class extends bj{constructor(a,b,c,d,f){super(),this.actor=a,this.layerIndex=b,this.availableImages=c,this.loadVectorData=f||lh,this.loading={},this.loaded={},this.deduped=new lg(a.scheduler),this.isSpriteLoaded=d,this.scheduler=a.scheduler}loadTile(a,b){const c=a.uid,d=a&&a.request,f=d&&d.collectResourceTiming,g=this.loading[c]=new le(a);g.abort=this.loadVectorData(a,(h,i)=>{const j=!this.loading[c];if(delete this.loading[c],j||h||!i)return g.status="done",j||(this.loaded[c]=g),b(h);const k=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl),g.vectorTile=i.vectorTile||new h2.VectorTile(new iG(k));const m=()=>{g.parse(g.vectorTile,this.layerIndex,this.availableImages,this.actor,(a,c)=>{if(a||!c)return b(a);const g={};if(f){const h=kc(d);h.length>0&&(g.resourceTiming=JSON.parse(JSON.stringify(h)))}b(null,aa({rawTileData:k.slice(0)},c,l,g))})};this.isSpriteLoaded?m():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(m,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):m()}),this.loaded=this.loaded||{},this.loaded[c]=g})}reloadTile(a,b){const c=this.loaded,d=a.uid,f=this;if(c&&c[d]){const g=c[d];g.showCollisionBoxes=a.showCollisionBoxes,g.enableTerrain=!!a.enableTerrain,g.projection=a.projection;const h=(a,c)=>{const d=g.reloadCallback;d&&(delete g.reloadCallback,g.parse(g.vectorTile,f.layerIndex,this.availableImages,f.actor,d)),b(a,c)};"parsing"===g.status?g.reloadCallback=h:"done"===g.status&&(g.vectorTile?g.parse(g.vectorTile,this.layerIndex,this.availableImages,this.actor,h):h())}}abortTile(a,b){const c=a.uid,d=this.loading[c];d&&(d.abort&&d.abort(),delete this.loading[c]),b()}removeTile(a,b){const c=this.loaded,d=a.uid;c&&c[d]&&delete c[d],b()}},a.WritingMode=i1,a.ZoomHistory=ei,a.add=x,a.addDynamicAttributes=jR,a.adjoint=function(a,b){var c=b[0],d=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8];return a[0]=h*l-i*k,a[1]=f*k-d*l,a[2]=d*i-f*h,a[3]=i*j-g*l,a[4]=c*l-f*j,a[5]=f*g-c*i,a[6]=g*k-h*j,a[7]=d*j-c*k,a[8]=c*h-d*g,a},a.asyncAll=$,a.bezier=V,a.bindAll=ag,a.boundsAttributes=kV,a.bufferConvexPolygon=function(a,b){const c=[];for(let d=0;d<a.length;d++){const f=Z(d-1,-1,a.length-1),g=Z(d+1,-1,a.length-1),h=a[d],i=a[g],j=a[f].sub(h).unit(),k=i.sub(h).unit(),l=k.angleWithSep(j.x,j.y),m=j.add(k).unit().mult(-1*b/Math.sin(l/2));c.push(h.add(m))}return c},a.cacheEntryPossiblyAdded=function(a){++a2>a_&&(a.getActor().send("enforceCacheSizeLimit",a$),a2=0)},a.calculateGlobeMatrix=la,a.calculateGlobeMercatorMatrix=function(a){const b=a.worldSize,c=X(a.center.lat,-85.051129,85.051129),d=new g(gv(a.center.lng)*b,gw(c)*b),f=gx(1,a.center.lat)*b,h=a.pixelsPerMeter,i=b/(f/a.pixelsPerMeter),j=l(new Float64Array(16));return n(j,j,[d.x,d.y,0]),o(j,j,[i,i,h]),j},a.clamp=X,a.clearTileCache=function(a){const b=i.caches.delete(aX);a&&b.catch(a).then(()=>a())},a.clipLine=jp,a.clone=function(a){var b=new j(16);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15],b},a.clone$1=ak,a.collisionCircleLayout=iv,a.config=az,a.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},a.create=function(){var a=new j(16);return j!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},a.create$1=k,a.createExpression=dk,a.createLayout=fk,a.createStyleLayer=function(a){return"custom"===a.type?new j0(a):new j3[a.type](a)},a.cross=F,a.degToRad=R,a.div=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},a.dot=E,a.ease=W,a.easeCubicInOut=U,a.emitValidationErrors=d6,a.endsWith=ah,a.enforceCacheSizeLimit=function(a){a0(),aY&&aY.then(b=>{b.keys().then(c=>{for(let d=0;d<c.length-a;d++)b.delete(c[d])})})},a.evaluateSizeForFeature=ix,a.evaluateSizeForZoom=iy,a.evaluateVariableOffset=jE,a.evented=e$,a.exactEquals=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]},a.exactEquals$1=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]},a.exported=ax,a.exported$1=aC,a.extend=aa,a.extend$1=bn,a.filterObject=aj,a.fromMat4=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[4],a[4]=b[5],a[5]=b[6],a[6]=b[8],a[7]=b[9],a[8]=b[10],a},a.fromQuat=function(a,b){var c=b[0],d=b[1],f=b[2],g=b[3],h=c+c,i=d+d,j=f+f,k=c*h,l=d*h,m=d*i,n=f*h,o=f*i,p=f*j,q=g*h,r=g*i,s=g*j;return a[0]=1-m-p,a[1]=l+s,a[2]=n-r,a[3]=0,a[4]=l-s,a[5]=1-k-p,a[6]=o+q,a[7]=0,a[8]=n+r,a[9]=o-q,a[10]=1-k-m,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},a.fromRotation=function(a,b){var c=Math.sin(b),d=Math.cos(b);return a[0]=d,a[1]=c,a[2]=0,a[3]=-c,a[4]=d,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},a.fromScaling=function(a,b){return a[0]=b[0],a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=b[1],a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=b[2],a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},a.furthestTileCorner=function(a){return T[Math.round((a+45+360)%360/90)%4]},a.getAABBPointSquareDist=function(a,b,c){let d=0;for(let f=0;f<2;++f){const g=c?c[f]:0;a[f]>g&&(d+=(a[f]-g)*(a[f]-g)),b[f]<g&&(d+=(g-b[f])*(g-b[f]))}return d},a.getAnchorAlignment=jd,a.getAnchorJustification=jG,a.getBounds=function(a){let b=1/0,c=1/0,d=-1/0,f=-1/0;for(const h of a)b=Math.min(b,h.x),c=Math.min(c,h.y),d=Math.max(d,h.x),f=Math.max(f,h.y);return{min:new g(b,c),max:new g(d,f)}},a.getColumn=function(a,b){return[a[4*b],a[4*b+1],a[4*b+2],a[4*b+3],]},a.getImage=be,a.getJSON=function(a,b){return a6(aa(a,{type:"json"}),b)},a.getMapSessionAPI=aV,a.getPerformanceMeasurement=kc,a.getProjection=function(a){const b=lw[a.name];if(!b)throw Error(`Invalid projection name: ${a.name}`);return b.conic?function(a,b){if(b.parallels&&.01>Math.abs(b.parallels[0]+b.parallels[1])){let c=function(a){const b=Math.max(.01,Math.cos(a*P)),c=1/(2*Math.max(Math.PI*b,1/b));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom",],project(a,d){const f=a*P*b,g=Math.sin(d*P)/b;return{x:f*c+.5,y:-g*c+.5,z:0}},unproject(a,d){const f=-(d-.5)/c,g=X((a-.5)/c*Q/b,-180,180),h=Math.asin(X(f*b,-1,1)),i=X(h*Q,-85.051129,85.051129);return new gs(g,i)}}}(b.parallels[0]);if("lambertConformalConic"===b.name){const{project:d,unproject:f}=lw.mercator;c={wrap:!0,supportsWorldCopies:!0,project:d,unproject:f}}return aa({},a,b,c)}return aa({},a,b)}(b,a):b},a.getRTLTextPluginStatus=e_,a.getReferrer=a5,a.getTilePoint=function(a,{x:b,y:c},d=0){return new g(((b-d)*a.scale-a.x)*8192,(c*a.scale-a.y)*8192)},a.getTileVec3=function(a,b,c=0){return w(((b.x-c)*a.scale-a.x)*8192,(b.y*a.scale-a.y)*8192,gA(b.z,b.y))},a.getVideo=function(a,b){const c=i.document.createElement("video");c.muted=!0,c.onloadstart=function(){b(null,c)};for(let d=0;d<a.length;d++){const f=i.document.createElement("source");ba(a[d])||(c.crossOrigin="Anonymous"),f.src=a[d],c.appendChild(f)}return{cancel(){}}},a.globeBuffersForTileMesh=function(a,b,c,d){const f=a.context,g=a.transform;let h=b.globeGridBuffer,i=b.globePoleBuffer;if(!h){const j=lb.createGridVertices(c.canonical);h=b.globeGridBuffer=f.createVertexBuffer(j,k$,!1)}if(!i){const k=lb.createPoleTriangleVertices(d,g.tileSize*d,0===c.canonical.y);i=b.globePoleBuffer=f.createVertexBuffer(k,k$,!1)}return[h,i]},a.globeDenormalizeECEF=k9,a.globeMatrixForTile=function(a,b){var c,d;const f=k9(k4(a)),g=((c=new Float64Array(16))[0]=(d=b)[0],c[1]=d[1],c[2]=d[2],c[3]=d[3],c[4]=d[4],c[5]=d[5],c[6]=d[6],c[7]=d[7],c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15],c);return r(g,g,f),g},a.globePoleMatrixForTile=function(a,b,c){const d=l(new Float64Array(16)),f=Math.pow(2,a.z),g=(a.x-f/2)/f*Math.PI*2,h=c.point,i=c.worldSize/(c.tileSize*f);return n(d,d,[h.x,h.y,-c.worldSize/Math.PI/2,]),o(d,d,[i,i,i]),p(d,d,-c._center.lat*P),q(d,d,-c._center.lng*P),q(d,d,g),b&&o(d,d,[1,-1,1]),d},a.globeTileBounds=k4,a.globeToMercatorTransition=function(a){return Y(5,6,a)},a.identity=l,a.identity$1=M,a.invert=function(a,b){var c=b[0],d=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],p=b[12],q=b[13],r=b[14],s=b[15],u=c*i-d*h,v=c*j-f*h,w=c*k-g*h,x=d*j-f*i,y=d*k-g*i,z=f*k-g*j,A=l*q-m*p,B=l*r-n*p,C=l*s-o*p,D=m*r-n*q,E=m*s-o*q,F=n*s-o*r,G=u*F-v*E+w*D+x*C-y*B+z*A;return G?(a[0]=(i*F-j*E+k*D)*(G=1/G),a[1]=(f*E-d*F-g*D)*G,a[2]=(q*z-r*y+s*x)*G,a[3]=(n*y-m*z-o*x)*G,a[4]=(j*C-h*F-k*B)*G,a[5]=(c*F-f*C+g*B)*G,a[6]=(r*w-p*z-s*v)*G,a[7]=(l*z-n*w+o*v)*G,a[8]=(h*E-i*C+k*A)*G,a[9]=(d*C-c*E-g*A)*G,a[10]=(p*y-q*w+s*u)*G,a[11]=(m*w-l*y-o*u)*G,a[12]=(i*B-h*D-j*A)*G,a[13]=(c*D-d*B+f*A)*G,a[14]=(q*v-p*x-r*u)*G,a[15]=(l*x-m*v+n*u)*G,a):null},a.isMapAuthenticated=function(a){return aW.has(a)},a.isMapboxURL=aJ,a.latFromMercatorY=gz,a.len=v,a.length=v,a.length$1=function(a){return Math.hypot(a[0],a[1],a[2],a[3])},a.loadVectorTile=lh,a.makeRequest=a6,a.mercatorXfromLng=gv,a.mercatorYfromLat=gw,a.mercatorZfromAltitude=gx,a.mul=r,a.mul$1=z,a.multiply=function(a,b,c){var d=b[0],f=b[1],g=b[2],h=b[3],i=b[4],j=b[5],k=b[6],l=b[7],m=b[8],n=c[0],o=c[1],p=c[2],q=c[3],r=c[4],s=c[5],u=c[6],v=c[7],w=c[8];return a[0]=n*d+o*h+p*k,a[1]=n*f+o*i+p*l,a[2]=n*g+o*j+p*m,a[3]=q*d+r*h+s*k,a[4]=q*f+r*i+s*l,a[5]=q*g+r*j+s*m,a[6]=u*d+v*h+w*k,a[7]=u*f+v*i+w*l,a[8]=u*g+v*j+w*m,a},a.multiply$1=m,a.multiply$2=z,a.nextPowerOfTwo=ae,a.normalize=D,a.normalize$1=function(a,b){var c=b[0],d=b[1],f=b[2],g=b[3],h=c*c+d*d+f*f+g*g;return h>0&&(h=1/Math.sqrt(h)),a[0]=c*h,a[1]=d*h,a[2]=f*h,a[3]=g*h,a},a.number=cr,a.ortho=function(a,b,c,d,f,g,h){var i=1/(b-c),j=1/(d-f),k=1/(g-h);return a[0]=-2*i,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*j,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*k,a[11]=0,a[12]=(b+c)*i,a[13]=(f+d)*j,a[14]=(h+g)*k,a[15]=1,a},a.pbf=iG,a.perspective=function(a,b,c,d,f){var g,h=1/Math.tan(b/2);return a[0]=h/c,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=h,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=f&&f!==1/0?(a[10]=(f+d)*(g=1/(d-f)),a[14]=2*f*d*g):(a[10]=-1,a[14]=-2*d),a},a.pick=function(a,b){const c={};for(let d=0;d<b.length;d++){const f=b[d];f in a&&(c[f]=a[f])}return c},a.plugin=e1,a.pointGeometry=g,a.polygonIntersectsBox=gT,a.polygonIntersectsPolygon=gJ,a.polygonizeBounds=function(a,b,c=0,d=!0){const f=new g(c,c),h=a.sub(f),i=b.add(f),j=[h,new g(i.x,h.y),i,new g(h.x,i.y),];return d&&j.push(h),j},a.posAttributes=kE,a.postMapLoadEvent=aT,a.postTurnstileEvent=aR,a.potpack=i$,a.prevPowerOfTwo=function(a){return a<=1?1:Math.pow(2,Math.floor(Math.log(a)/Math.LN2))},a.radToDeg=S,a.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout",],a.registerForPluginStateChange=function(a){return a({pluginStatus:eW,pluginURL:eX}),e$.on("pluginStateChange",a),a},a.removeAuthState=function(a){aW.delete(a)},a.renderColorRamp=hd,a.rotateX=p,a.rotateX$1=N,a.rotateY=q,a.rotateZ=function(a,b,c){var d=Math.sin(c),f=Math.cos(c),g=b[0],h=b[1],i=b[2],j=b[3],k=b[4],l=b[5],m=b[6],n=b[7];return b!==a&&(a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=g*f+k*d,a[1]=h*f+l*d,a[2]=i*f+m*d,a[3]=j*f+n*d,a[4]=k*f-g*d,a[5]=l*f-h*d,a[6]=m*f-i*d,a[7]=n*f-j*d,a},a.rotateZ$1=function(a,b,c){c*=.5;var d=b[0],f=b[1],g=b[2],h=b[3],i=Math.sin(c),j=Math.cos(c);return a[0]=d*j+f*i,a[1]=f*j-d*i,a[2]=g*j+h*i,a[3]=h*j-g*i,a},a.scale=o,a.scale$1=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a},a.scale$2=B,a.scaleAndAdd=C,a.setCacheLimits=function(a,b){a$=a,a_=b},a.setColumn=function(a,b,c){a[4*b+0]=c[0],a[4*b+1]=c[1],a[4*b+2]=c[2],a[4*b+3]=c[3]},a.setRTLTextPlugin=function(a,b,c=!1){if(eW===eS||eW===eT||eW===eU)throw Error("setRTLTextPlugin cannot be called multiple times.");eX=ax.resolveURL(a),eW=eS,eV=b,eZ(),c||e0()},a.smoothstep=Y,a.spec=bk,a.storeAuthState=function(a,b){b?aW.add(a):aW.delete(a)},a.sub=J,a.subtract=y,a.symbolSize=iz,a.tileAABB=function(a,b,c,d,f,g,h,i,j){var k,l,m;if("globe"===j.name){const n=k4(new kf(g,new ke(c,d,f)).canonical).getCorners(),o=Number.MAX_VALUE,p=[-o,-o,-o],q=[o,o,o],r=la(a,b);for(let s=0;s<n.length;s++)G(n[s],n[s],r),l=q,m=n[s],(k=q)[0]=Math.min(l[0],m[0]),k[1]=Math.min(l[1],m[1]),k[2]=Math.min(l[2],m[2]),A(p,p,n[s]);return new g0(q,p)}const u=lc({z:c,x:d,y:f},j);return new g0([(g+u.x/u.scale)*b,b*(u.y/u.scale),h,],[(g+u.x2/u.scale)*b,b*(u.y2/u.scale),i,])},a.tileTransform=lc,a.transformMat3=function(a,b,c){var d=b[0],f=b[1],g=b[2];return a[0]=d*c[0]+f*c[3]+g*c[6],a[1]=d*c[1]+f*c[4]+g*c[7],a[2]=d*c[2]+f*c[5]+g*c[8],a},a.transformMat4=G,a.transformMat4$1=K,a.transformQuat=H,a.translate=n,a.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],f=b[5];a[1]=b[3],a[2]=b[6],a[3]=c,a[5]=b[7],a[6]=d,a[7]=f}else a[0]=b[0],a[1]=b[3],a[2]=b[6],a[3]=b[1],a[4]=b[4],a[5]=b[7],a[6]=b[2],a[7]=b[5],a[8]=b[8];return a},a.triggerPluginCompletionEvent=eY,a.uniqueId=ac,a.validateCustomStyleLayer=function(a){const b=[],c=a.id;return void 0===c&&b.push({message:`layers.${c}: missing required property "id"`}),void 0===a.render&&b.push({message:`layers.${c}: missing required method "render"`}),a.renderingMode&&"2d"!==a.renderingMode&&"3d"!==a.renderingMode&&b.push({message:`layers.${c}: property "renderingMode" must be either "2d" or "3d"`}),b},a.validateFog=d3,a.validateLight=d2,a.validateStyle=d1,a.values=_,a.vectorTile=h2,a.version=b,a.warnOnce=am,a.window=i,a.wrap=Z}),f(["./shared"],function(a){function b(a){const c=typeof a;if("number"===c||"boolean"===c||"string"===c||null==a)return JSON.stringify(a);if(Array.isArray(a)){let d="[";for(const f of a)d+=`${b(f)},`;return`${d}]`}const g=Object.keys(a).sort();let h="{";for(let i=0;i<g.length;i++)h+=`${JSON.stringify(g[i])}:${b(a[g[i]])},`;return`${h}}`}function c(c){let d="";for(const f of a.refProperties)d+=`/${b(c[f])}`;return d}class d{constructor(a){this.keyCache={},a&&this.replace(a)}replace(a){this._layerConfigs={},this._layers={},this.update(a,[])}update(b,d){for(const f of b)this._layerConfigs[f.id]=f,(this._layers[f.id]=a.createStyleLayer(f)).compileFilter(),this.keyCache[f.id]&&delete this.keyCache[f.id];for(const g of d)delete this.keyCache[g],delete this._layerConfigs[g],delete this._layers[g];this.familiesBySource={};const h=function(a,b){const d={};for(let f=0;f<a.length;f++){const g=b&&b[a[f].id]||c(a[f]);b&&(b[a[f].id]=g);let h=d[g];h||(h=d[g]=[]),h.push(a[f])}const i=[];for(const j in d)i.push(d[j]);return i}(a.values(this._layerConfigs),this.keyCache);for(const i of h){const j=i.map(a=>this._layers[a.id]),k=j[0];if("none"===k.visibility)continue;const l=k.source||"";let m=this.familiesBySource[l];m||(m=this.familiesBySource[l]={});const n=k.sourceLayer||"_geojsonTileLayer";let o=m[n];o||(o=m[n]=[]),o.push(j)}}}const{ImageBitmap:f}=a.window;class g{loadTile(b,c){const{uid:d,encoding:g,rawImageData:h,padding:i,buildQuadTree:j}=b,k=f&&h instanceof f?this.getImageData(h,i):h;c(null,new a.DEMData(d,k,g,i<1,j))}getImageData(b,c){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(b.width,b.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=b.width,this.offscreenCanvas.height=b.height,this.offscreenCanvasContext.drawImage(b,0,0,b.width,b.height);const d=this.offscreenCanvasContext.getImageData(-c,-c,b.width+2*c,b.height+2*c);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new a.RGBAImage({width:d.width,height:d.height},d.data)}}var h,i=function a(b,c){var d,f=b&&b.type;if("FeatureCollection"===f)for(d=0;d<b.features.length;d++)a(b.features[d],c);else if("GeometryCollection"===f)for(d=0;d<b.geometries.length;d++)a(b.geometries[d],c);else if("Feature"===f)a(b.geometry,c);else if("Polygon"===f)j(b.coordinates,c);else if("MultiPolygon"===f)for(d=0;d<b.coordinates.length;d++)j(b.coordinates[d],c);return b};function j(a,b){if(0!==a.length){k(a[0],b);for(var c=1;c<a.length;c++)k(a[c],!b)}}function k(a,b){for(var c=0,d=0,f=0,g=a.length,h=g-1;f<g;h=f++){var i=(a[f][0]-a[h][0])*(a[h][1]+a[f][1]),j=c+i;d+=Math.abs(c)>=Math.abs(i)?c-j+i:i-j+c,c=j}c+d>=0!= !!b&&a.reverse()}const l=a.vectorTile.VectorTileFeature.prototype.toGeoJSON;class m{constructor(b){this._feature=b,this.extent=a.EXTENT,this.type=b.type,this.properties=b.tags,"id"in b&&!isNaN(b.id)&&(this.id=parseInt(b.id,10))}loadGeometry(){if(1===this._feature.type){const b=[];for(const c of this._feature.geometry)b.push([new a.pointGeometry(c[0],c[1]),]);return b}{const d=[];for(const f of this._feature.geometry){const g=[];for(const h of f)g.push(new a.pointGeometry(h[0],h[1]));d.push(g)}return d}}toGeoJSON(a,b,c){return l.call(this,a,b,c)}}class n{constructor(b){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=b.length,this._features=b}feature(a){return new m(this._features[a])}}var o=a.vectorTile.VectorTileFeature,p=q;function q(a,b){this.options=b||{},this.features=a,this.length=a.length}function r(a,b){this.id="number"==typeof a.id?a.id:void 0,this.type=a.type,this.rawGeometry=1===a.type?[a.geometry]:a.geometry,this.properties=a.tags,this.extent=b||4096}q.prototype.feature=function(a){return new r(this.features[a],this.options.extent)},r.prototype.loadGeometry=function(){var b=this.rawGeometry;this.geometry=[];for(var c=0;c<b.length;c++){for(var d=b[c],f=[],g=0;g<d.length;g++)f.push(new a.pointGeometry(d[g][0],d[g][1]));this.geometry.push(f)}return this.geometry},r.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var a=this.geometry,b=1/0,c=-1/0,d=1/0,f=-1/0,g=0;g<a.length;g++)for(var h=a[g],i=0;i<h.length;i++){var j=h[i];b=Math.min(b,j.x),c=Math.max(c,j.x),d=Math.min(d,j.y),f=Math.max(f,j.y)}return[b,d,c,f]},r.prototype.toGeoJSON=o.prototype.toGeoJSON;var s=u;function u(b){var c=new a.pbf;return function(a,b){for(var c in a.layers)b.writeMessage(3,v,a.layers[c])}(b,c),c.finish()}function v(a,b){b.writeVarintField(15,a.version||1),b.writeStringField(1,a.name||""),b.writeVarintField(5,a.extent||4096);var c,d={keys:[],values:[],keycache:{},valuecache:{}};for(c=0;c<a.length;c++)d.feature=a.feature(c),b.writeMessage(2,w,d);var f=d.keys;for(c=0;c<f.length;c++)b.writeStringField(3,f[c]);var g=d.values;for(c=0;c<g.length;c++)b.writeMessage(4,B,g[c])}function w(a,b){var c=a.feature;void 0!==c.id&&b.writeVarintField(1,c.id),b.writeMessage(2,x,a),b.writeVarintField(3,c.type),b.writeMessage(4,A,c)}function x(a,b){var c=a.feature,d=a.keys,f=a.values,g=a.keycache,h=a.valuecache;for(var i in c.properties){var j=c.properties[i],k=g[i];if(null!==j){void 0===k&&(d.push(i),g[i]=k=d.length-1),b.writeVarint(k);var l=typeof j;"string"!==l&&"boolean"!==l&&"number"!==l&&(j=JSON.stringify(j));var m=l+":"+j,n=h[m];void 0===n&&(f.push(j),h[m]=n=f.length-1),b.writeVarint(n)}}}function y(a,b){return(b<<3)+(7&a)}function z(a){return a<<1^a>>31}function A(a,b){for(var c=a.loadGeometry(),d=a.type,f=0,g=0,h=c.length,i=0;i<h;i++){var j=c[i],k=1;1===d&&(k=j.length),b.writeVarint(y(1,k));for(var l=3===d?j.length-1:j.length,m=0;m<l;m++){1===m&&1!==d&&b.writeVarint(y(2,l-1));var n=j[m].x-f,o=j[m].y-g;b.writeVarint(z(n)),b.writeVarint(z(o)),f+=n,g+=o}3===d&&b.writeVarint(y(7,1))}}function B(a,b){var c=typeof a;"string"===c?b.writeStringField(1,a):"boolean"===c?b.writeBooleanField(7,a):"number"===c&&(a%1!=0?b.writeDoubleField(3,a):a<0?b.writeSVarintField(6,a):b.writeVarintField(5,a))}function C(a,b,c,d,f,g){if(f-d<=c)return;const h=d+f>>1;D(a,b,h,d,f,g%2),C(a,b,c,d,h-1,g+1),C(a,b,c,h+1,f,g+1)}function D(a,b,c,d,f,g){for(;f>d;){if(f-d>600){const h=f-d+1,i=c-d+1,j=Math.log(h),k=.5*Math.exp(2*j/3),l=.5*Math.sqrt(j*k*(h-k)/h)*(i-h/2<0?-1:1);D(a,b,c,Math.max(d,Math.floor(c-i*k/h+l)),Math.min(f,Math.floor(c+(h-i)*k/h+l)),g)}const m=b[2*c+g];let n=d,o=f;for(E(a,b,d,c),b[2*f+g]>m&&E(a,b,d,f);n<o;){for(E(a,b,n,o),n++,o--;b[2*n+g]<m;)n++;for(;b[2*o+g]>m;)o--}b[2*d+g]===m?E(a,b,d,o):E(a,b,++o,f),o<=c&&(d=o+1),c<=o&&(f=o-1)}}function E(a,b,c,d){F(a,c,d),F(b,2*c,2*d),F(b,2*c+1,2*d+1)}function F(a,b,c){const d=a[b];a[b]=a[c],a[c]=d}function G(a,b,c,d){const f=a-c,g=b-d;return f*f+g*g}s.fromVectorTileJs=u,s.fromGeojsonVt=function(a,b){b=b||{};var c={};for(var d in a)c[d]=new p(a[d].features,b),c[d].name=d,c[d].version=b.version,c[d].extent=b.extent;return u({layers:c})},s.GeoJSONWrapper=p;class H{constructor(a,b=a=>a[0],c=a=>a[1],d=64,f=Float64Array){this.nodeSize=d,this.points=a;const g=a.length<65536?Uint16Array:Uint32Array,h=this.ids=new g(a.length),i=this.coords=new f(2*a.length);for(let j=0;j<a.length;j++)h[j]=j,i[2*j]=b(a[j]),i[2*j+1]=c(a[j]);C(h,i,d,0,h.length-1,0)}range(a,b,c,d){return function(a,b,c,d,f,g,h){const i=[0,a.length-1,0],j=[];let k,l;for(;i.length;){const m=i.pop(),n=i.pop(),o=i.pop();if(n-o<=h){for(let p=o;p<=n;p++)k=b[2*p],l=b[2*p+1],k>=c&&k<=f&&l>=d&&l<=g&&j.push(a[p]);continue}const q=Math.floor((o+n)/2);k=b[2*q],l=b[2*q+1],k>=c&&k<=f&&l>=d&&l<=g&&j.push(a[q]);const r=(m+1)%2;(0===m?c<=k:d<=l)&&(i.push(o),i.push(q-1),i.push(r)),(0===m?f>=k:g>=l)&&(i.push(q+1),i.push(n),i.push(r))}return j}(this.ids,this.coords,a,b,c,d,this.nodeSize)}within(a,b,c){return function(a,b,c,d,f,g){const h=[0,a.length-1,0],i=[],j=f*f;for(;h.length;){const k=h.pop(),l=h.pop(),m=h.pop();if(l-m<=g){for(let n=m;n<=l;n++)G(b[2*n],b[2*n+1],c,d)<=j&&i.push(a[n]);continue}const o=Math.floor((m+l)/2),p=b[2*o],q=b[2*o+1];G(p,q,c,d)<=j&&i.push(a[o]);const r=(k+1)%2;(0===k?c-f<=p:d-f<=q)&&(h.push(m),h.push(o-1),h.push(r)),(0===k?c+f>=p:d+f>=q)&&(h.push(o+1),h.push(l),h.push(r))}return i}(this.ids,this.coords,a,b,c,this.nodeSize)}}const I=Math.fround||(h=new Float32Array(1),a=>(h[0]=+a,h[0]));class J{constructor(a){this.options=R(Object.create({minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:a=>a}),a),this.trees=Array(this.options.maxZoom+1)}load(a){const{log:b,minZoom:c,maxZoom:d,nodeSize:f}=this.options;b&&console.time("total time");const g=`prepare ${a.length} points`;b&&console.time(g),this.points=a;let h=[];for(let i=0;i<a.length;i++)a[i].geometry&&h.push(L(a[i],i));this.trees[d+1]=new H(h,S,T,f,Float32Array),b&&console.timeEnd(g);for(let j=d;j>=c;j--){const k=+Date.now();h=this._cluster(h,j),this.trees[j]=new H(h,S,T,f,Float32Array),b&&console.log("z%d: %d clusters in %dms",j,h.length,+Date.now()-k)}return b&&console.timeEnd("total time"),this}getClusters(a,b){let c=((a[0]+180)%360+360)%360-180;const d=Math.max(-90,Math.min(90,a[1]));let f=180===a[2]?180:((a[2]+180)%360+360)%360-180;const g=Math.max(-90,Math.min(90,a[3]));if(a[2]-a[0]>=360)c=-180,f=180;else if(c>f){const h=this.getClusters([c,d,180,g],b),i=this.getClusters([-180,d,f,g],b);return h.concat(i)}const j=this.trees[this._limitZoom(b)],k=j.range(O(c),P(g),O(f),P(d)),l=[];for(const m of k){const n=j.points[m];l.push(n.numPoints?M(n):this.points[n.index])}return l}getChildren(a){const b=this._getOriginId(a),c=this._getOriginZoom(a),d="No cluster with the specified id.",f=this.trees[c];if(!f)throw Error(d);const g=f.points[b];if(!g)throw Error(d);const h=this.options.radius/(this.options.extent*Math.pow(2,c-1)),i=f.within(g.x,g.y,h),j=[];for(const k of i){const l=f.points[k];l.parentId===a&&j.push(l.numPoints?M(l):this.points[l.index])}if(0===j.length)throw Error(d);return j}getLeaves(a,b,c){const d=[];return this._appendLeaves(d,a,b=b||10,c=c||0,0),d}getTile(a,b,c){const d=this.trees[this._limitZoom(a)],f=Math.pow(2,a),{extent:g,radius:h}=this.options,i=h/g,j=(c-i)/f,k=(c+1+i)/f,l={features:[]};return this._addTileFeatures(d.range((b-i)/f,j,(b+1+i)/f,k),d.points,b,c,f,l),0===b&&this._addTileFeatures(d.range(1-i/f,j,1,k),d.points,f,c,f,l),b===f-1&&this._addTileFeatures(d.range(0,j,i/f,k),d.points,-1,c,f,l),l.features.length?l:null}getClusterExpansionZoom(a){let b=this._getOriginZoom(a)-1;for(;b<=this.options.maxZoom;){const c=this.getChildren(a);if(b++,1!==c.length)break;a=c[0].properties.cluster_id}return b}_appendLeaves(a,b,c,d,f){const g=this.getChildren(b);for(const h of g){const i=h.properties;if(i&&i.cluster?f+i.point_count<=d?f+=i.point_count:f=this._appendLeaves(a,i.cluster_id,c,d,f):f<d?f++:a.push(h),a.length===c)break}return f}_addTileFeatures(a,b,c,d,f,g){for(const h of a){const i=b[h],j=i.numPoints;let k,l,m;if(j)k=N(i),l=i.x,m=i.y;else{const n=this.points[i.index];k=n.properties,l=O(n.geometry.coordinates[0]),m=P(n.geometry.coordinates[1])}const o={type:1,geometry:[[Math.round(this.options.extent*(l*f-c)),Math.round(this.options.extent*(m*f-d)),],],tags:k};let p;j?p=i.id:this.options.generateId?p=i.index:this.points[i.index].id&&(p=this.points[i.index].id),void 0!==p&&(o.id=p),g.features.push(o)}}_limitZoom(a){return Math.max(this.options.minZoom,Math.min(+a,this.options.maxZoom+1))}_cluster(a,b){const c=[],{radius:d,extent:f,reduce:g,minPoints:h}=this.options,i=d/(f*Math.pow(2,b));for(let j=0;j<a.length;j++){const k=a[j];if(k.zoom<=b)continue;k.zoom=b;const l=this.trees[b+1],m=l.within(k.x,k.y,i),n=k.numPoints||1;let o=n;for(const p of m){const q=l.points[p];q.zoom>b&&(o+=q.numPoints||1)}if(o>n&&o>=h){let r=k.x*n,s=k.y*n,u=g&&n>1?this._map(k,!0):null;const v=(j<<5)+(b+1)+this.points.length;for(const w of m){const x=l.points[w];if(x.zoom<=b)continue;x.zoom=b;const y=x.numPoints||1;r+=x.x*y,s+=x.y*y,x.parentId=v,g&&(u||(u=this._map(k,!0)),g(u,this._map(x)))}k.parentId=v,c.push(K(r/o,s/o,v,o,u))}else if(c.push(k),o>1)for(const z of m){const A=l.points[z];A.zoom<=b||(A.zoom=b,c.push(A))}}return c}_getOriginId(a){return a-this.points.length>>5}_getOriginZoom(a){return(a-this.points.length)%32}_map(a,b){if(a.numPoints)return b?R({},a.properties):a.properties;const c=this.points[a.index].properties,d=this.options.map(c);return b&&d===c?R({},d):d}}function K(a,b,c,d,f){return{x:I(a),y:I(b),zoom:1/0,id:c,parentId:-1,numPoints:d,properties:f}}function L(a,b){const[c,d]=a.geometry.coordinates;return{x:I(O(c)),y:I(P(d)),zoom:1/0,index:b,parentId:-1}}function M(a){return{type:"Feature",id:a.id,properties:N(a),geometry:{type:"Point",coordinates:[360*(a.x-.5),Q(a.y),]}}}function N(a){const b=a.numPoints,c=b>=1e4?`${Math.round(b/1e3)}k`:b>=1e3?Math.round(b/100)/10+"k":b;return R(R({},a.properties),{cluster:!0,cluster_id:a.id,point_count:b,point_count_abbreviated:c})}function O(a){return a/360+.5}function P(a){const b=Math.sin(a*Math.PI/180),c=.5-.25*Math.log((1+b)/(1-b))/Math.PI;return c<0?0:c>1?1:c}function Q(a){return 360*Math.atan(Math.exp((180-360*a)*Math.PI/180))/Math.PI-90}function R(a,b){for(const c in b)a[c]=b[c];return a}function S(a){return a.x}function T(a){return a.y}function U(a,b,c,d){for(var f,g=d,h=c-b>>1,i=c-b,j=a[b],k=a[b+1],l=a[c],m=a[c+1],n=b+3;n<c;n+=3){var o=V(a[n],a[n+1],j,k,l,m);if(o>g)f=n,g=o;else if(o===g){var p=Math.abs(n-h);p<i&&(f=n,i=p)}}g>d&&(f-b>3&&U(a,b,f,d),a[f+2]=g,c-f>3&&U(a,f,c,d))}function V(a,b,c,d,f,g){var h=f-c,i=g-d;if(0!==h||0!==i){var j=((a-c)*h+(b-d)*i)/(h*h+i*i);j>1?(c=f,d=g):j>0&&(c+=h*j,d+=i*j)}return(h=a-c)*h+(i=b-d)*i}function W(a,b,c,d){var f={id:void 0===a?null:a,type:b,geometry:c,tags:d,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(a){var b=a.geometry,c=a.type;if("Point"===c||"MultiPoint"===c||"LineString"===c)X(a,b);else if("Polygon"===c||"MultiLineString"===c)for(var d=0;d<b.length;d++)X(a,b[d]);else if("MultiPolygon"===c)for(d=0;d<b.length;d++)for(var f=0;f<b[d].length;f++)X(a,b[d][f])}(f),f}function X(a,b){for(var c=0;c<b.length;c+=3)a.minX=Math.min(a.minX,b[c]),a.minY=Math.min(a.minY,b[c+1]),a.maxX=Math.max(a.maxX,b[c]),a.maxY=Math.max(a.maxY,b[c+1])}function Y(a,b,c,d){if(b.geometry){var f=b.geometry.coordinates,g=b.geometry.type,h=Math.pow(c.tolerance/((1<<c.maxZoom)*c.extent),2),i=[],j=b.id;if(c.promoteId?j=b.properties[c.promoteId]:c.generateId&&(j=d||0),"Point"===g)Z(f,i);else if("MultiPoint"===g)for(var k=0;k<f.length;k++)Z(f[k],i);else if("LineString"===g)$(f,i,h,!1);else if("MultiLineString"===g){if(c.lineMetrics){for(k=0;k<f.length;k++)$(f[k],i=[],h,!1),a.push(W(j,"LineString",i,b.properties));return}_(f,i,h,!1)}else if("Polygon"===g)_(f,i,h,!0);else{if("MultiPolygon"!==g){if("GeometryCollection"===g){for(k=0;k<b.geometry.geometries.length;k++)Y(a,{id:j,geometry:b.geometry.geometries[k],properties:b.properties},c,d);return}throw Error("Input data is not a valid GeoJSON object.")}for(k=0;k<f.length;k++){var l=[];_(f[k],l,h,!0),i.push(l)}}a.push(W(j,g,i,b.properties))}}function Z(a,b){b.push(aa(a[0])),b.push(ab(a[1])),b.push(0)}function $(a,b,c,d){for(var f,g,h=0,i=0;i<a.length;i++){var j=aa(a[i][0]),k=ab(a[i][1]);b.push(j),b.push(k),b.push(0),i>0&&(h+=d?(f*k-j*g)/2:Math.sqrt(Math.pow(j-f,2)+Math.pow(k-g,2))),f=j,g=k}var l=b.length-3;b[2]=1,U(b,0,l,c),b[l+2]=1,b.size=Math.abs(h),b.start=0,b.end=b.size}function _(a,b,c,d){for(var f=0;f<a.length;f++){var g=[];$(a[f],g,c,d),b.push(g)}}function aa(a){return a/360+.5}function ab(a){var b=Math.sin(a*Math.PI/180),c=.5-.25*Math.log((1+b)/(1-b))/Math.PI;return c<0?0:c>1?1:c}function ac(a,b,c,d,f,g,h,i){if(d/=b,g>=(c/=b)&&h<d)return a;if(h<c||g>=d)return null;for(var j=[],k=0;k<a.length;k++){var l=a[k],m=l.geometry,n=l.type,o=0===f?l.minX:l.minY,p=0===f?l.maxX:l.maxY;if(o>=c&&p<d)j.push(l);else if(!(p<c||o>=d)){var q=[];if("Point"===n||"MultiPoint"===n)ad(m,q,c,d,f);else if("LineString"===n)ae(m,q,c,d,f,!1,i.lineMetrics);else if("MultiLineString"===n)ag(m,q,c,d,f,!1);else if("Polygon"===n)ag(m,q,c,d,f,!0);else if("MultiPolygon"===n)for(var r=0;r<m.length;r++){var s=[];ag(m[r],s,c,d,f,!0),s.length&&q.push(s)}if(q.length){if(i.lineMetrics&&"LineString"===n){for(r=0;r<q.length;r++)j.push(W(l.id,n,q[r],l.tags));continue}"LineString"!==n&&"MultiLineString"!==n||(1===q.length?(n="LineString",q=q[0]):n="MultiLineString"),"Point"!==n&&"MultiPoint"!==n||(n=3===q.length?"Point":"MultiPoint"),j.push(W(l.id,n,q,l.tags))}}}return j.length?j:null}function ad(a,b,c,d,f){for(var g=0;g<a.length;g+=3){var h=a[g+f];h>=c&&h<=d&&(b.push(a[g]),b.push(a[g+1]),b.push(a[g+2]))}}function ae(a,b,c,d,f,g,h){for(var i,j,k=af(a),l=0===f?ai:aj,m=a.start,n=0;n<a.length-3;n+=3){var o=a[n],p=a[n+1],q=a[n+2],r=a[n+3],s=a[n+4],u=0===f?o:p,v=0===f?r:s,w=!1;h&&(i=Math.sqrt(Math.pow(o-r,2)+Math.pow(p-s,2))),u<c?v>c&&(j=l(k,o,p,r,s,c),h&&(k.start=m+i*j)):u>d?v<d&&(j=l(k,o,p,r,s,d),h&&(k.start=m+i*j)):ah(k,o,p,q),v<c&&u>=c&&(j=l(k,o,p,r,s,c),w=!0),v>d&&u<=d&&(j=l(k,o,p,r,s,d),w=!0),!g&&w&&(h&&(k.end=m+i*j),b.push(k),k=af(a)),h&&(m+=i)}var x=a.length-3;o=a[x],p=a[x+1],q=a[x+2],(u=0===f?o:p)>=c&&u<=d&&ah(k,o,p,q),x=k.length-3,g&&x>=3&&(k[x]!==k[0]||k[x+1]!==k[1])&&ah(k,k[0],k[1],k[2]),k.length&&b.push(k)}function af(a){var b=[];return b.size=a.size,b.start=a.start,b.end=a.end,b}function ag(a,b,c,d,f,g){for(var h=0;h<a.length;h++)ae(a[h],b,c,d,f,g,!1)}function ah(a,b,c,d){a.push(b),a.push(c),a.push(d)}function ai(a,b,c,d,f,g){var h=(g-b)/(d-b);return a.push(g),a.push(c+(f-c)*h),a.push(1),h}function aj(a,b,c,d,f,g){var h=(g-c)/(f-c);return a.push(b+(d-b)*h),a.push(g),a.push(1),h}function ak(a,b){for(var c=[],d=0;d<a.length;d++){var f,g=a[d],h=g.type;if("Point"===h||"MultiPoint"===h||"LineString"===h)f=al(g.geometry,b);else if("MultiLineString"===h||"Polygon"===h){f=[];for(var i=0;i<g.geometry.length;i++)f.push(al(g.geometry[i],b))}else if("MultiPolygon"===h)for(f=[],i=0;i<g.geometry.length;i++){for(var j=[],k=0;k<g.geometry[i].length;k++)j.push(al(g.geometry[i][k],b));f.push(j)}c.push(W(g.id,h,f,g.tags))}return c}function al(a,b){var c=[];c.size=a.size,void 0!==a.start&&(c.start=a.start,c.end=a.end);for(var d=0;d<a.length;d+=3)c.push(a[d]+b,a[d+1],a[d+2]);return c}function am(a,b){if(a.transformed)return a;var c,d,f,g=1<<a.z,h=a.x,i=a.y;for(c=0;c<a.features.length;c++){var j=a.features[c],k=j.geometry,l=j.type;if(j.geometry=[],1===l)for(d=0;d<k.length;d+=2)j.geometry.push(an(k[d],k[d+1],b,g,h,i));else for(d=0;d<k.length;d++){var m=[];for(f=0;f<k[d].length;f+=2)m.push(an(k[d][f],k[d][f+1],b,g,h,i));j.geometry.push(m)}}return a.transformed=!0,a}function an(a,b,c,d,f,g){return[Math.round(c*(a*d-f)),Math.round(c*(b*d-g)),]}function ao(a,b,c,d,f){for(var g=b===f.maxZoom?0:f.tolerance/((1<<b)*f.extent),h={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:c,y:d,z:b,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},i=0;i<a.length;i++){h.numFeatures++,ap(h,a[i],g,f);var j=a[i].minX,k=a[i].minY,l=a[i].maxX,m=a[i].maxY;j<h.minX&&(h.minX=j),k<h.minY&&(h.minY=k),l>h.maxX&&(h.maxX=l),m>h.maxY&&(h.maxY=m)}return h}function ap(a,b,c,d){var f=b.geometry,g=b.type,h=[];if("Point"===g||"MultiPoint"===g)for(var i=0;i<f.length;i+=3)h.push(f[i]),h.push(f[i+1]),a.numPoints++,a.numSimplified++;else if("LineString"===g)aq(h,f,a,c,!1,!1);else if("MultiLineString"===g||"Polygon"===g)for(i=0;i<f.length;i++)aq(h,f[i],a,c,"Polygon"===g,0===i);else if("MultiPolygon"===g)for(var j=0;j<f.length;j++){var k=f[j];for(i=0;i<k.length;i++)aq(h,k[i],a,c,!0,0===i)}if(h.length){var l=b.tags||null;if("LineString"===g&&d.lineMetrics){for(var m in l={},b.tags)l[m]=b.tags[m];l.mapbox_clip_start=f.start/f.size,l.mapbox_clip_end=f.end/f.size}var n={geometry:h,type:"Polygon"===g||"MultiPolygon"===g?3:"LineString"===g||"MultiLineString"===g?2:1,tags:l};null!==b.id&&(n.id=b.id),a.features.push(n)}}function aq(a,b,c,d,f,g){var h=d*d;if(d>0&&b.size<(f?h:d))c.numPoints+=b.length/3;else{for(var i=[],j=0;j<b.length;j+=3)(0===d||b[j+2]>h)&&(c.numSimplified++,i.push(b[j]),i.push(b[j+1])),c.numPoints++;f&&function(a,b){for(var c=0,d=0,f=a.length,g=f-2;d<f;g=d,d+=2)c+=(a[d]-a[g])*(a[d+1]+a[g+1]);if(c>0===b)for(d=0,f=a.length;d<f/2;d+=2){var h=a[d],i=a[d+1];a[d]=a[f-2-d],a[d+1]=a[f-1-d],a[f-2-d]=h,a[f-1-d]=i}}(i,g),a.push(i)}}function ar(a,b){var c=(b=this.options=function(a,b){for(var c in b)a[c]=b[c];return a}(Object.create(this.options),b)).debug;if(c&&console.time("preprocess data"),b.maxZoom<0||b.maxZoom>24)throw Error("maxZoom should be in the 0-24 range");if(b.promoteId&&b.generateId)throw Error("promoteId and generateId cannot be used together.");var d,f,g,h,i,j,k=function(a,b){var c=[];if("FeatureCollection"===a.type)for(var d=0;d<a.features.length;d++)Y(c,a.features[d],b,d);else Y(c,"Feature"===a.type?a:{geometry:a},b);return c}(a,b);this.tiles={},this.tileCoords=[],c&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",b.indexMaxZoom,b.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(k=(d=k,g=(f=b).buffer/f.extent,h=d,i=ac(d,1,-1-g,g,0,-1,2,f),j=ac(d,1,1-g,2+g,0,-1,2,f),(i||j)&&(h=ac(d,1,-g,1+g,0,-1,2,f)||[],i&&(h=ak(i,1).concat(h)),j&&(h=h.concat(ak(j,-1)))),h)).length&&this.splitTile(k,0,0,0),c&&(k.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 as(a,b,c){return 32*((1<<a)*c+b)+a}ar.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},ar.prototype.splitTile=function(a,b,c,d,f,g,h){for(var i=[a,b,c,d],j=this.options,k=j.debug;i.length;){d=i.pop(),c=i.pop(),b=i.pop(),a=i.pop();var l=1<<b,m=as(b,c,d),n=this.tiles[m];if(!n&&(k>1&&console.time("creation"),n=this.tiles[m]=ao(a,b,c,d,j),this.tileCoords.push({z:b,x:c,y:d}),k)){k>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",b,c,d,n.numFeatures,n.numPoints,n.numSimplified),console.timeEnd("creation"));var o="z"+b;this.stats[o]=(this.stats[o]||0)+1,this.total++}if(n.source=a,f){if(b===j.maxZoom||b===f)continue;var p=1<<f-b;if(c!==Math.floor(g/p)||d!==Math.floor(h/p))continue}else if(b===j.indexMaxZoom||n.numPoints<=j.indexMaxPoints)continue;if(n.source=null,0!==a.length){k>1&&console.time("clipping");var q,r,s,u,v,w,x=.5*j.buffer/j.extent,y=.5-x,z=.5+x,A=1+x;q=r=s=u=null,v=ac(a,l,c-x,c+z,0,n.minX,n.maxX,j),w=ac(a,l,c+y,c+A,0,n.minX,n.maxX,j),a=null,v&&(q=ac(v,l,d-x,d+z,1,n.minY,n.maxY,j),r=ac(v,l,d+y,d+A,1,n.minY,n.maxY,j),v=null),w&&(s=ac(w,l,d-x,d+z,1,n.minY,n.maxY,j),u=ac(w,l,d+y,d+A,1,n.minY,n.maxY,j),w=null),k>1&&console.timeEnd("clipping"),i.push(q||[],b+1,2*c,2*d),i.push(r||[],b+1,2*c,2*d+1),i.push(s||[],b+1,2*c+1,2*d),i.push(u||[],b+1,2*c+1,2*d+1)}}},ar.prototype.getTile=function(a,b,c){var d=this.options,f=d.extent,g=d.debug;if(a<0||a>24)return null;var h=1<<a,i=as(a,b=(b%h+h)%h,c);if(this.tiles[i])return am(this.tiles[i],f);g>1&&console.log("drilling down to z%d-%d-%d",a,b,c);for(var j,k=a,l=b,m=c;!j&&k>0;)k--,l=Math.floor(l/2),m=Math.floor(m/2),j=this.tiles[as(k,l,m)];return j&&j.source?(g>1&&console.log("found parent tile z%d-%d-%d",k,l,m),g>1&&console.time("drilling down"),this.splitTile(j.source,k,l,m,a,b,c),g>1&&console.timeEnd("drilling down"),this.tiles[i]?am(this.tiles[i],f):null):null};class at extends a.VectorTileWorkerSource{constructor(a,b,c,d,f){super(a,b,c,d,function(a,b){const c=a.tileID.canonical;if(!this._geoJSONIndex)return b(null,null);const d=this._geoJSONIndex.getTile(c.z,c.x,c.y);if(!d)return b(null,null);const f=new n(d.features);let g=s(f);0===g.byteOffset&&g.byteLength===g.buffer.byteLength||(g=new Uint8Array(g)),b(null,{vectorTile:f,rawData:g.buffer})}),f&&(this.loadGeoJSON=f)}loadData(b,c){const d=b&&b.request,f=d&&d.collectResourceTiming;this.loadGeoJSON(b,(g,h)=>{if(g||!h)return c(g);if("object"!=typeof h)return c(Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));{i(h,!0);try{var j,k;if(b.filter){const l=a.createExpression(b.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===l.result)throw Error(l.value.map(a=>`${a.key}: ${a.message}`).join(", "));const m=h.features.filter(a=>l.value.evaluate({zoom:0},a));h={type:"FeatureCollection",features:m}}this._geoJSONIndex=b.cluster?new J(function({superclusterOptions:b,clusterProperties:c}){if(!c||!b)return b;const d={},f={},g={accumulated:null,zoom:0},h={properties:null},i=Object.keys(c);for(const j of i){const[k,l]=c[j],m=a.createExpression(l),n=a.createExpression("string"==typeof k?[k,["accumulated",],["get",j,],]:k);d[j]=m.value,f[j]=n.value}return b.map=a=>{h.properties=a;const b={};for(const c of i)b[c]=d[c].evaluate(g,h);return b},b.reduce=(a,b)=>{for(const c of(h.properties=b,i))g.accumulated=a[c],a[c]=f[c].evaluate(g,h)},b}(b)).load(h.features):(j=h,k=b.geojsonVtOptions,new ar(j,k))}catch(n){return c(n)}this.loaded={};const o={};if(f){const p=a.getPerformanceMeasurement(d);p&&(o.resourceTiming={},o.resourceTiming[b.source]=JSON.parse(JSON.stringify(p)))}c(null,o)}})}reloadTile(a,b){const c=this.loaded;return c&&c[a.uid]?super.reloadTile(a,b):this.loadTile(a,b)}loadGeoJSON(b,c){if(b.request)a.getJSON(b.request,c);else{if("string"!=typeof b.data)return c(Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));try{return c(null,JSON.parse(b.data))}catch(d){return c(Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(a,b){try{b(null,this._geoJSONIndex.getClusterExpansionZoom(a.clusterId))}catch(c){b(c)}}getClusterChildren(a,b){try{b(null,this._geoJSONIndex.getChildren(a.clusterId))}catch(c){b(c)}}getClusterLeaves(a,b){try{b(null,this._geoJSONIndex.getLeaves(a.clusterId,a.limit,a.offset))}catch(c){b(c)}}}class au{constructor(b){this.self=b,this.actor=new a.Actor(b,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:at},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(a,b)=>{if(this.workerSourceTypes[a])throw Error(`Worker source with name "${a}" already registered.`);this.workerSourceTypes[a]=b},this.self.registerRTLTextPlugin=b=>{if(a.plugin.isParsed())throw Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=b.applyArabicShaping,a.plugin.processBidirectionalText=b.processBidirectionalText,a.plugin.processStyledBidirectionalText=b.processStyledBidirectionalText}}clearCaches(a,b,c){delete this.layerIndexes[a],delete this.availableImages[a],delete this.workerSources[a],delete this.demWorkerSources[a],c()}checkIfReady(a,b,c){c()}setReferrer(a,b){this.referrer=b}spriteLoaded(b,c){for(const d in this.isSpriteLoaded[b]=c,this.workerSources[b]){const f=this.workerSources[b][d];for(const g in f)f[g]instanceof a.VectorTileWorkerSource&&(f[g].isSpriteLoaded=c,f[g].fire(new a.Event("isSpriteLoaded")))}}setImages(a,b,c){for(const d in this.availableImages[a]=b,this.workerSources[a]){const f=this.workerSources[a][d];for(const g in f)f[g].availableImages=b}c()}enableTerrain(a,b,c){this.terrain=b,c()}setProjection(b,c){this.projections[b]=a.getProjection(c)}setLayers(a,b,c){this.getLayerIndex(a).replace(b),c()}updateLayers(a,b,c){this.getLayerIndex(a).update(b.layers,b.removedIds),c()}loadTile(b,c,d){const f=this.enableTerrain?a.extend({enableTerrain:this.terrain},c):c;f.projection=this.projections[b]||this.defaultProjection,this.getWorkerSource(b,c.type,c.source).loadTile(f,d)}loadDEMTile(b,c,d){const f=this.enableTerrain?a.extend({buildQuadTree:this.terrain},c):c;this.getDEMWorkerSource(b,c.source).loadTile(f,d)}reloadTile(b,c,d){const f=this.enableTerrain?a.extend({enableTerrain:this.terrain},c):c;f.projection=this.projections[b]||this.defaultProjection,this.getWorkerSource(b,c.type,c.source).reloadTile(f,d)}abortTile(a,b,c){this.getWorkerSource(a,b.type,b.source).abortTile(b,c)}removeTile(a,b,c){this.getWorkerSource(a,b.type,b.source).removeTile(b,c)}removeSource(a,b,c){if(!this.workerSources[a]||!this.workerSources[a][b.type]||!this.workerSources[a][b.type][b.source])return;const d=this.workerSources[a][b.type][b.source];delete this.workerSources[a][b.type][b.source],void 0!==d.removeSource?d.removeSource(b,c):c()}loadWorkerSource(a,b,c){try{this.self.importScripts(b.url),c()}catch(d){c(d.toString())}}syncRTLPluginState(b,c,d){try{a.plugin.setState(c);const f=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&null!=f){this.self.importScripts(f);const g=a.plugin.isParsed();d(g?void 0:Error(`RTL Text Plugin failed to import scripts from ${f}`),g)}}catch(h){d(h.toString())}}getAvailableImages(a){let b=this.availableImages[a];return b||(b=[]),b}getLayerIndex(a){let b=this.layerIndexes[a];return b||(b=this.layerIndexes[a]=new d),b}getWorkerSource(a,b,c){return this.workerSources[a]||(this.workerSources[a]={}),this.workerSources[a][b]||(this.workerSources[a][b]={}),this.workerSources[a][b][c]||(this.workerSources[a][b][c]=new this.workerSourceTypes[b]({send:(b,c,d,f,g,h)=>{this.actor.send(b,c,d,a,g,h)},scheduler:this.actor.scheduler},this.getLayerIndex(a),this.getAvailableImages(a),this.isSpriteLoaded[a])),this.workerSources[a][b][c]}getDEMWorkerSource(a,b){return this.demWorkerSources[a]||(this.demWorkerSources[a]={}),this.demWorkerSources[a][b]||(this.demWorkerSources[a][b]=new g),this.demWorkerSources[a][b]}enforceCacheSizeLimit(b,c){a.enforceCacheSizeLimit(c)}getWorkerPerformanceMetrics(a,b,c){c(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new au(self)),au}),f(["./shared"],function(a){var b=c;function c(a){var b,f;return b=a,"undefined"!=typeof window&&"undefined"!=typeof document&&!!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 a,b,c=new Blob([""],{type:"text/javascript"}),d=URL.createObjectURL(c);try{b=new Worker(d),a=!0}catch(f){a=!1}return b&&b.terminate(),URL.revokeObjectURL(d),a}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var a=document.createElement("canvas");a.width=a.height=1;var b=a.getContext("2d");if(!b)return!1;var c=b.getImageData(0,0,1,1);return c&&c.width===a.width}()&&(void 0===d[f=b&&b.failIfMajorPerformanceCaveat]&&(d[f]=function(a){var b,d,f,g,h=(b=a,d=document.createElement("canvas"),(f=Object.create(c.webGLContextAttributes)).failIfMajorPerformanceCaveat=b,d.getContext("webgl",f)||d.getContext("experimental-webgl",f));if(!h)return!1;try{g=h.createShader(h.VERTEX_SHADER)}catch(i){return!1}return!(!g||h.isContextLost())&&(h.shaderSource(g,"void main() {}"),h.compileShader(g),!0===h.getShaderParameter(g,h.COMPILE_STATUS))}(f)),!!d[f]&&!document.documentMode)}var d={};function f(a,b){var c=b[0],d=b[1],f=b[2],g=b[3],h=c*g-f*d;return h?(a[0]=g*(h=1/h),a[1]=-d*h,a[2]=-f*h,a[3]=c*h,a):null}function g(a,b){if(Array.isArray(a)){if(!Array.isArray(b)||a.length!==b.length)return!1;for(let c=0;c<a.length;c++)if(!g(a[c],b[c]))return!1;return!0}if("object"==typeof a&&null!==a&&null!==b){if("object"!=typeof b||Object.keys(a).length!==Object.keys(b).length)return!1;for(const d in a)if(!g(a[d],b[d]))return!1;return!0}return a===b}c.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const h={create:function(b,c,d){const f=a.window.document.createElement(b);return void 0!==c&&(f.className=c),d&&d.appendChild(f),f},createSVG:function(b,c,d){const f=a.window.document.createElementNS("http://www.w3.org/2000/svg",b);for(const g of Object.keys(c))f.setAttributeNS(null,g,c[g]);return d&&d.appendChild(f),f}},i=a.window.document&&a.window.document.documentElement.style,j=i&& void 0!==i.userSelect?"userSelect":"WebkitUserSelect";let k;h.disableDrag=function(){i&&j&&(k=i[j],i[j]="none")},h.enableDrag=function(){i&&j&&(i[j]=k)};const l=function(b){b.preventDefault(),b.stopPropagation(),a.window.removeEventListener("click",l,!0)};function m(b,c,d){const f=b.offsetWidth===c.width?1:b.offsetWidth/c.width;return new a.pointGeometry((d.clientX-c.left)*f,(d.clientY-c.top)*f)}function n(a){const{userImage:b}=a;return!!(b&&b.render&&b.render())&&(a.data.replace(new Uint8Array(b.data.buffer)),!0)}h.suppressClick=function(){a.window.addEventListener("click",l,!0),a.window.setTimeout(()=>{a.window.removeEventListener("click",l,!0)},0)},h.mousePos=function(a,b){const c=a.getBoundingClientRect();return m(a,c,b)},h.touchPos=function(a,b){const c=a.getBoundingClientRect(),d=[];for(let f=0;f<b.length;f++)d.push(m(a,c,b[f]));return d},h.mouseButton=function(b){return void 0!==a.window.InstallTrigger&&2===b.button&&b.ctrlKey&&a.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:b.button};class o 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(a){if(this.loaded!==a&&(this.loaded=a,a)){for(const{ids:b,callback:c}of this.requestors)this._notify(b,c);this.requestors=[]}}getImage(a){return this.images[a]}addImage(a,b){this._validate(a,b)&&(this.images[a]=b)}_validate(b,c){let d=!0;return this._validateStretch(c.stretchX,c.data&&c.data.width)||(this.fire(new a.ErrorEvent(Error(`Image "${b}" has invalid "stretchX" value`))),d=!1),this._validateStretch(c.stretchY,c.data&&c.data.height)||(this.fire(new a.ErrorEvent(Error(`Image "${b}" has invalid "stretchY" value`))),d=!1),this._validateContent(c.content,c)||(this.fire(new a.ErrorEvent(Error(`Image "${b}" has invalid "content" value`))),d=!1),d}_validateStretch(a,b){if(!a)return!0;let c=0;for(const d of a){if(d[0]<c||d[1]<d[0]||b<d[1])return!1;c=d[1]}return!0}_validateContent(a,b){return!(a&&(4!==a.length||a[0]<0||b.data.width<a[0]||a[1]<0||b.data.height<a[1]||a[2]<0||b.data.width<a[2]||a[3]<0||b.data.height<a[3]||a[2]<a[0]||a[3]<a[1]))}updateImage(a,b){b.version=this.images[a].version+1,this.images[a]=b,this.updatedImages[a]=!0}removeImage(a){const b=this.images[a];delete this.images[a],delete this.patterns[a],b.userImage&&b.userImage.onRemove&&b.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(a,b){let c=!0;if(!this.isLoaded())for(const d of a)this.images[d]||(c=!1);this.isLoaded()||c?this._notify(a,b):this.requestors.push({ids:a,callback:b})}_notify(b,c){const d={};for(const f of b){this.images[f]||this.fire(new a.Event("styleimagemissing",{id:f}));const g=this.images[f];g?d[f]={data:g.data.clone(),pixelRatio:g.pixelRatio,sdf:g.sdf,version:g.version,stretchX:g.stretchX,stretchY:g.stretchY,content:g.content,hasRenderCallback:Boolean(g.userImage&&g.userImage.render)}:a.warnOnce(`Image "${f}" 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.`)}c(null,d)}getPixelSize(){const{width:a,height:b}=this.atlasImage;return{width:a,height:b}}getPattern(b){const c=this.patterns[b],d=this.getImage(b);if(!d)return null;if(c&&c.position.version===d.version)return c.position;if(c)c.position.version=d.version;else{const f={w:d.data.width+2,h:d.data.height+2,x:0,y:0},g=new a.ImagePosition(f,d);this.patterns[b]={bin:f,position:g}}return this._updatePatternAtlas(),this.patterns[b].position}bind(b){const c=b.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.Texture(b,this.atlasImage,c.RGBA),this.atlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}_updatePatternAtlas(){const b=[];for(const c in this.patterns)b.push(this.patterns[c].bin);const{w:d,h:f}=a.potpack(b),g=this.atlasImage;for(const h in g.resize({width:d||1,height:f||1}),this.patterns){const{bin:i}=this.patterns[h],j=i.x+1,k=i.y+1,l=this.images[h].data,m=l.width,n=l.height;a.RGBAImage.copy(l,g,{x:0,y:0},{x:j,y:k},{width:m,height:n}),a.RGBAImage.copy(l,g,{x:0,y:n-1},{x:j,y:k-1},{width:m,height:1}),a.RGBAImage.copy(l,g,{x:0,y:0},{x:j,y:k+n},{width:m,height:1}),a.RGBAImage.copy(l,g,{x:m-1,y:0},{x:j-1,y:k},{width:1,height:n}),a.RGBAImage.copy(l,g,{x:0,y:0},{x:j+m,y:k},{width:1,height:n})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(a){for(const b of a){if(this.callbackDispatchedThisFrame[b])continue;this.callbackDispatchedThisFrame[b]=!0;const c=this.images[b];n(c)&&this.updateImage(b,c)}}}const p=new a.Properties({anchor:new a.DataConstantProperty(a.spec.light.anchor),position:new class{constructor(){this.specification=a.spec.light.position}possiblyEvaluate(b,c){return function([b,c,d]){const f=a.degToRad(c+90),g=a.degToRad(d);return{x:b*Math.cos(f)*Math.sin(g),y:b*Math.sin(f)*Math.sin(g),z:b*Math.cos(g),azimuthal:c,polar:d}}(b.expression.evaluate(c))}interpolate(b,c,d){return{x:a.number(b.x,c.x,d),y:a.number(b.y,c.y,d),z:a.number(b.z,c.z,d),azimuthal:a.number(b.azimuthal,c.azimuthal,d),polar:a.number(b.polar,c.polar,d)}}},color:new a.DataConstantProperty(a.spec.light.color),intensity:new a.DataConstantProperty(a.spec.light.intensity)}),q="-transition";class r extends a.Evented{constructor(b){super(),this._transitionable=new a.Transitionable(p),this.setLight(b),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(b,c={}){if(!this._validate(a.validateLight,b,c))for(const d in b){const f=b[d];a.endsWith(d,q)?this._transitionable.setTransition(d.slice(0,-q.length),f):this._transitionable.setValue(d,f)}}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}_validate(b,c,d){return(!d|| !1!==d.validate)&&a.emitValidationErrors(this,b.call(a.validateStyle,a.extend({value:c,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}const s=new a.Properties({source:new a.DataConstantProperty(a.spec.terrain.source),exaggeration:new a.DataConstantProperty(a.spec.terrain.exaggeration)}),u="-transition";class v extends a.Evented{constructor(b,c){super(),this._transitionable=new a.Transitionable(s),this.set(b),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=c}get(){return this._transitionable.serialize()}set(b){for(const c in b){const d=b[c];a.endsWith(c,u)?this._transitionable.setTransition(c.slice(0,-u.length),d):this._transitionable.setValue(c,d)}}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}}function w(b,c,d,f){const g=a.smoothstep(45,65,d),[h,i]=x(b,f),j=a.length(c);let k=1-Math.min(1,Math.exp(-((j-h)/(i-h)*6)));return k*=k*k,(k=Math.min(1,1.00747*k))*g*b.alpha}function x(a,b){const c=.5/Math.tan(.5*b);return[a.range[0]+c,a.range[1]+c]}const y=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"])}),z="-transition";class A extends a.Evented{constructor(b,c){super(),this._transitionable=new a.Transitionable(y),this.set(b),this._transitioning=this._transitionable.untransitioned(),this._transform=c}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(b,c={}){if(!this._validate(a.validateFog,b,c))for(const d in b){const f=b[d];a.endsWith(d,z)?this._transitionable.setTransition(d.slice(0,-z.length),f):this._transitionable.setValue(d,f)}}getOpacity(b){if(!this._transform.projection.supportsFog)return 0;const c=this.properties&&this.properties.get("color")||1;return a.smoothstep(45,65,b)*c.a}getOpacityAtLatLng(b,c){return this._transform.projection.supportsFog?function(b,c,d){const f=a.MercatorCoordinate.fromLngLat(c),g=d.elevation?d.elevation.getAtPointOrZero(f):0,h=[f.x,f.y,g];return a.transformMat4(h,h,d.mercatorFogMatrix),w(b,h,d.pitch,d._fov)}(this.state,b,c):0}getFovAdjustedRange(a){return this._transform.projection.supportsFog?x(this.state,a):[0,1]}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}_validate(b,c,d){return(!d|| !1!==d.validate)&&a.emitValidationErrors(this,b.call(a.validateStyle,a.extend({value:c,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}class B{constructor(b,c){this.workerPool=b,this.actors=[],this.currentActor=0,this.id=a.uniqueId();const d=this.workerPool.acquire(this.id);for(let f=0;f<d.length;f++){const g=new B.Actor(d[f],c,this.id);g.name=`Worker ${f}`,this.actors.push(g)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(b,c,d){a.asyncAll(this.actors,(a,d)=>{a.send(b,c,d)},d=d||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(a=>{a.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(b,c,d){return c*(a.EXTENT/(b.tileSize*Math.pow(2,d-b.tileID.overscaledZ)))}B.Actor=a.Actor;class D{constructor(a,b,c){this.context=a;const d=a.gl;this.buffer=d.createBuffer(),this.dynamicDraw=Boolean(c),this.context.unbindVAO(),a.bindElementBuffer.set(this.buffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,b.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete b.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(a){const b=this.context.gl;this.context.unbindVAO(),this.bind(),b.bufferSubData(b.ELEMENT_ARRAY_BUFFER,0,a.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const E={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class F{constructor(a,b,c,d){this.length=b.length,this.attributes=c,this.itemSize=b.bytesPerElement,this.dynamicDraw=d,this.context=a;const f=a.gl;this.buffer=f.createBuffer(),a.bindVertexBuffer.set(this.buffer),f.bufferData(f.ARRAY_BUFFER,b.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete b.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(a){const b=this.context.gl;this.bind(),b.bufferSubData(b.ARRAY_BUFFER,0,a.arrayBuffer)}enableAttributes(a,b){for(let c=0;c<this.attributes.length;c++){const d=b.attributes[this.attributes[c].name];void 0!==d&&a.enableVertexAttribArray(d)}}setVertexAttribPointers(a,b,c){for(let d=0;d<this.attributes.length;d++){const f=this.attributes[d],g=b.attributes[f.name];void 0!==g&&a.vertexAttribPointer(g,f.components,a[E[f.type]],!1,this.itemSize,f.offset+this.itemSize*(c||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class G{constructor(a){this.gl=a.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(a){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class H extends G{constructor(a,b){super(a),this.context=a,this.parent=b}getDefault(){return null}}class I extends H{attachment(){return this.gl.DEPTH_ATTACHMENT}set(a){if(a===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const b=this.gl;b.framebufferRenderbuffer(b.FRAMEBUFFER,this.attachment(),b.RENDERBUFFER,a),this.current=a,this.dirty=!1}}class J extends I{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class K{constructor(a,b,c,d){this.context=a,this.width=b,this.height=c;const f=this.framebuffer=a.gl.createFramebuffer();this.colorAttachment=new class extends H{setDirty(){this.dirty=!0}set(a){if(a===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const b=this.gl;b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,a,0),this.current=a,this.dirty=!1}}(a,f),d&&(this.depthAttachment=new I(a,f))}destroy(){const a=this.context.gl,b=this.colorAttachment.get();if(b&&a.deleteTexture(b),this.depthAttachment){const c=this.depthAttachment.get();c&&a.deleteRenderbuffer(c)}a.deleteFramebuffer(this.framebuffer)}}class L{constructor(a,b,c,d){this.screenBounds=a,this.cameraPoint=b,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=c,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(a=>d.pointCoordinate3D(a)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(b,c){let d,f;if(b instanceof a.pointGeometry||"number"==typeof b[0]){const g=a.pointGeometry.convert(b);d=[a.pointGeometry.convert(b)],f=c.isPointAboveHorizon(g)}else{const h=a.pointGeometry.convert(b[0]),i=a.pointGeometry.convert(b[1]);d=[h,i],f=a.polygonizeBounds(h,i).every(a=>c.isPointAboveHorizon(a))}return new L(d,c.getCameraPoint(),f,c)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(b){return a.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],b)}bufferedCameraGeometry(b){const c=this.screenBounds[0],d=1===this.screenBounds.length?this.screenBounds[0].add(new a.pointGeometry(1,1)):this.screenBounds[1],f=a.polygonizeBounds(c,d,0,!1);return this.cameraPoint.y>d.y&&(this.cameraPoint.x>c.x&&this.cameraPoint.x<d.x?f.splice(3,0,this.cameraPoint):this.cameraPoint.x>=d.x?f[2]=this.cameraPoint:this.cameraPoint.x<=c.x&&(f[3]=this.cameraPoint)),a.bufferConvexPolygon(f,b)}containsTile(b,c,d){var f;const g=b.queryPadding+1,h=b.tileID.wrap,i=d?this._bufferedCameraMercator(g,c).map(c=>a.getTilePoint(b.tileTransform,c,h)):this._bufferedScreenMercator(g,c).map(c=>a.getTilePoint(b.tileTransform,c,h)),j=this.screenGeometryMercator.map(c=>a.getTileVec3(b.tileTransform,c,h)),k=j.map(b=>new a.pointGeometry(b[0],b[1])),l=c.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),m=a.getTileVec3(b.tileTransform,l,h),n=j.map(b=>{const c=a.sub(b,b,m);return a.normalize(c,c),new a.Ray(m,c)}),o=C(b,1,c.zoom);if(a.polygonIntersectsBox(i,0,0,a.EXTENT,a.EXTENT))return{queryGeometry:this,tilespaceGeometry:k,tilespaceRays:n,bufferedTilespaceGeometry:i,bufferedTilespaceBounds:((f=a.getBounds(i)).min.x=a.clamp(f.min.x,0,a.EXTENT),f.min.y=a.clamp(f.min.y,0,a.EXTENT),f.max.x=a.clamp(f.max.x,0,a.EXTENT),f.max.y=a.clamp(f.max.y,0,a.EXTENT),f),tile:b,tileID:b.tileID,pixelToTileUnitsFactor:o}}_bufferedScreenMercator(a,b){const c=M(a);if(this._screenRaycastCache[c])return this._screenRaycastCache[c];{const d=this.bufferedScreenGeometry(a).map(a=>b.pointCoordinate3D(a));return this._screenRaycastCache[c]=d,d}}_bufferedCameraMercator(a,b){const c=M(a);if(this._cameraRaycastCache[c])return this._cameraRaycastCache[c];{const d=this.bufferedCameraGeometry(a).map(a=>b.pointCoordinate3D(a));return this._cameraRaycastCache[c]=d,d}}}function M(a){return 100*a|0}function N(b,c,d){const f=function(f,g){if(f)return d(f);if(g){const h=a.pick(a.extend(g,b),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding",]);g.vector_layers&&(h.vectorLayers=g.vector_layers,h.vectorLayerIds=h.vectorLayers.map(a=>a.id)),h.tiles=c.canonicalizeTileset(h,b.url),d(null,h)}};return b.url?a.getJSON(c.transformRequest(c.normalizeSourceURL(b.url),a.ResourceType.Source),f):a.exported.frame(()=>f(null,b))}class O{constructor(b,c,d){this.bounds=a.LngLatBounds.convert(this.validateBounds(b)),this.minzoom=c||0,this.maxzoom=d||24}validateBounds(a){return Array.isArray(a)&&4===a.length?[Math.max(-180,a[0]),Math.max(-90,a[1]),Math.min(180,a[2]),Math.min(90,a[3]),]:[-180,-90,180,90]}contains(b){const c=Math.pow(2,b.z),d=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*c),f=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*c),g=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*c),h=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*c);return b.x>=d&&b.x<g&&b.y>=f&&b.y<h}}class P extends a.Evented{constructor(b,c,d,f){super(),this.id=b,this.dispatcher=d,this.setEventedParent(f),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"},c),a.extend(this,a.pick(c,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=N(this._options,this.map._requestManager,(b,c)=>{this._tileJSONRequest=null,this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(a.extend(this,c),c.bounds&&(this.tileBounds=new O(c.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(c.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(a){this.map=a,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(b,c){const d=a.exported.devicePixelRatio>=2,f=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),d,this.tileSize);b.request=a.getImage(this.map._requestManager.transformRequest(f,a.ResourceType.Tile),(d,f,g,h)=>{if(delete b.request,b.aborted)b.state="unloaded",c(null);else if(d)b.state="errored",c(d);else if(f){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:g,expires:h});const i=this.map.painter.context,j=i.gl;b.texture=this.map.painter.getTileTexture(f.width),b.texture?b.texture.update(f,{useMipmap:!0}):(b.texture=new a.Texture(i,f,j.RGBA,{useMipmap:!0}),b.texture.bind(j.LINEAR,j.CLAMP_TO_EDGE),i.extTextureFilterAnisotropic&&j.texParameterf(j.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax)),b.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),c(null)}})}abortTile(a,b){a.request&&(a.request.cancel(),delete a.request),b()}unloadTile(a,b){a.texture&&this.map.painter.saveTileTexture(a.texture),b()}hasTransition(){return!1}}let Q;function R(b,c,d,f,g,h,i,j){const k=[b,d,g,c,f,h,1,1,1],l=[i,j,1],m=a.adjoint([],k),[n,o,p]=a.transformMat3(l,l,a.transpose(m,m));return a.multiply(k,[n,0,0,0,o,0,0,0,p],k)}class S extends a.Evented{constructor(a,b,c,d){super(),this.id=a,this.dispatcher=c,this.coordinates=b.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=b}load(b,c){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),(d,f)=>{this._loaded=!0,d?this.fire(new a.ErrorEvent(d)):f&&(this.image=a.exported.getImageData(f),this.width=this.image.width,this.height=this.image.height,b&&(this.coordinates=b),c&&c(),this._finishLoading())})}loaded(){return this._loaded}updateImage(a){return this.image&&a.url&&(this.options.url=a.url,this.load(a.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(a){this.map=a,this.load()}setCoordinates(b){this.coordinates=b,delete this._boundsArray;const c=b.map(a.MercatorCoordinate.fromLngLat);return this.tileID=function(b){let c=1/0,d=1/0,f=-1/0,g=-1/0;for(const h of b)c=Math.min(c,h.x),d=Math.min(d,h.y),f=Math.max(f,h.x),g=Math.max(g,h.y);const i=Math.max(f-c,g-d),j=Math.max(0,Math.floor(-Math.log(i)/Math.LN2)),k=Math.pow(2,j);return new a.CanonicalTileID(j,Math.floor((c+f)/2*k),Math.floor((d+g)/2*k))}(c),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const b=a.tileTransform(this.tileID,this.map.transform.projection),[c,d,f,g]=this.coordinates.map(c=>{const d=b.projection.project(c[0],c[1]);return a.getTilePoint(b,d)._round()});return this.perspectiveTransform=function(b,c,d,f,g,h,i,j,k,l){const m=R(0,0,b,0,0,c,b,c),n=R(d,f,g,h,i,j,k,l);return a.multiply(n,a.adjoint(m,m),n),[n[6]/n[8]*b/a.EXTENT,n[7]/n[8]*c/a.EXTENT,]}(this.width,this.height,c.x,c.y,d.x,d.y,g.x,g.y,f.x,f.y),this._boundsArray=new a.StructArrayLayout4i8,this._boundsArray.emplaceBack(c.x,c.y,0,0),this._boundsArray.emplaceBack(d.x,d.y,a.EXTENT,0),this._boundsArray.emplaceBack(g.x,g.y,0,a.EXTENT),this._boundsArray.emplaceBack(f.x,f.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const b=this.map.painter.context,c=b.gl;for(const d in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=b.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new a.Texture(b,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE)),this.tiles){const f=this.tiles[d];"loaded"!==f.state&&(f.state="loaded",f.texture=this.texture)}}loadTile(a,b){this.tileID&&this.tileID.equals(a.tileID.canonical)?(this.tiles[String(a.tileID.wrap)]=a,a.buckets={},b(null)):(a.state="errored",b(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const T={vector:class extends a.Evented{constructor(b,c,d,f){if(super(),this.id=b,this.dispatcher=d,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(c,["url","scheme","tileSize","promoteId",])),this._options=a.extend({type:"vector"},c),this._collectResourceTiming=c.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(f),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=N(this._options,this.map._requestManager,(b,c)=>{this._tileJSONRequest=null,this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(a.extend(this,c),c.bounds&&(this.tileBounds=new O(c.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(c.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(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}onAdd(a){this.map=a,this.load()}setSourceProperty(a){this._tileJSONRequest&&this._tileJSONRequest.cancel(),a();const b=this.map.style._getSourceCaches(this.id);for(const c of b)c.clearTiles();this.load()}setTiles(a){return this.setSourceProperty(()=>{this._options.tiles=a}),this}setUrl(a){return this.setSourceProperty(()=>{this.url=a,this._options.url=a}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}loadTile(b,c){const d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme)),f={request:this.map._requestManager.transformRequest(d,a.ResourceType.Tile),data:void 0,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,tileSize:this.tileSize*b.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:b.isSymbolTile};if(f.request.collectResourceTiming=this._collectResourceTiming,b.actor&&"expired"!==b.state)"loading"===b.state?b.reloadCallback=c:b.request=b.actor.send("reloadTile",f,h.bind(this));else if(b.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready)b.request=b.actor.send("loadTile",f,h.bind(this),void 0,!0);else{const g=a.loadVectorTile.call({deduped:this._deduped},f,(a,c)=>{a||!c?h.call(this,a):(f.data={cacheControl:c.cacheControl,expires:c.expires,rawData:c.rawData.slice(0)},b.actor&&b.actor.send("loadTile",f,h.bind(this),void 0,!0))},!0);b.request={cancel:g}}function h(d,f){return delete b.request,b.aborted?c(null):d&&404!==d.status?c(d):(f&&f.resourceTiming&&(b.resourceTiming=f.resourceTiming),this.map._refreshExpiredTiles&&f&&b.setExpiryData(f),b.loadVectorData(f,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),c(null),void(b.reloadCallback&&(this.loadTile(b,b.reloadCallback),b.reloadCallback=null)))}}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.actor&&a.actor.send("abortTile",{uid:a.uid,type:this.type,source:this.id})}unloadTile(a){a.unloadVectorData(),a.actor&&a.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:P,"raster-dem":class extends P{constructor(b,c,d,f){super(b,c,d,f),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},c),this.encoding=c.encoding||"mapbox"}loadTile(b,c){const d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function f(a,d){a&&(b.state="errored",c(a)),d&&(b.dem=d,b.dem.onDeserialize(),b.needsHillshadePrepare=!0,b.needsDEMTextureUpload=!0,b.state="loaded",c(null))}b.request=a.getImage(this.map._requestManager.transformRequest(d,a.ResourceType.Tile),(function(d,g,h,i){if(delete b.request,b.aborted)b.state="unloaded",c(null);else if(d)b.state="errored",c(d);else if(g){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const j=a.window.ImageBitmap&&g instanceof a.window.ImageBitmap&&(null==Q&&(Q=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.window.createImageBitmap),Q),k=1-(g.width-a.prevPowerOfTwo(g.width))/2;k<1||b.neighboringTiles||(b.neighboringTiles=this._getNeighboringTiles(b.tileID));const l=j?g:a.exported.getImageData(g,k),m={uid:b.uid,coord:b.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:k};b.actor&&"expired"!==b.state||(b.actor=this.dispatcher.getActor(),b.actor.send("loadDEMTile",m,f.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(b){const c=b.canonical,d=Math.pow(2,c.z),f=(c.x-1+d)%d,g=0===c.x?b.wrap-1:b.wrap,h=(c.x+1+d)%d,i=c.x+1===d?b.wrap+1:b.wrap,j={};return j[new a.OverscaledTileID(b.overscaledZ,g,c.z,f,c.y).key]={backfilled:!1},j[new a.OverscaledTileID(b.overscaledZ,i,c.z,h,c.y).key]={backfilled:!1},c.y>0&&(j[new a.OverscaledTileID(b.overscaledZ,g,c.z,f,c.y-1).key]={backfilled:!1},j[new a.OverscaledTileID(b.overscaledZ,b.wrap,c.z,c.x,c.y-1).key]={backfilled:!1},j[new a.OverscaledTileID(b.overscaledZ,i,c.z,h,c.y-1).key]={backfilled:!1}),c.y+1<d&&(j[new a.OverscaledTileID(b.overscaledZ,g,c.z,f,c.y+1).key]={backfilled:!1},j[new a.OverscaledTileID(b.overscaledZ,b.wrap,c.z,c.x,c.y+1).key]={backfilled:!1},j[new a.OverscaledTileID(b.overscaledZ,i,c.z,h,c.y+1).key]={backfilled:!1}),j}unloadTile(a){a.demTexture&&this.map.painter.saveTileTexture(a.demTexture),a.fbo&&(a.fbo.destroy(),delete a.fbo),a.dem&&delete a.dem,delete a.neighboringTiles,a.state="unloaded"}},geojson:class extends a.Evented{constructor(b,c,d,f){super(),this.id=b,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=d.getActor(),this.setEventedParent(f),this._data=c.data,this._options=a.extend({},c),this._collectResourceTiming=c.collectResourceTiming,void 0!==c.maxzoom&&(this.maxzoom=c.maxzoom),c.type&&(this.type=c.type),c.attribution&&(this.attribution=c.attribution),this.promoteId=c.promoteId;const g=a.EXTENT/this.tileSize;this.workerOptions=a.extend({source:this.id,cluster:c.cluster||!1,geojsonVtOptions:{buffer:(void 0!==c.buffer?c.buffer:128)*g,tolerance:(void 0!==c.tolerance?c.tolerance:.375)*g,extent:a.EXTENT,maxZoom:this.maxzoom,lineMetrics:c.lineMetrics||!1,generateId:c.generateId||!1},superclusterOptions:{maxZoom:void 0!==c.clusterMaxZoom?c.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,c.clusterMinPoints||2),extent:a.EXTENT,radius:(void 0!==c.clusterRadius?c.clusterRadius:50)*g,log:!1,generateId:c.generateId||!1},clusterProperties:c.clusterProperties,filter:c.filter},c.workerOptions)}onAdd(a){this.map=a,this.setData(this._data)}setData(a){return this._data=a,this._updateWorkerData(),this}getClusterExpansionZoom(a,b){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:a,source:this.id},b),this}getClusterChildren(a,b){return this.actor.send("geojson.getClusterChildren",{clusterId:a,source:this.id},b),this}getClusterLeaves(a,b,c,d){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:a,limit:b,offset:c},d),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new a.Event("dataloading",{dataType:"source"})),this._loaded=!1;const b=a.extend({},this.workerOptions),c=this._data;"string"==typeof c?(b.request=this.map._requestManager.transformRequest(a.exported.resolveURL(c),a.ResourceType.Source),b.request.collectResourceTiming=this._collectResourceTiming):b.data=JSON.stringify(c),this._pendingLoad=this.actor.send(`${this.type}.loadData`,b,(b,c)=>{if(this._loaded=!0,this._pendingLoad=null,b)this.fire(new a.ErrorEvent(b));else{const d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&c&&c.resourceTiming&&c.resourceTiming[this.id]&&(d.resourceTiming=c.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(b,c){const d=b.actor?"reloadTile":"loadTile";b.actor=this.actor,b.request=this.actor.send(d,{type:this.type,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(a,f)=>(delete b.request,b.unloadVectorData(),b.aborted?c(null):a?c(a):(b.loadVectorData(f,this.map.painter,"reloadTile"===d),c(null))),void 0,"loadTile"===d)}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.aborted=!0}unloadTile(a){a.unloadVectorData(),this.actor.send("removeTile",{uid:a.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 S{constructor(a,b,c,d){super(a,b,c,d),this.roundZoom=!0,this.type="video",this.options=b}load(){this._loaded=!1;const b=this.options;for(const c of(this.urls=[],b.urls))this.urls.push(this.map._requestManager.transformRequest(c,a.ResourceType.Source).url);a.getVideo(this.urls,(b,c)=>{this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(this.video=c,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(b){if(this.video){const c=this.video.seekable;b<c.start(0)||b>c.end(0)?this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${c.start(0)} and ${c.end(0)}-second mark.`))):this.video.currentTime=b}}getVideo(){return this.video}onAdd(a){this.map||(this.map=a,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const b=this.map.painter.context,c=b.gl;for(const d in this.texture?this.video.paused||(this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE),c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,this.video)):(this.texture=new a.Texture(b,this.video,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=b.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const f=this.tiles[d];"loaded"!==f.state&&(f.state="loaded",f.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:S,canvas:class extends S{constructor(b,c,d,f){super(b,c,d,f),c.coordinates?Array.isArray(c.coordinates)&&4===c.coordinates.length&&!c.coordinates.some(a=>!Array.isArray(a)||2!==a.length||a.some(a=>"number"!=typeof a))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,null,'missing required property "coordinates"'))),c.animate&&"boolean"!=typeof c.animate&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,null,'optional "animate" property must be a boolean value'))),c.canvas?"string"==typeof c.canvas||c.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,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.${b}`,null,'missing required property "canvas"'))),this.options=c,this.animate=void 0===c.animate||c.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(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(a){this.map=a,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let b=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,b=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,b=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const c=this.map.painter.context,d=c.gl;for(const f in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(b||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(c,this.canvas,d.RGBA,{premultiply:!0}),this.tiles){const g=this.tiles[f];"loaded"!==g.state&&(g.state="loaded",g.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const a of[this.canvas.width,this.canvas.height,])if(isNaN(a)||a<=0)return!0;return!1}}},U=function(b,c,d,f){const g=new T[c.type](b,c,d,f);if(g.id!==b)throw Error(`Expected Source id to be ${b} instead of ${g.id}`);return a.bindAll(["load","abort","unload","serialize","prepare",],g),g};function V(b,c){const d=a.identity([]);return a.scale(d,d,[.5*b.width,-(.5*b.height),1,]),a.translate(d,d,[1,-1,0]),a.multiply$1(d,d,b.calculateProjMatrix(c.toUnwrapped()))}function W(a,b,c,d,f,g,h,i=!1){const j=a.tilesIn(d,h,i);j.sort(Y);const k=[];for(const l of j)k.push({wrappedTileID:l.tile.tileID.wrapped().key,queryResults:l.tile.queryRenderedFeatures(b,c,a._state,l,f,g,V(a.transform,l.tile.tileID),i)});const m=function(a){const b={},c={};for(const d of a){const f=d.queryResults,g=d.wrappedTileID,h=c[g]=c[g]||{};for(const i in f){const j=f[i],k=h[i]=h[i]||{},l=b[i]=b[i]||[];for(const m of j)k[m.featureIndex]||(k[m.featureIndex]=!0,l.push(m))}}return b}(k);for(const n in m)m[n].forEach(b=>{const c=b.feature,d=a.getFeatureState(c.layer["source-layer"],c.id);c.source=c.layer.source,c.layer["source-layer"]&&(c.sourceLayer=c.layer["source-layer"]),c.state=d});return m}function X(a,b){const c=a.getRenderableIds().map(b=>a.getTileByID(b)),d=[],f={};for(let g=0;g<c.length;g++){const h=c[g],i=h.tileID.canonical.key;f[i]||(f[i]=!0,h.querySourceFeatures(d,b))}return d}function Y(a,b){const c=a.tileID,d=b.tileID;return c.overscaledZ-d.overscaledZ||c.canonical.y-d.canonical.y||c.wrap-d.wrap||c.canonical.x-d.canonical.x}function Z(){return null!=dp.workerClass?new dp.workerClass:new a.window.Worker(dp.workerUrl)}const $="mapboxgl_preloaded_worker_pool";class _{constructor(){this.active={}}acquire(a){if(!this.workers)for(this.workers=[];this.workers.length<_.workerCount;)this.workers.push(new Z);return this.active[a]=!0,this.workers.slice()}release(a){delete this.active[a],0===this.numActive()&&(this.workers.forEach(a=>{a.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[$]}numActive(){return Object.keys(this.active).length}}let aa;function ab(){return aa||(aa=new _),aa}function ac(b,c){const d={};for(const f in b)"ref"!==f&&(d[f]=b[f]);return a.refProperties.forEach(a=>{a in c&&(d[a]=c[a])}),d}function ad(a){a=a.slice();const b=Object.create(null);for(let c=0;c<a.length;c++)b[a[c].id]=a[c];for(let d=0;d<a.length;d++)"ref"in a[d]&&(a[d]=ac(a[d],b[a[d].ref]));return a}_.workerCount=2;const ae={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 af(a,b,c){c.push({command:ae.addSource,args:[a,b[a]]})}function ag(a,b,c){b.push({command:ae.removeSource,args:[a]}),c[a]=!0}function ah(a,b,c,d){ag(a,c,d),af(a,b,c)}function ai(a,b,c){let d;for(d in a[c])if(a[c].hasOwnProperty(d)&&"data"!==d&&!g(a[c][d],b[c][d]))return!1;for(d in b[c])if(b[c].hasOwnProperty(d)&&"data"!==d&&!g(a[c][d],b[c][d]))return!1;return!0}function aj(a,b,c,d,f,h){let i;for(i in b=b||{},a=a||{})a.hasOwnProperty(i)&&(g(a[i],b[i])||c.push({command:h,args:[d,i,b[i],f]}));for(i in b)b.hasOwnProperty(i)&&!a.hasOwnProperty(i)&&(g(a[i],b[i])||c.push({command:h,args:[d,i,b[i],f]}))}function ak(a){return a.id}function al(a,b){return a[b.id]=b,a}class am{constructor(a,b){this.reset(a,b)}reset(a,b){this.points=a||[],this._distances=[0];for(let c=1;c<this.points.length;c++)this._distances[c]=this._distances[c-1]+this.points[c].dist(this.points[c-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(b||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(b){if(1===this.points.length)return this.points[0];b=a.clamp(b,0,1);let c=1,d=this._distances[c];const f=b*this.paddedLength+this.padding;for(;d<f&&c<this._distances.length;)d=this._distances[++c];const g=c-1,h=this._distances[g],i=d-h,j=i>0?(f-h)/i:0;return this.points[g].mult(1-j).add(this.points[c].mult(j))}}class an{constructor(a,b,c){const d=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(a/c),this.yCellCount=Math.ceil(b/c);for(let g=0;g<this.xCellCount*this.yCellCount;g++)d.push([]),f.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=a,this.height=b,this.xScale=this.xCellCount/a,this.yScale=this.yCellCount/b,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(a,b,c,d,f){this._forEachCell(b,c,d,f,this._insertBoxCell,this.boxUid++),this.boxKeys.push(a),this.bboxes.push(b),this.bboxes.push(c),this.bboxes.push(d),this.bboxes.push(f)}insertCircle(a,b,c,d){this._forEachCell(b-d,c-d,b+d,c+d,this._insertCircleCell,this.circleUid++),this.circleKeys.push(a),this.circles.push(b),this.circles.push(c),this.circles.push(d)}_insertBoxCell(a,b,c,d,f,g){this.boxCells[f].push(g)}_insertCircleCell(a,b,c,d,f,g){this.circleCells[f].push(g)}_query(a,b,c,d,f,g){if(c<0||a>this.width||d<0||b>this.height)return!f&&[];const h=[];if(a<=0&&b<=0&&this.width<=c&&this.height<=d){if(f)return!0;for(let i=0;i<this.boxKeys.length;i++)h.push({key:this.boxKeys[i],x1:this.bboxes[4*i],y1:this.bboxes[4*i+1],x2:this.bboxes[4*i+2],y2:this.bboxes[4*i+3]});for(let j=0;j<this.circleKeys.length;j++){const k=this.circles[3*j],l=this.circles[3*j+1],m=this.circles[3*j+2];h.push({key:this.circleKeys[j],x1:k-m,y1:l-m,x2:k+m,y2:l+m})}return g?h.filter(g):h}return this._forEachCell(a,b,c,d,this._queryCell,h,{hitTest:f,seenUids:{box:{},circle:{}}},g),f?h.length>0:h}_queryCircle(a,b,c,d,f){const g=a-c,h=a+c,i=b-c,j=b+c;if(h<0||g>this.width||j<0||i>this.height)return!d&&[];const k=[];return this._forEachCell(g,i,h,j,this._queryCellCircle,k,{hitTest:d,circle:{x:a,y:b,radius:c},seenUids:{box:{},circle:{}}},f),d?k.length>0:k}query(a,b,c,d,f){return this._query(a,b,c,d,!1,f)}hitTest(a,b,c,d,f){return this._query(a,b,c,d,!0,f)}hitTestCircle(a,b,c,d){return this._queryCircle(a,b,c,!0,d)}_queryCell(a,b,c,d,f,g,h,i){const j=h.seenUids,k=this.boxCells[f];if(null!==k){const l=this.bboxes;for(const m of k)if(!j.box[m]){j.box[m]=!0;const n=4*m;if(a<=l[n+2]&&b<=l[n+3]&&c>=l[n+0]&&d>=l[n+1]&&(!i||i(this.boxKeys[m]))){if(h.hitTest)return g.push(!0),!0;g.push({key:this.boxKeys[m],x1:l[n],y1:l[n+1],x2:l[n+2],y2:l[n+3]})}}}const o=this.circleCells[f];if(null!==o){const p=this.circles;for(const q of o)if(!j.circle[q]){j.circle[q]=!0;const r=3*q;if(this._circleAndRectCollide(p[r],p[r+1],p[r+2],a,b,c,d)&&(!i||i(this.circleKeys[q]))){if(h.hitTest)return g.push(!0),!0;{const s=p[r],u=p[r+1],v=p[r+2];g.push({key:this.circleKeys[q],x1:s-v,y1:u-v,x2:s+v,y2:u+v})}}}}}_queryCellCircle(a,b,c,d,f,g,h,i){const j=h.circle,k=h.seenUids,l=this.boxCells[f];if(null!==l){const m=this.bboxes;for(const n of l)if(!k.box[n]){k.box[n]=!0;const o=4*n;if(this._circleAndRectCollide(j.x,j.y,j.radius,m[o+0],m[o+1],m[o+2],m[o+3])&&(!i||i(this.boxKeys[n])))return g.push(!0),!0}}const p=this.circleCells[f];if(null!==p){const q=this.circles;for(const r of p)if(!k.circle[r]){k.circle[r]=!0;const s=3*r;if(this._circlesCollide(q[s],q[s+1],q[s+2],j.x,j.y,j.radius)&&(!i||i(this.circleKeys[r])))return g.push(!0),!0}}}_forEachCell(a,b,c,d,f,g,h,i){const j=this._convertToXCellCoord(a),k=this._convertToYCellCoord(b),l=this._convertToXCellCoord(c),m=this._convertToYCellCoord(d);for(let n=j;n<=l;n++)for(let o=k;o<=m;o++)if(f.call(this,a,b,c,d,this.xCellCount*o+n,g,h,i))return}_convertToXCellCoord(a){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(a*this.xScale)))}_convertToYCellCoord(a){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(a*this.yScale)))}_circlesCollide(a,b,c,d,f,g){const h=d-a,i=f-b,j=c+g;return j*j>h*h+i*i}_circleAndRectCollide(a,b,c,d,f,g,h){const i=(g-d)/2,j=Math.abs(a-(d+i));if(j>i+c)return!1;const k=(h-f)/2,l=Math.abs(b-(f+k));if(l>k+c)return!1;if(j<=i||l<=k)return!0;const m=j-i,n=l-k;return m*m+n*n<=c*c}}const ao=Math.tan(85*Math.PI/180);function ap(b,c,d,g,h,i){let j=a.create();if(d){if("globe"===h.projection.name)j=a.calculateGlobeMatrix(h,h.worldSize/h._projectionScaler,[0,0]),a.multiply$1(j,j,a.globeDenormalizeECEF(a.globeTileBounds(c)));else{const k=f([],i);j[0]=k[0],j[1]=k[1],j[4]=k[2],j[5]=k[3]}g||a.rotateZ(j,j,h.angle)}else a.multiply$1(j,h.labelPlaneMatrix,b);return j}function aq(b,c,d,f,g,h){if(d){if("globe"===g.projection.name){const i=ap(b,c,d,f,g,h);return a.invert(i,i),a.multiply$1(i,b,i),i}{const j=a.clone(b),k=a.identity([]);return k[0]=h[0],k[1]=h[1],k[4]=h[2],k[5]=h[3],a.multiply$1(j,j,k),f||a.rotateZ(j,j,-g.angle),j}}return g.glCoordMatrix}function ar(b,c,d=0){const f=[b.x,b.y,d,1];d?a.transformMat4$1(f,f,c):aD(f,f,c);const g=f[3];return{point:new a.pointGeometry(f[0]/g,f[1]/g),signedDistanceFromCamera:g}}function as(a,b){return Math.min(.5+a/b*.5,1.5)}function at(a,b){const c=a[0]/a[3],d=a[1]/a[3];return c>= -b[0]&&c<=b[0]&&d>= -b[1]&&d<=b[1]}function au(b,c,d,f,g,h,i,j,k,l){const m=d.transform,n=f?b.textSizeData:b.iconSizeData,o=a.evaluateSizeForZoom(n,d.transform.zoom),p=[256/d.width*2+1,256/d.height*2+1,],q=f?b.text.dynamicLayoutVertexArray:b.icon.dynamicLayoutVertexArray;q.clear();const r=b.lineVertexArray,s=f?b.text.placedSymbolArray:b.icon.placedSymbolArray,u=d.transform.width/d.transform.height;let v=!1;for(let w=0;w<s.length;w++){const x=s.get(w);if(x.writingMode!==a.WritingMode.vertical||v||0!==w&&s.get(w-1).writingMode===a.WritingMode.horizontal||(v=!0),x.hidden||x.writingMode===a.WritingMode.vertical&&!v){aC(x.numGlyphs,q);continue}v=!1;const y=new a.pointGeometry(x.tileAnchorX,x.tileAnchorY),z=k?k(y):[0,0,0],A=m.projection.projectTilePoint(y.x,y.y,l.canonical),B=[A.x+z[0],A.y+z[1],A.z+z[2]],C=[...B,1];if(a.transformMat4$1(C,C,c),!at(C,p)){aC(x.numGlyphs,q);continue}const D=as(d.transform.cameraToCenterDistance,C[3]),E=a.evaluateSizeForFeature(n,o,x),F=i?E/D:E*D,G=ar(new a.pointGeometry(B[0],B[1]),g,B[2]);if(G.signedDistanceFromCamera<=0){aC(x.numGlyphs,q);continue}let H={};const I=i?null:k,J=ax(x,F,!1,j,c,g,h,b.glyphOffsetArray,r,q,G.point,y,H,u,I,m.projection,l);v=J.useVertical,I&&J.needsFlipping&&(H={}),(J.notEnoughRoom||v||J.needsFlipping&&ax(x,F,!0,j,c,g,h,b.glyphOffsetArray,r,q,G.point,y,H,u,I,m.projection,l).notEnoughRoom)&&aC(x.numGlyphs,q)}f?b.text.dynamicLayoutVertexBuffer.updateData(q):b.icon.dynamicLayoutVertexBuffer.updateData(q)}function av(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p){const q=i.glyphStartIndex+i.numGlyphs,r=i.lineStartIndex,s=i.lineStartIndex+i.lineLength,u=b.getoffsetX(i.glyphStartIndex),v=b.getoffsetX(q-1),w=aA(a*u,c,d,f,g,h,i.segment,r,s,j,k,l,m,n,!0,o,p);if(!w)return null;const x=aA(a*v,c,d,f,g,h,i.segment,r,s,j,k,l,m,n,!0,o,p);return x?{first:w,last:x}:null}function aw(b,c,d,f){return b.writingMode===a.WritingMode.horizontal&&Math.abs(d.y-c.y)>Math.abs(d.x-c.x)*f?{useVertical:!0}:b.writingMode===a.WritingMode.vertical?c.y<d.y?{needsFlipping:!0}:null:0!==b.flipState&&function(a,b,c){const d=(b.x-a.x)*c;return 0===d||Math.abs((b.y-a.y)/d)>ao}(c,d,f)?1===b.flipState?{needsFlipping:!0}:null:c.x>d.x?{needsFlipping:!0}:null}function ax(b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s){const u=c/24,v=b.lineOffsetX*u,w=b.lineOffsetY*u;let x;if(b.numGlyphs>1){const y=b.glyphStartIndex+b.numGlyphs,z=b.lineStartIndex,A=b.lineStartIndex+b.lineLength,B=av(u,j,v,w,d,m,n,b,k,h,o,q,!1,r,s);if(!B)return{notEnoughRoom:!0};const C=ar(B.first.point,i).point,D=ar(B.last.point,i).point;if(f&&!d){const E=aw(b,C,D,p);if(b.flipState=E&&E.needsFlipping?1:2,E)return E}x=[B.first];for(let F=b.glyphStartIndex+1;F<y-1;F++)x.push(aA(u*j.getoffsetX(F),v,w,d,m,n,b.segment,z,A,k,h,o,q,!1,!1,r,s));x.push(B.last)}else{if(f&&!d){const G=ar(n,g).point,H=b.lineStartIndex+b.segment+1,I=new a.pointGeometry(k.getx(H),k.gety(H)),J=ar(I,g),K=aw(b,G,J.signedDistanceFromCamera>0?J.point:az(n,I,G,1,g,void 0,r,s.canonical),p);if(b.flipState=K&&K.needsFlipping?1:2,K)return K}const L=aA(u*j.getoffsetX(b.glyphStartIndex),v,w,d,m,n,b.segment,b.lineStartIndex,b.lineStartIndex+b.lineLength,k,h,o,q,!1,!1,r,s);if(!L)return{notEnoughRoom:!0};x=[L]}for(const M of x)a.addDynamicAttributes(l,M.point,M.angle);return{}}function ay(b,c,d,f,g){const h=f.projectTilePoint(b.x,b.y,c);if(!g)return ar(h,d,h.z);const i=g(b);return ar(new a.pointGeometry(h.x+i[0],h.y+i[1]),d,h.z+i[2])}function az(a,b,c,d,f,g,h,i){const j=ay(a.add(a.sub(b)._unit()),i,f,h,g).point,k=c.sub(j);return c.add(k._mult(d/k.mag()))}function aA(b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s){const u=f?b-c:b+c;let v=u>0?1:-1,w=0;f&&(v*=-1,w=Math.PI),v<0&&(w+=Math.PI);let x=v>0?j+i:j+i+1,y=g,z=g,A=0,B=0;const C=Math.abs(u),D=[],E=[];let F=h;const G=()=>{const b=x-v;return 0===A?h:new a.pointGeometry(l.getx(b),l.gety(b))},H=()=>az(G(),F,z,C-A+1,m,o,r,s.canonical);for(;A+B<=C;){if((x+=v)<j||x>=k)return null;if(z=y,D.push(y),p&&E.push(F||G()),void 0===(y=n[x])){F=new a.pointGeometry(l.getx(x),l.gety(x));const I=ay(F,s.canonical,m,r,o);y=I.signedDistanceFromCamera>0?n[x]=I.point:H()}else F=null;A+=B,B=z.dist(y)}q&&o&&(F=F||new a.pointGeometry(l.getx(x),l.gety(x)),n[x]=y=void 0===n[x]?y:H(),B=z.dist(y));const J=(C-A)/B,K=y.sub(z),L=K.mult(J)._add(z);d&&L._add(K._unit()._perp()._mult(d*v));const M=w+Math.atan2(y.y-z.y,y.x-z.x);return D.push(L),p&&(F=F||new a.pointGeometry(l.getx(x),l.gety(x)),E.push(function(b,c,d){const f=1-d;return new a.pointGeometry(b.x*f+c.x*d,b.y*f+c.y*d)}(E.length>0?E[E.length-1]:F,F,J))),{point:L,angle:M,path:D,tilePath:E}}const aB=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,]);function aC(a,b){for(let c=0;c<a;c++){const d=b.length;b.resize(d+4),b.float32.set(aB,3*d)}}function aD(a,b,c){const d=b[0],f=b[1];return a[0]=c[0]*d+c[4]*f+c[12],a[1]=c[1]*d+c[5]*f+c[13],a[3]=c[3]*d+c[7]*f+c[15],a}class aE{constructor(a,b,c,d){this.opacity=a?Math.max(0,Math.min(1,a.opacity+(a.placed?b:-b))):d&&c?1:0,this.placed=c}isHidden(){return 0===this.opacity&&!this.placed}}class aF{constructor(a,b,c,d,f,g=!1){this.text=new aE(a?a.text:null,b,c,f),this.icon=new aE(a?a.icon:null,b,d,f),this.clipped=g}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class aG{constructor(a,b,c,d=!1){this.text=a,this.icon=b,this.skipFade=c,this.clipped=d}}class aH{constructor(){this.invProjMatrix=a.create(),this.viewportMatrix=a.create(),this.circles=[]}}class aI{constructor(a,b,c,d,f){this.bucketInstanceId=a,this.featureIndex=b,this.sourceLayerIndex=c,this.bucketIndex=d,this.tileID=f}}function aJ(b,c,d,f,g){const{horizontalAlign:h,verticalAlign:i}=a.getAnchorAlignment(b),j=a.evaluateVariableOffset(b,f);return new a.pointGeometry(-(h-.5)*c+j[0]*g,-(i-.5)*d+j[1]*g)}function aK(b,c,d,f,g){const h=new a.pointGeometry(b,c);return d&&h._rotate(f?g:-g),h}function aL(a,b,c,d,f){a.emplaceBack(b?1:0,c?1:0,d||0,f||0),a.emplaceBack(b?1:0,c?1:0,d||0,f||0),a.emplaceBack(b?1:0,c?1:0,d||0,f||0),a.emplaceBack(b?1:0,c?1:0,d||0,f||0)}function aM(a){if(0===a.opacity&&!a.placed)return 0;if(1===a.opacity&&a.placed)return 4294967295;const b=a.placed?1:0,c=Math.floor(127*a.opacity);return 33554432*c+16777216*b+131072*c+65536*b+512*c+256*b+2*c+b}class aN{constructor(a){this._sortAcrossTiles="viewport-y"!==a.layout.get("symbol-z-order")&& void 0!==a.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(a,b,c,d,f){const g=this._bucketParts;for(;this._currentTileIndex<a.length;)if(b.getBucketParts(g,d,a[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,f())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort((a,b)=>a.sortKey-b.sortKey));this._currentPartIndex<g.length;){const h=g[this._currentPartIndex];if(b.placeLayerBucketPart(h,this._seenCrossTileIDs,c,0===h.symbolInstanceStart),this._currentPartIndex++,f())return!0}return!1}}class aO{constructor(b,c,d,f,g,h,i,j){this.placement=new class{constructor(b,c,d,f,g){this.transform=b.clone(),this.collisionIndex=new class{constructor(a,b,c=new an(a.width+200,a.height+200,25),d=new an(a.width+200,a.height+200,25)){this.transform=a,this.grid=c,this.ignoredGrid=d,this.pitchfactor=Math.cos(a._pitch)*a.cameraToCenterDistance,this.screenRightBoundary=a.width+100,this.screenBottomBoundary=a.height+100,this.gridRightBoundary=a.width+200,this.gridBottomBoundary=a.height+200,this.fogState=b}placeCollisionBox(a,b,c,d,f,g,h){let i=b.projectedAnchorX,j=b.projectedAnchorY,k=b.projectedAnchorZ;const l=b.elevation,m=b.tileID;if(l&&m){const n=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),o=n.upVector(m.canonical,b.tileAnchorX,b.tileAnchorY),p=n.upVectorScale(m.canonical);i+=o[0]*l*p,j+=o[1]*l*p,k+=o[2]*l*p}const q=this.projectAndGetPerspectiveRatio(g,i,j,k,b.tileID),r=f*q.perspectiveRatio,s=(b.x1*a+c.x-b.padding)*r+q.point.x,u=(b.y1*a+c.y-b.padding)*r+q.point.y,v=(b.x2*a+c.x+b.padding)*r+q.point.x,w=(b.y2*a+c.y+b.padding)*r+q.point.y,x=q.perspectiveRatio<=.55||q.aboveHorizon;return!this.isInsideGrid(s,u,v,w)|| !d&&this.grid.hitTest(s,u,v,w,h)||x?{box:[],offscreen:!1}:{box:[s,u,v,w],offscreen:this.isOffscreen(s,u,v,w)}}placeCollisionCircles(b,c,d,f,g,h,i,j,k,l,m,n,o,p){const q=[],r=this.transform.elevation,s=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),u=r?r.getAtTileOffsetFunc(p,s):a=>[0,0,0],v=new a.pointGeometry(c.tileAnchorX,c.tileAnchorY),w=this.transform.projection.projectTilePoint(c.tileAnchorX,c.tileAnchorY,p.canonical),x=u(v),y=[w.x+x[0],w.y+x[1],w.z+x[2]],z=this.projectAndGetPerspectiveRatio(h,y[0],y[1],y[2],p),{perspectiveRatio:A}=z,B=(l?g/A:g*A)/a.ONE_EM,C=ar(new a.pointGeometry(y[0],y[1]),i,y[2]).point,D=z.signedDistanceFromCamera>0?av(B,f,c.lineOffsetX*B,c.lineOffsetY*B,!1,C,v,c,d,i,{},r&&!l?u:null,l&&!!r,this.transform.projection,p):null;let E=!1,F=!1,G=!0;if(D&&!z.aboveHorizon){const H=.5*n*A+o,I=new a.pointGeometry(-100,-100),J=new a.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),K=new am,L=D.first,M=D.last;let N=[];for(let O=L.path.length-1;O>=1;O--)N.push(L.path[O]);for(let P=1;P<M.path.length;P++)N.push(M.path[P]);const Q=2.5*H;if(j){const R=N.map(r?(a,b)=>{const c=u(b<L.path.length-1?L.tilePath[L.path.length-1-b]:M.tilePath[b-L.path.length+2]);return ar(a,j,c[2])}:a=>ar(a,j));N=R.some(a=>a.signedDistanceFromCamera<=0)?[]:R.map(a=>a.point)}let S=[];if(N.length>0){const T=N[0].clone(),U=N[0].clone();for(let V=1;V<N.length;V++)T.x=Math.min(T.x,N[V].x),T.y=Math.min(T.y,N[V].y),U.x=Math.max(U.x,N[V].x),U.y=Math.max(U.y,N[V].y);S=T.x>=I.x&&U.x<=J.x&&T.y>=I.y&&U.y<=J.y?[N]:U.x<I.x||T.x>J.x||U.y<I.y||T.y>J.y?[]:a.clipLine([N],I.x,I.y,J.x,J.y)}for(const W of S){K.reset(W,.25*H);let X=0;X=K.length<=.5*H?1:Math.ceil(K.paddedLength/Q)+1;for(let Y=0;Y<X;Y++){const Z=Y/Math.max(X-1,1),$=K.lerp(Z),_=$.x+100,aa=$.y+100;q.push(_,aa,H,0);const ab=_-H,ac=aa-H,ad=_+H,ae=aa+H;if(G=G&&this.isOffscreen(ab,ac,ad,ae),F=F||this.isInsideGrid(ab,ac,ad,ae),!b&&this.grid.hitTestCircle(_,aa,H,m)&&(E=!0,!k))return{circles:[],offscreen:!1,collisionDetected:E}}}}return{circles:(k||!E)&&F?q:[],offscreen:G,collisionDetected:E}}queryRenderedSymbols(b){if(0===b.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const c=[];let d=1/0,f=1/0,g=-1/0,h=-1/0;for(const i of b){const j=new a.pointGeometry(i.x+100,i.y+100);d=Math.min(d,j.x),f=Math.min(f,j.y),g=Math.max(g,j.x),h=Math.max(h,j.y),c.push(j)}const k=this.grid.query(d,f,g,h).concat(this.ignoredGrid.query(d,f,g,h)),l={},m={};for(const n of k){const o=n.key;if(void 0===l[o.bucketInstanceId]&&(l[o.bucketInstanceId]={}),l[o.bucketInstanceId][o.featureIndex])continue;const p=[new a.pointGeometry(n.x1,n.y1),new a.pointGeometry(n.x2,n.y1),new a.pointGeometry(n.x2,n.y2),new a.pointGeometry(n.x1,n.y2),];a.polygonIntersectsPolygon(c,p)&&(l[o.bucketInstanceId][o.featureIndex]=!0,void 0===m[o.bucketInstanceId]&&(m[o.bucketInstanceId]=[]),m[o.bucketInstanceId].push(o.featureIndex))}return m}insertCollisionBox(a,b,c,d,f){(b?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:d,collisionGroupID:f},a[0],a[1],a[2],a[3])}insertCollisionCircles(a,b,c,d,f){const g=b?this.ignoredGrid:this.grid,h={bucketInstanceId:c,featureIndex:d,collisionGroupID:f};for(let i=0;i<a.length;i+=4)g.insertCircle(h,a[i],a[i+1],a[i+2])}projectAndGetPerspectiveRatio(b,c,d,f,g){const h=[c,d,f||0,1];let i=!1;if(f||this.transform.pitch>0){a.transformMat4$1(h,h,b);let j=!1;this.fogState&&g&&(j=function(b,c,d,f,g,h){const i=h.calculateFogTileMatrix(g),j=[c,d,f];return a.transformMat4(j,j,i),w(b,j,h.pitch,h._fov)}(this.fogState,c,d,f||0,g.toUnwrapped(),this.transform)>.9),i=h[2]>h[3]||j}else aD(h,h,b);return{point:new a.pointGeometry((h[0]/h[3]+1)/2*this.transform.width+100,(-h[1]/h[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/h[3]*.5,1.5),signedDistanceFromCamera:h[3],aboveHorizon:i}}isOffscreen(a,b,c,d){return c<100||a>=this.screenRightBoundary||d<100||b>this.screenBottomBoundary}isInsideGrid(a,b,c,d){return c>=0&&a<this.gridRightBoundary&&d>=0&&b<this.gridBottomBoundary}getViewportMatrix(){const b=a.identity([]);return a.translate(b,b,[-100,-100,0]),b}}(this.transform,g),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=c,this.retainedQueryData={},this.collisionGroups=new class{constructor(a){this.crossSourceCollisions=a,this.maxGroupID=0,this.collisionGroups={}}get(a){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[a]){const b=++this.maxGroupID;this.collisionGroups[a]={ID:b,predicate:a=>a.collisionGroupID===b}}return this.collisionGroups[a]}}(d),this.collisionCircleArrays={},this.prevPlacement=f,f&&(f.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(b,c,d,f){const g=d.getBucket(c),h=d.latestFeatureIndex;if(!g||!h||c.id!==g.layerIds[0])return;const i=g.layers[0].layout,j=d.collisionBoxArray,k=Math.pow(2,this.transform.zoom-d.tileID.overscaledZ),l=d.tileSize/a.EXTENT,m=d.tileID.toUnwrapped(),n=this.transform.calculateProjMatrix(m),o="map"===i.get("text-pitch-alignment"),p="map"===i.get("text-rotation-alignment");c.compileFilter();const q=c.dynamicFilter(),r=c.dynamicFilterNeedsFeature(),s=this.transform.calculatePixelsToTileUnitsMatrix(d),u=ap(n,d.tileID.canonical,o,p,this.transform,s);let v=null;if(o){const w=aq(n,d.tileID.canonical,o,p,this.transform,s);v=a.multiply$1([],this.transform.labelPlaneMatrix,w)}let x=null;q&&d.latestFeatureIndex&&(x={unwrappedTileID:m,dynamicFilter:q,dynamicFilterNeedsFeature:r,featureIndex:d.latestFeatureIndex}),this.retainedQueryData[g.bucketInstanceId]=new aI(g.bucketInstanceId,h,g.sourceLayerIndex,g.index,d.tileID);const y={bucket:g,layout:i,posMatrix:n,textLabelPlaneMatrix:u,labelToScreenMatrix:v,clippingData:x,scale:k,textPixelRatio:l,holdingForFade:d.holdingForFade(),collisionBoxArray:j,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(g.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(g.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(g.sourceID)};if(f)for(const z of g.sortKeyRanges){const{sortKey:A,symbolInstanceStart:B,symbolInstanceEnd:C}=z;b.push({sortKey:A,symbolInstanceStart:B,symbolInstanceEnd:C,parameters:y})}else b.push({symbolInstanceStart:0,symbolInstanceEnd:g.symbolInstances.length,parameters:y})}attemptAnchorPlacement(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,r,s){const u=[m.textOffset0,m.textOffset1],v=aJ(a,c,d,u,f),w=this.collisionIndex.placeCollisionBox(f,b,aK(v.x,v.y,g,h,this.transform.angle),l,i,j,k.predicate);if((!q||0!==this.collisionIndex.placeCollisionBox(o.getSymbolInstanceIconSize(s,this.transform.zoom,n),q,aK(v.x,v.y,g,h,this.transform.angle),l,i,j,k.predicate).box.length)&&w.box.length>0){let x;return this.prevPlacement&&this.prevPlacement.variableOffsets[m.crossTileID]&&this.prevPlacement.placements[m.crossTileID]&&this.prevPlacement.placements[m.crossTileID].text&&(x=this.prevPlacement.variableOffsets[m.crossTileID].anchor),this.variableOffsets[m.crossTileID]={textOffset:u,width:c,height:d,anchor:a,textScale:f,prevAnchor:x},this.markUsedJustification(o,a,m,p),o.allowVerticalPlacement&&(this.markUsedOrientation(o,p,m),this.placedOrientations[m.crossTileID]=p),{shift:v,placedGlyphBoxes:w}}}placeLayerBucketPart(b,c,d,f){const{bucket:g,layout:h,posMatrix:i,textLabelPlaneMatrix:j,labelToScreenMatrix:k,clippingData:l,textPixelRatio:m,holdingForFade:n,collisionBoxArray:o,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:q,collisionGroup:r}=b.parameters,s=h.get("text-optional"),u=h.get("icon-optional"),v=h.get("text-allow-overlap"),w=h.get("icon-allow-overlap"),x="map"===h.get("text-rotation-alignment"),y="map"===h.get("text-pitch-alignment"),z="none"!==h.get("icon-text-fit"),A="viewport-y"===h.get("symbol-z-order"),B=v&&(w||!g.hasIconData()||u),C=w&&(v||!g.hasTextData()||s);!g.collisionArrays&&o&&g.deserializeCollisionBoxes(o),d&&f&&g.updateCollisionDebugBuffers(this.transform.zoom,o);const D=(b,f,o)=>{if(l){const A={zoom:this.transform.zoom,pitch:this.transform.pitch};let D=null;if(l.dynamicFilterNeedsFeature){const E=this.retainedQueryData[g.bucketInstanceId];D=l.featureIndex.loadFeature({featureIndex:b.featureIndex,bucketIndex:E.bucketIndex,sourceLayerIndex:E.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,l.dynamicFilter)(A,D,this.retainedQueryData[g.bucketInstanceId].tileID.canonical,new a.pointGeometry(b.tileAnchorX,b.tileAnchorY),this.transform.calculateDistanceTileData(l.unwrappedTileID)))return this.placements[b.crossTileID]=new aG(!1,!1,!1,!0),void(c[b.crossTileID]=!0)}if(c[b.crossTileID])return;if(n)return void(this.placements[b.crossTileID]=new aG(!1,!1,!1));let F=!1,G=!1,H=!0,I=null,J={box:null,offscreen:null},K={box:null,offscreen:null},L=null,M=null,N=null,O=0,P=0,Q=0;o.textFeatureIndex?O=o.textFeatureIndex:b.useRuntimeCollisionCircles&&(O=b.featureIndex),o.verticalTextFeatureIndex&&(P=o.verticalTextFeatureIndex);const R=a=>{a.tileID=this.retainedQueryData[g.bucketInstanceId].tileID,(this.transform.elevation||a.elevation)&&(a.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[g.bucketInstanceId].tileID,a.tileAnchorX,a.tileAnchorY):0)},S=o.textBox;if(S){R(S);const T=c=>{let d=a.WritingMode.horizontal;if(g.allowVerticalPlacement&&!c&&this.prevPlacement){const f=this.prevPlacement.placedOrientations[b.crossTileID];f&&(this.placedOrientations[b.crossTileID]=f,d=f,this.markUsedOrientation(g,d,b))}return d},U=(c,d)=>{if(g.allowVerticalPlacement&&b.numVerticalGlyphVertices>0&&o.verticalTextBox){for(const f of g.writingModes)if(f===a.WritingMode.vertical?K=J=d():J=c(),J&&J.box&&J.box.length)break}else J=c()};if(h.get("text-variable-anchor")){let V=h.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[b.crossTileID]){const W=this.prevPlacement.variableOffsets[b.crossTileID];V.indexOf(W.anchor)>0&&(V=V.filter(a=>a!==W.anchor)).unshift(W.anchor)}const X=(a,c,d)=>{const h=g.getSymbolInstanceTextSize(p,b,this.transform.zoom,f),j=(a.x2-a.x1)*h+2*a.padding,k=(a.y2-a.y1)*h+2*a.padding,l=z&&!w?c:null;l&&R(l);let n={box:[],offscreen:!1};const o=v?2*V.length:V.length;for(let s=0;s<o;++s){const u=this.attemptAnchorPlacement(V[s%V.length],a,j,k,h,x,y,m,i,r,s>=V.length,b,f,g,d,l,p,q);if(u&&(n=u.placedGlyphBoxes)&&n.box&&n.box.length){F=!0,I=u.shift;break}}return n};U(()=>X(S,o.iconBox,a.WritingMode.horizontal),()=>{const c=o.verticalTextBox;return c&&R(c),g.allowVerticalPlacement&&!(J&&J.box&&J.box.length)&&b.numVerticalGlyphVertices>0&&c?X(c,o.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null}}),J&&(F=J.box,H=J.offscreen);const Y=T(J&&J.box);if(!F&&this.prevPlacement){const Z=this.prevPlacement.variableOffsets[b.crossTileID];Z&&(this.variableOffsets[b.crossTileID]=Z,this.markUsedJustification(g,Z.anchor,b,Y))}}else{const $=(c,d)=>{const h=g.getSymbolInstanceTextSize(p,b,this.transform.zoom,f),j=this.collisionIndex.placeCollisionBox(h,c,new a.pointGeometry(0,0),v,m,i,r.predicate);return j&&j.box&&j.box.length&&(this.markUsedOrientation(g,d,b),this.placedOrientations[b.crossTileID]=d),j};U(()=>$(S,a.WritingMode.horizontal),()=>{const c=o.verticalTextBox;return g.allowVerticalPlacement&&b.numVerticalGlyphVertices>0&&c?(R(c),$(c,a.WritingMode.vertical)):{box:null,offscreen:null}}),T(J&&J.box&&J.box.length)}}if(F=(L=J)&&L.box&&L.box.length>0,H=L&&L.offscreen,b.useRuntimeCollisionCircles){const _=g.text.placedSymbolArray.get(b.centerJustifiedTextSymbolIndex>=0?b.centerJustifiedTextSymbolIndex:b.verticalPlacedTextSymbolIndex),aa=a.evaluateSizeForFeature(g.textSizeData,p,_),ab=h.get("text-padding");M=this.collisionIndex.placeCollisionCircles(v,_,g.lineVertexArray,g.glyphOffsetArray,aa,i,j,k,d,y,r.predicate,b.collisionCircleDiameter*aa/a.ONE_EM,ab,this.retainedQueryData[g.bucketInstanceId].tileID),F=v||M.circles.length>0&&!M.collisionDetected,H=H&&M.offscreen}if(o.iconFeatureIndex&&(Q=o.iconFeatureIndex),o.iconBox){const ac=b=>{R(b);const c=z&&I?aK(I.x,I.y,x,y,this.transform.angle):new a.pointGeometry(0,0),d=g.getSymbolInstanceIconSize(q,this.transform.zoom,f);return this.collisionIndex.placeCollisionBox(d,b,c,w,m,i,r.predicate)};G=K&&K.box&&K.box.length&&o.verticalIconBox?(N=ac(o.verticalIconBox)).box.length>0:(N=ac(o.iconBox)).box.length>0,H=H&&N.offscreen}const ad=s||0===b.numHorizontalGlyphVertices&&0===b.numVerticalGlyphVertices,ae=u||0===b.numIconVertices;if(ad||ae?ae?ad||(G=G&&F):F=G&&F:G=F=G&&F,F&&L&&L.box&&this.collisionIndex.insertCollisionBox(L.box,h.get("text-ignore-placement"),g.bucketInstanceId,K&&K.box&&P?P:O,r.ID),G&&N&&this.collisionIndex.insertCollisionBox(N.box,h.get("icon-ignore-placement"),g.bucketInstanceId,Q,r.ID),M&&(F&&this.collisionIndex.insertCollisionCircles(M.circles,h.get("text-ignore-placement"),g.bucketInstanceId,O,r.ID),d)){const af=g.bucketInstanceId;let ag=this.collisionCircleArrays[af];void 0===ag&&(ag=this.collisionCircleArrays[af]=new aH);for(let ah=0;ah<M.circles.length;ah+=4)ag.circles.push(M.circles[ah+0]),ag.circles.push(M.circles[ah+1]),ag.circles.push(M.circles[ah+2]),ag.circles.push(M.collisionDetected?1:0)}this.placements[b.crossTileID]=new aG(F||B,G||C,H||g.justReloaded),c[b.crossTileID]=!0};if(A){const E=g.getSortedSymbolIndexes(this.transform.angle);for(let F=E.length-1;F>=0;--F){const G=E[F];D(g.symbolInstances.get(G),G,g.collisionArrays[G])}}else for(let H=b.symbolInstanceStart;H<b.symbolInstanceEnd;H++)D(g.symbolInstances.get(H),H,g.collisionArrays[H]);if(d&&g.bucketInstanceId in this.collisionCircleArrays){const I=this.collisionCircleArrays[g.bucketInstanceId];a.invert(I.invProjMatrix,i),I.viewportMatrix=this.collisionIndex.getViewportMatrix()}g.justReloaded=!1}markUsedJustification(b,c,d,f){let g;g=f===a.WritingMode.vertical?d.verticalPlacedTextSymbolIndex:({left:d.leftJustifiedTextSymbolIndex,center:d.centerJustifiedTextSymbolIndex,right:d.rightJustifiedTextSymbolIndex})[a.getAnchorJustification(c)];const h=[d.leftJustifiedTextSymbolIndex,d.centerJustifiedTextSymbolIndex,d.rightJustifiedTextSymbolIndex,d.verticalPlacedTextSymbolIndex,];for(const i of h)i>=0&&(b.text.placedSymbolArray.get(i).crossTileID=g>=0&&i!==g?0:d.crossTileID)}markUsedOrientation(b,c,d){const f=c===a.WritingMode.horizontal||c===a.WritingMode.horizontalOnly?c:0,g=c===a.WritingMode.vertical?c:0,h=[d.leftJustifiedTextSymbolIndex,d.centerJustifiedTextSymbolIndex,d.rightJustifiedTextSymbolIndex,];for(const i of h)b.text.placedSymbolArray.get(i).placedOrientation=f;d.verticalPlacedTextSymbolIndex&&(b.text.placedSymbolArray.get(d.verticalPlacedTextSymbolIndex).placedOrientation=g)}commit(a){this.commitTime=a,this.zoomAtLastRecencyCheck=this.transform.zoom;const b=this.prevPlacement;let c=!1;this.prevZoomAdjustment=b?b.zoomAdjustment(this.transform.zoom):0;const d=b?b.symbolFadeChange(a):1,f=b?b.opacities:{},g=b?b.variableOffsets:{},h=b?b.placedOrientations:{};for(const i in this.placements){const j=this.placements[i],k=f[i];k?(this.opacities[i]=new aF(k,d,j.text,j.icon,null,j.clipped),c=c||j.text!==k.text.placed||j.icon!==k.icon.placed):(this.opacities[i]=new aF(null,d,j.text,j.icon,j.skipFade,j.clipped),c=c||j.text||j.icon)}for(const l in f){const m=f[l];if(!this.opacities[l]){const n=new aF(m,d,!1,!1);n.isHidden()||(this.opacities[l]=n,c=c||m.text.placed||m.icon.placed)}}for(const o in g)this.variableOffsets[o]||!this.opacities[o]||this.opacities[o].isHidden()||(this.variableOffsets[o]=g[o]);for(const p in h)this.placedOrientations[p]||!this.opacities[p]||this.opacities[p].isHidden()||(this.placedOrientations[p]=h[p]);c?this.lastPlacementChangeTime=a:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=b?b.lastPlacementChangeTime:a)}updateLayerOpacities(a,b){const c={};for(const d of b){const f=d.getBucket(a);f&&d.latestFeatureIndex&&a.id===f.layerIds[0]&&this.updateBucketOpacities(f,c,d.collisionBoxArray)}}updateBucketOpacities(b,c,d){b.hasTextData()&&b.text.opacityVertexArray.clear(),b.hasIconData()&&b.icon.opacityVertexArray.clear(),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexArray.clear(),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexArray.clear();const f=b.layers[0].layout,g=!!b.layers[0].dynamicFilter(),h=new aF(null,0,!1,!1,!0),i=f.get("text-allow-overlap"),j=f.get("icon-allow-overlap"),k=f.get("text-variable-anchor"),l="map"===f.get("text-rotation-alignment"),m="map"===f.get("text-pitch-alignment"),n="none"!==f.get("icon-text-fit"),o=new aF(null,0,i&&(j||!b.hasIconData()||f.get("icon-optional")),j&&(i||!b.hasTextData()||f.get("text-optional")),!0);!b.collisionArrays&&d&&(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData())&&b.deserializeCollisionBoxes(d);const p=(a,b,c)=>{for(let d=0;d<b/4;d++)a.opacityVertexArray.emplaceBack(c)};let q=0;for(let r=0;r<b.symbolInstances.length;r++){const s=b.symbolInstances.get(r),{numHorizontalGlyphVertices:u,numVerticalGlyphVertices:v,crossTileID:w}=s;let x=this.opacities[w];c[w]?x=h:x||(x=o,this.opacities[w]=x),c[w]=!0;const y=u>0||v>0,z=s.numIconVertices>0,A=this.placedOrientations[s.crossTileID],B=A===a.WritingMode.vertical,C=A===a.WritingMode.horizontal||A===a.WritingMode.horizontalOnly;if(!y&&!z||x.isHidden()||q++,y){const D=aM(x.text);p(b.text,u,B?0:D),p(b.text,v,C?0:D);const E=x.text.isHidden();[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex,].forEach(a=>{a>=0&&(b.text.placedSymbolArray.get(a).hidden=E||B?1:0)}),s.verticalPlacedTextSymbolIndex>=0&&(b.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).hidden=E||C?1:0);const F=this.variableOffsets[s.crossTileID];F&&this.markUsedJustification(b,F.anchor,s,A);const G=this.placedOrientations[s.crossTileID];G&&(this.markUsedJustification(b,"left",s,G),this.markUsedOrientation(b,G,s))}if(z){const H=aM(x.icon);s.placedIconSymbolIndex>=0&&(p(b.icon,s.numIconVertices,B?0:H),b.icon.placedSymbolArray.get(s.placedIconSymbolIndex).hidden=x.icon.isHidden()),s.verticalPlacedIconSymbolIndex>=0&&(p(b.icon,s.numVerticalIconVertices,C?0:H),b.icon.placedSymbolArray.get(s.verticalPlacedIconSymbolIndex).hidden=x.icon.isHidden())}if(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData()){const I=b.collisionArrays[r];if(I){let J=new a.pointGeometry(0,0),K=!0;if(I.textBox||I.verticalTextBox){if(k){const L=this.variableOffsets[w];L?(J=aJ(L.anchor,L.width,L.height,L.textOffset,L.textScale),l&&J._rotate(m?this.transform.angle:-this.transform.angle)):K=!1}g&&(K=!x.clipped),I.textBox&&aL(b.textCollisionBox.collisionVertexArray,x.text.placed,!K||B,J.x,J.y),I.verticalTextBox&&aL(b.textCollisionBox.collisionVertexArray,x.text.placed,!K||C,J.x,J.y)}const M=K&&Boolean(!C&&I.verticalIconBox);I.iconBox&&aL(b.iconCollisionBox.collisionVertexArray,x.icon.placed,M,n?J.x:0,n?J.y:0),I.verticalIconBox&&aL(b.iconCollisionBox.collisionVertexArray,x.icon.placed,!M,n?J.x:0,n?J.y:0)}}}if(b.fullyClipped=0===q,b.sortFeatures(this.transform.angle),this.retainedQueryData[b.bucketInstanceId]&&(this.retainedQueryData[b.bucketInstanceId].featureSortOrder=b.featureSortOrder),b.hasTextData()&&b.text.opacityVertexBuffer&&b.text.opacityVertexBuffer.updateData(b.text.opacityVertexArray),b.hasIconData()&&b.icon.opacityVertexBuffer&&b.icon.opacityVertexBuffer.updateData(b.icon.opacityVertexArray),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexBuffer&&b.iconCollisionBox.collisionVertexBuffer.updateData(b.iconCollisionBox.collisionVertexArray),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexBuffer&&b.textCollisionBox.collisionVertexBuffer.updateData(b.textCollisionBox.collisionVertexArray),b.bucketInstanceId in this.collisionCircleArrays){const N=this.collisionCircleArrays[b.bucketInstanceId];b.placementInvProjMatrix=N.invProjMatrix,b.placementViewportMatrix=N.viewportMatrix,b.collisionCircleArray=N.circles,delete this.collisionCircleArrays[b.bucketInstanceId]}}symbolFadeChange(a){return 0===this.fadeDuration?1:(a-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(a){return Math.max(0,(this.transform.zoom-a)/1.5)}hasTransitions(a){return this.stale||a-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(a,b){const c=this.zoomAtLastRecencyCheck===b?1-this.zoomAdjustment(b):1;return this.zoomAtLastRecencyCheck=b,this.commitTime+this.fadeDuration*c>a}setStale(){this.stale=!0}}(b,g,h,i,j),this._currentPlacementIndex=c.length-1,this._forceFullPlacement=d,this._showCollisionBoxes=f,this._done=!1}isDone(){return this._done}continuePlacement(b,c,d){const f=a.exported.now(),g=()=>{const b=a.exported.now()-f;return!this._forceFullPlacement&&b>2};for(;this._currentPlacementIndex>=0;){const h=c[b[this._currentPlacementIndex]],i=this.placement.collisionIndex.transform.zoom;if("symbol"===h.type&&(!h.minzoom||h.minzoom<=i)&&(!h.maxzoom||h.maxzoom>i)){if(this._inProgressLayer||(this._inProgressLayer=new aN(h)),this._inProgressLayer.continuePlacement(d[h.source],this.placement,this._showCollisionBoxes,h,g))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(a){return this.placement.commit(a),this.placement}}const aP=512/a.EXTENT/2;class aQ{constructor(a,b,c){this.tileID=a,this.indexedSymbolInstances={},this.bucketInstanceId=c;for(let d=0;d<b.length;d++){const f=b.get(d),g=f.key;this.indexedSymbolInstances[g]||(this.indexedSymbolInstances[g]=[]),this.indexedSymbolInstances[g].push({crossTileID:f.crossTileID,coord:this.getScaledCoordinates(f,a)})}}getScaledCoordinates(b,c){const d=aP/Math.pow(2,c.canonical.z-this.tileID.canonical.z);return{x:Math.floor((c.canonical.x*a.EXTENT+b.tileAnchorX)*d),y:Math.floor((c.canonical.y*a.EXTENT+b.tileAnchorY)*d)}}findMatches(a,b,c){const d=this.tileID.canonical.z<b.canonical.z?1:Math.pow(2,this.tileID.canonical.z-b.canonical.z);for(let f=0;f<a.length;f++){const g=a.get(f);if(g.crossTileID)continue;const h=this.indexedSymbolInstances[g.key];if(!h)continue;const i=this.getScaledCoordinates(g,b);for(const j of h)if(Math.abs(j.coord.x-i.x)<=d&&Math.abs(j.coord.y-i.y)<=d&&!c[j.crossTileID]){c[j.crossTileID]=!0,g.crossTileID=j.crossTileID;break}}}}class aR{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(a){const b=Math.round((a-this.lng)/360);if(0!==b)for(const c in this.indexes){const d=this.indexes[c],f={};for(const g in d){const h=d[g];h.tileID=h.tileID.unwrapTo(h.tileID.wrap+b),f[h.tileID.key]=h}this.indexes[c]=f}this.lng=a}addBucket(a,b,c){if(this.indexes[a.overscaledZ]&&this.indexes[a.overscaledZ][a.key]){if(this.indexes[a.overscaledZ][a.key].bucketInstanceId===b.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(a.overscaledZ,this.indexes[a.overscaledZ][a.key])}for(let d=0;d<b.symbolInstances.length;d++)b.symbolInstances.get(d).crossTileID=0;this.usedCrossTileIDs[a.overscaledZ]||(this.usedCrossTileIDs[a.overscaledZ]={});const f=this.usedCrossTileIDs[a.overscaledZ];for(const g in this.indexes){const h=this.indexes[g];if(Number(g)>a.overscaledZ)for(const i in h){const j=h[i];j.tileID.isChildOf(a)&&j.findMatches(b.symbolInstances,a,f)}else{const k=h[a.scaledTo(Number(g)).key];k&&k.findMatches(b.symbolInstances,a,f)}}for(let l=0;l<b.symbolInstances.length;l++){const m=b.symbolInstances.get(l);m.crossTileID||(m.crossTileID=c.generate(),f[m.crossTileID]=!0)}return void 0===this.indexes[a.overscaledZ]&&(this.indexes[a.overscaledZ]={}),this.indexes[a.overscaledZ][a.key]=new aQ(a,b.symbolInstances,b.bucketInstanceId),!0}removeBucketCrossTileIDs(a,b){for(const c in b.indexedSymbolInstances)for(const d of b.indexedSymbolInstances[c])delete this.usedCrossTileIDs[a][d.crossTileID]}removeStaleBuckets(a){let b=!1;for(const c in this.indexes){const d=this.indexes[c];for(const f in d)a[d[f].bucketInstanceId]||(this.removeBucketCrossTileIDs(c,d[f]),delete d[f],b=!0)}return b}}class aS{constructor(){this.layerIndexes={},this.crossTileIDs=new class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(a,b,c,d){let f=this.layerIndexes[a.id];void 0===f&&(f=this.layerIndexes[a.id]=new aR);let g=!1;const h={};for(const i of("globe"!==d.name&&f.handleWrapJump(c),b)){const j=i.getBucket(a);j&&a.id===j.layerIds[0]&&(j.bucketInstanceId||(j.bucketInstanceId=++this.maxBucketInstanceId),f.addBucket(i.tileID,j,this.crossTileIDs)&&(g=!0),h[j.bucketInstanceId]=!0)}return f.removeStaleBuckets(h)&&(g=!0),g}pruneUnusedLayers(a){const b={};for(const c in a.forEach(a=>{b[a]=!0}),this.layerIndexes)b[c]||delete this.layerIndexes[c]}}const aT=(b,c)=>a.emitValidationErrors(b,c&&c.filter(a=>"source.canvas"!==a.identifier)),aU=a.pick(ae,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection",]),aV=a.pick(ae,["setCenter","setZoom","setBearing","setPitch",]),aW=function(){const b={},c=a.spec.$version;for(const d in a.spec.$root){const f=a.spec.$root[d];if(f.required){let g=null;null!=(g="version"===d?c:"array"===f.type?[]:{})&&(b[d]=g)}}return b}(),aX={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class aY extends a.Evented{constructor(b,c={}){super(),this.map=b,this.dispatcher=new B(ab(),this),this.imageManager=new o,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(b._requestManager,c.localFontFamily?a.LocalGlyphMode.all:c.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,c.localFontFamily||c.localIdeographFontFamily),this.lineAtlas=new a.LineAtlas(256,512),this.crossTileSymbolIndex=new aS,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());const d=this;this._rtlTextPluginCallback=aY.registerForPluginStateChange(b=>{d.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:b.pluginStatus,pluginURL:b.pluginURL},(b,c)=>{if(a.triggerPluginCompletionEvent(b),c&&c.every(a=>a))for(const f in d._sourceCaches){const g=d._sourceCaches[f],h=g.getSource().type;"vector"!==h&&"geojson"!==h||g.reload()}})}),this.on("data",a=>{if("source"!==a.dataType||"metadata"!==a.sourceDataType)return;const b=this.getSource(a.sourceId);if(b&&b.vectorLayerIds)for(const c in this._layers){const d=this._layers[c];d.source===b.id&&this._validateLayer(d)}})}loadURL(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"}));const d="boolean"==typeof c.validate?c.validate:!a.isMapboxURL(b);b=this.map._requestManager.normalizeStyleURL(b,c.accessToken);const f=this.map._requestManager.transformRequest(b,a.ResourceType.Style);this._request=a.getJSON(f,(b,c)=>{this._request=null,b?this.fire(new a.ErrorEvent(b)):c&&this._load(c,d)})}loadJSON(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(b,!1!==c.validate)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(aW,!1)}_updateLayerCount(a,b){const c=b?1:-1;a.is3D()&&(this._num3DLayers+=c),"circle"===a.type&&(this._numCircleLayers+=c),"symbol"===a.type&&(this._numSymbolLayers+=c)}_load(b,c){if(c&&aT(this,a.validateStyle(b)))return;for(const d in this._loaded=!0,this.stylesheet=b,this.updateProjection(),b.sources)this.addSource(d,b.sources[d],{validate:!1});this._changed=!1,b.sprite?this._loadSprite(b.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(b.glyphs);const f=ad(this.stylesheet.layers);for(let g of(this._order=f.map(a=>a.id),this._layers={},this._serializedLayers={},f))(g=a.createStyleLayer(g)).setEventedParent(this,{layer:{id:g.id}}),this._layers[g.id]=g,this._serializedLayers[g.id]=g.serialize(),this._updateLayerCount(g,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new r(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&&0===this.terrain.drapeRenderMode}setProjection(a){a?this.stylesheet.projection=a:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const a=this.map.transform.projection,b=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),c=this.map.transform.projection;if(this._loaded&&(c.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),b){if(c.isReprojectedInTileSpace||a.isReprojectedInTileSpace)for(const d in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[d].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(b){this._spriteRequest=function(b,c,d){let f,g,h;const i=a.exported.devicePixelRatio>1?"@2x":"";let j=a.getJSON(c.transformRequest(c.normalizeSpriteURL(b,i,".json"),a.ResourceType.SpriteJSON),(a,b)=>{j=null,h||(h=a,f=b,l())}),k=a.getImage(c.transformRequest(c.normalizeSpriteURL(b,i,".png"),a.ResourceType.SpriteImage),(a,b)=>{k=null,h||(h=a,g=b,l())});function l(){if(h)d(h);else if(f&&g){const b=a.exported.getImageData(g),c={};for(const i in f){const{width:j,height:k,x:l,y:m,sdf:n,pixelRatio:o,stretchX:p,stretchY:q,content:r}=f[i],s=new a.RGBAImage({width:j,height:k});a.RGBAImage.copy(b,s,{x:l,y:m},{x:0,y:0},{width:j,height:k}),c[i]={data:s,pixelRatio:o,sdf:n,stretchX:p,stretchY:q,content:r}}d(null,c)}}return{cancel(){j&&(j.cancel(),j=null),k&&(k.cancel(),k=null)}}}(b,this.map._requestManager,(b,c)=>{if(this._spriteRequest=null,b)this.fire(new a.ErrorEvent(b));else if(c)for(const d in c)this.imageManager.addImage(d,c[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(b){const c=this.getSource(b.source);if(!c)return;const d=b.sourceLayer;d&&("geojson"===c.type||c.vectorLayerIds&& -1===c.vectorLayerIds.indexOf(d))&&this.fire(new a.ErrorEvent(Error(`Source layer "${d}" does not exist on source "${c.id}" as specified by style layer "${b.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const a in this._sourceCaches)if(!this._sourceCaches[a].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(a){const b=[];for(const c of a){const d=this._layers[c];"custom"!==d.type&&b.push(d.serialize())}return b}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const a in this._sourceCaches)if(this._sourceCaches[a].hasTransition())return!0;for(const b in this._layers)if(this._layers[b].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(a){return!!this.terrain&&aX[a.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(b){if(!this._loaded)return;const c=this._changed;if(this._changed){const d=Object.keys(this._updatedLayers),f=Object.keys(this._removedLayers);for(const g in(d.length||f.length)&&this._updateWorkerLayers(d,f),this._updatedSources){const h=this._updatedSources[g];"reload"===h?this._reloadSource(g):"clear"===h&&this._clearSource(g)}for(const i in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[i].updateTransitions(b);this.light.updateTransitions(b),this.fog&&this.fog.updateTransitions(b),this._resetUpdates()}const j={};for(const k in this._sourceCaches){const l=this._sourceCaches[k];j[k]=l.used,l.used=!1}for(const m of this._order){const n=this._layers[m];if(n.recalculate(b,this._availableImages),!n.isHidden(b.zoom)){const o=this._getLayerSourceCache(n);o&&(o.used=!0)}const p=this.map.painter;if(p){const q=n.getProgramIds();if(!q)continue;const r=n.getProgramConfiguration(b.zoom);for(const s of q)p.useProgram(s,r)}}for(const u in j){const v=this._sourceCaches[u];j[u]!==v.used&&v.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:v.getSource().id}))}this.light.recalculate(b),this.terrain&&this.terrain.recalculate(b),this.fog&&this.fog.recalculate(b),this.z=b.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),c&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const a=Object.keys(this._changedImages);if(a.length){for(const b in this._sourceCaches)this._sourceCaches[b].reloadTilesForDependencies(["icons","patterns"],a);this._changedImages={}}}_updateWorkerLayers(a,b){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(a),removedIds:b})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(b){if(this._checkLoaded(),aT(this,a.validateStyle(b)))return!1;(b=a.clone$1(b)).layers=ad(b.layers);const c=(function(a,b){if(!a)return[{command:ae.setStyle,args:[b]},];let c=[];try{if(!g(a.version,b.version))return[{command:ae.setStyle,args:[b]},];g(a.center,b.center)||c.push({command:ae.setCenter,args:[b.center]}),g(a.zoom,b.zoom)||c.push({command:ae.setZoom,args:[b.zoom]}),g(a.bearing,b.bearing)||c.push({command:ae.setBearing,args:[b.bearing]}),g(a.pitch,b.pitch)||c.push({command:ae.setPitch,args:[b.pitch]}),g(a.sprite,b.sprite)||c.push({command:ae.setSprite,args:[b.sprite]}),g(a.glyphs,b.glyphs)||c.push({command:ae.setGlyphs,args:[b.glyphs]}),g(a.transition,b.transition)||c.push({command:ae.setTransition,args:[b.transition]}),g(a.light,b.light)||c.push({command:ae.setLight,args:[b.light]}),g(a.fog,b.fog)||c.push({command:ae.setFog,args:[b.fog]}),g(a.projection,b.projection)||c.push({command:ae.setProjection,args:[b.projection]});const d={},f=[];!function(a,b,c,d){let f;for(f in b=b||{},a=a||{})a.hasOwnProperty(f)&&(b.hasOwnProperty(f)||ag(f,c,d));for(f in b)b.hasOwnProperty(f)&&(a.hasOwnProperty(f)?g(a[f],b[f])||("geojson"===a[f].type&&"geojson"===b[f].type&&ai(a,b,f)?c.push({command:ae.setGeoJSONSourceData,args:[f,b[f].data,]}):ah(f,b,c,d)):af(f,b,c))}(a.sources,b.sources,f,d);const h=[];a.layers&&a.layers.forEach(a=>{d[a.source]?c.push({command:ae.removeLayer,args:[a.id]}):h.push(a)});let i=a.terrain;i&&d[i.source]&&(c.push({command:ae.setTerrain,args:[void 0]}),i=void 0),c=c.concat(f),g(i,b.terrain)||c.push({command:ae.setTerrain,args:[b.terrain]}),function(a,b,c){b=b||[];const d=(a=a||[]).map(ak),f=b.map(ak),h=a.reduce(al,{}),i=b.reduce(al,{}),j=d.slice(),k=Object.create(null);let l,m,n,o,p,q,r;for(l=0,m=0;l<d.length;l++)n=d[l],i.hasOwnProperty(n)?m++:(c.push({command:ae.removeLayer,args:[n]}),j.splice(j.indexOf(n,m),1));for(l=0,m=0;l<f.length;l++)n=f[f.length-1-l],j[j.length-1-l]!==n&&(h.hasOwnProperty(n)?(c.push({command:ae.removeLayer,args:[n]}),j.splice(j.lastIndexOf(n,j.length-m),1)):m++,q=j[j.length-l],c.push({command:ae.addLayer,args:[i[n],q]}),j.splice(j.length-l,0,n),k[n]=!0);for(l=0;l<f.length;l++)if(o=h[n=f[l]],p=i[n],!k[n]&&!g(o,p)){if(g(o.source,p.source)&&g(o["source-layer"],p["source-layer"])&&g(o.type,p.type)){for(r in aj(o.layout,p.layout,c,n,null,ae.setLayoutProperty),aj(o.paint,p.paint,c,n,null,ae.setPaintProperty),g(o.filter,p.filter)||c.push({command:ae.setFilter,args:[n,p.filter,]}),g(o.minzoom,p.minzoom)&&g(o.maxzoom,p.maxzoom)||c.push({command:ae.setLayerZoomRange,args:[n,p.minzoom,p.maxzoom,]}),o)o.hasOwnProperty(r)&&"layout"!==r&&"paint"!==r&&"filter"!==r&&"metadata"!==r&&"minzoom"!==r&&"maxzoom"!==r&&(0===r.indexOf("paint.")?aj(o[r],p[r],c,n,r.slice(6),ae.setPaintProperty):g(o[r],p[r])||c.push({command:ae.setLayerProperty,args:[n,r,p[r],]}));for(r in p)p.hasOwnProperty(r)&&!o.hasOwnProperty(r)&&"layout"!==r&&"paint"!==r&&"filter"!==r&&"metadata"!==r&&"minzoom"!==r&&"maxzoom"!==r&&(0===r.indexOf("paint.")?aj(o[r],p[r],c,n,r.slice(6),ae.setPaintProperty):g(o[r],p[r])||c.push({command:ae.setLayerProperty,args:[n,r,p[r],]}))}else c.push({command:ae.removeLayer,args:[n]}),q=j[j.lastIndexOf(n)+1],c.push({command:ae.addLayer,args:[p,q,]})}}(h,b.layers,c)}catch(j){console.warn("Unable to compute style diff:",j),c=[{command:ae.setStyle,args:[b]},]}return c})(this.serialize(),b).filter(a=>!(a.command in aV));if(0===c.length)return!1;const d=c.filter(a=>!(a.command in aU));if(d.length>0)throw Error(`Unimplemented: ${d.map(a=>a.command).join(", ")}.`);return c.forEach(a=>{"setTransition"!==a.command&&this[a.command].apply(this,a.args)}),this.stylesheet=b,this.updateProjection(),!0}addImage(b,c){if(this.getImage(b))return this.fire(new a.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(b,c),this._afterImageUpdated(b)}updateImage(a,b){this.imageManager.updateImage(a,b)}getImage(a){return this.imageManager.getImage(a)}removeImage(b){if(!this.getImage(b))return this.fire(new a.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(b),this._afterImageUpdated(b)}_afterImageUpdated(b){this._availableImages=this.imageManager.listImages(),this._changedImages[b]=!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(b,c,d={}){if(this._checkLoaded(),void 0!==this.getSource(b))throw Error("There is already a source with this ID");if(!c.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(c).join(", ")}.`);if(["vector","raster","geojson","video","image",].indexOf(c.type)>=0&&this._validate(a.validateStyle.source,`sources.${b}`,c,null,d))return;this.map&&this.map._collectResourceTiming&&(c.collectResourceTiming=!0);const f=U(b,c,this.dispatcher,this);f.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:f.serialize(),sourceId:b}));const g=c=>{const d=(c?"symbol:":"other:")+b,g=this._sourceCaches[d]=new a.SourceCache(d,f,c);(c?this._symbolSourceCaches:this._otherSourceCaches)[b]=g,g.style=this,g.onAdd(this.map)};g(!1),"vector"!==c.type&&"geojson"!==c.type||g(!0),f.onAdd&&f.onAdd(this.map),this._changed=!0}removeSource(b){this._checkLoaded();const c=this.getSource(b);if(void 0===c)throw Error("There is no source with this ID");for(const d in this._layers)if(this._layers[d].source===b)return this.fire(new a.ErrorEvent(Error(`Source "${b}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.get().source===b)return this.fire(new a.ErrorEvent(Error(`Source "${b}" cannot be removed while terrain is using it.`)));const f=this._getSourceCaches(b);for(const g of f)delete this._sourceCaches[g.id],delete this._updatedSources[g.id],g.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:g.getSource().id})),g.setEventedParent(null),g.clearTiles();delete this._otherSourceCaches[b],delete this._symbolSourceCaches[b],c.setEventedParent(null),c.onRemove&&c.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(a,b){this._checkLoaded(),this.getSource(a).setData(b),this._changed=!0}getSource(a){const b=this._getSourceCache(a);return b&&b.getSource()}addLayer(b,c,d={}){this._checkLoaded();const f=b.id;if(this.getLayer(f))return void this.fire(new a.ErrorEvent(Error(`Layer with id "${f}" already exists on this map`)));let g;if("custom"===b.type){if(aT(this,a.validateCustomStyleLayer(b)))return;g=a.createStyleLayer(b)}else{if("object"==typeof b.source&&(this.addSource(f,b.source),b=a.clone$1(b),b=a.extend(b,{source:f})),this._validate(a.validateStyle.layer,`layers.${f}`,b,{arrayIndex:-1},d))return;g=a.createStyleLayer(b),this._validateLayer(g),g.setEventedParent(this,{layer:{id:f}}),this._serializedLayers[g.id]=g.serialize(),this._updateLayerCount(g,!0)}const h=c?this._order.indexOf(c):this._order.length;if(c&& -1===h)return void this.fire(new a.ErrorEvent(Error(`Layer with id "${c}" does not exist on this map.`)));this._order.splice(h,0,f),this._layerOrderChanged=!0,this._layers[f]=g;const i=this._getLayerSourceCache(g);if(this._removedLayers[f]&&g.source&&i&&"custom"!==g.type){const j=this._removedLayers[f];delete this._removedLayers[f],j.type!==g.type?this._updatedSources[g.source]="clear":(this._updatedSources[g.source]="reload",i.pause())}this._updateLayer(g),g.onAdd&&g.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(b,c){if(this._checkLoaded(),this._changed=!0,!this._layers[b])return void this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style and cannot be moved.`)));if(b===c)return;const d=this._order.indexOf(b);this._order.splice(d,1);const f=c?this._order.indexOf(c):this._order.length;c&& -1===f?this.fire(new a.ErrorEvent(Error(`Layer with id "${c}" does not exist on this map.`))):(this._order.splice(f,0,b),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(b){this._checkLoaded();const c=this._layers[b];if(!c)return void this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style and cannot be removed.`)));c.setEventedParent(null),this._updateLayerCount(c,!1);const d=this._order.indexOf(b);this._order.splice(d,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[b]=c,delete this._layers[b],delete this._serializedLayers[b],delete this._updatedLayers[b],delete this._updatedPaintProps[b],c.onRemove&&c.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(a){return this._layers[a]}hasLayer(a){return a in this._layers}hasLayerType(a){for(const b in this._layers)if(this._layers[b].type===a)return!0;return!1}setLayerZoomRange(b,c,d){this._checkLoaded();const f=this.getLayer(b);f?f.minzoom===c&&f.maxzoom===d||(null!=c&&(f.minzoom=c),null!=d&&(f.maxzoom=d),this._updateLayer(f)):this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(b,c,d={}){this._checkLoaded();const f=this.getLayer(b);if(f){if(!g(f.filter,c))return null==c?(f.filter=void 0,void this._updateLayer(f)):void(this._validate(a.validateStyle.filter,`layers.${f.id}.filter`,c,{layerType:f.type},d)||(f.filter=a.clone$1(c),this._updateLayer(f)))}else this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style and cannot be filtered.`)))}getFilter(b){return a.clone$1(this.getLayer(b).filter)}setLayoutProperty(b,c,d,f={}){this._checkLoaded();const h=this.getLayer(b);h?g(h.getLayoutProperty(c),d)||(h.setLayoutProperty(c,d,f),this._updateLayer(h)):this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(b,c){const d=this.getLayer(b);if(d)return d.getLayoutProperty(c);this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style.`)))}setPaintProperty(b,c,d,f={}){this._checkLoaded();const h=this.getLayer(b);h?g(h.getPaintProperty(c),d)||(h.setPaintProperty(c,d,f)&&this._updateLayer(h),this._changed=!0,this._updatedPaintProps[b]=!0):this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(a,b){return this.getLayer(a).getPaintProperty(b)}setFeatureState(b,c){this._checkLoaded();const d=b.source,f=b.sourceLayer,g=this.getSource(d);if(void 0===g)return void this.fire(new a.ErrorEvent(Error(`The source '${d}' does not exist in the map's style.`)));const h=g.type;if("geojson"===h&&f)return void this.fire(new a.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===h&&!f)return void this.fire(new a.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===b.id&&this.fire(new a.ErrorEvent(Error("The feature id parameter must be provided.")));const i=this._getSourceCaches(d);for(const j of i)j.setFeatureState(f,b.id,c)}removeFeatureState(b,c){this._checkLoaded();const d=b.source,f=this.getSource(d);if(void 0===f)return void this.fire(new a.ErrorEvent(Error(`The source '${d}' does not exist in the map's style.`)));const g=f.type,h="vector"===g?b.sourceLayer:void 0;if("vector"===g&&!h)return void this.fire(new a.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(c&&"string"!=typeof b.id&&"number"!=typeof b.id)return void this.fire(new a.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const i=this._getSourceCaches(d);for(const j of i)j.removeFeatureState(h,b.id,c)}getFeatureState(b){this._checkLoaded();const c=b.source,d=b.sourceLayer,f=this.getSource(c);if(void 0!==f){if("vector"!==f.type||d)return void 0===b.id&&this.fire(new a.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(c)[0].getFeatureState(d,b.id);this.fire(new a.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const b={};for(const c in this._sourceCaches){const d=this._sourceCaches[c].getSource();b[d.id]||(b[d.id]=d.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:b,layers:this._serializeLayers(this._order)},a=>void 0!==a)}_updateLayer(a){this._updatedLayers[a.id]=!0;const b=this._getLayerSourceCache(a);a.source&&!this._updatedSources[a.source]&&b&&"raster"!==b.getSource().type&&(this._updatedSources[a.source]="reload",b.pause()),this._changed=!0,a.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(a){var b,c;const d={},f=[];for(let g=this._order.length-1;g>=0;g--){const h=this._order[g];if(b=h,"fill-extrusion"===this._layers[b].type)for(const i of(d[h]=g,a)){const j=i[h];if(j)for(const k of j)f.push(k)}}f.sort((a,b)=>b.intersectionZ-a.intersectionZ);const l=[];for(let m=this._order.length-1;m>=0;m--){const n=this._order[m];if(c=n,"fill-extrusion"===this._layers[c].type)for(let o=f.length-1;o>=0;o--){const p=f[o].feature;if(d[p.layer.id]<m)break;l.push(p),f.pop()}else for(const q of a){const r=q[n];if(r)for(const s of r)l.push(s.feature)}}return l}queryRenderedFeatures(b,c,d){c&&c.filter&&this._validate(a.validateStyle.filter,"queryRenderedFeatures.filter",c.filter,null,c);const f={};if(c&&c.layers){if(!Array.isArray(c.layers))return this.fire(new a.ErrorEvent(Error("parameters.layers must be an Array."))),[];for(const g of c.layers){const h=this._layers[g];if(!h)return this.fire(new a.ErrorEvent(Error(`The layer '${g}' does not exist in the map's style and cannot be queried for features.`))),[];f[h.source]=!0}}const i=[];c.availableImages=this._availableImages;const j=c&&c.layers?c.layers.some(a=>{const b=this.getLayer(a);return b&&b.is3D()}):this.has3DLayers(),k=L.createFromScreenPoints(b,d);for(const l in this._sourceCaches){const m=this._sourceCaches[l].getSource().id;c.layers&&!f[m]||i.push(W(this._sourceCaches[l],this._layers,this._serializedLayers,k,c,d,j,!!this.map._showQueryGeometry))}return this.placement&&i.push(function(a,b,c,d,f,g,h){const i={},j=g.queryRenderedSymbols(d),k=[];for(const l of Object.keys(j).map(Number))k.push(h[l]);for(const m of(k.sort(Y),k)){const n=m.featureIndex.lookupSymbolFeatures(j[m.bucketInstanceId],b,m.bucketIndex,m.sourceLayerIndex,f.filter,f.layers,f.availableImages,a);for(const o in n){const p=i[o]=i[o]||[],q=n[o];for(const r of(q.sort((a,b)=>{const c=m.featureSortOrder;if(c){const d=c.indexOf(a.featureIndex);return c.indexOf(b.featureIndex)-d}return b.featureIndex-a.featureIndex}),q))p.push(r)}}for(const s in i)i[s].forEach(b=>{const d=b.feature,f=c(a[s]).getFeatureState(d.layer["source-layer"],d.id);d.source=d.layer.source,d.layer["source-layer"]&&(d.sourceLayer=d.layer["source-layer"]),d.state=f});return i}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),k.screenGeometry,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(i)}querySourceFeatures(b,c){c&&c.filter&&this._validate(a.validateStyle.filter,"querySourceFeatures.filter",c.filter,null,c);const d=this._getSourceCaches(b);let f=[];for(const g of d)f=f.concat(X(g,c));return f}addSourceType(a,b,c){return aY.getSourceType(a)?c(Error(`A source type called "${a}" already exists.`)):(aY.setSourceType(a,b),b.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:a,url:b.workerSourceURL},c):c(null,null))}getLight(){return this.light.getLight()}setLight(b,c={}){this._checkLoaded();const d=this.light.getLight();let f=!1;for(const h in b)if(!g(b[h],d[h])){f=!0;break}if(!f)return;const i={now:a.exported.now(),transition:a.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(b,c),this.light.updateTransitions(i)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(b,c=1){if(this._checkLoaded(),!b)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===c){if("object"==typeof b.source){const d="terrain-dem-src";this.addSource(d,b.source),b=a.clone$1(b),b=a.extend(b,{source:d})}if(this._validate(a.validateStyle.terrain,"terrain",b))return}if(!this.terrain||this.terrain&&c!==this.terrain.drapeRenderMode)this._createTerrain(b,c);else{const f=this.terrain,h=f.get();for(const i in b)if(!g(b[i],h[i])){f.set(b),this.stylesheet.terrain=b;const j={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};f.updateTransitions(j);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(b){const c=this.fog=new A(b,this.map.transform);this.stylesheet.fog=b;const d={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(d)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const a of this.map._markers)a._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(b){if(this._checkLoaded(),!b)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const c=this.fog,d=c.get();for(const f in b)if(!g(b[f],d[f])){c.set(b),this.stylesheet.fog=b;const h={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(h);break}}else this._createFog(b);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const a=this._order.filter(a=>this.isLayerDraped(this._layers[a])),b=this._order.filter(a=>!this.isLayerDraped(this._layers[a]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...a),this._drapedFirstOrder.push(...b)}_createTerrain(b,c){const d=this.terrain=new v(b,c);this.stylesheet.terrain=b,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const f={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(f)}_force3DLayerUpdate(){for(const a in this._layers){const b=this._layers[a];"fill-extrusion"===b.type&&this._updateLayer(b)}}_forceSymbolLayerUpdate(){for(const a in this._layers){const b=this._layers[a];"symbol"===b.type&&this._updateLayer(b)}}_validate(b,c,d,f,g={}){return(!g|| !1!==g.validate)&&aT(this,b.call(a.validateStyle,a.extend({key:c,style:this.serialize(),value:d,styleSpec:a.spec},f)))}_remove(){for(const b in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[b].setEventedParent(null);for(const c in this._sourceCaches)this._sourceCaches[c].clearTiles(),this._sourceCaches[c].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(a){const b=this._getSourceCaches(a);for(const c of b)c.clearTiles()}_reloadSource(a){const b=this._getSourceCaches(a);for(const c of b)c.resume(),c.reload()}_updateSources(a){for(const b in this._sourceCaches)this._sourceCaches[b].update(a)}_generateCollisionBoxes(){for(const a in this._sourceCaches){const b=this._sourceCaches[a];b.resume(),b.reload()}}_updatePlacement(b,c,d,f,g=!1){let h=!1,i=!1;const j={};for(const k of this._order){const l=this._layers[k];if("symbol"!==l.type)continue;if(!j[l.source]){const m=this._getLayerSourceCache(l);if(!m)continue;j[l.source]=m.getRenderableIds(!0).map(a=>m.getTileByID(a)).sort((a,b)=>b.tileID.overscaledZ-a.tileID.overscaledZ||(a.tileID.isLessThan(b.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(l,j[l.source],b.center.lng,b.projection);h=h||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),g=g||this._layerOrderChanged||0===d,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(g||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),b.zoom))&&(this.pauseablePlacement=new aO(b,this._order,g,c,d,f,this.placement,this.fog&&b.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,j),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),i=!0),h&&this.pauseablePlacement.placement.setStale()),i||h)for(const o of this._order){const p=this._layers[o];"symbol"===p.type&&this.placement.updateLayerOpacities(p,j[p.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(const a in this._sourceCaches)this._sourceCaches[a].releaseSymbolFadeTiles()}getImages(a,b,c){this.imageManager.getImages(b.icons,c),this._updateTilesForChangedImages();const d=a=>{a&&a.setDependencies(b.tileID.key,b.type,b.icons)};d(this._otherSourceCaches[b.source]),d(this._symbolSourceCaches[b.source])}getGlyphs(a,b,c){this.glyphManager.getGlyphs(b.stacks,c)}getResource(b,c,d){return a.makeRequest(c,d)}_getSourceCache(a){return this._otherSourceCaches[a]}_getLayerSourceCache(a){return"symbol"===a.type?this._symbolSourceCaches[a.source]:this._otherSourceCaches[a.source]}_getSourceCaches(a){const b=[];return this._otherSourceCaches[a]&&b.push(this._otherSourceCaches[a]),this._symbolSourceCaches[a]&&b.push(this._symbolSourceCaches[a]),b}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)}}aY.getSourceType=function(a){return T[a]},aY.setSourceType=function(a,b){T[a]=b},aY.registerForPluginStateChange=a.registerForPluginStateChange;var aZ="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform 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);}\n#endif",a$="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 a_={},a0={};a_=a4("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform 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(\nmix(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;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform 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) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 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;\n#else\nfloat 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));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat 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);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 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;\n#else\nfloat 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);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{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(\nunpack_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))\n);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) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat 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;\n#else\nvec4 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);\n#endif\nreturn 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);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),a0=a4("#ifdef FOG\nuniform 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);}\n#endif","#ifdef FOG\nuniform 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);}\n#endif",!0);const a1=a4("\nhighp 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;}\n#ifdef TERRAIN\nhighp 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;}\n#endif","\nfloat 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;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nfloat 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;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nreturn mix(globe,mercator,t);\n#else\nreturn globe;\n#endif\n}\n#ifdef PROJECTION_GLOBE_VIEW\nmat3 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);}\n#endif\nvec2 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(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}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."),a2=aZ;var a3={background:a4("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:a4("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);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:a4("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 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(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform 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;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute 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;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 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) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}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);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 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);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat 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;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(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);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:a4("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:a4("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat 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);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute 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;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 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);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=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);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:a4("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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","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:a4("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(\n0.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:a4("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(\nmix(-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(\n0.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:a4("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;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying 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;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:a4("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:a4("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:a4("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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 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);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:a4("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 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);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:a4("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute 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;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool 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);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat 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);\n#endif\nfloat 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*=(\n(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;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:a4("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;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute 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;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool 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);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat 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);\n#endif\nfloat 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\n? pos_nx.xy\n: 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*=(\n(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;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:a4("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}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(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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:a4("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;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:a4("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;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat 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);\n#ifdef RENDER_LINE_DASH\nfloat 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);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\nattribute float a_linesofar;\n#endif\nuniform 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;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat 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;\n#ifndef RENDER_TO_TEXTURE\nfloat 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;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nfloat 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);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat 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);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:a4("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;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 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);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute 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;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat 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;\n#ifndef RENDER_TO_TEXTURE\nfloat 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;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:a4("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(\ndot(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);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:a4("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;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;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 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_minFontScale=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 anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.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 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp 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_minFontScale,fontScale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_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:a4("#define SDF_PX 8.0\nuniform 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;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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_inv_rot_matrix;uniform vec2 u_merc_center;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 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 anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.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 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp 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);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 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:a4("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform 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;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat 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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 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 anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp 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);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.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;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_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:a4("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst 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;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:a4("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying 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:a4("\nvarying 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(\ncos_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;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",a$),skyboxGradient:a4("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));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",a$),skyboxCapture:a4("\nvarying 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;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat 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:a4("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_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:a4("uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)\ndiscard;float t=clamp(1.0-sqrt(normDistFromCenter-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;void main() {gl_Position=vec4(a_pos,1.0);}")};function a4(a,b,c){const d=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,f=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,g=b.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),h=a.match(f),i=b.match(f),j=aZ.match(f);let k=i?i.concat(h):h;c||(a_.staticUniforms&&(k=a_.staticUniforms.concat(k)),a0.staticUniforms&&(k=a0.staticUniforms.concat(k))),k&&(k=k.concat(j));const l={};return{fragmentSource:a=a.replace(d,(a,b,c,d,f)=>(l[f]=!0,"define"===b?`
#ifndef HAS_UNIFORM_u_${f}
varying ${c} ${d} ${f};
#else
uniform ${c} ${d} u_${f};
#endif
`:`
#ifdef HAS_UNIFORM_u_${f}
${c} ${d} ${f} = u_${f};
#endif
`)),vertexSource:b=b.replace(d,(a,b,c,d,f)=>{const g="float"===d?"vec2":"vec4",h=f.match(/color/)?"color":g;return l[f]?"define"===b?`
#ifndef HAS_UNIFORM_u_${f}
uniform lowp float u_${f}_t;
attribute ${c} ${g} a_${f};
varying ${c} ${d} ${f};
#else
uniform ${c} ${d} u_${f};
#endif
`:"vec4"===h?`
#ifndef HAS_UNIFORM_u_${f}
${f} = a_${f};
#else
${c} ${d} ${f} = u_${f};
#endif
`:`
#ifndef HAS_UNIFORM_u_${f}
${f} = unpack_mix_${h}(a_${f}, u_${f}_t);
#else
${c} ${d} ${f} = u_${f};
#endif
`:"define"===b?`
#ifndef HAS_UNIFORM_u_${f}
uniform lowp float u_${f}_t;
attribute ${c} ${g} a_${f};
#else
uniform ${c} ${d} u_${f};
#endif
`:"vec4"===h?`
#ifndef HAS_UNIFORM_u_${f}
${c} ${d} ${f} = a_${f};
#else
${c} ${d} ${f} = u_${f};
#endif
`:`
#ifndef HAS_UNIFORM_u_${f}
${c} ${d} ${f} = unpack_mix_${h}(a_${f}, u_${f}_t);
#else
${c} ${d} ${f} = u_${f};
#endif
`}),staticAttributes:g,staticUniforms:k}}class a5{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(a,b,c,d,f,g,h,i){this.context=a;let j=this.boundPaintVertexBuffers.length!==d.length;for(let k=0;!j&&k<d.length;k++)this.boundPaintVertexBuffers[k]!==d[k]&&(j=!0);a.extVertexArrayObject&&this.vao&&this.boundProgram===b&&this.boundLayoutVertexBuffer===c&&!j&&this.boundIndexBuffer===f&&this.boundVertexOffset===g&&this.boundDynamicVertexBuffer===h&&this.boundDynamicVertexBuffer2===i?(a.bindVertexArrayOES.set(this.vao),h&&h.bind(),f&&f.dynamicDraw&&f.bind(),i&&i.bind()):this.freshBind(b,c,d,f,g,h,i)}freshBind(a,b,c,d,f,g,h){let i;const j=a.numAttributes,k=this.context,l=k.gl;if(k.extVertexArrayObject)this.vao&&this.destroy(),this.vao=k.extVertexArrayObject.createVertexArrayOES(),k.bindVertexArrayOES.set(this.vao),i=0,this.boundProgram=a,this.boundLayoutVertexBuffer=b,this.boundPaintVertexBuffers=c,this.boundIndexBuffer=d,this.boundVertexOffset=f,this.boundDynamicVertexBuffer=g,this.boundDynamicVertexBuffer2=h;else{i=k.currentNumAttributes||0;for(let m=j;m<i;m++)l.disableVertexAttribArray(m)}for(const n of(b.enableAttributes(l,a),c))n.enableAttributes(l,a);for(const o of(g&&g.enableAttributes(l,a),h&&h.enableAttributes(l,a),b.bind(),b.setVertexAttribPointers(l,a,f),c))o.bind(),o.setVertexAttribPointers(l,a,f);g&&(g.bind(),g.setVertexAttribPointers(l,a,f)),d&&d.bind(),h&&(h.bind(),h.setVertexAttribPointers(l,a,f)),k.currentNumAttributes=j}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function a6(b,c,d,f,g,h,i){const j=b.context,k=j.gl,l=d.fbo;if(!l)return;b.prepareDrawTile(c);const m=b.useProgram("hillshade");j.activeTexture.set(k.TEXTURE0),k.bindTexture(k.TEXTURE_2D,l.colorAttachment.get());const n=((b,c,d,f)=>{const g=d.paint.get("hillshade-shadow-color"),h=d.paint.get("hillshade-highlight-color"),i=d.paint.get("hillshade-accent-color");let j=d.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===d.paint.get("hillshade-illumination-anchor")&&(j-=b.transform.angle);const k=!b.options.moving;return{u_matrix:f||b.transform.calculateProjMatrix(c.tileID.toUnwrapped(),k),u_image:0,u_latrange:function(b,c){const d=Math.pow(2,c.canonical.z),f=c.canonical.y;return[new a.MercatorCoordinate(0,f/d).toLngLat().lat,new a.MercatorCoordinate(0,(f+1)/d).toLngLat().lat,]}(0,c.tileID),u_light:[d.paint.get("hillshade-exaggeration"),j,],u_shadow:g,u_highlight:h,u_accent:i}})(b,d,f,b.terrain?c.projMatrix:null);b.prepareDrawProgram(j,m,c.toUnwrapped());const{tileBoundsBuffer:o,tileBoundsIndexBuffer:p,tileBoundsSegments:q}=b.getTileBoundsBuffers(d);m.draw(j,k.TRIANGLES,g,h,i,a.CullFaceMode.disabled,n,f.id,o,p,q)}function a7(b,c,d){if(!c.needsDEMTextureUpload)return;const f=b.context,g=f.gl;f.pixelStoreUnpackPremultiplyAlpha.set(!1),c.demTexture=c.demTexture||b.getTileTexture(d.stride);const h=d.getPixels();c.demTexture?c.demTexture.update(h,{premultiply:!1}):c.demTexture=new a.Texture(f,h,g.RGBA,{premultiply:!1}),c.needsDEMTextureUpload=!1}function a8(b,c,d,f,g,h){const i=b.context,j=i.gl;if(!c.dem)return;const k=c.dem;if(i.activeTexture.set(j.TEXTURE1),a7(b,c,k),!c.demTexture)return;c.demTexture.bind(j.NEAREST,j.CLAMP_TO_EDGE);const l=k.dim;i.activeTexture.set(j.TEXTURE0);let m=c.fbo;if(!m){const n=new a.Texture(i,{width:l,height:l,data:null},j.RGBA);n.bind(j.LINEAR,j.CLAMP_TO_EDGE),(m=c.fbo=i.createFramebuffer(l,l,!0)).colorAttachment.set(n.texture)}i.bindFramebuffer.set(m.framebuffer),i.viewport.set([0,0,l,l]);const{tileBoundsBuffer:o,tileBoundsIndexBuffer:p,tileBoundsSegments:q}=b.getMercatorTileBoundsBuffers();b.useProgram("hillshadePrepare").draw(i,j.TRIANGLES,f,g,h,a.CullFaceMode.disabled,((b,c)=>{const d=c.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:[d,d],u_zoom:b.overscaledZ,u_unpack:c.unpackVector}})(c.tileID,k),d.id,o,p,q),c.needsHillshadePrepare=!1}const a9=(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image0:new a.Uniform1i(b,c.u_image0),u_skirt_height:new a.Uniform1f(b,c.u_skirt_height)}),ba=(a,b)=>({u_matrix:a,u_image0:0,u_skirt_height:b}),bb=(a,b,c,d,f)=>({u_proj_matrix:Float32Array.from(a),u_globe_matrix:b,u_merc_matrix:c,u_zoom_transition:d,u_merc_center:f,u_image0:0});function bc(a,b){return null!=a&&null!=b&&!(!a.hasData()||!b.hasData())&&null!=a.demTexture&&null!=b.demTexture&&a.tileID.key!==b.tileID.key}const bd=new class{constructor(){this.operations={}}newMorphing(a,b,c,d,f){if(a in this.operations){const g=this.operations[a];g.to.tileID.key!==c.tileID.key&&(g.queued=c)}else this.operations[a]={startTime:d,phase:0,duration:f,from:b,to:c,queued:null}}getMorphValuesForProxy(a){if(!(a in this.operations))return null;const b=this.operations[a];return{from:b.from,to:b.to,phase:b.phase}}update(a){for(const b in this.operations){const c=this.operations[b];for(c.phase=(a-c.startTime)/c.duration;c.phase>=1||!this._validOp(c);)if(!this._nextOp(c,a)){delete this.operations[b];break}}}_nextOp(a,b){return!!a.queued&&(a.from=a.to,a.to=a.queued,a.queued=null,a.phase=0,a.startTime=b,!0)}_validOp(a){return a.from.hasData()&&a.to.hasData()}},be={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function bf(a,b){const c=1<<a.z;return!b&&(0===a.x||a.x===c-1)||0===a.y||a.y===c-1}const bg=a=>({u_matrix:a});function bh(b,c,d,f,g){if(g>0){const h=a.exported.now(),i=(h-b.timeAdded)/g,j=c?(h-c.timeAdded)/g:-1,k=d.getSource(),l=f.coveringZoomLevel({tileSize:k.tileSize,roundZoom:k.roundZoom}),m=!c||Math.abs(c.tileID.overscaledZ-l)>Math.abs(b.tileID.overscaledZ-l),n=m&&b.refreshedUponExpiration?1:a.clamp(m?i:1-j,0,1);return b.refreshedUponExpiration&&i>=1&&(b.refreshedUponExpiration=!1),c?{opacity:1,mix:1-n}:{opacity:n,mix:0}}return{opacity:1,mix:0}}class bi extends a.SourceCache{constructor(a){const b={type:"raster-dem",maxzoom:a.transform.maxZoom},c=new B(ab(),null),d=U("mock-dem",b,c,a.style);super("mock-dem",d,!1),d.setEventedParent(this),this._sourceLoaded=!0}_loadTile(a,b){a.state="loaded",b(null)}}class bj extends a.SourceCache{constructor(a){const b=U("proxy",{type:"geojson",maxzoom:a.transform.maxZoom},new B(ab(),null),a.style);super("proxy",b,!1),b.setEventedParent(this),this.map=this.getSource().map=a,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(b,c,d){if(b.freezeTileCoverage)return;this.transform=b;const f=b.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((c,d)=>{if(c[d.key]="",!this._tiles[d.key]){const f=new a.Tile(d,this._source.tileSize*d.overscaleFactor(),b.tileZoom);f.state="loaded",this._tiles[d.key]=f}return c},{});for(const g in this._tiles)g in f||(this.freeFBO(g),this._tiles[g].unloadVectorData(),delete this._tiles[g])}freeFBO(a){const b=this.proxyCachedFBO[a];if(void 0!==b){const c=Object.values(b);this.renderCachePool.push(...c),delete this.proxyCachedFBO[a]}}deallocRenderCache(){this.renderCache.forEach(a=>a.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class bk extends a.OverscaledTileID{constructor(a,b,c){super(a.overscaledZ,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y),this.proxyTileKey=b,this.projMatrix=c}}class bl extends a.Elevation{constructor(b,c){super(),this.painter=b,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[d,f,g]=function(b){const c=new a.StructArrayLayout4i8,d=new a.StructArrayLayout3ui6;c.reserve(17161),d.reserve(33800);const f=a.EXTENT/128,g=a.EXTENT+f/2,h=g+f;for(let i=-f;i<h;i+=f)for(let j=-f;j<h;j+=f){const k=j<0||j>g||i<0||i>g?24575:0,l=a.clamp(Math.round(j),0,a.EXTENT),m=a.clamp(Math.round(i),0,a.EXTENT);c.emplaceBack(l+k,m,l,m)}const n=(a,b)=>{const c=131*b+a;d.emplaceBack(c+1,c,c+131),d.emplaceBack(c+131,c+131+1,c+1)};for(let o=1;o<129;o++)for(let p=1;p<129;p++)n(p,o);return[0,129].forEach(a=>{for(let b=0;b<130;b++)n(b,a),n(a,b)}),[c,d,32768]}(),h=b.context;this.gridBuffer=h.createVertexBuffer(d,a.boundsAttributes.members),this.gridIndexBuffer=h.createIndexBuffer(f),this.gridSegments=a.SegmentVector.simpleSegment(0,0,d.length,f.length),this.gridNoSkirtSegments=a.SegmentVector.simpleSegment(0,0,d.length,g),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new bj(c.map),this.orthoMatrix=a.create(),a.ortho(this.orthoMatrix,0,a.EXTENT,0,a.EXTENT,0,1);const i=h.gl;this._overlapStencilMode=new a.StencilMode({func:i.GEQUAL,mask:255},0,255,i.KEEP,i.KEEP,i.REPLACE),this._previousZoom=b.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=c,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new bi(c.map)}set style(a){a.on("data",this._onStyleDataEvent.bind(this)),a.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=a,this._checkRenderCacheEfficiency()}update(b,c,d){if(b&&b.terrain){this._style!==b&&(this.style=b),this.enabled=!0;const f=b.terrain.properties;this.sourceCache=0===b.terrain.drapeRenderMode?this._mockSourceCache:b._getSourceCache(f.get("source")),this._exaggeration=f.get("exaggeration");const g=()=>{this.sourceCache.used&&a.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const b=this.getScaledDemTileSize();this.sourceCache.update(c,b,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,g(),this._initializing=!0),g(),c.updateElevation(!d),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(c),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(a){this._findCoveringTileCache[a]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const b=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==b.efficiency&&a.warnOnce(`Terrain render cache efficiency is not optimal (${b.efficiency}%) and performance
may be affected negatively, consider placing all background, fill and line layers before layer
with id '${b.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(a){a.coord&&"source"===a.dataType?this._clearRenderCacheForTile(a.sourceCacheId,a.coord):"style"===a.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const a in this._style._sourceCaches)this._style._sourceCaches[a].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(a=>a.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const a=2*this.proxySourceCache.getSource().tileSize;return[a,a]}set useVertexMorphing(a){this._useVertexMorphing=a}updateTileBinding(b){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const c=this.proxySourceCache,d=this.painter.transform;this._initializing&&(this._initializing=0===d._centerAltitude&& -1===this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(d.center),-1),this._emptyDEMTextureDirty=!this._initializing);const f=this.proxyCoords=c.getIds().map(a=>{const b=c.getTileByID(a).tileID;return b.projMatrix=d.calculateProjMatrix(b.toUnwrapped()),b});(function(b,c){const d=c.transform.pointCoordinate(c.transform.getCameraPoint()),f=new a.pointGeometry(d.x,d.y);b.sort((b,c)=>{if(c.overscaledZ-b.overscaledZ)return c.overscaledZ-b.overscaledZ;const d=new a.pointGeometry(b.canonical.x+(1<<b.canonical.z)*b.wrap,b.canonical.y),g=new a.pointGeometry(c.canonical.x+(1<<c.canonical.z)*c.wrap,c.canonical.y),h=f.mult(1<<b.canonical.z);return h.x-=.5,h.y-=.5,h.distSqr(d)-h.distSqr(g)})})(f,this.painter),this._previousZoom=d.zoom;const g=this.proxyToSource||{};this.proxyToSource={},f.forEach(a=>{this.proxyToSource[a.key]={}}),this.terrainTileForTile={};const h=this._style._sourceCaches;for(const i in h){const j=h[i];if(!j.used||(j!==this.sourceCache&&this.resetTileLookupCache(j.id),this._setupProxiedCoordsForOrtho(j,b[i],g),j.usedForTerrain))continue;const k=b[i];j.getSource().reparseOverscaled&&this._assignTerrainTiles(k)}this.proxiedCoords[c.id]=f.map(a=>new bk(a,a.key,this.orthoMatrix)),this._assignTerrainTiles(f),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(g),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();const l={};for(const m of(this._visibleDemTiles=[],this.proxyCoords)){const n=this.terrainTileForTile[m.key];if(!n)continue;const o=n.tileID.key;o in l||(this._visibleDemTiles.push(n),l[o]=o)}}_assignTerrainTiles(a){this._initializing||a.forEach(a=>{if(this.terrainTileForTile[a.key])return;const b=this._findTileCoveringTileID(a,this.sourceCache);b&&(this.terrainTileForTile[a.key]=b)})}_prepareDEMTextures(){const a=this.painter.context,b=a.gl;for(const c in this.terrainTileForTile){const d=this.terrainTileForTile[c],f=d.dem;f&&(!d.demTexture||d.needsDEMTextureUpload)&&(a.activeTexture.set(b.TEXTURE1),a7(this.painter,d,f))}}_prepareDemTileUniforms(a,b,c,d){if(!b||null==b.demTexture)return!1;const f=a.tileID.canonical,g=Math.pow(2,b.tileID.canonical.z-f.z),h=d||"";return c[`u_dem_tl${h}`]=[f.x*g%1,f.y*g%1,],c[`u_dem_scale${h}`]=g,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const b=this.painter.context,c=b.gl;if(!this._emptyDepthBufferTexture){const d={width:1,height:1,data:new Uint8Array([255,255,255,255,])};this._emptyDepthBufferTexture=new a.Texture(b,d,c.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let a=0;const b=this._visibleDemTiles.reduce((b,c)=>{if(!c.dem)return b;const d=c.dem.tree.minimums[0];return d>0&&a++,b+d},0);return a?b/a:0}_updateEmptyDEMTexture(){const b=this.painter.context,c=b.gl;b.activeTexture.set(c.TEXTURE2);const d=this._getLoadedAreaMinimum(),f={width:1,height:1,data:new Uint8Array(a.DEMData.pack(d,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let g=this._emptyDEMTexture;return g?g.update(f,{premultiply:!1}):g=this._emptyDEMTexture=new a.Texture(b,f,c.RGBA,{premultiply:!1}),g}setupElevationDraw(b,c,d){var f;const g=this.painter.context,h=g.gl,i=(f=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.DEMData.getUnpackVector(f),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});i.u_dem_size=this.sourceCache.getSource().tileSize,i.u_exaggeration=this.exaggeration();const j=this.painter.transform,k=j.projection.createTileTransform(j,j.worldSize),l=b.tileID.canonical;i.u_tile_tl_up=k.upVector(l,0,0),i.u_tile_tr_up=k.upVector(l,a.EXTENT,0),i.u_tile_br_up=k.upVector(l,a.EXTENT,a.EXTENT),i.u_tile_bl_up=k.upVector(l,0,a.EXTENT),i.u_tile_up_scale=k.upVectorScale(l);let m=null,n=null,o=1;if(d&&d.morphing&&this._useVertexMorphing){const p=d.morphing.srcDemTile,q=d.morphing.dstDemTile;o=d.morphing.phase,p&&q&&(this._prepareDemTileUniforms(b,p,i,"_prev")&&(n=p),this._prepareDemTileUniforms(b,q,i)&&(m=q))}if(n&&m?(g.activeTexture.set(h.TEXTURE2),m.demTexture.bind(h.NEAREST,h.CLAMP_TO_EDGE,h.NEAREST),g.activeTexture.set(h.TEXTURE4),n.demTexture.bind(h.NEAREST,h.CLAMP_TO_EDGE,h.NEAREST),i.u_dem_lerp=o):(m=this.terrainTileForTile[b.tileID.key],g.activeTexture.set(h.TEXTURE2),(this._prepareDemTileUniforms(b,m,i)?m.demTexture:this.emptyDEMTexture).bind(h.NEAREST,h.CLAMP_TO_EDGE)),g.activeTexture.set(h.TEXTURE3),d&&d.useDepthForOcclusion?(this._depthTexture.bind(h.NEAREST,h.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height,]):(this.emptyDepthBufferTexture.bind(h.NEAREST,h.CLAMP_TO_EDGE),i.u_depth_size_inv=[1,1]),d&&d.useMeterToDem&&m){const r=(1<<m.tileID.canonical.z)*a.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;i.u_meter_to_dem=r}d&&d.labelPlaneMatrixInv&&(i.u_label_plane_matrix_inv=d.labelPlaneMatrixInv),c.setTerrainUniformValues(g,i)}renderToBackBuffer(b){const c=this.painter,d=this.painter.context;0!==b.length&&(d.bindFramebuffer.set(null),d.viewport.set([0,0,c.width,c.height]),this.renderingToTexture=!1,function(b,c,d,f,g){if("globe"===b.transform.projection.name)!function(b,c,d,f,g){const h=b.context,i=h.gl;let j,k;const l=b.options.showTerrainWireframe?2:0,m=(a,c)=>{if(k===a)return;const d=[];c&&d.push(be[l]),d.push(be[a]),d.push("PROJECTION_GLOBE_VIEW"),j=b.useProgram("globeRaster",null,d),k=a},n=b.colorModeForRenderPass(),o=new a.DepthMode(i.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);bd.update(g);const p=b.transform,q=a.calculateGlobeMatrix(p,p.worldSize),r=a.calculateGlobeMercatorMatrix(p),s=[a.mercatorXfromLng(p.center.lng),a.mercatorYfromLat(p.center.lat),],u=b.globeSharedBuffers;(l?[!1,!0]:[!1]).forEach(l=>{k=-1;const v=l?i.LINES:i.TRIANGLES;for(const w of f){const x=d.getTile(w),y=Math.pow(2,w.canonical.z),[z,A]=a.globeBuffersForTileMesh(b,x,w,y),B=a.StencilMode.disabled,C=c.prevTerrainTileForTile[w.key],D=c.terrainTileForTile[w.key];bc(C,D)&&bd.newMorphing(w.key,C,D,g,250),h.activeTexture.set(i.TEXTURE0),x.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE);const E=bd.getMorphValuesForProxy(w.key),F=E?1:0,G={};E&&a.extend$1(G,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:a.easeCubicInOut(E.phase)}});const H=a.globeMatrixForTile(w.canonical,q),I=bb(p.projMatrix,H,r,a.globeToMercatorTransition(p.zoom),s);if(m(F,l),c.setupElevationDraw(x,j,G),b.prepareDrawProgram(h,j,w.toUnwrapped()),u){const[J,K]=l?u.getWirefameBuffer(b.context):[u.gridIndexBuffer,u.gridSegments,];j.draw(h,v,o,B,n,a.CullFaceMode.backCCW,I,"globe_raster",z,J,K)}if(!l){const L=[0===w.canonical.y?a.globePoleMatrixForTile(w.canonical,!1,p):null,w.canonical.y===y-1?a.globePoleMatrixForTile(w.canonical,!0,p):null,];for(const M of L){if(!M)continue;const N=bb(p.projMatrix,M,M,0,s);u&&j.draw(h,v,o,B,n,a.CullFaceMode.disabled,N,"globe_pole_raster",A,u.poleIndexBuffer,u.poleSegments)}}}})}(b,c,d,f,g);else{const h=b.context,i=h.gl;let j,k;const l=b.options.showTerrainWireframe?2:0,m=(a,c)=>{if(k===a)return;const d=[be[a]];c&&d.push(be[l]),j=b.useProgram("terrainRaster",null,d),k=a},n=b.colorModeForRenderPass(),o=new a.DepthMode(i.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);bd.update(g);const p=b.transform,q=6*Math.pow(1.5,22-p.zoom)*c.exaggeration();(l?[!1,!0]:[!1]).forEach(l=>{k=-1;const r=l?i.LINES:i.TRIANGLES,[s,u]=l?c.getWirefameBuffer():[c.gridIndexBuffer,c.gridSegments,];for(const v of f){const w=d.getTile(v),x=a.StencilMode.disabled,y=c.prevTerrainTileForTile[v.key],z=c.terrainTileForTile[v.key];bc(y,z)&&bd.newMorphing(v.key,y,z,g,250),h.activeTexture.set(i.TEXTURE0),w.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_NEAREST);const A=bd.getMorphValuesForProxy(v.key),B=A?1:0;let C;A&&(C={morphing:{srcDemTile:A.from,dstDemTile:A.to,phase:a.easeCubicInOut(A.phase)}});const D=ba(v.projMatrix,bf(v.canonical,p.renderWorldCopies)?q/10:q);m(B,l),c.setupElevationDraw(w,j,C),b.prepareDrawProgram(h,j,v.toUnwrapped()),j.draw(h,r,o,x,n,a.CullFaceMode.backCCW,D,"terrain_raster",c.gridBuffer,s,u)}})}}(c,this,this.proxySourceCache,b,this._updateTimestamp),this.renderingToTexture=!0,b.splice(0,b.length))}renderBatch(b){if(0===this._drapedRenderBatches.length)return b+1;this.renderingToTexture=!0;const c=this.painter,d=this.painter.context,f=this.proxySourceCache,g=this.proxiedCoords[f.id],h=this._drapedRenderBatches.shift(),i=[],j=c.style.order;let k=0;for(const l of g){const m=f.getTileByID(l.proxyTileKey),n=f.proxyCachedFBO[l.key]?f.proxyCachedFBO[l.key][b]:void 0,o=void 0!==n?f.renderCache[n]:this.pool[k++],p=void 0!==n;if(m.texture=o.tex,p&&!o.dirty){i.push(m.tileID);continue}let q;d.bindFramebuffer.set(o.fb.framebuffer),this.renderedToTile=!1,o.dirty&&(d.clear({color:a.Color.transparent,stencil:0}),o.dirty=!1);for(let r=h.start;r<=h.end;++r){const s=c.style._layers[j[r]];if(s.isHidden(c.transform.zoom))continue;const u=c.style._getLayerSourceCache(s),v=u?this.proxyToSource[l.key][u.id]:[l];if(!v)continue;const w=v;d.viewport.set([0,0,o.fb.width,o.fb.height,]),q!==(u?u.id:null)&&(this._setupStencil(o,v,s,u),q=u?u.id:null),c.renderLayer(c,u,s,w)}this.renderedToTile?(o.dirty=!0,i.push(m.tileID)):p|| --k,5===k&&(k=0,this.renderToBackBuffer(i))}return this.renderToBackBuffer(i),this.renderingToTexture=!1,d.bindFramebuffer.set(null),d.viewport.set([0,0,c.width,c.height]),h.end+1}postRender(){}renderCacheEfficiency(a){const b=a.order.length;if(0===b)return{efficiency:100};let c,d=0,f=0,g=!1;for(let h=0;h<b;++h){const i=a._layers[a.order[h]];this._style.isLayerDraped(i)?(g&& ++d,++f):g||(g=!0,c=i.id)}return 0===f?{efficiency:100}:{efficiency:100*(1-d/f),firstUndrapedLayer:c}}getMinElevationBelowMSL(){let a=0;return this._visibleDemTiles.filter(a=>a.dem).forEach(b=>{a=Math.min(a,b.dem.tree.minimums[0])}),0===a?a:(a-30)*this._exaggeration}raycast(a,b,c){if(!this._visibleDemTiles)return null;const d=this._visibleDemTiles.filter(a=>a.dem).map(d=>{const f=d.tileID,g=Math.pow(2,f.overscaledZ),{x:h,y:i}=f.canonical,j=h/g,k=(h+1)/g,l=i/g,m=(i+1)/g;return{minx:j,miny:l,maxx:k,maxy:m,t:d.dem.tree.raycastRoot(j,l,k,m,a,b,c),tile:d}});for(const f of(d.sort((a,b)=>(null!==a.t?a.t:Number.MAX_VALUE)-(null!==b.t?b.t:Number.MAX_VALUE)),d)){if(null==f.t)break;const g=f.tile.dem.tree.raycast(f.minx,f.miny,f.maxx,f.maxy,a,b,c);if(null!=g)return g}return null}_createFBO(){const b=this.painter.context,c=b.gl,d=this.drapeBufferSize;b.activeTexture.set(c.TEXTURE0);const f=new a.Texture(b,{width:d[0],height:d[1],data:null},c.RGBA);f.bind(c.LINEAR,c.CLAMP_TO_EDGE);const g=b.createFramebuffer(d[0],d[1],!1);return g.colorAttachment.set(f.texture),g.depthAttachment=new J(b,g.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=b.createRenderbuffer(b.gl.DEPTH_STENCIL,d[0],d[1]),this._stencilRef=0,g.depthAttachment.set(this._sharedDepthStencil),b.clear({stencil:0})):g.depthAttachment.set(this._sharedDepthStencil),b.extTextureFilterAnisotropic&&!b.extTextureFilterAnisotropicForceOff&&c.texParameterf(c.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax),{fb:g,tex:f,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const a in this._style._sourceCaches)if(this._style._sourceCaches[a].hasTransition())return!0;return this._style.order.some(a=>{const b=this._style._layers[a],c=b.isHidden(this.painter.transform.zoom),d=b.getCrossfadeParameters(),f=!!d&&1!==d.t,g=b.hasTransition();return"custom"!==b.type&&!c&&(f||g)})}_clearRasterFadeFromRenderCache(){let a=!1;for(const b in this._style._sourceCaches)if(this._style._sourceCaches[b]._source instanceof P){a=!0;break}if(a)for(let c=0;c<this._style.order.length;++c){const d=this._style._layers[this._style.order[c]],f=d.isHidden(this.painter.transform.zoom),g=this._style._getLayerSourceCache(d);if("raster"!==d.type||f||!g)continue;const h=d.paint.get("raster-fade-duration");for(const i of this.proxyCoords){const j=this.proxyToSource[i.key][g.id];if(j)for(const k of j){const l=bh(g.getTile(k),g.findLoadedParent(k,0),g,this.painter.transform,h);(1!==l.opacity||0!==l.mix)&&this._clearRenderCacheForTile(g.id,k)}}}}_setupDrapedRenderBatches(){const a=this._style.order,b=a.length;if(0===b)return;const c=[];let d,f=0,g=this._style._layers[a[f]];for(;!this._style.isLayerDraped(g)&&g.isHidden(this.painter.transform.zoom)&& ++f<b;)g=this._style._layers[a[f]];for(;f<b;++f){const h=this._style._layers[a[f]];h.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(h)?void 0===d&&(d=f):void 0!==d&&(c.push({start:d,end:f-1}),d=void 0))}void 0!==d&&c.push({start:d,end:f-1}),this._drapedRenderBatches=c}_setupRenderCache(a){const b=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,b.renderCache.length>b.renderCachePool.length){const c=Object.values(b.proxyCachedFBO);b.proxyCachedFBO={};for(let d=0;d<c.length;++d){const f=Object.values(c[d]);b.renderCachePool.push(...f)}}return}this._clearRasterFadeFromRenderCache();const g=this.proxyCoords,h=this._tilesDirty;for(let i=g.length-1;i>=0;i--){const j=g[i];if(b.getTileByID(j.key),void 0!==b.proxyCachedFBO[j.key]){const k=a[j.key],l=this.proxyToSource[j.key];let m=0;for(const n in l){const o=l[n],p=k[n];if(!p||p.length!==o.length||o.some((a,b)=>a!==p[b]||h[n]&&h[n].hasOwnProperty(a.key))){m=-1;break}++m}for(const q in b.proxyCachedFBO[j.key])b.renderCache[b.proxyCachedFBO[j.key][q]].dirty=m<0||m!==Object.values(k).length}}const r=[...this._drapedRenderBatches];for(const s of(r.sort((a,b)=>b.end-b.start-(a.end-a.start)),r))for(const u of g){if(b.proxyCachedFBO[u.key])continue;let v=b.renderCachePool.pop();void 0===v&&b.renderCache.length<50&&(v=b.renderCache.length,b.renderCache.push(this._createFBO())),void 0!==v&&(b.proxyCachedFBO[u.key]={},b.proxyCachedFBO[u.key][s.start]=v,b.renderCache[v].dirty=!0)}this._tilesDirty={}}_setupStencil(a,b,c,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const f=this.painter.context,g=f.gl;if(b.length<=1)return void(this._overlapStencilType=!1);let h;if(c.isTileClipped())h=b.length,this._overlapStencilMode.test={func:g.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(b[0].overscaledZ>b[b.length-1].overscaledZ))return void(this._overlapStencilType=!1);h=1,this._overlapStencilMode.test={func:g.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+h>255&&(f.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=h,this._overlapStencilMode.ref=this._stencilRef,c.isTileClipped()&&this._renderTileClippingMasks(b,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(b){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[b.key]),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(b,c){const d=this.painter,f=this.painter.context,g=f.gl;d._tileClippingMaskIDs={},f.setColorMode(a.ColorMode.disabled),f.setDepthMode(a.DepthMode.disabled);const h=d.useProgram("clippingMask");for(const i of b){const j=d._tileClippingMaskIDs[i.key]=--c;h.draw(f,g.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:g.ALWAYS,mask:0},j,255,g.KEEP,g.KEEP,g.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,bg(i.projMatrix),"$clipping",d.tileExtentBuffer,d.quadTriangleIndexBuffer,d.tileExtentSegments)}}pointCoordinate(b){const c=this.painter.transform;if(b.x<0||b.x>c.width||b.y<0||b.y>c.height)return null;const d=[b.x,b.y,1,1];a.transformMat4$1(d,d,c.pixelMatrixInverse),a.scale$1(d,d,1/d[3]),d[0]/=c.worldSize,d[1]/=c.worldSize;const f=c._camera.position,g=a.mercatorZfromAltitude(1,c.center.lat),h=[f[0],f[1],f[2]/g,0],i=a.subtract([],d.slice(0,3),h);a.normalize(i,i);const j=this.raycast(h,i,this._exaggeration);return null!==j&&j?(a.scaleAndAdd(h,h,i,j),h[3]=h[2],h[2]*=g,h):null}drawDepth(){const b=this.painter,c=b.context,d=this.proxySourceCache,f=Math.ceil(b.width),g=Math.ceil(b.height);if(this._depthFBO&&(this._depthFBO.width!==f||this._depthFBO.height!==g)&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const h=c.gl,i=c.createFramebuffer(f,g,!0);c.activeTexture.set(h.TEXTURE0);const j=new a.Texture(c,{width:f,height:g,data:null},h.RGBA);j.bind(h.NEAREST,h.CLAMP_TO_EDGE),i.colorAttachment.set(j.texture);const k=c.createRenderbuffer(c.gl.DEPTH_COMPONENT16,f,g);i.depthAttachment.set(k),this._depthFBO=i,this._depthTexture=j}c.bindFramebuffer.set(this._depthFBO.framebuffer),c.viewport.set([0,0,f,g]),function(b,c,d,f){if("globe"===b.transform.projection.name)return;const g=b.context,h=g.gl;g.clear({depth:1});const i=b.useProgram("terrainDepth"),j=new a.DepthMode(h.LESS,a.DepthMode.ReadWrite,b.depthRangeFor3D);for(const k of f){const l=d.getTile(k),m=ba(k.projMatrix,0);c.setupElevationDraw(l,i),i.draw(g,h.TRIANGLES,j,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,m,"terrain_depth",c.gridBuffer,c.gridIndexBuffer,c.gridNoSkirtSegments)}}(b,this,d,this.proxyCoords)}_setupProxiedCoordsForOrtho(a,b,c){if(a.getSource() instanceof S)return this._setupProxiedCoordsForImageSource(a,b,c);this._findCoveringTileCache[a.id]=this._findCoveringTileCache[a.id]||{};const d=this.proxiedCoords[a.id]=[],f=this.proxyCoords;for(let g=0;g<f.length;g++){const h=f[g],i=this._findTileCoveringTileID(h,a);if(i){const j=this._createProxiedId(h,i,c[h.key]&&c[h.key][a.id]);d.push(j),this.proxyToSource[h.key][a.id]=[j,]}}let k=!1;for(let l=0;l<b.length;l++){const m=a.getTile(b[l]);if(!m||!m.hasData())continue;const n=this._findTileCoveringTileID(m.tileID,this.proxySourceCache);if(n&&n.tileID.canonical.z!==m.tileID.canonical.z){const o=this.proxyToSource[n.tileID.key][a.id],p=this._createProxiedId(n.tileID,m,c[n.tileID.key]&&c[n.tileID.key][a.id]);o?o.splice(o.length-1,0,p):this.proxyToSource[n.tileID.key][a.id]=[p],d.push(p),k=!0}}this._sourceTilesOverlap[a.id]=k}_setupProxiedCoordsForImageSource(b,c,d){if(!b.getSource().loaded())return;const f=this.proxiedCoords[b.id]=[],g=this.proxyCoords,h=b.getSource(),i=new a.pointGeometry(h.tileID.x,h.tileID.y)._div(1<<h.tileID.z),j=h.coordinates.map(a.MercatorCoordinate.fromLngLat).reduce((a,b)=>(a.min.x=Math.min(a.min.x,b.x-i.x),a.min.y=Math.min(a.min.y,b.y-i.y),a.max.x=Math.max(a.max.x,b.x-i.x),a.max.y=Math.max(a.max.y,b.y-i.y),a),{min:new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),k=(b,c)=>{const d=b.wrap+b.canonical.x/(1<<b.canonical.z),f=b.canonical.y/(1<<b.canonical.z),g=a.EXTENT/(1<<b.canonical.z),h=c.wrap+c.canonical.x/(1<<c.canonical.z),i=c.canonical.y/(1<<c.canonical.z);return d+g<h+j.min.x||d>h+j.max.x||f+g<i+j.min.y||f>i+j.max.y};for(let l=0;l<g.length;l++){const m=g[l];for(let n=0;n<c.length;n++){const o=b.getTile(c[n]);if(!o||!o.hasData()||k(m,o.tileID))continue;const p=this._createProxiedId(m,o,d[m.key]&&d[m.key][b.id]),q=this.proxyToSource[m.key][b.id];q?q.push(p):this.proxyToSource[m.key][b.id]=[p],f.push(p)}}}_createProxiedId(b,c,d){let f=this.orthoMatrix;if(d){const g=d.find(a=>a.key===c.tileID.key);if(g)return g}if(c.tileID.key!==b.key){const h=b.canonical.z-c.tileID.canonical.z;let i,j,k;f=a.create();const l=c.tileID.wrap-b.wrap<<b.overscaledZ;h>0?(j=(i=a.EXTENT>>h)*((c.tileID.canonical.x<<h)-b.canonical.x+l),k=i*((c.tileID.canonical.y<<h)-b.canonical.y)):(i=a.EXTENT<< -h,j=a.EXTENT*(c.tileID.canonical.x-(b.canonical.x+l<< -h)),k=a.EXTENT*(c.tileID.canonical.y-(b.canonical.y<< -h))),a.ortho(f,0,i,0,i,0,1),a.translate(f,f,[j,k,0])}return new bk(c.tileID,b.key,f)}_findTileCoveringTileID(b,c){let d=c.getTile(b);if(d&&d.hasData())return d;const f=this._findCoveringTileCache[c.id],g=f[b.key];if((d=g?c.getTileByID(g):null)&&d.hasData()||null===g)return d;let h=d?d.tileID:b,i=h.overscaledZ;const j=c.getSource().minzoom,k=[];if(!g){const l=c.getSource().maxzoom;if(b.canonical.z>=l){const m=b.canonical.z-l;c.getSource().reparseOverscaled?(i=Math.max(b.canonical.z+2,c.transform.tileZoom),h=new a.OverscaledTileID(i,b.wrap,l,b.canonical.x>>m,b.canonical.y>>m)):0!==m&&(i=l,h=new a.OverscaledTileID(i,b.wrap,l,b.canonical.x>>m,b.canonical.y>>m))}h.key!==b.key&&(k.push(h.key),d=c.getTile(h))}const n=a=>{k.forEach(b=>{f[b]=a}),k.length=0};for(i-=1;i>=j&&(!d||!d.hasData());i--){d&&n(d.tileID.key);const o=h.calculateScaledKey(i);if((d=c.getTileByID(o))&&d.hasData())break;const p=f[o];if(null===p)break;void 0===p?k.push(o):d=c.getTileByID(p)}return n(d?d.tileID.key:null),d&&d.hasData()?d:null}findDEMTileFor(a){return this.enabled?this._findTileCoveringTileID(a,this.sourceCache):null}prepareDrawTile(a){this.renderedToTile=!0}_clearRenderCacheForTile(a,b){let c=this._tilesDirty[a];c||(c=this._tilesDirty[a]={}),c[b.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const b=function(b){let c,d,f;const g=new a.StructArrayLayout2ui4,h=131;for(d=1;d<129;d++){for(c=1;c<129;c++)f=d*h+c,g.emplaceBack(f,f+1),g.emplaceBack(f,f+h),g.emplaceBack(f+1,f+h),128===d&&g.emplaceBack(f+h,f+h+1);g.emplaceBack(f+1,f+1+h)}return g}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(b),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,b.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}}function bm(a){const b=[];for(let c=0;c<a.length;c++){if(null===a[c])continue;const d=a[c].split(" ");b.push(d.pop())}return b}class bn{static cacheKey(a,b,c){let d=`${a}${c?c.cacheKey:""}`;for(const f of b)d+=`/${f}`;return d}constructor(b,c,d,f,g,h){var i,j,k,l;const m=b.gl;this.program=m.createProgram();const n=bm(d.staticAttributes),o=f?f.getBinderAttributes():[],p=n.concat(o),q=d.staticUniforms?bm(d.staticUniforms):[],r=f?f.getBinderUniforms():[],s=q.concat(r),u=[];for(const v of s)0>u.indexOf(v)&&u.push(v);let w=f?f.defines():[];w=w.concat(h.map(a=>`#define ${a}`));const x=w.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",a2,a1.fragmentSource,a0.fragmentSource,d.fragmentSource).join("\n"),y=w.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",a2,a1.vertexSource,a0.vertexSource,a_.vertexSource,d.vertexSource).join("\n"),z=m.createShader(m.FRAGMENT_SHADER);if(m.isContextLost())return void(this.failedToCreate=!0);m.shaderSource(z,x),m.compileShader(z),m.attachShader(this.program,z);const A=m.createShader(m.VERTEX_SHADER);if(m.isContextLost())return void(this.failedToCreate=!0);m.shaderSource(A,y),m.compileShader(A),m.attachShader(this.program,A),this.attributes={};const B={};this.numAttributes=p.length;for(let C=0;C<this.numAttributes;C++)p[C]&&(m.bindAttribLocation(this.program,C,p[C]),this.attributes[p[C]]=C);m.linkProgram(this.program),m.deleteShader(A),m.deleteShader(z);for(let D=0;D<u.length;D++){const E=u[D];if(E&&!B[E]){const F=m.getUniformLocation(this.program,E);F&&(B[E]=F)}}this.fixedUniforms=g(b,B),this.binderUniforms=f?f.getUniforms(b,B):[],-1!==h.indexOf("TERRAIN")&&(this.terrainUniforms=(i=b,j=B,{u_dem:new a.Uniform1i(i,j.u_dem),u_dem_prev:new a.Uniform1i(i,j.u_dem_prev),u_dem_unpack:new a.Uniform4f(i,j.u_dem_unpack),u_dem_tl:new a.Uniform2f(i,j.u_dem_tl),u_dem_scale:new a.Uniform1f(i,j.u_dem_scale),u_dem_tl_prev:new a.Uniform2f(i,j.u_dem_tl_prev),u_dem_scale_prev:new a.Uniform1f(i,j.u_dem_scale_prev),u_dem_size:new a.Uniform1f(i,j.u_dem_size),u_dem_lerp:new a.Uniform1f(i,j.u_dem_lerp),u_exaggeration:new a.Uniform1f(i,j.u_exaggeration),u_depth:new a.Uniform1i(i,j.u_depth),u_depth_size_inv:new a.Uniform2f(i,j.u_depth_size_inv),u_meter_to_dem:new a.Uniform1f(i,j.u_meter_to_dem),u_label_plane_matrix_inv:new a.UniformMatrix4f(i,j.u_label_plane_matrix_inv),u_tile_tl_up:new a.Uniform3f(i,j.u_tile_tl_up),u_tile_tr_up:new a.Uniform3f(i,j.u_tile_tr_up),u_tile_br_up:new a.Uniform3f(i,j.u_tile_br_up),u_tile_bl_up:new a.Uniform3f(i,j.u_tile_bl_up),u_tile_up_scale:new a.Uniform1f(i,j.u_tile_up_scale)})),-1!==h.indexOf("FOG")&&(this.fogUniforms=(k=b,l=B,{u_fog_matrix:new a.UniformMatrix4f(k,l.u_fog_matrix),u_fog_range:new a.Uniform2f(k,l.u_fog_range),u_fog_color:new a.Uniform4f(k,l.u_fog_color),u_fog_horizon_blend:new a.Uniform1f(k,l.u_fog_horizon_blend),u_fog_temporal_offset:new a.Uniform1f(k,l.u_fog_temporal_offset)}))}setTerrainUniformValues(a,b){if(!this.terrainUniforms)return;const c=this.terrainUniforms;if(!this.failedToCreate)for(const d in a.program.set(this.program),b)c[d].set(b[d])}setFogUniformValues(a,b){if(!this.fogUniforms)return;const c=this.fogUniforms;if(!this.failedToCreate)for(const d in a.program.set(this.program),b)c[d].location&&c[d].set(b[d])}draw(a,b,c,d,f,g,h,i,j,k,l,m,n,o,p,q){const r=a.gl;if(this.failedToCreate)return;for(const s of(a.program.set(this.program),a.setDepthMode(c),a.setStencilMode(d),a.setColorMode(f),a.setCullFace(g),Object.keys(this.fixedUniforms)))this.fixedUniforms[s].set(h[s]);o&&o.setUniforms(a,this.binderUniforms,m,{zoom:n});const u={[r.LINES]:2,[r.TRIANGLES]:3,[r.LINE_STRIP]:1}[b];for(const v of l.get()){const w=v.vaos||(v.vaos={});(w[i]||(w[i]=new a5)).bind(a,this,j,o?o.getPaintVertexBuffers():[],k,v.vertexOffset,p,q),r.drawElements(b,v.primitiveLength*u,r.UNSIGNED_SHORT,v.primitiveOffset*u*2)}}}function bo(a,b,c){const d=1/C(c,1,b.transform.tileZoom),f=Math.pow(2,c.tileID.overscaledZ),g=c.tileSize*Math.pow(2,b.transform.tileZoom)/f,h=g*(c.tileID.canonical.x+c.tileID.wrap*f),i=g*c.tileID.canonical.y;return{u_image:0,u_texsize:c.imageAtlasTexture.size,u_scale:[d,a.fromScale,a.toScale],u_fade:a.t,u_pixel_coord_upper:[h>>16,i>>16],u_pixel_coord_lower:[65535&h,65535&i]}}const bp=(b,c,d,f)=>{const g=c.style.light,h=g.properties.get("position"),i=[h.x,h.y,h.z],j=a.create$1();"viewport"===g.properties.get("anchor")&&(a.fromRotation(j,-c.transform.angle),a.transformMat3(i,i,j));const k=g.properties.get("color");return{u_matrix:b,u_lightpos:i,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[k.r,k.g,k.b],u_vertical_gradient:+d,u_opacity:f}},bq=(b,c,d,f,g,h,i)=>a.extend(bp(b,c,d,f),bo(h,c,i),{u_height_factor:-Math.pow(2,g.overscaledZ)/i.tileSize/8}),br=a=>({u_matrix:a}),bs=(b,c,d,f)=>a.extend(br(b),bo(d,c,f)),bt=(a,b)=>({u_matrix:a,u_world:b}),bu=(b,c,d,f,g)=>a.extend(bs(b,c,d,f),{u_world:g}),bv=(b,c,d,f)=>{const g=b.transform;let h;return h="map"===f.paint.get("circle-pitch-alignment")?g.calculatePixelsToTileUnitsMatrix(d):new Float32Array([g.pixelsToGLUnits[0],0,0,g.pixelsToGLUnits[1],]),{u_camera_to_center_distance:g.cameraToCenterDistance,u_matrix:b.translatePosMatrix(c.projMatrix,d,f.paint.get("circle-translate"),f.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:h}},bw=a=>{const b=[];return"map"===a.paint.get("circle-pitch-alignment")&&b.push("PITCH_WITH_MAP"),"map"===a.paint.get("circle-pitch-scale")&&b.push("SCALE_WITH_MAP"),b},bx=(b,c,d)=>{const f=a.EXTENT/d.tileSize;return{u_matrix:b,u_camera_to_center_distance:c.cameraToCenterDistance,u_extrude_scale:[c.pixelsToGLUnits[0]/f,c.pixelsToGLUnits[1]/f,]}},by=(a,b,c=1)=>({u_matrix:a,u_color:b,u_overlay:0,u_overlay_scale:c}),bz=(a,b,c,d)=>({u_matrix:a,u_extrude_scale:C(b,1,c),u_intensity:d}),bA=(b,c,d,f,g,h)=>{const i=b.transform,j=i.calculatePixelsToTileUnitsMatrix(c),k={u_matrix:bD(b,c,d,g),u_pixels_to_tile_units:j,u_device_pixel_ratio:a.exported.devicePixelRatio,u_units_to_pixels:[1/i.pixelsToGLUnits[0],1/i.pixelsToGLUnits[1],],u_dash_image:0,u_gradient_image:1,u_image_height:h,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(bE(d)){const l=bC(c,b.transform);k.u_texsize=c.lineAtlasTexture.size,k.u_scale=[l,f.fromScale,f.toScale,],k.u_mix=f.t}return k},bB=(b,c,d,f,g)=>{const h=b.transform,i=bC(c,h);return{u_matrix:bD(b,c,d,g),u_texsize:c.imageAtlasTexture.size,u_pixels_to_tile_units:h.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:a.exported.devicePixelRatio,u_image:0,u_scale:[i,f.fromScale,f.toScale],u_fade:f.t,u_units_to_pixels:[1/h.pixelsToGLUnits[0],1/h.pixelsToGLUnits[1],],u_alpha_discard_threshold:0}};function bC(a,b){return 1/C(a,1,b.tileZoom)}function bD(a,b,c,d){return a.translatePosMatrix(d||b.tileID.projMatrix,b,c.paint.get("line-translate"),c.paint.get("line-translate-anchor"))}function bE(a){const b=a.paint.get("line-dasharray").value;return b.value||"constant"!==b.kind}const bF=(a,b,c,d,f,g)=>{var h,i;return{u_matrix:a,u_tl_parent:b,u_scale_parent:c,u_fade_t:d.mix,u_opacity:d.opacity*f.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:f.paint.get("raster-brightness-min"),u_brightness_high:f.paint.get("raster-brightness-max"),u_saturation_factor:(i=f.paint.get("raster-saturation"))>0?1-1/(1.001-i):-i,u_contrast_factor:(h=f.paint.get("raster-contrast"))>0?1/(1-h):1+h,u_spin_weights:bG(f.paint.get("raster-hue-rotate")),u_perspective_transform:g}};function bG(a){a*=Math.PI/180;const b=Math.sin(a),c=Math.cos(a);return[(2*c+1)/3,(-Math.sqrt(3)*b-c+1)/3,(Math.sqrt(3)*b-c+1)/3,]}const bH=(a,b,c,d,f,g,h,i,j,k,l,m,n,o)=>{const p=f.transform;return{u_is_size_zoom_constant:+("constant"===a||"source"===a),u_is_size_feature_constant:+("constant"===a||"camera"===a),u_size_t:b?b.uSizeT:0,u_size:b?b.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+c,u_aspect_ratio:p.width/p.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:h,u_coord_matrix:i,u_is_text:+j,u_pitch_with_map:+d,u_texsize:k,u_tile_id:l,u_zoom_transition:m,u_inv_rot_matrix:n,u_merc_center:o,u_texture:0}},bI=(b,c,d,f,g,h,i,j,k,l,m,n,o,p,q)=>{const{cameraToCenterDistance:r,_pitch:s}=g.transform;return a.extend(bH(b,c,d,f,g,h,i,j,k,l,n,o,p,q),{u_gamma_scale:f?r*Math.cos(g.terrain?0:s):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+m})},bJ=(b,c,d,f,g,h,i,j,k,l,m,n,o,p)=>a.extend(bI(b,c,d,f,g,h,i,j,!0,k,!0,m,n,o,p),{u_texsize_icon:l,u_texture_icon:1}),bK=(a,b,c)=>({u_matrix:a,u_opacity:b,u_color:c}),bL=(b,c,d,f,g,h)=>a.extend(function(a,b,c,d){const f=c.imageManager.getPattern(a.from.toString()),g=c.imageManager.getPattern(a.to.toString()),{width:h,height:i}=c.imageManager.getPixelSize(),j=Math.pow(2,d.tileID.overscaledZ),k=d.tileSize*Math.pow(2,c.transform.tileZoom)/j,l=k*(d.tileID.canonical.x+d.tileID.wrap*j),m=k*d.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:f.tl,u_pattern_br_a:f.br,u_pattern_tl_b:g.tl,u_pattern_br_b:g.br,u_texsize:[h,i],u_mix:b.t,u_pattern_size_a:f.displaySize,u_pattern_size_b:g.displaySize,u_scale_a:b.fromScale,u_scale_b:b.toScale,u_tile_units_to_pixels:1/C(d,1,c.transform.tileZoom),u_pixel_coord_upper:[l>>16,m>>16,],u_pixel_coord_lower:[65535&l,65535&m,]}}(f,h,d,g),{u_matrix:b,u_opacity:c}),bM={fillExtrusion:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fillExtrusionPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_height_factor:new a.Uniform1f(b,c.u_height_factor),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fill:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),fillPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),fillOutline:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world)}),fillOutlinePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),circle:(b,c)=>({u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.UniformMatrix2f(b,c.u_extrude_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),collisionBox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.Uniform2f(b,c.u_extrude_scale)}),collisionCircle:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_inv_matrix:new a.UniformMatrix4f(b,c.u_inv_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_viewport_size:new a.Uniform2f(b,c.u_viewport_size)}),debug:(b,c)=>({u_color:new a.UniformColor(b,c.u_color),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_overlay:new a.Uniform1i(b,c.u_overlay),u_overlay_scale:new a.Uniform1f(b,c.u_overlay_scale)}),clippingMask:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmap:(b,c)=>({u_extrude_scale:new a.Uniform1f(b,c.u_extrude_scale),u_intensity:new a.Uniform1f(b,c.u_intensity),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmapTexture:(b,c)=>({u_image:new a.Uniform1i(b,c.u_image),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_opacity:new a.Uniform1f(b,c.u_opacity)}),hillshade:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_latrange:new a.Uniform2f(b,c.u_latrange),u_light:new a.Uniform2f(b,c.u_light),u_shadow:new a.UniformColor(b,c.u_shadow),u_highlight:new a.UniformColor(b,c.u_highlight),u_accent:new a.UniformColor(b,c.u_accent)}),hillshadePrepare:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_dimension:new a.Uniform2f(b,c.u_dimension),u_zoom:new a.Uniform1f(b,c.u_zoom),u_unpack:new a.Uniform4f(b,c.u_unpack)}),line:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_dash_image:new a.Uniform1i(b,c.u_dash_image),u_gradient_image:new a.Uniform1i(b,c.u_gradient_image),u_image_height:new a.Uniform1f(b,c.u_image_height),u_texsize:new a.Uniform2f(b,c.u_texsize),u_scale:new a.Uniform3f(b,c.u_scale),u_mix:new a.Uniform1f(b,c.u_mix),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),linePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_image:new a.Uniform1i(b,c.u_image),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),raster:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_tl_parent:new a.Uniform2f(b,c.u_tl_parent),u_scale_parent:new a.Uniform1f(b,c.u_scale_parent),u_fade_t:new a.Uniform1f(b,c.u_fade_t),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image0:new a.Uniform1i(b,c.u_image0),u_image1:new a.Uniform1i(b,c.u_image1),u_brightness_low:new a.Uniform1f(b,c.u_brightness_low),u_brightness_high:new a.Uniform1f(b,c.u_brightness_high),u_saturation_factor:new a.Uniform1f(b,c.u_saturation_factor),u_contrast_factor:new a.Uniform1f(b,c.u_contrast_factor),u_spin_weights:new a.Uniform3f(b,c.u_spin_weights),u_perspective_transform:new a.Uniform2f(b,c.u_perspective_transform)}),symbolIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_texture:new a.Uniform1i(b,c.u_texture)}),symbolSDF:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texture:new a.Uniform1i(b,c.u_texture),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),symbolTextAndIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texsize_icon:new a.Uniform2f(b,c.u_texsize_icon),u_texture:new a.Uniform1i(b,c.u_texture),u_texture_icon:new a.Uniform1i(b,c.u_texture_icon),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),background:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_color:new a.UniformColor(b,c.u_color)}),backgroundPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image:new a.Uniform1i(b,c.u_image),u_pattern_tl_a:new a.Uniform2f(b,c.u_pattern_tl_a),u_pattern_br_a:new a.Uniform2f(b,c.u_pattern_br_a),u_pattern_tl_b:new a.Uniform2f(b,c.u_pattern_tl_b),u_pattern_br_b:new a.Uniform2f(b,c.u_pattern_br_b),u_texsize:new a.Uniform2f(b,c.u_texsize),u_mix:new a.Uniform1f(b,c.u_mix),u_pattern_size_a:new a.Uniform2f(b,c.u_pattern_size_a),u_pattern_size_b:new a.Uniform2f(b,c.u_pattern_size_b),u_scale_a:new a.Uniform1f(b,c.u_scale_a),u_scale_b:new a.Uniform1f(b,c.u_scale_b),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_tile_units_to_pixels:new a.Uniform1f(b,c.u_tile_units_to_pixels)}),terrainRaster:a9,terrainDepth:a9,skybox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_cubemap:new a.Uniform1i(b,c.u_cubemap),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxGradient:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_center_direction:new a.Uniform3f(b,c.u_center_direction),u_radius:new a.Uniform1f(b,c.u_radius),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxCapture:(b,c)=>({u_matrix_3f:new a.UniformMatrix3f(b,c.u_matrix_3f),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_sun_intensity:new a.Uniform1f(b,c.u_sun_intensity),u_color_tint_r:new a.Uniform4f(b,c.u_color_tint_r),u_color_tint_m:new a.Uniform4f(b,c.u_color_tint_m),u_luminance:new a.Uniform1f(b,c.u_luminance)}),globeRaster:(b,c)=>({u_proj_matrix:new a.UniformMatrix4f(b,c.u_proj_matrix),u_globe_matrix:new a.UniformMatrix4f(b,c.u_globe_matrix),u_merc_matrix:new a.UniformMatrix4f(b,c.u_merc_matrix),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_image0:new a.Uniform1i(b,c.u_image0)}),globeAtmosphere:(b,c)=>({u_center:new a.Uniform2f(b,c.u_center),u_radius:new a.Uniform1f(b,c.u_radius),u_screen_size:new a.Uniform2f(b,c.u_screen_size),u_pixel_ratio:new a.Uniform1f(b,c.u_pixel_ratio),u_opacity:new a.Uniform1f(b,c.u_opacity),u_fadeout_range:new a.Uniform1f(b,c.u_fadeout_range),u_start_color:new a.Uniform3f(b,c.u_start_color),u_end_color:new a.Uniform3f(b,c.u_end_color)})};let bN;function bO(b,c,d,f,g,h,i){var j;const k=b.context,l=k.gl,m=b.useProgram("collisionBox"),n=[];let o=0,p=0;for(let q=0;q<f.length;q++){const r=f[q],s=c.getTile(r),u=s.getBucket(d);if(!u)continue;let v=r.projMatrix;0===g[0]&&0===g[1]||(v=b.translatePosMatrix(r.projMatrix,s,g,h));const w=i?u.textCollisionBox:u.iconCollisionBox,x=u.collisionCircleArray;if(x.length>0){const y=a.create(),z=v;a.mul(y,u.placementInvProjMatrix,b.transform.glCoordMatrix),a.mul(y,y,u.placementViewportMatrix),n.push({circleArray:x,circleOffset:p,transform:z,invTransform:y}),o+=x.length/4,p=o}w&&(b.terrain&&b.terrain.setupElevationDraw(s,m),m.draw(k,l.LINES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,bx(v,b.transform,s),d.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,null,b.transform.zoom,null,w.collisionVertexBuffer,w.collisionVertexBufferExt))}if(!i||!n.length)return;const A=b.useProgram("collisionCircle"),B=new a.StructArrayLayout2f1f2i16;B.resize(4*o),B._trim();let C=0;for(const D of n)for(let E=0;E<D.circleArray.length/4;E++){const F=4*E,G=D.circleArray[F+0],H=D.circleArray[F+1],I=D.circleArray[F+2],J=D.circleArray[F+3];B.emplace(C++,G,H,I,J,0),B.emplace(C++,G,H,I,J,1),B.emplace(C++,G,H,I,J,2),B.emplace(C++,G,H,I,J,3)}(!bN||bN.length<2*o)&&(bN=function(b){const c=2*b,d=new a.StructArrayLayout3ui6;d.resize(c),d._trim();for(let f=0;f<c;f++){const g=6*f;d.uint16[g+0]=4*f+0,d.uint16[g+1]=4*f+1,d.uint16[g+2]=4*f+2,d.uint16[g+3]=4*f+2,d.uint16[g+4]=4*f+3,d.uint16[g+5]=4*f+0}return d}(o));const K=k.createIndexBuffer(bN,!0),L=k.createVertexBuffer(B,a.collisionCircleLayout.members,!0);for(const M of n){const N={u_matrix:M.transform,u_inv_matrix:M.invTransform,u_camera_to_center_distance:(j=b.transform).cameraToCenterDistance,u_viewport_size:[j.width,j.height]};A.draw(k,l.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,N,d.id,L,K,a.SegmentVector.simpleSegment(0,2*M.circleOffset,M.circleArray.length,M.circleArray.length/2),null,b.transform.zoom,null,null,null)}L.destroy(),K.destroy()}const bP=a.identity(new Float32Array(16));function bQ(b,c,d,f,g,h){const{horizontalAlign:i,verticalAlign:j}=a.getAnchorAlignment(b),k=a.evaluateVariableOffset(b,f);return new a.pointGeometry((-(i-.5)*c/g+k[0])*h,(-(j-.5)*d/g+k[1])*h)}function bR(b,c,d,f,g,h,i,j,k,l,m,n){const o=b.text.placedSymbolArray,p=b.text.dynamicLayoutVertexArray,q=b.icon.dynamicLayoutVertexArray,r={},s=j.projMatrix,u=h.elevation,v=u?u.getAtTileOffsetFunc(j,n):a=>[0,0,0];p.clear();for(let w=0;w<o.length;w++){const x=o.get(w),y=b.allowVerticalPlacement&&!x.placedOrientation,z=x.hidden||!x.crossTileID||y?null:f[x.crossTileID];if(z){const A=new a.pointGeometry(x.tileAnchorX,x.tileAnchorY),B=v(A),C=ar(A,d?s:i,B[2]),D=as(h.cameraToCenterDistance,C.signedDistanceFromCamera);let E=g.evaluateSizeForFeature(b.textSizeData,l,x)*D/a.ONE_EM;d&&(E*=b.tilePixelRatio/k);const{width:F,height:G,anchor:H,textOffset:I,textScale:J}=z,K=bQ(H,F,G,I,J,E),L=d?ar(A.add(K),i,B[2]).point:C.point.add(c?K.rotate(-h.angle):K),M=b.allowVerticalPlacement&&x.placedOrientation===a.WritingMode.vertical?Math.PI/2:0;for(let N=0;N<x.numGlyphs;N++)a.addDynamicAttributes(p,L,M);m&&x.associatedIconIndex>=0&&(r[x.associatedIconIndex]={shiftedAnchor:L,angle:M})}else aC(x.numGlyphs,p)}if(m){q.clear();const O=b.icon.placedSymbolArray;for(let P=0;P<O.length;P++){const Q=O.get(P);if(Q.hidden)aC(Q.numGlyphs,q);else{const R=r[P];if(R)for(let S=0;S<Q.numGlyphs;S++)a.addDynamicAttributes(q,R.shiftedAnchor,R.angle);else aC(Q.numGlyphs,q)}}b.icon.dynamicLayoutVertexBuffer.updateData(q)}b.text.dynamicLayoutVertexBuffer.updateData(p)}function bS(a,b,c){return c.iconsInText&&b?"symbolTextAndIcon":a?"symbolSDF":"symbolIcon"}function bT(b,c,d,f,g,h,i,j,k,l,m,n){const o=b.context,p=o.gl,q=b.transform,r=q.projection.createTileTransform(q,q.worldSize),s="map"===j,u="map"===k,v=s&&"point"!==d.layout.get("symbol-placement"),w=s&&!u&&!v,x=void 0!==d.layout.get("symbol-sort-key").constantOr(1);let y=!1;const z=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),A=[a.mercatorXfromLng(q.center.lng),a.mercatorYfromLat(q.center.lat),],B=d.layout.get("text-variable-anchor"),C="globe"===q.projection.name,D=C?a.globeToMercatorTransition(q.zoom):0,E=[],F=[];for(const G of(b.terrain&&u&&F.push("PITCH_WITH_MAP_TERRAIN"),C&&F.push("PROJECTION_GLOBE_VIEW"),v&&F.push("PROJECTED_POS_ON_VIEWPORT"),f)){const H=c.getTile(G),I=H.getBucket(d);if(!I||I.projection!==q.projection.name)continue;const J=g?I.text:I.icon;if(!J||I.fullyClipped||!J.segments.get().length)continue;const K=J.programConfigurations.get(d.id),L=g||I.sdfIcons,M=g?I.textSizeData:I.iconSizeData,N=u||0!==q.pitch,O=b.useProgram(bS(L,g,I),K,F),P=a.evaluateSizeForZoom(M,q.zoom),Q=[G.canonical.x,G.canonical.y,1<<G.canonical.z,];let R,S,T,U,V=[0,0],W=null;if(g){if(S=H.glyphAtlasTexture,T=p.LINEAR,R=H.glyphAtlasTexture.size,I.iconsInText){V=H.imageAtlasTexture.size,W=H.imageAtlasTexture;const X="composite"===M.kind||"camera"===M.kind;U=N||b.options.rotating||b.options.zooming||X?p.LINEAR:p.NEAREST}}else{const Y=1!==d.layout.get("icon-size").constantOr(0)||I.iconsNeedLinear;S=H.imageAtlasTexture,T=L||b.options.rotating||b.options.zooming||Y||N?p.LINEAR:p.NEAREST,R=H.imageAtlasTexture.size}const Z=b.transform.calculatePixelsToTileUnitsMatrix(H),$=ap(G.projMatrix,H.tileID.canonical,u,s,b.transform,Z),_=b.terrain&&u&&v?a.invert(new Float32Array(16),$):bP,aa=aq(G.projMatrix,H.tileID.canonical,u,s,b.transform,Z),ab=B&&I.hasTextData(),ac="none"!==d.layout.get("icon-text-fit")&&ab&&I.hasIconData();if(v){const ad=q.elevation,ae=ad?ad.getAtTileOffsetFunc(G,r):a=>[0,0,0];au(I,G.projMatrix,b,g,$,aa,u,l,ae,G)}const af=b.translatePosMatrix(G.projMatrix,H,h,i),ag=v||g&&B||ac?bP:$,ah=b.translatePosMatrix(aa,H,h,i,!0),ai=L&&0!==d.paint.get(g?"text-halo-width":"icon-halo-width").constantOr(1);let aj;const ak=r.createInversionMatrix(G.toUnwrapped());aj=L?I.iconsInText?bJ(M.kind,P,w,u,b,af,ag,ah,R,V,Q,D,ak,A):bI(M.kind,P,w,u,b,af,ag,ah,g,R,!0,Q,D,ak,A):bH(M.kind,P,w,u,b,af,ag,ah,g,R,Q,D,ak,A);const al={program:O,buffers:J,uniformValues:aj,atlasTexture:S,atlasTextureIcon:W,atlasInterpolation:T,atlasInterpolationIcon:U,isSDF:L,hasHalo:ai,tile:H,labelPlaneMatrixInv:_};if(x&&I.canOverlap){y=!0;const am=J.segments.get();for(const an of am)E.push({segments:new a.SegmentVector([an]),sortKey:an.sortKey,state:al})}else E.push({segments:J.segments,sortKey:0,state:al})}for(const ao of(y&&E.sort((a,b)=>a.sortKey-b.sortKey),E)){const ar=ao.state;if(b.terrain&&b.terrain.setupElevationDraw(ar.tile,ar.program,{useDepthForOcclusion:!C,labelPlaneMatrixInv:ar.labelPlaneMatrixInv}),o.activeTexture.set(p.TEXTURE0),ar.atlasTexture.bind(ar.atlasInterpolation,p.CLAMP_TO_EDGE),ar.atlasTextureIcon&&(o.activeTexture.set(p.TEXTURE1),ar.atlasTextureIcon&&ar.atlasTextureIcon.bind(ar.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),ar.isSDF){const as=ar.uniformValues;ar.hasHalo&&(as.u_is_halo=1,bU(ar.buffers,ao.segments,d,b,ar.program,z,m,n,as)),as.u_is_halo=0}bU(ar.buffers,ao.segments,d,b,ar.program,z,m,n,ar.uniformValues)}}function bU(b,c,d,f,g,h,i,j,k){const l=f.context;g.draw(l,l.gl.TRIANGLES,h,i,j,a.CullFaceMode.disabled,k,d.id,b.layoutVertexBuffer,b.indexBuffer,c,d.paint,f.transform.zoom,b.programConfigurations.get(d.id),b.dynamicLayoutVertexBuffer,b.opacityVertexBuffer)}function bV(b,c,d,f,g,h,i){const j=b.context.gl,k=d.paint.get("fill-pattern"),l=k&&k.constantOr(1),m=d.getCrossfadeParameters();let n,o,p,q,r;for(const s of(i?(o=l&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",n=j.LINES):(o=l?"fillPattern":"fill",n=j.TRIANGLES),f)){const u=c.getTile(s);if(l&&!u.patternsLoaded())continue;const v=u.getBucket(d);if(!v)continue;b.prepareDrawTile(s);const w=v.programConfigurations.get(d.id),x=b.useProgram(o,w);l&&(b.context.activeTexture.set(j.TEXTURE0),u.imageAtlasTexture.bind(j.LINEAR,j.CLAMP_TO_EDGE),w.updatePaintBuffers(m));const y=k.constantOr(null);if(y&&u.imageAtlas){const z=u.imageAtlas,A=z.patternPositions[y.to.toString()],B=z.patternPositions[y.from.toString()];A&&B&&w.setConstantPatternPositions(A,B)}const C=b.translatePosMatrix(s.projMatrix,u,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(i){q=v.indexBuffer2,r=v.segments2;const D=b.terrain&&b.terrain.renderingToTexture?b.terrain.drapeBufferSize:[j.drawingBufferWidth,j.drawingBufferHeight,];p="fillOutlinePattern"===o&&l?bu(C,b,m,u,D):bt(C,D)}else q=v.indexBuffer,r=v.segments,p=l?bs(C,b,m,u):br(C);b.prepareDrawProgram(b.context,x,s.toUnwrapped()),x.draw(b.context,n,g,b.stencilModeForClipping(s),h,a.CullFaceMode.disabled,p,d.id,v.layoutVertexBuffer,q,r,d.paint,b.transform.zoom,w)}}function bW(b,c,d,f,g,h,i){const j=b.context,k=j.gl,l=d.paint.get("fill-extrusion-pattern"),m=l.constantOr(1),n=d.getCrossfadeParameters(),o=d.paint.get("fill-extrusion-opacity");for(const p of f){const q=c.getTile(p),r=q.getBucket(d);if(!r)continue;const s=r.programConfigurations.get(d.id),u=b.useProgram(m?"fillExtrusionPattern":"fillExtrusion",s);if(b.terrain){const v=b.terrain;if(!r.enableTerrain)continue;if(v.setupElevationDraw(q,u,{useMeterToDem:!0}),bX(j,c,p,r,d,v),!r.centroidVertexBuffer){const w=u.attributes.a_centroid_pos;void 0!==w&&k.vertexAttrib2f(w,0,0)}}m&&(b.context.activeTexture.set(k.TEXTURE0),q.imageAtlasTexture.bind(k.LINEAR,k.CLAMP_TO_EDGE),s.updatePaintBuffers(n));const x=l.constantOr(null);if(x&&q.imageAtlas){const y=q.imageAtlas,z=y.patternPositions[x.to.toString()],A=y.patternPositions[x.from.toString()];z&&A&&s.setConstantPatternPositions(z,A)}const B=b.translatePosMatrix(p.projMatrix,q,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),C=d.paint.get("fill-extrusion-vertical-gradient"),D=m?bq(B,b,C,o,p,n,q):bp(B,b,C,o);b.prepareDrawProgram(j,u,p.toUnwrapped()),u.draw(j,j.gl.TRIANGLES,g,h,i,a.CullFaceMode.backCCW,D,d.id,r.layoutVertexBuffer,r.indexBuffer,r.segments,d.paint,b.transform.zoom,s,b.terrain?r.centroidVertexBuffer:null)}}function bX(b,c,d,f,g,h){const i=[b=>{let c=b.canonical.x-1,d=b.wrap;return c<0&&(c=(1<<b.canonical.z)-1,d--),new a.OverscaledTileID(b.overscaledZ,d,b.canonical.z,c,b.canonical.y)},b=>{let c=b.canonical.x+1,d=b.wrap;return c===1<<b.canonical.z&&(c=0,d++),new a.OverscaledTileID(b.overscaledZ,d,b.canonical.z,c,b.canonical.y)},b=>new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,(0===b.canonical.y?1<<b.canonical.z:b.canonical.y)-1),b=>new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,b.canonical.y===(1<<b.canonical.z)-1?0:b.canonical.y+1),],j=a=>{const b=c.getSource().maxzoom,d=a=>{const b=c.getTileByID(a);if(b&&b.hasData())return b.getBucket(g)};let f,h,i;return(a.overscaledZ===a.canonical.z||a.overscaledZ>=b)&&(f=d(a.key)),a.overscaledZ>=b&&(h=d(a.calculateScaledKey(a.overscaledZ+1))),a.overscaledZ>b&&(i=d(a.calculateScaledKey(a.overscaledZ-1))),f||h||i},k=[0,0,0],l=(b,c)=>(k[0]=Math.min(b.min.y,c.min.y),k[1]=Math.max(b.max.y,c.max.y),k[2]=a.EXTENT-c.min.x>b.max.x?c.min.x-a.EXTENT:b.max.x,k),m=(b,c)=>(k[0]=Math.min(b.min.x,c.min.x),k[1]=Math.max(b.max.x,c.max.x),k[2]=a.EXTENT-c.min.y>b.max.y?c.min.y-a.EXTENT:b.max.y,k),n=[(a,b)=>l(a,b),(a,b)=>l(b,a),(a,b)=>m(a,b),(a,b)=>m(b,a),],o=new a.pointGeometry(0,0);let p,q,r;const s=(b,c,f,g,i)=>{const j=[[g?f:b,g?b:f,0],[g?f:c,g?c:f,0],],k=i<0?a.EXTENT+i:i,l=[g?k:(b+c)/2,g?(b+c)/2:k,0,];return 0===f&&i<0||0!==f&&i>0?h.getForTilePoints(r,[l],!0,q):j.push(l),h.getForTilePoints(d,j,!0,p),Math.max(j[0][2],j[1][2],l[2])/h.exaggeration()};for(let u=0;u<4;u++){const v=f.borders[u];if(0===v.length&&(f.borderDone[u]=!0),f.borderDone[u])continue;const w=r=i[u](d),x=j(w);if(!x||!x.enableTerrain||!(q=h.findDEMTileFor(w))||!q.dem)continue;if(!p){const y=h.findDEMTileFor(d);if(!y||!y.dem)return;p=y}const z=(u<2?1:5)-u,A=x.borders[z];let B=0;for(let C=0;C<v.length;C++){const D=f.featuresOnBorder[v[C]],E=D.borders[u];let F;for(;B<A.length&&!((F=x.featuresOnBorder[A[B]]).borders[z][1]>E[0]+3);)x.borderDone[z]||x.encodeCentroid(void 0,F,!1),B++;if(F&&B<A.length){const G=B;let H=0;for(;!(F.borders[z][0]>E[1]-3)&&(H++,++B!==A.length);)F=x.featuresOnBorder[A[B]];if(F=x.featuresOnBorder[A[G]],D.intersectsCount()>1||F.intersectsCount()>1||1!==H){1!==H&&(B=G),f.encodeCentroid(void 0,D,!1),x.borderDone[z]||x.encodeCentroid(void 0,F,!1);continue}const I=n[u](D,F),J=u%2?a.EXTENT-1:0;o.x=s(I[0],Math.min(a.EXTENT-1,I[1]),J,u<2,I[2]),o.y=0,f.encodeCentroid(o,D,!1),x.borderDone[z]||x.encodeCentroid(o,F,!1)}else f.encodeCentroid(void 0,D,!1)}f.borderDone[u]=f.needsCentroidUpdate=!0,x.borderDone[z]||(x.borderDone[z]=x.needsCentroidUpdate=!0)}(f.needsCentroidUpdate|| !f.centroidVertexBuffer&&0!==f.centroidVertexArray.length)&&f.uploadCentroid(b)}const bY=new a.Color(1,0,0,1),bZ=new a.Color(0,1,0,1),b$=new a.Color(0,0,1,1),b_=new a.Color(1,0,1,1),b0=new a.Color(0,1,1,1);function b1(a,b,c,d){b3(a,0,b+c/2,a.transform.width,c,d)}function b2(a,b,c,d){b3(a,b-c/2,0,c,a.transform.height,d)}function b3(b,c,d,f,g,h){const i=b.context,j=i.gl;j.enable(j.SCISSOR_TEST),j.scissor(c*a.exported.devicePixelRatio,d*a.exported.devicePixelRatio,f*a.exported.devicePixelRatio,g*a.exported.devicePixelRatio),i.clear({color:h}),j.disable(j.SCISSOR_TEST)}function b4(b,c,d){const f=b.context,g=f.gl,h=d.projMatrix,i=b.useProgram("debug"),j=c.getTileByID(d.key);b.terrain&&b.terrain.setupElevationDraw(j,i);const k=a.DepthMode.disabled,l=a.StencilMode.disabled,m=b.colorModeForRenderPass(),n="$debug";f.activeTexture.set(g.TEXTURE0),b.emptyTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),j._makeDebugTileBoundsBuffers(b.context,b.transform.projection);const o=j._tileDebugBuffer||b.debugBuffer,p=j._tileDebugIndexBuffer||b.debugIndexBuffer,q=j._tileDebugSegments||b.debugSegments;i.draw(f,g.LINE_STRIP,k,l,m,a.CullFaceMode.disabled,by(h,a.Color.red),n,o,p,q);const r=j.latestRawTileData,s=Math.floor((r&&r.byteLength||0)/1024),u=c.getTile(d).tileSize,v=512/Math.min(u,512)*(d.overscaledZ/b.transform.zoom)*.5;let w=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(w+=` => ${d.overscaledZ}`),function(a,b){a.initDebugOverlayCanvas();const c=a.debugOverlayCanvas,d=a.context.gl,f=a.debugOverlayCanvas.getContext("2d");f.clearRect(0,0,c.width,c.height),f.shadowColor="white",f.shadowBlur=2,f.lineWidth=1.5,f.strokeStyle="white",f.textBaseline="top",f.font="bold 36px Open Sans, sans-serif",f.fillText(b,5,5),f.strokeText(b,5,5),a.debugOverlayTexture.update(c),a.debugOverlayTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE)}(b,`${w} ${s}kb`),i.draw(f,g.TRIANGLES,k,l,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,by(h,a.Color.transparent,v),n,b.debugBuffer,b.quadTriangleIndexBuffer,b.debugSegments)}const b5=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"},]),{members:b6}=b5;function b7(a,b,c,d){a.emplaceBack(b,c,d)}class b8{constructor(b){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,b7(this.vertexArray,-1,-1,1),b7(this.vertexArray,1,-1,1),b7(this.vertexArray,-1,1,1),b7(this.vertexArray,1,1,1),b7(this.vertexArray,-1,-1,-1),b7(this.vertexArray,1,-1,-1),b7(this.vertexArray,-1,1,-1),b7(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=b.createVertexBuffer(this.vertexArray,b6),this.indexBuffer=b.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function b9(b,c,d,f,g,h){var i,j,k,l,m;const n=b.gl,o=c.paint.get("sky-atmosphere-color"),p=c.paint.get("sky-atmosphere-halo-color"),q=c.paint.get("sky-atmosphere-sun-intensity"),r=(i=a.fromMat4([],f),j=g,k=q,l=o,m=p,{u_matrix_3f:i,u_sun_direction:j,u_sun_intensity:k,u_color_tint_r:[l.r,l.g,l.b,l.a],u_color_tint_m:[m.r,m.g,m.b,m.a],u_luminance:5e-5});n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+h,c.skyboxTexture,0),d.draw(b,n.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,r,"skyboxCapture",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)}const ca={symbol:function(b,c,d,f,g){if("translucent"!==b.renderPass)return;const h=a.StencilMode.disabled,i=b.colorModeForRenderPass();d.layout.get("text-variable-anchor")&&function(b,c,d,f,g,h,i){const j=c.transform,k="map"===g,l="map"===h,m=j.projection.createTileTransform(j,j.worldSize);for(const n of b){const o=f.getTile(n),p=o.getBucket(d);if(!p||p.projection!==j.projection.name||!p.text||!p.text.segments.get().length)continue;const q=a.evaluateSizeForZoom(p.textSizeData,j.zoom),r=c.transform.calculatePixelsToTileUnitsMatrix(o),s=ap(n.projMatrix,o.tileID.canonical,l,k,c.transform,r),u="none"!==d.layout.get("icon-text-fit")&&p.hasIconData();if(q){const v=Math.pow(2,j.zoom-o.tileID.overscaledZ);bR(p,k,l,i,a.symbolSize,j,s,n,v,q,u,m)}}}(f,b,d,c,d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),g),0!==d.paint.get("icon-opacity").constantOr(1)&&bT(b,c,d,f,!1,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),d.layout.get("icon-rotation-alignment"),d.layout.get("icon-pitch-alignment"),d.layout.get("icon-keep-upright"),h,i),0!==d.paint.get("text-opacity").constantOr(1)&&bT(b,c,d,f,!0,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),d.layout.get("text-keep-upright"),h,i),c.map.showCollisionBoxes&&(bO(b,c,d,f,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),!0),bO(b,c,d,f,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),!1))},circle:function(b,c,d,f){if("translucent"!==b.renderPass)return;const g=d.paint.get("circle-opacity"),h=d.paint.get("circle-stroke-width"),i=d.paint.get("circle-stroke-opacity"),j=void 0!==d.layout.get("circle-sort-key").constantOr(1);if(0===g.constantOr(1)&&(0===h.constantOr(1)||0===i.constantOr(1)))return;const k=b.context,l=k.gl,m=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),n=a.StencilMode.disabled,o=b.colorModeForRenderPass(),p=[];for(let q=0;q<f.length;q++){const r=f[q],s=c.getTile(r),u=s.getBucket(d);if(!u)continue;const v=u.programConfigurations.get(d.id),w=bw(d),x={programConfiguration:v,program:b.useProgram("circle",v,w),layoutVertexBuffer:u.layoutVertexBuffer,indexBuffer:u.indexBuffer,uniformValues:bv(b,r,s,d),tile:s};if(j){const y=u.segments.get();for(const z of y)p.push({segments:new a.SegmentVector([z,]),sortKey:z.sortKey,state:x})}else p.push({segments:u.segments,sortKey:0,state:x})}j&&p.sort((a,b)=>a.sortKey-b.sortKey);const A={useDepthForOcclusion:"globe"!==b.transform.projection.name};for(const B of p){const{programConfiguration:C,program:D,layoutVertexBuffer:E,indexBuffer:F,uniformValues:G,tile:H}=B.state,I=B.segments;b.terrain&&b.terrain.setupElevationDraw(H,D,A),b.prepareDrawProgram(k,D,H.tileID.toUnwrapped()),D.draw(k,l.TRIANGLES,m,n,o,a.CullFaceMode.disabled,G,d.id,E,F,I,d.paint,b.transform.zoom,C)}},heatmap:function(b,c,d,f){if(0!==d.paint.get("heatmap-opacity")){if("offscreen"===b.renderPass){const g=b.context,h=g.gl,i=a.StencilMode.disabled,j=new a.ColorMode([h.ONE,h.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(a,b,c){const d=a.gl;a.activeTexture.set(d.TEXTURE1),a.viewport.set([0,0,b.width/4,b.height/4,]);let f=c.heatmapFbo;if(f)d.bindTexture(d.TEXTURE_2D,f.colorAttachment.get()),a.bindFramebuffer.set(f.framebuffer);else{const g=d.createTexture();d.bindTexture(d.TEXTURE_2D,g),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.LINEAR),f=c.heatmapFbo=a.createFramebuffer(b.width/4,b.height/4,!1),function(a,b,c,d){const f=a.gl;f.texImage2D(f.TEXTURE_2D,0,f.RGBA,b.width/4,b.height/4,0,f.RGBA,a.extRenderToTextureHalfFloat?a.extTextureHalfFloat.HALF_FLOAT_OES:f.UNSIGNED_BYTE,null),d.colorAttachment.set(c)}(a,b,g,f)}})(g,b,d),g.clear({color:a.Color.transparent});for(let k=0;k<f.length;k++){const l=f[k];if(c.hasRenderableParent(l))continue;const m=c.getTile(l),n=m.getBucket(d);if(!n)continue;const o=n.programConfigurations.get(d.id),p=b.useProgram("heatmap",o),{zoom:q}=b.transform;b.terrain&&b.terrain.setupElevationDraw(m,p),b.prepareDrawProgram(g,p,l.toUnwrapped()),p.draw(g,h.TRIANGLES,a.DepthMode.disabled,i,j,a.CullFaceMode.disabled,bz(l.projMatrix,m,q,d.paint.get("heatmap-intensity")),d.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,d.paint,b.transform.zoom,o)}g.viewport.set([0,0,b.width,b.height,])}else"translucent"===b.renderPass&&(b.context.setColorMode(b.colorModeForRenderPass()),function(b,c){const d=b.context,f=d.gl,g=c.heatmapFbo;if(!g)return;d.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,g.colorAttachment.get()),d.activeTexture.set(f.TEXTURE1);let h=c.colorRampTexture;h||(h=c.colorRampTexture=new a.Texture(d,c.colorRamp,f.RGBA)),h.bind(f.LINEAR,f.CLAMP_TO_EDGE),b.useProgram("heatmapTexture").draw(d,f.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,{u_image:0,u_color_ramp:1,u_opacity:c.paint.get("heatmap-opacity")},c.id,b.viewportBuffer,b.quadTriangleIndexBuffer,b.viewportSegments,c.paint,b.transform.zoom)}(b,d))}},line:function(b,c,d,f){if("translucent"!==b.renderPass)return;const g=d.paint.get("line-opacity"),h=d.paint.get("line-width");if(0===g.constantOr(1)||0===h.constantOr(1))return;const i=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),j=b.colorModeForRenderPass(),k=d.paint.get("line-dasharray"),l=k.constantOr(1),m=d.layout.get("line-cap"),n=d.paint.get("line-pattern"),o=n.constantOr(1),p=d.paint.get("line-gradient"),q=d.getCrossfadeParameters(),r=o?"linePattern":"line",s=b.context,u=s.gl,v=(a=>{const b=[];bE(a)&&b.push("RENDER_LINE_DASH"),a.paint.get("line-gradient")&&b.push("RENDER_LINE_GRADIENT");const c=a.paint.get("line-pattern").constantOr(1),d=1!==a.paint.get("line-opacity").constantOr(1);return!c&&d&&b.push("RENDER_LINE_ALPHA_DISCARD"),b})(d);let w=v.includes("RENDER_LINE_ALPHA_DISCARD");for(const x of(b.terrain&&b.terrain.clipOrMaskOverlapStencilType()&&(w=!1),f)){const y=c.getTile(x);if(o&&!y.patternsLoaded())continue;const z=y.getBucket(d);if(!z)continue;b.prepareDrawTile(x);const A=z.programConfigurations.get(d.id),B=b.useProgram(r,A,v),C=n.constantOr(null);if(C&&y.imageAtlas){const D=y.imageAtlas,E=D.patternPositions[C.to.toString()],F=D.patternPositions[C.from.toString()];E&&F&&A.setConstantPatternPositions(E,F)}const G=k.constantOr(null),H=m.constantOr(null);if(!o&&G&&H&&y.lineAtlas){const I=y.lineAtlas,J=I.getDash(G.to,H),K=I.getDash(G.from,H);J&&K&&A.setConstantPatternPositions(J,K)}const L=b.terrain?x.projMatrix:null,M=o?bB(b,y,d,q,L):bA(b,y,d,q,L,z.lineClipsArray.length);if(p){const N=z.gradients[d.id];let O=N.texture;if(d.gradientVersion!==N.version){let P=256;if(d.stepInterpolant){const Q=c.getSource().maxzoom,R=x.canonical.z===Q?Math.ceil(1<<b.transform.maxZoom-x.canonical.z):1;P=a.clamp(a.nextPowerOfTwo(z.maxLineLength/a.EXTENT*1024*R),256,s.maxTextureSize)}N.gradient=a.renderColorRamp({expression:d.gradientExpression(),evaluationKey:"lineProgress",resolution:P,image:N.gradient||void 0,clips:z.lineClipsArray}),N.texture?N.texture.update(N.gradient):N.texture=new a.Texture(s,N.gradient,u.RGBA),N.version=d.gradientVersion,O=N.texture}s.activeTexture.set(u.TEXTURE1),O.bind(d.stepInterpolant?u.NEAREST:u.LINEAR,u.CLAMP_TO_EDGE)}l&&(s.activeTexture.set(u.TEXTURE0),y.lineAtlasTexture.bind(u.LINEAR,u.REPEAT),A.updatePaintBuffers(q)),o&&(s.activeTexture.set(u.TEXTURE0),y.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),A.updatePaintBuffers(q)),b.prepareDrawProgram(s,B,x.toUnwrapped());const S=c=>{B.draw(s,u.TRIANGLES,i,c,j,a.CullFaceMode.disabled,M,d.id,z.layoutVertexBuffer,z.indexBuffer,z.segments,d.paint,b.transform.zoom,A,z.layoutVertexBuffer2)};if(w){const T=b.stencilModeForClipping(x).ref;0===T&&b.terrain&&s.clear({stencil:0});const U={func:u.EQUAL,mask:255};M.u_alpha_discard_threshold=.8,S(new a.StencilMode(U,T,255,u.KEEP,u.KEEP,u.INVERT)),M.u_alpha_discard_threshold=0,S(new a.StencilMode(U,T,255,u.KEEP,u.KEEP,u.KEEP))}else S(b.stencilModeForClipping(x))}w&&(b.resetStencilClippingMasks(),b.terrain&&s.clear({stencil:0}))},fill:function(b,c,d,f){const g=d.paint.get("fill-color"),h=d.paint.get("fill-opacity");if(0===h.constantOr(1))return;const i=b.colorModeForRenderPass(),j=d.paint.get("fill-pattern"),k=b.opaquePassEnabledForLayer()&&!j.constantOr(1)&&1===g.constantOr(a.Color.transparent).a&&1===h.constantOr(0)?"opaque":"translucent";if(b.renderPass===k){const l=b.depthModeForSublayer(1,"opaque"===b.renderPass?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);bV(b,c,d,f,l,i,!1)}if("translucent"===b.renderPass&&d.paint.get("fill-antialias")){const m=b.depthModeForSublayer(d.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);bV(b,c,d,f,m,i,!0)}},"fill-extrusion":function(b,c,d,f){const g=d.paint.get("fill-extrusion-opacity");if(0!==g&&"translucent"===b.renderPass){const h=new a.DepthMode(b.context.gl.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);if(1!==g||d.paint.get("fill-extrusion-pattern").constantOr(1))bW(b,c,d,f,h,a.StencilMode.disabled,a.ColorMode.disabled),bW(b,c,d,f,h,b.stencilModeFor3D(),b.colorModeForRenderPass()),b.resetStencilClippingMasks();else{const i=b.colorModeForRenderPass();bW(b,c,d,f,h,a.StencilMode.disabled,i)}}},hillshade:function(b,c,d,f){if("offscreen"!==b.renderPass&&"translucent"!==b.renderPass)return;const g=b.context,h=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),i=b.colorModeForRenderPass(),j=b.terrain&&b.terrain.renderingToTexture,[k,l]="translucent"!==b.renderPass||j?[{},f]:b.stencilConfigForOverlap(f);for(const m of l){const n=c.getTile(m);if(n.needsHillshadePrepare&&"offscreen"===b.renderPass)a8(b,n,d,h,a.StencilMode.disabled,i);else if("translucent"===b.renderPass){const o=j&&b.terrain?b.terrain.stencilModeForRTTOverlap(m):k[m.overscaledZ];a6(b,m,n,d,h,o,i)}}g.viewport.set([0,0,b.width,b.height]),b.resetStencilClippingMasks()},raster:function(b,c,d,f,g,h){if("translucent"!==b.renderPass||0===d.paint.get("raster-opacity")||!f.length)return;const i=b.context,j=i.gl,k=c.getSource(),l=b.useProgram("raster"),m=b.colorModeForRenderPass(),n=b.terrain&&b.terrain.renderingToTexture,[o,p]=k instanceof S||n?[{},f]:b.stencilConfigForOverlap(f),q=p[p.length-1].overscaledZ,r=!b.options.moving;for(const s of p){const u=n?a.DepthMode.disabled:b.depthModeForSublayer(s.overscaledZ-q,1===d.paint.get("raster-opacity")?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,j.LESS),v=s.toUnwrapped(),w=c.getTile(s);if(n&&(!w||!w.hasData()))continue;const x=n?s.projMatrix:b.transform.calculateProjMatrix(v,r),y=b.terrain&&n?b.terrain.stencilModeForRTTOverlap(s):o[s.overscaledZ],z=h?0:d.paint.get("raster-fade-duration");w.registerFadeDuration(z);const A=c.findLoadedParent(s,0),B=bh(w,A,c,b.transform,z);let C,D;b.terrain&&b.terrain.prepareDrawTile(s);const E="nearest"===d.paint.get("raster-resampling")?j.NEAREST:j.LINEAR;i.activeTexture.set(j.TEXTURE0),w.texture.bind(E,j.CLAMP_TO_EDGE),i.activeTexture.set(j.TEXTURE1),A?(A.texture.bind(E,j.CLAMP_TO_EDGE),C=Math.pow(2,A.tileID.overscaledZ-w.tileID.overscaledZ),D=[w.tileID.canonical.x*C%1,w.tileID.canonical.y*C%1,]):w.texture.bind(E,j.CLAMP_TO_EDGE);const F=bF(x,D||[0,0],C||1,B,d,k instanceof S?k.perspectiveTransform:[0,0]);if(b.prepareDrawProgram(i,l,v),k instanceof S)l.draw(i,j.TRIANGLES,u,a.StencilMode.disabled,m,a.CullFaceMode.disabled,F,d.id,k.boundsBuffer,b.quadTriangleIndexBuffer,k.boundsSegments);else{const{tileBoundsBuffer:G,tileBoundsIndexBuffer:H,tileBoundsSegments:I}=b.getTileBoundsBuffers(w);l.draw(i,j.TRIANGLES,u,y,m,a.CullFaceMode.disabled,F,d.id,G,H,I)}}b.resetStencilClippingMasks()},background:function(b,c,d,f){const g=d.paint.get("background-color"),h=d.paint.get("background-opacity");if(0===h)return;const i=b.context,j=i.gl,k=b.transform,l=k.tileSize,m=d.paint.get("background-pattern");if(b.isPatternMissing(m))return;const n=!m&&1===g.a&&1===h&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==n)return;const o=a.StencilMode.disabled,p=b.depthModeForSublayer(0,"opaque"===n?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),q=b.colorModeForRenderPass(),r=b.useProgram(m?"backgroundPattern":"background");let s,u=f;u||(u=Object.values(s=b.getBackgroundTiles()).map(a=>a.tileID)),m&&(i.activeTexture.set(j.TEXTURE0),b.imageManager.bind(b.context));const v=d.getCrossfadeParameters();for(const w of u){const x=w.toUnwrapped(),y=f?w.projMatrix:b.transform.calculateProjMatrix(x);b.prepareDrawTile(w);const z=c?c.getTile(w):s?s[w.key]:new a.Tile(w,l,k.zoom,b),A=m?bL(y,h,b,m,{tileID:w,tileSize:l},v):bK(y,h,g);b.prepareDrawProgram(i,r,x);const{tileBoundsBuffer:B,tileBoundsIndexBuffer:C,tileBoundsSegments:D}=b.getTileBoundsBuffers(z);r.draw(i,j.TRIANGLES,p,o,q,a.CullFaceMode.disabled,A,d.id,B,C,D)}},sky:function(b,c,d){const f=b.transform,g="mercator"===f.projection.name||"globe"===f.projection.name?1:a.smoothstep(7,8,f.zoom),h=d.paint.get("sky-opacity")*g;if(0===h)return;const i=b.context,j=d.paint.get("sky-type"),k=new a.DepthMode(i.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),l=b.frameCounter/1e3%1;"atmosphere"===j?"offscreen"===b.renderPass?d.needsSkyboxCapture(b)&&(function(b,c,d,f){const g=b.context,h=g.gl;let i=c.skyboxFbo;if(!i){i=c.skyboxFbo=g.createFramebuffer(32,32,!1),c.skyboxGeometry=new b8(g),c.skyboxTexture=g.gl.createTexture(),h.bindTexture(h.TEXTURE_CUBE_MAP,c.skyboxTexture),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,h.LINEAR);for(let j=0;j<6;++j)h.texImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,h.RGBA,32,32,0,h.RGBA,h.UNSIGNED_BYTE,null)}g.bindFramebuffer.set(i.framebuffer),g.viewport.set([0,0,32,32,]);const k=c.getCenter(b,!0),l=b.useProgram("skyboxCapture"),m=new Float64Array(16);a.identity(m),a.rotateY(m,m,-(.5*Math.PI)),b9(g,c,l,m,k,0),a.identity(m),a.rotateY(m,m,.5*Math.PI),b9(g,c,l,m,k,1),a.identity(m),a.rotateX(m,m,-(.5*Math.PI)),b9(g,c,l,m,k,2),a.identity(m),a.rotateX(m,m,.5*Math.PI),b9(g,c,l,m,k,3),a.identity(m),b9(g,c,l,m,k,4),a.identity(m),a.rotateY(m,m,Math.PI),b9(g,c,l,m,k,5),g.viewport.set([0,0,b.width,b.height,])}(b,d),d.markSkyboxValid(b)):"sky"===b.renderPass&&function(b,c,d,f,g){var h,i;const j=b.context,k=j.gl,l=b.transform,m=b.useProgram("skybox");j.activeTexture.set(k.TEXTURE0),k.bindTexture(k.TEXTURE_CUBE_MAP,c.skyboxTexture);const n=(h=l.skyboxMatrix,i=c.getCenter(b,!1),{u_matrix:h,u_sun_direction:i,u_cubemap:0,u_opacity:f,u_temporal_offset:g});b.prepareDrawProgram(j,m),m.draw(j,k.TRIANGLES,d,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.backCW,n,"skybox",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)}(b,d,k,h,l):"gradient"===j&&"sky"===b.renderPass&&function(b,c,d,f,g){var h,i,j,k,l;const m=b.context,n=m.gl,o=b.transform,p=b.useProgram("skyboxGradient");c.skyboxGeometry||(c.skyboxGeometry=new b8(m)),m.activeTexture.set(n.TEXTURE0);let q=c.colorRampTexture;q||(q=c.colorRampTexture=new a.Texture(m,c.colorRamp,n.RGBA)),q.bind(n.LINEAR,n.CLAMP_TO_EDGE);const r=(h=o.skyboxMatrix,i=c.getCenter(b,!1),j=c.paint.get("sky-gradient-radius"),k=f,l=g,{u_matrix:h,u_color_ramp:0,u_center_direction:i,u_radius:a.degToRad(j),u_opacity:k,u_temporal_offset:l});b.prepareDrawProgram(m,p),p.draw(m,n.TRIANGLES,d,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.backCW,r,"skyboxGradient",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)}(b,d,k,h,l)},debug:function(a,b,c){for(let d=0;d<c.length;d++)b4(a,b,c[d])},custom:function(b,c,d){const f=b.context,g=d.implementation;if(b.transform.projection.unsupportedLayers&&b.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("offscreen"===b.renderPass){const h=g.prerender;h&&(b.setCustomLayerDefaults(),f.setColorMode(b.colorModeForRenderPass()),h.call(g,f.gl,b.transform.customLayerMatrix()),f.setDirty(),b.setBaseState())}else if("translucent"===b.renderPass){b.setCustomLayerDefaults(),f.setColorMode(b.colorModeForRenderPass()),f.setStencilMode(a.StencilMode.disabled);const i="3d"===g.renderingMode?new a.DepthMode(b.context.gl.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D):b.depthModeForSublayer(0,a.DepthMode.ReadOnly);f.setDepthMode(i),g.render(f.gl,b.transform.customLayerMatrix()),f.setDirty(),b.setBaseState(),f.bindFramebuffer.set(null)}}};class cb{constructor(b,c){this.context=new class{constructor(b){this.gl=b,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new class extends G{getDefault(){return a.Color.transparent}set(a){const b=this.current;(a.r!==b.r||a.g!==b.g||a.b!==b.b||a.a!==b.a||this.dirty)&&(this.gl.clearColor(a.r,a.g,a.b,a.a),this.current=a,this.dirty=!1)}}(this),this.clearDepth=new class extends G{getDefault(){return 1}set(a){(a!==this.current||this.dirty)&&(this.gl.clearDepth(a),this.current=a,this.dirty=!1)}}(this),this.clearStencil=new class extends G{getDefault(){return 0}set(a){(a!==this.current||this.dirty)&&(this.gl.clearStencil(a),this.current=a,this.dirty=!1)}}(this),this.colorMask=new class extends G{getDefault(){return[!0,!0,!0,!0]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||a[2]!==b[2]||a[3]!==b[3]||this.dirty)&&(this.gl.colorMask(a[0],a[1],a[2],a[3]),this.current=a,this.dirty=!1)}}(this),this.depthMask=new class extends G{getDefault(){return!0}set(a){(a!==this.current||this.dirty)&&(this.gl.depthMask(a),this.current=a,this.dirty=!1)}}(this),this.stencilMask=new class extends G{getDefault(){return 255}set(a){(a!==this.current||this.dirty)&&(this.gl.stencilMask(a),this.current=a,this.dirty=!1)}}(this),this.stencilFunc=new class extends G{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(a){const b=this.current;(a.func!==b.func||a.ref!==b.ref||a.mask!==b.mask||this.dirty)&&(this.gl.stencilFunc(a.func,a.ref,a.mask),this.current=a,this.dirty=!1)}}(this),this.stencilOp=new class extends G{getDefault(){const a=this.gl;return[a.KEEP,a.KEEP,a.KEEP]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||a[2]!==b[2]||this.dirty)&&(this.gl.stencilOp(a[0],a[1],a[2]),this.current=a,this.dirty=!1)}}(this),this.stencilTest=new class extends G{getDefault(){return!1}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;a?b.enable(b.STENCIL_TEST):b.disable(b.STENCIL_TEST),this.current=a,this.dirty=!1}}(this),this.depthRange=new class extends G{getDefault(){return[0,1]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||this.dirty)&&(this.gl.depthRange(a[0],a[1]),this.current=a,this.dirty=!1)}}(this),this.depthTest=new class extends G{getDefault(){return!1}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;a?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST),this.current=a,this.dirty=!1}}(this),this.depthFunc=new class extends G{getDefault(){return this.gl.LESS}set(a){(a!==this.current||this.dirty)&&(this.gl.depthFunc(a),this.current=a,this.dirty=!1)}}(this),this.blend=new class extends G{getDefault(){return!1}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;a?b.enable(b.BLEND):b.disable(b.BLEND),this.current=a,this.dirty=!1}}(this),this.blendFunc=new class extends G{getDefault(){const a=this.gl;return[a.ONE,a.ZERO]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||this.dirty)&&(this.gl.blendFunc(a[0],a[1]),this.current=a,this.dirty=!1)}}(this),this.blendColor=new class extends G{getDefault(){return a.Color.transparent}set(a){const b=this.current;(a.r!==b.r||a.g!==b.g||a.b!==b.b||a.a!==b.a||this.dirty)&&(this.gl.blendColor(a.r,a.g,a.b,a.a),this.current=a,this.dirty=!1)}}(this),this.blendEquation=new class extends G{getDefault(){return this.gl.FUNC_ADD}set(a){(a!==this.current||this.dirty)&&(this.gl.blendEquation(a),this.current=a,this.dirty=!1)}}(this),this.cullFace=new class extends G{getDefault(){return!1}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;a?b.enable(b.CULL_FACE):b.disable(b.CULL_FACE),this.current=a,this.dirty=!1}}(this),this.cullFaceSide=new class extends G{getDefault(){return this.gl.BACK}set(a){(a!==this.current||this.dirty)&&(this.gl.cullFace(a),this.current=a,this.dirty=!1)}}(this),this.frontFace=new class extends G{getDefault(){return this.gl.CCW}set(a){(a!==this.current||this.dirty)&&(this.gl.frontFace(a),this.current=a,this.dirty=!1)}}(this),this.program=new class extends G{getDefault(){return null}set(a){(a!==this.current||this.dirty)&&(this.gl.useProgram(a),this.current=a,this.dirty=!1)}}(this),this.activeTexture=new class extends G{getDefault(){return this.gl.TEXTURE0}set(a){(a!==this.current||this.dirty)&&(this.gl.activeTexture(a),this.current=a,this.dirty=!1)}}(this),this.viewport=new class extends G{getDefault(){const a=this.gl;return[0,0,a.drawingBufferWidth,a.drawingBufferHeight,]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||a[2]!==b[2]||a[3]!==b[3]||this.dirty)&&(this.gl.viewport(a[0],a[1],a[2],a[3]),this.current=a,this.dirty=!1)}}(this),this.bindFramebuffer=new class extends G{getDefault(){return null}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.bindFramebuffer(b.FRAMEBUFFER,a),this.current=a,this.dirty=!1}}(this),this.bindRenderbuffer=new class extends G{getDefault(){return null}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.bindRenderbuffer(b.RENDERBUFFER,a),this.current=a,this.dirty=!1}}(this),this.bindTexture=new class extends G{getDefault(){return null}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.bindTexture(b.TEXTURE_2D,a),this.current=a,this.dirty=!1}}(this),this.bindVertexBuffer=new class extends G{getDefault(){return null}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,a),this.current=a,this.dirty=!1}}(this),this.bindElementBuffer=new class extends G{getDefault(){return null}set(a){const b=this.gl;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a),this.current=a,this.dirty=!1}}(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new class extends G{constructor(a){super(a),this.vao=a.extVertexArrayObject}getDefault(){return null}set(a){this.vao&&(a!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(a),this.current=a,this.dirty=!1)}}(this),this.pixelStoreUnpack=new class extends G{getDefault(){return 4}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.pixelStorei(b.UNPACK_ALIGNMENT,a),this.current=a,this.dirty=!1}}(this),this.pixelStoreUnpackPremultiplyAlpha=new class extends G{getDefault(){return!1}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a),this.current=a,this.dirty=!1}}(this),this.pixelStoreUnpackFlipY=new class extends G{getDefault(){return!1}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,a),this.current=a,this.dirty=!1}}(this),this.extTextureFilterAnisotropic=b.getExtension("EXT_texture_filter_anisotropic")||b.getExtension("MOZ_EXT_texture_filter_anisotropic")||b.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=b.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=b.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(b.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=b.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=b.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=b.getParameter(b.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(a,b){return new D(this,a,b)}createVertexBuffer(a,b,c){return new F(this,a,b,c)}createRenderbuffer(a,b,c){const d=this.gl,f=d.createRenderbuffer();return this.bindRenderbuffer.set(f),d.renderbufferStorage(d.RENDERBUFFER,a,b,c),this.bindRenderbuffer.set(null),f}createFramebuffer(a,b,c){return new K(this,a,b,c)}clear({color:a,depth:b,stencil:c}){const d=this.gl;let f=0;a&&(f|=d.COLOR_BUFFER_BIT,this.clearColor.set(a),this.colorMask.set([!0,!0,!0,!0])),void 0!==b&&(f|=d.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(b),this.depthMask.set(!0)),void 0!==c&&(f|=d.STENCIL_BUFFER_BIT,this.clearStencil.set(c),this.stencilMask.set(255)),d.clear(f)}setCullFace(a){!1===a.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(a.mode),this.frontFace.set(a.frontFace))}setDepthMode(a){a.func!==this.gl.ALWAYS||a.mask?(this.depthTest.set(!0),this.depthFunc.set(a.func),this.depthMask.set(a.mask),this.depthRange.set(a.range)):this.depthTest.set(!1)}setStencilMode(a){a.test.func!==this.gl.ALWAYS||a.mask?(this.stencilTest.set(!0),this.stencilMask.set(a.mask),this.stencilOp.set([a.fail,a.depthFail,a.pass,]),this.stencilFunc.set({func:a.test.func,ref:a.ref,mask:a.test.mask})):this.stencilTest.set(!1)}setColorMode(b){g(b.blendFunction,a.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(b.blendFunction),this.blendColor.set(b.blendColor)),this.colorMask.set(b.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}(b),this.transform=c,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=a.SourceCache.maxUnderzooming+a.SourceCache.maxOverzooming+1,this.depthEpsilon=152587890625e-16,this.crossTileSymbolIndex=new aS,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(a,b){const c=!!a&&!!a.terrain&&this.transform.projection.supportsTerrain;if(!(c||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new bl(this,a));const d=this._terrain;this.transform.elevation=c?d:null,d.update(a,this.transform,b)}_updateFog(a){const b=a.fog;if(!b||1>b.getOpacity(this.transform.pitch)||.03>b.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);const[c,d]=b.getFovAdjustedRange(this.transform._fov);if(c>d)return void(this.transform.fogCullDistSq=null);const f=c+.78*(d-c);this.transform.fogCullDistSq=f*f}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(b,c){if(this.width=b*a.exported.devicePixelRatio,this.height=c*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height,]),this.style)for(const d of this.style.order)this.style._layers[d].resize()}setup(){const b=this.context,c=new a.StructArrayLayout2i4;c.emplaceBack(0,0),c.emplaceBack(a.EXTENT,0),c.emplaceBack(0,a.EXTENT),c.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=b.createVertexBuffer(c,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);const d=new a.StructArrayLayout2i4;d.emplaceBack(0,0),d.emplaceBack(a.EXTENT,0),d.emplaceBack(0,a.EXTENT),d.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=b.createVertexBuffer(d,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);const f=new a.StructArrayLayout2i4;f.emplaceBack(-1,-1),f.emplaceBack(1,-1),f.emplaceBack(-1,1),f.emplaceBack(1,1),this.viewportBuffer=b.createVertexBuffer(f,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);const g=new a.StructArrayLayout4i8;g.emplaceBack(0,0,0,0),g.emplaceBack(a.EXTENT,0,a.EXTENT,0),g.emplaceBack(0,a.EXTENT,0,a.EXTENT),g.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=b.createVertexBuffer(g,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);const h=new a.StructArrayLayout3ui6;h.emplaceBack(0,1,2),h.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=b.createIndexBuffer(h);const i=new a.StructArrayLayout1ui2;for(const j of[0,1,3,2,0])i.emplaceBack(j);this.debugIndexBuffer=b.createIndexBuffer(i),this.emptyTexture=new a.Texture(b,{width:1,height:1,data:new Uint8Array([0,0,0,0])},b.gl.RGBA),this.identityMat=a.create();const k=this.context.gl;this.stencilClearMode=new a.StencilMode({func:k.ALWAYS,mask:0},0,255,k.ZERO,k.ZERO,k.ZERO),this.loadTimeStamps.push(a.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(a){return a._makeTileBoundsBuffers(this.context,this.transform.projection),a._tileBoundsBuffer?{tileBoundsBuffer:a._tileBoundsBuffer,tileBoundsIndexBuffer:a._tileBoundsIndexBuffer,tileBoundsSegments:a._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const b=this.context,c=b.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(b,c.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,bg(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(b,c,d){if(!c||this.currentStencilSource===c.id||!b.isTileClipped()||!d||0===d.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let f=!1;for(const g of d)if(void 0===this._tileClippingMaskIDs[g.key]){f=!0;break}if(!f)return}this.currentStencilSource=c.id;const h=this.context,i=h.gl;this.nextStencilID+d.length>256&&this.clearStencil(),h.setColorMode(a.ColorMode.disabled),h.setDepthMode(a.DepthMode.disabled);const j=this.useProgram("clippingMask");for(const k of(this._tileClippingMaskIDs={},d)){const l=c.getTile(k),m=this._tileClippingMaskIDs[k.key]=this.nextStencilID++,{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=this.getTileBoundsBuffers(l);j.draw(h,i.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:i.ALWAYS,mask:0},m,255,i.KEEP,i.KEEP,i.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,bg(k.projMatrix),"$clipping",n,o,p)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const b=this.nextStencilID++,c=this.context.gl;return new a.StencilMode({func:c.NOTEQUAL,mask:255},b,255,c.KEEP,c.KEEP,c.REPLACE)}stencilModeForClipping(b){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(b);const c=this.context.gl;return new a.StencilMode({func:c.EQUAL,mask:255},this._tileClippingMaskIDs[b.key],0,c.KEEP,c.KEEP,c.REPLACE)}stencilConfigForOverlap(b){const c=this.context.gl,d=b.sort((a,b)=>b.overscaledZ-a.overscaledZ),f=d[d.length-1].overscaledZ,g=d[0].overscaledZ-f+1;if(g>1){this.currentStencilSource=void 0,this.nextStencilID+g>256&&this.clearStencil();const h={};for(let i=0;i<g;i++)h[i+f]=new a.StencilMode({func:c.GEQUAL,mask:255},i+this.nextStencilID,255,c.KEEP,c.KEEP,c.REPLACE);return this.nextStencilID+=g,[h,d]}return[{[f]:a.StencilMode.disabled},d,]}colorModeForRenderPass(){const b=this.context.gl;if(this._showOverdrawInspector){const c=.125;return new a.ColorMode([b.CONSTANT_COLOR,b.ONE],new a.Color(c,c,c,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?a.ColorMode.unblended:a.ColorMode.alphaBlended}depthModeForSublayer(b,c,d){if(!this.opaquePassEnabledForLayer())return a.DepthMode.disabled;const f=1-((1+this.currentLayer)*this.numSublayers+b)*this.depthEpsilon;return new a.DepthMode(d||this.context.gl.LEQUAL,c,[f,f])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(b,c){this.style=b,this.options=c,this.lineAtlas=b.lineAtlas,this.imageManager=b.imageManager,this.glyphManager=b.glyphManager,this.symbolFadeChange=b.placement.symbolFadeChange(a.exported.now()),this.imageManager.beginFrame();const d=this.style.order,f=this.style._sourceCaches;for(const g in f){const h=f[g];h.used&&h.prepare(this.context)}const i={},j={},k={};for(const l in f){const m=f[l];i[l]=m.getVisibleCoordinates(),j[l]=i[l].slice().reverse(),k[l]=m.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let n=0;n<d.length;n++)if(this.style._layers[d[n]].is3D()){this.opaquePassCutoff=n;break}if(this.terrain&&(this.terrain.updateTileBinding(k),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new a.GlobeSharedBuffers(this.context)),!a.isMapAuthenticated(this.context.gl))return;for(const o of(this.renderPass="offscreen",d)){const p=this.style._layers[o],q=b._getLayerSourceCache(p);if(!p.hasOffscreenPass()||p.isHidden(this.transform.zoom))continue;const r=q?j[q.id]:void 0;("custom"===p.type||p.isSky()||r&&r.length)&&this.renderLayer(this,q,p,r)}this.depthRangeFor3D=[0,1-(b.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 s=a.Color.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(s=this.style.fog.properties.get("color")),this.context.clear({color:c.showOverdrawInspector?a.Color.black:s,depth:1}),this.clearStencil(),this._showOverdrawInspector=c.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=d.length-1;this.currentLayer>=0;this.currentLayer--){const u=this.style._layers[d[this.currentLayer]],v=b._getLayerSourceCache(u);if(u.isSky())continue;const w=v?j[v.id]:void 0;this._renderTileClippingMasks(u,v,w),this.renderLayer(this,v,u,w)}if(this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){const x=this.style._layers[d[this.currentLayer]],y=b._getLayerSourceCache(x);x.isSky()&&this.renderLayer(this,y,x,y?j[y.id]:void 0)}for("globe"===this.transform.projection.name&&function(b){const c=b.context,d=c.gl,f=b.transform,g=new a.DepthMode(d.LEQUAL,a.DepthMode.ReadOnly,[0,1]),h=b.useProgram("globeAtmosphere"),i=f._camera.getWorldToCamera(f.worldSize,1),j=f._camera.getCameraToClipPerspective(f._fov,f.width/f.height,f._nearZ,f._farZ),k=a.mul([],i,a.calculateGlobeMatrix(f,f.worldSize)),l=a.mul([],f.labelPlaneMatrix,j),m=a.transformMat4([],[0,0,0],k),n=a.add([],m,[f.worldSize/Math.PI/2,0,0,]),o=a.transformMat4([],m,l),p=a.transformMat4([],n,l),q=a.length(a.sub([],p,o)),r=1-a.globeToMercatorTransition(f.zoom),s={u_center:o,u_radius:q,u_screen_size:[f.width,f.height,],u_pixel_ratio:a.exported.devicePixelRatio,u_opacity:r,u_fadeout_range:2,u_start_color:[1,1,1],u_end_color:[.0118,.7451,.9882,]};b.prepareDrawProgram(c,h);const u=b.globeSharedBuffers;u&&h.draw(c,d.TRIANGLES,g,a.StencilMode.disabled,a.ColorMode.alphaBlended,a.CullFaceMode.backCW,s,"skybox",u.atmosphereVertexBuffer,u.atmosphereIndexBuffer,u.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<d.length;){const z=this.style._layers[d[this.currentLayer]],A=b._getLayerSourceCache(z);if(z.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(z)){if(z.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const B=A?("symbol"===z.type?k:j)[A.id]:void 0;this._renderTileClippingMasks(z,A,A?i[A.id]:void 0),this.renderLayer(this,A,z,B),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let C=null;a.values(this.style._layers).forEach(a=>{const c=b._getLayerSourceCache(a);c&&!a.isHidden(this.transform.zoom)&&(!C||C.getSource().maxzoom<c.getSource().maxzoom)&&(C=c)}),C&&this.options.showTileBoundaries&&ca.debug(this,C,C.getVisibleCoordinates())}this.options.showPadding&&function(a){var b,c,d,f;const g=a.transform.padding;b1(a,a.transform.height-(g.top||0),3,bY),b1(a,g.bottom||0,3,bZ),b2(a,g.left||0,3,b$),b2(a,a.transform.width-(g.right||0),3,b_);const h=a.transform.centerPoint;b3(b=a,(c=h.x)-1,(d=a.transform.height-h.y)-10,2,20,f=b0),b3(b,c-10,d-1,20,2,f)}(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(a,b,c,d){c.isHidden(this.transform.zoom)||("background"===c.type||"sky"===c.type||"custom"===c.type||d&&d.length)&&(this.id=c.id,this.gpuTimingStart(c),a.transform.projection.unsupportedLayers&&a.transform.projection.unsupportedLayers.includes(c.type)||ca[c.type](a,b,c,d,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(a){if(!this.options.gpuTiming)return;const b=this.context.extTimerQuery;let c=this.gpuTimers[a.id];c||(c=this.gpuTimers[a.id]={calls:0,cpuTime:0,query:b.createQueryEXT()}),c.calls++,b.beginQueryEXT(b.TIME_ELAPSED_EXT,c.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const a=this.context.extTimerQuery;a.endQueryEXT(a.TIME_ELAPSED_EXT)}collectGpuTimers(){const a=this.gpuTimers;return this.gpuTimers={},a}queryGpuTimers(a){const b={};for(const c in a){const d=a[c],f=this.context.extTimerQuery,g=f.getQueryObjectEXT(d.query,f.QUERY_RESULT_EXT)/1e6;f.deleteQueryEXT(d.query),b[c]=g}return b}translatePosMatrix(b,c,d,f,g){if(!d[0]&&!d[1])return b;const h=g?"map"===f?this.transform.angle:0:"viewport"===f?-this.transform.angle:0;if(h){const i=Math.sin(h),j=Math.cos(h);d=[d[0]*j-d[1]*i,d[0]*i+d[1]*j,]}const k=[g?d[0]:C(c,d[0],this.transform.zoom),g?d[1]:C(c,d[1],this.transform.zoom),0,],l=new Float32Array(16);return a.translate(l,b,k),l}saveTileTexture(a){const b=this._tileTextures[a.size[0]];b?b.push(a):this._tileTextures[a.size[0]]=[a]}getTileTexture(a){const b=this._tileTextures[a];return b&&b.length>0?b.pop():null}isPatternMissing(a){if(!a)return!1;if(!a.from||!a.to)return!0;const b=this.imageManager.getPattern(a.from.toString()),c=this.imageManager.getPattern(a.to.toString());return!b||!c}currentGlobalDefines(){const a=this.terrain&&this.terrain.renderingToTexture,b=this.style&&this.style.fog,c=[];return this.terrain&&!this.terrain.renderingToTexture&&c.push("TERRAIN"),b&&!a&&0!==b.getOpacity(this.transform.pitch)&&c.push("FOG"),a&&c.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&c.push("OVERDRAW_INSPECTOR"),c}useProgram(a,b,c){this.cache=this.cache||{};const d=this.currentGlobalDefines().concat(c||[]),f=bn.cacheKey(a,d,b);return this.cache[f]||(this.cache[f]=new bn(this.context,a,a3[a],b,bM[a],d)),this.cache[f]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const a=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height,]),this.context.blendEquation.set(a.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(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(a){this.terrain&&this.terrain.prepareDrawTile(a)}prepareDrawProgram(a,b,c){if(this.terrain&&this.terrain.renderingToTexture)return;const d=this.style.fog;if(d){const f=d.getOpacity(this.transform.pitch);0!==f&&b.setFogUniformValues(a,((a,b,c,d)=>{const f=b.properties.get("color"),g=a.frameCounter/1e3%1,h=[f.r/f.a,f.g/f.a,f.b/f.a,d,];return{u_fog_matrix:c?a.transform.calculateFogTileMatrix(c):a.identityMat,u_fog_range:b.getFovAdjustedRange(a.transform._fov),u_fog_color:h,u_fog_horizon_blend:b.properties.get("horizon-blend"),u_fog_temporal_offset:g}})(this,d,c,f))}}setTileLoadedFlag(a){this.tileLoaded=a}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const a=this.context.gl,b=a.createTexture();return a.bindTexture(a.TEXTURE_2D,b),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,a.drawingBufferWidth,a.drawingBufferHeight,0),b}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const a=this.style&&this.style.fog;return!!a&&0!==a.getOpacity(this.transform.pitch)}getBackgroundTiles(){const b=this._backgroundTiles,c=this._backgroundTiles={},d=this.transform.coveringTiles({tileSize:512});for(const f of d)c[f.key]=b[f.key]||new a.Tile(f,512,this.transform.tileZoom,this);return c}clearBackgroundTiles(){this._backgroundTiles={}}}class cc{constructor(a=0,b=0,c=0,d=0){if(isNaN(a)||a<0||isNaN(b)||b<0||isNaN(c)||c<0||isNaN(d)||d<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=a,this.bottom=b,this.left=c,this.right=d}interpolate(b,c,d){return null!=c.top&&null!=b.top&&(this.top=a.number(b.top,c.top,d)),null!=c.bottom&&null!=b.bottom&&(this.bottom=a.number(b.bottom,c.bottom,d)),null!=c.left&&null!=b.left&&(this.left=a.number(b.left,c.left,d)),null!=c.right&&null!=b.right&&(this.right=a.number(b.right,c.right,d)),this}getCenter(b,c){const d=a.clamp((this.left+b-this.right)/2,0,b),f=a.clamp((this.top+c-this.bottom)/2,0,c);return new a.pointGeometry(d,f)}equals(a){return this.top===a.top&&this.bottom===a.bottom&&this.left===a.left&&this.right===a.right}clone(){return new cc(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function cd(b,c){const d=a.getColumn(b,3);a.fromQuat(b,c),a.setColumn(b,3,d)}function ce(b,c){a.setColumn(b,3,[c[0],c[1],c[2],1])}function cf(b,c){const d=a.identity$1([]);return a.rotateZ$1(d,d,-c),a.rotateX$1(d,d,-b),d}function cg(b,c){const d=[b[0],b[1],0],f=[c[0],c[1],0];if(a.length(d)>=1e-15){const g=a.normalize([],d);a.scale$2(f,g,a.dot(f,g)),c[0]=f[0],c[1]=f[1]}const h=a.cross([],c,b);if(1e-15>a.len(h))return null;const i=Math.atan2(-h[1],h[0]);return cf(Math.atan2(Math.sqrt(b[0]*b[0]+b[1]*b[1]),-b[2]),i)}class ch{constructor(a,b){this.position=a,this.orientation=b}get position(){return this._position}set position(b){this._position=this._renderWorldCopies?function(b){if(!b)return;const c=Array.isArray(b)?new a.MercatorCoordinate(b[0],b[1],b[2]):b;return c.x=a.wrap(c.x,0,1),c}(b):b}lookAtPoint(b,c){if(this.orientation=null,!this.position)return;const d=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(b)):0,f=this.position,g=a.MercatorCoordinate.fromLngLat(b,d),h=[g.x-f.x,g.y-f.y,g.z-f.z];c||(c=[0,0,1]),c[2]=Math.abs(c[2]),this.orientation=cg(h,c)}setPitchBearing(b,c){this.orientation=cf(a.degToRad(b),a.degToRad(-c))}}class ci{constructor(b,c){this._transform=a.identity([]),this._orientation=a.identity$1([]),c&&(this._orientation=c,cd(this._transform,this._orientation)),b&&ce(this._transform,b)}get mercatorPosition(){const b=this.position;return new a.MercatorCoordinate(b[0],b[1],b[2])}get position(){const b=a.getColumn(this._transform,3);return[b[0],b[1],b[2]]}set position(a){ce(this._transform,a)}get orientation(){return this._orientation}set orientation(a){this._orientation=a,cd(this._transform,this._orientation)}getPitchBearing(){const a=this.forward(),b=this.right();return{bearing:Math.atan2(-b[1],b[0]),pitch:Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2])}}setPitchBearing(a,b){this._orientation=cf(a,b),cd(this._transform,this._orientation)}forward(){const b=a.getColumn(this._transform,2);return[-b[0],-b[1],-b[2]]}up(){const b=a.getColumn(this._transform,1);return[-b[0],-b[1],-b[2]]}right(){const b=a.getColumn(this._transform,0);return[b[0],b[1],b[2]]}getCameraToWorld(b,c){const d=new Float64Array(16);return a.invert(d,this.getWorldToCamera(b,c)),d}getWorldToCameraPosition(b,c,d){const f=this.position;a.scale$2(f,f,-b);const g=new Float64Array(16);return a.fromScaling(g,[d,d,d]),a.translate(g,g,f),g[10]*=c,g}getWorldToCamera(b,c){const d=new Float64Array(16),f=new Float64Array(4),g=this.position;return a.conjugate(f,this._orientation),a.scale$2(g,g,-b),a.fromQuat(d,f),a.translate(d,d,g),d[1]*=-1,d[5]*=-1,d[9]*=-1,d[13]*=-1,d[8]*=c,d[9]*=c,d[10]*=c,d[11]*=c,d}getCameraToClipPerspective(b,c,d,f){const g=new Float64Array(16);return a.perspective(g,b,c,d,f),g}getDistanceToElevation(b){const c=0===b?0:a.mercatorZfromAltitude(b,this.position[1]),d=this.forward();return(c-this.position[2])/d[2]}clone(){return new ci([...this.position],[...this.orientation])}}function cj(b,c){const d=cl(b),f=function(b,c,d,f,g){const h=new a.LngLat(d.lng-180*cm,d.lat),i=new a.LngLat(d.lng+180*cm,d.lat),j=b.project(h.lng,h.lat),k=b.project(i.lng,i.lat),l=-Math.atan2(k.y-j.y,k.x-j.x),m=a.MercatorCoordinate.fromLngLat(d);m.y=a.clamp(m.y,-0.999975,.999975);const n=m.toLngLat(),o=b.project(n.lng,n.lat),p=a.MercatorCoordinate.fromLngLat(n);p.x+=cm;const q=p.toLngLat(),r=b.project(q.lng,q.lat),s=co(r.x-o.x,r.y-o.y,l),u=a.MercatorCoordinate.fromLngLat(n);u.y+=cm;const v=u.toLngLat(),w=b.project(v.lng,v.lat),x=co(w.x-o.x,w.y-o.y,l),y=Math.abs(s.x)/Math.abs(x.y),z=a.identity([]);a.rotateZ(z,z,-l*(1-(g?0:f)));const A=a.identity([]);return a.scale(A,A,[1,1-(1-y)*f,1]),A[4]=-x.x/x.y*f,a.rotateZ(A,A,l),a.multiply$1(A,z,A),A}(b.projection,0,b.center,d,c),g=ck(b);return a.scale(f,f,[g,g,1]),f}function ck(b){const c=b.projection,d=cl(b),f=cn(c,b.center),g=cn(c,a.LngLat.convert(c.center));return Math.pow(2,f*d+(1-d)*g)}function cl(b){const c=b.projection.range;if(!c)return 0;const d=Math.max(b.width,b.height),f=Math.log(d/1024)/Math.LN2;return a.smoothstep(c[0]+f,c[1]+f,b.zoom)}const cm=1/4e4;function cn(b,c){const d=a.clamp(c.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),f=new a.LngLat(c.lng-180*cm,d),g=new a.LngLat(c.lng+180*cm,d),h=b.project(f.lng,d),i=b.project(g.lng,d),j=a.MercatorCoordinate.fromLngLat(f),k=a.MercatorCoordinate.fromLngLat(g),l=i.x-h.x,m=i.y-h.y,n=k.x-j.x,o=k.y-j.y;return Math.log(Math.sqrt((n*n+o*o)/(l*l+m*m)))/Math.LN2}function co(a,b,c){const d=Math.cos(c),f=Math.sin(c);return{x:a*d-b*f,y:a*f+b*d}}class cp{constructor(b,c,d,f,g){this.tileSize=512,this._renderWorldCopies=void 0===g||g,this._minZoom=b||0,this._maxZoom=c||22,this._minPitch=null==d?0:d,this._maxPitch=null==f?60:f,this.setProjection(),this.setMaxBounds(),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 cc,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new ci,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const a=new cp(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return a.setProjection(this.getProjection()),a._elevation=this._elevation,a._centerAltitude=this._centerAltitude,a.tileSize=this.tileSize,a.setMaxBounds(this.getMaxBounds()),a.width=this.width,a.height=this.height,a.cameraElevationReference=this.cameraElevationReference,a._center=this._center,a._setZoom(this.zoom),a._cameraZoom=this._cameraZoom,a.angle=this.angle,a._fov=this._fov,a._pitch=this._pitch,a._nearZ=this._nearZ,a._farZ=this._farZ,a._averageElevation=this._averageElevation,a._unmodified=this._unmodified,a._edgeInsets=this._edgeInsets.clone(),a._camera=this._camera.clone(),a._calcMatrices(),a.freezeTileCoverage=this.freezeTileCoverage,a}get elevation(){return this._elevation}set elevation(a){this._elevation!==a&&(this._elevation=a,a?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(a){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),a&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels",])}setProjection(b){null==b&&(b={name:"mercator"}),this.projectionOptions=b;const c=this.projection?this.getProjection():void 0;return this.projection=a.getProjection(b),!g(c,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(a){this._minZoom!==a&&(this._minZoom=a,this.zoom=Math.max(this.zoom,a))}get maxZoom(){return this._maxZoom}set maxZoom(a){this._maxZoom!==a&&(this._maxZoom=a,this.zoom=Math.min(this.zoom,a))}get minPitch(){return this._minPitch}set minPitch(a){this._minPitch!==a&&(this._minPitch=a,this.pitch=Math.max(this.pitch,a))}get maxPitch(){return this._maxPitch}set maxPitch(a){this._maxPitch!==a&&(this._maxPitch=a,this.pitch=Math.min(this.pitch,a))}get renderWorldCopies(){return this._renderWorldCopies&& !0===this.projection.supportsWorldCopies}set renderWorldCopies(a){void 0===a?a=!0:null===a&&(a=!1),this._renderWorldCopies=a}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}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(a){this.rotation=a}get rotation(){return-this.angle/Math.PI*180}set rotation(b){var c,d,f,g,h,i,j,k,l,m;const n=-b*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(c=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(c[1]=0,c[2]=0),c[0]=1,c[3]=1,c),d=this.rotationMatrix,f=this.rotationMatrix,g=this.angle,h=f[0],i=f[1],j=f[2],k=f[3],l=Math.sin(g),m=Math.cos(g),d[0]=h*m+j*l,d[1]=i*m+k*l,d[2]=-(h*l)+j*m,d[3]=-(i*l)+k*m)}get pitch(){return this._pitch/Math.PI*180}set pitch(b){const c=a.clamp(b,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==c&&(this._unmodified=!1,this._pitch=c,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(a){a=Math.max(.01,Math.min(60,a)),this._fov!==a&&(this._unmodified=!1,this._fov=a/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(a){this._averageElevation=a,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(a){const b=Math.min(Math.max(a,this.minZoom),this.maxZoom);this._zoom!==b&&(this._unmodified=!1,this._setZoom(b),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(a){this._zoom=a,this.scale=this.zoomScale(a),this.tileZoom=Math.floor(a),this.zoomFraction=a-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const a=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return -1===a?(this._cameraZoom=null,!1):(this._centerAltitude=a,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const b=this._elevation,c=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8],],d=this.horizonLineFromTop();let f=0,g=0;for(let h=0;h<c.length;h++){const i=new a.pointGeometry(c[h][0]*this.width,d+c[h][1]*(this.height-d)),j=b.pointCoordinate(i);if(!j)continue;const k=1/Math.hypot(j[0]-this._camera.position[0],j[1]-this._camera.position[1]);f+=j[3]*k,g+=k}return 0===g?NaN:f/g}get center(){return this._center}set center(a){a.lat===this._center.lat&&a.lng===this._center.lng||(this._unmodified=!1,this._center=a,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCenterElevation()?this._updateCameraOnTerrain():this._cameraZoom=null:this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._cameraZoom||!this._elevation)return;const a=this._cameraZoom,b=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),c=this.pixelsPerMeter/this.worldSize*b,d=this._mercatorZfromZoom(a),f=this._mercatorZfromZoom(this._maxZoom),g=Math.max(d-c,f);this._setZoom(this._zoomFromMercatorZ(g))}get padding(){return this._edgeInsets.toJSON()}set padding(a){this._edgeInsets.equals(a)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,a,1),this._calcMatrices())}computeZoomRelativeTo(b){const c=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,b.toAltitude()));let d;d=b.z<this._camera.position[2]?[c.x,c.y,c.z]:[b.x,b.y,b.z];const f=a.length(a.sub([],this._camera.position,d));return a.clamp(this._zoomFromMercatorZ(f),this._minZoom,this._maxZoom)}setFreeCameraOptions(b){if(!this.height|| !b.position&&!b.orientation)return;this._updateCameraState();let c=!1;if(b.orientation&&!a.exactEquals(b.orientation,this._camera.orientation)&&(c=this._setCameraOrientation(b.orientation)),b.position){const d=[b.position.x,b.position.y,b.position.z,];a.exactEquals$1(d,this._camera.position)||(this._setCameraPosition(d),c=!0)}c&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const b=this._camera.position,c=new ch;return c.position=new a.MercatorCoordinate(b[0],b[1],b[2]),c.orientation=this._camera.orientation,c._elevation=this.elevation,c._renderWorldCopies=this.renderWorldCopies,c}_setCameraOrientation(b){if(!a.length$1(b))return!1;a.normalize$1(b,b);const c=a.transformQuat([],[0,0,-1],b),d=a.transformQuat([],[0,-1,0],b);if(d[2]<0)return!1;const f=cg(c,d);return!!f&&(this._camera.orientation=f,!0)}_setCameraPosition(b){const c=this.zoomScale(this.minZoom)*this.tileSize,d=this.zoomScale(this.maxZoom)*this.tileSize,f=this.cameraToCenterDistance;b[2]=a.clamp(b[2],f/d,f/c),this._camera.position=b}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(a){return this._edgeInsets.equals(a)}interpolatePadding(a,b,c){this._unmodified=!1,this._edgeInsets.interpolate(a,b,c),this._constrain(),this._calcMatrices()}coveringZoomLevel(a){const b=(a.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/a.tileSize));return Math.max(0,b)}getVisibleUnwrappedCoordinates(b){const c=[new a.UnwrappedTileID(0,b)];if(this.renderWorldCopies){const d=this.pointCoordinate(new a.pointGeometry(0,0)),f=this.pointCoordinate(new a.pointGeometry(this.width,0)),g=this.pointCoordinate(new a.pointGeometry(this.width,this.height)),h=this.pointCoordinate(new a.pointGeometry(0,this.height)),i=Math.floor(Math.min(d.x,f.x,g.x,h.x)),j=Math.floor(Math.max(d.x,f.x,g.x,h.x)),k=1;for(let l=i-k;l<=j+k;l++)0!==l&&c.push(new a.UnwrappedTileID(l,b))}return c}coveringTiles(b){let c=this.coveringZoomLevel(b);const d=c,f=this.elevation&&!b.isTerrainDEM,g="mercator"===this.projection.name;if(void 0!==b.minzoom&&c<b.minzoom)return[];void 0!==b.maxzoom&&c>b.maxzoom&&(c=b.maxzoom);const h=this.locationCoordinate(this.center),i=1<<c,j=[i*h.x,i*h.y,0],k=a.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,c,"globe"!==this.projection.name),l=this.pointCoordinate(this.getCameraPoint()),m=i*a.mercatorZfromAltitude(1,this.center.lat),n=this._camera.position[2]/a.mercatorZfromAltitude(1,this.center.lat),o=[i*l.x,i*l.y,n],p=this.cameraToCenterDistance/b.tileSize*(b.roundZoom?1:.502),q=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?c:0,r=b.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,s=b.isTerrainDEM?-r:this._elevation?this._elevation.getMinElevationBelowMSL():0,u=this.projection.isReprojectedInTileSpace?ck(this):1,v=b=>{const c=1/4e4,d=new a.MercatorCoordinate(b.x+c,b.y,b.z),f=new a.MercatorCoordinate(b.x,b.y+c,b.z),g=b.toLngLat(),h=d.toLngLat(),i=f.toLngLat(),j=this.locationCoordinate(g),k=this.locationCoordinate(h),l=this.locationCoordinate(i),m=Math.hypot(k.x-j.x,k.y-j.y),n=Math.hypot(l.x-j.x,l.y-j.y);return Math.sqrt(m*n)*u/c},w=b=>{const c=r,d=s;return{aabb:a.tileAABB(this,i,0,0,0,b,d,c,this.projection),zoom:0,x:0,y:0,minZ:d,maxZ:c,wrap:b,fullyVisible:!1}},x=[];let y=[];const z=c,A=b.reparseOverscaled?d:c,B=a=>a*a,C=B((n-this._centerAltitude)*m),D=a=>{if(!this._elevation||!a.tileID||!g)return;const b=this._elevation.getMinMaxForTile(a.tileID),c=a.aabb;b?(c.min[2]=b.min,c.max[2]=b.max,c.center[2]=(c.min[2]+c.max[2])/2):(a.shouldSplit=E(a),a.shouldSplit||(c.min[2]=c.max[2]=c.center[2]=this._centerAltitude))},E=b=>{if(b.zoom<q)return!0;if(b.zoom===z)return!1;if(null!=b.shouldSplit)return b.shouldSplit;const c=b.aabb.distanceX(o),g=b.aabb.distanceY(o);let h=C;f&&(h=B(b.aabb.distanceZ(o)*m));let i=1;if(this.projection.isReprojectedInTileSpace&&d<=5){const j=Math.pow(2,b.zoom),k=v(new a.MercatorCoordinate((b.x+.5)/j,(b.y+.5)/j));i=k>.85?1:k}const l=c*c+g*g+h;return l<B((1<<z-b.zoom)*p*i*((a,b)=>{if(b*B(.707)<a)return 1;const c=Math.sqrt(b/a);return c/(1.4144271570014144+(Math.pow(1.1,c-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(h,C),l))};if(this.renderWorldCopies)for(let F=1;F<=3;F++)x.push(w(-F)),x.push(w(F));for(x.push(w(0));x.length>0;){const G=x.pop(),H=G.x,I=G.y;let J=G.fullyVisible;if(!J){const K=G.aabb.intersects(k);if(0===K)continue;J=2===K}if(G.zoom!==z&&E(G))for(let L=0;L<4;L++){const M=(H<<1)+L%2,N=(I<<1)+(L>>1),O={aabb:g?G.aabb.quadrant(L):a.tileAABB(this,i,G.zoom+1,M,N,G.wrap,G.minZ,G.maxZ,this.projection),zoom:G.zoom+1,x:M,y:N,wrap:G.wrap,fullyVisible:J,tileID:void 0,shouldSplit:void 0,minZ:G.minZ,maxZ:G.maxZ};f&&(O.tileID=new a.OverscaledTileID(G.zoom+1===z?A:G.zoom+1,G.wrap,G.zoom+1,M,N),D(O)),x.push(O)}else{const P=G.zoom===z?A:G.zoom;if(b.minzoom&&b.minzoom>P)continue;const Q=j[0]-(.5+H+(G.wrap<<G.zoom))*(1<<c-G.zoom),R=j[1]-.5-I,S=G.tileID?G.tileID:new a.OverscaledTileID(P,G.wrap,G.zoom,H,I);y.push({tileID:S,distanceSq:Q*Q+R*R})}}if(this.fogCullDistSq){const T=this.fogCullDistSq,U=this.horizonLineFromTop();y=y.filter(c=>{const d=[0,0,0,1],f=[a.EXTENT,a.EXTENT,0,1],g=this.calculateFogTileMatrix(c.tileID.toUnwrapped());a.transformMat4$1(d,d,g),a.transformMat4$1(f,f,g);const h=a.getAABBPointSquareDist(d,f);if(0===h)return!0;let i=!1;const j=this._elevation;if(j&&h>T&&0!==U){const k=this.calculateProjMatrix(c.tileID.toUnwrapped());let l;b.isTerrainDEM||(l=j.getMinMaxForTile(c.tileID)),l||(l={min:s,max:r});const m=a.furthestTileCorner(this.rotation),n=[m[0]*a.EXTENT,m[1]*a.EXTENT,l.max,];a.transformMat4(n,n,k),i=(1-n[1])*this.height*.5<U}return h<T||i})}return y.sort((a,b)=>a.distanceSq-b.distanceSq).map(a=>a.tileID)}resize(a,b){this.width=a,this.height=b,this.pixelsToGLUnits=[2/a,-2/b],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(a){return Math.pow(2,a)}scaleZoom(a){return Math.log(a)/Math.LN2}project(b){const c=a.clamp(b.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),d=this.projection.project(b.lng,c);return new a.pointGeometry(d.x*this.worldSize,d.y*this.worldSize)}unproject(a){return this.projection.unproject(a.x/this.worldSize,a.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(b,c){const d=this.pointCoordinate(c),f=this.pointCoordinate(this.centerPoint),g=this.locationCoordinate(b);this.setLocation(new a.MercatorCoordinate(g.x-(d.x-f.x),g.y-(d.y-f.y)))}setLocation(a){this.center=this.coordinateLocation(a),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(a){return this.projection.locationPoint(this,a)}locationPoint3D(a){return this._coordinatePoint(this.locationCoordinate(a),!0)}pointLocation(a){return this.coordinateLocation(this.pointCoordinate(a))}pointLocation3D(a){return this.coordinateLocation(this.pointCoordinate3D(a))}locationCoordinate(b,c){const d=c?a.mercatorZfromAltitude(c,b.lat):void 0,f=this.projection.project(b.lng,b.lat);return new a.MercatorCoordinate(f.x,f.y,d)}coordinateLocation(a){return this.projection.unproject(a.x,a.y)}pointRayIntersection(b,c){const d=null!=c?c:this._centerAltitude,f=[b.x,b.y,0,1],g=[b.x,b.y,1,1];a.transformMat4$1(f,f,this.pixelMatrixInverse),a.transformMat4$1(g,g,this.pixelMatrixInverse);const h=g[3];a.scale$1(f,f,1/f[3]),a.scale$1(g,g,1/h);const i=f[2],j=g[2];return{p0:f,p1:g,t:i===j?0:(d-i)/(j-i)}}screenPointToMercatorRay(b){const c=[b.x,b.y,0,1],d=[b.x,b.y,1,1];return a.transformMat4$1(c,c,this.pixelMatrixInverse),a.transformMat4$1(d,d,this.pixelMatrixInverse),a.scale$1(c,c,1/c[3]),a.scale$1(d,d,1/d[3]),c[2]=a.mercatorZfromAltitude(c[2],this._center.lat)*this.worldSize,d[2]=a.mercatorZfromAltitude(d[2],this._center.lat)*this.worldSize,a.scale$1(c,c,1/this.worldSize),a.scale$1(d,d,1/this.worldSize),new a.Ray([c[0],c[1],c[2]],a.normalize([],a.sub([],d,c)))}rayIntersectionCoordinate(b){const{p0:c,p1:d,t:f}=b,g=a.mercatorZfromAltitude(c[2],this._center.lat),h=a.mercatorZfromAltitude(d[2],this._center.lat);return new a.MercatorCoordinate(a.number(c[0],d[0],f)/this.worldSize,a.number(c[1],d[1],f)/this.worldSize,a.number(g,h,f))}pointCoordinate(a,b=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(a.x,a.y,b)}pointCoordinate3D(b){if(!this.elevation)return this.pointCoordinate(b);const c=this.elevation;let d=this.elevation.pointCoordinate(b);if(d)return new a.MercatorCoordinate(d[0],d[1],d[2]);let f=0,g=this.horizonLineFromTop();if(b.y>g)return this.pointCoordinate(b);const h=.02*g,i=b.clone();for(let j=0;j<10&&g-f>h;j++){i.y=a.number(f,g,.66);const k=c.pointCoordinate(i);k?(g=i.y,d=k):f=i.y}return d?new a.MercatorCoordinate(d[0],d[1],d[2]):this.pointCoordinate(b)}isPointAboveHorizon(a){if(this.elevation)return!this.elevation.pointCoordinate(a);{const b=this.horizonLineFromTop();return a.y<b}}_coordinatePoint(b,c){const d=c&&this.elevation?this.elevation.getAtPointOrZero(b,this._centerAltitude):this._centerAltitude,f=[b.x*this.worldSize,b.y*this.worldSize,d+b.toAltitude(),1,];return a.transformMat4$1(f,f,this.pixelMatrix),f[3]>0?new a.pointGeometry(f[0]/f[3],f[1]/f[3]):new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(b,c){var d,f,g,h,i,j,k,l;const m=new a.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),n=new a.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new a.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),p=new a.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let q=this.pointCoordinate(m,b),r=this.pointCoordinate(n,b);const s=this.pointCoordinate(o,c),u=this.pointCoordinate(p,c);return q.y>1&&r.y>=0?q=new a.MercatorCoordinate((1-u.y)/(d=u,((f=q).y-d.y)/(f.x-d.x))+u.x,1):q.y<0&&r.y<=1&&(q=new a.MercatorCoordinate(-u.y/(g=u,((h=q).y-g.y)/(h.x-g.x))+u.x,0)),r.y>1&&q.y>=0?r=new a.MercatorCoordinate((1-s.y)/(i=s,((j=r).y-i.y)/(j.x-i.x))+s.x,1):r.y<0&&q.y<=1&&(r=new a.MercatorCoordinate(-s.y/(k=s,((l=r).y-k.y)/(l.x-k.x))+s.x,0)),new a.LngLatBounds().extend(this.coordinateLocation(q)).extend(this.coordinateLocation(r)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(s))}_getBounds3D(){const a=this.elevation;if(!a.visibleDemTiles.length)return this._getBounds(0,0);const b=a.visibleDemTiles.reduce((a,b)=>{if(b.dem){const c=b.dem.tree;a.min=Math.min(a.min,c.minimums[0]),a.max=Math.max(a.max,c.maximums[0])}return a},{min:Number.MAX_VALUE,max:0});return this._getBounds(b.min*a.exaggeration(),b.max*a.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(a=!0){const b=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,c=this.height/2-b*(1-this._horizonShift);return a?Math.max(0,c):c}getMaxBounds(){return this.maxBounds}setMaxBounds(b){this.maxBounds=b,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,b&&(this.minLat=b.getSouth(),this.maxLat=b.getNorth(),this.minLng=b.getWest(),this.maxLng=b.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(a,b){return this.projection.createTileTransform(this,b).createTileMatrix(a)}calculateDistanceTileData(b){const c=b.key,d=this._distanceTileDataCache;if(d[c])return d[c];const f=b.canonical,g=1/this.height,h=this.cameraWorldSize/this.zoomScale(f.z),i=(f.x+Math.pow(2,f.z)*b.wrap)*h,j=f.y*h,k=this.point,l=this.angle,m=Math.sin(-l),n=-Math.cos(-l);return d[c]={bearing:[m,n],center:[(k.x-i)*g,(k.y-j)*g],scale:h/a.EXTENT*g},d[c]}calculateFogTileMatrix(b){const c=b.key,d=this._fogTileMatrixCache;if(d[c])return d[c];const f=this.calculatePosMatrix(b,this.cameraWorldSize);return a.multiply$1(f,this.worldToFogMatrix,f),d[c]=new Float32Array(f),d[c]}calculateProjMatrix(b,c=!1){const d=b.key,f=c?this._alignedProjMatrixCache:this._projMatrixCache;if(f[d])return f[d];const g=this.calculatePosMatrix(b,this.worldSize);return a.multiply$1(g,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:c?this.alignedProjMatrix:this.projMatrix,g),f[d]=new Float32Array(g),f[d]}calculatePixelsToTileUnitsMatrix(b){const c=b.tileID.key,d=this._pixelsToTileUnitsCache;if(d[c])return d[c];const f=function(b,c){var d,f,g,h,i,j,k,l;const{scale:m}=b.tileTransform,n=m*a.EXTENT/(b.tileSize*Math.pow(2,c.zoom-b.tileID.overscaledZ+b.tileID.canonical.z));return d=new Float32Array(4),h=(f=c.inverseAdjustmentMatrix)[1],i=f[2],j=f[3],l=(g=[n,n])[1],d[0]=f[0]*(k=g[0]),d[1]=h*k,d[2]=i*l,d[3]=j*l,d}(b,this);return d[c]=f,d[c]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;const b=this._elevation;this._updateCameraState();const c=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(c),f=this._camera.forward(),g=a.mercatorZfromAltitude(1,this._center.lat);d[2]/=g,f[2]/=g,a.normalize(f,f);const h=b.raycast(d,f,b.exaggeration());if(h){const i=a.scaleAndAdd([],d,f,h),j=new a.MercatorCoordinate(i[0],i[1],a.mercatorZfromAltitude(i[2],a.latFromMercatorY(i[1]))),k=(j.z+a.length([j.x-d[0],j.y-d[1],j.z-d[2]*g,]))*this._projectionScaler;this._cameraZoom=this._zoomFromMercatorZ(k),this._centerAltitude=j.toAltitude(),this._center=this.coordinateLocation(j),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const b=this._elevation;this._updateCameraState();const c=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(c),f=b.getAtPointOrZero(new a.MercatorCoordinate(...d)),g=this._minimumHeightOverTerrain()*Math.cos(a.degToRad(this._maxPitch)),h=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*f;if(h<g){const i=this.locationCoordinate(this._center,this._centerAltitude),j=[i.x-d[0],i.y-d[1],i.z-d[2],],k=a.length(j);j[2]-=(g-h)/this._projectionScaler;const l=a.length(j);if(0===l)return;a.scale$2(j,j,k/l*this._projectionScaler),this._camera.position=[i.x-j[0],i.y-j[1],i.z*this._projectionScaler-j[2],],this._camera.orientation=cg(j,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const b=this.center;return b.lat=a.clamp(b.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(b.lng=a.clamp(b.lng,this.minLng,this.maxLng)),this.center=b,void(this._constraining=!1)}const c=this._unmodified,{x:d,y:f}=this.point;let g=0,h=d,i=f;const j=this.width/2,k=this.height/2,l=this.worldMinY*this.scale,m=this.worldMaxY*this.scale;if(f-k<l&&(i=l+k),f+k>m&&(i=m-k),m-l<this.height&&(g=Math.max(g,this.height/(m-l)),i=(m+l)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const n=this.worldMinX*this.scale,o=this.worldMaxX*this.scale,p=this.worldSize/2-(n+o)/2;(h=(d+p+this.worldSize)%this.worldSize-p)-j<n&&(h=n+j),h+j>o&&(h=o-j),o-n<this.width&&(g=Math.max(g,this.width/(o-n)),h=(o+n)/2)}h===d&&i===f||(this.center=this.unproject(new a.pointGeometry(h,i))),g&&(this.zoom+=this.scaleZoom(g)),this._constrainCameraAltitude(),this._unmodified=c,this._constraining=!1}_minZoomForBounds(){let a=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(a=Math.max(a,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),a}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const b=this._fov/2,c=this.centerOffset,d=this.pixelsPerMeter;this._projectionScaler=d/(a.mercatorZfromAltitude(1,this.center.lat)*this.worldSize),this.cameraToCenterDistance=.5/Math.tan(b)*this.height*this._projectionScaler,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const g=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?d:1),h=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);h[8]=-(2*c.x)/this.width,h[9]=2*c.y/this.height;let i=a.mul([],h,g);if(this.projection.isReprojectedInTileSpace){const j=this.locationCoordinate(this.center),k=a.identity([]);a.translate(k,k,[j.x*this.worldSize,j.y*this.worldSize,0,]),a.multiply$1(k,k,cj(this)),a.translate(k,k,[-j.x*this.worldSize,-j.y*this.worldSize,0,]),a.multiply$1(i,i,k),this.inverseAdjustmentMatrix=function(a){const b=cj(a,!0);return f([],[b[0],b[1],b[4],b[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=a.scale([],i,[this.worldSize,this.worldSize,this.worldSize/d,1,]),this.projMatrix=i,this.invProjMatrix=a.invert(new Float64Array(16),this.projMatrix);const l=new Float32Array(16);a.identity(l),a.scale(l,l,[1,-1,1]),a.rotateX(l,l,this._pitch),a.rotateZ(l,l,this.angle);const m=a.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),n=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;m[8]=-(2*c.x)/this.width,m[9]=2*(c.y+n)/this.height,this.skyboxMatrix=a.multiply$1(l,m,l);const o=this.point,p=o.x,q=o.y,r=this.width%2/2,s=this.height%2/2,u=Math.cos(this.angle),v=Math.sin(this.angle),w=p-Math.round(p)+u*r+v*s,x=q-Math.round(q)+u*s+v*r,y=new Float64Array(i);if(a.translate(y,y,[w>.5?w-1:w,x>.5?x-1:x,0,]),this.alignedProjMatrix=y,i=a.create(),a.scale(i,i,[this.width/2,-this.height/2,1,]),a.translate(i,i,[1,-1,0]),this.labelPlaneMatrix=i,i=a.create(),a.scale(i,i,[1,-1,1]),a.translate(i,i,[-1,-1,0]),a.scale(i,i,[2/this.width,2/this.height,1,]),this.glCoordMatrix=i,this.pixelMatrix=a.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},i=a.invert(new Float64Array(16),this.pixelMatrix),!i)throw Error("failed to invert matrix");this.pixelMatrixInverse=i,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const b=this.cameraWorldSize,c=this.cameraPixelsPerMeter,d=this._camera.position,f=1/this.height,g=[b,b,c];a.scale$2(g,g,f),a.scale$2(d,d,-1),a.multiply$2(d,d,g);const h=a.create();a.translate(h,h,d),a.scale(h,h,g),this.mercatorFogMatrix=h,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(b,c,f)}_computeCameraPosition(a){const b=(a=a||this.pixelsPerMeter)/this.pixelsPerMeter,c=this._camera.forward(),d=this.point,f=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*b-a/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-c[0]*f,d.y/this.worldSize-c[1]*f,a/this.worldSize*this._centerAltitude-c[2]*f,]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(b){const c=this._maxCameraBoundsDistance()*Math.cos(this._pitch),d=b[2];let f=1;d>0&&(f=Math.min((c-this._camera.position[2])/d,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,b,f),this._updateStateFromCamera()}_updateStateFromCamera(){const b=this._camera.position,c=this._camera.forward(),{pitch:d,bearing:f}=this._camera.getPitchBearing(),g=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,h=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),i=Math.max((b[2]-g)/Math.cos(d),h),j=this._zoomFromMercatorZ(i);a.scaleAndAdd(b,b,c,i),this._pitch=a.clamp(d,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(f,-Math.PI,Math.PI),this._setZoom(a.clamp(j,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new a.MercatorCoordinate(b[0],b[1],b[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(a){return Math.pow(2,a)*this.tileSize}_mercatorZfromZoom(a){return this.cameraToCenterDistance/this._worldSizeFromZoom(a)}_minimumHeightOverTerrain(){const a=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(a)}_zoomFromMercatorZ(a){return this.scaleZoom(this.cameraToCenterDistance/(a*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(b,c){const d=Math.min(b.x,c.x),f=Math.max(b.x,c.x),g=Math.min(b.y,c.y),h=Math.max(b.y,c.y);if(g<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const i=[new a.pointGeometry(d,g),new a.pointGeometry(f,h),new a.pointGeometry(d,h),new a.pointGeometry(f,g),],j=this.renderWorldCopies?-3:0,k=this.renderWorldCopies?4:1;for(const l of i){const m=this.pointRayIntersection(l);if(m.t<0)return!0;const n=this.rayIntersectionCoordinate(m);if(n.x<j||n.y<0||n.x>k||n.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(b,c){const d=a.length(a.sub([],this._camera.position,b)),f=this._zoomFromMercatorZ(d)+c;return d-this._mercatorZfromZoom(f)}getCameraPoint(){const b=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.pointGeometry(0,b))}}function cq(a,b){let c=!1,d=null;const f=()=>{d=null,c&&(a(),d=setTimeout(f,b),c=!1)};return()=>(c=!0,d||f(),d)}const cr={linearity:.3,easing:a.bezier(0,0,.3,1)},cs=a.extend({deceleration:2500,maxSpeed:1400},cr),ct=a.extend({deceleration:20,maxSpeed:1400},cr),cu=a.extend({deceleration:1e3,maxSpeed:360},cr),cv=a.extend({deceleration:1e3,maxSpeed:90},cr);function cw(a,b){(!a.duration||a.duration<b.duration)&&(a.duration=b.duration,a.easing=b.easing)}function cx(b,c,d){const{maxSpeed:f,linearity:g,deceleration:h}=d,i=a.clamp(b*g/(c/1e3),-f,f),j=Math.abs(i)/(h*g);return{easing:d.easing,duration:1e3*j,amount:i*(j/2)}}class cy extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(b,c,d,f={}){const g=h.mousePos(c.getCanvasContainer(),d),i=c.unproject(g);super(b,a.extend({point:g,lngLat:i,originalEvent:d},f)),this._defaultPrevented=!1,this.target=c}}class cz extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(b,c,d){const f="touchend"===b?d.changedTouches:d.touches,g=h.touchPos(c.getCanvasContainer(),f),i=g.map(a=>c.unproject(a)),j=g.reduce((a,b,c,d)=>a.add(b.div(d.length)),new a.pointGeometry(0,0));super(b,{points:g,point:j,lngLats:i,lngLat:c.unproject(j),originalEvent:d}),this._defaultPrevented=!1}}class cA extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(a,b,c){super(a,{originalEvent:c}),this._defaultPrevented=!1}}class cB{constructor(a,b){this._map=a,this._clickTolerance=b.clickTolerance}reset(){delete this._mousedownPos}wheel(a){return this._firePreventable(new cA(a.type,this._map,a))}mousedown(a,b){return this._mousedownPos=b,this._firePreventable(new cy(a.type,this._map,a))}mouseup(a){this._map.fire(new cy(a.type,this._map,a))}preclick(b){const c=a.extend({},b);c.type="preclick",this._map.fire(new cy(c.type,this._map,c))}click(a,b){this._mousedownPos&&this._mousedownPos.dist(b)>=this._clickTolerance||(this.preclick(a),this._map.fire(new cy(a.type,this._map,a)))}dblclick(a){return this._firePreventable(new cy(a.type,this._map,a))}mouseover(a){this._map.fire(new cy(a.type,this._map,a))}mouseout(a){this._map.fire(new cy(a.type,this._map,a))}touchstart(a){return this._firePreventable(new cz(a.type,this._map,a))}touchmove(a){this._map.fire(new cz(a.type,this._map,a))}touchend(a){this._map.fire(new cz(a.type,this._map,a))}touchcancel(a){this._map.fire(new cz(a.type,this._map,a))}_firePreventable(a){if(this._map.fire(a),a.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cC{constructor(a){this._map=a}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(a){this._map.fire(new cy(a.type,this._map,a))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new cy("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(a){this._delayContextMenu?this._contextMenuEvent=a:this._map.fire(new cy(a.type,this._map,a)),this._map.listens("contextmenu")&&a.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cD{constructor(a,b){this._map=a,this._el=a.getCanvasContainer(),this._container=a.getContainer(),this._clickTolerance=b.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(a,b){this.isEnabled()&&a.shiftKey&&0===a.button&&(h.disableDrag(),this._startPos=this._lastPos=b,this._active=!0)}mousemoveWindow(a,b){if(!this._active)return;const c=b;if(this._lastPos.equals(c)|| !this._box&&c.dist(this._startPos)<this._clickTolerance)return;const d=this._startPos;this._lastPos=c,this._box||(this._box=h.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",a));const f=Math.min(d.x,c.x),g=Math.max(d.x,c.x),i=Math.min(d.y,c.y),j=Math.max(d.y,c.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${f}px,${i}px)`,this._box.style.width=g-f+"px",this._box.style.height=j-i+"px")})}mouseupWindow(b,c){if(!this._active||0!==b.button)return;const d=this._startPos,f=c;if(this.reset(),h.suppressClick(),d.x!==f.x||d.y!==f.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:b})),{cameraAnimation:a=>a.fitScreenCoordinates(d,f,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",b)}keydown(a){this._active&&27===a.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",a))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(b,c){return this._map.fire(new a.Event(b,{originalEvent:c}))}}function cE(a,b){const c={};for(let d=0;d<a.length;d++)c[a[d].identifier]=b[d];return c}class cF{constructor(b){this.singleTap=new class{constructor(a){this.reset(),this.numTouches=a.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(b,c,d){(this.centroid||d.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=b.timeStamp),d.length===this.numTouches&&(this.centroid=function(b){const c=new a.pointGeometry(0,0);for(const d of b)c._add(d);return c.div(b.length)}(c),this.touches=cE(d,c)))}touchmove(a,b,c){if(this.aborted||!this.centroid)return;const d=cE(c,b);for(const f in this.touches){const g=this.touches[f],h=d[f];(!h||h.dist(g)>30)&&(this.aborted=!0)}}touchend(a,b,c){if((!this.centroid||a.timeStamp-this.startTime>500)&&(this.aborted=!0),0===c.length){const d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}(b),this.numTaps=b.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(a,b,c){this.singleTap.touchstart(a,b,c)}touchmove(a,b,c){this.singleTap.touchmove(a,b,c)}touchend(a,b,c){const d=this.singleTap.touchend(a,b,c);if(d){const f=a.timeStamp-this.lastTime<500,g=!this.lastTap||30>this.lastTap.dist(d);if(f&&g||this.reset(),this.count++,this.lastTime=a.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class cG{constructor(){this._zoomIn=new cF({numTouches:1,numTaps:2}),this._zoomOut=new cF({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(a,b,c){this._zoomIn.touchstart(a,b,c),this._zoomOut.touchstart(a,b,c)}touchmove(a,b,c){this._zoomIn.touchmove(a,b,c),this._zoomOut.touchmove(a,b,c)}touchend(a,b,c){const d=this._zoomIn.touchend(a,b,c),f=this._zoomOut.touchend(a,b,c);return d?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()+1,around:b.unproject(d)},{originalEvent:a})}):f?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()-1,around:b.unproject(f)},{originalEvent:a})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const cH={0:1,2:2};class cI{constructor(a){this.reset(),this._clickTolerance=a.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(a,b){return!1}_move(a,b){return{}}mousedown(a,b){if(this._lastPoint)return;const c=h.mouseButton(a);this._correctButton(a,c)&&(this._lastPoint=b,this._eventButton=c)}mousemoveWindow(a,b){const c=this._lastPoint;if(c){if(a.preventDefault(),function(a,b){const c=cH[b];return void 0===a.buttons||(a.buttons&c)!==c}(a,this._eventButton))this.reset();else if(this._moved||!(b.dist(c)<this._clickTolerance))return this._moved=!0,this._lastPoint=b,this._move(c,b)}}mouseupWindow(a){this._lastPoint&&h.mouseButton(a)===this._eventButton&&(this._moved&&h.suppressClick(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class cJ extends cI{mousedown(a,b){super.mousedown(a,b),this._lastPoint&&(this._active=!0)}_correctButton(a,b){return 0===b&&!a.ctrlKey}_move(a,b){return{around:b,panDelta:b.sub(a)}}}class cK extends cI{_correctButton(a,b){return 0===b&&a.ctrlKey||2===b}_move(a,b){const c=.8*(b.x-a.x);if(c)return this._active=!0,{bearingDelta:c}}contextmenu(a){a.preventDefault()}}class cL extends cI{_correctButton(a,b){return 0===b&&a.ctrlKey||2===b}_move(a,b){const c=-0.5*(b.y-a.y);if(c)return this._active=!0,{pitchDelta:c}}contextmenu(a){a.preventDefault()}}class cM{constructor(b,c){this._map=b,this._el=b.getCanvasContainer(),this._minTouches=1,this._clickTolerance=c.clickTolerance||1,this.reset(),a.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert",],this)}reset(){this._active=!1,this._touches={},this._sum=new a.pointGeometry(0,0)}touchstart(a,b,c){return this._calculateTransform(a,b,c)}touchmove(a,b,c){if(this._active&&!(c.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===c.length)return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return a.preventDefault(),this._calculateTransform(a,b,c)}}touchend(a,b,c){this._calculateTransform(a,b,c),this._active&&c.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(b,c,d){d.length>0&&(this._active=!0);const f=cE(d,c),g=new a.pointGeometry(0,0),h=new a.pointGeometry(0,0);let i=0;for(const j in f){const k=f[j],l=this._touches[j];l&&(g._add(k),h._add(k.sub(l)),i++,f[j]=k)}if(this._touches=f,i<this._minTouches||!h.mag())return;const m=h.div(i);return this._sum._add(m),this._sum.mag()<this._clickTolerance?void 0:{around:g.div(i),panDelta:m}}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=h.create("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(){"hidden"===this._alertContainer.style.visibility&&(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 cN{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(a){}_move(a,b,c){return{}}touchstart(a,b,c){this._firstTwoTouches||c.length<2||(this._firstTwoTouches=[c[0].identifier,c[1].identifier,],this._start([b[0],b[1]]))}touchmove(a,b,c){if(!this._firstTwoTouches)return;a.preventDefault();const[d,f]=this._firstTwoTouches,g=cO(c,b,d),h=cO(c,b,f);if(!g||!h)return;const i=this._aroundCenter?null:g.add(h).div(2);return this._move([g,h],i,a)}touchend(a,b,c){if(!this._firstTwoTouches)return;const[d,f]=this._firstTwoTouches,g=cO(c,b,d),i=cO(c,b,f);g&&i||(this._active&&h.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(a){this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function cO(a,b,c){for(let d=0;d<a.length;d++)if(a[d].identifier===c)return b[d]}function cP(a,b){return Math.log(a/b)/Math.LN2}class cQ extends cN{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(a){this._startDistance=this._distance=a[0].dist(a[1])}_move(a,b){const c=this._distance;if(this._distance=a[0].dist(a[1]),this._active||!(.1>Math.abs(cP(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:cP(this._distance,c),pinchAround:b}}}function cR(a,b){return 180*a.angleWith(b)/Math.PI}class cS extends cN{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(a){this._startVector=this._vector=a[0].sub(a[1]),this._minDiameter=a[0].dist(a[1])}_move(a,b){const c=this._vector;if(this._vector=a[0].sub(a[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:cR(this._vector,c),pinchAround:b}}_isBelowThreshold(a){this._minDiameter=Math.min(this._minDiameter,a.mag());const b=25/(Math.PI*this._minDiameter)*360,c=cR(a,this._startVector);return Math.abs(c)<b}}function cT(a){return Math.abs(a.y)>Math.abs(a.x)}class cU extends cN{constructor(a){super(),this._map=a}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(a){this._lastPoints=a,cT(a[0].sub(a[1]))&&(this._valid=!1)}_move(a,b,c){const d=a[0].sub(this._lastPoints[0]),f=a[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&c.touches.length<3)&&(this._valid=this.gestureBeginsVertically(d,f,c.timeStamp),this._valid))return this._lastPoints=a,this._active=!0,{pitchDelta:-((d.y+f.y)/2*.5)}}gestureBeginsVertically(a,b,c){if(void 0!==this._valid)return this._valid;const d=a.mag()>=2,f=b.mag()>=2;if(!d&&!f)return;if(!d||!f)return void 0===this._firstMove&&(this._firstMove=c),c-this._firstMove<100&&void 0;const g=a.y>0==b.y>0;return cT(a)&&cT(b)&&g}}class cV{constructor(){const a={panStep:100,bearingStep:15,pitchStep:10};this._panStep=a.panStep,this._bearingStep=a.bearingStep,this._pitchStep=a.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(a){if(a.altKey||a.ctrlKey||a.metaKey)return;let b=0,c=0,d=0,f=0,g=0;switch(a.keyCode){case 61:case 107:case 171:case 187:b=1;break;case 189:case 109:case 173:b=-1;break;case 37:a.shiftKey?c=-1:(a.preventDefault(),f=-1);break;case 39:a.shiftKey?c=1:(a.preventDefault(),f=1);break;case 38:a.shiftKey?d=1:(a.preventDefault(),g=-1);break;case 40:a.shiftKey?d=-1:(a.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(c=0,d=0),{cameraAnimation:h=>{const i=h.getZoom();h.easeTo({duration:300,easeId:"keyboardHandler",easing:cW,zoom:b?Math.round(i)+b*(a.shiftKey?2:1):i,bearing:h.getBearing()+c*this._bearingStep,pitch:h.getPitch()+d*this._pitchStep,offset:[-f*this._panStep,-g*this._panStep,],center:h.getCenter()},{originalEvent:a})}}}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 cW(a){return a*(2-a)}const cX=4.000244140625;class cY{constructor(b,c){this._map=b,this._el=b.getCanvasContainer(),this._handler=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen",],this)}setZoomRate(a){this._defaultZoomRate=a}setWheelZoomRate(a){this._wheelZoomRate=a}isEnabled(){return!!this._enabled}isActive(){return!!this._active|| void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(a){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(b){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(b.ctrlKey||b.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let c=b.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*b.deltaY:b.deltaY;const d=a.exported.now(),f=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,0!==c&&c%cX==0?this._type="wheel":0!==c&&4>Math.abs(c)?this._type="trackpad":f>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,b)):this._type||(this._type=200>Math.abs(f*c)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),b.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=b,this._delta-=c,this._active||this._start(b)),b.preventDefault()}_onTimeout(a){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)}_start(a){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const b=h.mousePos(this._el,a);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:b,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const b=this._map.transform,c=()=>b._terrainEnabled()&&this._aroundCoord?b.computeZoomRelativeTo(this._aroundCoord):b.zoom;if(0!==this._delta){const d="wheel"===this._type&&Math.abs(this._delta)>cX?this._wheelZoomRate:this._defaultZoomRate;let f=2/(1+Math.exp(-Math.abs(this._delta*d)));this._delta<0&&0!==f&&(f=1/f);const g=c(),h=Math.pow(2,g),i="number"==typeof this._targetZoom?b.zoomScale(this._targetZoom):h;this._targetZoom=Math.min(b.maxZoom,Math.max(b.minZoom,b.scaleZoom(i*f))),"wheel"===this._type&&(this._startZoom=c(),this._easing=this._smoothOutEasing(200)),this._delta=0}const j="number"==typeof this._targetZoom?this._targetZoom:c(),k=this._startZoom,l=this._easing;let m,n=!1;if("wheel"===this._type&&k&&l){const o=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),p=l(o);m=a.number(k,j,p),o<1?this._frameId||(this._frameId=!0):n=!0}else m=j,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!n,zoomDelta:m-c(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(b){let c=a.ease;if(this._prevEase){const d=this._prevEase,f=(a.exported.now()-d.start)/d.duration,g=d.easing(f+.01)-d.easing(f),h=.27/Math.sqrt(g*g+1e-4)*.01,i=Math.sqrt(.0729-h*h);c=a.bezier(h,i,.25,1)}return this._prevEase={start:a.exported.now(),duration:b,easing:c},c}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=h.create("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}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(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 cZ{constructor(a,b){this._clickZoom=a,this._tapZoom=b}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 c${constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(a,b){return a.preventDefault(),{cameraAnimation(c){c.easeTo({duration:300,zoom:c.getZoom()+(a.shiftKey?-1:1),around:c.unproject(b)},{originalEvent:a})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class c_{constructor(){this._tap=new cF({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(a,b,c){this._swipePoint||(this._tapTime&&a.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?c.length>0&&(this._swipePoint=b[0],this._swipeTouch=c[0].identifier):this._tap.touchstart(a,b,c))}touchmove(a,b,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;const d=b[0],f=d.y-this._swipePoint.y;return this._swipePoint=d,a.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(a,b,c)}touchend(a,b,c){this._tapTime?this._swipePoint&&0===c.length&&this.reset():this._tap.touchend(a,b,c)&&(this._tapTime=a.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class c0{constructor(a,b,c){this._el=a,this._mousePan=b,this._touchPan=c}enable(a){this._inertiaOptions=a||{},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 c1{constructor(a,b,c){this._pitchWithRotate=a.pitchWithRotate,this._mouseRotate=b,this._mousePitch=c}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 c2{constructor(a,b,c,d){this._el=a,this._touchZoom=b,this._touchRotate=c,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(a){this._touchZoom.enable(a),this._rotationDisabled||this._touchRotate.enable(a),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const c3=a=>a.zoom||a.drag||a.pitch||a.rotate;class c4 extends a.Event{}function c5(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}const c6="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class c7 extends a.Evented{constructor(b,c){super(),this._moving=!1,this._zooming=!1,this.transform=b,this._bearingSnap=c.bearingSnap,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(a,b){return this.jumpTo({center:a},b)}panBy(b,c,d){return b=a.pointGeometry.convert(b).mult(-1),this.panTo(this.transform.center,a.extend({offset:b},c),d)}panTo(b,c,d){return this.easeTo(a.extend({center:b},c),d)}getZoom(){return this.transform.zoom}setZoom(a,b){return this.jumpTo({zoom:a},b),this}zoomTo(b,c,d){return this.easeTo(a.extend({zoom:b},c),d)}zoomIn(a,b){return this.zoomTo(this.getZoom()+1,a,b),this}zoomOut(a,b){return this.zoomTo(this.getZoom()-1,a,b),this}getBearing(){return this.transform.bearing}setBearing(a,b){return this.jumpTo({bearing:a},b),this}getPadding(){return this.transform.padding}setPadding(a,b){return this.jumpTo({padding:a},b),this}rotateTo(b,c,d){return this.easeTo(a.extend({bearing:b},c),d)}resetNorth(b,c){return this.rotateTo(0,a.extend({duration:1e3},b),c),this}resetNorthPitch(b,c){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},b),c),this}snapToNorth(a,b){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(a,b):this}getPitch(){return this.transform.pitch}setPitch(a,b){return this.jumpTo({pitch:a},b),this}cameraForBounds(b,c){b=a.LngLatBounds.convert(b);const d=c&&c.bearing||0;return this._cameraForBoxAndBearing(b.getNorthWest(),b.getSouthEast(),d,c)}_extendCameraOptions(b){const c={top:0,bottom:0,right:0,left:0};if("number"==typeof(b=a.extend({padding:c,offset:[0,0],maxZoom:this.transform.maxZoom},b)).padding){const d=b.padding;b.padding={top:d,bottom:d,right:d,left:d}}return b.padding=a.extend(c,b.padding),b}_cameraForBoxAndBearing(b,c,d,f){const g=this._extendCameraOptions(f),h=this.transform,i=h.padding,j=h.project(a.LngLat.convert(b)),k=h.project(a.LngLat.convert(c)),l=j.rotate(-a.degToRad(d)),m=k.rotate(-a.degToRad(d)),n=new a.pointGeometry(Math.max(l.x,m.x),Math.max(l.y,m.y)),o=new a.pointGeometry(Math.min(l.x,m.x),Math.min(l.y,m.y)),p=n.sub(o),q=(h.width-(i.left+i.right+g.padding.left+g.padding.right))/p.x,r=(h.height-(i.top+i.bottom+g.padding.top+g.padding.bottom))/p.y;if(r<0||q<0)return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const s=Math.min(h.scaleZoom(h.scale*Math.min(q,r)),g.maxZoom),u="number"==typeof g.offset.x?new a.pointGeometry(g.offset.x,g.offset.y):a.pointGeometry.convert(g.offset),v=new a.pointGeometry((g.padding.left-g.padding.right)/2,(g.padding.top-g.padding.bottom)/2).rotate(d*Math.PI/180),w=u.add(v).mult(h.scale/h.zoomScale(s));return{center:h.unproject(j.add(k).div(2).sub(w)),zoom:s,bearing:d}}_cameraForBox(b,c,d,f,g){var h;const i=this._extendCameraOptions(g);d=d||0,f=f||0,b=a.LngLat.convert(b),c=a.LngLat.convert(c);const j=this.transform.clone();j.padding=i.padding;const k=this.getFreeCameraOptions(),l=new a.LngLat(.5*(b.lng+c.lng),.5*(b.lat+c.lat)),m=.5*(d+f);if(j._camera.position[2]<a.mercatorZfromAltitude(m,l.lat))return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");k.lookAtPoint(l),j.setFreeCameraOptions(k);const n=a.MercatorCoordinate.fromLngLat(b),o=a.MercatorCoordinate.fromLngLat(c),p=j.pointRayIntersection(j.centerPoint,m),q=[(h=j.rayIntersectionCoordinate(p)).x,h.y,h.z,],r=j.screenPointToMercatorRay(j.centerPoint),s="globe"!==j.projection.name;let u,v=0;do{const w=Math.floor(j.zoom),x=1<<w,y=Math.min(x*n.x,x*o.x),z=Math.min(x*n.y,x*o.y),A=Math.max(x*n.x,x*o.x),B=Math.max(x*n.y,x*o.y),C=new a.Aabb([y,z,d],[A,B,f]),D=a.Frustum.fromInvProjectionMatrix(j.invProjMatrix,j.worldSize,w,s);if(2!==C.intersects(D)){u&&(j._camera.position=a.scaleAndAdd([],j._camera.position,r.dir,-u),j._updateStateFromCamera());break}const E=a.sub([],j._camera.position,q);u=.5*a.length(E),j._camera.position=a.scaleAndAdd([],j._camera.position,r.dir,u);try{j._updateStateFromCamera()}catch(F){return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++v<10)return{center:j.center,zoom:j.zoom,bearing:j.bearing,pitch:j.pitch}}fitBounds(a,b,c){return this._fitInternal(this.cameraForBounds(a,b),b,c)}_raycastElevationBox(b,c){const d=this.transform.elevation;if(!d)return;const f=new a.pointGeometry(b.x,c.y),g=new a.pointGeometry(c.x,b.y),h=d.pointCoordinate(b);if(!h)return;const i=d.pointCoordinate(c);if(!i)return;const j=d.pointCoordinate(f);if(!j)return;const k=d.pointCoordinate(g);if(!k)return;const l=new a.MercatorCoordinate(h[0],h[1]).toLngLat(),m=new a.MercatorCoordinate(i[0],i[1]).toLngLat(),n=new a.MercatorCoordinate(j[0],j[1]).toLngLat(),o=new a.MercatorCoordinate(k[0],k[1]).toLngLat(),p=Math.min(l.lng,Math.min(m.lng,Math.min(n.lng,o.lng))),q=Math.min(l.lat,Math.min(m.lat,Math.min(n.lat,o.lat))),r=Math.max(l.lng,Math.max(m.lng,Math.max(n.lng,o.lng))),s=Math.max(l.lat,Math.max(m.lat,Math.max(n.lat,o.lat))),u=Math.min(h[3],Math.min(i[3],Math.min(j[3],k[3]))),v=Math.max(h[3],Math.max(i[3],Math.max(j[3],k[3])));return{minLngLat:new a.LngLat(p,q),maxLngLat:new a.LngLat(r,s),minAltitude:u,maxAltitude:v}}fitScreenCoordinates(b,c,d,f,g){let h,i,j,k;const l=a.pointGeometry.convert(b),m=a.pointGeometry.convert(c),n=this._raycastElevationBox(l,m);if(n)h=n.minLngLat,i=n.maxLngLat,j=n.minAltitude,k=n.maxAltitude;else{if(this.transform.anyCornerOffEdge(l,m))return this;h=this.transform.pointLocation(l),i=this.transform.pointLocation(m)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(a.pointGeometry.convert(b)),this.transform.pointLocation(a.pointGeometry.convert(c)),d,f):this._cameraForBox(h,i,j,k,f),f,g)}_fitInternal(b,c,d){return b?(delete(c=a.extend(b,c)).padding,c.linear?this.easeTo(c,d):this.flyTo(c,d)):this}jumpTo(b,c){this.stop();const d=b.preloadOnly?this.transform.clone():this.transform;let f=!1,g=!1,h=!1;return"zoom"in b&&d.zoom!== +b.zoom&&(f=!0,d.zoom=+b.zoom),void 0!==b.center&&(d.center=a.LngLat.convert(b.center)),"bearing"in b&&d.bearing!== +b.bearing&&(g=!0,d.bearing=+b.bearing),"pitch"in b&&d.pitch!== +b.pitch&&(h=!0,d.pitch=+b.pitch),null==b.padding||d.isPaddingEqual(b.padding)||(d.padding=b.padding),b.preloadOnly?(this._preloadTiles(d),this):(this.fire(new a.Event("movestart",c)).fire(new a.Event("move",c)),f&&this.fire(new a.Event("zoomstart",c)).fire(new a.Event("zoom",c)).fire(new a.Event("zoomend",c)),g&&this.fire(new a.Event("rotatestart",c)).fire(new a.Event("rotate",c)).fire(new a.Event("rotateend",c)),h&&this.fire(new a.Event("pitchstart",c)).fire(new a.Event("pitch",c)).fire(new a.Event("pitchend",c)),this.fire(new a.Event("moveend",c)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||a.warnOnce(c6),this.transform.getFreeCameraOptions()}setFreeCameraOptions(b,c){const d=this.transform;if(!d.projection.supportsFreeCamera)return void a.warnOnce(c6);this.stop();const f=d.zoom,g=d.pitch,h=d.bearing;d.setFreeCameraOptions(b);const i=f!==d.zoom,j=g!==d.pitch,k=h!==d.bearing;return this.fire(new a.Event("movestart",c)).fire(new a.Event("move",c)),i&&this.fire(new a.Event("zoomstart",c)).fire(new a.Event("zoom",c)).fire(new a.Event("zoomend",c)),k&&this.fire(new a.Event("rotatestart",c)).fire(new a.Event("rotate",c)).fire(new a.Event("rotateend",c)),j&&this.fire(new a.Event("pitchstart",c)).fire(new a.Event("pitch",c)).fire(new a.Event("pitchend",c)),this.fire(new a.Event("moveend",c)),this}easeTo(b,c){this._stop(!1,b.easeId),(!1===(b=a.extend({offset:[0,0],duration:500,easing:a.ease},b)).animate|| !b.essential&&a.exported.prefersReducedMotion)&&(b.duration=0);const d=this.transform,f=this.getZoom(),g=this.getBearing(),h=this.getPitch(),i=this.getPadding(),j="zoom"in b?+b.zoom:f,k="bearing"in b?this._normalizeBearing(b.bearing,g):g,l="pitch"in b?+b.pitch:h,m="padding"in b?b.padding:d.padding,n=a.pointGeometry.convert(b.offset);let o=d.centerPoint.add(n);const p="globe"===d.projection.name?d.pointCoordinate(o).toLngLat():d.pointLocation(o),q=a.LngLat.convert(b.center||p);this._normalizeCenter(q);const r=d.project(p),s=d.project(q).sub(r),u=d.zoomScale(j-f);let v,w;b.around&&(v=a.LngLat.convert(b.around),w=d.locationPoint(v));const x=this._zooming||j!==f,y=this._rotating||g!==k,z=this._pitching||l!==h,A=!d.isPaddingEqual(m),B=d=>p=>{if(x&&(d.zoom=a.number(f,j,p)),y&&(d.bearing=a.number(g,k,p)),z&&(d.pitch=a.number(h,l,p)),A&&(d.interpolatePadding(i,m,p),o=d.centerPoint.add(n)),v)d.setLocationAtPoint(v,w);else{const q=d.zoomScale(d.zoom-f),B=j>f?Math.min(2,u):Math.max(.5,u),C=Math.pow(B,1-p),D=d.unproject(r.add(s.mult(p*C)).mult(q));d.setLocationAtPoint(d.renderWorldCopies?D.wrap():D,o)}return b.preloadOnly||this._fireMoveEvents(c),d};if(b.preloadOnly){const C=this._emulate(B,b.duration,d);return this._preloadTiles(C),this}const D={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=y,this._pitching=z,this._padding=A,this._easeId=b.easeId,this._prepareEase(c,b.noMoveStart,D),this._ease(B(d),a=>{d.recenterOnTerrain(),this._afterEase(c,a)},b),this}_prepareEase(b,c,d={}){this._moving=!0,this.transform.cameraElevationReference="sea",c||d.moving||this.fire(new a.Event("movestart",b)),this._zooming&&!d.zooming&&this.fire(new a.Event("zoomstart",b)),this._rotating&&!d.rotating&&this.fire(new a.Event("rotatestart",b)),this._pitching&&!d.pitching&&this.fire(new a.Event("pitchstart",b))}_fireMoveEvents(b){this.fire(new a.Event("move",b)),this._zooming&&this.fire(new a.Event("zoom",b)),this._rotating&&this.fire(new a.Event("rotate",b)),this._pitching&&this.fire(new a.Event("pitch",b))}_afterEase(b,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId,this.transform.cameraElevationReference="ground";const d=this._zooming,f=this._rotating,g=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new a.Event("zoomend",b)),f&&this.fire(new a.Event("rotateend",b)),g&&this.fire(new a.Event("pitchend",b)),this.fire(new a.Event("moveend",b))}flyTo(b,c){if(!b.essential&&a.exported.prefersReducedMotion){const d=a.pick(b,["center","zoom","bearing","pitch","around",]);return this.jumpTo(d,c)}this.stop(),b=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},b);const f=this.transform,g=this.getZoom(),h=this.getBearing(),i=this.getPitch(),j=this.getPadding(),k="zoom"in b?a.clamp(+b.zoom,f.minZoom,f.maxZoom):g,l="bearing"in b?this._normalizeBearing(b.bearing,h):h,m="pitch"in b?+b.pitch:i,n="padding"in b?b.padding:f.padding,o=f.zoomScale(k-g),p=a.pointGeometry.convert(b.offset);let q=f.centerPoint.add(p);const r=f.pointLocation(q),s=a.LngLat.convert(b.center||r);this._normalizeCenter(s);const u=f.project(r),v=f.project(s).sub(u);let w=b.curve;const x=Math.max(f.width,f.height),y=x/o,z=v.mag();if("minZoom"in b){const A=a.clamp(Math.min(b.minZoom,g,k),f.minZoom,f.maxZoom),B=x/f.zoomScale(A-g);w=Math.sqrt(B/z*2)}const C=w*w;function D(a){const b=(y*y-x*x+(a?-1:1)*C*C*z*z)/(2*(a?y:x)*C*z);return Math.log(Math.sqrt(b*b+1)-b)}function E(a){return(Math.exp(a)-Math.exp(-a))/2}function F(a){return(Math.exp(a)+Math.exp(-a))/2}const G=D(0);let H=function(a){return F(G)/F(G+w*a)},I=function(a){var b;return x*((F(G)*(E(b=G+w*a)/F(b))-E(G))/C)/z},J=(D(1)-G)/w;if(1e-6>Math.abs(z)||!isFinite(J)){if(1e-6>Math.abs(x-y))return this.easeTo(b,c);const K=y<x?-1:1;J=Math.abs(Math.log(y/x))/w,I=function(){return 0},H=function(a){return Math.exp(K*w*a)}}b.duration="duration"in b?+b.duration:1e3*J/("screenSpeed"in b?+b.screenSpeed/w:+b.speed),b.maxDuration&&b.duration>b.maxDuration&&(b.duration=0);const L=h!==l,M=m!==i,N=!f.isPaddingEqual(n),O=d=>f=>{const o=f*J,r=1/H(o);d.zoom=1===f?k:g+d.scaleZoom(r),L&&(d.bearing=a.number(h,l,f)),M&&(d.pitch=a.number(i,m,f)),N&&(d.interpolatePadding(j,n,f),q=d.centerPoint.add(p));const w=1===f?s:d.unproject(u.add(v.mult(I(o))).mult(r));return d.setLocationAtPoint(d.renderWorldCopies?w.wrap():w,q),d._updateCenterElevation(),b.preloadOnly||this._fireMoveEvents(c),d};if(b.preloadOnly){const P=this._emulate(O,b.duration,f);return this._preloadTiles(P),this}return this._zooming=!0,this._rotating=L,this._pitching=M,this._padding=N,this._prepareEase(c,!1),this._ease(O(f),()=>this._afterEase(c),b),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(a,b){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const c=this._onEaseEnd;delete this._onEaseEnd,c.call(this,b)}if(!a){const d=this.handlers;d&&d.stop(!1)}return this}_ease(b,c,d){!1===d.animate||0===d.duration?(b(1),c()):(this._easeStart=a.exported.now(),this._easeOptions=d,this._onEaseFrame=b,this._onEaseEnd=c,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const b=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(b)),b<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(b,c){b=a.wrap(b,-180,180);const d=Math.abs(b-c);return Math.abs(b-360-c)<d&&(b-=360),Math.abs(b+360-c)<d&&(b+=360),b}_normalizeCenter(a){const b=this.transform;if(!b.renderWorldCopies||b.maxBounds)return;const c=a.lng-b.center.lng;a.lng+=c>180?-360:c< -180?360:0}_emulate(a,b,c){const d=Math.ceil(15*b/1e3),f=[],g=a(c.clone());for(let h=0;h<=d;h++){const i=g(h/d);f.push(i.clone())}return f}}class c8{constructor(b={}){this.options=b,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact",],this)}getDefaultPosition(){return"bottom-right"}onAdd(a){const b=this.options&&this.options.compact;return this._map=a,this._container=h.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=h.create("button","mapboxgl-ctrl-attrib-button",this._container),h.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),b&&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),void 0===b&&(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(a,b){const c=this._map._getUIString(`AttributionControl.${b}`);a.setAttribute("aria-label",c),a.removeAttribute("title"),a.firstElementChild&&a.firstElementChild.setAttribute("title",c)}_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 b=this._editLink;b||(b=this._editLink=this._container.querySelector(".mapbox-improve-map"));const c=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN},];if(b){const d=c.reduce((a,b,d)=>(b.value&&(a+=`${b.key}=${b.value}${d<c.length-1?"&":""}`),a),"?");b.href=`${a.config.FEEDBACK_URL}/${d}${this._map._hash?this._map._hash.getHashString(!0):""}`,b.rel="noopener nofollow",this._setElementTitle(b,"MapFeedback")}}_updateData(a){a&&("metadata"===a.sourceDataType||"visibility"===a.sourceDataType||"style"===a.dataType)&&(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let a=[];if(this._map.style.stylesheet){const b=this._map.style.stylesheet;this.styleOwner=b.owner,this.styleId=b.id}const c=this._map.style._sourceCaches;for(const d in c){const f=c[d];if(f.used){const g=f.getSource();g.attribution&&0>a.indexOf(g.attribution)&&a.push(g.attribution)}}a.sort((a,b)=>a.length-b.length),a=a.filter((b,c)=>{for(let d=c+1;d<a.length;d++)if(a[d].indexOf(b)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?a=[...this.options.customAttribution,...a,]:a.unshift(this.options.customAttribution));const h=a.join(" | ");h!==this._attribHTML&&(this._attribHTML=h,a.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 c9{constructor(){a.bindAll(["_updateLogo"],this),a.bindAll(["_updateCompact"],this)}onAdd(a){this._map=a,this._container=h.create("div","mapboxgl-ctrl");const b=h.create("a","mapboxgl-ctrl-logo");return b.target="_blank",b.rel="noopener nofollow",b.href="https://www.mapbox.com/",b.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),b.setAttribute("rel","noopener nofollow"),this._container.appendChild(b),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(a){a&&"metadata"!==a.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const a=this._map.style._sourceCaches;if(0===Object.entries(a).length)return!0;for(const b in a){const c=a[b].getSource();if(c.hasOwnProperty("mapbox_logo")&&!c.mapbox_logo)return!1}return!0}_updateCompact(){const a=this._container.children;if(a.length){const b=a[0];this._map.getCanvasContainer().offsetWidth<250?b.classList.add("mapboxgl-compact"):b.classList.remove("mapboxgl-compact")}}}class da{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(a){const b=++this._id;return this._queue.push({callback:a,id:b,cancelled:!1}),b}remove(a){const b=this._currentlyRunning,c=b?this._queue.concat(b):this._queue;for(const d of c)if(d.id===a)return void(d.cancelled=!0)}run(a=0){const b=this._currentlyRunning=this._queue;for(const c of(this._queue=[],b))if(!c.cancelled&&(c.callback(a),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function db(b,c,d){if(b=new a.LngLat(b.lng,b.lat),c){const f=new a.LngLat(b.lng-360,b.lat),g=new a.LngLat(b.lng+360,b.lat),h=360*Math.ceil(Math.abs(b.lng-d.center.lng)/360),i=d.locationPoint(b).distSqr(c),j=c.x<0||c.y<0||c.x>d.width||c.y>d.height;d.locationPoint(f).distSqr(c)<i&&(j||Math.abs(f.lng-d.center.lng)<h)?b=f:d.locationPoint(g).distSqr(c)<i&&(j||Math.abs(g.lng-d.center.lng)<h)&&(b=g)}for(;Math.abs(b.lng-d.center.lng)>180;){const k=d.locationPoint(b);if(k.x>=0&&k.y>=0&&k.x<=d.width&&k.y<=d.height)break;b.lng>d.center.lng?b.lng-=360:b.lng+=360}return b}const dc={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 dd extends a.Evented{constructor(b,c){if(super(),(b instanceof a.window.HTMLElement||c)&&(b=a.extend({element:b},c)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer",],this),this._anchor=b&&b.anchor||"center",this._color=b&&b.color||"#3FB1CE",this._scale=b&&b.scale||1,this._draggable=b&&b.draggable||!1,this._clickTolerance=b&&b.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=b&&b.rotation||0,this._rotationAlignment=b&&b.rotationAlignment||"auto",this._pitchAlignment=b&&b.pitchAlignment&&"auto"!==b.pitchAlignment?b.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),b&&b.element)this._element=b.element,this._offset=a.pointGeometry.convert(b&&b.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const d=41,f=27,g=h.createSVG("svg",{display:"block",height:d*this._scale+"px",width:f*this._scale+"px",viewBox:`0 0 ${f} ${d}`},this._element),i=h.createSVG("radialGradient",{id:"shadowGradient"},h.createSVG("defs",{},g));h.createSVG("stop",{offset:"10%","stop-opacity":.4},i),h.createSVG("stop",{offset:"100%","stop-opacity":.05},i),h.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},g),h.createSVG("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},g),h.createSVG("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},g),h.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},g),this._offset=a.pointGeometry.convert(b&&b.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",a=>{a.preventDefault()}),this._element.addEventListener("mousedown",a=>{a.preventDefault()});const j=this._element.classList;for(const k in dc)j.remove(`mapboxgl-marker-anchor-${k}`);j.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(a){return a===this._map||(this.remove(),this._map=a,a.getCanvasContainer().appendChild(this._element),a.on("move",this._updateMoving),a.on("moveend",this._update),a.on("remove",this._clearFadeTimer),a._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick)),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(a){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")),a){if(!("offset"in a.options)){const b=38.1,c=13.5,d=Math.sqrt(Math.pow(c,2)/2);a.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-b],"bottom-left":[d,-1*(b-c+d),],"bottom-right":[-d,-1*(b-c+d),],left:[c,-1*(b-c)],right:[-c,-1*(b-c)]}:this._offset}this._popup=a,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(a){const b=a.code,c=a.charCode||a.keyCode;"Space"!==b&&"Enter"!==b&&32!==c&&13!==c||this.togglePopup()}_onMapClick(a){const b=a.originalEvent.target,c=this._element;this._popup&&(b===c||c.contains(b))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const a=this._popup;return a&&(a.isOpen()?(a.remove(),this._element.setAttribute("aria-expanded","false")):(a.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_evaluateOpacity(){const a=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(a))return void this._clearFadeTimer();const b=this._map.unproject(a);let c=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const d=this._map.getFreeCameraOptions();if(d.position){const f=d.position.toLngLat();c=f.distanceTo(b)<.9*f.distanceTo(this._lngLat)}}const g=(1-this._map._queryFogOpacity(b))*(c?.2:1);this._element.style.opacity=`${g}`,this._popup&&this._popup._setOpacity(`${g}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(a){const b=this._map.transform;return!!a&&a.x>=0&&a.x<b.width&&a.y>=0&&a.y<b.height}_updateDOM(){const b=this._pos||new a.pointGeometry(0,0),c=this._calculatePitch(),d=this._calculateRotation();this._element.style.transform=`${dc[this._anchor]} translate(${b.x}px, ${b.y}px) rotateX(${c}deg) rotateZ(${d}deg)`}_calculatePitch(){return"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?0:"map"===this._pitchAlignment?this._map.getPitch():0}_calculateRotation(){return"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?this._rotation:"map"===this._rotationAlignment?this._rotation-this._map.getBearing():0}_update(b){a.window.cancelAnimationFrame(this._updateFrameId),this._map&&(this._map.transform.renderWorldCopies&&(this._lngLat=db(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._transformedOffset()),!0===b?this._updateFrameId=a.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(this._map.getTerrain()||this._map.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const a=this._map.transform,b=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&b._rotate(a.angle),"map"===this._pitchAlignment&&(b.y*=Math.cos(a._pitch)),b}getOffset(){return this._offset}setOffset(b){return this._offset=a.pointGeometry.convert(b),this._update(),this}_onMove(b){if(!this._isDragging){const c=this._clickTolerance||this._map._clickTolerance;this._isDragging=b.point.dist(this._pointerdownPos)>=c}this._isDragging&&(this._pos=b.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(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,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new a.Event("dragend")),this._state="inactive"}_addDragHandler(a){this._element.contains(a.originalEvent.target)&&(a.preventDefault(),this._positionDelta=a.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=a.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(a){return this._draggable=!!a,this._map&&(a?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(a){return this._rotation=a||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(a){return this._rotationAlignment=a||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(a){return this._pitchAlignment=a&&"auto"!==a?a:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const{HTMLImageElement:de,HTMLElement:df,ImageBitmap:dg}=a.window;function dh(a){a.parentNode&&a.parentNode.removeChild(a)}class di{constructor(b,c,d=!1){this._clickTolerance=10,this.element=c,this.mouseRotate=new cK({clickTolerance:b.dragRotate._mouseRotate._clickTolerance}),this.map=b,d&&(this.mousePitch=new cL({clickTolerance:b.dragRotate._mousePitch._clickTolerance})),a.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset",],this),c.addEventListener("mousedown",this.mousedown),c.addEventListener("touchstart",this.touchstart,{passive:!1}),c.addEventListener("touchmove",this.touchmove),c.addEventListener("touchend",this.touchend),c.addEventListener("touchcancel",this.reset)}down(a,b){this.mouseRotate.mousedown(a,b),this.mousePitch&&this.mousePitch.mousedown(a,b),h.disableDrag()}move(a,b){const c=this.map,d=this.mouseRotate.mousemoveWindow(a,b);if(d&&d.bearingDelta&&c.setBearing(c.getBearing()+d.bearingDelta),this.mousePitch){const f=this.mousePitch.mousemoveWindow(a,b);f&&f.pitchDelta&&c.setPitch(c.getPitch()+f.pitchDelta)}}off(){const a=this.element;a.removeEventListener("mousedown",this.mousedown),a.removeEventListener("touchstart",this.touchstart,{passive:!1}),a.removeEventListener("touchmove",this.touchmove),a.removeEventListener("touchend",this.touchend),a.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(b){this.down(a.extend({},b,{ctrlKey:!0,preventDefault:()=>b.preventDefault()}),h.mousePos(this.element,b)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(a){this.move(a,h.mousePos(this.element,a))}mouseup(a){this.mouseRotate.mouseupWindow(a),this.mousePitch&&this.mousePitch.mouseupWindow(a),this.offTemp()}touchstart(a){1!==a.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,a.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>a.preventDefault()},this._startPos))}touchmove(a){1!==a.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,a.targetTouches)[0],this.move({preventDefault:()=>a.preventDefault()},this._lastPos))}touchend(a){0===a.targetTouches.length&&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 dj,dk=0,dl=!1;function dm(a,b,c){const d=c&&c.maxWidth||100,f=a._containerHeight/2,g=a.unproject([0,f]),h=a.unproject([d,f]),i=g.distanceTo(h);if(c&&"imperial"===c.unit){const j=3.2808*i;j>5280?dn(b,d,j/5280,a._getUIString("ScaleControl.Miles"),a):dn(b,d,j,a._getUIString("ScaleControl.Feet"),a)}else c&&"nautical"===c.unit?dn(b,d,i/1852,a._getUIString("ScaleControl.NauticalMiles"),a):i>=1e3?dn(b,d,i/1e3,a._getUIString("ScaleControl.Kilometers"),a):dn(b,d,i,a._getUIString("ScaleControl.Meters"),a)}function dn(a,b,c,d,f){const g=function(a){const b=Math.pow(10,`${Math.floor(a)}`.length-1);let c=a/b;return c=c>=10?10:c>=5?5:c>=3?3:c>=2?2:c>=1?1:function(a){const b=Math.pow(10,Math.ceil(-Math.log(a)/Math.LN10));return Math.round(a*b)/b}(c),b*c}(c),h=g/c;f._requestDomTask(()=>{a.style.width=b*h+"px",a.innerHTML=`${g}&nbsp;${d}`})}const dp={version:a.version,supported:b,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends c7{constructor(b){if(null!=(b=a.extend({},{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,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},b)).minZoom&&null!=b.maxZoom&&b.minZoom>b.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=b.minPitch&&null!=b.maxPitch&&b.minPitch>b.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=b.minPitch&&b.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=b.maxPitch&&b.maxPitch>85)throw Error("maxPitch must be less than or equal to 85");if(super(new cp(b.minZoom,b.maxZoom,b.minPitch,b.maxPitch,b.renderWorldCopies),b),this._interactive=b.interactive,this._minTileCacheSize=b.minTileCacheSize,this._maxTileCacheSize=b.maxTileCacheSize,this._failIfMajorPerformanceCaveat=b.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=b.preserveDrawingBuffer,this._antialias=b.antialias,this._trackResize=b.trackResize,this._bearingSnap=b.bearingSnap,this._refreshExpiredTiles=b.refreshExpiredTiles,this._fadeDuration=b.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=b.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=b.collectResourceTiming,this._optimizeForTerrain=b.optimizeForTerrain,this._renderTaskQueue=new da,this._domRenderTaskQueue=new da,this._controls=[],this._markers=[],this._mapId=a.uniqueId(),this._locale=a.extend({},{"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"},b.locale),this._clickTolerance=b.clickTolerance,this._cooperativeGestures=b.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new class{constructor(a){this.jumpTo(a)}getValue(b){if(b<=this._startTime)return this._start;if(b>=this._endTime)return this._end;const c=a.easeCubicInOut((b-this._startTime)/(this._endTime-this._startTime));return this._start*(1-c)+this._end*c}isEasing(a){return a>=this._startTime&&a<=this._endTime}jumpTo(a){this._startTime=-1/0,this._endTime=-1/0,this._start=a,this._end=a}easeTo(a,b,c){this._start=this.getValue(b),this._end=a,this._startTime=b,this._endTime=b+c}}(0),this._requestManager=new a.RequestManager(b.transformRequest,b.accessToken,b.testMode),this._silenceAuthErrors=!!b.testMode,"string"==typeof b.container){if(this._container=a.window.document.getElementById(b.container),!this._container)throw Error(`Container '${b.container}' not found.`)}else{if(!(b.container instanceof df))throw Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=b.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."),b.maxBounds&&this.setMaxBounds(b.maxBounds),a.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored",],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==a.window&&(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 class{constructor(b,c){this._map=b,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new class{constructor(a){this._map=a,this.clear()}clear(){this._inertiaBuffer=[]}record(b){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:b})}_drainInertiaBuffer(){const b=this._inertiaBuffer,c=a.exported.now();for(;b.length>0&&c-b[0].time>160;)b.shift()}_onMoveEnd(b){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const c={zoom:0,bearing:0,pitch:0,pan:new a.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)c.zoom+=d.zoomDelta||0,c.bearing+=d.bearingDelta||0,c.pitch+=d.pitchDelta||0,d.panDelta&&c.pan._add(d.panDelta),d.around&&(c.around=d.around),d.pinchAround&&(c.pinchAround=d.pinchAround);const f=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,g={};if(c.pan.mag()){const h=cx(c.pan.mag(),f,a.extend({},cs,b||{}));g.offset=c.pan.mult(h.amount/c.pan.mag()),g.center=this._map.transform.center,cw(g,h)}if(c.zoom){const i=cx(c.zoom,f,ct);g.zoom=this._map.transform.zoom+i.amount,cw(g,i)}if(c.bearing){const j=cx(c.bearing,f,cu);g.bearing=this._map.transform.bearing+a.clamp(j.amount,-179,179),cw(g,j)}if(c.pitch){const k=cx(c.pitch,f,cv);g.pitch=this._map.transform.pitch+k.amount,cw(g,k)}if(g.zoom||g.bearing){const l=void 0===c.pinchAround?c.around:c.pinchAround;g.around=l?this._map.unproject(l):this._map.getCenter()}return this.clear(),a.extend(g,{noMoveStart:!0})}}(b),this._bearingSnap=c.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new class{constructor(){this.constants=[1,1,.01],this.radius=0}setup(b,c){const d=a.sub([],c,b);this.radius=a.length(d[2]<0?a.div([],d,this.constants):[d[0],d[1],0])}projectRay(b){a.div(b,b,this.constants),a.normalize(b,b),a.mul$1(b,b,this.constants);const c=a.scale$2([],b,this.radius);if(c[2]>0){const d=a.scale$2([],[0,0,1],a.dot(c,[0,0,1])),f=a.scale$2([],a.normalize([],[c[0],c[1],0]),this.radius),g=a.add([],c,a.scale$2([],a.sub([],a.add([],f,d),c),2));c[0]=g[0],c[1]=g[1]}return c}},this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(c),a.bindAll(["handleEvent","handleWindowEvent"],this);const d=this._el;for(const[f,g,h]of(this._listeners=[[d,"touchstart",{passive:!0},],[d,"touchmove",{passive:!1},],[d,"touchend",void 0],[d,"touchcancel",void 0],[d,"mousedown",void 0],[d,"mousemove",void 0],[d,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0},],[a.window.document,"mouseup",void 0],[d,"mouseover",void 0],[d,"mouseout",void 0],[d,"dblclick",void 0],[d,"click",void 0],[d,"keydown",{capture:!1},],[d,"keyup",void 0],[d,"wheel",{passive:!1},],[d,"contextmenu",void 0],[a.window,"blur",void 0],],this._listeners))f.addEventListener(g,f===a.window.document?this.handleWindowEvent:this.handleEvent,h)}destroy(){for(const[b,c,d]of this._listeners)b.removeEventListener(c,b===a.window.document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(a){const b=this._map,c=b.getCanvasContainer();this._add("mapEvent",new cB(b,a));const d=b.boxZoom=new cD(b,a);this._add("boxZoom",d);const f=new cG,g=new c$;b.doubleClickZoom=new cZ(g,f),this._add("tapZoom",f),this._add("clickZoom",g);const h=new c_;this._add("tapDragZoom",h);const i=b.touchPitch=new cU(b);this._add("touchPitch",i);const j=new cK(a),k=new cL(a);b.dragRotate=new c1(a,j,k),this._add("mouseRotate",j,["mousePitch"]),this._add("mousePitch",k,["mouseRotate"]);const l=new cJ(a),m=new cM(b,a);b.dragPan=new c0(c,l,m),this._add("mousePan",l),this._add("touchPan",m,["touchZoom","touchRotate",]);const n=new cS,o=new cQ;b.touchZoomRotate=new c2(c,o,n,h),this._add("touchRotate",n,["touchPan","touchZoom",]),this._add("touchZoom",o,["touchPan","touchRotate",]),this._add("blockableMapEvent",new cC(b));const p=b.scrollZoom=new cY(b,this);this._add("scrollZoom",p,["mousePan"]);const q=b.keyboard=new cV;for(const r of(this._add("keyboard",q),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard",]))a.interactive&&a[r]&&b[r].enable(a[r])}_add(a,b,c){this._handlers.push({handlerName:a,handler:b,allowed:c}),this._handlersById[a]=b}stop(a){if(!this._updatingCamera){for(const{handler:b}of this._handlers)b.reset();this._inertia.clear(),this._fireEvents({},{},a),this._changes=[]}}isActive(){for(const{handler:a}of this._handlers)if(a.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(c3(this._eventsInProgress))||this.isZooming()}_blockedByActive(a,b,c){for(const d in a)if(d!==c&&(!b||0>b.indexOf(d)))return!0;return!1}handleWindowEvent(a){this.handleEvent(a,`${a.type}Window`)}_getMapTouches(a){const b=[];for(const c of a)this._el.contains(c.target)&&b.push(c);return b}handleEvent(a,b){this._updatingCamera=!0;const c="renderFrame"===a.type,d=c?void 0:a,f={needsRenderFrame:!1},g={},i={},j=a.touches?this._getMapTouches(a.touches):void 0,k=j?h.touchPos(this._el,j):c?void 0:h.mousePos(this._el,a);for(const{handlerName:l,handler:m,allowed:n}of this._handlers){if(!m.isEnabled())continue;let o;this._blockedByActive(i,n,l)?m.reset():m[b||a.type]&&(o=m[b||a.type](a,k,j),this.mergeHandlerResult(f,g,o,l,d),o&&o.needsRenderFrame&&this._triggerRenderFrame()),(o||m.isActive())&&(i[l]=m)}const p={};for(const q in this._previousActiveHandlers)i[q]||(p[q]=d);this._previousActiveHandlers=i,(Object.keys(p).length||c5(f))&&(this._changes.push([f,g,p]),this._triggerRenderFrame()),(Object.keys(i).length||c5(f))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:r}=f;r&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],r(this._map))}mergeHandlerResult(b,c,d,f,g){if(!d)return;a.extend(b,d);const h={handlerName:f,originalEvent:d.originalEvent||g};void 0!==d.zoomDelta&&(c.zoom=h),void 0!==d.panDelta&&(c.drag=h),void 0!==d.pitchDelta&&(c.pitch=h),void 0!==d.bearingDelta&&(c.rotate=h)}_applyChanges(){const b={},c={},d={};for(const[f,g,h]of this._changes)f.panDelta&&(b.panDelta=(b.panDelta||new a.pointGeometry(0,0))._add(f.panDelta)),f.zoomDelta&&(b.zoomDelta=(b.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(b.bearingDelta=(b.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(b.pitchDelta=(b.pitchDelta||0)+f.pitchDelta),void 0!==f.around&&(b.around=f.around),void 0!==f.aroundCoord&&(b.aroundCoord=f.aroundCoord),void 0!==f.pinchAround&&(b.pinchAround=f.pinchAround),f.noInertia&&(b.noInertia=f.noInertia),a.extend(c,g),a.extend(d,h);this._updateMapTransform(b,c,d),this._changes=[]}_updateMapTransform(b,c,d){const f=this._map,g=f.transform,h=a=>[a.x,a.y,a.z];if((a=>{const b=this._eventsInProgress.drag;return b&&!this._handlersById[b.handlerName].isActive()})()&&!c5(b)){const i=g.zoom;g.cameraElevationReference="sea",g.recenterOnTerrain(),g.cameraElevationReference="ground",i!==g.zoom&&this._map._update(!0)}if(!c5(b))return this._fireEvents(c,d,!0);let{panDelta:j,zoomDelta:k,bearingDelta:l,pitchDelta:m,around:n,aroundCoord:o,pinchAround:p}=b;void 0!==p&&(n=p),c.drag&&!this._eventsInProgress.drag&&n&&(this._dragOrigin=h(g.pointCoordinate3D(n)),this._trackingEllipsoid.setup(g._camera.position,this._dragOrigin)),g.cameraElevationReference="sea",f._stop(!0),n=n||f.transform.centerPoint,l&&(g.bearing+=l),m&&(g.pitch+=m),g._updateCameraState();const q=[0,0,0];if(j){const r=g.pointCoordinate(n),s=g.pointCoordinate(n.sub(j));r&&s&&(q[0]=s.x-r.x,q[1]=s.y-r.y)}const u=g.zoom,v=[0,0,0];if(k){const w=h(o||g.pointCoordinate3D(n)),x={dir:a.normalize([],a.sub([],w,g._camera.position))};if(x.dir[2]<0){const y=g.zoomDeltaToMovement(w,k);a.scale$2(v,x.dir,y)}}const z=a.add(q,q,v);g._translateCameraConstrained(z),k&&Math.abs(g.zoom-u)>1e-4&&g.recenterOnTerrain(),g.cameraElevationReference="ground",this._map._update(),b.noInertia||this._inertia.record(b),this._fireEvents(c,d,!0)}_fireEvents(b,c,d){const f=c3(this._eventsInProgress),g=c3(b),h={};for(const i in b){const{originalEvent:j}=b[i];this._eventsInProgress[i]||(h[`${i}start`]=j),this._eventsInProgress[i]=b[i]}for(const k in!f&&g&&this._fireEvent("movestart",g.originalEvent),h)this._fireEvent(k,h[k]);for(const l in g&&this._fireEvent("move",g.originalEvent),b){const{originalEvent:m}=b[l];this._fireEvent(l,m)}const n={};let o;for(const p in this._eventsInProgress){const{handlerName:q,originalEvent:r}=this._eventsInProgress[p];this._handlersById[q].isActive()||(delete this._eventsInProgress[p],o=c[q]||r,n[`${p}end`]=o)}for(const s in n)this._fireEvent(s,n[s]);const u=c3(this._eventsInProgress);if(d&&(f||g)&&!u){this._updatingCamera=!0;const v=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),w=a=>0!==a&& -this._bearingSnap<a&&a<this._bearingSnap;v?(w(v.bearing||this._map.getBearing())&&(v.bearing=0),this._map.easeTo(v,{originalEvent:o})):(this._map.fire(new a.Event("moveend",{originalEvent:o})),w(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(b,c){this._map.fire(new a.Event(b,c?{originalEvent:c}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(a=>{delete this._frameId,this.handleEvent(new c4("renderFrame",{timeStamp:a})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}(this,b),this._localFontFamily=b.localFontFamily,this._localIdeographFontFamily=b.localIdeographFontFamily,b.style&&this.setStyle(b.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),b.projection&&this.setProjection(b.projection),this._hash=b.hash&&new class{constructor(b){this._hashName=b&&encodeURIComponent(b),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash",],this),this._updateHash=cq(this._updateHashUnthrottled.bind(this),300)}addTo(b){return this._map=b,a.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return a.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(b){const c=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,f=Math.pow(10,Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10)),g=Math.round(c.lng*f)/f,h=Math.round(c.lat*f)/f,i=this._map.getBearing(),j=this._map.getPitch();let k="";if(k+=b?`/${g}/${h}/${d}`:`${d}/${h}/${g}`,(i||j)&&(k+="/"+Math.round(10*i)/10),j&&(k+=`/${Math.round(j)}`),this._hashName){const l=this._hashName;let m=!1;const n=a.window.location.hash.slice(1).split("&").map(a=>{const b=a.split("=")[0];return b===l?(m=!0,`${b}=${k}`):a}).filter(a=>a);return m||n.push(`${l}=${k}`),`#${n.join("&")}`}return`#${k}`}_getCurrentHash(){const b=a.window.location.hash.replace("#","");if(this._hashName){let c;return b.split("&").map(a=>a.split("=")).forEach(a=>{a[0]===this._hashName&&(c=a)}),(c&&c[1]||"").split("/")}return b.split("/")}_onHashChange(){const a=this._getCurrentHash();if(a.length>=3&&!a.some(a=>isNaN(a))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(a[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+a[2],+a[1]],zoom:+a[0],bearing:b,pitch:+(a[4]||0)}),!0}return!1}_updateHashUnthrottled(){const b=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,b)}}("string"==typeof b.hash&&b.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:b.center,zoom:b.zoom,bearing:b.bearing,pitch:b.pitch}),b.bounds&&(this.resize(),this.fitBounds(b.bounds,a.extend({},b.fitBoundsOptions,{duration:0})))),this.resize(),b.attributionControl&&this.addControl(new c8({customAttribution:b.customAttribution})),this._logoControl=new c9,this.addControl(this._logoControl,b.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",b=>{this._update("style"===b.dataType),this.fire(new a.Event(`${b.dataType}data`,b))}),this.on("dataloading",b=>{this.fire(new a.Event(`${b.dataType}dataloading`,b))})}_getMapId(){return this._mapId}addControl(b,c){if(void 0===c&&(c=b.getDefaultPosition?b.getDefaultPosition():"top-right"),!b||!b.onAdd)return this.fire(new a.ErrorEvent(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const d=b.onAdd(this);this._controls.push(b);const f=this._controlPositions[c];return -1!==c.indexOf("bottom")?f.insertBefore(d,f.firstChild):f.appendChild(d),this}removeControl(b){if(!b||!b.onRemove)return this.fire(new a.ErrorEvent(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const c=this._controls.indexOf(b);return c> -1&&this._controls.splice(c,1),b.onRemove(this),this}hasControl(a){return this._controls.indexOf(a)> -1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(b){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const c=!this._moving;return c&&this.fire(new a.Event("movestart",b)).fire(new a.Event("move",b)),this.fire(new a.Event("resize",b)),c&&this.fire(new a.Event("moveend",b)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(b){return this.transform.setMaxBounds(a.LngLatBounds.convert(b)),this._update()}setMinZoom(b){if((b=null==b?-2:b)>= -2&&b<=this.transform.maxZoom)return this.transform.minZoom=b,this._update(),this.getZoom()<b?this.setZoom(b):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(b){if((b=null==b?22:b)>=this.transform.minZoom)return this.transform.maxZoom=b,this._update(),this.getZoom()>b?this.setZoom(b):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(b){if((b=null==b?0:b)<0)throw Error("minPitch must be greater than or equal to 0");if(b>=0&&b<=this.transform.maxPitch)return this.transform.minPitch=b,this._update(),this.getPitch()<b?this.setPitch(b):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(b){if((b=null==b?85:b)>85)throw Error("maxPitch must be less than or equal to 85");if(b>=this.transform.minPitch)return this.transform.maxPitch=b,this._update(),this.getPitch()>b?this.setPitch(b):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(a){return this.transform.renderWorldCopies=a,this._update()}getProjection(){return this.transform.getProjection()}setProjection(a){return this._lazyInitEmptyStyle(),"string"==typeof a&&(a={name:a}),this._runtimeProjection=a,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(b){return this.transform.locationPoint3D(a.LngLat.convert(b))}unproject(b){return this.transform.pointLocation3D(a.pointGeometry.convert(b))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(a,b,c){if("mouseenter"===a||"mouseover"===a){let d=!1;const f=f=>{const g=b.filter(a=>this.getLayer(a)),h=g.length?this.queryRenderedFeatures(f.point,{layers:g}):[];h.length?d||(d=!0,c.call(this,new cy(a,this,f.originalEvent,{features:h}))):d=!1},g=()=>{d=!1};return{layers:new Set(b),listener:c,delegates:{mousemove:f,mouseout:g}}}if("mouseleave"===a||"mouseout"===a){let h=!1;const i=d=>{const f=b.filter(a=>this.getLayer(a));(f.length?this.queryRenderedFeatures(d.point,{layers:f}):[]).length?h=!0:h&&(h=!1,c.call(this,new cy(a,this,d.originalEvent)))},j=b=>{h&&(h=!1,c.call(this,new cy(a,this,b.originalEvent)))};return{layers:new Set(b),listener:c,delegates:{mousemove:i,mouseout:j}}}return{layers:new Set(b),listener:c,delegates:{[a]:a=>{const d=b.filter(a=>this.getLayer(a)),f=d.length?this.queryRenderedFeatures(a.point,{layers:d}):[];f.length&&(a.features=f,c.call(this,a),delete a.features)}}}}on(a,b,c){if(void 0===c)return super.on(a,b);Array.isArray(b)||(b=[b]);const d=this._createDelegatedListener(a,b,c);for(const f in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[a]=this._delegatedListeners[a]||[],this._delegatedListeners[a].push(d),d.delegates)this.on(f,d.delegates[f]);return this}once(a,b,c){if(void 0===c)return super.once(a,b);Array.isArray(b)||(b=[b]);const d=this._createDelegatedListener(a,b,c);for(const f in d.delegates)this.once(f,d.delegates[f]);return this}off(a,b,c){if(void 0===c)return super.off(a,b);b=new Set(Array.isArray(b)?b:[b]);const d=(a,b)=>{if(a.size!==b.size)return!1;for(const c of a)if(!b.has(c))return!1;return!0},f=this._delegatedListeners?this._delegatedListeners[a]:void 0;return f&&(a=>{for(let f=0;f<a.length;f++){const g=a[f];if(g.listener===c&&d(g.layers,b)){for(const h in g.delegates)this.off(h,g.delegates[h]);return a.splice(f,1),this}}})(f),this}queryRenderedFeatures(b,c){return this.style?(void 0!==c|| void 0===b||b instanceof a.pointGeometry||Array.isArray(b)||(c=b,b=void 0),this.style.queryRenderedFeatures(b=b||[[0,0],[this.transform.width,this.transform.height,],],c=c||{},this.transform)):[]}querySourceFeatures(a,b){return this.style.querySourceFeatures(a,b)}queryTerrainElevation(b,c){const d=this.transform.elevation;return d?(c=a.extend({},{exaggerated:!0},c),d.getAtPoint(a.MercatorCoordinate.fromLngLat(b),null,c.exaggerated)):null}setStyle(b,c){return!1!==(c=a.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},c)).diff&&c.localIdeographFontFamily===this._localIdeographFontFamily&&c.localFontFamily===this._localFontFamily&&this.style&&b?(this._diffStyle(b,c),this):(this._localIdeographFontFamily=c.localIdeographFontFamily,this._localFontFamily=c.localFontFamily,this._updateStyle(b,c))}_getUIString(a){const b=this._locale[a];if(null==b)throw Error(`Missing UI string '${a}'`);return b}_updateStyle(a,b){return this.style&&(this.style.setEventedParent(null),this.style._remove(),delete this.style),a&&(this.style=new aY(this,b||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof a?this.style.loadURL(a):this.style.loadJSON(a)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new aY(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(b,c){if("string"==typeof b){const d=this._requestManager.normalizeStyleURL(b),f=this._requestManager.transformRequest(d,a.ResourceType.Style);a.getJSON(f,(b,d)=>{b?this.fire(new a.ErrorEvent(b)):d&&this._updateDiff(d,c)})}else"object"==typeof b&&this._updateDiff(b,c)}_updateDiff(b,c){try{this.style.setState(b)&&this._update(!0)}catch(d){a.warnOnce(`Unable to perform style diff: ${d.message||d.error||d}. Rebuilding the style from scratch.`),this._updateStyle(b,c)}}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.")}addSource(a,b){return this._lazyInitEmptyStyle(),this.style.addSource(a,b),this._update(!0)}isSourceLoaded(b){const c=this.style&&this.style._getSourceCaches(b);if(0!==c.length)return c.every(a=>a.loaded());this.fire(new a.ErrorEvent(Error(`There is no source with ID '${b}'`)))}areTilesLoaded(){const a=this.style&&this.style._sourceCaches;for(const b in a){const c=a[b]._tiles;for(const d in c){const f=c[d];if("loaded"!==f.state&&"errored"!==f.state)return!1}}return!0}addSourceType(a,b,c){return this._lazyInitEmptyStyle(),this.style.addSourceType(a,b,c)}removeSource(a){return this.style.removeSource(a),this._updateTerrain(),this._update(!0)}getSource(a){return this.style.getSource(a)}addImage(b,c,{pixelRatio:d=1,sdf:f=!1,stretchX:g,stretchY:h,content:i}={}){if(this._lazyInitEmptyStyle(),c instanceof de||dg&&c instanceof dg){const{width:j,height:k,data:l}=a.exported.getImageData(c);this.style.addImage(b,{data:new a.RGBAImage({width:j,height:k},l),pixelRatio:d,stretchX:g,stretchY:h,content:i,sdf:f,version:0})}else{if(void 0===c.width|| void 0===c.height)return this.fire(new a.ErrorEvent(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:m,height:n,data:o}=c,p=c;this.style.addImage(b,{data:new a.RGBAImage({width:m,height:n},new Uint8Array(o)),pixelRatio:d,stretchX:g,stretchY:h,content:i,sdf:f,version:0,userImage:p}),p.onAdd&&p.onAdd(this,b)}}}updateImage(b,c){const d=this.style.getImage(b);if(!d)return this.fire(new a.ErrorEvent(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const f=c instanceof de||dg&&c instanceof dg?a.exported.getImageData(c):c,{width:g,height:h,data:i}=f;return void 0===g|| void 0===h?this.fire(new a.ErrorEvent(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`"))):g!==d.data.width||h!==d.data.height?this.fire(new a.ErrorEvent(Error("The width and height of the updated image must be that same as the previous version of the image"))):(d.data.replace(i,!(c instanceof de||dg&&c instanceof dg)),void this.style.updateImage(b,d))}hasImage(b){return b?!!this.style.getImage(b):(this.fire(new a.ErrorEvent(Error("Missing required image id"))),!1)}removeImage(a){this.style.removeImage(a)}loadImage(b,c){a.getImage(this._requestManager.transformRequest(b,a.ResourceType.Image),(b,d)=>{c(b,d instanceof de?a.exported.getImageData(d):d)})}listImages(){return this.style.listImages()}addLayer(a,b){return this._lazyInitEmptyStyle(),this.style.addLayer(a,b),this._update(!0)}moveLayer(a,b){return this.style.moveLayer(a,b),this._update(!0)}removeLayer(a){return this.style.removeLayer(a),this._update(!0)}getLayer(a){return this.style.getLayer(a)}setLayerZoomRange(a,b,c){return this.style.setLayerZoomRange(a,b,c),this._update(!0)}setFilter(a,b,c={}){return this.style.setFilter(a,b,c),this._update(!0)}getFilter(a){return this.style.getFilter(a)}setPaintProperty(a,b,c,d={}){return this.style.setPaintProperty(a,b,c,d),this._update(!0)}getPaintProperty(a,b){return this.style.getPaintProperty(a,b)}setLayoutProperty(a,b,c,d={}){return this.style.setLayoutProperty(a,b,c,d),this._update(!0)}getLayoutProperty(a,b){return this.style.getLayoutProperty(a,b)}setLight(a,b={}){return this._lazyInitEmptyStyle(),this.style.setLight(a,b),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(a){return this._lazyInitEmptyStyle(),!a&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(a),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){"globe"===this.transform.projection.name&&this.transform.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(a){return this._lazyInitEmptyStyle(),this.style.setFog(a),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(b){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.LngLat.convert(b),this.transform):0}setFeatureState(a,b){return this.style.setFeatureState(a,b),this._update()}removeFeatureState(a,b){return this.style.removeFeatureState(a,b),this._update()}getFeatureState(a){return this.style.getFeatureState(a)}_updateContainerDimensions(){if(!this._container)return;const b=this._container.getBoundingClientRect().width||400,c=this._container.getBoundingClientRect().height||300;let d,f=this._container;for(;f&&!d;){const g=a.window.getComputedStyle(f).transform;g&&"none"!==g&&(d=g.match(/matrix.*\((.+)\)/)[1].split(", ")),f=f.parentElement}d?(this._containerWidth=d[0]&&"0"!==d[0]?Math.abs(b/d[0]):b,this._containerHeight=d[3]&&"0"!==d[3]?Math.abs(c/d[3]):c):(this._containerWidth=b,this._containerHeight=c)}_detectMissingCSS(){"rgb(250, 128, 114)"!==a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&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(){const a=this._container;a.classList.add("mapboxgl-map"),(this._missingCSSCanary=h.create("div","mapboxgl-canary",a)).style.visibility="hidden",this._detectMissingCSS();const b=this._canvasContainer=h.create("div","mapboxgl-canvas-container",a);this._interactive&&b.classList.add("mapboxgl-interactive"),this._canvas=h.create("canvas","mapboxgl-canvas",b),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);const c=this._controlContainer=h.create("div","mapboxgl-control-container",a),d=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right",].forEach(a=>{d[a]=h.create("div",`mapboxgl-ctrl-${a}`,c)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(b,c){const d=a.exported.devicePixelRatio||1;this._canvas.width=d*Math.ceil(b),this._canvas.height=d*Math.ceil(c),this._canvas.style.width=`${b}px`,this._canvas.style.height=`${c}px`}_addMarker(a){this._markers.push(a)}_removeMarker(a){const b=this._markers.indexOf(a);-1!==b&&this._markers.splice(b,1)}_setupPainter(){const c=a.extend({},b.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),d=this._canvas.getContext("webgl",c)||this._canvas.getContext("experimental-webgl",c);d?(a.storeAuthState(d,!0),this.painter=new cb(d,this.transform),this.on("data",a=>{"source"===a.dataType&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(d)):this.fire(new a.ErrorEvent(Error("Failed to initialize WebGL")))}_contextLost(b){b.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:b}))}_contextRestored(b){this._setupPainter(),this.resize(),this._update(),this.fire(new a.Event("webglcontextrestored",{originalEvent:b}))}_onMapScroll(a){if(a.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(a){return this.style&&(this._styleDirty=this._styleDirty||a,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(a){return this._update(),this._renderTaskQueue.add(a)}_cancelRenderFrame(a){this._renderTaskQueue.remove(a)}_requestDomTask(a){!this.loaded()||this.loaded()&&!this.isMoving()?a():this._domRenderTaskQueue.add(a)}_render(b){let c;const d=this.painter.context.extTimerQuery,f=a.exported.now();this.listens("gpu-timing-frame")&&(c=d.createQueryEXT(),d.beginQueryEXT(d.TIME_ELAPSED_EXT,c));let g=this._updateAverageElevation(f);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(b),this._domRenderTaskQueue.run(b),this._removed)return;this._updateProjection();let h=!1;const i=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const j=this.transform.zoom,k=this.transform.pitch,l=a.exported.now();this.style.zoomHistory.update(j,l);const m=new a.EvaluationParameters(j,{now:l,fadeDuration:i,pitch:k,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=m.crossFadingFactor();1===n&&n===this._crossFadingFactor||(h=!0,this._crossFadingFactor=n),this.style.update(m)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,i,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:i,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()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const o=a.exported.now()-f;d.endQueryEXT(d.TIME_ELAPSED_EXT,c),setTimeout(()=>{const b=d.getQueryObjectEXT(c,d.QUERY_RESULT_EXT)/1e6;d.deleteQueryEXT(c),this.fire(new a.Event("gpu-timing-frame",{cpuTime:o,gpuTime:b}))},50)}if(this.listens("gpu-timing-layer")){const p=this.painter.collectGpuTimers();setTimeout(()=>{const b=this.painter.queryGpuTimers(p);this.fire(new a.Event("gpu-timing-layer",{layerTimes:b}))},50)}const q=this._sourcesDirty||this._styleDirty||this._placementDirty||g;if(q||this._repaint)this.triggerRepaint();else{const r=!this.isMoving()&&this.loaded();if(r&&(g=this._updateAverageElevation(f,!0)),g)this.triggerRepaint();else if(this._triggerFrame(!1),r&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const s=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:s})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||q||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const a of this._markers)a._update()}_updateAverageElevation(a,b=!1){const c=a=>(this.transform.averageElevation=a,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&c(0);if((b||a-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(a)){const d=this.transform.averageElevation;let f=this.transform.sampleAverageElevation();isNaN(f)?f=0:this._averageElevationLastSampledAt=a;const g=Math.abs(d-f);if(g>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(f),c(f);this._averageElevation.easeTo(f,a,300)}else if(g>1e-4)return this._averageElevation.jumpTo(f),c(f)}return!!this._averageElevation.isEasing(a)&&c(this._averageElevation.getValue(a))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,b=>{if(b&&(b.message===a.AUTH_ERR_MSG||401===b.status)){const c=this.painter.context.gl;a.storeAuthState(c,!1),this._logoControl instanceof c9&&this._logoControl._updateLogo(),c&&c.clear(c.DEPTH_BUFFER_BIT|c.COLOR_BUFFER_BIT|c.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.ErrorEvent(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(){const a=this.painter.canvasCopy(),b=this.painter.getCanvasCopiesAndTimestamps();b.timeStamps.push(performance.now());const c=this.painter.context.gl,d=c.createFramebuffer();function f(a){c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,a,0);const b=new Uint8Array(c.drawingBufferWidth*c.drawingBufferHeight*4);return c.readPixels(0,0,c.drawingBufferWidth,c.drawingBufferHeight,c.RGBA,c.UNSIGNED_BYTE,b),b}return c.bindFramebuffer(c.FRAMEBUFFER,d),this._canvasPixelComparison(f(a),b.canvasCopies.map(f),b.timeStamps)}_canvasPixelComparison(a,b,c){let d=c[1]-c[0];const f=a.length/4;for(let g=0;g<b.length;g++){const h=b[g];let i=0;for(let j=0;j<h.length;j+=4)h[j]===a[j]&&h[j+1]===a[j+1]&&h[j+2]===a[j+2]&&h[j+3]===a[j+3]&&(i+=1);d+=(c[g+2]-c[g+1])*(1-i/f)}return d}remove(){for(const b of(this._hash&&this._hash.remove(),this._controls))b.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.destroy(),delete this.handlers,this.setStyle(null),void 0!==a.window&&(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));const c=this.painter.context.gl.getExtension("WEBGL_lose_context");c&&c.loseContext(),dh(this._canvasContainer),dh(this._controlContainer),dh(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(b){this._renderNextFrame=this._renderNextFrame||b,this.style&&!this._frame&&(this._frame=a.exported.frame(a=>{const b=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,b&&this._render(a)}))}_preloadTiles(b){const c=this.style&&Object.values(this.style._sourceCaches)||[];return a.asyncAll(c,(a,c)=>a._preloadTiles(b,c),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(a){this._trackResize&&this.resize({originalEvent:a})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(a){this._showTileBoundaries!==a&&(this._showTileBoundaries=a,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(a){this._showTerrainWireframe!==a&&(this._showTerrainWireframe=a,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(a){this._speedIndexTiming!==a&&(this._speedIndexTiming=a,this._update())}get showPadding(){return!!this._showPadding}set showPadding(a){this._showPadding!==a&&(this._showPadding=a,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(a){this._showCollisionBoxes!==a&&(this._showCollisionBoxes=a,a?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(a){this._showOverdrawInspector!==a&&(this._showOverdrawInspector=a,this._update())}get repaint(){return!!this._repaint}set repaint(a){this._repaint!==a&&(this._repaint=a,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(a){this._vertices=a,this._update()}_setCacheLimits(b,c){a.setCacheLimits(b,c)}get version(){return a.version}},NavigationControl:class{constructor(b){this.options=a.extend({},{showCompass:!0,showZoom:!0,visualizePitch:!1},b),this._container=h.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",a=>a.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons",],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",a=>this._map.zoomIn({},{originalEvent:a})),h.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",a=>this._map.zoomOut({},{originalEvent:a})),h.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",a=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:a}):this._map.resetNorth({},{originalEvent:a})}),this._compassIcon=h.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const a=this._map.getZoom(),b=a===this._map.getMaxZoom(),c=a===this._map.getMinZoom();this._zoomInButton.disabled=b,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",b.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.toString())}_rotateCompassArrow(){const a=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=a)})}onAdd(a){return this._map=a,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new di(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(a,b){const c=h.create("button",a,this._container);return c.type="button",c.addEventListener("click",b),c}_setButtonTitle(a,b){const c=this._map._getUIString(`NavigationControl.${b}`);a.setAttribute("aria-label",c),a.firstElementChild&&a.firstElementChild.setAttribute("title",c)}},GeolocateControl:class extends a.Evented{constructor(b){super(),this.options=a.extend({},{positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},b),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation",],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=cq(this._updateMarkerRotation,20)}onAdd(b){var c;return this._map=b,this._container=h.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),c=this._setupUI,void 0!==dj?c(dj):void 0!==a.window.navigator.permissions?a.window.navigator.permissions.query({name:"geolocation"}).then(a=>{c(dj="denied"!==a.state)}):c(dj=!!a.window.navigator.geolocation),this._container}onRemove(){void 0!==this._geolocationWatchID&&(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,dk=0,dl=!1}_isOutOfMapMaxBounds(a){const b=this._map.getMaxBounds(),c=a.coords;return b&&(c.longitude<b.getWest()||c.longitude>b.getEast()||c.latitude<b.getSouth()||c.latitude>b.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(b){if(this._map){if(this._isOutOfMapMaxBounds(b))return this._setErrorState(),this.fire(new a.Event("outofmaxbounds",b)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=b,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&&"OFF"!==this._watchState&&this._updateMarker(b),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(b),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("geolocate",b)),this._finish()}}_updateCamera(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude),d=b.coords.accuracy,f=this._map.getBearing(),g=a.extend({bearing:f},this.options.fitBoundsOptions);this._map.fitBounds(c.toBounds(d),g,{geolocateSource:!0})}_updateMarker(b){if(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=b.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const a=this._map._containerHeight/2,b=this._map.unproject([0,a]),c=this._map.unproject([100,a]),d=b.distanceTo(c)/100,f=Math.ceil(2*this._accuracy/d);this._circleElement.style.width=`${f}px`,this._circleElement.style.height=`${f}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(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(b){if(this._map){if(this.options.trackUserLocation){if(1===b.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===b.code&&dl)return;this._setErrorState()}}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",b)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(b){if(this._container.addEventListener("contextmenu",a=>a.preventDefault()),this._geolocateButton=h.create("button","mapboxgl-ctrl-geolocate",this._container),h.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===b){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c)}else{const d=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",d),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",d)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","mapboxgl-user-location"),this._dotElement.appendChild(h.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(h.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new dd({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=h.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new dd({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",b=>{b.geolocateSource||"ACTIVE_LOCK"!==this._watchState||b.originalEvent&&"resize"===b.originalEvent.type||(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(a){this._userLocationDotMarker&&(a.webkitCompassHeading?this._heading=a.webkitCompassHeading:!0===a.absolute&&(this._heading=-1*a.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":dk--,dl=!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("OFF"===this._watchState&& void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let b;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++dk>1?(b={maximumAge:6e5,timeout:0},dl=!0):(b=this.options.positionOptions,dl=!1),this._geolocationWatchID=a.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,b),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(){const b=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};void 0!==a.window.DeviceMotionEvent&&"function"==typeof a.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(a=>{"granted"===a&&b()}).catch(console.error):b()}_clearWatch(){a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),a.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),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:c8,ScaleControl:class{constructor(b){this.options=a.extend({},{maxWidth:100,unit:"metric"},b),a.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){dm(this._map,this._container,this.options)}onAdd(a){return this._map=a,this._container=h.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",a.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(a){this.options.unit=a,dm(this._map,this._container,this.options)}},FullscreenControl:class{constructor(b){this._fullscreen=!1,b&&b.container&&(b.container instanceof a.window.HTMLElement?this._container=b.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(b){return this._map=b,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("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(){const b=this._fullscreenButton=h.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);h.create("span","mapboxgl-ctrl-icon",b).setAttribute("aria-hidden",!0),b.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const a=this._getTitle();this._fullscreenButton.setAttribute("aria-label",a),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",a)}_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(b){super(),this.options=a.extend(Object.create({closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"}),b),a.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag",],this),this._classList=new Set(b&&b.className?b.className.trim().split(/\s+/):[])}addTo(b){return this._map&&this.remove(),this._map=b,this.options.closeOnClick&&this._map.on("preclick",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new a.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(b){return this.setDOMContent(a.window.document.createTextNode(b))}setHTML(b){const c=a.window.document.createDocumentFragment(),d=a.window.document.createElement("body");let f;for(d.innerHTML=b;f=d.firstChild;)c.appendChild(f);return this.setDOMContent(c)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(a){return this.options.maxWidth=a,this._update(),this}setDOMContent(a){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(a),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(a){return this._classList.add(a),this._container&&this._updateClassList(),this}removeClassName(a){return this._classList.delete(a),this._container&&this._updateClassList(),this}setOffset(a){return this.options.offset=a,this._update(),this}toggleClassName(a){let b;return this._classList.delete(a)?b=!1:(this._classList.add(a),b=!0),this._container&&this._updateClassList(),b}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(a){this._update(a.point)}_onMouseMove(a){this._update(a.point)}_onDrag(a){this._update(a.point)}_getAnchor(a){if(this.options.anchor)return this.options.anchor;const b=this._pos,c=this._container.offsetWidth,d=this._container.offsetHeight;let f;return f=b.y+a.bottom.y<d?["top"]:b.y>this._map.transform.height-d?["bottom"]:[],b.x<c/2?f.push("left"):b.x>this._map.transform.width-c/2&&f.push("right"),0===f.length?"bottom":f.join("-")}_updateClassList(){const a=[...this._classList];a.push("mapboxgl-popup"),this._anchor&&a.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&a.push("mapboxgl-popup-track-pointer"),this._container.className=a.join(" ")}_update(b){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=h.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=h.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=db(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||b){const c=this._pos=this._trackPointer&&b?b:this._map.project(this._lngLat),d=function(b){if(b||(b=new a.pointGeometry(0,0)),"number"==typeof b){const c=Math.round(Math.sqrt(.5*Math.pow(b,2)));return{center:new a.pointGeometry(0,0),top:new a.pointGeometry(0,b),"top-left":new a.pointGeometry(c,c),"top-right":new a.pointGeometry(-c,c),bottom:new a.pointGeometry(0,-b),"bottom-left":new a.pointGeometry(c,-c),"bottom-right":new a.pointGeometry(-c,-c),left:new a.pointGeometry(b,0),right:new a.pointGeometry(-b,0)}}if(b instanceof a.pointGeometry||Array.isArray(b)){const d=a.pointGeometry.convert(b);return{center:d,top:d,"top-left":d,"top-right":d,bottom:d,"bottom-left":d,"bottom-right":d,left:d,right:d}}return{center:a.pointGeometry.convert(b.center||[0,0,]),top:a.pointGeometry.convert(b.top||[0,0]),"top-left":a.pointGeometry.convert(b["top-left"]||[0,0]),"top-right":a.pointGeometry.convert(b["top-right"]||[0,0]),bottom:a.pointGeometry.convert(b.bottom||[0,0,]),"bottom-left":a.pointGeometry.convert(b["bottom-left"]||[0,0]),"bottom-right":a.pointGeometry.convert(b["bottom-right"]||[0,0]),left:a.pointGeometry.convert(b.left||[0,0]),right:a.pointGeometry.convert(b.right||[0,0,])}}(this.options.offset),f=this._anchor=this._getAnchor(d),g=c.add(d[f]).round();this._map._requestDomTask(()=>{this._container&&f&&(this._container.style.transform=`${dc[f]} translate(${g.x}px,${g.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const a=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");a&&a.focus()}_onClose(){this.remove()}_setOpacity(a){this._content&&(this._content.style.opacity=a),this._tip&&(this._tip.style.opacity=a)}},Marker:dd,Style:aY,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.pointGeometry,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:ch,Evented:a.Evented,config:a.config,prewarm:function(){ab().acquire($)},clearPrewarmedResources:function(){const a=aa;a&&(a.isPreloaded()&&1===a.numActive()?(a.release($),aa=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(t){a.config.ACCESS_TOKEN=t},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(t){a.config.API_URL=t},get workerCount(){return _.workerCount},set workerCount(e){_.workerCount=e},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){a.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(b){a.clearTileCache(b)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return dp}),c})}},])