/* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory());
})(this, (function () { 'use strict';

let shared,worker,mapboxgl;function define(o,e){if(!shared)shared=e;else if(!worker)worker=e;else{const r={};shared(r),mapboxgl=e(r);const n="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 = {}; ("+shared+")(sharedChunk); ("+worker+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(mapboxgl.workerUrl=window.URL.createObjectURL(new Blob([n],{type:"text/javascript"})))}}


define(["exports"],function(e){var t=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function n(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=r*s-i*n;return a?(e[0]=s*(a=1/a),e[1]=-n*a,e[2]=-i*a,e[3]=r*a,e):null}function i(){var e=new r(9);return r!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function s(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-o*u,e[1]=i*u-n*c,e[2]=n*o-i*a,e[3]=o*l-s*c,e[4]=r*c-i*l,e[5]=i*s-r*o,e[6]=s*u-a*l,e[7]=n*l-r*u,e[8]=r*a-n*s,e}function a(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=r[0],p=r[1],f=r[2],m=r[3],y=r[4],g=r[5],x=r[6],v=r[7],b=r[8];return e[0]=d*n+p*a+f*u,e[1]=d*i+p*o+f*c,e[2]=d*s+p*l+f*h,e[3]=m*n+y*a+g*u,e[4]=m*i+y*o+g*c,e[5]=m*s+y*l+g*h,e[6]=x*n+v*a+b*u,e[7]=x*i+v*o+b*c,e[8]=x*s+v*l+b*h,e}function o(){var e=new r(16);return r!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function l(e){var t=new r(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function u(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function c(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],y=t[14],g=t[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,A=i*u-s*l,I=c*m-h*f,M=c*y-d*f,S=c*g-p*f,B=h*y-d*m,P=h*g-p*m,T=d*g-p*y,z=x*T-v*P+b*B+w*S-_*M+A*I;return z?(e[0]=(o*T-l*P+u*B)*(z=1/z),e[1]=(i*P-n*T-s*B)*z,e[2]=(m*A-y*_+g*w)*z,e[3]=(d*_-h*A-p*w)*z,e[4]=(l*S-a*T-u*M)*z,e[5]=(r*T-i*S+s*M)*z,e[6]=(y*b-f*A-g*v)*z,e[7]=(c*A-d*b+p*v)*z,e[8]=(a*P-o*S+u*I)*z,e[9]=(n*S-r*P-s*I)*z,e[10]=(f*_-m*b+g*x)*z,e[11]=(h*b-c*_-p*x)*z,e[12]=(o*M-a*B-l*I)*z,e[13]=(r*B-n*M+i*I)*z,e[14]=(m*v-f*w-y*x)*z,e[15]=(c*w-h*v+d*x)*z,e):null}function h(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],y=t[13],g=t[14],x=t[15],v=r[0],b=r[1],w=r[2],_=r[3];return e[0]=v*n+b*o+w*h+_*m,e[1]=v*i+b*l+w*d+_*y,e[2]=v*s+b*u+w*p+_*g,e[3]=v*a+b*c+w*f+_*x,e[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*m,e[5]=v*i+b*l+w*d+_*y,e[6]=v*s+b*u+w*p+_*g,e[7]=v*a+b*c+w*f+_*x,e[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*m,e[9]=v*i+b*l+w*d+_*y,e[10]=v*s+b*u+w*p+_*g,e[11]=v*a+b*c+w*f+_*x,e[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*m,e[13]=v*i+b*l+w*d+_*y,e[14]=v*s+b*u+w*p+_*g,e[15]=v*a+b*c+w*f+_*x,e}function d(e,t,r){var n,i,s,a,o,l,u,c,h,d,p,f,m=r[0],y=r[1],g=r[2];return t===e?(e[12]=t[0]*m+t[4]*y+t[8]*g+t[12],e[13]=t[1]*m+t[5]*y+t[9]*g+t[13],e[14]=t[2]*m+t[6]*y+t[10]*g+t[14],e[15]=t[3]*m+t[7]*y+t[11]*g+t[15]):(i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=i,e[2]=s,e[3]=a,e[4]=o,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+o*y+h*g+t[12],e[13]=i*m+l*y+d*g+t[13],e[14]=s*m+u*y+p*g+t[14],e[15]=a*m+c*y+f*g+t[15]),e}function p(e,t,r){var n=r[0],i=r[1],s=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function f(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[4],a=t[5],o=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+u*n,e[5]=a*i+c*n,e[6]=o*i+h*n,e[7]=l*i+d*n,e[8]=u*i-s*n,e[9]=c*i-a*n,e[10]=h*i-o*n,e[11]=d*i-l*n,e}function m(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],a=t[1],o=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-u*n,e[1]=a*i-c*n,e[2]=o*i-h*n,e[3]=l*i-d*n,e[8]=s*n+u*i,e[9]=a*n+c*i,e[10]=o*n+h*i,e[11]=l*n+d*i,e}function y(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],a=t[1],o=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i+u*n,e[1]=a*i+c*n,e[2]=o*i+h*n,e[3]=l*i+d*n,e[4]=u*i-s*n,e[5]=c*i-a*n,e[6]=h*i-o*n,e[7]=d*i-l*n,e}function g(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function x(e,r,n){var i,s,a,o=n[0],l=n[1],u=n[2],c=Math.sqrt(o*o+l*l+u*u);return c<t?null:(o*=c=1/c,l*=c,u*=c,i=Math.sin(r),s=Math.cos(r),e[0]=o*o*(a=1-s)+s,e[1]=l*o*a+u*i,e[2]=u*o*a-l*i,e[3]=0,e[4]=o*l*a-u*i,e[5]=l*l*a+s,e[6]=u*l*a+o*i,e[7]=0,e[8]=o*u*a+l*i,e[9]=l*u*a-o*i,e[10]=u*u*a+s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function v(e,t){var r=t[0],n=t[1],i=t[2],s=t[4],a=t[5],o=t[6],l=t[8],u=t[9],c=t[10];return e[0]=Math.sqrt(r*r+n*n+i*i),e[1]=Math.sqrt(s*s+a*a+o*o),e[2]=Math.sqrt(l*l+u*u+c*c),e}function b(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=r+r,o=n+n,l=i+i,u=r*a,c=n*a,h=n*o,d=i*a,p=i*o,f=i*l,m=s*a,y=s*o,g=s*l;return e[0]=1-h-f,e[1]=c+g,e[2]=d-y,e[3]=0,e[4]=c-g,e[5]=1-u-f,e[6]=p+m,e[7]=0,e[8]=d+y,e[9]=p-m,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}var w=h;function _(){var e=new r(3);return r!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function A(e){var t=new r(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function I(e){var t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function M(e,t,n){var i=new r(3);return i[0]=e,i[1]=t,i[2]=n,i}function S(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function B(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function P(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function T(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function z(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function k(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function F(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function V(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function D(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function E(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function C(e){var t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function R(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function L(e,t){var r=t[0],n=t[1],i=t[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function O(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function U(e,t,r){var n=t[0],i=t[1],s=t[2],a=r[0],o=r[1],l=r[2];return e[0]=i*l-s*o,e[1]=s*a-n*l,e[2]=n*o-i*a,e}function N(e,t,r,n){var i=t[0],s=t[1],a=t[2];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=a+n*(r[2]-a),e}function j(e,t,r){var n=t[0],i=t[1],s=t[2],a=r[3]*n+r[7]*i+r[11]*s+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(a=a||1),e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/a,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/a,e}function G(e,t,r){var n=t[0],i=t[1],s=t[2];return e[0]=n*r[0]+i*r[3]+s*r[6],e[1]=n*r[1]+i*r[4]+s*r[7],e[2]=n*r[2]+i*r[5]+s*r[8],e}function $(e,t,r){var n=r[0],i=r[1],s=r[2],a=r[3],o=t[0],l=t[1],u=t[2],c=i*u-s*l,h=s*o-n*u,d=n*l-i*o;return e[0]=o+a*(c+=c)+i*(d+=d)-s*(h+=h),e[1]=l+a*h+s*c-n*d,e[2]=u+a*d+n*h-i*c,e}function q(e){return e[0]=0,e[1]=0,e[2]=0,e}function H(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var X=P,Z=T,W=I;function Y(){var e=new r(4);return r!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function J(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function K(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=r*r+n*n+i*i+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=r*a,e[1]=n*a,e[2]=i*a,e[3]=s*a,e}function Q(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function ee(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*a,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*a,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*a,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*a,e}function te(){var e=new r(4);return r!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function re(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ne(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+a*o,e[1]=i*l+s*o,e[2]=s*l-i*o,e[3]=a*l-n*o,e}function ie(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l-s*o,e[1]=i*l+a*o,e[2]=s*l+n*o,e[3]=a*l-i*o,e}_(),Y();var se,ae,oe,le=K,ue=(se=_(),ae=M(1,0,0),oe=M(0,1,0),function(e,t,r){var n=O(t,r);return n<-.999999?(U(se,ae,t),W(se)<1e-6&&U(se,oe,t),L(se,se),function(e,t,r){r*=.5;var n=Math.sin(r);e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r);}(e,se,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(U(se,t,r),e[0]=se[0],e[1]=se[1],e[2]=se[2],e[3]=1+n,le(e,e))});function ce(){var e=new r(2);return r!=Float32Array&&(e[0]=0,e[1]=0),e}function he(e,t){var n=new r(2);return n[0]=e,n[1]=t,n}function de(e,t,r){return e[0]=t,e[1]=r,e}function pe(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function fe(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function me(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function ye(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function ge(e,t){var r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e}function xe(e,t){return e[0]*t[0]+e[1]*t[1]}te(),te(),i();var ve,be,we=fe;function _e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}ce();var Ae=function(){if(be)return ve;function e(e,t,r,n){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=r,this.p2y=n;}return be=1,ve=e,e.prototype={sampleCurveX:function(e){return ((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return ((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return (3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,n=0;n<8;n++){var i=this.sampleCurveX(r)-e;if(Math.abs(i)<t)return r;var s=this.sampleCurveDerivativeX(r);if(Math.abs(s)<1e-6)break;r-=i/s;}var a=0,o=1;for(r=e,n=0;n<20&&(i=this.sampleCurveX(r),!(Math.abs(i-e)<t));n++)e>i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},ve}(),Ie=_e(Ae);function Me(e,t){this.x=e,this.y=t;}function Se(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return !1;for(let r=0;r<e.length;r++)if(!Se(e[r],t[r]))return !1;return !0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return !1;if(Object.keys(e).length!==Object.keys(t).length)return !1;for(const r in e)if(!Se(e[r],t[r]))return !1;return !0}return e===t}Me.prototype={clone(){return new Me(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),r=Math.sin(e),n=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=n,this},_rotateAround(e,t){const r=Math.cos(e),n=Math.sin(e),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-n*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Me},Me.convert=function(e){if(e instanceof Me)return e;if(Array.isArray(e))return new Me(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Me(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Be=Math.PI/180,Pe=180/Math.PI;function Te(e){return e*Be}function ze(e){return e*Pe}const ke=[[0,0],[1,0],[1,1],[0,1]];function Fe(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}function Ve(e,t,r,n){const i=new Ie(e,t,r,n);return function(e){return i.solve(e)}}const De=Ve(.25,.1,.25,1);function Ee(e,t,r){return Math.min(r,Math.max(t,e))}function Ce(e,t,r){return (r=Ee((r-e)/(t-e),0,1))*r*(3-2*r)}function Re(e,t,r){const n=r-t,i=((e-t)%n+n)%n+t;return i===t?r:i}function Le(e,t,r){if(!e.length)return r(null,[]);let n=e.length;const i=new Array(e.length);let s=null;e.forEach((e,a)=>{t(e,(e,t)=>{e&&(s=e),i[a]=t,0===--n&&r(s,i);});});}let Oe=1;function Ue(){return Oe++}function Ne(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log2(e)))}function je(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t));});}function Ge(e,t,r){const n={};for(const r in e)n[r]=t.call(this,e[r],r,e);return n}function $e(e,t,r){const n={};for(const r in e)t.call(this,e[r],r,e)&&(n[r]=e[r]);return n}function qe(e){return Array.isArray(e)?e.map(qe):"object"==typeof e&&e?Ge(e,qe):e}function He(e,t){for(let r=0;r<e.length;r++)if(t.indexOf(e[r])>=0)return !0;return !1}const Xe={};function Ze(e){Xe[e]||("undefined"!=typeof console&&console.warn(e),Xe[e]=!0);}function We(e,t,r){return (r.y-e.y)*(t.x-e.x)>(t.y-e.y)*(r.x-e.x)}function Ye(e){let t=0;for(let r,n,i=0,s=e.length,a=s-1;i<s;a=i++)r=e[i],n=e[a],t+=(n.x-r.x)*(r.y+n.y);return t}function Je([e,t,r]){const n=Te(t+90),i=Te(r);return {x:e*Math.cos(n)*Math.sin(i),y:e*Math.sin(n)*Math.sin(i),z:e*Math.cos(i),azimuthal:t,polar:r}}function Ke(e){return ("undefined"!=typeof self||void 0!==e)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==e?e:self)instanceof WorkerGlobalScope}function Qe(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,r,n,i)=>{const s=n||i;return t[r]=!s||s.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e;}return t}let et,tt=null;function rt(e,t){return [e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function nt(e,t,r,n){for(;t<r;){const i=t+r>>1;e[i]<n?t=i+1:r=i;}return t}function it(e,t,r,n){for(;t<r;){const i=t+r>>1;e[i]<=n?t=i+1:r=i;}return t}function st(e){return e>0?1/(1.001-e):1+e}function at(e){return e>0?1-1/(1.001-e):-e}function ot(e,t,r){return (e-t.min)*(r.max-r.min)/(t.max-t.min)+r.min}const lt={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return /^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!lt.API_URL)return null;try{const e=new URL(lt.API_URL);return "api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/mapbox-gl-pmtiles-provider-v0.0.1.js"})};function ut(){return new URL(lt.DRACO_URL,lt.API_URL).href}function ct(){if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(void 0===et){if("object"!=typeof WebAssembly)return !1;const e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);et=WebAssembly.validate(e);}return et}()?lt.MESHOPT_SIMD_URL:lt.MESHOPT_URL,lt.API_URL).href}function ht(){return new URL(lt.BUILDING_GEN_URL,lt.API_URL).href}function dt(e){return lt.API_URL_REGEX.test(e)}function pt(e){return lt.API_SPRITE_REGEX.test(e)}let ft,mt,yt,gt,xt,vt;function bt(){return null==ft&&(ft=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),ft}const wt={now:()=>void 0!==gt?gt:performance.now(),setNow(e){gt=e;},restoreNow(){gt=void 0;},frame(e){const t=requestAnimationFrame(e);return {cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:n}=e;xt||(xt=document.createElement("canvas"));const i=xt.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return (r>xt.width||n>xt.height)&&(xt.width=r,xt.height=n),i.clearRect(-t,-t,r+2*t,n+2*t),i.drawImage(e,0,0,r,n),i.getImageData(-t,-t,r+2*t,n+2*t)},resolveURL:e=>(mt||(mt=document.createElement("a")),mt.href=e,mt.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(null==yt&&(yt=window.matchMedia("(prefers-reduced-motion: reduce)")),yt.matches)},hasCanvasFingerprintNoise(){if(void 0!==vt)return vt;if(!bt())return vt=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;n<e.width;++n)t.fillStyle=`rgba(${r++},${r++},${r++}, 255)`,t.fillRect(n,0,1,1);const n=t.getImageData(0,0,e.width,e.height);r=0;for(let e=0;e<n.data.length;++e)if(e%4!=3&&r++!==n.data[e])return vt=!0,!0;return vt=!1,!1}};function _t(e,t){const r=e.indexOf("?");if(r<0)return `${e}?${new URLSearchParams(t).toString()}`;const n=new URLSearchParams(e.slice(r));for(const e in t)n.set(e,t[e]);return `${e.slice(0,r)}?${n.toString()}`}function At(e,t={persistentParams:[]}){const r=e.indexOf("?");if(r<0)return e;const n=new URLSearchParams,i=new URLSearchParams(e.slice(r));for(const e of t.persistentParams){const t=i.get(e);t&&n.set(e,t);}const s=n.toString();return `${e.slice(0,r)}${s.length>0?`?${s}`:""}`}const It="mapbox-tiles";let Mt=500,St=50;const Bt=["language","worldview","jobid"];let Pt;function Tt(){try{return caches}catch(e){}}function zt(){const e=Tt();e&&null==Pt&&(Pt=e.open(It));}let kt=1/0;const Ft={supported:!1,testSupport:function(e){!Et&&Dt&&(Ct?Lt(e):Vt=e);}};let Vt,Dt,Et=!1,Ct=!1;const Rt="undefined"!=typeof self?self:{};function Lt(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,Dt),e.isContextLost())return;Ft.supported=!0;}catch(e){}e.deleteTexture(t),Et=!0;}Rt.document&&(Dt=Rt.document.createElement("img"),Dt.onload=function(){Vt&&Lt(Vt),Vt=null,Ct=!0;},Dt.onerror=function(){Et=!0,Vt=null;},Dt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ot={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(Ot);class Ut extends Error{constructor(e,t,r){401===t&&dt(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=r;}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}function Nt(e){return "object"==typeof e&&null!==e&&"status"in e&&404===e.status}const jt=Ke()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href;const Gt=function(e,t){return /^file:/.test(r=e.url)||/^file:/.test(jt())&&!/^\w+:/.test(r)?function(e,t){const r=new XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return "json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{t(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===e.type)try{n=JSON.parse(r.response);}catch(e){return t(e)}const i=new Headers;r.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(e=>{const t=e.split(": "),r=t.shift(),n=t.join(": ");i.append(r,n);}),t(null,n,i);}else t(new Ut(r.statusText,r.status,e.url));},r.send(e.body),{cancel:()=>r.abort()}}(e,t):function(e,t){const r=new AbortController,n=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:jt(),referrerPolicy:e.referrerPolicy,signal:r.signal});let i=!1,s=!1;const a=(o=n.url).indexOf("sku=")>0&&dt(o);var o;"json"===e.type&&n.headers.set("Accept","application/json");const l=(r,i,o)=>{if(s)return;if(r&&"SecurityError"!==r.message&&Ze(r.toString()),i&&o)return u(i);const l=Date.now();fetch(n).then(r=>{if(r.ok){const e=a?r.clone():null;return u(r,e,l)}return t(new Ut(r.statusText,r.status,e.url))}).catch(r=>{"AbortError"!==r.name&&t(new Error(`${r.message} ${e.url}`));});},u=(r,a,o)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then(e=>{s||(a&&o&&function(e,t,r){if(zt(),null==Pt)return;const n=Qe(t.headers.get("cache-control")||"");if(n["no-store"])return;const i={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach((e,t)=>i.headers.set(t,e)),n["max-age"]&&i.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());const s=i.headers.get("expires");if(!s)return;if(new Date(s).getTime()-r<42e4)return;let a=At(e.url,{persistentParams:Bt});if(206===t.status){const t=e.headers.get("Range");if(!t)return;i.status=200,a=_t(a,{range:t});}const o=new Response(200!==(l=t.status)&&404!==l&&[101,103,204,205,304].includes(l)?null:t.body,i);var l;zt(),null!=Pt&&Pt.then(e=>e.put(a,o)).catch(e=>Ze(e.message));}(n,a,o),i=!0,t(null,e,r.headers));}).catch(e=>{s||t(new Error(e.message));});};return a?function(e,t){if(zt(),null==Pt)return t(null);Pt.then(r=>{let n=At(e.url,{persistentParams:Bt});const i=e.headers.get("Range");i&&(n=_t(n,{range:i})),r.match(n).then(e=>{const i=function(e){if(!e)return !1;const t=new Date(e.headers.get("expires")||0),r=Qe(e.headers.get("cache-control")||"");return Number(t)>Date.now()&&!r["no-cache"]}(e);r.delete(n).catch(t),i&&r.put(n,e.clone()).catch(t),t(null,e,i);}).catch(t);}).catch(t);}(n,l):l(null,null),{cancel:()=>{s=!0,i||r.abort();}}}(e,t);var r;},$t=function(e,t){return Gt(Object.assign(e,{type:"arrayBuffer"}),t)};function qt(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}let Ht,Xt;Ht=[],Xt=0;const Zt=function(e,t){if(Ft.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Xt>=lt.MAX_PARALLEL_IMAGE_REQUESTS){const r={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0;}};return Ht.push(r),r}Xt++;let r=!1;const n=()=>{if(!r)for(r=!0,Xt--;Ht.length&&Xt<lt.MAX_PARALLEL_IMAGE_REQUESTS;){const e=Ht.shift(),{requestParameters:t,callback:r,cancelled:n}=e;n||(e.cancel=Zt(t,r).cancel);}},i=$t(e,(e,r,i)=>{n(),e?t(e):r&&function(e,t){const r=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(r).then(e=>{t(null,e);}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));});}(r,(e,r)=>t(e,r,i));});return {cancel:()=>{i.cancel(),n();}}};var Wt,Yt,Jt,Kt={exports:{}},Qt={exports:{}},er={exports:{}},tr=function(){if(Jt)return Kt.exports;Jt=1;var e=(Wt||(Wt=1,Qt.exports=function(e,t){var r,n,i,s,a,o,l,u;for(n=e.length-(r=3&e.length),i=t,a=3432918353,o=461845907,u=0;u<n;)l=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24,++u,i=27492+(65535&(s=5*(65535&(i=(i^=l=(65535&(l=(l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+(((s>>>16)+58964&65535)<<16);switch(l=0,r){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Qt.exports),t=(Yt||(Yt=1,er.exports=function(e,t){for(var r,n=e.length,i=t^n,s=0;n>=4;)r=1540483477*(65535&(r=255&e.charCodeAt(s)|(255&e.charCodeAt(++s))<<8|(255&e.charCodeAt(++s))<<16|(255&e.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&e.charCodeAt(s+2))<<16;case 2:i^=(255&e.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),er.exports);return Kt.exports=e,Kt.exports.murmur3=e,Kt.exports.murmur2=t,Kt.exports}(),rr=_e(tr);class nr{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e;}}class ir extends nr{constructor(e,t={}){super("error",Object.assign({error:e},t));}}function sr(e,t,r){r[e]&&-1!==r[e].indexOf(t)||(r[e]=r[e]||[],r[e].push(t));}function ar(e,t,r){if(r&&r[e]){const n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1);}}class or{on(e,t){return this._listeners=this._listeners||{},sr(e,t,this._listeners),this}off(e,t){return ar(e,t,this._listeners),ar(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},sr(e,t,this._oneTimeListeners),this):new Promise(t=>{this.once(e,t);})}fire(e,t){const r="string"==typeof e?new nr(e,t):e,n=r.type;if(this.listens(n)){r.target=this;const e=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const t of e)t.call(this,r);const t=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const e of t)ar(n,e,this._oneTimeListeners),e.call(this,r);const i=this._eventedParent;if(i){const e="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(r,e),i.fire(r);}}else r instanceof ir&&console.error(r.error);return this}listens(e){return !!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}class lr{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId);}static from(e){return new lr(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,r]=e.split("");return new lr({name:t,iconsetId:r})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return lr.toString(this)}serialize(){return {name:this.name,iconsetId:this.iconsetId}}}var ur,cr={},hr=function(){if(ur)return cr;ur=1;var e={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 t(e){return (e=Math.round(e))<0?0:e>255?255:e}function r(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function n(e){return (t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t;}function i(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}try{cr.parseCSSColor=function(s){var a,o=s.replace(/ /g,"").toLowerCase();if(o in e)return e[o].slice();if("#"===o[0])return 4===o.length?(a=parseInt(o.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===o.length&&(a=parseInt(o.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var l=o.indexOf("("),u=o.indexOf(")");if(-1!==l&&u+1===o.length){var c=o.substr(0,l),h=o.substr(l+1,u-(l+1)).split(","),d=1;switch(c){case "rgba":if(4!==h.length)return null;d=n(h.pop());case "rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),d];case "hsla":if(4!==h.length)return null;d=n(h.pop());case "hsl":if(3!==h.length)return null;var p=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),y=m<=.5?m*(f+1):m+f-m*f,g=2*m-y;return [t(255*i(g,y,p+1/3)),t(255*i(g,y,p)),t(255*i(g,y,p-1/3)),d];default:return null}}return null};}catch(e){}return cr}();class dr{constructor(e,t,r,n=1){this.r=e,this.g=t,this.b=r,this.a=n;}static parse(e){if(!e)return;if(e instanceof dr)return e;if("string"!=typeof e)return;const t=hr.parseCSSColor(e);return t?new dr(t[0]/255,t[1]/255,t[2]/255,t[3]):void 0}toString(){const[e,t,r,n]=[this.r,this.g,this.b,this.a];return `rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*r)},${n})`}toNonPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new fr(e,t,r,n,i)}toPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new mr(e,t*i,r*i,n*i,i)}clone(){return new dr(this.r,this.g,this.b,this.a)}}class pr{constructor(e,t,r,n,i,s=!1){if(this.premultiplied=!1,this.premultiplied=s,e){const s=e.image.height,a=s*s;this.premultiplied?(t=0===i?0:t/i*(s-1),r=0===i?0:r/i*(s-1),n=0===i?0:n/i*(s-1)):(t*=s-1,r*=s-1,n*=s-1),t=Math.max(0,Math.min(s-1,t)),r=Math.max(0,Math.min(s-1,r)),n=Math.max(0,Math.min(s-1,n));const o=Math.floor(t),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(t),h=Math.ceil(r),d=Math.ceil(n),p=t-o,f=r-l,m=n-u,y=e.image.data,g=4*(o+l*a+u*s),x=4*(o+l*a+d*s),v=4*(o+h*a+u*s),b=4*(o+h*a+d*s),w=4*(c+l*a+u*s),_=4*(c+l*a+d*s),A=4*(c+h*a+u*s),I=4*(c+h*a+d*s);this.r=yr(yr(yr(y[g],y[x],m),yr(y[v],y[b],m),f),yr(yr(y[w],y[_],m),yr(y[A],y[I],m),f),p)/255*(this.premultiplied?i:1),this.g=yr(yr(yr(y[g+1],y[x+1],m),yr(y[v+1],y[b+1],m),f),yr(yr(y[w+1],y[_+1],m),yr(y[A+1],y[I+1],m),f),p)/255*(this.premultiplied?i:1),this.b=yr(yr(yr(y[g+2],y[x+2],m),yr(y[v+2],y[b+2],m),f),yr(yr(y[w+2],y[_+2],m),yr(y[A+2],y[I+2],m),f),p)/255*(this.premultiplied?i:1),this.a=i;}else this.r=t,this.g=r,this.b=n,this.a=i;}toArray(){const{r:e,g:t,b:r,a:n}=this;return [255*e,255*t,255*r,n]}toHslaArray(){let{r:e,g:t,b:r,a:n}=this;if(this.premultiplied){if(0===n)return [0,0,0,0];const i=1/n;e*=i,t*=i,r*=i;}const i=Math.min(Math.max(e,0),1),s=Math.min(Math.max(t,0),1),a=Math.min(Math.max(r,0),1),o=Math.min(i,s,a),l=Math.max(i,s,a),u=l-o,c=.5*(o+l);if(0===u)return [0,0,100*c,n];const h=c>.5?u/(2-l-o):u/(l+o);let d;switch(l){case i:d=60*((s-a)/u+(s<a?6:0));break;case s:d=60*((a-i)/u+2);break;default:d=60*((i-s)/u+4);}return [d,100*h,100*c,n]}toArray01(){const{r:e,g:t,b:r,a:n}=this;return [e,t,r,n]}toArray01Scaled(e){const{r:t,g:r,b:n}=this;return [t*e,r*e,n*e]}toArray01Linear(){const{r:e,g:t,b:r,a:n}=this;return [Math.pow(e,2.2),Math.pow(t,2.2),Math.pow(r,2.2),n]}}class fr extends pr{constructor(e,t,r,n,i){super(e,t,r,n,i,!1);}}class mr extends pr{constructor(e,t,r,n,i){super(e,t,r,n,i,!0);}}function yr(e,t,r){return e*(1-r)+t*r}function gr(e,t,r){return e.map((e,n)=>yr(e,t[n],r))}dr.black=new dr(0,0,0,1),dr.white=new dr(1,1,1,1),dr.transparent=new dr(0,0,0,0),dr.red=new dr(1,0,0,1),dr.blue=new dr(0,0,1,1);var xr=Object.freeze({__proto__:null,array:gr,color:function(e,t,r){return new dr(yr(e.r,t.r,r),yr(e.g,t.g,r),yr(e.b,t.b,r),yr(e.a,t.a,r))},number:yr});class vr extends Error{constructor(e,t){super(t),this.message=t,this.key=e;}}class br{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,r]of t)this.bindings[e]=r;}concat(e){return new br(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return !!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const wr={kind:"null"},_r={kind:"number"},Ar={kind:"string"},Ir={kind:"boolean"},Mr={kind:"color"},Sr={kind:"object"},Br={kind:"value"},Pr={kind:"collator"},Tr={kind:"formatted"},zr={kind:"resolvedImage"};function kr(e,t){return {kind:"array",itemType:e,N:t}}function Fr(e){if("array"===e.kind){const t=Fr(e.itemType);return "number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Vr=[wr,_r,Ar,Ir,Mr,Tr,Sr,kr(Br),zr];function Dr(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Dr(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else {if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Vr)if(!Dr(e,t))return null}return `Expected ${Fr(e)} but found ${Fr(t)} instead.`}function Er(e,t){return t.some(t=>t.kind===e.kind)}function Cr(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function Rr(e,t){return "array"===e.kind&&"array"===t.kind?e.N===t.N&&Rr(e.itemType,t.itemType):e.kind===t.kind}class Lr{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Or{constructor(e,t,r,n,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=r,this.fontStack=n,this.textColor=i;}}class Ur{constructor(e){this.sections=e;}static fromString(e){return new Ur([new Or(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof Ur?e:Ur.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const r=t.image.getPrimary().id.toString();e.push(["image",r]);continue}e.push(t.text);const r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(r);}return e}}class Nr{constructor(e,t={}){this.id=lr.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1;}toString(){return JSON.stringify(this)}static parse(e){let t,r,n,i;try{({id:t,params:r,sx:n,sy:i}=JSON.parse(e)||{});}catch(e){return null}return t?new Nr(t,{params:r,sx:n,sy:i}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class jr{constructor(e,t,r,n,i=!1){this.primaryId=lr.from(e),this.primaryOptions=t,r&&(this.secondaryId=lr.from(r)),this.secondaryOptions=n,this.available=i;}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return !!this.primaryId}getPrimary(){return new Nr(this.primaryId,this.primaryOptions)}hasSecondary(){return !!this.secondaryId}getSecondary(){return this.secondaryId?new Nr(this.secondaryId,this.secondaryOptions):null}static from(e){return "string"==typeof e?jr.build({name:e}):e}static build(e,t,r,n){return !e||"object"==typeof e&&!("name"in e)?null:new jr(e,r,t,n)}}function Gr(e,t,r,n){return "number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function $r(e){if(null===e)return !0;if("string"==typeof e)return !0;if("boolean"==typeof e)return !0;if("number"==typeof e)return !0;if(e instanceof dr)return !0;if(e instanceof Lr)return !0;if(e instanceof Ur)return !0;if(e instanceof jr)return !0;if(Array.isArray(e)){for(const t of e)if(!$r(t))return !1;return !0}if("object"==typeof e){for(const t in e)if(!$r(e[t]))return !1;return !0}return !1}function qr(e){if(null===e)return wr;if("string"==typeof e)return Ar;if("boolean"==typeof e)return Ir;if("number"==typeof e)return _r;if(e instanceof dr)return Mr;if(e instanceof Lr)return Pr;if(e instanceof Ur)return Tr;if(e instanceof jr)return zr;if(Array.isArray(e)){const t=e.length;let r;for(const t of e){const e=qr(t);if(r){if(r===e)continue;r=Br;break}r=e;}return kr(r||Br,t)}return Sr}function Hr(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ur||e instanceof jr||e instanceof dr?e.toString():JSON.stringify(e)}class Xr{constructor(e,t){this.type=e,this.value=t;}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!$r(e[1]))return t.error("invalid value");const r=e[1];let n=qr(r);const i=t.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Xr(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof dr?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Ur?this.value.serialize():this.value}}class Zr{constructor(e){this.name="ExpressionEvaluationError",this.message=e;}toJSON(){return this.message}}const Wr={string:Ar,number:_r,boolean:Ir,object:Sr};class Yr{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,n=1;const i=e[0];if("array"===i){let i,s;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in Wr)||"object"===r)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=Wr[r],n++;}else i=Br;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);s=e[2],n++;}r=kr(i,s);}else r=Wr[i];const s=[];for(;n<e.length;n++){const r=t.parse(e[n],n,Br);if(!r)return null;s.push(r);}return new Yr(r,s)}evaluate(e){for(let t=0;t<this.args.length;t++){const r=this.args[t].evaluate(e);if(!Dr(this.type,qr(r)))return r;if(t===this.args.length-1)throw new Zr(`The expression ${JSON.stringify(this.args[t].serialize())} evaluated to ${Fr(qr(r))} but was expected to be of type ${Fr(this.type)}.`)}return null}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const r=e.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){t.push(r.kind);const n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n);}}return t.concat(this.args.map(e=>e.serialize()))}}class Jr{constructor(e){this.type=Tr,this.sections=e;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return t.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=e.length-1;++r){const s=e[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let e=null;if(s["font-scale"]&&(e=t.parseObjectValue(s["font-scale"],r,"font-scale",_r),!e))return null;let a=null;if(s["text-font"]&&(a=t.parseObjectValue(s["text-font"],r,"text-font",kr(Ar)),!a))return null;let o=null;if(s["text-color"]&&(o=t.parseObjectValue(s["text-color"],r,"text-color",Mr),!o))return null;const l=n[n.length-1];l.scale=e,l.font=a,l.textColor=o;}else {const s=t.parse(e[r],r,Br);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new Jr(n)}evaluate(e){return new Ur(this.sections.map(t=>{const r=t.content.evaluate(e);return Rr(qr(r),zr)?new Or("",r,null,null,null):new Or(Hr(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor);}outputDefined(){return !1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const r={};t.scale&&(r["font-scale"]=t.scale.serialize()),t.font&&(r["text-font"]=t.font.serialize()),t.textColor&&(r["text-color"]=t.textColor.serialize()),e.push(r);}return e}}class Kr{constructor(e,t,r,n){this._imageWarnHistory={},this.type=zr,this.namePrimary=e,this.nameSecondary=t,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),n&&(this.paramsSecondary=n.params,this.iconsetIdSecondary=n.iconset?n.iconset.id:void 0);}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let r=1;const n=[];function i(){if(r<e.length){const i=t.parse(e[r],r++,Ar);return i?(n.push({image:i,options:{}}),!0):(t.error(n.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return !0}function s(){if(r<e.length){const s=e[r];if(null===(i=s)||"object"!=typeof i||Array.isArray(i))return !0;const a=s.params,o=s.iconset,l=t.concat(r);if(!a&&!o)return r++,!0;if(a){if("object"!=typeof a||a.constructor!==Object)return l.error('Image options "params" should be an object'),!1;const e={},t=l.concat(void 0,"params");for(const r in a){if(!r)return t.error("Image parameter name should be non-empty"),!1;const n=t.concat(void 0,r).parse(a[r],void 0,Mr,void 0,{typeAnnotation:"coerce"});if(!n)return !1;e[r]=n;}n[n.length-1].options.params=e;}if(o){if("object"!=typeof o||o.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!o.id)return l.error('Image options "iconset" should have an "id" property'),!1;n[n.length-1].options.iconset=o;}return r++,!0}var i;return !0}for(let e=0;e<2;e++)if(!i()||!s())return;return new Kr(n[0].image,n[1]?n[1].image:void 0,n[0].options,n[1]?n[1].options:void 0)}evaluateParams(e,t){const r={};if(t){for(const n in t)if(t[n])try{r[n]=t[n].evaluate(e);}catch(e){continue}if(0!==Object.keys(r).length)return {params:r}}}evaluate(e){const t={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},r=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,n=jr.build(t,r,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(n&&e.availableImages){const t=n.getPrimary().id;if(n.available=e.availableImages.some(e=>lr.isEqual(e,t)),n.available){const t=n.getSecondary()?n.getSecondary().id:null;t&&(n.available=e.availableImages.some(e=>lr.isEqual(e,t)));}}return n}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t]);}outputDefined(){return !1}serializeOptions(e,t){const r={};if(t&&(r.iconset={id:t}),e){r.params={};for(const t in e)e[t]&&(r.params[t]=e[t].serialize());}return Object.keys(r).length>0?r:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t);}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t);}return e}}function Qr(e){return tn(e)?"string":rn(e)?"number":nn(e)?"boolean":Array.isArray(e)?"array":null===e?"null":en(e)?"object":typeof e}function en(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function tn(e){return "string"==typeof e||e instanceof String}function rn(e){return "number"==typeof e||e instanceof Number}function nn(e){return "boolean"==typeof e||e instanceof Boolean}const sn={"to-boolean":Ir,"to-color":Mr,"to-number":_r,"to-string":Ar};class an{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0],n=[];let i=wr;if("to-array"===r){if(!Array.isArray(e[1]))return null;const r=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);i=kr(t.expectedType.itemType,r);}else {if(!(r>0&&$r(e[1][0])))return null;i=kr(qr(e[1][0]),r);}for(let s=0;s<r;s++){const r=e[1][s];let a;if(Array.isArray(r))a=t.parse(r,void 0,i.itemType);else {const e=Qr(r);if(e!==i.itemType.kind)return t.error(`Expected ${i.itemType.kind} but found ${e}.`);a=t.registry.literal.parse(["literal",void 0===r?null:r],t);}if(!a)return null;n.push(a);}}else {if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return t.error("Expected one argument.");i=sn[r];for(let r=1;r<e.length;r++){const i=t.parse(e[r],r,Br);if(!i)return null;n.push(i);}}return new an(i,n)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,r;for(const n of this.args){if(t=n.evaluate(e),r=null,t instanceof dr)return t;if("string"==typeof t){const r=e.parseColor(t);if(r)return r}else if(Array.isArray(t)&&(r=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Gr(t[0],t[1],t[2],t[3]),!r))return new dr(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Zr(r||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const r of this.args){if(t=r.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Zr(`Could not convert ${JSON.stringify(t)} to number.`)}return "formatted"===this.type.kind?Ur.fromString(Hr(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?jr.build(Hr(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):Hr(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Jr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Kr(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize());}),e}}const on=["Unknown","Point","LineString","Polygon"];class ln{constructor(e,t,r){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,this.scope=e,this.options=t,this.iconImageUseTheme=r;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?on[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||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=dr.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class un{constructor(e,t,r,n,i){this.name=e,this.type=t,this._evaluate=r,this.args=n,this._overloadIndex=i;}evaluate(e){if(!this._evaluate){const e=un.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1];}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const r=e[0],n=un.definitions[r];if(!n)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=[];let o=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==e.length-1)continue;a.push(n),l++,o=new Pi(t.registry,t.path,null,t.scope,void 0,t._scope,t.options,t.iconImageUseTheme);const s=[];let c=!1;for(let t=1;t<e.length;t++){const r=e[t],i=Array.isArray(n)?n[t-1]:n.type,a=o.parse(r,1+s.length,i);if(!a){c=!0;break}s.push(a);}if(!c)if(Array.isArray(n)&&n.length!==s.length)o.error(`Expected ${n.length} arguments, but found ${s.length} instead.`);else {for(let e=0;e<s.length;e++){const t=Array.isArray(n)?n[e]:n.type,r=s[e];o.concat(e+1).checkSubtype(t,r.type);}if(0===o.errors.length)return new un(r,i,u,s,l)}}if(1===a.length)t.errors.push(...o.errors);else {const r=(a.length?a:s.map(([e])=>e)).map(cn).join(" | "),n=[];for(let r=1;r<e.length;r++){const i=t.parse(e[r],1+n.length);if(!i)return null;n.push(Fr(i.type));}t.error(`Expected arguments of type ${r}, but found (${n.join(", ")}) instead.`);}return null}static register(e,t){un.definitions=t;for(const r in t)e[r]=un;}}function cn(e){return Array.isArray(e)?`(${e.map(Fr).join(", ")})`:`(${Fr(e.type)}...)`}class hn{constructor(e,t,r){this.type=Pr,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=t;}static parse(e,t){if(2!==e.length)return t.error("Expected one argument."),null;const r=e[1];if("object"!=typeof r||Array.isArray(r))return t.error("Collator options argument must be an object."),null;const n=void 0===r["case-sensitive"]?t.parse(!1,1,Ir):t.parseObjectValue(r["case-sensitive"],1,"case-sensitive",Ir);if(!n)return null;const i=void 0===r["diacritic-sensitive"]?t.parse(!1,1,Ir):t.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",Ir);if(!i)return null;let s=null;return r.locale&&(s=t.parseObjectValue(r.locale,1,"locale",Ar),!s)?null:new hn(n,i,s)}evaluate(e){return new Lr(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale);}outputDefined(){return !1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function dn(e,t,r=0,n=e.length-1,i=fn){for(;n>r;){if(n-r>600){const s=n-r+1,a=t-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);dn(e,t,Math.max(r,Math.floor(t-a*l/s+u)),Math.min(n,Math.floor(t+(s-a)*l/s+u)),i);}const s=e[t];let a=r,o=n;for(pn(e,r,t),i(e[n],s)>0&&pn(e,r,n);a<o;){for(pn(e,a,o),a++,o--;i(e[a],s)<0;)a++;for(;i(e[o],s)>0;)o--;}0===i(e[r],s)?pn(e,r,o):(o++,pn(e,o,n)),o<=t&&(r=o+1),t<=o&&(n=o-1);}}function pn(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function fn(e,t){return e<t?-1:e>t?1:0}function mn(e){let t=0;for(let r,n,i=0,s=e.length,a=s-1;i<s;a=i++)r=e[i],n=e[a],t+=(n.x-r.x)*(r.y+n.y);return t}function yn(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1]);}function gn(e,t){return !(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function xn(e,t,r){const n=e[0]-t[0],i=e[1]-t[1],s=e[0]-r[0],a=e[1]-r[1];return n*a-s*i===0&&n*s<=0&&i*a<=0}function vn(e,t,r){return t[1]>e[1]!=r[1]>e[1]&&e[0]<(r[0]-t[0])*(e[1]-t[1])/(r[1]-t[1])+t[0]}function bn(e,t,r=!1){let n=!1;for(let i=0,s=t.length;i<s;i++){const s=t[i];for(let t=0,i=s.length,a=i-1;t<i;a=t++){const i=s[a],o=s[t];if(xn(e,i,o))return r;vn(e,i,o)&&(n=!n);}}return n}function wn(e,t,r,n){const i=n[0]-r[0],s=n[1]-r[1],a=(e[0]-r[0])*s-i*(e[1]-r[1]),o=(t[0]-r[0])*s-i*(t[1]-r[1]);return a>0&&o<0||a<0&&o>0}function _n(e,t,r,n){return 0!==(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*s[0]&&!(!wn(e,t,r,n)||!wn(r,n,e,t));var i,s;}function An(e){const t=new Me(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new Me(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of e[0])t.x>n.x&&(t.x=n.x),t.y>n.y&&(t.y=n.y),r.x<n.x&&(r.x=n.x),r.y<n.y&&(r.y=n.y);return {min:t,max:r}}const In=8192;function Mn(e,t){const r=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return [Math.round(r*i*In),Math.round(n*i*In)]}function Sn(e,t){for(let r=0;r<t.length;r++)if(bn(e,t[r]))return !0;return !1}function Bn(e,t,r){for(const n of r)for(let r=0,i=n.length,s=i-1;r<i;s=r++)if(_n(e,t,n[s],n[r]))return !0;return !1}function Pn(e,t){for(let r=0;r<e.length;++r)if(!bn(e[r],t))return !1;for(let r=0;r<e.length-1;++r)if(Bn(e[r],e[r+1],t))return !1;return !0}function Tn(e,t){for(let r=0;r<t.length;r++)if(Pn(e,t[r]))return !0;return !1}function zn(e,t,r){const n=[];for(let i=0;i<e.length;i++){const s=[];for(let n=0;n<e[i].length;n++){const a=Mn(e[i][n],r);yn(t,a),s.push(a);}n.push(s);}return n}function kn(e,t,r){const n=[];for(let i=0;i<e.length;i++){const s=zn(e[i],t,r);n.push(s);}return n}function Fn(e,t,r,n){if(e[0]<r[0]||e[0]>r[2]){const t=.5*n;let i=e[0]-r[0]>t?-n:r[0]-e[0]>t?n:0;0===i&&(i=e[0]-r[2]>t?-n:r[2]-e[0]>t?n:0),e[0]+=i;}yn(t,e);}function Vn(e,t,r,n){const i=Math.pow(2,n.z)*In,s=[n.x*In,n.y*In],a=[];if(!e)return a;for(const n of e)for(const e of n){const n=[e.x+s[0],e.y+s[1]];Fn(n,t,r,i),a.push(n);}return a}function Dn(e,t,r,n){const i=Math.pow(2,n.z)*In,s=[n.x*In,n.y*In],a=[];if(!e)return a;for(const r of e){const e=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];yn(t,r),e.push(r);}a.push(e);}if(t[2]-t[0]<=i/2){(o=t)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const e of a)for(const n of e)Fn(n,t,r,i);}var o;return a}class En{constructor(e,t){this.type=Ir,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if($r(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const r=t.features[e].geometry.type;if("Polygon"===r||"MultiPolygon"===r)return new En(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new En(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new En(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(!i)return !1;if("Polygon"===t.type){const s=zn(t.coordinates,n,i),a=Vn(e.geometry(),r,n,i);if(!gn(r,n))return !1;for(const e of a)if(!bn(e,s))return !1}if("MultiPolygon"===t.type){const s=kn(t.coordinates,n,i),a=Vn(e.geometry(),r,n,i);if(!gn(r,n))return !1;for(const e of a)if(!Sn(e,s))return !1}return !0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(!i)return !1;if("Polygon"===t.type){const s=zn(t.coordinates,n,i),a=Dn(e.geometry(),r,n,i);if(!gn(r,n))return !1;for(const e of a)if(!Pn(e,s))return !1}if("MultiPolygon"===t.type){const s=kn(t.coordinates,n,i),a=Dn(e.geometry(),r,n,i);if(!gn(r,n))return !1;for(const e of a)if(!Tn(e,s))return !1}return !0}(e,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}serialize(){return ["within",this.geojson]}}const Cn={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},Rn=1/298.257223563,Ln=Rn*(2-Rn),On=Math.PI/180;class Un{static fromTile(e,t,r){const n=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),i=Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/On;return new Un(i,r)}static get units(){return Cn}constructor(e,t){if(void 0===e)throw new Error("No latitude given.");if(t&&!Cn[t])throw new Error(`Unknown unit ${t}. Use one of: ${Object.keys(Cn).join(", ")}`);const r=6378.137*On*(t?Cn[t]:1),n=Math.cos(e*On),i=1/(1-Ln*(1-n*n)),s=Math.sqrt(i);this.kx=r*s*n,this.ky=r*s*i*(1-Ln);}distance(e,t){const r=Gn(e[0]-t[0])*this.kx,n=(e[1]-t[1])*this.ky;return Math.sqrt(r*r+n*n)}bearing(e,t){const r=Gn(t[0]-e[0])*this.kx;return Math.atan2(r,(t[1]-e[1])*this.ky)/On}destination(e,t,r){const n=r*On;return this.offset(e,Math.sin(n)*t,Math.cos(n)*t)}offset(e,t,r){return [e[0]+t/this.kx,e[1]+r/this.ky]}lineDistance(e){let t=0;for(let r=0;r<e.length-1;r++)t+=this.distance(e[r],e[r+1]);return t}area(e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];for(let e=0,i=n.length,s=i-1;e<i;s=e++)t+=Gn(n[e][0]-n[s][0])*(n[e][1]+n[s][1])*(r?-1:1);}return Math.abs(t)/2*this.kx*this.ky}along(e,t){let r=0;if(t<=0)return e[0];for(let n=0;n<e.length-1;n++){const i=e[n],s=e[n+1],a=this.distance(i,s);if(r+=a,r>t)return jn(i,s,(t-(r-a))/a)}return e[e.length-1]}pointToSegmentDistance(e,t,r){let[n,i]=t,s=Gn(r[0]-n)*this.kx,a=(r[1]-i)*this.ky;if(0!==s||0!==a){const t=(Gn(e[0]-n)*this.kx*s+(e[1]-i)*this.ky*a)/(s*s+a*a);t>1?(n=r[0],i=r[1]):t>0&&(n+=s/this.kx*t,i+=a/this.ky*t);}return s=Gn(e[0]-n)*this.kx,a=(e[1]-i)*this.ky,Math.sqrt(s*s+a*a)}pointOnLine(e,t){let r=1/0,n=e[0][0],i=e[0][1],s=0,a=0;for(let o=0;o<e.length-1;o++){let l=e[o][0],u=e[o][1],c=Gn(e[o+1][0]-l)*this.kx,h=(e[o+1][1]-u)*this.ky,d=0;0===c&&0===h||(d=(Gn(t[0]-l)*this.kx*c+(t[1]-u)*this.ky*h)/(c*c+h*h),d>1?(l=e[o+1][0],u=e[o+1][1]):d>0&&(l+=c/this.kx*d,u+=h/this.ky*d)),c=Gn(t[0]-l)*this.kx,h=(t[1]-u)*this.ky;const p=c*c+h*h;p<r&&(r=p,n=l,i=u,s=o,a=d);}return {point:[n,i],index:s,t:Math.max(0,Math.min(1,a))}}lineSlice(e,t,r){let n=this.pointOnLine(r,e),i=this.pointOnLine(r,t);if(n.index>i.index||n.index===i.index&&n.t>i.t){const e=n;n=i,i=e;}const s=[n.point],a=n.index+1,o=i.index;!Nn(r[a],s[0])&&a<=o&&s.push(r[a]);for(let e=a+1;e<=o;e++)s.push(r[e]);return Nn(r[o],i.point)||s.push(i.point),s}lineSliceAlong(e,t,r){let n=0;const i=[];for(let s=0;s<r.length-1;s++){const a=r[s],o=r[s+1],l=this.distance(a,o);if(n+=l,n>e&&0===i.length&&i.push(jn(a,o,(e-(n-l))/l)),n>=t)return i.push(jn(a,o,(t-(n-l))/l)),i;n>e&&i.push(o);}return i}bufferPoint(e,t){const r=t/this.ky,n=t/this.kx;return [e[0]-n,e[1]-r,e[0]+n,e[1]+r]}bufferBBox(e,t){const r=t/this.ky,n=t/this.kx;return [e[0]-n,e[1]-r,e[2]+n,e[3]+r]}insideBBox(e,t){return Gn(e[0]-t[0])>=0&&Gn(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function Nn(e,t){return e[0]===t[0]&&e[1]===t[1]}function jn(e,t,r){const n=Gn(t[0]-e[0]);return [e[0]+n*r,e[1]+(t[1]-e[1])*r]}function Gn(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class $n{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e);}push(e){this.data.push(e),this._up(this.length++);}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return --this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const i=e-1>>1,s=t[i];if(r(n,s)>=0)break;t[e]=s,e=i;}t[e]=n;}_down(e){const{data:t,compare:r}=this,n=this.length>>1,i=t[e];for(;e<n;){let n=1+(e<<1);const s=n+1;if(s<this.length&&r(t[s],t[n])<0&&(n=s),r(t[n],i)>=0)break;t[e]=t[n],e=n;}t[e]=i;}}var qn=8192;function Hn(e,t){return t.dist-e.dist}function Xn(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return !1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return !1;return !0}function Zn(e){return e[1]-e[0]+1}function Wn(e,t){const r=e[1]>=e[0]&&e[1]<t;return r||console.warn("Distance Expression: Index is out of range"),r}function Yn(e,t){if(e[0]>e[1])return [null,null];const r=Zn(e);if(t){if(2===r)return [e,null];const t=Math.floor(r/2);return [[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===r)return [e,null];const t=Math.floor(r/2)-1;return [[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function Jn(e,t){const r=[1/0,1/0,-1/0,-1/0];if(!Wn(t,e.length))return r;for(let n=t[0];n<=t[1];++n)yn(r,e[n]);return r}function Kn(e){const t=[1/0,1/0,-1/0,-1/0];for(let r=0;r<e.length;++r)for(let n=0;n<e[r].length;++n)yn(t,e[r][n]);return t}function Qn(e,t,r){if(Xn(e)||Xn(t))return NaN;let n=0,i=0;return e[2]<t[0]&&(n=t[0]-e[2]),e[0]>t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]<t[1]&&(i=t[1]-e[3]),r.distance([0,0],[n,i])}function ei(e){return 360*e-180}function ti(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ri(e,t,r=8192){const n=Math.pow(2,t.z),i=(e.y/r+t.y)/n;return [ei((e.x/r+t.x)/n),ti(i)]}function ni(e,t){const r=[];for(let n=0;n<e.length;++n)r.push(ri(e[n],t));return r}function ii(e,t,r){const n=r.pointOnLine(t,e).point;return r.distance(e,n)}function si(e,t,r,n,i){const s=r.slice(n[0],n[1]+1);let a=1/0;for(let r=t[0];r<=t[1];++r)if(0===(a=Math.min(a,ii(e[r],s,i))))return 0;return a}function ai(e,t,r,n,i){const s=Math.min(i.pointToSegmentDistance(e,r,n),i.pointToSegmentDistance(t,r,n)),a=Math.min(i.pointToSegmentDistance(r,e,t),i.pointToSegmentDistance(n,e,t));return Math.min(s,a)}function oi(e,t,r,n,i){if(!Wn(t,e.length)||!Wn(n,r.length))return NaN;let s=1/0;for(let a=t[0];a<t[1];++a)for(let t=n[0];t<n[1];++t){if(_n(e[a],e[a+1],r[t],r[t+1]))return 0;s=Math.min(s,ai(e[a],e[a+1],r[t],r[t+1],i));}return s}function li(e,t,r,n,i){if(!Wn(t,e.length)||!Wn(n,r.length))return NaN;let s=1/0;for(let a=t[0];a<=t[1];++a)for(let t=n[0];t<=n[1];++t)if(0===(s=Math.min(s,i.distance(e[a],r[t]))))return s;return s}function ui(e,t,r){if(bn(e,t,!0))return 0;let n=1/0;for(const i of t){const t=i.length;if(t<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(i[0]!==i[t-1]&&0===(n=Math.min(n,r.pointToSegmentDistance(e,i[t-1],i[0]))))return n;if(0===(n=Math.min(n,ii(e,i,r))))return n}return n}function ci(e,t,r,n){if(!Wn(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(bn(e[n],r,!0))return 0;let i=1/0;for(let s=t[0];s<t[1];++s)for(const t of r)for(let r=0,a=t.length,o=a-1;r<a;o=r++){if(_n(e[s],e[s+1],t[o],t[r]))return 0;i=Math.min(i,ai(e[s],e[s+1],t[o],t[r],n));}return i}function hi(e,t){for(const r of e)for(let e=0;e<=r.length-1;++e)if(bn(r[e],t,!0))return !0;return !1}function di(e,t,r,n=1/0){const i=Kn(e),s=Kn(t);if(n!==1/0&&Qn(i,s,r)>=n)return n;if(gn(i,s)){if(hi(e,t))return 0}else if(hi(t,e))return 0;let a=n;for(const n of e)for(let e=0,i=n.length,s=i-1;e<i;s=e++)for(const i of t)for(let t=0,o=i.length,l=o-1;t<o;l=t++){if(_n(n[s],n[e],i[l],i[t]))return 0;a=Math.min(a,ai(n[s],n[e],i[l],i[t],r));}return a}function pi(e,t,r,n,i,s,a){if(null===s||null===a)return;const o=Qn(Jn(n,s),Jn(i,a),r);o<t&&e.push({dist:o,range1:s,range2:a});}function fi(e,t,r,n,i=1/0){let s=Math.min(n.distance(e[0],r[0][0]),i);if(0===s)return s;const a=new $n([{dist:0,range1:[0,e.length-1],range2:[0,0]}],Hn),o=t?50:100,l=Kn(r);for(;a.length;){const i=a.pop();if(i.dist>=s)continue;const u=i.range1;if(Zn(u)<=o){if(!Wn(u,e.length))return NaN;if(t){const t=ci(e,u,r,n);if(0===(s=Math.min(s,t)))return s}else for(let t=u[0];t<=u[1];++t){const i=ui(e[t],r,n);if(0===(s=Math.min(s,i)))return s}}else {const r=Yn(u,t);if(null!==r[0]){const t=Qn(Jn(e,r[0]),l,n);t<s&&a.push({dist:t,range1:r[0],range2:[0,0]});}if(null!==r[1]){const t=Qn(Jn(e,r[1]),l,n);t<s&&a.push({dist:t,range1:r[1],range2:[0,0]});}}}return s}function mi(e,t,r,n,i,s=1/0){let a=Math.min(s,i.distance(e[0],r[0]));if(0===a)return a;const o=new $n([{dist:0,range1:[0,e.length-1],range2:[0,r.length-1]}],Hn),l=t?50:100,u=n?50:100;for(;o.length;){const s=o.pop();if(s.dist>=a)continue;const c=s.range1,h=s.range2;if(Zn(c)<=l&&Zn(h)<=u){if(!Wn(c,e.length)||!Wn(h,r.length))return NaN;if(t&&n?a=Math.min(a,oi(e,c,r,h,i)):t||n?t&&!n?a=Math.min(a,si(r,h,e,c,i)):!t&&n&&(a=Math.min(a,si(e,c,r,h,i))):a=Math.min(a,li(e,c,r,h,i)),0===a)return a}else {const s=Yn(c,t),l=Yn(h,n);pi(o,a,i,e,r,s[0],l[0]),pi(o,a,i,e,r,s[0],l[1]),pi(o,a,i,e,r,s[1],l[0]),pi(o,a,i,e,r,s[1],l[1]);}}return a}function yi(e,t,r,n,i=1/0){let s=i;const a=Jn(e,[0,e.length-1]);for(const i of r)if(!(s!==1/0&&Qn(a,Jn(i,[0,i.length-1]),n)>=s)&&(s=Math.min(s,mi(e,t,i,!0,n,s)),0===s))return s;return s}function gi(e,t,r,n,i=1/0){let s=i;const a=Jn(e,[0,e.length-1]);for(const i of r){if(s!==1/0&&Qn(a,Kn(i),n)>=s)continue;const r=fi(e,t,i,n,s);if(isNaN(r))return r;if(0===(s=Math.min(s,r)))return s}return s}function xi(e){return "Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class vi{constructor(e,t){this.type=_r,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if($r(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e<t.features.length;++e)if(xi(t.features[e].geometry.type))return new vi(t,t.features[e].geometry)}else if("Feature"===t.type){if(xi(t.geometry.type))return new vi(t,t.geometry)}else if(xi(t.type))return new vi(t,t)}return t.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const t=e.geometry(),r=e.canonicalID();if(null!=t&&null!=r){if("Point"===e.geometryType())return function(e,t,r){const n=[];for(const r of e)for(const e of r)n.push(ri(e,t));const i=new Un(n[0][1],"meters");return "Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type?mi(n,!1,"Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,i):"MultiLineString"===r.type?yi(n,!1,r.coordinates,i):"Polygon"===r.type||"MultiPolygon"===r.type?gi(n,!1,"Polygon"===r.type?[r.coordinates]:r.coordinates,i):null}(t,r,this.geometries);if("LineString"===e.geometryType())return function(e,t,r){const n=[];for(const r of e){const e=[];for(const n of r)e.push(ri(n,t));n.push(e);}const i=new Un(n[0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return yi("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,n,i);if("MultiLineString"===r.type){let e=1/0;for(let t=0;t<r.coordinates.length;t++){const s=yi(r.coordinates[t],!0,n,i,e);if(isNaN(s))return s;if(0===(e=Math.min(e,s)))return e}return e}if("Polygon"===r.type||"MultiPolygon"===r.type){let e=1/0;for(let t=0;t<n.length;t++){const s=gi(n[t],!0,"Polygon"===r.type?[r.coordinates]:r.coordinates,i,e);if(isNaN(s))return s;if(0===(e=Math.min(e,s)))return e}return e}return null}(t,r,this.geometries);if("Polygon"===e.geometryType())return function(e,t,r){const n=[];for(const r of function(e){const t=e.length;if(t<=1)return [e];const r=[];let n,i;for(let s=0;s<t;s++){const t=mn(e[s]);0!==t&&(e[s].area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e[s]]):n.push(e[s]));}return n&&r.push(n),r}(e)){const e=[];for(let n=0;n<r.length;++n)e.push(ni(r[n],t));n.push(e);}const i=new Un(n[0][0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return gi("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,n,i);if("MultiLineString"===r.type){let e=1/0;for(let t=0;t<r.coordinates.length;t++){const s=gi(r.coordinates[t],!0,n,i,e);if(isNaN(s))return s;if(0===(e=Math.min(e,s)))return e}return e}return "Polygon"===r.type||"MultiPolygon"===r.type?function(e,t,r){let n=1/0;for(const i of e)for(const e of t){const t=di(i,e,r,n);if(isNaN(t))return t;if(0===(n=Math.min(n,t)))return n}return n}("Polygon"===r.type?[r.coordinates]:r.coordinates,n,i):null}(t,r,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.");}else console.warn("Distance Expression: requires valid feature and canonical information.");return null}eachChild(){}outputDefined(){return !0}serialize(){return ["distance",this.geojson]}}function bi(e){if(e instanceof un){if("get"===e.name&&1===e.args.length)return !1;if("feature-state"===e.name)return !1;if("has"===e.name&&1===e.args.length)return !1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return !1;if(/^filter-/.test(e.name))return !1}if(e instanceof En)return !1;if(e instanceof vi)return !1;if(e instanceof Si)return e.featureConstant;let t=!0;return e.eachChild(e=>{t&&!bi(e)&&(t=!1);}),t}function wi(e){if(e instanceof un&&"feature-state"===e.name)return !1;let t=!0;return e.eachChild(e=>{t&&!wi(e)&&(t=!1);}),t}function _i(e,t){if(e instanceof un&&t.indexOf(e.name)>=0)return !1;let r=!0;return e.eachChild(e=>{r&&!_i(e,t)&&(r=!1);}),r}function Ai(e,t,r){return [e,t,r].filter(Boolean).join("")}function Ii(e,t){switch(e){case "string":return Hr(t);case "number":return +t;case "boolean":return !!t;case "color":return dr.parse(t);case "formatted":return Ur.fromString(Hr(t));case "resolvedImage":return jr.build(Hr(t))}return t}function Mi(e,t,r,n){return void 0!==n&&(e=n*Math.round(e/n)),void 0!==t&&e<t&&(e=t),void 0!==r&&e>r&&(e=r),e}class Si{constructor(e,t,r,n=!1){this.type=e,this.key=t,this.scope=r,this.featureConstant=n;}static parse(e,t){let r=t.expectedType;if(null==r&&(r=Br),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const n=t.parse(e[1],1);if(!(n instanceof Xr))return t.error("Key name of 'config' expression must be a string literal.");let i,s=!0;const a=Hr(n.value);if(e.length>=3){const r=t.parse(e[2],2);if(!(r instanceof Xr))return t.error("Scope of 'config' expression must be a string literal.");i=Hr(r.value);}if(t.options){const e=Ai(a,i,t._scope),r=t.options.get(e);r&&(s=bi(r.value||r.default));}return new Si(r,a,i,s)}evaluate(e){const t=Ai(this.key,this.scope,e.scope),r=e.getConfig(t);if(!r)return null;const{type:n,value:i,values:s,minValue:a,maxValue:o,stepValue:l}=r,u=r.default.evaluate(e);let c=u;if(i){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),c=i.evaluate(e),e.scope=t;}return n&&(c=Ii(n,c)),void 0===c||void 0===a&&void 0===o&&void 0===l||("number"==typeof c?c=Mi(c,a,o,l):Array.isArray(c)&&(c=c.map(e=>"number"==typeof e?Mi(e,a,o,l):e))),void 0!==i&&void 0!==c&&s&&!s.includes(c)&&(c=u,n&&(c=Ii(n,c))),(n&&n!==this.type||void 0!==c&&!Rr(qr(c),this.type))&&(c=Ii(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Bi{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t;}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const r=e[1];return t.scope.has(r)?new Bi(r,t.scope.get(r)):t.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}class Pi{constructor(e,t=[],r,n=new br,i=[],s,a,o){this.registry=e,this.path=t,this.key=t.map(e=>"string"==typeof e?`['${e}']`:`[${e}]`).join(""),this.scope=n,this.errors=i,this.expectedType=r,this._scope=s,this.options=a,this.iconImageUseTheme=o;}parse(e,t,r,n,i={}){return t||r?this.concat(t,null,r,n)._parse(e,i):this._parse(e,i)}parseObjectValue(e,t,r,n,i,s={}){return this.concat(t,r,n,i)._parse(e,s)}_parse(e,t){function r(e,t,r){return "assert"===r?new Yr(t,[e]):"coerce"===r?new an(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof e[0]?this.registry[e[0]]:void 0;if(n){let i=n.parse(e,this);if(!i)return null;if(this.expectedType){const e=this.expectedType,n=i.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(e,n))return null}else i=r(i,e,t.typeAnnotation||"coerce");else i=r(i,e,t.typeAnnotation||"assert");}if(!(i instanceof Xr)&&"resolvedImage"!==i.type.kind&&Ti(i)){const e=new ln(this._scope,this.options,this.iconImageUseTheme);try{i=new Xr(i.type,i.evaluate(e));}catch(e){return this.error(e.message),null}}return i}return an.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,r,n){let i="number"==typeof e?this.path.concat(e):this.path;i="string"==typeof t?i.concat(t):i;const s=n?this.scope.concat(n):this.scope;return new Pi(this.registry,i,r||null,s,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const r=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new vr(r,e));}checkSubtype(e,t){const r=Dr(e,t);return r&&this.error(r),r}}function Ti(e){if(e instanceof Bi)return Ti(e.boundExpression);if(e instanceof un&&"error"===e.name)return !1;if(e instanceof hn)return !1;if(e instanceof En)return !1;if(e instanceof vi)return !1;if(e instanceof Si)return !1;const t=e instanceof an||e instanceof Yr;let r=!0;return e.eachChild(e=>{r=t?r&&Ti(e):r&&e instanceof Xr;}),!!r&&bi(e)&&_i(e,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function zi(e,t){const r=e.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=e[o],i=e[o+1],n<=t){if(o===r||t<i)return o;s=o+1;}else {if(!(n>t))throw new Zr("Input is not a number.");a=o-1;}return 0}class ki{constructor(e,t,r){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t);}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const r=t.parse(e[1],1,_r);if(!r)return null;const n=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let r=1;r<e.length;r+=2){const s=1===r?-1/0:e[r],a=e[r+1],o=r,l=r+1;if("number"!=typeof s)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',o);if(n.length&&n[n.length-1][0]>=s)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=t.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new ki(i,r,n)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;return n>=t[i-1]?r[i-1].evaluate(e):r[zi(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const Fi=.95047,Vi=1.08883,Di=4/29,Ei=6/29,Ci=3*Ei*Ei,Ri=Ei*Ei*Ei,Li=Math.PI/180,Oi=180/Math.PI;function Ui(e){return e>Ri?Math.pow(e,1/3):e/Ci+Di}function Ni(e){return e>Ei?e*e*e:Ci*(e-Di)}function ji(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Gi(e){return (e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function $i(e){const t=Gi(e.r),r=Gi(e.g),n=Gi(e.b),i=Ui((.4124564*t+.3575761*r+.1804375*n)/Fi),s=Ui((.2126729*t+.7151522*r+.072175*n)/1);return {l:116*s-16,a:500*(i-s),b:200*(s-Ui((.0193339*t+.119192*r+.9503041*n)/Vi)),alpha:e.a}}function qi(e){let t=(e.l+16)/116,r=isNaN(e.a)?t:t+e.a/500,n=isNaN(e.b)?t:t-e.b/200;return t=1*Ni(t),r=Fi*Ni(r),n=Vi*Ni(n),new dr(ji(3.2404542*r-1.5371385*t-.4985314*n),ji(-.969266*r+1.8760108*t+.041556*n),ji(.0556434*r-.2040259*t+1.0572252*n),e.alpha)}function Hi(e,t,r){const n=t-e;return e+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const Xi={forward:$i,reverse:qi,interpolate:function(e,t,r){return {l:yr(e.l,t.l,r),a:yr(e.a,t.a,r),b:yr(e.b,t.b,r),alpha:yr(e.alpha,t.alpha,r)}}},Zi={forward:function(e){const{l:t,a:r,b:n}=$i(e),i=Math.atan2(n,r)*Oi;return {h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Li,r=e.c;return qi({l:e.l,a:Math.cos(t)*r,b:Math.sin(t)*r,alpha:e.alpha})},interpolate:function(e,t,r){return {h:Hi(e.h,t.h,r),c:yr(e.c,t.c,r),l:yr(e.l,t.l,r),alpha:yr(e.alpha,t.alpha,r)}}};var Wi=Object.freeze({__proto__:null,hcl:Zi,lab:Xi});class Yi{constructor(e,t,r,n,i){this.type=e,this.operator=t,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t);}static interpolationFactor(e,t,r,n){let i=0;if("exponential"===e.name)i=Ji(t,e.base,r,n);else if("linear"===e.name)i=Ji(t,1,r,n);else if("cubic-bezier"===e.name){const s=e.controlPoints;i=new Ie(s[0],s[1],s[2],s[3]).solve(Ji(t,1,r,n));}return i}static parse(e,t){let[r,n,i,...s]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e};}else {if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e};}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,_r),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Mr:t.expectedType&&"value"!==t.expectedType.kind&&(o=t.expectedType);for(let e=0;e<s.length;e+=2){const r=s[e],n=s[e+1],i=e+3,l=e+4;if("number"!=typeof r)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',i);if(a.length&&a[a.length-1][0]>=r)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return "number"===o.kind||"color"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new Yi(o,r,n,i,a):t.error(`Type ${Fr(o)} is not interpolatable.`)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;if(n>=t[i-1])return r[i-1].evaluate(e);const s=zi(t,n),a=Yi.interpolationFactor(this.interpolation,n,t[s],t[s+1]),o=r[s].evaluate(e),l=r[s+1].evaluate(e);return "interpolate"===this.operator?xr[this.type.kind.toLowerCase()](o,l,a):"interpolate-hcl"===this.operator?Zi.reverse(Zi.interpolate(Zi.forward(o),Zi.forward(l),a)):Xi.reverse(Xi.interpolate(Xi.forward(o),Xi.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const t=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function Ji(e,t,r,n){const i=n-r,s=e-r;return 0===i?0:1===t?s/i:(Math.pow(t,s)-1)/(Math.pow(t,i)-1)}class Ki{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument."),null;let r=null;const n=t.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of e.slice(1)){const e=t.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r=r||e.type,i.push(e);}const s=n&&i.some(e=>Dr(n,e.type));return new Ki(s?Br:r,i)}evaluate(e){let t,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(e),r&&r instanceof jr&&!r.available&&(t||(t=r),r=null,n===this.args.length))return t;if(null!==r)break}return r}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize());}),e}}class Qi{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t;}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result);}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let n=1;n<e.length-1;n+=2){const i=e[n];if("string"!=typeof i)return t.error(`Expected string, but found ${typeof i} instead.`,n);if(/[^a-zA-Z0-9_]/.test(i))return t.error("Variable names must contain only alphanumeric characters or '_'.",n);const s=t.parse(e[n+1],n+1);if(!s)return null;r.push([i,s]);}const n=t.parse(e[e.length-1],e.length-1,t.expectedType,r);return n?new Qi(r,n):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,r]of this.bindings)e.push(t,r.serialize());return e.push(this.result.serialize()),e}}class es{constructor(e,t,r){this.type=e,this.index=t,this.input=r;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,_r),n=t.parse(e[2],2,kr(t.expectedType||Br));return r&&n?new es(n.type.itemType,r,n):null}evaluate(e){const t=this.index.evaluate(e),r=this.input.evaluate(e);if(t<0)throw new Zr("Array index out of bounds: negative index");if(t>=r.length)throw new Zr("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new Zr("Array index must be an integer. Use at-interpolated for fractional indices");return r[t]}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}class ts{constructor(e,t,r){this.type=e,this.index=t,this.input=r;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,_r),n=t.parse(e[2],2,kr(t.expectedType||Br));return r&&n?new ts(n.type.itemType,r,n):null}evaluate(e){const t=this.index.evaluate(e),r=this.input.evaluate(e);if(t<0)throw new Zr(`Array index out of bounds: ${t} < 0.`);if(t>r.length-1)throw new Zr(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t===Math.floor(t))return r[t];const n=Math.floor(t),i=Math.ceil(t),s=r[n],a=r[i];if("number"!=typeof s||"number"!=typeof a)throw new Zr(`Cannot interpolate between non-number values at index ${t}.`);const o=t-n;return s*(1-o)+a*o}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at-interpolated",this.index.serialize(),this.input.serialize()]}}class rs{constructor(e,t){this.type=Ir,this.needle=e,this.haystack=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Br),n=t.parse(e[2],2,Br);return r&&n?Er(r.type,[Ir,Ar,_r,wr,Br])?new rs(r,n):(t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Fr(r.type)} instead`),null):null}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(null==r)return !1;if(!Cr(t,["boolean","string","number","null"]))throw new Zr(`Expected first argument to be of type boolean, string, number or null, but found ${Fr(qr(t))} instead.`);if(!Cr(r,["string","array"]))throw new Zr(`Expected second argument to be of type array or string, but found ${Fr(qr(r))} instead.`);return r.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}class ns{constructor(e,t,r){this.type=_r,this.needle=e,this.haystack=t,this.fromIndex=r;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Br),n=t.parse(e[2],2,Br);if(!r||!n)return null;if(!Er(r.type,[Ir,Ar,_r,wr,Br]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Fr(r.type)} instead`),null;if(4===e.length){const i=t.parse(e[3],3,_r);return i?new ns(r,n,i):null}return new ns(r,n)}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!Cr(t,["boolean","string","number","null"]))throw new Zr(`Expected first argument to be of type boolean, string, number or null, but found ${Fr(qr(t))} instead.`);if(!Cr(r,["string","array"]))throw new Zr(`Expected second argument to be of type array or string, but found ${Fr(qr(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(e);return r.indexOf(t,n)}return r.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}class is{constructor(e,t,r,n,i,s){this.inputType=e,this.type=t,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let r,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const i={},s=[];for(let a=2;a<e.length-1;a+=2){let o=e[a];const l=e[a+1];Array.isArray(o)||(o=[o]);const u=t.concat(a);if(0===o.length)return u.error("Expected at least one branch label.");for(const e of o){if("number"!=typeof e&&"string"!=typeof e)return u.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,qr(e)))return null}else r=qr(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=s.length;}const c=t.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=t.parse(e[1],1,Br);if(!a)return null;const o=t.parse(e[e.length-1],e.length-1,n);return o?"value"!==a.type.kind&&t.concat(1).checkSubtype(r,a.type)?null:new is(r,n,a,i,s,o):null}evaluate(e){const t=this.input.evaluate(e);return (Rr(qr(t),this.inputType)&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise);}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),r=[],n={};for(const e of t){const t=n[this.cases[e]];void 0===t?(n[this.cases[e]]=r.length,r.push([this.cases[e],[e]])):r[t][1].push(e);}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,n]of r)e.push(1===n.length?i(n[0]):n.map(i)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class ss{constructor(e,t,r){this.type=e,this.branches=t,this.otherwise=r;}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return t.error("Expected an odd number of arguments."),null;let r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n=[];for(let i=1;i<e.length-1;i+=2){const s=t.parse(e[i],i,Ir);if(!s)return null;const a=t.parse(e[i+1],i+1,r);if(!a)return null;n.push([s,a]),r=r||a.type;}const i=t.parse(e[e.length-1],e.length-1,r);return i?new ss(r,n,i):null}evaluate(e){for(const[t,r]of this.branches)if(t.evaluate(e))return r.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,r]of this.branches)e(t),e(r);e(this.otherwise);}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize());}),e}}class as{constructor(e,t,r,n){this.type=e,this.input=t,this.beginIndex=r,this.endIndex=n;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Br),n=t.parse(e[2],2,_r);if(!r||!n)return null;if(!Er(r.type,[kr(Br),Ar,Br]))return t.error(`Expected first argument to be of type array or string, but found ${Fr(r.type)} instead`),null;if(4===e.length){const i=t.parse(e[3],3,_r);return i?new as(r.type,r,n,i):null}return new as(r.type,r,n)}evaluate(e){const t=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!Cr(t,["string","array"]))throw new Zr(`Expected first argument to be of type array or string, but found ${Fr(qr(t))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(e);return t.slice(r,n)}return t.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}class os{constructor(e,t){this.type=kr(Ar),this.str=e,this.delimiter=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,Ar),n=t.parse(e[2],2,Ar);return r&&n?new os(r,n):void 0}evaluate(e){const t=this.str.evaluate(e),r=this.delimiter.evaluate(e);return t.split(r)}eachChild(e){e(this.str),e(this.delimiter);}outputDefined(){return !1}serialize(){return ["split",this.str.serialize(),this.delimiter.serialize()]}}function ls(e,t){return "=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function us(e,t,r,n){return 0===n.compare(t,r)}function cs(e,t,r){const n="=="!==e&&"!="!==e;return class i{constructor(e,t,r){this.type=Ir,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind;}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const r=e[0];let s=t.parse(e[1],1,Br);if(!s)return null;if(!ls(r,s.type))return t.concat(1).error(`"${r}" comparisons are not supported for type '${Fr(s.type)}'.`);let a=t.parse(e[2],2,Br);if(!a)return null;if(!ls(r,a.type))return t.concat(2).error(`"${r}" comparisons are not supported for type '${Fr(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${Fr(s.type)}' and '${Fr(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new Yr(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new Yr(s.type,[a])));let o=null;if(4===e.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(o=t.parse(e[3],3,Pr),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const t=qr(s),r=qr(a);if(t.kind!==r.kind||"string"!==t.kind&&"number"!==t.kind)throw new Zr(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=qr(s),r=qr(a);if("string"!==e.kind||"string"!==r.kind)return t(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):t(i,s,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator);}outputDefined(){return !0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize());}),t}}}const hs=cs("==",function(e,t,r){return t===r},us),ds=cs("!=",function(e,t,r){return t!==r},function(e,t,r,n){return !us(0,t,r,n)}),ps=cs("<",function(e,t,r){return t<r},function(e,t,r,n){return n.compare(t,r)<0}),fs=cs(">",function(e,t,r){return t>r},function(e,t,r,n){return n.compare(t,r)>0}),ms=cs("<=",function(e,t,r){return t<=r},function(e,t,r,n){return n.compare(t,r)<=0}),ys=cs(">=",function(e,t,r){return t>=r},function(e,t,r,n){return n.compare(t,r)>=0});class gs{constructor(e,t,r,n,i,s){this.type=Ar,this.number=e,this.locale=t,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=s;}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,_r);if(!r)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=t.parseObjectValue(n.locale,2,"locale",Ar),!i))return null;let s=null;if(n.currency&&(s=t.parseObjectValue(n.currency,2,"currency",Ar),!s))return null;let a=null;if(n.unit&&(a=t.parseObjectValue(n.unit,2,"unit",Ar),!a))return null;let o=null;if(n["min-fraction-digits"]&&(o=t.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",_r),!o))return null;let l=null;return n["max-fraction-digits"]&&(l=t.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",_r),!l)?null:new gs(r,i,s,a,o,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class xs{constructor(e){this.type=_r,this.input=e;}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?(t.error(`Expected argument of type string or array, but found ${Fr(r.type)} instead.`),null):new xs(r):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Zr(`Expected value to be of type string or array, but found ${Fr(qr(t))} instead.`)}eachChild(e){e(this.input);}outputDefined(){return !1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize());}),e}}function vs(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const bs={"==":hs,"!=":ds,">":fs,"<":ps,">=":ys,"<=":ms,array:Yr,at:es,"at-interpolated":ts,boolean:Yr,case:ss,coalesce:Ki,collator:hn,format:Jr,image:Kr,in:rs,"index-of":ns,interpolate:Yi,"interpolate-hcl":Yi,"interpolate-lab":Yi,length:xs,let:Qi,literal:Xr,match:is,number:Yr,"number-format":gs,object:Yr,slice:as,step:ki,string:Yr,"to-boolean":an,"to-color":an,"to-number":an,"to-string":an,var:Bi,within:En,distance:vi,config:Si,split:os};function ws(e,[t,r,n,i]){t=t.evaluate(e),r=r.evaluate(e),n=n.evaluate(e);const s=i?i.evaluate(e):1,a=Gr(t,r,n,s);if(a)throw new Zr(a);return new dr(t/255,r/255,n/255,s)}function _s(e,[t,r,n,i]){t=t.evaluate(e),r=r.evaluate(e),n=n.evaluate(e);const s=i?i.evaluate(e):1,a=function(e,t,r,n){return "number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'h' must be between 0 and 360.`}(t,r,n,s);if(a)throw new Zr(a);const o=`hsla(${t}, ${r}%, ${n}%, ${s})`,l=dr.parse(o);if(!l)throw new Zr(`Failed to parse HSLA color: ${o}`);return l}function As(e,t){return e in t}function Is(e,t){const r=t[e];return void 0===r?null:r}function Ms(e){return {type:e}}function Ss(e){if(e instanceof Si)return new Set([e.key]);let t=new Set;return e.eachChild(e=>{t=new Set([...t,...Ss(e)]);}),t}function Bs(e){if(e instanceof un&&"is-active-floor"===e.name)return !0;let t=!1;return e.eachChild(e=>{!t&&Bs(e)&&(t=!0);}),t}function Ps(e){return {result:"success",value:e}}function Ts(e){return {result:"error",value:e}}function zs(e,t){return !!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function ks(e){return "data-driven"===e["property-type"]}function Fs(e){return zs(e.expression,"measure-light")}function Vs(e){return zs(e.expression,"zoom")}function Ds(e){return !!e.expression&&e.expression.interpolated}function Es(e){return "object"==typeof e&&null!==e&&!Array.isArray(e)}function Cs(e){return e}function Rs(e,t){const r="color"===t.type,n=e.stops&&"object"==typeof e.stops[0][0],i=n||!(n||void 0!==e.property),s=e.type||(Ds(t)?"exponential":"interval");if(r&&((e=Object.assign({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],dr.parse(e[1])])),e.default=dr.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Wi[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let a,o,l;if("exponential"===s)a=Ns;else if("interval"===s)a=Us;else if("categorical"===s){a=Os,o=Object.create(null);for(const t of e.stops)o[t[0]]=t[1];l=typeof e.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);a=js;}if(n){const r={},n=[];for(let t=0;t<e.stops.length;t++){const i=e.stops[t],s=i[0].zoom;void 0===r[s]&&(r[s]={zoom:s,type:e.type,property:e.property,default:e.default,stops:[]},n.push(s)),r[s].stops.push([i[0].value,i[1]]);}const i=[];for(const e of n)i.push([r[e].zoom,Rs(r[e],t)]);const s={name:"linear"};return {kind:"composite",interpolationType:s,interpolationFactor:Yi.interpolationFactor.bind(void 0,s),zoomStops:i.map(e=>e[0]),evaluate:({zoom:r},n)=>Ns({stops:i,base:e.base},t,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:Yi.interpolationFactor.bind(void 0,r),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:r})=>a(e,t,r,o,l)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[e.property]:void 0;return void 0===i?Ls(e.default,t.default):a(e,t,i,o,l)}}}function Ls(e,t,r){return void 0!==e?e:void 0!==t?t:void 0!==r?r:void 0}function Os(e,t,r,n,i){return Ls(typeof r===i?n[r]:void 0,e.default,t.default)}function Us(e,t,r){if(!rn(r))return Ls(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];const i=zi(e.stops.map(e=>e[0]),r);return e.stops[i][1]}function Ns(e,t,r){const n=void 0!==e.base?e.base:1;if(!rn(r))return Ls(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[i-1][0])return e.stops[i-1][1];const s=zi(e.stops.map(e=>e[0]),r),a=function(e,t,r,n){const i=n-r,s=e-r;return 0===i?0:1===t?s/i:(Math.pow(t,s)-1)/(Math.pow(t,i)-1)}(r,n,e.stops[s][0],e.stops[s+1][0]),o=e.stops[s][1],l=e.stops[s+1][1];let u=xr[t.type]||Cs;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Wi[e.colorSpace];u=(e,r)=>t.reverse(t.interpolate(t.forward(e),t.forward(r),a));}return "function"==typeof o.evaluate?{evaluate(...e){const t=o.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==r)return u(t,r,a)}}:u(o,l,a)}function js(e,t,r){return "color"===t.type?r=dr.parse(r):"formatted"===t.type?r=Ur.fromString(r.toString()):"resolvedImage"===t.type?r=jr.build(r.toString()):Qr(r)===t.type||"enum"===t.type&&t.values[r]||(r=void 0),Ls(r,e.default,t.default)}un.register(bs,{error:[{kind:"error"},[Ar],(e,[t])=>{throw new Zr(t.evaluate(e))}],typeof:[Ar,[Br],(e,[t])=>Fr(qr(t.evaluate(e)))],"to-rgba":[kr(_r,4),[Mr],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[kr(_r,4),[Mr],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Mr,[_r,_r,_r],ws],rgba:[Mr,[_r,_r,_r,_r],ws],hsl:[Mr,[_r,_r,_r],_s],hsla:[Mr,[_r,_r,_r,_r],_s],has:{type:Ir,overloads:[[[Ar],(e,[t])=>As(t.evaluate(e),e.properties())],[[Ar,Sr],(e,[t,r])=>As(t.evaluate(e),r.evaluate(e))]]},get:{type:Br,overloads:[[[Ar],(e,[t])=>Is(t.evaluate(e),e.properties())],[[Ar,Sr],(e,[t,r])=>Is(t.evaluate(e),r.evaluate(e))]]},"feature-state":[Br,[Ar],(e,[t])=>Is(t.evaluate(e),e.featureState||{})],properties:[Sr,[],e=>e.properties()],"geometry-type":[Ar,[],e=>e.geometryType()],worldview:[Ar,[],e=>e.globals.worldview||""],"is-active-floor":[Ir,Ms(Ar),(e,t)=>{if(!(e.globals&&e.globals.activeFloors&&e.globals.activeFloors.size>0))return !1;if(0===t.length)return !0;const r=e.globals.activeFloors;return t.some(t=>{const n=t.evaluate(e);return r.has(n)})}],id:[Br,[],e=>e.id()],zoom:[_r,[],e=>e.globals.zoom],pitch:[_r,[],e=>e.globals.pitch||0],"distance-from-center":[_r,[],e=>e.distanceFromCenter()],"measure-light":[_r,[Ar],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[_r,[],e=>e.globals.heatmapDensity||0],"line-progress":[_r,[],e=>e.globals.lineProgress||0],"raster-value":[_r,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[_r,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[_r,[],e=>e.globals.skyRadialProgress||0],accumulated:[Br,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[_r,Ms(_r),(e,t)=>{let r=0;for(const n of t)r+=n.evaluate(e);return r}],"*":[_r,Ms(_r),(e,t)=>{let r=1;for(const n of t)r*=n.evaluate(e);return r}],"-":{type:_r,overloads:[[[_r,_r],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[_r],(e,[t])=>-t.evaluate(e)]]},"/":[_r,[_r,_r],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[_r,[_r,_r],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[_r,[],()=>Math.LN2],pi:[_r,[],()=>Math.PI],e:[_r,[],()=>Math.E],"^":[_r,[_r,_r],(e,[t,r])=>Math.pow(t.evaluate(e),r.evaluate(e))],sqrt:[_r,[_r],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[_r,[_r],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[_r,[_r],(e,[t])=>Math.log(t.evaluate(e))],log2:[_r,[_r],(e,[t])=>Math.log2(t.evaluate(e))],sin:[_r,[_r],(e,[t])=>Math.sin(t.evaluate(e))],cos:[_r,[_r],(e,[t])=>Math.cos(t.evaluate(e))],tan:[_r,[_r],(e,[t])=>Math.tan(t.evaluate(e))],asin:[_r,[_r],(e,[t])=>Math.asin(t.evaluate(e))],acos:[_r,[_r],(e,[t])=>Math.acos(t.evaluate(e))],atan:[_r,[_r],(e,[t])=>Math.atan(t.evaluate(e))],min:[_r,Ms(_r),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[_r,Ms(_r),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[_r,[_r],(e,[t])=>Math.abs(t.evaluate(e))],round:[_r,[_r],(e,[t])=>{const r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[_r,[_r],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[_r,[_r],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Ir,[Ar,Br],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[Ir,[Br],(e,[t])=>e.id()===t.value],"filter-type-==":[Ir,[Ar],(e,[t])=>e.geometryType()===t.value],"filter-<":[Ir,[Ar,Br],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n<i}],"filter-id-<":[Ir,[Br],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r<n}],"filter->":[Ir,[Ar,Br],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Ir,[Br],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>n}],"filter-<=":[Ir,[Ar,Br],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Ir,[Br],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r<=n}],"filter->=":[Ir,[Ar,Br],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Ir,[Br],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>=n}],"filter-has":[Ir,[Br],(e,[t])=>t.value in e.properties()],"filter-has-id":[Ir,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Ir,[kr(Ar)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Ir,[kr(Br)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Ir,[Ar,kr(Br)],(e,[t,r])=>r.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Ir,[Ar,kr(Br)],(e,[t,r])=>function(e,t,r,n){for(;r<=n;){const i=r+n>>1;if(t[i]===e)return !0;t[i]>e?n=i-1:r=i+1;}return !1}(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:Ir,overloads:[[[Ir,Ir],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[Ms(Ir),(e,t)=>{for(const r of t)if(!r.evaluate(e))return !1;return !0}]]},any:{type:Ir,overloads:[[[Ir,Ir],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[Ms(Ir),(e,t)=>{for(const r of t)if(r.evaluate(e))return !0;return !1}]]},"!":[Ir,[Ir],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Ir,[Ar],(e,[t])=>{const r=e.globals&&e.globals.isSupportedScript;return !r||r(t.evaluate(e))}],upcase:[Ar,[Ar],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Ar,[Ar],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Ar,Ms(Br),(e,t)=>t.map(t=>Hr(t.evaluate(e))).join("")],"resolved-locale":[Ar,[Pr],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[_r,[_r,_r,Br],(e,t)=>{const[r,n,i]=t.map(t=>t.evaluate(e));if(r>n)return r;if(r===n)return r;let s;if("string"==typeof i)s=function(e){let t=0;if(0===e.length)return t;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return t}(i);else {if("number"!=typeof i)throw new Zr(`Invalid seed input: ${i}`);s=i;}return r+vs(s)()*(n-r)}]});class Gs{constructor(e,t,r,n,i){this.expression=e,this._warningHistory={},this._scope=r,this._options=n,this._iconImageUseTheme=i,this._evaluator=new ln(r,n,i),this._defaultValue=t?function(e){return "color"===e.type&&(Es(e.default)||Array.isArray(e.default))?new dr(0,0,0,0):"color"===e.type?dr.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this.configDependencies=Ss(e),this.isIndoorDependent=Bs(e);}evaluateWithoutErrorHandling(e,t,r,n,i,s,a,o){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=r,this._evaluator.canonical=n||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=o||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,r,n,i,s,a,o,l){this._evaluator||(this._evaluator=new ln(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=o||null,this._evaluator.iconImageUseTheme=l||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Zr(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){const t=e;return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function $s(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in bs}function qs(e,t,r,n,i){const s=new Pi(bs,[],t?function(e){const t={color:Mr,string:Ar,number:_r,enum:Ar,boolean:Ir,formatted:Tr,resolvedImage:zr};return "array"===e.type?kr(t[e.value]||Br,e.length):t[e.type]}(t):void 0,void 0,void 0,r,n,i),a=s.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return a?Ps(new Gs(a,t,r,n,i)):Ts(s.errors)}class Hs{constructor(e,t,r,n){this.kind=e,this._styleExpression=t,this.isLightConstant=r,this.isLineProgressConstant=n,this.isStateDependent="constant"!==e&&!wi(t.expression),this.configDependencies=Ss(t.expression),this.isIndoorDependent=Bs(t.expression);}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s,a){return this._styleExpression.evaluate(e,t,r,n,i,s,void 0,void 0,a)}}class Xs{constructor(e,t,r,n,i,s){this.kind=e,this.zoomStops=r,this._styleExpression=t,this.isStateDependent="camera"!==e&&!wi(t.expression),this.isIndoorDependent=Bs(t.expression),this.isLightConstant=i,this.isLineProgressConstant=s,this.configDependencies=Ss(t.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s){return this._styleExpression.evaluate(e,t,r,n,i,s)}interpolationFactor(e,t,r){return this.interpolationType?Yi.interpolationFactor(this.interpolationType,e,t,r):0}}function Zs(e,t,r,n,i){if("error"===(e=qs(e,t,r,n,i)).result)return e;const s=e.value.expression,a=bi(s);if(!a&&!ks(t))return Ts([new vr("","data expressions not supported")]);const o=_i(s,["zoom","pitch","distance-from-center"]);if(!o&&!Vs(t))return Ts([new vr("","zoom expressions not supported")]);const l=_i(s,["measure-light"]);if(!l&&!Fs(t))return Ts([new vr("","measure-light expression not supported")]);const u=_i(s,["line-progress"]);if(!u&&!function(e){return zs(e.expression,"line-progress")}(t))return Ts([new vr("","line-progress expression not supported")]);const c=t.expression&&t.expression.relaxZoomRestriction,h=Ys(s);return h||o||c?h instanceof vr?Ts([h]):h instanceof Yi&&!Ds(t)?Ts([new vr("",'"interpolate" expressions cannot be used with this property')]):Ps(h?new Xs(a&&u?"camera":"composite",e.value,h.labels,h instanceof Yi?h.interpolation:void 0,l,u):new Hs(a&&u?"constant":"source",e.value,l,u)):Ts([new vr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Ws{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,Rs(this._parameters,this._specification));}static deserialize(e){return new Ws(e._parameters,e._specification)}static serialize(e){return {_parameters:e._parameters,_specification:e._specification}}}function Ys(e){let t=null;if(e instanceof Qi)t=Ys(e.result);else if(e instanceof Ki){for(const r of e.args)if(t=Ys(r),t)break}else (e instanceof ki||e instanceof Yi)&&e.input instanceof un&&"zoom"===e.input.name&&(t=e);return t instanceof vr||e.eachChild(e=>{const r=Ys(e);r instanceof vr?t=r:t&&r&&t!==r&&(t=new vr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));}),t}var Js,Ks,Qs=function(){if(Ks)return Js;Ks=1,Js=t;var e=3;function t(t,r,n){var i=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a<this.d*this.d;a++){var o=s[e+a],l=s[e+a+1];i.push(o===l?null:s.subarray(o,l));}var u=s[e+i.length+1];this.keys=s.subarray(s[e+i.length],u),this.bboxes=s.subarray(u),this.insert=this._insertReadonly;}else {this.d=r+2*n;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[];}this.n=r,this.extent=t,this.padding=n,this.scale=r/t,this.uid=0;var h=n/r*t;this.min=-h,this.max=t+h;}return t.prototype.insert=function(e,t,r,n,i){this._forEachCell(t,r,n,i,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(n),this.bboxes.push(i);},t.prototype._insertReadonly=function(){throw "Cannot insert into a GridIndex created from an ArrayBuffer."},t.prototype._insertCell=function(e,t,r,n,i,s){this.cells[i].push(s);},t.prototype.query=function(e,t,r,n,i){var s=this.min,a=this.max;if(e<=s&&t<=s&&a<=r&&a<=n&&!i)return Array.prototype.slice.call(this.keys);var o=[];return this._forEachCell(e,t,r,n,this._queryCell,o,{},i),o},t.prototype._queryCell=function(e,t,r,n,i,s,a,o){var l=this.cells[i];if(null!==l)for(var u=this.keys,c=this.bboxes,h=0;h<l.length;h++){var d=l[h];if(void 0===a[d]){var p=4*d;(o?o(c[p+0],c[p+1],c[p+2],c[p+3]):e<=c[p+2]&&t<=c[p+3]&&r>=c[p+0]&&n>=c[p+1])?(a[d]=!0,s.push(u[d])):a[d]=!1;}}},t.prototype._forEachCell=function(e,t,r,n,i,s,a,o){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),d=l;d<=c;d++)for(var p=u;p<=h;p++){var f=this.d*p+d;if((!o||o(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&i.call(this,e,t,r,n,f,s,a,o))return}},t.prototype._convertFromCellCoord=function(e){return (e-this.padding)/this.scale},t.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},t.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,r=e+this.cells.length+1+1,n=0,i=0;i<this.cells.length;i++)n+=this.cells[i].length;var s=new Int32Array(r+n+this.keys.length+this.bboxes.length);s[0]=this.extent,s[1]=this.n,s[2]=this.padding;for(var a=r,o=0;o<t.length;o++){var l=t[o];s[e+o]=a,s.set(l,a),a+=l.length;}return s[e+t.length]=a,s.set(this.keys,a),s[e+t.length+1]=a+=this.keys.length,s.set(this.bboxes,a),a+=this.bboxes.length,s.buffer},Js}(),ea=_e(Qs);const ta={};function ra(e,t,r={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),ta[t]={klass:e,omit:r.omit||[]};}ra(Object,"Object"),ea.serialize=function(e,t){const r=e.toArrayBuffer();return t&&t.add(r),{buffer:r}},ea.deserialize=function(e){return new ea(e.buffer)},Object.defineProperty(ea,"name",{value:"Grid"}),ra(ea,"Grid"),delete Me.prototype.constructor,ra(dr,"Color"),ra(Error,"Error"),ra(Ur,"Formatted"),ra(Or,"FormattedSection"),ra(Ut,"AJAXError"),ra(jr,"ResolvedImage"),ra(Ws,"StylePropertyFunction"),ra(Gs,"StyleExpression",{omit:["_evaluator"]}),ra(lr,"ImageId"),ra(Nr,"ImageVariant"),ra(Xs,"ZoomDependentExpression"),ra(Hs,"ZoomConstantExpression"),ra(un,"CompoundExpression",{omit:["_evaluate"]});for(const e in bs)ta[bs[e]._classRegistryKey]||ra(bs[e],`Expression${e}`);function na(e){return e&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function ia(e,t){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp)return e;if(na(e)||e instanceof ImageBitmap)return t&&t.add(e),e;if(ArrayBuffer.isView(e))return t&&t.add(e.buffer),e;if(e instanceof ImageData)return t&&t.add(e.data.buffer),e;if(Array.isArray(e)){const r=[];for(const n of e)r.push(ia(n,t));return r}if(e instanceof Map){const r={$name:"Map",entries:[]};for(const[n,i]of e.entries())r.entries.push(ia(n),ia(i,t));return r}if(e instanceof Set){const t={$name:"Set"};let r=0;for(const n of e.values())t[++r]=ia(n);return t}if("bigint"==typeof e)return {$name:"BigInt",value:e.toString()};if("object"==typeof e){const r=e.constructor,n=r._classRegistryKey;if(!n)throw new Error(`Can't serialize object of unregistered class "${r.name}".`);const i=r.serialize?r.serialize(e,t):{};if(!r.serialize){for(const r in e)e.hasOwnProperty(r)&&(ta[n].omit.indexOf(r)>=0||(i[r]=ia(e[r],t)));e instanceof Error&&(i.message=e.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==n&&(i.$name=n),i}throw new Error("can't serialize object of type "+typeof e)}function sa(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||na(e)||e instanceof ImageBitmap||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(sa);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=e.entries||[],r=new Map;for(let e=0;e<t.length;e+=2)r.set(sa(t[e]),sa(t[e+1]));return r}if("Set"===t){const t=new Set;for(const r of Object.keys(e))"$name"!==r&&t.add(sa(e[r]));return t}if("BigInt"===t)return BigInt(e.value);const{klass:r}=ta[t];if(!r)throw new Error(`Can't deserialize unregistered class "${t}".`);if(r.deserialize)return r.deserialize(e);const n=Object.create(r.prototype);for(const t of Object.keys(e))"$name"!==t&&(n[t]=sa(e[t]));return n}throw new Error("can't deserialize object of type "+typeof e)}const aa=e=>e>=1536&&e<=1791,oa=e=>e>=1872&&e<=1919,la=e=>e>=2208&&e<=2303,ua=e=>e>=11904&&e<=12031,ca=e=>e>=12032&&e<=12255,ha=e=>e>=12272&&e<=12287,da=e=>e>=12288&&e<=12351,pa=e=>e>=12352&&e<=12447,fa=e=>e>=12448&&e<=12543,ma=e=>e>=12544&&e<=12591,ya=e=>e>=12704&&e<=12735,ga=e=>e>=12736&&e<=12783,xa=e=>e>=12784&&e<=12799,va=e=>e>=12800&&e<=13055,ba=e=>e>=13056&&e<=13311,wa=e=>e>=13312&&e<=19903,_a=e=>e>=19968&&e<=40959,Aa=e=>e>=40960&&e<=42127,Ia=e=>e>=42128&&e<=42191,Ma=e=>e>=44032&&e<=55215,Sa=e=>e>=63744&&e<=64255,Ba=e=>e>=64336&&e<=65023,Pa=e=>e>=65040&&e<=65055,Ta=e=>e>=65072&&e<=65103,za=e=>e>=65104&&e<=65135,ka=e=>e>=65136&&e<=65279,Fa=e=>e>=65280&&e<=65519;function Va(e){for(const t of e)if(Ra(t.charCodeAt(0)))return !0;return !1}function Da(e){for(const t of e)if(!Ea(t.charCodeAt(0)))return !1;return !0}function Ea(e){return !(aa(e)||oa(e)||la(e)||Ba(e)||ka(e))}function Ca(e){return !(e<11904||!(ya(e)||ma(e)||Ta(e)||Sa(e)||ba(e)||ua(e)||ga(e)||da(e)||wa(e)||_a(e)||va(e)||Fa(e)||pa(e)||ha(e)||ca(e)||xa(e)||fa(e)||Pa(e)||Ia(e)||Aa(e)))}function Ra(e){return !(746!==e&&747!==e&&(e<4352||!(ya(e)||ma(e)||Ta(e)&&!(e>=65097&&e<=65103)||Sa(e)||ba(e)||ua(e)||ga(e)||!(!da(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||wa(e)||_a(e)||va(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||Ma(e)||pa(e)||ha(e)||(e=>e>=12688&&e<=12703)(e)||ca(e)||xa(e)||fa(e)&&12540!==e||!(!Fa(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!za(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||Pa(e)||(e=>e>=19904&&e<=19967)(e)||Aa(e)||Ia(e))))}function La(e){return 12312===e||12313===e||12316===e||12540===e||12448===e}function Oa(e){return !(Ra(e)||function(e){return !!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||da(e)||fa(e)||(e=>e>=57344&&e<=63743)(e)||Ta(e)||za(e)||Fa(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function Ua(e){return aa(e)||oa(e)||la(e)||Ba(e)||ka(e)}function Na(e){return e>=1424&&e<=2303||Ba(e)||ka(e)}function ja(e,t){return !(!t&&Na(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function Ga(e){for(const t of e)if(Na(t.charCodeAt(0)))return !0;return !1}const $a={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let qa=null,Ha=$a.unavailable,Xa=null;const Za=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Ha=$a.error),qa&&qa(e);};function Wa(){Ya.fire(new nr("pluginStateChange",{pluginStatus:Ha,pluginURL:Xa}));}const Ya=new or,Ja=function(){return Ha},Ka=function(){if(Ha!==$a.deferred||!Xa)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ha=$a.loading,Wa(),Xa&&$t({url:Xa},e=>{e?Za(e):(Ha=$a.loaded,Wa());});},Qa={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ha===$a.loaded||null!=Qa.applyArabicShaping,isLoading:()=>Ha===$a.loading,setState(e){Ha=e.pluginStatus,Xa=e.pluginURL;},isParsing:()=>Ha===$a.parsing,isParsed:()=>Ha===$a.parsed,getPluginURL:()=>Xa},eo=function(){Qa.isLoading()||Qa.isLoaded()||"deferred"!==Ja()||Ka();};class to{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness,this.worldview=t.worldview,this.activeFloors=t.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(e){return function(e,t){for(const r of e)if(!ja(r.charCodeAt(0),t))return !1;return !0}(e,Qa.isLoaded())}}class ro{constructor(e,t,r,n,i){this.property=e,this.value=t,this.expression=function(e,t,r,n,i){if(Es(e))return new Ws(e,t);if($s(e)||Array.isArray(e)&&e.length>0){const s=Zs(e,t,r,n,i);if("error"===s.result)throw new Error(s.value.map(e=>`${e.key}: ${e.message}`).join(", "));return s.value}{let r=e;return "string"==typeof e&&"color"===t.type&&(r=dr.parse(e)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>r}}}(void 0===t?e.specification.default:t,e.specification,r,n,i);}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,r,n){return this.property.possiblyEvaluate(this,e,t,r,n)}}class no{constructor(e,t,r,n){this.property=e,this.value=new ro(e,void 0,t,r,n);}transitioned(e,t){return new so(this.property,this.value,t,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new so(this.property,this.value,null,{},0)}}class io{constructor(e,t,r,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=r,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set;}getValue(e){return qe(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new no(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new ro(this._values[e].property,null===t?void 0:qe(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent());}setTransitionOrValue(e,t){t&&(this._options=t);const r=this._properties.properties;if(e)for(const t in e){const n=e[t];if(t.endsWith("-transition")){const e=t.slice(0,-11);r[e]&&this.setTransition(e,n);}else r.hasOwnProperty(t)&&this.setValue(t,n);}}getTransition(e){return qe(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new no(this._values[e].property)),this._values[e].transition=qe(t)||void 0;}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r);const n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n);}return e}transitioned(e,t){const r=new ao(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(e,t._values[n]);return r}untransitioned(){const e=new ao(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class so{constructor(e,t,r,n,i){const s=n.delay||0,a=n.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+s,this.end=this.begin+a,e.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(e,t,r){const n=e.now||0,i=this.value.possiblyEvaluate(e,t,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n<this.begin)return s.possiblyEvaluate(e,t,r);{const a=(n-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(e,t,r),i,Fe(a))}}return i}}class ao{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues);}possiblyEvaluate(e,t,r){const n=new uo(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(e,t,r);return n}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return !0;return !1}}class oo{constructor(e,t,r,n){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=t,this._options=r,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set;}getValue(e){return qe(this._values[e].value)}setValue(e,t){this._values[e]=new ro(this._values[e].property,null===t?void 0:qe(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].isIndoorDependent());}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r);}return e}possiblyEvaluate(e,t,r,n){const i=new uo(this._properties);for(const s of Object.keys(this._values))i._values[s]=this._values[s].possiblyEvaluate(e,t,r,n);return i}isIndoorDependent(){return this._isIndoorDependent}}class lo{constructor(e,t,r,n){this.property=e,this.value=t,this.parameters=r,this.iconImageUseTheme=n;}isConstant(){return "constant"===this.value.kind}constantOr(e){return "constant"===this.value.kind?this.value.value:e}evaluate(e,t,r,n,i){return this.property.evaluate(this.value,this.parameters,e,t,r,n,this.iconImageUseTheme,i)}}class uo{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues);}get(e){return this._values[e]}}class co{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,r){const n=xr[this.specification.type];return n?n(e,t,r):e}}class ho{constructor(e,t){this.specification=e,this.overrides=t;}possiblyEvaluate(e,t,r,n,i){return "constant"===e.expression.kind||"camera"===e.expression.kind?new lo(this,{kind:"constant",value:e.expression.evaluate(t,null,{},r,n,void 0,i)},t):new lo(this,e.expression,t,i)}interpolate(e,t,r){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new lo(this,{kind:"constant",value:void 0},e.parameters);const n=xr[this.specification.type];return n?new lo(this,{kind:"constant",value:n(e.value.value,t.value.value,r)},e.parameters):e}evaluate(e,t,r,n,i,s,a,o){return "constant"===e.kind?e.value:e.evaluate(t,r,n,i,s,o,a)}}class po{constructor(e){this.specification=e;}possiblyEvaluate(e,t,r,n){return !!e.expression.evaluate(t,null,{},r,n)}interpolate(){return !1}}class fo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new to(0,{});for(const r in e){const n=e[r],i=n.specification;i&&i.overridable&&this.overridableProperties.push(r);const s=this.defaultPropertyValues[r]=new ro(n,void 0),a=this.defaultTransitionablePropertyValues[r]=new no(n);this.defaultTransitioningPropertyValues[r]=a.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=s.possiblyEvaluate(t);}}}ra(ho,"DataDrivenProperty"),ra(co,"DataConstantProperty"),ra(po,"ColorRampProperty");var mo=JSON.parse('{"$version":8,"$root":{"version":{"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"snow":{"type":"snow"},"rain":{"type":"rain"},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"indoor":{"type":"indoor"},"imports":{"type":"array","value":"import"},"iconsets":{"type":"iconsets"},"schema":{"type":"schema"},"sources":{"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"type":"featuresets"}},"featuresets":{"*":{"type":"featureset"}},"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","expression":{}},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string"},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false},"shadow-quality":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]}},"shadow-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"shadow-draw-before-layer":{"type":"string"}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"iconsets":{"*":{"type":"iconset"}},"iconset":["iconset_sprite","iconset_source"],"iconset_sprite":{"type":{"type":"enum","values":{"sprite":1}},"url":{"type":"string"}},"iconset_source":{"type":{"type":"enum","values":{"source":1}},"source":{"type":"string"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"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":{"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"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"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"type":"enum","values":{"video":1}},"urls":{"type":"array","value":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"type":"enum","values":{"image":1}},"url":{"type":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"modelNodeOverride":{"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360}},"modelNodeOverrides":{"*":{"type":"modelNodeOverride"}},"modelMaterialOverride":{"model-color":{"type":"color"},"model-color-mix-intensity":{"type":"number"},"model-opacity":{"type":"number"},"model-emissive-strength":{"type":"number"}},"modelMaterialOverrides":{"*":{"type":"modelMaterialOverride"}},"modelSourceModel":{"uri":{"type":"string"},"position":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[-180,-90],"maximum":[180,90]},"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360},"nodeOverrides":{"type":"modelNodeOverrides"},"materialOverrides":{"type":"modelMaterialOverrides"},"nodeOverrideNames":{"type":"array","value":"string"},"materialOverrideNames":{"type":"array","value":"string"},"featureProperties":{"type":"*"}},"modelSourceModels":{"*":{"type":"modelSourceModel"}},"source_model":{"type":{"type":"enum","values":{"model":1,"batched-model":1}},"url":{"type":"string"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"},"models":{"type":"modelSourceModels"}},"layer":{"id":{"type":"string"},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"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"},"appearances":{"type":"array","value":"appearance","supported-layer-types":["symbol"]}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":true,"parameters":["zoom","pitch","feature","feature-state","measure-light","distance-from-center"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_building","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"model-allow-density-reduction":{"type":"boolean","default":true}},"layout_clip":{"clip-layer-types":{"type":"array","value":"enum","values":{"model":1,"symbol":1},"default":[],"expression":{}},"clip-layer-scope":{"type":"array","value":"string","default":[],"expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"default":"none","expression":{}},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-markup":1},"default":"none","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"source-max-zoom":{"type":"number","minimum":0,"maximum":24}},"layout_building":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","minimum":1,"maximum":200,"default":3,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-unit-width":{"type":"number","minimum":1,"maximum":20,"default":3.1,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-window":{"type":"array","length":2,"value":"number","minimum":0.1,"maximum":1,"default":[0.9,0.9],"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-roof-shape":{"type":"enum","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"default":"flat","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flip-roof-orientation":{"property-type":"data-driven","type":"boolean","default":false,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1,"none":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["zoom","feature","line-progress"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"default":"none","expression":{}},"line-cross-slope":{"type":"number","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"line-width-unit":{"type":"enum","values":{"pixels":1,"meters":1},"default":"pixels","expression":{"parameters":["zoom"]}},"line-elevation-ground-scale":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","line-progress"]},"transition":true,"property-type":"data-driven"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{"parameters":["zoom"]}},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"appearance":true,"use-theme":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]}},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_hillshade":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster-particle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_clip":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_model":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_building":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"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":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"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","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","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_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"line-blend-mode":{"type":"enum","values":{"default":1,"multiply":1,"additive":1},"default":"default","expression":{"parameters":["zoom"]}}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"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","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"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"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}},"model-ignore-line-cutout":{"type":"boolean","default":false,"expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function yo(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function go(e){if(Array.isArray(e))return e.map(go);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const r in e)t[r]=go(e[r]);return t}return yo(e)}function xo(e){if(!0===e||!1===e)return !0;if(!Array.isArray(e)||0===e.length)return !1;switch(e[0]){case "has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case "in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case "any":case "all":for(const t of e.slice(1))if(!xo(t)&&"boolean"!=typeof t)return !1;return !0;default:return !0}}function vo(e,t="",r=null,n="fill"){if(null==e)return {filter:()=>!0,needGeometry:!1,needFeature:!1};xo(e)||(e=So(e));const i=e;let s=!0;try{s=function(e){if(!_o(e))return e;let t=go(e);return wo(t),t=bo(t),t}(i);}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n        `);}let a=null,o=null;if("background"!==n&&"sky"!==n&&"slot"!==n){o=mo[`filter_${n}`];const e=qs(s,o,t,r);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(t,r,n)=>e.value.evaluate(t,r,{},n);}let l=null,u=null;if(s!==i){const e=qs(i,o,t,r);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));l=(t,r,n,i,s)=>e.value.evaluate(t,r,{},n,void 0,void 0,i,s),u=!bi(e.value.expression);}return {filter:a,dynamicFilter:l||void 0,needGeometry:Mo(s),needFeature:!!u}}function bo(e){if(!Array.isArray(e))return e;const t=function(e){if(Ao.has(e[0]))for(let t=1;t<e.length;t++)if(_o(e[t]))return !0;return e}(e);return !0===t?t:t.map(e=>bo(e))}function wo(e){let t=!1;const r=[];if("case"===e[0]){for(let n=1;n<e.length-1;n+=2)t=t||_o(e[n]),r.push(e[n+1]);r.push(e[e.length-1]);}else if("match"===e[0]){t=t||_o(e[1]);for(let t=2;t<e.length-1;t+=2)r.push(e[t+1]);r.push(e[e.length-1]);}else if("step"===e[0]){t=t||_o(e[1]);for(let t=1;t<e.length-1;t+=2)r.push(e[t+1]);}t&&(e.length=0,e.push("any",...r));for(let t=1;t<e.length;t++)wo(e[t]);}function _o(e){if(!Array.isArray(e))return !1;if("pitch"===(t=e[0])||"distance-from-center"===t)return !0;var t;for(let t=1;t<e.length;t++)if(_o(e[t]))return !0;return !1}const Ao=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Io(e,t){return e<t?-1:e>t?1:0}function Mo(e){if(!Array.isArray(e))return !1;if("within"===e[0]||"distance"===e[0])return !0;for(let t=1;t<e.length;t++)if(Mo(e[t]))return !0;return !1}function So(e){if(!e)return !0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?Bo(e[1],e[2],"=="):"!="===t?zo(Bo(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?Bo(e[1],e[2],t):"any"===t?(r=e.slice(1),["any"].concat(r.map(So))):"all"===t?["all"].concat(e.slice(1).map(So)):"none"===t?["all"].concat(e.slice(1).map(So).map(zo)):"in"===t?Po(e[1],e.slice(2)):"!in"===t?zo(Po(e[1],e.slice(2))):"has"===t?To(e[1]):"!has"!==t||zo(To(e[1]));var r;}function Bo(e,t,r){switch(e){case "$type":return [`filter-type-${r}`,t];case "$id":return [`filter-id-${r}`,t];default:return [`filter-${r}`,e,t]}}function Po(e,t){if(0===t.length)return !1;switch(e){case "$type":return ["filter-type-in",["literal",t]];case "$id":return ["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(Io)]]:["filter-in-small",e,["literal",t]]}}function To(e){switch(e){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",e]}}function zo(e){return ["!",e]}const ko="";function Fo(e,t){return t?`${e}${ko}${t}`:e}function Vo(e){const t=e.indexOf(ko);return t>=0?e.slice(t+1):""}let Do;const Eo=()=>Do||(Do=new fo({"icon-size":new ho(mo.layout_symbol["icon-size"]),"icon-image":new ho(mo.layout_symbol["icon-image"]),"icon-rotate":new ho(mo.layout_symbol["icon-rotate"]),"icon-offset":new ho(mo.layout_symbol["icon-offset"]),"text-size":new ho(mo.layout_symbol["text-size"]),"text-rotate":new ho(mo.layout_symbol["text-rotate"]),"text-offset":new ho(mo.layout_symbol["text-offset"])}));let Co;const Ro=()=>Co||(Co=new fo({"icon-opacity":new ho(mo.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ho(mo.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ho(mo.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ho(mo.paint_symbol["text-emissive-strength"]),"icon-color":new ho(mo.paint_symbol["icon-color"]),"icon-halo-color":new ho(mo.paint_symbol["icon-halo-color"]),"icon-halo-width":new ho(mo.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ho(mo.paint_symbol["icon-halo-blur"]),"icon-translate":new ho(mo.paint_symbol["icon-translate"]),"text-opacity":new ho(mo.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ho(mo.paint_symbol["text-occlusion-opacity"]),"text-color":new ho(mo.paint_symbol["text-color"],{runtimeType:Mr,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ho(mo.paint_symbol["text-halo-color"]),"text-halo-width":new ho(mo.paint_symbol["text-halo-width"]),"text-halo-blur":new ho(mo.paint_symbol["text-halo-blur"]),"text-translate":new ho(mo.paint_symbol["text-translate"]),"symbol-z-offset":new ho(mo.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}));class Lo{constructor(e,t,r,n,i,s){this._conditionSpec=e,this._propertiesSpec=r;const a=qs(e,mo.appearance.condition);if("success"===a.result&&(this.condition=a.value),this.name=t,r){this.layoutProperties=new uo(Eo()),this.unevaluatedLayout=new oo(Eo(),n,i,s),this.paintProperties=new uo(Ro()),this.unevaluatedPaint=new oo(Ro(),n,i,"");for(const e in r)e in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(e,r[e]):e in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(e,r[e]);}}isActive(e){return !(this.condition||!e.isHidden||"hidden"!==this.name)||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,t,r){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,r)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,t,""));}serialize(){const e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);const t=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},r=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},n=Object.assign({},t,r);return Object.keys(n).length>0&&(e.properties=n),e}hasIconLayoutProperties(){const e=this.hasLayoutProperty("icon-image"),t=this.hasLayoutProperty("icon-size"),r=this.hasLayoutProperty("icon-offset"),n=this.hasLayoutProperty("icon-rotate");return e||t||r||n}hasTextLayoutProperties(){const e=this.hasLayoutProperty("text-size"),t=this.hasLayoutProperty("text-offset"),r=this.hasLayoutProperty("text-rotate");return e||t||r}hasIconPaintProperties(){return !!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasTextPaintProperties(){return !!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&void 0!==this.unevaluatedLayout._values[e].value}hasPaintProperty(e){return this.unevaluatedPaint&&void 0!==this.unevaluatedPaint._values[e].value}}const Oo="-transition",Uo=new Set(["fill","line","background","hillshade","raster"]);class No extends or{constructor(e,t,r,n,i,s){if(super(),this.id=e.id,this.fqid=Fo(this.id,r),this.type=e.type,this.scope=r,this.lut=n,this.options=i,this.iconImageUseTheme=s,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},"custom"!==e.type){if(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type){this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter;const t=qs(this.filter,mo[`filter_${e.type}`]);"error"!==t.result&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...t.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||t.value.isIndoorDependent);}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new oo(t.layout,this.scope,i,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),t.paint){this._transitionablePaint=new io(t.paint,this.scope,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new uo(t.paint);}}}onAdd(e){}onRemove(e){}isDraped(e){return !this.is3D(!0)&&Uo.has(this.type)}getLayoutProperty(e){return "visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),"visibility"===e&&this.possiblyEvaluateVisibility());}setAppearances(e){this.appearances=[],e.forEach(e=>{this.appearances.push(new Lo(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme));}),this.appearancesVersion++;}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}));}getPaintProperty(e){return e.endsWith(Oo)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return !!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const r=this._transitionablePaint,n=r._properties.properties;if(e.endsWith(Oo)){const i=e.slice(0,-11);return n[i]&&r.setTransition(i,t||void 0),!1}if(!n[e])return !1;const i=r._values[e],s=i.value.isDataDriven(),a=i.value;r.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);const o=r._values[e].value,l=o.isDataDriven(),u=e.endsWith("pattern")||"line-dasharray"===e;return l||s||u||this._handleOverridablePaintPropertyUpdate(e,a,o)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,r){return null}_handleOverridablePaintPropertyUpdate(e,t,r){return !1}isHidden(e){return !!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t);}serialize(){const e={id:this.id,type:this.type,slot:this.slot,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 0!==this.appearances.length&&(e.appearances=this.appearances.map(e=>e.serialize())),$e(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}is3D(e){return !1}hasElevation(){return !1}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof lo&&ks(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return !0}for(const e of this.appearances)if(!wi(e.condition.expression))return !0;return !1}compileFilter(e){this._filterCompiled||(this._featureFilter=vo(this.filter,this.scope,e),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}getAppearances(){return this.appearances}queryRenderedFeatures(e,t,r){return {}}queryRadius(e){}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){}}const jo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Go{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}const $o=new ArrayBuffer(0);class qo{constructor(){this._reallocCount=0,this.capacity=0,this.length=0;}static serialize(e,t){return e._trim(),t&&e.arrayBuffer&&t.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,e.arrayBuffer?t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement:(t.capacity=0,t.arrayBuffer=$o),t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(e){this.reserve(e),this.length=e;}reserve(e){if(e>this.capacity){this._reallocCount++,this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t);}}reserveForAdditional(e){this.reserve(this.length+e);}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null;}}function Ho(e,t=1){let r=0,n=0;return {members:e.map(e=>{const i=jo[e.type].BYTES_PER_ELEMENT,s=r=Xo(r,Math.max(t,i)),a=e.components||1;return n=Math.max(n,i),r+=i*a,{name:e.name,type:e.type,components:a,offset:s}}),size:Xo(r,Math.max(n,t)),alignment:t}}function Xo(e,t){return Math.ceil(e/t)*t}class Zo extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.int16[n+0]=t,this.int16[n+1]=r,e}}Zo.prototype.bytesPerElement=4,ra(Zo,"StructArrayLayout2i4");class Wo extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}Wo.prototype.bytesPerElement=6,ra(Wo,"StructArrayLayout3i6");class Yo extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,e}}Yo.prototype.bytesPerElement=8,ra(Yo,"StructArrayLayout2i2ui8");class Jo extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Jo.prototype.bytesPerElement=4,ra(Jo,"StructArrayLayout1f4");class Ko extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e,s=2*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.float32[s+1]=n,e}}Ko.prototype.bytesPerElement=8,ra(Ko,"StructArrayLayout2i1f8");class Qo extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}Qo.prototype.bytesPerElement=8,ra(Qo,"StructArrayLayout3i8");class el extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,e}}el.prototype.bytesPerElement=8,ra(el,"StructArrayLayout4i8");class tl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=5*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=s,e}}tl.prototype.bytesPerElement=10,ra(tl,"StructArrayLayout5i10");class rl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=s,this.uint8[u+7]=a,this.float32[c+2]=o,e}}rl.prototype.bytesPerElement=12,ra(rl,"StructArrayLayout2i4ub1f12");class nl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=r,this.float32[i+2]=n,e}}nl.prototype.bytesPerElement=12,ra(nl,"StructArrayLayout3f12");class il extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=6*e,o=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=r,this.uint16[a+2]=n,this.uint16[a+3]=i,this.float32[o+2]=s,e}}il.prototype.bytesPerElement=12,ra(il,"StructArrayLayout4ui1f12");class sl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.uint16[s+0]=t,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,e}}sl.prototype.bytesPerElement=8,ra(sl,"StructArrayLayout4ui8");class al extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=6*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,e}}al.prototype.bytesPerElement=12,ra(al,"StructArrayLayout6i12");class ol extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,r,n,i,s,a,o,l,u,c,h)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=r,this.int16[p+2]=n,this.int16[p+3]=i,this.uint16[p+4]=s,this.uint16[p+5]=a,this.uint16[p+6]=o,this.uint16[p+7]=l,this.int16[p+8]=u,this.int16[p+9]=c,this.int16[p+10]=h,this.int16[p+11]=d,e}}ol.prototype.bytesPerElement=24,ra(ol,"StructArrayLayout4i4ui4i24");class ll extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=10*e,l=5*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,e}}ll.prototype.bytesPerElement=20,ra(ll,"StructArrayLayout3i3f20");class ul extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.float32[s+0]=t,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,e}}ul.prototype.bytesPerElement=16,ra(ul,"StructArrayLayout4f16");class cl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}cl.prototype.bytesPerElement=4,ra(cl,"StructArrayLayout1ul4");class hl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=r,e}}hl.prototype.bytesPerElement=4,ra(hl,"StructArrayLayout2ui4");class dl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,r,n,i,s,a,o,l,u,c,h,d)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.int16[f+4]=s,this.float32[m+3]=a,this.float32[m+4]=o,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[f+14]=c,this.uint32[m+8]=h,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}dl.prototype.bytesPerElement=40,ra(dl,"StructArrayLayout5i4f1i1ul2ui40");class pl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=s,this.int16[l+6]=a,this.int16[l+7]=o,e}}pl.prototype.bytesPerElement=16,ra(pl,"StructArrayLayout3i2i2i16");class fl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=4*e,o=8*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,e}}fl.prototype.bytesPerElement=16,ra(fl,"StructArrayLayout2f1f2i16");class ml extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=20*e,l=5*e;return this.uint8[o+0]=t,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,e}}ml.prototype.bytesPerElement=20,ra(ml,"StructArrayLayout2ub4f20");class yl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=r,this.uint16[i+2]=n,e}}yl.prototype.bytesPerElement=6,ra(yl,"StructArrayLayout3ui6");class gl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b){const w=this.length;return this.resize(w+1),this.emplace(w,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w){const _=30*e,A=15*e,I=60*e;return this.int16[_+0]=t,this.int16[_+1]=r,this.int16[_+2]=n,this.float32[A+2]=i,this.float32[A+3]=s,this.uint16[_+8]=a,this.uint16[_+9]=o,this.uint32[A+5]=l,this.uint32[A+6]=u,this.uint32[A+7]=c,this.uint16[_+16]=h,this.uint16[_+17]=d,this.uint16[_+18]=p,this.float32[A+10]=f,this.float32[A+11]=m,this.uint8[I+48]=y,this.uint8[I+49]=g,this.uint8[I+50]=x,this.uint32[A+13]=v,this.int16[_+28]=b,this.uint8[I+58]=w,e}}gl.prototype.bytesPerElement=60,ra(gl,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class xl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,I,M,S,B,P,T,z,k,F){const V=this.length;return this.resize(V+1),this.emplace(V,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,I,M,S,B,P,T,z,k,F)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,I,M,S,B,P,T,z,k,F,V){const D=20*e,E=40*e,C=80*e;return this.float32[D+0]=t,this.float32[D+1]=r,this.int16[E+4]=n,this.int16[E+5]=i,this.int16[E+6]=s,this.int16[E+7]=a,this.int16[E+8]=o,this.int16[E+9]=l,this.int16[E+10]=u,this.int16[E+11]=c,this.int16[E+12]=h,this.uint16[E+13]=d,this.uint16[E+14]=p,this.uint16[E+15]=f,this.uint16[E+16]=m,this.uint16[E+17]=y,this.uint16[E+18]=g,this.uint16[E+19]=x,this.uint16[E+20]=v,this.uint16[E+21]=b,this.uint16[E+22]=w,this.uint16[E+23]=_,this.uint16[E+24]=A,this.uint16[E+25]=I,this.uint16[E+26]=M,this.uint16[E+27]=S,this.uint32[D+14]=B,this.float32[D+15]=P,this.float32[D+16]=T,this.float32[D+17]=z,this.float32[D+18]=k,this.uint8[C+76]=F,this.uint16[E+39]=V,e}}xl.prototype.bytesPerElement=80,ra(xl,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class vl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=6*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=n,this.float32[o+3]=i,this.float32[o+4]=s,this.float32[o+5]=a,e}}vl.prototype.bytesPerElement=24,ra(vl,"StructArrayLayout6f24");class bl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,this.float32[a+4]=s,e}}bl.prototype.bytesPerElement=20,ra(bl,"StructArrayLayout5f20");class wl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=s,this.float32[l+5]=a,this.float32[l+6]=o,e}}wl.prototype.bytesPerElement=28,ra(wl,"StructArrayLayout7f28");class _l extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,n,i,s,a,o,l,u,c)}emplace(e,t,r,n,i,s,a,o,l,u,c,h){const d=11*e;return this.float32[d+0]=t,this.float32[d+1]=r,this.float32[d+2]=n,this.float32[d+3]=i,this.float32[d+4]=s,this.float32[d+5]=a,this.float32[d+6]=o,this.float32[d+7]=l,this.float32[d+8]=u,this.float32[d+9]=c,this.float32[d+10]=h,e}}_l.prototype.bytesPerElement=44,ra(_l,"StructArrayLayout11f44");class Al extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,r,n,i,s,a,o,l)}emplace(e,t,r,n,i,s,a,o,l,u){const c=9*e;return this.float32[c+0]=t,this.float32[c+1]=r,this.float32[c+2]=n,this.float32[c+3]=i,this.float32[c+4]=s,this.float32[c+5]=a,this.float32[c+6]=o,this.float32[c+7]=l,this.float32[c+8]=u,e}}Al.prototype.bytesPerElement=36,ra(Al,"StructArrayLayout9f36");class Il extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.float32[n+0]=t,this.float32[n+1]=r,e}}Il.prototype.bytesPerElement=8,ra(Il,"StructArrayLayout2f8");class Ml extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=6*e;return this.uint32[3*e+0]=t,this.uint16[s+2]=r,this.uint16[s+3]=n,this.uint16[s+4]=i,e}}Ml.prototype.bytesPerElement=12,ra(Ml,"StructArrayLayout1ul3ui12");class Sl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Sl.prototype.bytesPerElement=2,ra(Sl,"StructArrayLayout1ui2");class Bl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=s,this.float32[g+5]=a,this.float32[g+6]=o,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=y,e}}Bl.prototype.bytesPerElement=64,ra(Bl,"StructArrayLayout16f64");class Pl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=10*e,u=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=s,this.float32[u+3]=a,this.float32[u+4]=o,e}}Pl.prototype.bytesPerElement=20,ra(Pl,"StructArrayLayout4ui3f20");class Tl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}Tl.prototype.bytesPerElement=2,ra(Tl,"StructArrayLayout1i2");class zl extends qo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}zl.prototype.bytesPerElement=1,ra(zl,"StructArrayLayout1ub1");class kl extends Go{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]}}kl.prototype.size=40;class Fl extends dl{get(e){return new kl(this,e)}}ra(Fl,"CollisionBoxArray");class Vl extends Go{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e;}}Vl.prototype.size=60;class Dl extends gl{get(e){return new Vl(this,e)}}ra(Dl,"PlacedSymbolArray");class El extends Go{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}El.prototype.size=80;class Cl extends xl{get(e){return new El(this,e)}}ra(Cl,"SymbolInstanceArray");class Rl extends Jo{getoffsetX(e){return this.float32[1*e+0]}}ra(Rl,"GlyphOffsetArray");class Ll extends Zo{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}ra(Ll,"SymbolLineVertexArray");class Ol extends Go{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]}}Ol.prototype.size=12;class Ul extends Ml{get(e){return new Ol(this,e)}}ra(Ul,"FeatureIndexArray");class Nl extends hl{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}ra(Nl,"FillExtrusionCentroidArray");class jl extends Go{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}jl.prototype.size=6;class Gl extends Wo{get(e){return new jl(this,e)}}ra(Gl,"FillExtrusionWallArray");const $l=Ho([{name:"a_pos",components:2,type:"Int16"}],4),ql=Ho([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Hl=Ho([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Xl{constructor(e=[]){this.segments=e;}_prepareSegment(e,t,r,n,i){let s=this.segments[this.segments.length-1];return e>Xl.MAX_VERTEX_ARRAY_LENGTH&&Ze(`Max vertices per segment is ${Xl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!s||s.vertexLength+e>Xl.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==n||void 0!==i&&s&&void 0!==s.batchIndex&&s.batchIndex!==i)&&(s={vertexOffset:t,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(s.sortKey=n),void 0!==i&&(s.batchIndex=i),this.segments.push(s)),s}prepareSegment(e,t,r,n,i){return this._prepareSegment(e,t.length,r.length,n,i)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy();}static simpleSegment(e,t,r,n){return new Xl([{vertexOffset:e,primitiveOffset:t,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Zl(e,t){return 256*(e=Ee(Math.floor(e),0,255))+Ee(Math.floor(t),0,255)}Xl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ra(Xl,"SegmentVector");const Wl=Ho([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Yl=Ho([{name:"a_pattern_b",components:4,type:"Uint16"}]),Jl=Ho([{name:"a_dash",components:4,type:"Uint16"}]);class Kl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(e,t,r,n){this.ids.push(Ql(e)),this.positions.push(t,r,n);}eachPosition(e,t){const r=Ql(e);let n=0,i=this.ids.length-1;for(;n<i;){const e=n+i>>1;this.ids[e]>=r?i=e:n=e+1;}for(;this.ids[n]===r;)t(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(e,t){const r=new Float64Array(e.ids),n=new Uint32Array(e.positions);return eu(r,n,0,r.length-1),t&&(t.add(r.buffer),t.add(n.buffer)),{ids:r,positions:n}}static deserialize(e){const t=new Kl;let r;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==r&&t.uniqueIds.push(e),r=e;return t.indexed=!0,t}}function Ql(e){const t=+e;return Number.isSafeInteger(t)?t:rr(String(e))}function eu(e,t,r,n){for(;r<n;){const i=e[r+n>>1];let s=r-1,a=n+1;for(;;){do{s++;}while(e[s]<i);do{a--;}while(e[a]>i);if(s>=a)break;tu(e,s,a),tu(t,3*s,3*a),tu(t,3*s+1,3*a+1),tu(t,3*s+2,3*a+2);}a-r<n-a?(eu(e,t,r,a),r=a+1):(eu(e,t,a+1,n),n=a);}}function tu(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}ra(Kl,"FeaturePositionMap");class ru{constructor(e){this.gl=e.gl,this.initialized=!1;}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}set(e,t,r){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class nu extends ru{constructor(e){super(e),this.current=0;}set(e,t,r){this.fetchUniformLocation(e,t)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r));}}class iu extends ru{constructor(e){super(e),this.current=0;}set(e,t,r){this.fetchUniformLocation(e,t)&&this.current!==r&&(this.current=r,this.gl.uniform1f(this.location,r));}}class su extends ru{constructor(e){super(e),this.current=[0,0];}set(e,t,r){this.fetchUniformLocation(e,t)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])));}}class au extends ru{constructor(e){super(e),this.current=[0,0,0];}set(e,t,r){this.fetchUniformLocation(e,t)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2])));}}class ou extends ru{constructor(e){super(e),this.current=[0,0,0,0];}set(e,t,r){this.fetchUniformLocation(e,t)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4ui(this.location,r[0],r[1],r[2],r[3])));}}class lu extends ru{constructor(e){super(e),this.current=[0,0,0,0];}set(e,t,r){this.fetchUniformLocation(e,t)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4f(this.location,r[0],r[1],r[2],r[3])));}}class uu extends ru{constructor(e){super(e),this.current=dr.transparent.toPremultipliedRenderColor(null);}set(e,t,r){this.fetchUniformLocation(e,t)&&(r.r===this.current.r&&r.g===this.current.g&&r.b===this.current.b&&r.a===this.current.a||(this.current=r,this.gl.uniform4f(this.location,r.r,r.g,r.b,r.a)));}}const cu=new Float32Array(16);class hu extends ru{constructor(e){super(e),this.current=cu;}set(e,t,r){if(this.fetchUniformLocation(e,t)){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let e=1;e<16;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}}}const du=new Float32Array(9),pu=new Float32Array(4);class fu extends ru{constructor(e){super(e),this.current=pu;}set(e,t,r){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix2fv(this.location,!1,r);break}}}function mu(e){return [Zl(255*e.r,255*e.g),Zl(255*e.b,255*e.a)]}function yu(e,t,r,n,i,s,a,o){return !!e&&("composite"===e.kind||"source"===e.kind?"none"===e.evaluate(new to(0,{brightness:s,worldview:o}),t,r,i,n,a):"none"===e.value)}class gu{constructor(e,t,r,n){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=r,this.context=n;}setUniform(e,t,r,n,i){const s=n.constantOr(this.value);t.set(e,i,s instanceof dr?s.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):s);}getBinding(e,t){return "color"===this.type?new uu(e):new iu(e)}}class xu{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1;}setConstantPatternPositions(e,t){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=t?t.tl.concat(t.br):this.pattern;}setUniform(e,t,r,n,i){let s=null;"u_pattern"!==i&&"u_dash"!==i||(s=this.pattern),"u_pattern_b"===i&&(s=this.patternTransition),"u_pixel_ratio"===i&&(s=this.pixelRatio),s&&t.set(e,i,s);}getBinding(e,t){return "u_pattern"===t||"u_pattern_b"===t||"u_dash"===t?new ou(e):new iu(e)}}class vu{constructor(e,t,r,n){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?2:1,offset:0})),this.paintVertexArray=new n;}populatePaintArray(e,t,r,n,i,s,a,o){const l=this.paintVertexArray.length,u="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new to(0,{brightness:s,worldview:o}),t,{},i,n,a):"constant"===this.expression.kind&&this.expression.value,c=yu(this.lutExpression,t,{},n,i,s,a,o);this.paintVertexArray.resize(e),this._setPaintValue(l,e,u,c?null:this.context.lut);}updatePaintArray(e,t,r,n,i,s,a,o){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:a,worldview:o},r,n,void 0,i):"constant"===this.expression.kind&&this.expression.value,u=yu(this.lutExpression,r,n,i,void 0,a,void 0,o);this._setPaintValue(e,t,l,u?null:this.context.lut);}_setPaintValue(e,t,r,n){if("color"===this.type){const i=mu(r.toPremultipliedRenderColor(n));for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i[0],i[1]);}else {for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,r);this.maxValue=Math.max(this.maxValue,Math.abs(r));}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&"constant"!==this.lutExpression.kind&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||"constant"!==this.expression.kind&&(this.expression.isStateDependent||!this.expression.isLightConstant)));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}}class bu{constructor(e,t,r,n,i,s){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=r,this.useIntegerZoom=n,this.context=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?4:2,offset:0})),this.paintVertexArray=new s;}populatePaintArray(e,t,r,n,i,s,a,o){const l=this.expression.evaluate(new to(this.context.zoom,{brightness:s,worldview:o}),t,{},i,n,a),u=this.expression.evaluate(new to(this.context.zoom+1,{brightness:s,worldview:o}),t,{},i,n,a),c=yu(this.lutExpression,t,{},n,i,s,a,o),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,u,c?null:this.context.lut);}updatePaintArray(e,t,r,n,i,s,a,o){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:a,worldview:o},r,n,void 0,i),u=this.expression.evaluate({zoom:this.context.zoom+1,brightness:a,worldview:o},r,n,void 0,i),c=yu(this.lutExpression,r,n,i,void 0,a,void 0,o);this._setPaintValue(e,t,l,u,c?null:this.context.lut);}_setPaintValue(e,t,r,n,i){if("color"===this.type){const s=mu(r.toPremultipliedRenderColor(i)),a=mu(n.toPremultipliedRenderColor(i));for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,s[0],s[1],a[0],a[1]);}else {for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r,n);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(n));}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}setUniform(e,t,r,n,i){const s=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,a=Ee(this.expression.interpolationFactor(s,this.context.zoom,this.context.zoom+1),0,1);t.set(e,i,a);}getBinding(e,t){return new iu(e)}}class wu{constructor(e,t,r,n,i){this.expression=e,this.layerId=i,this.paintVertexAttributes=("array"===r?Jl:Wl).members;for(let e=0;e<t.length;++e);this.paintVertexArray=new n,this.paintTransitionVertexArray=new sl;}populatePaintArray(e,t,r,n){const i=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(i,e,t.patterns&&t.patterns[this.layerId],r);}updatePaintArray(e,t,r,n,i,s,a){this._setPaintValues(e,t,r.patterns&&r.patterns[this.layerId],s);}_setPaintValues(e,t,r,n){if(!n||!r)return;const i=n[r[0]],s=n[r[1]];if(i){if(i){const{tl:r,br:n,pixelRatio:s}=i;for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1],n[0],n[1],s);}if(s){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);const{tl:r,br:n}=s;for(let i=e;i<t;i++)this.paintTransitionVertexArray.emplace(i,r[0],r[1],n[0],n[1]);}}}upload(e){const t=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,t)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=e.createVertexBuffer(this.paintTransitionVertexArray,Yl.members,t));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy();}}class _u{constructor(e,t,r=()=>!0){this.binders={},this._buffers=[],this.context=t;const n=[],i=e;for(const s in e.paint._values){const a=i.paint.get(s);if(s.endsWith("-use-theme"))continue;if(!r(s))continue;if(!(a instanceof lo&&ks(a.property.specification)))continue;const o=Mu(s,e.type),l=a.value,u=a.property.specification.type,c=!!a.property.useIntegerZoom,h="line-dasharray"===s||s.endsWith("pattern"),d=i.paint.get(`${s}-use-theme`),p="line-dasharray"===s&&"constant"!==i.layout.get("line-cap").value.kind||d&&"constant"!==d.value.kind;if("constant"!==l.kind||p)if("source"===l.kind||p||h){const t=Pu(s,u,"source");this.binders[s]=h?new wu(l,o,u,t,e.id):new vu(l,o,u,t),n.push(`/a_${s}`);}else {const e=Pu(s,u,"composite");this.binders[s]=new bu(l,o,u,c,t,e),n.push(`/z_${s}`);}else this.binders[s]=h?new xu(l.value,o):new gu(l.value,o,u,t),n.push(`/u_${s}`);d&&(this.binders[s].lutExpression=d.value);}this.cacheKey=n.sort().join("");}getMaxValue(e){const t=this.binders[e];return t instanceof vu||t instanceof bu?t.maxValue:0}populatePaintArrays(e,t,r,n,i,s,a,o){for(const l in this.binders){const u=this.binders[l];u.context=this.context,(u instanceof vu||u instanceof bu||u instanceof wu)&&u.populatePaintArray(e,t,r,n,i,s,a,o);}}setConstantPatternPositions(e,t){for(const r in this.binders){const n=this.binders[r];n instanceof xu&&n.setConstantPatternPositions(e,t);}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof wu?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,r,n,i,s,a,o,l,u){let c=!1;const h=Object.keys(e),d=0!==h.length&&!o,p=d?h:t.uniqueIds;this.context.lut=i.lut;for(const o in this.binders){const h=this.binders[o];if(h.context=this.context,(h instanceof vu||h instanceof bu||h instanceof wu)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=i.paint.get(o);h.expression=f.value;for(const r of p){const i=e[r.toString()];t.eachPosition(r,(e,t,r)=>{const o=n.feature(e);h.updatePaintArray(t,r,o,i,s,a,l,u);});}if(!d)for(const t of r.uniqueIds){const i=e[t.toString()];r.eachPosition(t,(e,t,r)=>{const o=n.feature(e);h.updatePaintArray(t,r,o,i,s,a,l,u);});}c=!0;}}return c}defines(){const e=[];for(const t in this.binders){const r=this.binders[t];(r instanceof gu||r instanceof xu)&&e.push(...r.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`));}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof gu||n instanceof xu||n instanceof bu)for(const i of n.uniformNames)t.push({name:i,property:r,binding:n.getBinding(e,i)});}return t}setUniforms(e,t,r,n,i){for(const{name:t,property:s,binding:a}of r)this.binders[s].setUniform(e,a,i,n.get(s),t);}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof vu||t instanceof bu||t instanceof wu)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof wu&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer);}}upload(e){for(const t in this.binders){const r=this.binders[t];(r instanceof vu||r instanceof bu||r instanceof wu)&&r.upload(e);}this.updatePaintBuffers();}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof vu||t instanceof bu||t instanceof wu)&&t.destroy();}}}class Au{constructor(e,t,r=()=>!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new _u(n,t,r);this.needsUpload=!1,this._featureMap=new Kl,this._featureMapWithoutIds=new Kl,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(e,t,r,n,i,s,a,o,l){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(e,t,n,i,s,a,o,l);void 0!==t.id?this._featureMap.add(t.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0;}updatePaintArrays(e,t,r,n,i,s,a,o){for(const l of r)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,n,i,s,a||0,o)||this.needsUpload;}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1;}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy();}}const Iu={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function Mu(e,t){return Iu[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Su={"line-pattern":{source:il,composite:il},"fill-pattern":{source:il,composite:il},"fill-extrusion-pattern":{source:il,composite:il},"line-dasharray":{source:sl,composite:sl}},Bu={color:{source:Il,composite:ul},number:{source:Jo,composite:Il}};function Pu(e,t,r){const n=Su[e];return n&&n[r]||Bu[t][r]}ra(gu,"ConstantBinder"),ra(xu,"PatternConstantBinder"),ra(vu,"SourceExpressionBinder"),ra(wu,"PatternCompositeBinder"),ra(bu,"CompositeExpressionBinder"),ra(_u,"ProgramConfiguration",{omit:["_buffers"]}),ra(Au,"ProgramConfigurationSet");const Tu=qn/Math.PI/2,zu=64,ku=[zu,32,16],Fu=-Tu,Vu=Tu;function Du(e,t,r,n=Tu){return r=Te(r),[e*Math.sin(r)*n,-t*n,e*Math.cos(r)*n]}function Eu(e,t,r){return Du(Math.cos(Te(e)),Math.sin(Te(e)),t,r)}const Cu=6371008.8,Ru=2*Math.PI*Cu;class Lu{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Lu(Re(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,r=this.lat*t,n=e.lat*t,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return Cu*Math.acos(Math.min(i,1))}toBounds(e=0){const t=360*e/40075017,r=t/Math.cos(Math.PI/180*this.lat);return new Ou({lng:this.lng-r,lat:this.lat-t},{lng:this.lng+r,lat:this.lat+t})}toEcef(e){return Eu(this.lat,this.lng,Tu+e*Tu/Cu)}static convert(e){if(e instanceof Lu)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Lu(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Lu(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class Ou{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]));}setNorthEast(e){return this._ne=e instanceof Lu?new Lu(e.lng,e.lat):Lu.convert(e),this}setSouthWest(e){return this._sw=e instanceof Lu?new Lu(e.lng,e.lat):Lu.convert(e),this}extend(e){const t=this._sw,r=this._ne;let n,i;if(e instanceof Lu)n=e,i=e;else {if(!(e instanceof Ou))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Ou.convert(e)):this.extend(Lu.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(Lu.convert(e)):this;if(n=e._sw,i=e._ne,!n||!i)return this}return t||r?(t.lng=Math.min(n.lng,t.lng),t.lat=Math.min(n.lat,t.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new Lu(n.lng,n.lat),this._ne=new Lu(i.lng,i.lat)),this}getCenter(){return new Lu((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 Lu(this.getWest(),this.getNorth())}getSouthEast(){return new Lu(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:t,lat:r}=Lu.convert(e);let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(e){if(e)return e instanceof Ou?e:new Ou(e)}}function Uu(e){return Ru*Math.cos(e*Math.PI/180)}function Nu(e){return (180+e)/360}function ju(e){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Gu(e,t){return e/Uu(t)}function $u(e){return 360*e-180}function qu(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Hu(e,t){return e*Uu(qu(t))}const Xu=85.051129;function Zu(e){return Math.cos(Te(Ee(e,-85.051129,Xu)))}function Wu(e,t){const r=Ee(t,0,25.5),n=Math.pow(2,r);return Zu(e)*Ru/(512*n)}function Yu(e){return 1/Math.cos(e*Math.PI/180)}function Ju(e,t=0){const r=Math.exp(Math.PI*(1-(e.y+t/qn)/(1<<e.z)*2));return 80150034*r/(r*r+1)/qn/(1<<e.z)}class Ku{constructor(e,t,r=0){this.x=+e,this.y=+t,this.z=+r;}static fromLngLat(e,t=0){const r=Lu.convert(e);return new Ku(Nu(r.lng),ju(r.lat),Gu(t,r.lat))}toLngLat(){return new Lu($u(this.x),qu(this.y))}toAltitude(){return Hu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ru*Yu(qu(this.y))}}function Qu(e,t,r,n,i,s,a,o,l){const u=(t+n)/2,c=(r+i)/2,h=new Me(u,c);o(h),function(e,t,r,n,i,s){const a=r-i,o=n-s;return Math.abs((n-t)*a-(r-e)*o)/Math.hypot(a,o)}(h.x,h.y,s.x,s.y,a.x,a.y)>=l?(Qu(e,t,r,u,c,s,h,o,l),Qu(e,u,c,n,i,h,a,o,l)):e.push(a);}function ec(e,t,r){let n=e[0],i=n.x,s=n.y;t(n);const a=[n];for(let o=1;o<e.length;o++){const l=e[o],{x:u,y:c}=l;t(l),Qu(a,i,s,u,c,n,l,t,r),i=u,s=c,n=l;}return a}function tc(e,t,r,n){if(n(t,r)){const i=t.add(r)._mult(.5);tc(e,t,i,n),tc(e,i,r,n);}else e.push(r);}function rc(e,t){let r=e[0];const n=[r];for(let i=1;i<e.length;i++){const s=e[i];tc(n,r,s,t),r=s;}return n}const nc=Math.pow(2,14)-1,ic=-nc-1;function sc(e,t){const r=Math.round(e.x*t),n=Math.round(e.y*t);return e.x=Ee(r,ic,nc),e.y=Ee(n,ic,nc),(r<e.x||r>e.x+1||n<e.y||n>e.y+1)&&Ze("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function ac(e,t,r){const n=e.loadGeometry(),i=e.extent,s=qn/i;if(t&&r&&r.projection.isReprojectedInTileSpace){const s=1<<t.z,{scale:a,x:o,y:l,projection:u}=r,c=e=>{const r=$u((t.x+e.x/i)/s),n=qu((t.y+e.y/i)/s),c=u.project(r,n);e.x=(c.x*a-o)*i,e.y=(c.y*a-l)*i;};for(let t=0;t<n.length;t++)if(1!==e.type)n[t]=ec(n[t],c,1);else {const e=[];for(const r of n[t])r.x<0||r.x>=i||r.y<0||r.y>=i||(c(r),e.push(r));n[t]=e;}}for(const e of n)for(const t of e)sc(t,s);return n}function oc(e,t){return {type:e.type,id:e.id,properties:e.properties,geometry:t?ac(e):[]}}class lc{constructor(e,t,r,n,i){this.properties={},this.extent=r,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=i,e.readFields(uc,this,t);}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,r=[];let n,i=1,s=0,a=0,o=0;for(;e.pos<t;){if(s<=0){const t=e.readVarint();i=7&t,s=t>>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(n&&r.push(n),n=[]),n&&n.push(new Me(a,o));else {if(7!==i)throw new Error(`unknown command ${i}`);n&&n.push(n[0].clone());}}return n&&r.push(n),r}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;for(;e.pos<t;){if(n<=0){const t=e.readVarint();r=7&t,n=t>>3;}if(n--,1===r||2===r)i+=e.readSVarint(),s+=e.readSVarint(),i<a&&(a=i),i>o&&(o=i),s<l&&(l=s),s>u&&(u=s);else if(7!==r)throw new Error(`unknown command ${r}`)}return [a,l,o,u]}toGeoJSON(e,t,r){const n=this.extent*Math.pow(2,r),i=this.extent*e,s=this.extent*t,a=this.loadGeometry();function o(e){return [360*(e.x+i)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/n)*Math.PI))-90]}function l(e){return e.map(o)}let u;if(1===this.type){const e=[];for(const t of a)e.push(t[0]);const t=l(e);u=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};}else if(2===this.type){const e=a.map(l);u=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};}else {if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return [e];const r=[];let n,i;for(let s=0;s<t;s++){const t=cc(e[s]);0!==t&&(void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e[s]]):n&&n.push(e[s]));}return n&&r.push(n),r}(a),t=[];for(const r of e)t.push(r.map(l));u=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t};}}const c={type:"Feature",geometry:u,properties:this.properties};return null!=this.id&&(c.id=this.id),c}}function uc(e,t,r){1===e?t.id=r.readVarint():2===e?function(e,t){const r=e.readVarint()+e.pos;for(;e.pos<r;){const r=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[r]=n;}}(r,t):3===e?t.type=r.readVarint():4===e&&(t._geometry=r.pos);}function cc(e){let t=0;for(let r,n,i=0,s=e.length,a=s-1;i<s;a=i++)r=e[i],n=e[a],t+=(n.x-r.x)*(r.y+n.y);return t}lc.types=["Unknown","Point","LineString","Polygon"];class hc{constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(dc,this,t),this.length=this._features.length;}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new lc(this._pbf,t,this.extent,this._keys,this._values)}}function dc(e,t,r){15===e?t.version=r.readVarint():1===e?t.name=r.readString():5===e?t.extent=r.readVarint():2===e?t._features.push(r.pos):3===e?t._keys.push(r.readString()):4===e&&t._values.push(function(e){let t=null;const r=e.readVarint()+e.pos;for(;e.pos<r;){const r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null;}if(null==t)throw new Error("unknown feature value");return t}(r));}class pc{constructor(e,t){this.layers=e.readFields(fc,{},t);}}function fc(e,t,r){if(3===e){const e=new hc(r,r.readVarint()+r.pos);e.length&&(t[e.name]=e);}}const mc="3d_elevation_id",yc="level";class gc{constructor(){this._valid=!1;}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),0!==this._geometry.length&&0!==this._geometry[0].length||(this._valid=!1),this}geometry(e,t){return this._valid&&e(t(this._geometry)),this}require(e,t,r){return this.get(e,!0,t,r)}optional(e,t,r){return this.get(e,!1,t,r)}success(){return this._valid}get(e,t,r,n){const i=this.feature.properties.hasOwnProperty(e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==i&&!Number.isNaN(i)?r(n?n(i):i):t&&(this._valid=!1),this}}class xc{constructor(e,t){this.featureFunc=e,this.vertexFunc=t;}parseFeature(e,t,r){return this.featureFunc(e,t,r)}parseVertex(e,t,r){return this.vertexFunc(e,t,r)}}const vc=new xc((e,t,r)=>e.reset(t).require(mc,e=>{r.id=e;}).optional("fixed_height_relative",e=>{r.constantHeight=e;},wc.decodeRelativeHeight).geometry(e=>{r.bounds=e;},An).success(),(e,t,r)=>e.reset(t).require(mc,e=>{r.id=e;}).require("elevation_idx",e=>{r.idx=e;}).require("extent",e=>{r.extent=e;}).require("height_relative",e=>{r.height=e;},wc.decodeRelativeHeight).geometry(e=>{r.position=e;},wc.getPoint).success()),bc=new xc((e,t,r)=>e.reset(t).require(mc,e=>{r.id=e;}).optional("fixed_height",e=>{r.constantHeight=e;},wc.decodeMetricHeight).geometry(e=>{r.bounds=e;},An).success(),(e,t,r)=>e.reset(t).require(mc,e=>{r.id=e;}).require("elevation_idx",e=>{r.idx=e;}).require("extent",e=>{r.extent=e;}).require("height",e=>{r.height=e;},wc.decodeMetricHeight).geometry(e=>{r.position=e;},wc.getPoint).success());class wc{static getPoint(e){return he(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?"1.0.1"===e?bc:void 0:vc}static parse(e){const t=[],r=[],n=e.length,i=new gc;for(let s=0;s<n;s++){const n=e.feature(s),a=n.properties.version,o=wc.getVersionSchema(a);if(void 0===o){Ze(`Unknown elevation feature version number ${a||"(unknown)"}`);continue}const l=n.properties.type;if(!l)continue;const u=lc.types[n.type];if("Point"===u&&"curve_point"===l){const e={};o.parseVertex(i,n,e)&&t.push(e);}else if("Polygon"===u&&"curve_meta"===l){const e={};o.parseFeature(i,n,e)&&r.push(e);}}return {vertices:t,features:r}}}class _c{constructor(e,t){this.pos=e,this.dir=t;}intersectsPlane(e,t,r){const n=xe(t,this.dir);if(Math.abs(n)<1e-6)return !1;const i=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1])/n;return r[0]=this.pos[0]+this.dir[0]*i,r[1]=this.pos[1]+this.dir[1]*i,!0}}class Ac{constructor(e,t){this.pos=e,this.dir=t;}intersectsPlane(e,t,r){const n=O(t,this.dir);if(Math.abs(n)<1e-6)return !1;const i=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/n;return r[0]=this.pos[0]+this.dir[0]*i,r[1]=this.pos[1]+this.dir[1]*i,r[2]=this.pos[2]+this.dir[2]*i,!0}closestPointOnSphere(e,r,n){if(function(e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return Math.abs(n-a)<=t*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-o)<=t*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-l)<=t*Math.max(1,Math.abs(s),Math.abs(l))}(this.pos,e)||0===r)return n[0]=n[1]=n[2]=0,!1;const[i,s,a]=this.dir,o=this.pos[0]-e[0],l=this.pos[1]-e[1],u=this.pos[2]-e[2],c=i*i+s*s+a*a,h=2*(o*i+l*s+u*a),d=h*h-4*c*(o*o+l*l+u*u-r*r);if(d<0){const e=Math.max(-h/2,0),t=o+i*e,c=l+s*e,d=u+a*e,p=Math.hypot(t,c,d);return n[0]=t*r/p,n[1]=c*r/p,n[2]=d*r/p,!1}{const e=(-h-Math.sqrt(d))/(2*c);if(e<0){const e=Math.hypot(o,l,u);return n[0]=o*r/e,n[1]=l*r/e,n[2]=u*r/e,!1}return n[0]=o+i*e,n[1]=l+s*e,n[2]=u+a*e,!0}}}class Ic{constructor(e,t,r,n,i){this.TL=e,this.TR=t,this.BR=r,this.BL=n,this.horizon=i;}static fromInvProjectionMatrix(e,t,r){const n=[-1,1,1],i=[1,1,1],s=[1,-1,1],a=[-1,-1,1],o=j(n,n,e),l=j(i,i,e),u=j(s,s,e),c=j(a,a,e);return new Ic(o,l,u,c,t/r)}}function Mc(e,t,r){let n=1/0,i=-1/0;const s=[];for(const a of e){X(s,a,t);const e=O(s,r);n=Math.min(n,e),i=Math.max(i,e);}return [n,i]}function Sc(e,t){let r=!0;for(let n=0;n<e.planes.length;n++){const i=e.planes[n];let s=0;for(let e=0;e<t.length;e++)s+=+(O(i,t[e])+i[3]>=0);if(0===s)return 0;s!==t.length&&(r=!1);}return r?2:1}function Bc(e,t){for(const r of e.projections){const n=Mc(t,e.points[0],r.axis);if(r.projection[1]<n[0]||r.projection[0]>n[1])return 0}return 1}function Pc(e,t){let r=0;const n=[0,0,0,0];for(let i=0;i<e.length;i++)n[0]=e[i][0],n[1]=e[i][1],n[2]=e[i][2],n[3]=1,Q(n,t)>=0&&r++;return r}class Tc{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=zc.fromPoints(this.points),this.projections=[],this.frustumEdges=[X([],this.points[2],this.points[3]),X([],this.points[0],this.points[3]),X([],this.points[4],this.points[0]),X([],this.points[5],this.points[1]),X([],this.points[6],this.points[2]),X([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],r=[e[2],0,-e[0]];this.projections.push({axis:t,projection:Mc(this.points,this.points[0],t)}),this.projections.push({axis:r,projection:Mc(this.points,this.points[0],r)});}}static fromInvProjectionMatrix(e,t,r,n){const i=Math.pow(2,r),s=[[-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(r=>{const s=ee([],r,e),a=1/s[3]/t*i;return (o=s)[0]=(l=s)[0]*(u=[a,a,n?1/s[3]:a,a])[0],o[1]=l[1]*u[1],o[2]=l[2]*u[2],o[3]=l[3]*u[3],o;var o,l,u;}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=L([],U([],X([],s[e[0]],s[e[1]]),X([],s[e[2]],s[e[1]]))),r=-O(t,s[e[1]]);return t.concat(r)}),o=[];for(let e=0;e<s.length;e++)o.push([s[e][0],s[e][1],s[e][2]]);return new Tc(o,a)}intersectsPrecise(e,t,r){for(let r=0;r<t.length;r++)if(!Pc(e,t[r]))return 0;for(let t=0;t<this.planes.length;t++)if(!Pc(e,this.planes[t]))return 0;for(const t of r)for(const r of this.frustumEdges){const n=U([],t,r),i=I(n);if(0===i)continue;F(n,n,1/i);const s=Mc(this.points,this.points[0],n),a=Mc(e,this.points[0],n);if(s[0]>a[1]||a[0]>s[1])return 0}return 1}containsPoint(e){for(const t of this.planes){const r=t[3];if(O([t[0],t[1],t[2]],e)+r<0)return !1}return !0}}class zc{static fromPoints(e){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of e)z(t,t,n),k(r,r,n);return new zc(t,r)}static fromTileIdAndHeight(e,t,r){const n=1<<e.canonical.z,i=e.canonical.x,s=e.canonical.y;return new zc([i/n,s/n,t],[(i+1)/n,(s+1)/n,r])}static applyTransform(e,t){const r=e.getCorners();for(let e=0;e<r.length;++e)j(r[e],r[e],t);return zc.fromPoints(r)}static applyTransformFast(e,t){const r=[t[12],t[13],t[14]],n=[...r];for(let i=0;i<3;i++)for(let s=0;s<3;s++){const a=t[4*s+i],o=a*e.min[s],l=a*e.max[s];r[i]+=Math.min(o,l),n[i]+=Math.max(o,l);}return new zc(r,n)}static projectAabbCorners(e,t){const r=e.getCorners();for(let e=0;e<r.length;++e)j(r[e],r[e],t);return r}constructor(e,t){this.min=e,this.max=t,this.center=F([],B([],this.min,this.max),.5);}quadrant(e){const t=[e%2==0,e<2],r=A(this.min),n=A(this.max);for(let e=0;e<t.length;e++)r[e]=t[e]?this.min[e]:this.center[e],n[e]=t[e]?this.center[e]:this.max[e];return n[2]=this.max[2],new zc(r,n)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return [[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?Sc(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?Sc(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,t){return t||this.intersects(e)?Bc(e,this.getCorners()):0}intersectsPreciseFlat(e,t){return t||this.intersectsFlat(e)?Bc(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let t=0;t<3;++t)if(this.min[t]>e.max[t]||e.min[t]>this.max[t])return !1;return !0}intersectsAabbXY(e){return !(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t]);}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t]);}closestPoint(e){return [Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}ra(zc,"Aabb");class kc{constructor(e,t){this.feature=e,this.metersToTile=t,this.index=0;}get(){const e=this.feature.vertices[this.index],t=this.feature.vertexProps[this.index].dir,r=t[1],n=-t[0],i=(e.extent+1)*this.metersToTile;return [new Me(Math.trunc(e.position[0]+r*i),Math.trunc(e.position[1]+n*i)),new Me(Math.trunc(e.position[0]-r*i),Math.trunc(e.position[1]-n*i))]}next(){this.index++;}valid(){return this.index<this.feature.vertices.length}}class Fc{constructor(e,t,r,n,i,s){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this._tmpVec2=[ce(),ce(),ce(),ce(),ce(),ce(),ce()],this.id=e,this.heightRange={min:r,max:r},this.safeArea=t,this.constantHeight=r,null==this.constantHeight&&(null!=this.constantHeight||0!==n.length)){this.vertices=n,this.edges=i,this.edges=this.edges.filter(e=>{return e.a<this.vertices.length&&e.b<this.vertices.length&&!((t=this.vertices[e.a].position)[0]===(r=this.vertices[e.b].position)[0]&&t[1]===r[1]);var t,r;}),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(const e of this.vertices)this.vertexProps.push({dir:he(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,e.height),this.heightRange.max=Math.max(this.heightRange.max,e.height);for(const e of this.edges){const t=this.vertices[e.a].position,r=this.vertices[e.b].position,n=fe(ce(),r,t),i=ye(n),s=me(ce(),n,1/i);this.edgeProps.push({vec:n,dir:s,len:i});const a=this.vertexProps[e.a].dir,o=this.vertexProps[e.b].dir;pe(a,a,s),pe(o,o,s);}for(const e of this.vertexProps)0===e.dir[0]&&0===e.dir[1]||ge(e.dir,e.dir);this.tessellate(s);}}pointElevation(e){if(null!=this.constantHeight)return this.constantHeight;const t=this.getClosestEdge(e);if(null==t)return 0;const[r,n]=t;return yr(this.vertices[this.edges[r].a].height,this.vertices[this.edges[r].b].height,n)}computeSlopeNormal(e,t){const r=this.getClosestEdge(e);if(!r)return M(0,0,1);const n=r[0],i=this.edges[n],s=this.edgeProps[n].vec,a=M(s[0],s[1],(this.vertices[i.b].height-this.vertices[i.a].height)*t),o=M(a[1],-a[0],0);U(o,o,a);const l=I(o);return l>0?F(o,o,1/l):S(o,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(0===this.edges.length)return;let t=0,r=Number.POSITIVE_INFINITY,n=0;const[i,s,a,o,l,u,c]=this._tmpVec2;de(c,e.x,e.y);const h=new _c(c,null);for(let e=0;e<this.edges.length;e++){const d=this.edges[e],p=this.edgeProps[e].dir;h.dir=p;const f=this.vertices[d.a].position,m=this.vertices[d.b].position,y=h.intersectsPlane(f,this.vertexProps[d.a].dir,i),g=h.intersectsPlane(m,this.vertexProps[d.b].dir,s);if(!y||!g)continue;fe(a,s,i),fe(o,c,i);const x=xe(a,a),v=x>0?xe(o,a)/x:0,b=Ee(v,0,1),w=Math.abs((v-b)*this.edgeProps[e].len);fe(l,c,f),de(u,p[1],-p[0]);const _=w+Math.abs(xe(l,u));_<r&&(t=e,r=_,n=b);}return [t,n]}tessellate(e){const t=_(),r=_(),n=_(),i=_();for(let s=this.edges.length-1;s>=0;--s){const a=this.edges[s].a,o=this.edges[s].b,{position:l,height:u,extent:c}=this.vertices[a],{position:h,height:d,extent:p}=this.vertices[o],f=this.vertexProps[a].dir,m=this.vertexProps[o].dir;if(S(t,l[0]/e,l[1]/e,u),S(r,h[0]/e,h[1]/e,d),S(n,f[1],-f[0],0),F(n,n,c),S(i,m[1],-m[0],0),F(i,i,p),this.distSqLines(M(t[0]+.5*n[0],t[1]+.5*n[1],t[2]+.5*n[2]),M(r[0]-.5*i[0],r[1]-.5*i[1],r[2]-.5*i[2]),M(t[0]-.5*n[0],t[1]-.5*n[1],t[2]-.5*n[2]),M(r[0]+.5*i[0],r[1]+.5*i[1],r[2]+.5*i[2]))<=.0025000000000000005)continue;const y=this.vertices.length,g=pe(ce(),l,h);this.vertices.push({position:me(g,g,.5),height:.5*(u+d),extent:.5*(c+p)});const x=pe(ce(),f,m);this.vertexProps.push({dir:ge(x,x)}),this.edges.splice(s,1),this.edgeProps.splice(s,1),this.edges.push({a,b:y}),this.edges.push({a:y,b:o});const v=fe(ce(),this.vertices[y].position,l),b=ye(v),w={vec:v,dir:me(ce(),v,1/b),len:b};this.edgeProps.push(w),this.edgeProps.push(w);}}distSqLines(e,t,r,n){const i=P(_(),t,e),s=P(_(),n,r),a=P(_(),e,r),o=O(i,i),l=O(i,s),u=O(i,a),c=O(s,s),h=O(s,a),d=o*c-l*l;if(0===d)return E(N(i,r,n,O(a,s)/O(s,s)),e);const p=(o*h-l*u)/d;return E(N(i,e,t,(l*h-u*c)/d),N(s,r,n,p))}}class Vc{static parseFrom(e,t){const r=wc.parse(e);if(!r)return [];let{vertices:n,features:i}=r;const s=1/Ju(t);i.sort((e,t)=>e.id-t.id),n.sort((e,t)=>e.id-t.id||e.idx-t.idx),n=n.filter((e,t,r)=>t===r.findIndex(t=>t.id===e.id&&t.idx===e.idx));const a=new Array;let o=0;const l=n.length;for(const e of i){if(e.constantHeight){a.push(new Fc(e.id,e.bounds,e.constantHeight));continue}for(;o!==l&&n[o].id<e.id;)o++;if(o===l||n[o].id!==e.id)continue;const t=new Array,r=new Array,i=o;for(;o!==l&&n[o].id===e.id;){const e=n[o];if(t.push({position:e.position,height:e.height,extent:e.extent}),o!==i&&n[o-1].idx===e.idx-1){const e=o-i;r.push({a:e-1,b:e});}o++;}a.push(new Fc(e.id,e.bounds,void 0,t,r,s));}return a}static getElevationFeature(e,t){if(!t)return;const r=+e.properties[mc];return Number.isNaN(r)?void 0:t.find(e=>e.id===r)}}class Dc{constructor(e,t){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(t)||(this.zScale=Math.pow(2,t.z-e.z),this.xOffset=(e.x*this.zScale-t.x)*qn,this.yOffset=(e.y*this.zScale-t.y)*qn);}constantElevation(e,t){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,r){const n=this.constantElevation(t,r);return null!=n?n:(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),r))}computeBiasedHeight(e,t){return t<=0?e:e+t*Ce(0,t,e>=0?e:Math.abs(.5*e))}}ra(Fc,"ElevationFeature");class Ec{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Zo,this.indexArray=new yl,this.segments=new Xl,this.programConfigurations=new Au(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,"none"!==this.elevationMode&&(this.elevatedLayoutVertexArray=new Jo),this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){const i=this.layers[0],s=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:i,id:o,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=oc(i,e);if(!this.layers[0]._featureFilter.filter(new to(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=a?a.evaluate(c,{},r):void 0,d={id:o,properties:i.properties,type:i.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:ac(i,r,n),patterns:{},sortKey:h};s.push(d);}a&&s.sort((e,t)=>e.sortKey-t.sortKey);let o=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new al,o=n.projection);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n,l=e[s].feature;this.addFeature(n,i,s,t.availableImages,r,o,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,i,s,a,this.index);}this.hasElevation||(this.elevatedLayoutVertexArray=void 0);}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,this.worldview);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,$l.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Hl.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,ql.members))),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy());}addFeature(e,t,r,n,i,s,a,o){let l;"none"!==this.elevationMode&&(l=Vc.getElevationFeature(e,o));for(const r of t)for(const t of r){const r=t.x,n=t.y;if(r<0||r>=qn||n<0||n>=qn)continue;if(s){const e=s.projectTilePoint(r,n,i),t=s.upVector(i,r,n);this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t);}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),o=a.vertexLength;if(this.addCircleVertex(r,n,-1,-1),this.addCircleVertex(r,n,1,-1),this.addCircleVertex(r,n,1,1),this.addCircleVertex(r,n,-1,1),"none"!==this.elevationMode){const e=l?l.pointElevation(new Me(r,n)):0;this.hasElevation=this.hasElevation||0!==e;for(let t=0;t<4;t++)this.elevatedLayoutVertexArray.emplaceBack(e);}this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+2,o+3),a.vertexLength+=4,a.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},n,i,a,void 0,this.worldview);}addCircleVertex(e,t,r,n){this.layoutVertexArray.emplaceBack(2*e+(r+1)/2,2*t+(n+1)/2);}addGlobeExtVertex(e,t){const r=16384;this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*r,t[1]*r,t[2]*r);}}function Cc(e,t){for(let r=0;r<e.length;r++)if(Xc(t,e[r]))return !0;for(let r=0;r<t.length;r++)if(Xc(e,t[r]))return !0;return !!Uc(e,t)}function Rc(e,t,r){return !!Xc(e,t)||!!$c(t,e,r)}function Lc(e,t){if(1===e.length)return Hc(t,e[0]);for(let r=0;r<t.length;r++){const n=t[r];for(let t=0;t<n.length;t++)if(Xc(e,n[t]))return !0}for(let r=0;r<e.length;r++)if(Hc(t,e[r]))return !0;for(let r=0;r<t.length;r++)if(Uc(e,t[r]))return !0;return !1}function Oc(e,t,r){if(e.length>1){if(Uc(e,t))return !0;for(let n=0;n<t.length;n++)if($c(t[n],e,r))return !0}for(let n=0;n<e.length;n++)if($c(e[n],t,r))return !0;return !1}function Uc(e,t){if(0===e.length||0===t.length)return !1;for(let r=0;r<e.length-1;r++){const n=e[r],i=e[r+1];for(let e=0;e<t.length-1;e++)if(Nc(n,i,t[e],t[e+1]))return !0}return !1}function Nc(e,t,r,n){return We(e,r,n)!==We(t,r,n)&&We(e,t,r)!==We(e,t,n)}function jc(e,t,r){return (e.x-r.x)*(t.y-r.y)-(e.y-r.y)*(t.x-r.x)}function Gc(e,t,r,n){const i=jc(e,t,n),s=jc(e,t,r);if(Math.sign(i)===Math.sign(s))return;const a=jc(r,n,e),o=a+s-i;return Math.sign(a)!==Math.sign(o)?[a/(a-o),s/(s-i)]:void 0}function $c(e,t,r){const n=r*r;if(1===t.length)return e.distSqr(t[0])<n;for(let r=1;r<t.length;r++)if(qc(e,t[r-1],t[r])<n)return !0;return !1}function qc(e,t,r){const n=t.distSqr(r);if(0===n)return e.distSqr(t);const i=((e.x-t.x)*(r.x-t.x)+(e.y-t.y)*(r.y-t.y))/n;return e.distSqr(i<0?t:i>1?r:r.sub(t)._mult(i)._add(t))}function Hc(e,t){let r,n,i,s=!1;for(let a=0;a<e.length;a++){r=e[a];for(let e=0,a=r.length-1;e<r.length;a=e++)n=r[e],i=r[a],n.y>t.y!=i.y>t.y&&t.x<(i.x-n.x)*(t.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function Xc(e,t){let r=!1;for(let n=0,i=e.length-1;n<e.length;i=n++){const s=e[n],a=e[i];s.y>t.y!=a.y>t.y&&t.x<(a.x-s.x)*(t.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function Zc(e,t,r,n,i){for(const s of e)if(t<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new Me(t,r),new Me(t,i),new Me(n,i),new Me(n,r)];if(e.length>2)for(const t of s)if(Xc(e,t))return !0;for(let t=0;t<e.length-1;t++)if(Wc(e[t],e[t+1],s))return !0;return !1}function Wc(e,t,r){const n=r[0],i=r[2];if(e.x<n.x&&t.x<n.x||e.x>i.x&&t.x>i.x||e.y<n.y&&t.y<n.y||e.y>i.y&&t.y>i.y)return !1;const s=We(e,t,r[0]);return s!==We(e,t,r[1])||s!==We(e,t,r[2])||s!==We(e,t,r[3])}function Yc(e,t,r,n,i,s){let a=t.y-e.y,o=e.x-t.x;if(s=s||0){const e=a*a+o*o;if(0===e)return !0;const t=Math.sqrt(e);a/=t,o/=t;}return !((r.x-e.x)*a+(r.y-e.y)*o-s<0||(n.x-e.x)*a+(n.y-e.y)*o-s<0||(i.x-e.x)*a+(i.y-e.y)*o-s<0)}function Jc(e,t,r,n,i,s,a){return !(Yc(e,t,n,i,s,a)||Yc(t,r,n,i,s,a)||Yc(r,e,n,i,s,a)||Yc(n,i,e,t,r,a)||Yc(i,s,e,t,r,a)||Yc(s,n,e,t,r,a))}function Kc(e,t,r){const n=t.paint.get(e).value;return "constant"===n.kind?n.value:r.programConfigurations.get(t.id).getMaxValue(e)}function Qc(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function eh(e,t,r,n,i){if(!t[0]&&!t[1])return e;const s=Me.convert(t)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let t=0;t<e.length;t++)a.push(e[t].sub(s));return a}function th(e,t,r,n){const i=Me.convert(e)._mult(n);return "viewport"===t&&i._rotate(-r),i}let rh,nh;ra(Ec,"CircleBucket",{omit:["layers"]});class ih{constructor(e,t,r){this.z=e,this.x=t,this.y=r,this.key=oh(0,e,e,t,r);}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){const t=this.z-e.z;return 0===e.z||e.z<this.z&&e.x===this.x>>t&&e.y===this.y>>t}url(e,t){const r=function(e,t,r){const n=2**r,i=2*Math.PI*6378137,s=i*(e/n-.5),a=i*(.5-(t+1)/n);return `${s},${a},${s+i/n},${a+i/n}`}(this.x,this.y,this.z),n=function(e,t,r){let n,i="";for(let s=e;s>0;s--)n=1<<s-1,i+=(t&n?1:0)+(r&n?2:0);return i}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",n).replace("{bbox-epsg-3857}",r)}toString(){return `${this.z}/${this.x}/${this.y}`}}class sh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=oh(e,t.z,t.z,t.x,t.y);}}class ah{constructor(e,t,r,n,i){this.overscaledZ=e,this.wrap=t,this.canonical=new ih(r,+n,+i),this.key=0===t&&e===r?this.canonical.key:oh(t,e,r,n,i);}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new ah(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ah(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return oh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-e;return oh(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return !1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return [new ah(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new ah(t,this.wrap,t,r,n),new ah(t,this.wrap,t,r+1,n),new ah(t,this.wrap,t,r,n+1),new ah(t,this.wrap,t,r+1,n+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new ah(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new ah(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new sh(this.wrap,this.canonical)}toString(){return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function oh(e,t,r,n,i){const s=1<<Math.min(r,22);let a=s*(i%s)+n%s;return e&&r<22&&(a+=s*s*((e<0?-2*e-1:2*e)%(1<<2*(22-r)))),16*(32*a+r)+(t-r)}const lh=[e=>{let t=e.canonical.x-1,r=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,r--),new ah(e.overscaledZ,r,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,r=e.wrap;return t===1<<e.canonical.z&&(t=0,r++),new ah(e.overscaledZ,r,e.canonical.z,t,e.canonical.y)},e=>new ah(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new ah(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)];ra(ih,"CanonicalTileID"),ra(ah,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const uh=Ho([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:ch}=uh,hh=Ho([{name:"a_pos_3",components:3,type:"Int16"}]);var dh=Ho([{name:"a_pos",type:"Int16",components:2}]);function ph(e){return e*Tu/Cu}const fh=[new zc([Fu,Fu,Fu],[Vu,Vu,Vu]),new zc([Fu,Fu,Fu],[0,0,Vu]),new zc([0,Fu,Fu],[Vu,0,Vu]),new zc([Fu,0,Fu],[0,Vu,Vu]),new zc([0,0,Fu],[Vu,Vu,Vu])];function mh(e,t,r,n=!0){const i=F([],e._camera.position,e.worldSize),s=[t,r,1,1];ee(s,s,e.pixelMatrixInverse),J(s,s,1/s[3]);const a=L([],X([],s,i)),o=e.globeMatrix,l=[o[12],o[13],o[14]],u=X([],l,i),c=I(u),h=L([],u),d=e.worldSize/(2*Math.PI),p=O(h,a),f=Math.asin(d/c);if(f<Math.acos(p)){if(!n)return null;const e=[],t=[];F(e,a,c/p),L(t,X(t,e,u)),L(a,B(a,u,F(a,t,Math.tan(f)*c)));}const m=[];new Ac(i,a).closestPointOnSphere(l,d,m);const y=L([],rt(o,0)),g=L([],rt(o,1)),x=L([],rt(o,2)),v=O(y,m),b=O(g,m),w=O(x,m),_=ze(Math.asin(-b/d));let A=ze(Math.atan2(v,w));A=e.center.lng+function(e,t){const r=(t-e+180)%360-180;return r<-180?r+360:r}(e.center.lng,A);const M=Nu(A),S=Ee(ju(_),0,1);return new Ku(M,S)}class yh{constructor(e,t,r){this.a=X([],e,r),this.b=X([],t,r),this.center=r;const n=L([],this.a),i=L([],this.b);this.angle=Math.acos(O(n,i));}}function gh(e,t){if(0===e.angle)return null;let r;return r=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),r<0||r>1?null:function(e,t,r,n){const i=Math.sin(r);return e*(Math.sin((1-n)*r)/i)+t*(Math.sin(n*r)/i)}(e.a[t],e.b[t],e.angle,Ee(r,0,1))+e.center[t]}function xh(e){if(e.z<=1)return fh[e.z+2*e.y+e.x];const t=Ih(Ah(e));return zc.fromPoints(t)}function vh(e,t,r){return F(e,e,1-r),V(e,e,t,r)}function bh(e,t){const r=Vh(t.zoom);if(0===r)return xh(e);const n=Ah(e),i=Ih(n),s=Nu(n.getWest())*t.worldSize,a=Nu(n.getEast())*t.worldSize,o=ju(n.getNorth())*t.worldSize,l=ju(n.getSouth())*t.worldSize,u=[s,o,0],h=[a,o,0],d=[s,l,0],p=[a,l,0],f=c([],t.globeMatrix);return j(u,u,f),j(h,h,f),j(d,d,f),j(p,p,f),i[0]=vh(i[0],d,r),i[1]=vh(i[1],p,r),i[2]=vh(i[2],h,r),i[3]=vh(i[3],u,r),zc.fromPoints(i)}function wh(e,t,r){for(const n of e)j(n,n,t),F(n,n,r);}function _h(e,t,r,n){const i=t/e.worldSize,s=e.globeMatrix;if(r.z<=1){const e=xh(r).getCorners();return wh(e,s,i),zc.fromPoints(e)}const a=Ah(r,n),o=Ih(a,Tu+ph(e._tileCoverLift));wh(o,s,i);const l=Number.MAX_VALUE,u=[-l,-l,-l],c=[l,l,l];if(a.contains(e.center)){for(const e of o)z(c,c,e),k(u,u,e);u[2]=0;const t=e.point,r=[t.x*i,t.y*i,0];return z(c,c,r),k(u,u,r),new zc(c,u)}if(e._tileCoverLift>0){for(const e of o)z(c,c,e),k(u,u,e);return new zc(c,u)}const h=[s[12]*i,s[13]*i,s[14]*i],d=a.getCenter(),p=Ee(e.center.lat,-85.051129,Xu),f=Ee(d.lat,-85.051129,Xu),m=Nu(e.center.lng),y=ju(p);let g=m-Nu(d.lng);const x=y-ju(f);g>.5?g-=1:g<-.5&&(g+=1);let v=0;Math.abs(g)>Math.abs(x)?v=g>=0?1:3:(v=x>=0?0:2,V(h,h,[s[4]*i,s[5]*i,s[6]*i],-Math.sin(Te(x>=0?a.getSouth():a.getNorth()))*Tu));const b=o[v],w=o[(v+1)%4],_=new yh(b,w,h),A=[gh(_,0)||b[0],gh(_,1)||b[1],gh(_,2)||b[2]],I=Vh(e.zoom);if(I>0){const n=function({x:e,y:t,z:r},n,i,s,a){const o=1/(1<<r);let l=e*o,u=l+o,c=t*o,h=c+o,d=0;const p=(l+u)/2-s;return p>.5?d=-1:p<-.5&&(d=1),l=((l+d)*n-(s*=n))*i+s,u=((u+d)*n-s)*i+s,c=(c*n-(a*=n))*i+a,h=(h*n-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(r,t,e._pixelsPerMercatorPixel,m,y);for(let e=0;e<o.length;e++)vh(o[e],n[e],I);const i=B([],n[v],n[(v+1)%4]);F(i,i,.5),vh(A,i,I);}for(const e of o)z(c,c,e),k(u,u,e);return c[2]=Math.min(b[2],w[2]),z(c,c,A),k(u,u,A),new zc(c,u)}function Ah({x:e,y:t,z:r},n=!1){const i=1/(1<<r),s=new Lu($u(e*i),t===(1<<r)-1&&n?-90:qu((t+1)*i)),a=new Lu($u((e+1)*i),0===t&&n?90:qu(t*i));return new Ou(s,a)}function Ih(e,t=Tu){const r=Te(e.getNorth()),n=Te(e.getSouth()),i=Math.cos(r),s=Math.cos(n),a=Math.sin(r),o=Math.sin(n),l=e.getWest(),u=e.getEast();return [Du(s,o,l,t),Du(s,o,u,t),Du(i,a,u,t),Du(i,a,l,t)]}function Mh(e,t,r,n){const i=1<<r.z,s=(e/qn+r.x)/i;return Eu(qu((t/qn+r.y)/i),$u(s),n)}function Sh({min:e,max:t}){return 16383/Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])}const Bh=new Float64Array(16);function Ph(e){const t=Sh(e),r=g(Bh,[t,t,t]);return d(r,r,R([],e.min))}function Th(e){const t=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}(Bh,e.min),r=1/Sh(e);return p(t,t,[r,r,r])}function zh(e){const t=qn/(2*Math.PI);return e/(2*Math.PI)/t}function kh(e,t){return qn/(512*Math.pow(2,e))*Sh(xh(t))}function Fh(e,t,r,n,i){const s=zh(r),a=[e,t,-r/(2*Math.PI)],o=u(new Float64Array(16));return d(o,o,a),p(o,o,[s,s,s]),f(o,o,Te(-i)),m(o,o,Te(-n)),o}function Vh(e){return Ce(5,6,e)}function Dh(e,t){const r=Eu(t.lat,t.lng),n=function(e){const t=Eu(e._center.lat,e._center.lng);let r=U([],M(0,1,0),t);const n=x([],-e.angle,t);r=j(r,r,n),x(n,-e._pitch,r);const i=L([],t);return F(i,i,ph(e.cameraToCenterDistance/e.pixelsPerMeter)),j(i,i,n),B([],t,i)}(e);return a=(i=P([],n,r))[0],o=i[1],l=i[2],u=(s=r)[0],c=s[1],h=s[2],p=(d=Math.sqrt((a*a+o*o+l*l)*(u*u+c*c+h*h)))&&O(i,s)/d,Math.acos(Math.min(Math.max(p,-1),1));var i,s,a,o,l,u,c,h,d,p;}function Eh(e,t){return Dh(e,t)>Math.PI/2*1.01}const Ch=Te(85),Rh=Math.cos(Ch),Lh=Math.sin(Ch),Oh=o(),Uh=e=>{const t=[];return "map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Nh(e,t,r,n,i,s,a,o,l){if(s&&e.queryGeometry.isAboveHorizon)return !1;s&&(l*=e.pixelToTileUnitsFactor);const u=e.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(o),d=i&&r.elevation?r.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,p=r.projection.projectTilePoint(h.x,h.y,u);if(d>0){const e=r.projection.upVector(u,h.x,h.y);p.x+=e[0]*c*d,p.y+=e[1]*c*d,p.z+=e[2]*c*d;}const f=s?h:jh(p.x,p.y,p.z,n),m=s?e.tilespaceRays.map(e=>qh(e,d)):e.queryGeometry.screenGeometry,y=ee([],[p.x,p.y,p.z,1],n);if(!a&&s?l*=y[3]/r.cameraToCenterDistance:a&&!s&&(l*=r.cameraToCenterDistance/y[3]),s){const e=qu((t.y/qn+u.y)/(1<<u.z));l/=r.projection.pixelsPerMeter(e,1)/Gu(1,e);}if(Rc(m,f,l))return !0}return !1}function jh(e,t,r,n){const i=ee([],[e,t,r,1],n);return new Me(i[0]/i[3],i[1]/i[3])}const Gh=M(0,0,0),$h=M(0,0,1);function qh(e,t){const r=_();return Gh[2]=t,e.intersectsPlane(Gh,$h,r),new Me(r[0],r[1])}class Hh extends Ec{}let Xh,Zh,Wh,Yh;function Jh(e,{width:t,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*r*n)throw new RangeError("mismatched image size")}else i=new Uint8Array(t*r*n);return e.width=t,e.height=r,e.data=i,e}function Kh(e,t,r){const{width:n,height:i}=t;n===e.width&&i===e.height||(Qh(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r,null),e.width=n,e.height=i,e.data=t.data);}function Qh(e,t,r,n,i,s,a,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,u=t.data,c=4===s&&o;for(let o=0;o<i.height;o++){const h=((r.y+o)*e.width+r.x)*s,d=((n.y+o)*t.width+n.x)*s;if(c)for(let e=0;e<i.width;e++){const t=h+e*s+3,r=d+e*s;u[r+0]=255,u[r+1]=255,u[r+2]=255,u[r+3]=l[t];}else if(a)for(let e=0;e<i.width;e++){const t=h+e*s,r=d+e*s,n=new dr(l[t+0]/255,l[t+1]/255,l[t+2]/255,l[t+3]).toNonPremultipliedRenderColor(a).toArray();u[r+0]=n[0],u[r+1]=n[1],u[r+2]=n[2],u[r+3]=n[3];}else for(let e=0;e<i.width*s;e++)u[d+e]=l[h+e];}return t}ra(Hh,"HeatmapBucket",{omit:["layers"]});class ed{constructor(e,t){Jh(this,e,1,t);}resize(e){Kh(this,new ed(e),1);}clone(){return new ed({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,r,n,i){Qh(e,t,r,n,i,1,null);}}class td{constructor(e,t){Jh(this,e,4,t);}resize(e){Kh(this,new td(e),4);}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e;}clone(){return new td({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,r,n,i,s,a){Qh(e,t,r,n,i,4,s,a);}}class rd{constructor(e,t){this.width=e.width,this.height=e.height,this.data=t instanceof Uint8Array?new Float32Array(t.buffer):t;}}function nd(e){const t={},r=e.resolution||256,n=e.clips?e.clips.length:1,i=e.image||new td({width:r,height:n}),s=(r,n,s)=>{t[e.evaluationKey]=s;const a=e.expression.evaluate(t),o=a?a.toNonPremultipliedRenderColor(null):null;o&&(i.data[r+n+0]=Math.floor(255*o.r),i.data[r+n+1]=Math.floor(255*o.g),i.data[r+n+2]=Math.floor(255*o.b),i.data[r+n+3]=Math.floor(255*o.a));};if(e.clips)for(let t=0,i=0;t<n;++t,i+=4*r)for(let n=0,a=0;n<r;n++,a+=4){const o=n/(r-1),{start:l,end:u}=e.clips[t];s(i,a,l*(1-o)+u*o);}else for(let e=0,t=0;e<r;e++,t+=4)s(0,t,e/(r-1));return i}ra(ed,"AlphaImage"),ra(td,"RGBAImage");const id=Ho([{name:"a_pos",components:2,type:"Int16"}],4),sd=Ho([{name:"a_road_z_offset",components:1,type:"Float32"}],4),ad=Ho([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),od=Ho([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);function ld(e,t,r=2){const n=t&&t.length,i=n?t[0]*r:e.length;let s=ud(e,0,i,r,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,u;if(n&&(s=function(e,t,r,n){const i=[];for(let r=0,s=t.length;r<s;r++){const a=ud(e,t[r]*n,r<s-1?t[r+1]*n:e.length,n,!1);a===a.next&&(a.steiner=!0),i.push(bd(a));}i.sort(yd);for(let e=0;e<i.length;e++)r=gd(i[e],r);return r}(e,t,s,r)),e.length>80*r){o=e[0],l=e[1];let t=o,n=l;for(let s=r;s<i;s+=r){const r=e[s],i=e[s+1];r<o&&(o=r),i<l&&(l=i),r>t&&(t=r),i>n&&(n=i);}u=Math.max(t-o,n-l),u=0!==u?32767/u:0;}return hd(s,a,r,o,l,u,0),a}function ud(e,t,r,n,i){let s;if(i===function(e,t,r,n){let i=0;for(let s=t,a=r-n;s<r;s+=n)i+=(e[a]-e[s])*(e[s+1]+e[a+1]),a=s;return i}(e,t,r,n)>0)for(let i=t;i<r;i+=n)s=kd(i/n|0,e[i],e[i+1],s);else for(let i=r-n;i>=t;i-=n)s=kd(i/n|0,e[i],e[i+1],s);return s&&Md(s,s.next)&&(Fd(s),s=s.next),s}function cd(e,t){if(!e)return e;t||(t=e);let r,n=e;do{if(r=!1,n.steiner||!Md(n,n.next)&&0!==Id(n.prev,n,n.next))n=n.next;else {if(Fd(n),n=t=n.prev,n===n.next)break;r=!0;}}while(r||n!==t);return t}function hd(e,t,r,n,i,s,a){if(!e)return;!a&&s&&function(e,t,r,n){let i=e;do{0===i.z&&(i.z=vd(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,r=1;do{let n,i=e;e=null;let s=null;for(t=0;i;){t++;let a=i,o=0;for(let e=0;e<r&&(o++,a=a.nextZ,a);e++);let l=r;for(;o>0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:e=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(t>1)}(i);}(e,n,i,s);let o=e;for(;e.prev!==e.next;){const l=e.prev,u=e.next;if(s?pd(e,n,i,s):dd(e))t.push(l.i,e.i,u.i),Fd(e),e=u.next,o=u.next;else if((e=u)===o){a?1===a?hd(e=fd(cd(e),t),t,r,n,i,s,2):2===a&&md(e,t,r,n,i,s):hd(cd(e),t,r,n,i,s,1);break}}}function dd(e){const t=e.prev,r=e,n=e.next;if(Id(t,r,n)>=0)return !1;const i=t.x,s=r.x,a=n.x,o=t.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),d=Math.max(i,s,a),p=Math.max(o,l,u);let f=n.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=h&&f.y<=p&&_d(i,o,s,l,a,u,f.x,f.y)&&Id(f.prev,f,f.next)>=0)return !1;f=f.next;}return !0}function pd(e,t,r,n){const i=e.prev,s=e,a=e.next;if(Id(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,d=a.y,p=Math.min(o,l,u),f=Math.min(c,h,d),m=Math.max(o,l,u),y=Math.max(c,h,d),g=vd(p,f,t,r,n),x=vd(m,y,t,r,n);let v=e.prevZ,b=e.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=y&&v!==i&&v!==a&&_d(o,c,l,h,u,d,v.x,v.y)&&Id(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=y&&b!==i&&b!==a&&_d(o,c,l,h,u,d,b.x,b.y)&&Id(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=y&&v!==i&&v!==a&&_d(o,c,l,h,u,d,v.x,v.y)&&Id(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=y&&b!==i&&b!==a&&_d(o,c,l,h,u,d,b.x,b.y)&&Id(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function fd(e,t){let r=e;do{const n=r.prev,i=r.next.next;!Md(n,i)&&Sd(n,r,r.next,i)&&Td(n,i)&&Td(i,n)&&(t.push(n.i,r.i,i.i),Fd(r),Fd(r.next),r=e=i),r=r.next;}while(r!==e);return cd(r)}function md(e,t,r,n,i,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Ad(a,e)){let o=zd(a,e);return a=cd(a,a.next),o=cd(o,o.next),hd(a,t,r,n,i,s,0),void hd(o,t,r,n,i,s,0)}e=e.next;}a=a.next;}while(a!==e)}function yd(e,t){let r=e.x-t.x;return 0===r&&(r=e.y-t.y,0===r)&&(r=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),r}function gd(e,t){const r=function(e,t){let r=t;const n=e.x,i=e.y;let s,a=-1/0;if(Md(e,r))return r;do{if(Md(e,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const e=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=n&&e>a&&(a=e,s=r.x<r.next.x?r:r.next,e===n))return s}r=r.next;}while(r!==t);if(!s)return null;const o=s,l=s.x,u=s.y;let c=1/0;r=s;do{if(n>=r.x&&r.x>=l&&n!==r.x&&wd(i<u?n:a,i,l,u,i<u?a:n,i,r.x,r.y)){const t=Math.abs(i-r.y)/(n-r.x);Td(r,e)&&(t<c||t===c&&(r.x>s.x||r.x===s.x&&xd(s,r)))&&(s=r,c=t);}r=r.next;}while(r!==o);return s}(e,t);if(!r)return t;const n=zd(r,e);return cd(n,n.next),cd(r,r.next)}function xd(e,t){return Id(e.prev,e,t.prev)<0&&Id(t.next,e,e.next)<0}function vd(e,t,r,n,i){return (e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function bd(e){let t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;}while(t!==e);return r}function wd(e,t,r,n,i,s,a,o){return (i-a)*(t-o)>=(e-a)*(s-o)&&(e-a)*(n-o)>=(r-a)*(t-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function _d(e,t,r,n,i,s,a,o){return !(e===a&&t===o)&&wd(e,t,r,n,i,s,a,o)}function Ad(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Sd(r,r.next,e,t))return !0;r=r.next;}while(r!==e);return !1}(e,t)&&(Td(e,t)&&Td(t,e)&&function(e,t){let r=e,n=!1;const i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==e);return n}(e,t)&&(Id(e.prev,e,t.prev)||Id(e,t.prev,t))||Md(e,t)&&Id(e.prev,e,e.next)>0&&Id(t.prev,t,t.next)>0)}function Id(e,t,r){return (t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Md(e,t){return e.x===t.x&&e.y===t.y}function Sd(e,t,r,n){const i=Pd(Id(e,t,r)),s=Pd(Id(e,t,n)),a=Pd(Id(r,n,e)),o=Pd(Id(r,n,t));return i!==s&&a!==o||!(0!==i||!Bd(e,r,t))||!(0!==s||!Bd(e,n,t))||!(0!==a||!Bd(r,e,n))||!(0!==o||!Bd(r,t,n))}function Bd(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Pd(e){return e>0?1:e<0?-1:0}function Td(e,t){return Id(e.prev,e,e.next)<0?Id(e,t,e.next)>=0&&Id(e,e.prev,t)>=0:Id(e,t,e.prev)<0||Id(e,e.next,t)<0}function zd(e,t){const r=Vd(e.i,e.x,e.y),n=Vd(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function kd(e,t,r,n){const i=Vd(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Fd(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ);}function Vd(e,t,r){return {i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Dd(e,t){const r=e.length;if(r<=1)return [e];const n=[];let i,s;for(let t=0;t<r;t++){const r=Ye(e[t]);0!==r&&(e[t].area=Math.abs(r),void 0===s&&(s=r<0),s===r<0?(i&&n.push(i),i=[e[t]]):i.push(e[t]));}if(i&&n.push(i),t>1)for(let e=0;e<n.length;e++)n[e].length<=t||(dn(n[e],t,1,n[e].length-1,Ed),n[e]=n[e].slice(0,t));return n}function Ed(e,t){return t.area-e.area}function Cd(e,t,r=1){if(!e)return null;const n="string"==typeof e?jr.from(e).getPrimary():e.getPrimary(),i="string"==typeof e?null:e.getSecondary();for(const e of [n,i]){if(!e)continue;const n=e.id.toString();t.has(n)||t.set(n,[]),e.scaleSelf(r),t.get(n).push(e);}return {primary:n.toString(),secondary:i?i.toString():null}}function Rd(e,t,r,n){const i=n.patternDependencies;let s=!1;for(const n of t){const t=n.paint.get(`${e}-pattern`);t.isConstant()||(s=!0),Cd(t.constantOr(null),i,r)&&(s=!0);}return s}function Ld(e,t,r,n,i,s){const a=s.patternDependencies;for(const o of t){const t=o.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){const e=Cd(t.evaluate({zoom:n},r,{},void 0,s.availableImages),a,i);if(!e)continue;const{primary:l,secondary:u}=e;l&&(r.patterns[o.id]=[l,u].filter(Boolean));}}return r}class Od{constructor(){this.portals=[];}static isOnBorder(e,t){return e<=0&&t<=0||e>=qn&&t>=qn}static evaluate(e){if(0===e.length)return new Od;let t=[];for(const r of e)t.push(...r.portals);if(0===t.length)return new Od;for(const e of t){const t=e.va,r=e.vb;(Od.isOnBorder(t.x,r.x)||Od.isOnBorder(t.y,r.y))&&(e.type="border");}const r=t.filter(e=>"unevaluated"!==e.type),n=t.filter(e=>"unevaluated"===e.type);if(0===n.length)return new Od;n.sort((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hash<t.hash?1:-1),t=r.concat(n);let i=r.length,s=i,a=i;do{if(s++,s===t.length||t[i].hash!==t[s].hash){if(s-i===2){a<i&&(t[a]=t[i],t[i]=null);const e=t[a],r=t[s-1];e.type=e.isTunnel!==r.isTunnel?"tunnel":"polygon",e.connection={a:e.connection.a,b:r.connection.a},a++;}i=s;}}while(i!==t.length);return t.splice(a),t.sort((e,t)=>e.hash<t.hash?1:-1),{portals:t}}}ra(Od,"ElevationPortalGraph");class Ud{constructor(e,t,r){this.outPositions=e,this.outNormals=t,this.outIndices=r,this.vertexLookup=new Map;}addVertex(e,t,r){let n=e[2];null!=r&&(n*=r);const i=`${e[0]},${e[1]},${e[2]},${t[0]},${t[1]},${t[2]}`,s=this.vertexLookup.get(i);if(null!=s)return s;const a=this.outPositions.length;this.vertexLookup.set(i,a);const o=Math.trunc(16384*t[0]),l=Math.trunc(16384*t[1]),u=Math.trunc(16384*t[2]);return this.outPositions.emplaceBack(e[0],e[1],n),this.outNormals.emplaceBack(o,l,u),a}addTriangle(e,t,r){this.outIndices.emplaceBack(e,t,r);}addTriangles(e,t,r){if(0===e.length)return;const n=1===r.length,i=_(),s=_();for(let a=0;a<e.length;a+=3){const o=t[e[a+0]],l=t[e[a+1]],u=t[e[a+2]],c=n?r[0]:r[e[a+1]],h=n?r[0]:r[e[a+2]];S(i,o.x,o.y,n?r[0]:r[e[a+0]]);const d=this.addVertex(i,s);S(i,l.x,l.y,c);const p=this.addVertex(i,s);S(i,u.x,u.y,h);const f=this.addVertex(i,s);this.outIndices.emplaceBack(d,p,f);}}addQuad(e,t,r,n,i,s){const a=this.addVertex(e,i,s),o=this.addVertex(t,i,s),l=this.addVertex(r,i,s),u=this.addVertex(n,i,s);this.addTriangle(a,o,l),this.addTriangle(l,u,a);}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear();}}class Nd{constructor(e,t,r,n){this.unevaluatedPortals=new Od,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new Ko,this.vertexNormals=new Qo,this.indexArray=new yl,this.tileToMeters=Ju(e),this.bridgeProgramConfigurations=new Au(t,{zoom:r,lut:n},e=>"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new Au(t,{zoom:r,lut:n},e=>"fill-bridge-guard-rail-color"!==e);}addVertices(e,t){const r=this.unevalVertices.length;for(let r=0;r<e.length;r++)this.unevalVertices.push(e[r]),this.unevalHeights.push(t[r]);return r}addTriangles(e,t,r){const n=r?this.unevalTunnelTriangles:this.unevalTriangles;for(const r of e)n.push(r+t);}addRenderableRing(e,t,r,n,i,s){const a=[new Me(i.min.x,i.min.y),new Me(i.max.x,i.min.y),new Me(i.max.x,i.max.y),new Me(i.min.x,i.max.y)];for(let o=0;o<r-1;o++){const r=t+o,l=r+1,u=this.unevalVertices[r],c=this.unevalVertices[l];if(!(u.x>=i.min.x&&u.x<=i.max.x&&u.y>=i.min.y&&u.y<=i.max.y||c.x>=i.min.x&&c.x<=i.max.x&&c.y>=i.min.y&&c.y<=i.max.y||Wc(u,c,a)))continue;if(this.isOnBorder(u.x,c.x)||this.isOnBorder(u.y,c.y))continue;const h=Nd.computeEdgeHash(this.unevalVertices[r],this.unevalVertices[l]);let d,p=this.vertexHashLookup.get(Nd.computePosHash(u));null!=p?d=p.next:(p=this.vertexHashLookup.get(Nd.computePosHash(c)),d=null!=p?p.prev:h),this.unevalEdges.push({polygonIdx:e,a:r,b:l,hash:h,portalHash:d,isTunnel:n,type:"unevaluated",featureInfo:s});}}addPortalCandidates(e,t,r,n,i){if(0!==t.length){this.vertexHashLookup.clear();for(const i of t){if(0===i.length)continue;const t=i[0];let s=Nd.computeEdgeHash(t[t.length-2],t[t.length-1]);for(let i=0;i<t.length-1;i++){const a=t[i+0],o=t[i+1],l=he(o.x-a.x,o.y-a.y),u=ye(l);if(0===u)continue;let c="unevaluated";const h=n.pointElevation(a),d=n.pointElevation(o);Math.abs(h)<.01&&Math.abs(d)<.01?c="entrance":(this.isOnBorder(a.x,o.x)||this.isOnBorder(a.y,o.y))&&(c="border");const p=Nd.computeEdgeHash(a,o);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:a,vb:o,vab:l,length:u,hash:p,isTunnel:r,type:c});const f=Nd.computePosHash(a);this.vertexHashLookup.set(f,{prev:s,next:p}),s=p;}}}}construct(e){if(0===this.unevalVertices.length)return;const t=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset;},n=new Ud(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const i=t(),s=t(),a=t(),o=(e,t)=>{e.sort((e,r)=>e.type===t&&r.type!==t?-1:e.type!==t&&r.type===t?1:0);const r=e.findIndex(e=>e.type!==t);return r>=0?r:e.length};let l=0;this.unevalEdges.length>0&&(l=o(this.unevalEdges,"none"),this.constructBridgeStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),r(a);const u=t(),c=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=o(e,"tunnel")+l;this.unevalEdges.push(...e),this.constructTunnelStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:t});}r(u),n.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(c),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(s),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),r(i),this.maskSegments=Xl.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.depthSegments=Xl.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableBridgeSegments=Xl.simpleSegment(0,a.primitiveOffset,0,a.primitiveLength),this.renderableTunnelSegments=Xl.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.shadowCasterSegments=Xl.simpleSegment(0,i.primitiveOffset,0,i.primitiveLength);}update(e,t,r,n,i,s,a,o){this.bridgeProgramConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o),this.tunnelProgramConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o);}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,ad.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,od.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e));}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy();}populatePaintArrays(e,t,r,n,i){const s=(s,a)=>{for(let o=0;o<a.length-1;o++){const l=a[o].featureIndex,u=a[o+1].vertexStart,c=e.feature(l);s.populatePaintArrays(u,c,l,{},r,t,n,void 0,i);}};s(this.bridgeProgramConfigurations,this.bridgeFeatureSections),s(this.tunnelProgramConfigurations,this.tunnelFeatureSections);}computeVertexConnections(e,t,r,n,i){const s=new Map;for(let a=n;a<i;a++){const n=r[a],i=n.a,o=n.b,l=Nd.computePosHash(e[i]),u=Nd.computePosHash(e[o]);let c=s.get(l);c||(c={},s.set(l,c));let h=s.get(u);h||(h={},s.set(u,h)),t[i]<=0&&t[o]<=0||(c.to=o,h.from=i);}return s}isTerminalVertex(e,t){const r=Nd.computePosHash(this.unevalVertices[e]),n=t.get(r);return !n||!n.from||!n.to}constructBridgeStructures(e,t,r,n,i,s){e.clearVertexLookup();const a=this.computeVertexConnections(t,r,n,i.min,i.max),o=1/s,l=.5*o,u=(e,n)=>S(e,t[n].x,t[n].y,r[n]*o),c=_(),h=_(),d=_(),p=_(),f=_(),m=(e,r)=>{const n=a.get(Nd.computePosHash(t[r])),i=n.from,s=n.to;if(!i||!s)return;u(c,i),u(h,r),u(d,s),q(p),H(c,h)||(X(f,h,c),L(p,f)),H(d,h)||(X(f,d,h),B(p,p,L(f,f)));const o=W(p);return o>0?F(e,p,1/o):void 0};let y=Number.POSITIVE_INFINITY;this.sortSubarray(n,i.min,i.max,(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex);const g=_(),x=_(),v=_(),b=_(),w=_(),A=_(),I=_(),M=_(),P=_(),T=[_(),_(),_(),_()],z=[_(),_(),_(),_()],k=[{coord:new Me(0,0),height:0},{coord:new Me(0,0),height:0}],V=(e,t)=>e>t;for(let u=i.min;u<i.max;u++){const i=n[u];if(!i.featureInfo.guardRailEnabled)continue;if(!this.prepareEdgePoints(k,t,r,i,V))continue;const[c,h]=k;if(S(g,c.coord.x,c.coord.y,o*c.height),S(x,h.coord.x,h.coord.y,o*h.height),H(g,x))continue;X(v,x,g),L(v,v);const d=m(M,i.a)||v,p=m(P,i.b)||v;S(b,d[1],-d[0],0),L(b,b),S(w,p[1],-p[0],0),L(w,w),U(M,b,d),L(A,M),U(M,w,p),L(I,M),B(T[0],g,F(M,X(M,b,A),l)),B(T[1],g,F(M,B(M,b,A),l)),B(T[2],g,F(M,A,l)),T[3]=g,B(z[0],x,F(M,X(M,w,I),l)),B(z[1],x,F(M,B(M,w,I),l)),B(z[2],x,F(M,I,l)),z[3]=x,y=this.addFeatureSection(i.featureInfo.featureIndex,y,this.bridgeFeatureSections,e);const f=e.addVertex(T[0],b,s),_=e.addVertex(T[1],b,s),D=e.addVertex(z[0],w,s),E=e.addVertex(z[1],w,s);e.addTriangle(f,_,D),e.addTriangle(_,E,D);const C=e.addVertex(T[1],A,s),O=e.addVertex(T[2],A,s),N=e.addVertex(z[1],I,s),j=e.addVertex(z[2],I,s);e.addTriangle(C,O,N),e.addTriangle(O,j,N),R(b,b),R(w,w);const G=e.addVertex(T[2],b,s),$=e.addVertex(T[3],b,s),q=e.addVertex(z[2],w,s),Z=e.addVertex(z[3],w,s);e.addTriangle(G,$,q),e.addTriangle($,Z,q);const W=this.isTerminalVertex(i.a,a),Y=this.isTerminalVertex(i.b,a);c.height<.01&&W&&e.addQuad(T[3],T[2],T[1],T[0],R(d,d),s),h.height<.01&&Y&&e.addQuad(z[0],z[1],z[2],z[3],p,s);}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()});}constructTunnelStructures(e,t,r,n,i,s){e.clearVertexLookup();let a=Number.POSITIVE_INFINITY;const o=(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(n,i.min,i.max,o),this.sortSubarray(n,s.min,s.max,o);const l=e=>L(e,e),u=[{coord:new Me(0,0),height:0},{coord:new Me(0,0),height:0}],c=(e,t)=>e<t,h=_(),d=_(),p=_(),f=_(),m=_();for(let s=i.min;s<i.max;s++){if(!this.prepareEdgePoints(u,t,r,n[s],c))continue;const[i,o]=u,y=l(S(m,-(o.coord.y-i.coord.y),o.coord.x-i.coord.x,0));a=this.addFeatureSection(n[s].featureInfo.featureIndex,a,this.tunnelFeatureSections,e),e.addQuad(S(h,i.coord.x,i.coord.y,i.height),S(d,o.coord.x,o.coord.y,o.height),S(p,o.coord.x,o.coord.y,n[s].isTunnel?-.1:0),S(f,i.coord.x,i.coord.y,n[s].isTunnel?-.1:0),y);}for(let i=s.min;i<s.max;i++){const s=n[i];s.isTunnel&&([s.a,s.b]=[s.b,s.a]);const o=t[s.a],u=t[s.b],c=l(S(m,-(u.y-o.y),u.x-o.x,0));a=this.addFeatureSection(s.featureInfo.featureIndex,a,this.tunnelFeatureSections,e),e.addQuad(S(h,u.x,u.y,0),S(d,o.x,o.y,0),S(p,o.x,o.y,r[s.a]+4),S(f,u.x,u.y,r[s.b]+4),c),e.addQuad(S(h,o.x,o.y,0),S(d,u.x,u.y,0),S(p,u.x,u.y,r[s.b]+4),S(f,o.x,o.y,r[s.a]+4),c);}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()});}setElevatedPoint(e,t,r,n){e.coord.x=t,e.coord.y=r,e.height=n;}prepareEdgePoints(e,t,r,n,i){let s=t[n.a].x,a=t[n.a].y,o=t[n.b].x,l=t[n.b].y,u=r[n.a],c=r[n.b];const h=i(u,0),d=i(c,0);if(h&&d)return this.setElevatedPoint(e[0],s,a,u),this.setElevatedPoint(e[1],o,l,c),!0;if(!h&&!d)return !1;if(h){if(!d){const e=c/(c-u);o=yr(o,s,e),l=yr(l,a,e),c=yr(c,u,e);}}else {const e=u/(u-c);s=yr(s,o,e),a=yr(a,l,e),u=yr(u,c,e);}return this.setElevatedPoint(e[0],s,a,u),this.setElevatedPoint(e[1],o,l,c),!0}prepareEdges(e,t){if(0===t.length)return;t.sort((e,t)=>e.hash===t.hash?t.polygonIdx-e.polygonIdx:t.hash>e.hash?1:-1);let r=0,n=0,i=0,s=t[r].polygonIdx;do{n++,(n===t.length||t[r].hash!==t[n].hash)&&((1===n-r||t[n-1].polygonIdx!==s)&&(i<r&&(t[i]=t[r],t[r]=null),t[i].type="none",i++),r=n,r!==t.length&&(s=t[r].polygonIdx));}while(r!==t.length);if(t.splice(i),0!==t.length&&0!==e.length){t.sort((e,t)=>e.portalHash<t.portalHash?1:-1);let r=0,n=0;for(;r!==t.length&&n!==e.length;){const i=t[r],s=e[n];i.portalHash>s.hash?r++:s.hash>i.portalHash?n++:(i.type=s.type,r++);}}}isOnBorder(e,t){return e<=0&&t<=0||e>=qn&&t>=qn}addFeatureSection(e,t,r,n){return e!==t&&(t=e,r.push({featureIndex:e,vertexStart:n.getVertexCount()}),n.clearVertexLookup()),t}sortSubarray(e,t,r,n){const i=e.slice(t,r);i.sort(n),e.splice(t,i.length,...i);}static computeEdgeHash(e,t){return (e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(Nd.computePosHash(e))<<32n|BigInt(Nd.computePosHash(t))}static computePosHash(e){return ((65535&e.x)<<16|65535&e.y)>>>0}}function jd(e,t){return e>t?1:e<t?-1:0}class Gd{constructor(e=jd,t=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!t;}rotateLeft(e){var t=e.right;t&&(e.right=t.left,t.left&&(t.left.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.left=e),e.parent=t;}rotateRight(e){var t=e.left;t&&(e.left=t.right,t.right&&(t.right.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.right=e),e.parent=t;}_splay(e){for(;e.parent;){var t=e.parent;t.parent?t.left===e&&t.parent.left===t?(this.rotateRight(t.parent),this.rotateRight(t)):t.right===e&&t.parent.right===t?(this.rotateLeft(t.parent),this.rotateLeft(t)):t.left===e&&t.parent.right===t?(this.rotateRight(t),this.rotateLeft(t)):(this.rotateLeft(t),this.rotateRight(t)):t.left===e?this.rotateRight(t):this.rotateLeft(t);}}splay(e){for(var t,r,n,i,s;e.parent;)(r=(t=e.parent).parent)&&r.parent?((n=r.parent).left===r?n.left=e:n.right=e,e.parent=n):(e.parent=null,this._root=e),i=e.left,s=e.right,e===t.left?(r&&(r.left===t?(t.right?(r.left=t.right,r.left.parent=r):r.left=null,t.right=r,r.parent=t):(i?(r.right=i,i.parent=r):r.right=null,e.left=r,r.parent=e)),s?(t.left=s,s.parent=t):t.left=null,e.right=t,t.parent=e):(r&&(r.right===t?(t.left?(r.right=t.left,r.right.parent=r):r.right=null,t.left=r,r.parent=t):(s?(r.left=s,s.parent=r):r.left=null,e.right=r,r.parent=e)),i?(t.right=i,i.parent=t):t.right=null,e.left=t,t.parent=e);}replace(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.parent=e.parent);}minNode(e=this._root){if(e)for(;e.left;)e=e.left;return e}maxNode(e=this._root){if(e)for(;e.right;)e=e.right;return e}insert(e,t){var r=this._root,n=null,i=this._compare;if(this._noDuplicates)for(;r;){if(n=r,0===i(r.key,e))return;r=i(r.key,e)<0?r.right:r.left;}else for(;r;)n=r,r=i(r.key,e)<0?r.right:r.left;return r={key:e,data:t,left:null,right:null,parent:n},n?i(n.key,r.key)<0?n.right=r:n.left=r:this._root=r,this.splay(r),this._size++,r}find(e){for(var t=this._root,r=this._compare;t;){var n=r(t.key,e);if(n<0)t=t.right;else {if(!(n>0))return t;t=t.left;}}return null}contains(e){for(var t=this._root,r=this._compare;t;){var n=r(e,t.key);if(0===n)return !0;t=n<0?t.left:t.right;}return !1}remove(e){var t=this.find(e);if(!t)return !1;if(this.splay(t),t.left)if(t.right){var r=this.minNode(t.right);r.parent!==t&&(this.replace(r,r.right),r.right=t.right,r.right.parent=r),this.replace(t,r),r.left=t.left,r.left.parent=r;}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return !1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t;}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var r=t.left,n=t.right,i=null;r&&(r.parent=null,i=this.maxNode(r),this.splay(i),this._root=i),n&&(r?i.right=n:this._root=n,n.parent=i),this._size--;}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key);}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,r=[],n=!1,i=0;!n;)t?(r.push(t),t=t.left):r.length>0?(e(t=r.pop(),i++),t=t.right):n=!0;return this}range(e,t,r,n){const i=[],s=this._compare;let a,o=this._root;for(;0!==i.length||o;)if(o)i.push(o),o=o.left;else {if(o=i.pop(),a=s(o.key,t),a>0)break;if(s(o.key,e)>=0&&r.call(n,o))return this;o=o.right;}return this}keys(){for(var e=this._root,t=[],r=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.key),e=e.right):n=!0;return r}values(){for(var e=this._root,t=[],r=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.data),e=e.right):n=!0;return r}at(e){for(var t=this._root,r=[],n=!1,i=0;!n;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),i===e)return t;i++,t=t.right;}else n=!0;return null}load(e=[],t=[],r=!1){if(0!==this._size)throw new Error("bulk-load: tree is not empty");const n=e.length;return r&&qd(e,t,0,n-1,this._compare),this._root=$d(null,e,t,0,n),this._size=n,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(e,t,r,n,i){return new Gd(r,i).load(e,t,n)}}function $d(e,t,r,n,i){const s=i-n;if(s>0){const a=n+Math.floor(s/2),o={key:t[a],data:r[a],parent:e};return o.left=$d(o,t,r,n,a),o.right=$d(o,t,r,a+1,i),o}return null}function qd(e,t,r,n,i){if(r>=n)return;const s=e[r+n>>1];let a=r-1,o=n+1;for(;;){do{a++;}while(i(e[a],s)<0);do{o--;}while(i(e[o],s)>0);if(a>=o)break;let r=e[a];e[a]=e[o],e[o]=r,r=t[a],t[a]=t[o],t[o]=r;}qd(e,t,r,o,i),qd(e,t,o+1,n,i);}const Hd=11102230246251565e-32,Xd=134217729,Zd=(3+8*Hd)*Hd;function Wd(e,t,r,n,i){let s,a,o,l,u=t[0],c=n[0],h=0,d=0;c>u==c>-u?(s=u,u=t[++h]):(s=c,c=n[++d]);let p=0;if(h<e&&d<r)for(c>u==c>-u?(a=u+s,o=s-(a-u),u=t[++h]):(a=c+s,o=s-(a-c),c=n[++d]),s=a,0!==o&&(i[p++]=o);h<e&&d<r;)c>u==c>-u?(a=s+u,l=a-s,o=s-(a-l)+(u-l),u=t[++h]):(a=s+c,l=a-s,o=s-(a-l)+(c-l),c=n[++d]),s=a,0!==o&&(i[p++]=o);for(;h<e;)a=s+u,l=a-s,o=s-(a-l)+(u-l),u=t[++h],s=a,0!==o&&(i[p++]=o);for(;d<r;)a=s+c,l=a-s,o=s-(a-l)+(c-l),c=n[++d],s=a,0!==o&&(i[p++]=o);return 0===s&&0!==p||(i[p++]=s),p}function Yd(e){return new Float64Array(e)}const Jd=Yd(4),Kd=Yd(8),Qd=Yd(12),ep=Yd(16),tp=Yd(4);function rp(e,t,r){null===t?(e.inOut=!1,e.otherInOut=!0):(e.isSubject===t.isSubject?(e.inOut=!t.inOut,e.otherInOut=t.otherInOut):(e.inOut=!t.otherInOut,e.otherInOut=t.isVertical()?!t.inOut:t.inOut),t&&(e.prevInResult=!np(t,r)||t.isVertical()?t.prevInResult:t)),e.resultTransition=np(e,r)?function(e,t){let r,n=!e.inOut,i=!e.otherInOut;switch(t){case 0:r=n&&i;break;case 1:r=n||i;break;case 3:r=n!==i;break;case 2:r=e.isSubject?n&&!i:i&&!n;}return r?1:-1}(e,r):0;}function np(e,t){switch(e.type){case 0:switch(t){case 0:return !e.otherInOut;case 1:return e.otherInOut;case 2:return e.isSubject&&e.otherInOut||!e.isSubject&&!e.otherInOut;case 3:return !0}break;case 2:return 0===t||1===t;case 3:return 2===t;case 1:return !1}return !1}class ip{constructor(e,t,r,n,i){this.left=t,this.point=e,this.otherEvent=r,this.isSubject=n??!1,this.type=i||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0;}isBelow(e){const t=this.point,r=this.otherEvent.point;return this.left?(t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1])>0:(r[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(r[1]-e[1])>0}isAbove(e){return !this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){const e=new ip(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function sp(e,t){return e[0]===t[0]&&e[1]===t[1]}function ap(e,t,r){const n=function(e,t,r,n,i,s){const a=(t-s)*(r-i),o=(e-i)*(n-s),l=a-o;if(0===a||0===o||a>0!=o>0)return l;const u=Math.abs(a+o);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,r,n,i,s,a){let o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,I;const M=e-i,S=r-i,B=t-s,P=n-s;b=M*P,d=Xd*M,p=d-(d-M),f=M-p,d=Xd*P,m=d-(d-P),y=P-m,w=f*y-(b-p*m-f*m-p*y),_=B*S,d=Xd*B,p=d-(d-B),f=B-p,d=Xd*S,m=d-(d-S),y=S-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,Jd[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,Jd[1]=v-(g+h)+(h-_),I=x+g,h=I-x,Jd[2]=x-(I-h)+(g-h),Jd[3]=I;let T=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,Jd),z=22204460492503146e-32*a;if(T>=z||-T>=z)return T;if(h=e-M,o=e-(M+h)+(h-i),h=r-S,u=r-(S+h)+(h-i),h=t-B,l=t-(B+h)+(h-s),h=n-P,c=n-(P+h)+(h-s),0===o&&0===l&&0===u&&0===c)return T;if(z=11093356479670487e-47*a+Zd*Math.abs(T),T+=M*c+P*o-(B*u+S*l),T>=z||-T>=z)return T;b=o*P,d=Xd*o,p=d-(d-o),f=o-p,d=Xd*P,m=d-(d-P),y=P-m,w=f*y-(b-p*m-f*m-p*y),_=l*S,d=Xd*l,p=d-(d-l),f=l-p,d=Xd*S,m=d-(d-S),y=S-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,tp[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,tp[1]=v-(g+h)+(h-_),I=x+g,h=I-x,tp[2]=x-(I-h)+(g-h),tp[3]=I;const k=Wd(4,Jd,4,tp,Kd);b=M*c,d=Xd*M,p=d-(d-M),f=M-p,d=Xd*c,m=d-(d-c),y=c-m,w=f*y-(b-p*m-f*m-p*y),_=B*u,d=Xd*B,p=d-(d-B),f=B-p,d=Xd*u,m=d-(d-u),y=u-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,tp[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,tp[1]=v-(g+h)+(h-_),I=x+g,h=I-x,tp[2]=x-(I-h)+(g-h),tp[3]=I;const F=Wd(k,Kd,4,tp,Qd);b=o*c,d=Xd*o,p=d-(d-o),f=o-p,d=Xd*c,m=d-(d-c),y=c-m,w=f*y-(b-p*m-f*m-p*y),_=l*u,d=Xd*l,p=d-(d-l),f=l-p,d=Xd*u,m=d-(d-u),y=u-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,tp[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,tp[1]=v-(g+h)+(h-_),I=x+g,h=I-x,tp[2]=x-(I-h)+(g-h),tp[3]=I;const V=Wd(F,Qd,4,tp,ep);return ep[V-1]}(e,t,r,n,i,s,u)}(e[0],e[1],t[0],t[1],r[0],r[1]);return n>0?-1:n<0?1:0}function op(e,t){const r=e.point,n=t.point;return r[0]>n[0]?1:r[0]<n[0]?-1:r[1]!==n[1]?r[1]>n[1]?1:-1:function(e,t,r){return e.left!==t.left?e.left?1:-1:0!==ap(r,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,r)}function lp(e,t,r){const n=new ip(t,!1,e,e.isSubject),i=new ip(t,!0,e.otherEvent,e.isSubject);return sp(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),n.contourId=i.contourId=e.contourId,op(i,e.otherEvent)>0&&(e.otherEvent.left=!0,i.left=!1),e.otherEvent.otherEvent=i,e.otherEvent=n,r.push(i),r.push(n),r}function up(e,t){return e[0]*t[1]-e[1]*t[0]}function cp(e,t){return e[0]*t[0]+e[1]*t[1]}function hp(e,t,r){const n=function(e,t,r,n){const i=[t[0]-e[0],t[1]-e[1]],s=[n[0]-r[0],n[1]-r[1]];function a(e,t,r){return [e[0]+t*r[0],e[1]+t*r[1]]}const o=[r[0]-e[0],r[1]-e[1]];let l=up(i,s),u=l*l;const c=cp(i,i);if(u>0){const t=up(o,s)/l;if(t<0||t>1)return null;const n=up(o,i)/l;return n<0||n>1?null:0===t||1===t?[a(e,t,i)]:0===n||1===n?[a(r,n,s)]:[a(e,t,i)]}if(l=up(o,i),u=l*l,u>0)return null;const h=cp(i,o)/c,d=h+cp(i,s)/c,p=Math.min(h,d),f=Math.max(h,d);return p<=1&&f>=0?1===p?[a(e,p>0?p:0,i)]:0===f?[a(e,f<1?f:1,i)]:[a(e,p>0?p:0,i),a(e,f<1?f:1,i)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),i=n?n.length:0;if(0===i||1===i&&(sp(e.point,t.point)||sp(e.otherEvent.point,t.otherEvent.point))||2===i&&e.isSubject===t.isSubject)return 0;if(1===i)return !sp(e.point,n[0])&&!sp(e.otherEvent.point,n[0])&&lp(e,n[0],r),!sp(t.point,n[0])&&!sp(t.otherEvent.point,n[0])&&lp(t,n[0],r),1;const s=[];let a=!1,o=!1;return sp(e.point,t.point)?a=!0:1===op(e,t)?s.push(t,e):s.push(e,t),sp(e.otherEvent.point,t.otherEvent.point)?o=!0:1===op(e.otherEvent,t.otherEvent)?s.push(t.otherEvent,e.otherEvent):s.push(e.otherEvent,t.otherEvent),a&&o||a?(t.type=1,e.type=t.inOut===e.inOut?2:3,a&&!o&&lp(s[1].otherEvent,s[0].point,r),2):o?(lp(s[0],s[1].point,r),3):s[0]!==s[3].otherEvent?(lp(s[0],s[1].point,r),lp(s[1],s[2].point,r),3):(lp(s[0],s[1].point,r),lp(s[3].otherEvent,s[2].point,r),3)}function dp(e,t){if(e===t)return 0;if(0!==ap(e.point,e.otherEvent.point,t.point)||0!==ap(e.point,e.otherEvent.point,t.otherEvent.point))return sp(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1]<t.point[1]?-1:1:1===op(e,t)?t.isAbove(e.point)?-1:1:e.isBelow(t.point)?-1:1;if(e.isSubject!==t.isSubject)return e.isSubject?-1:1;{let r=e.point,n=t.point;if(r[0]===n[0]&&r[1]===n[1])return r=e.otherEvent.point,n=t.otherEvent.point,r[0]===n[0]&&r[1]===n[1]?0:(e.contourId??0)>(t.contourId??0)?1:-1}return 1===op(e,t)?1:-1}class pp{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null;}isExterior(){return null==this.holeOf}}function fp(e,t,r,n){let i,s=e+1,a=t[e].point;const o=t.length;for(s<o&&(i=t[s].point);s<o&&i[0]===a[0]&&i[1]===a[1];){if(!r[s])return s;s++,s<o&&(i=t[s].point);}for(s=e-1;r[s]&&s>n;)s--;return s}function mp(e,t,r){const n=new pp;if(null!=e.prevInResult){const i=e.prevInResult,s=i.outputContourId;if(i.resultTransition>0){const e=t[s];if(null!=e.holeOf){const i=e.holeOf;t[i].holeIds.push(r),n.holeOf=i,n.depth=t[s].depth;}else t[s].holeIds.push(r),n.holeOf=s,n.depth=t[s].depth+1;}else n.holeOf=null,n.depth=t[s].depth;}else n.holeOf=null,n.depth=0;return n}const yp=Math.max,gp=Math.min;let xp=0;function vp(e,t,r,n,i,s){let a,o,l,u,c,h;for(a=0,o=e.length-1;a<o;a++){if(l=e[a],u=e[a+1],c=new ip(l,!1,void 0,t),h=new ip(u,!1,c,t),c.otherEvent=h,l[0]===u[0]&&l[1]===u[1])continue;c.contourId=h.contourId=r,s||(c.isExteriorRing=!1,h.isExteriorRing=!1),op(c,h)>0?h.left=!0:c.left=!0;const o=l[0],d=l[1];i[0]=gp(i[0],o),i[1]=gp(i[1],d),i[2]=yp(i[2],o),i[3]=yp(i[3],d),n.push(c),n.push(h);}}const bp=[];function wp(e,t,r){let n=e,i=t;"number"==typeof e[0][0][0]&&(n=[e]),"number"==typeof t[0][0][0]&&(i=[t]);let s=function(e,t,r){let n=null;return e.length*t.length===0&&(0===r?n=bp:2===r?n=e:(1===r||3===r)&&(n=0===e.length?t:e)),n}(n,i,r);if(s)return s===bp?null:s;const a=[1/0,1/0,-1/0,-1/0],o=[1/0,1/0,-1/0,-1/0],l=function(e,t,r,n,i){const s=new $n(void 0,op);let a,o,l,u,c,h;for(l=0,u=e.length;l<u;l++)for(a=e[l],c=0,h=a.length;c<h;c++)o=0===c,o&&xp++,vp(a[c],!0,xp,s,r,o);for(l=0,u=t.length;l<u;l++)for(a=t[l],c=0,h=a.length;c<h;c++)o=0===c,2===i&&(o=!1),o&&xp++,vp(a[c],!1,xp,s,n,o);return s}(n,i,a,o,r);if(s=function(e,t,r,n,i){let s=null;return (r[0]>n[2]||n[0]>r[2]||r[1]>n[3]||n[1]>r[3])&&(0===i?s=bp:2===i?s=e:(1===i||3===i)&&(s=e.concat(t))),s}(n,i,a,o,r),s)return s===bp?null:s;const u=function(e,t,r,n,i,s){const a=new Gd(dp),o=[],l=Math.min(n[2],i[2]);let u,c,h;for(;0!==e.length;){let t=e.pop();if(o.push(t),0===s&&t.point[0]>l||2===s&&t.point[0]>n[2])break;if(t.left){c=u=a.insert(t),h=a.minNode(),u=u!==h?a.prev(u):null,c=a.next(c);const r=u?u.key:null;let n;if(rp(t,r,s),c&&2===hp(t,c.key,e)&&(rp(t,r,s),rp(c.key,t,s)),u&&2===hp(u.key,t,e)){let e=u;e=e!==h?a.prev(e):null,n=e?e.key:null,rp(r,n,s),rp(t,r,s);}}else t=t.otherEvent,c=u=a.find(t),u&&c&&(u=u!==h?a.prev(u):null,c=a.next(c),a.remove(t),c&&u&&hp(u.key,c.key,e));}return o}(l,0,0,a,o,r),c=function(e){let t,r;const n=function(e){let t,r,n,i,s;const a=[];for(r=0,n=e.length;r<n;r++)t=e[r],(t.left&&t.inResult||!t.left&&t.otherEvent.inResult)&&a.push(t);let o=!1;for(;!o;)for(o=!0,r=0,n=a.length;r<n;r++)r+1<n&&1===op(a[r],a[r+1])&&(i=a[r],a[r]=a[r+1],a[r+1]=i,o=!1);for(r=0,n=a.length;r<n;r++)t=a[r],t.otherPos=r;for(r=0,n=a.length;r<n;r++)t=a[r],t.left||(s=t.otherPos,t.otherPos=t.otherEvent.otherPos,t.otherEvent.otherPos=s);return a}(e),i={},s=[];for(t=0,r=n.length;t<r;t++){if(i[t])continue;const e=s.length,r=mp(n[t],s,e),a=t=>{i[t]=!0,t<n.length&&n[t]&&(n[t].outputContourId=e);};let o=t,l=t;for(r.points.push(n[t].point);a(o),o=n[o].otherPos,a(o),r.points.push(n[o].point),o=fp(o,n,i,l),!(o==l||o>=n.length)&&n[o];);s.push(r);}return s}(u),h=[];for(let e=0;e<c.length;e++){let t=c[e];if(t.isExterior()){let e=[t.points];for(let r=0;r<t.holeIds.length;r++)e.push(c[t.holeIds[r]].points);h.push(e);}}return h}function _p(e,t,r,n){const i=[],s=0===n?(e,t,r,n,i,s)=>{e.push(new Me(s,r+(s-t)/(n-t)*(i-r)));}:(e,t,r,n,i,s)=>{e.push(new Me(t+(s-r)/(i-r)*(n-t),s));};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;e<i.length-1;e++){const o=i[e].x,l=i[e].y,u=i[e+1].x,c=i[e+1].y,h=0===n?o:l,d=0===n?u:c;h<t?d>t&&s(a,o,l,u,c,t):h>r?d<r&&s(a,o,l,u,c,r):a.push(i[e]),d<t&&h>=t&&s(a,o,l,u,c,t),d>r&&h<=r&&s(a,o,l,u,c,r);}let o=i[i.length-1];const l=0===n?o.x:o.y;l>=t&&l<=r&&a.push(o),a.length&&(o=a[a.length-1],a[0].x===o.x&&a[0].y===o.y||a.push(a[0]),e.push(a));}e.length&&i.push(e);}return i}function Ap(e,t){const r=wp(Mp(e),Mp([t]),0);return null==r?[]:Sp(r)}function Ip(e,t,r=0){const n=65536;let i=Mp(e,n);const s=[];for(;t.valid();t.next()){const[e,i]=t.get();let a=e.x*n,o=e.y*n,l=i.x*n,u=i.y*n;const c=l-a,h=u-o,d=Math.hypot(c,h);if(0===d)continue;a-=c*r,o-=h*r,l+=c*r,u+=h*r;const p=Math.trunc(h/d*3),f=-Math.trunc(c/d*3);s.push([[[a,o],[l,u],[l+p,u+f],[a+p,o+f],[a,o]]]);}return s.length>0&&(i=wp(i,s,2)),Sp(i,1/n,128)}function Mp(e,t=1){return [e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function Sp(e,t=1,r){return e.map(e=>e.map((e,n)=>{const i=e.map(e=>{let n=e[0],i=e[1];return r&&(n=Math.round(n/r)*r,i=Math.round(i/r)*r),new Me(n*t,i*t)._round()});return n>0&&i.reverse(),i}))}class Bp{constructor(e,t){this.layoutVertexArray=new Zo,this.indexArray=new yl,this.lineIndexArray=new hl,this.triangleSegments=new Xl,this.lineSegments=new Xl,this.programConfigurations=new Au(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new Jo);}update(e,t,r,n,i,s,a,o){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o);}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,id.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,sd.members))),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy());}populatePaintArrays(e,t,r,n,i,s,a){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,r,n,i,s,void 0,a);}}class Pp{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new Bp(e,!1),this.elevationBufferData=new Bp(e,!0),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.hasPattern=Rd("fill",this.layers,this.pixelRatio,t);const i=this.layers[0].layout.get("fill-sort-key"),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=oc(a,e);if(!this.layers[0]._featureFilter.filter(new to(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r,t.availableImages):void 0,d={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:ac(a,r,n),patterns:{},sortKey:h};s.push(d);}i&&s.sort((e,t)=>e.sortKey-t.sortKey);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const e=Ld("fill",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,i,s,r,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[s].feature,i,s,a,this.index);}}update(e,t,r,n,i,s,a){this.bufferData.update(e,t,r,n,i,s,a,this.worldview),this.elevationBufferData.update(e,t,r,n,i,s,a,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,r,n,i,s,a,this.worldview);}addFeatures(e,t,r,n,i,s){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,s,e.elevationFeatures);}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return !this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e);}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy();}addFeature(e,t,r,n,i,s=[],a,o){const l=Dd(t,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,l,n,r,o):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(e,r,i,s,n,a,this.worldview),this.elevationBufferData.populatePaintArrays(e,r,i,s,n,a,this.worldview);}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,t,r,n,i){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,r,n,i,this.worldview));}addElevatedRoadFeature(e,t,r,n,i){const s=new Array,a=Vc.getElevationFeature(e,i);if(!a)return void this.addGeometry(t,this.bufferData);{const e=this.clipPolygonsToTile(t,1);e.length>0&&s.push({polygons:e,elevationFeature:a,elevationTileID:r});}const o={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},r),featureIndex:n};for(const t of s)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new Nd(t.elevationTileID,this.layers,this.zoom,this.lut));const r=t.elevationFeature.isTunnel();let n=0;e.properties.hasOwnProperty(yc)&&(n=+e.properties[yc]),this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,t.polygons,r,t.elevationFeature,n);}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const i=new Dc(r,t.elevationTileID);this.addElevatedGeometry(t.polygons,i,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,n,o);}}addElevatedGeometry(e,t,r,n,i,s){const a={elevation:r,elevationSampler:t,bias:n,index:i,featureInfo:s},[o,l]=this.addGeometry(e,this.elevationBufferData,a);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:o,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,o),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l));}addGeometry(e,t,r){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=null;r&&(s=r.elevationSampler.constantElevation(r.elevation,r.bias),null!=s&&(n=s,i=s));const a=(e,a,o)=>{if(null!=r)if(a.push(e),null!=s)t.elevatedLayoutVertexArray.emplaceBack(s),o.push(s);else {const s=r.elevationSampler.pointElevation(e,r.elevation,r.bias);t.elevatedLayoutVertexArray.emplaceBack(s),o.push(s),n=Math.min(n,s),i=Math.max(i,s);}};for(const n of e){let e=0;for(const t of n)e+=t.length;const i=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),s=i.vertexLength,o=[],l=[],u=[],c=[],h=[],d=t.layoutVertexArray.length;for(const e of n){if(0===e.length)continue;e!==n[0]&&l.push(o.length/2);const i=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),s=i.vertexLength;r&&h.push(t.layoutVertexArray.length-d),a(e[0],u,c),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(s+e.length-1,s),o.push(e[0].x),o.push(e[0].y);for(let r=1;r<e.length;r++)a(e[r],u,c),t.layoutVertexArray.emplaceBack(e[r].x,e[r].y),t.lineIndexArray.emplaceBack(s+r-1,s+r),o.push(e[r].x),o.push(e[r].y);i.vertexLength+=e.length,i.primitiveLength+=e.length;}const p=ld(o,l);for(let e=0;e<p.length;e+=3)t.indexArray.emplaceBack(s+p[e],s+p[e+1],s+p[e+2]);if(p.length>0&&r&&"hd-road-base"===this.elevationMode){const e=r.elevation.isTunnel(),t=r.elevation.safeArea,n=this.elevatedStructures.addVertices(u,c);this.elevatedStructures.addTriangles(p,n,e);const i=h.length;if(i>0){for(let s=0;s<i-1;s++)this.elevatedStructures.addRenderableRing(r.index,h[s]+n,h[s+1]-h[s],e,t,r.featureInfo);this.elevatedStructures.addRenderableRing(r.index,h[i-1]+n,u.length-h[i-1],e,t,r.featureInfo);}}i.vertexLength+=e,i.primitiveLength+=p.length/3;}return [n,i]}prepareElevatedPolygons(e,t,r){const n=1/Ju(r),i=[];for(const r of e){const e=Ip(r,new kc(t,n),.1);i.push(...e);}return i}clipPolygonsToTile(e,t){const r=-t,n=-t,i=qn+t,s=qn+t;let a=0;const o=[],l=[];for(;a<e.length;a++){const t=e[a],u=An(t);(u.min.x>=r&&u.max.x<=i&&u.min.y>=n&&u.max.y<=s?o:l).push(t);}if(o.length===e.length)return e;const u=[new Me(r,n),new Me(i,n),new Me(i,s),new Me(r,s),new Me(r,n)],c=o;for(const e of l)c.push(...Ap(e,u));return c}}let Tp,zp,kp,Fp;ra(Pp,"FillBucket",{omit:["layers","patternFeatures"]}),ra(Bp,"FillBufferData"),ra(Nd,"ElevatedStructures");class Vp{constructor(e,t,r,n){if(this.triangleCount=t.length/3,this.min=new Me(0,0),this.max=new Me(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[i,s]=[e[0].clone(),e[0].clone()];for(let t=1;t<e.length;++t){const r=e[t];i.x=Math.min(i.x,r.x),i.y=Math.min(i.y,r.y),s.x=Math.max(s.x,r.x),s.y=Math.max(s.y,r.y);}if(n){const e=Math.ceil(Math.max(s.x-i.x,s.y-i.y)/n);r=Math.max(r,e);}if(0===r)return;this.min=i,this.max=s;const a=this.max.sub(this.min);a.x=Math.max(a.x,1),a.y=Math.max(a.y,1);const o=Math.max(a.x,a.y)/r;this.cellsX=Math.max(1,Math.ceil(a.x/o)),this.cellsY=Math.max(1,Math.ceil(a.y/o)),this.xScale=1/o,this.yScale=1/o;const l=[];for(let r=0;r<this.triangleCount;r++){const n=e[t[3*r+0]].sub(this.min),i=e[t[3*r+1]].sub(this.min),s=e[t[3*r+2]].sub(this.min),a=Dp(Math.floor(Math.min(n.x,i.x,s.x)),this.xScale,this.cellsX),u=Dp(Math.floor(Math.max(n.x,i.x,s.x)),this.xScale,this.cellsX),c=Dp(Math.floor(Math.min(n.y,i.y,s.y)),this.yScale,this.cellsY),h=Dp(Math.floor(Math.max(n.y,i.y,s.y)),this.yScale,this.cellsY),d=new Me(0,0),p=new Me(0,0),f=new Me(0,0),m=new Me(0,0);for(let e=c;e<=h;++e){d.y=p.y=e*o,f.y=m.y=(e+1)*o;for(let t=a;t<=u;++t)d.x=f.x=t*o,p.x=m.x=(t+1)*o,(Jc(n,i,s,d,p,m)||Jc(n,i,s,d,m,f))&&l.push({cellIdx:e*this.cellsX+t,triIdx:r});}}if(0===l.length)return;l.sort((e,t)=>e.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let u=0;for(;u<l.length;){const e=l[u].cellIdx,t={start:this.payload.length,len:0};for(;u<l.length&&l[u].cellIdx===e;)++t.len,this.payload.push(l[u++].triIdx);this.cells[e]=t;}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0);}queryPoint(e,t){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const r=Dp(e.x-this.min.x,this.xScale,this.cellsX),n=Dp(e.y-this.min.y,this.yScale,this.cellsY),i=this.cells[n*this.cellsX+r];if(i){this._lazyInitLookup();for(let e=0;e<i.len;e++){const r=this.payload[i.start+e],n=Math.floor(r/8),s=1<<r%8;if(!(this.lookup[n]&s)&&(this.lookup[n]|=s,t.push(r),t.length===this.triangleCount))return}}}query(e,t,r){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=Dp(e.x-this.min.x,this.xScale,this.cellsX),i=Dp(t.x-this.min.x,this.xScale,this.cellsX),s=Dp(e.y-this.min.y,this.yScale,this.cellsY),a=Dp(t.y-this.min.y,this.yScale,this.cellsY);for(let e=s;e<=a;e++)for(let t=n;t<=i;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;e<n.len;e++){const t=this.payload[n.start+e],i=Math.floor(t/8),s=1<<t%8;if(!(this.lookup[i]&s)&&(this.lookup[i]|=s,r.push(t),r.length===this.triangleCount))return}}}}function Dp(e,t,r){return Math.max(0,Math.min(r-1,Math.floor(e*t)))}ra(Vp,"TriangleGridIndex");class Ep{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){for(const r of this.footprints)t.push({footprint:r,id:e});}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){const i=[];for(const{feature:s,id:a,index:o,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=oc(s,e);if(!this.layers[0]._featureFilter.filter(new to(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,r))continue;const c={id:a,properties:s.properties,type:s.type,sourceLayerIndex:l,index:o,geometry:e?u.geometry:ac(s,r,n),patterns:{}};i.push(c);}for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n;this.addFeature(n,i,s,r,{},t.availableImages,t.brightness),t.featureIndex.insert(e[s].feature,i,s,a,this.index);}}isEmpty(){return 0===this.footprints.length}uploadPending(){return !1}upload(e){}update(e,t,r,n,i,s,a){}destroy(){}addFeature(e,t,r,n,i,s=[],a){for(const e of Dd(t,2)){const t=[],r=[],n=[],i=new Me(1/0,1/0),s=new Me(-1/0,-1/0);for(const a of e)if(0!==a.length){a!==e[0]&&n.push(r.length/2);for(let e=0;e<a.length;e++)r.push(a[e].x),r.push(a[e].y),t.push(a[e]),i.x=Math.min(i.x,a[e].x),i.y=Math.min(i.y,a[e].y),s.x=Math.max(s.x,a[e].x),s.y=Math.max(s.y,a[e].y);}const a=ld(r,n),o=new Vp(t,a,8,256);this.footprints.push({vertices:t,indices:a,grid:o,min:i,max:s});}}}ra(Ep,"ClipBucket",{omit:["layers"]});const Cp=Ho([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Rp=Ho([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Lp=Ho([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),Op=Ho([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Up=Ho([{name:"a_join_normal_inside",components:3,type:"Int16"}]),Np=Ho([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),jp=Ho([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Gp}=Cp,$p=Number.MAX_SAFE_INTEGER,qp=$p-1;function Hp(e,t,r,n){return e.order<t||e.order===$p||!(e.clipMask&r)||function(e,t){if(0===t.length)return !1;let r=e;for(;""!==r;){if(t.includes(r))return !1;r=Vo(r);}return !0}(n,e.clipScope)}function Xp(e,t){return e.x-t.x||e.y-t.y}function Zp(e,t){return 0===Xp(e.min,t.min)&&0===Xp(e.max,t.max)}function Wp(e,t){return !(e.min.x>t.max.x||e.max.x<t.min.x||e.min.y>t.max.y||e.max.y<t.min.y)}function Yp(e,t){if(e.length!==t.length)return !1;for(let r=0;r<e.length;r++)if(e[r].sourceId!==t[r].sourceId||!Zp(e[r],t[r])||e[r].order!==t[r].order||e[r].clipMask!==t[r].clipMask||!Se(e[r].clipScope,t[r].clipScope))return !1;return !0}function Jp(e,t,r){const n=1/qn,i=1/(1<<r.canonical.z),s=(t.x*n+r.canonical.x)*i+r.wrap,a=(t.y*n+r.canonical.y)*i;return {min:new Me((e.x*n+r.canonical.x)*i+r.wrap,(e.y*n+r.canonical.y)*i),max:new Me(s,a)}}function Kp(e,t,r){const n=1<<r.canonical.z,i=((t.x-r.wrap)*n-r.canonical.x)*qn,s=(t.y*n-r.canonical.y)*qn;return {min:new Me(((e.x-r.wrap)*n-r.canonical.x)*qn,(e.y*n-r.canonical.y)*qn),max:new Me(i,s)}}function Qp(e,t,r,n,i,s,a){const o=e.indices,l=e.vertices,u=[];for(let c=n;c<n+i;c+=3){const n=t[r[c+0]+s],i=t[r[c+1]+s],h=t[r[c+2]+s],d=Math.min(n.x,i.x,h.x),p=Math.max(n.x,i.x,h.x),f=Math.min(n.y,i.y,h.y),m=Math.max(n.y,i.y,h.y);u.length=0,e.grid.query(new Me(d,f),new Me(p,m),u);for(let e=0;e<u.length;e++){const t=u[e];if(Jc(l[o[3*t+0]],l[o[3*t+1]],l[o[3*t+2]],n,i,h,a))return !0}}return !1}function ef(e,t,r,n){if(!e||!r)return !1;let i=e.vertices;if(!t.canonical.equals(n.canonical)||t.wrap!==n.wrap){if(r.vertices.length<e.vertices.length)return ef(r,n,e,t);const s=t.canonical,a=n.canonical,o=Math.pow(2,a.z-s.z);i=e.vertices.map(e=>new Me((e.x+s.x*qn)*o-a.x*qn,(e.y+s.y*qn)*o-a.y*qn));}return Qp(r,i,e.indices,0,e.indices.length,0,0)}function tf(e,t,r,n){const i=Math.pow(2,n.z-r.z);return new Me((e+r.x*qn)*i-n.x*qn,(t+r.y*qn)*i-n.y*qn)}function rf(e,t){const r=[];t.grid.queryPoint(e,r);const n=t.indices,i=t.vertices;for(let t=0;t<r.length;t++){const s=r[t];if(Xc([i[n[3*s+0]],i[n[3*s+1]],i[n[3*s+2]]],e))return !0}return !1}const nf={None:0,Model:1,Symbol:2,FillExtrusion:4},sf=[new Me(0,0),new Me(qn,0),new Me(qn,qn),new Me(0,qn)];function af(e,t){const r=[];let n=[];if(!t||e.length<2)return [e];if(2===e.length)return Wc(e[0],e[1],sf)?[e]:[];for(let t=0;t<e.length+2;t++){const i=e[t%e.length],s=e[(t+1)%e.length],a=Wc(0===t?e[e.length-1]:e[(t-1)%e.length],i,sf),o=Wc(i,s,sf),l=a||o;l&&n.push(i),l&&o||n.length>0&&(n.length>1&&r.push(n),n=[]);}return n.length>1&&r.push(n),r}const of=lc.types,lf=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],uf=["fill-extrusion-flood-light-ground-radius"],cf=Math.pow(2,13),hf=Math.pow(2,15)-1,df=new Me(0,1),pf=2147483648,ff=1073741824;function mf(e,t,r,n,i,s,a,o){e.emplaceBack((t<<1)+a,(r<<1)+s,(Math.floor(n*cf)<<1)+i,Math.round(o));}function yf(e,t,r){e.emplaceBack(t.x*qn,t.y*qn,r?1:0);}function gf(e,t,r,n,i,s){e.emplaceBack(t.x,t.y,(r.x<<1)+n,(r.y<<1)+i,s);}function xf(e,t,r){const n=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*n,r[1]*n,r[2]*n);}class vf{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class bf{constructor(){this.centroidXY=new Me(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new Me(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Me(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new Me(0,0);}span(){return new Me(this.max.x-this.min.x,this.max.y-this.min.y)}}class wf{constructor(){this.acc=new Me(0,0),this.accCount=0,this.centroidDataIndex=0;}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y);}appendEdge(e,t,r){this.accCount++,this.acc._add(t);let n=!!this.borders;t.x<e.min.x?(e.min.x=t.x,n=!0):t.x>e.max.x&&(e.max.x=t.x,n=!0),t.y<e.min.y?(e.min.y=t.y,n=!0):t.y>e.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===qn)&&t.x===r.x)!=((0===t.y||t.y===qn)&&t.y===r.y)&&this.processBorderOverlap(t,r),n&&this.checkBorderIntersection(t,r);}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,yr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>qn!=e.x>qn&&this.addBorderIntersection(1,yr(t.y,e.y,(qn-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,yr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>qn!=e.y>qn&&this.addBorderIntersection(3,yr(t.x,e.x,(qn-t.y)/(e.y-t.y)));}addBorderIntersection(e,t){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 r=this.borders[e];t<r[0]&&(r[0]=t),t>r[1]&&(r[1]=t);}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const r=0===e.x?0:1;this.addBorderIntersection(r,t.y),this.addBorderIntersection(r,e.y);}else {const r=0===e.y?2:3;this.addBorderIntersection(r,t.x),this.addBorderIntersection(r,e.x);}}centroid(){return 0===this.accCount?new Me(0,0):new Me(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function _f(e,t){const r=e.add(t)._unit(),n=Ee(e.x*r.x+e.y*r.y,-1,1);var i,s,a;return a=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(a)))/4*hf*((i=e).x*(s=t).y-i.y*s.x<0?-1:1)}const Af=[e=>e.x<0,e=>e.x>qn,e=>e.y<0,e=>e.y>qn];function If(e,t,r,n){const i=[4];if(0===n)return i;r._mult(n);const s=e.sub(r),a=t.sub(r),o=[e,t,s,a];for(let e=0;e<4;e++)for(const t of o)if(Af[e](t)){i.push(e);break}return i}class Mf{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new tl,this.indexArray=new yl,this.programConfigurations=new Au(e.layers,{zoom:e.zoom,lut:e.lut},e=>uf.includes(e)),this._segments=new Xl,this.hiddenByLandmarkVertexArray=new zl,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Xl;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,r,n=!1){const i=e.length;if(i>2){let s=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);let o;s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{const t=e[0],r=e[1];o=_f(t.sub(e[i-1])._perp()._unit(),r.sub(t)._perp()._unit());}for(let l=0;l<i;l++){const u=l===i-1?0:l+1,c=e[l],h=e[u],d=e[u===i-1?0:u+1],p=h.sub(c)._perp()._unit(),f=_f(p,d.sub(h)._perp()._unit()),m=o,y=f;if(zf(c,h,t)||n&&kf(c,t)&&kf(h,t)){o=f;continue}const g=a.vertexLength;gf(this.vertexArray,c,h,1,1,m),gf(this.vertexArray,c,h,1,0,m),gf(this.vertexArray,c,h,0,1,y),gf(this.vertexArray,c,h,0,0,y),a.vertexLength+=4;const x=If(c,h,p,r);for(const e of x)this._segmentToGroundQuads[s].push({id:g,region:e}),this._segmentToRegionTriCounts[s][e]+=2,a.primitiveLength+=2;o=f;}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),t=e.length;for(let e=0;e<t;e++)this._segmentToGroundQuads[e].sort((e,t)=>e.region-t.region);for(let r=0;r<t;r++){const t=this._segmentToGroundQuads[r],n=e[r],i=this._segmentToRegionTriCounts[r];i.reduce((e,t)=>e+t,0);let s=0;for(let e=0;e<=4;e++){const t=i[e];if(0!==t){let r=this.regionSegments[e];r||(r=this.regionSegments[e]=new Xl);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+s,vertexLength:n.vertexLength,primitiveLength:t};r.get().push(i);}s+=t;}for(let e=0;e<t.length;e++){const r=t[e].id;this.indexArray.emplaceBack(r,r+1,r+3),this.indexArray.emplaceBack(r,r+3,r+2);}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null;}addPaintPropertiesData(e,t,r,n,i,s,a){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,t,r,n,i,s,void 0,a);}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Rp.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),null!=this.groundRadiusArray&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,Lp.members)));}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e);}update(e,t,r,n,i,s,a,o){this.hasData()&&this.programConfigurations.updatePaintArrays(e,t,r,n,i,s,a,o);}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&pf||e.flags&ff));}updateHiddenByLandmarkRange(e,t,r){if(!this.hasData())return;const n=t+e;if(0!==t){for(let t=e;t<n;++t)this.hiddenByLandmarkVertexArray.emplace(t,r?1:0);this._needsHiddenByLandmarkUpdate=!0;}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Np.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy();}}}}class Sf{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new yl,this.footprintVertices=new Zo,this.footprintSegments=[],this.layoutVertexArray=new el,this.centroidVertexArray=new Nl,this.wallVertexArray=new Gl,this.indexArray=new yl,this.programConfigurations=new Au(e.layers,{zoom:e.zoom,lut:e.lut},e=>lf.includes(e)),this.segments=new Xl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new Mf(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.features=[],this.hasPattern=Rd("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Ju(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:i,id:s,index:a,sourceLayerIndex:o}of e){const e=this.layers[0]._featureFilter.needGeometry,l=oc(i,e);if(!this.layers[0]._featureFilter.filter(new to(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,r))continue;const u={id:s,sourceLayerIndex:o,index:a,geometry:e?l.geometry:ac(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length,h="Polygon"===of[u.type];if(this.hasPattern)this.features.push({featureId:i.id,feature:Ld("fill-extrusion",this.layers,u,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of u.geometry)for(const s of af(e,h))this.addFeature(i.id,u,[s],a,r,{},t.availableImages,n,t.brightness);else this.addFeature(i.id,u,u.geometry,a,r,{},t.availableImages,n,t.brightness);t.featureIndex.insert(i,u.geometry,a,o,this.index,c);}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(e,t,r,n,i,s){for(const{featureId:e,feature:a}of this.features){const o="Polygon"===of[a.type],{geometry:l}=a;if(this.wallMode)for(const u of l)for(const l of af(u,o))this.addFeature(e,a,[l],a.index,t,r,n,i,s);else this.addFeature(e,a,l,a.index,t,r,n,i,s);}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,this.worldview),this.groundEffect.update(e,t,i,r,n,s,a,this.worldview);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gp),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Up.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,jp.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(e,t,r,n,i,s,a,o,l){const u=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Me(0,0),new Me(qn,qn)],h=o.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===of[t.type],f=new wf;f.centroidDataIndex=this.centroidData.length;const m=new bf;m.buildingId=e,t.properties&&t.properties.hasOwnProperty("building_id")&&(m.buildingId=Number(t.properties.building_id)),f.buildingId=m.buildingId;const y=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},i)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},i);let x;if(m.height=g,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new al),this.wallMode){if(d)return void Ze("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==r.length)return;x=function(e){const t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=function(e){let t=0;const r=e.length;for(let n=0;n<r;n++)t+=(e[(n+1)%r].x-e[n].x)*(e[(n+1)%r].y+e[n].y);return t>=0}(e);r||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},i=[],s=[],a=[];let o=e.length;for(;o>=2&&e[o-1].equals(e[o-2]);)o--;if(o<(t?3:2))return n;let l,u,c,h,d,p=0;for(;p<o-1&&e[p].equals(e[p+1]);)p++;t&&(l=e[o-2],d=e[p].sub(l)._unit()._perp());for(let r=p;r<o;r++){if(c=r===o-1?t?e[p+1]:void 0:e[r+1],c&&e[r].equals(c))continue;d&&(h=d),l&&(u=l),l=e[r],d=c?c.sub(l)._unit()._perp():h,h=h||d;let n=h.add(d);0===n.x&&0===n.y||n._unit();const f=n.x*d.x+n.y*d.y,m=0!==f?1/f:1/0,y=h.x*d.y-h.y*d.x>0;let g="miter";const x=2;"miter"===g&&m>x&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m<x&&(g="miter"));const v=(e,t,r,n)=>{const o=new Me(e.x,e.y),l=new Me(e.x,e.y);o.x+=t.x*n,o.y+=t.y*n,l.x-=t.x*Math.max(r,1),l.y-=t.y*Math.max(r,1),a.push(t),i.push(o),s.push(l);};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else {const e=-Math.sqrt(m*m-1),t=y?e:0,r=y?0:e;u&&v(l,h,t,r),c&&v(l,d,t,r);}}n.geometry=[...i,...s.reverse(),i[0]],n.joinNormals=[...a,...a.reverse(),a[a.length-1]];const f=n.geometry.length-1;for(let e=0;e<f/2;e++)if(e+1<f/2){let t=e,r=e+1,i=f-1-e,s=f-2-e;t=0===t?f-1:t-1,r=0===r?f-1:r-1,i=0===i?f-1:i-1,s=0===s?f-1:s-1,n.indices.push(i),n.indices.push(r),n.indices.push(t),n.indices.push(i),n.indices.push(s),n.indices.push(r);}return n}(r[0]),r=[x.geometry];}const v=(e,t)=>e<(t.length-1)/2||e===t.length-1,b=this.wallMode?[r]:Dd(r,500);for(let e=b.length-1;e>=0;e--){const t=b[e];(0===t.length||Ff(t[0]))&&b.splice(e,1);}let w;if(d)w=Cf(b,c,i);else {w=[];for(const e of b)w.push({polygon:e,bounds:c});}const _=p?this.edgeRadius:0,A=_>0&&this.zoom<17,I=(e,t)=>{if(0===e.length)return !1;const r=e[e.length-1];return t.x===r.x&&t.y===r.y};for(const{polygon:e,bounds:t}of w){let r=0,n=0;for(const t of e)p&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=p?t.length-1:t.length;const s=this.segments.prepareSegment((p?5:4)*n,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const a={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},o=new vf;if(o.vertexOffset=this.footprintVertices.length,o.indexOffset=3*this.footprintIndices.length,o.ringIndices=[],p){const n=[],a=[];r=s.vertexLength;for(let r=0;r<e.length;r++){const l=e[r];l.length&&0!==r&&a.push(n.length/2);const c=[];let p,f;p=l[1].sub(l[0])._perp()._unit(),o.ringIndices.push(l.length-1);for(let e=1;e<l.length;e++){const t=l[e],r=l[e===l.length-1?1:e+1],a=t.clone();if(_){f=r.sub(t)._perp()._unit();const e=p.add(f)._unit(),n=_*Math.min(4,1/(p.x*e.x+p.y*e.y));a.x+=n*e.x,a.y+=n*e.y,a.x=Math.round(a.x),a.y=Math.round(a.y),p=f;}if(!y||0!==_&&!A||I(c,a)||c.push(a),mf(this.layoutVertexArray,a.x,a.y,0,0,1,1,0),this.wallMode){const t=v(e,l);yf(this.wallVertexArray,x.joinNormals[e],!t);}s.vertexLength++,this.footprintVertices.emplaceBack(t.x,t.y),n.push(t.x,t.y),d&&xf(this.layoutVertexExtArray,h.projectTilePoint(a.x,a.y,i),h.upVector(i,a.x,a.y));}y&&(0===_||A)&&(0!==c.length&&I(c,c[0])&&c.pop(),this.groundEffect.addData(c,t,u));}const l=this.wallMode?x.indices:ld(n,a);for(let e=0;e<l.length;e+=3)this.footprintIndices.emplaceBack(o.vertexOffset+l[e+0],o.vertexOffset+l[e+1],o.vertexOffset+l[e+2]),this.indexArray.emplaceBack(r+l[e],r+l[e+2],r+l[e+1]),s.primitiveLength++;o.indexCount+=l.length,o.vertexCount+=this.footprintVertices.length-o.vertexOffset;}for(let n=0;n<e.length;n++){const a=e[n];f.startRing(m,a[0]);let o=a.length>4&&Vf(a[a.length-2],a[0],a[1]),l=_?Pf(a[a.length-2],a[0],a[1],_):0;const c=[];let g,b,w;b=a[1].sub(a[0])._perp()._unit();let A=!0;for(let e=1,n=0;e<a.length;e++){let u=a[e-1],p=a[e];const M=a[e===a.length-1?1:e+1];if(f.appendEdge(m,p,u),zf(p,u,t)){_&&(b=M.sub(p)._perp()._unit(),A=!A);continue}const S=p.sub(u)._perp(),B=S.x/(Math.abs(S.x)+Math.abs(S.y)),P=S.y>0?1:0,T=u.dist(p);if(n+T>32768&&(n=0),_){w=M.sub(p)._perp()._unit();let e=Tf(u,p,M,Bf(b,w),_);isNaN(e)&&(e=0);const t=p.sub(u)._unit();u=u.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,b=w,y&&this.zoom>=17&&(I(c,u)||c.push(u),I(c,p)||c.push(p));}const z=s.vertexLength,k=a.length>4&&Vf(u,p,M);let F=Df(n,o,A);if(mf(this.layoutVertexArray,u.x,u.y,B,P,0,0,F),mf(this.layoutVertexArray,u.x,u.y,B,P,0,1,F),this.wallMode){const t=v(e-1,a),r=x.joinNormals[e-1];yf(this.wallVertexArray,r,t),yf(this.wallVertexArray,r,t);}if(n+=T,F=Df(n,k,!A),o=k,mf(this.layoutVertexArray,p.x,p.y,B,P,0,0,F),mf(this.layoutVertexArray,p.x,p.y,B,P,0,1,F),this.wallMode){const t=v(e,a),r=x.joinNormals[e];yf(this.wallVertexArray,r,t),yf(this.wallVertexArray,r,t);}if(s.vertexLength+=4,this.indexArray.emplaceBack(z+0,z+1,z+2),this.indexArray.emplaceBack(z+1,z+3,z+2),s.primitiveLength+=2,_){const n=r+(1===e?a.length-2:e-2),i=1===e?r:n+1;if(this.indexArray.emplaceBack(z+1,n,z+3),this.indexArray.emplaceBack(n,i,z+3),s.primitiveLength+=2,void 0===g&&(g=z),!zf(M,a[e],t)){const t=e===a.length-1?g:s.vertexLength;this.indexArray.emplaceBack(z+2,z+3,t),this.indexArray.emplaceBack(z+3,t+1,t),this.indexArray.emplaceBack(z+3,i,t+1),s.primitiveLength+=3;}A=!A;}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(u.x,u.y,i),r=h.projectTilePoint(p.x,p.y,i),n=h.upVector(i,u.x,u.y),s=h.upVector(i,p.x,p.y);xf(e,t,n),xf(e,t,n),xf(e,r,s),xf(e,r,s);}}p&&(r+=a.length-1),y&&_&&this.zoom>=17&&(0!==c.length&&I(c,c[0])&&c.pop(),this.groundEffect.addData(c,t,u,_>0));}this.footprintSegments.push(o),a.triangleCount=this.indexArray.length-a.triangleArrayOffset,this.polygonSegments.push(a),++m.footprintSegLen,++m.polygonSegLen;}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?df:this.encodeCentroid(f,m),t.properties&&t.properties.hasOwnProperty("building_id")){const e=m.buildingId;let t=this.buildingGroups.get(e);t||(t={accX:0,accY:0,accCount:0,mergedMin:new Me(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new Me(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(e,t)),t.accX+=f.acc.x,t.accY+=f.acc.y,t.accCount+=f.accCount,t.mergedMin.x=Math.min(t.mergedMin.x,m.min.x),t.mergedMin.y=Math.min(t.mergedMin.y,m.min.y),t.mergedMax.x=Math.max(t.mergedMax.x,m.max.x),t.mergedMax.y=Math.max(t.mergedMax.y,m.max.y),t.partIndices.push(this.centroidData.length);}if(this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;t<f.borders.length;t++)f.borders[t][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[t].push(e);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,n,s,a,i,l,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(t,n,s,a,i,l,this.worldview),this.maxHeight=Math.max(this.maxHeight,g);}}_finalizeBuildingGroups(){for(const[,e]of this.buildingGroups){if(0===e.partIndices.length)continue;const t=new wf;t.acc=new Me(e.accX,e.accY),t.accCount=e.accCount;const r=new bf;r.min=e.mergedMin,r.max=e.mergedMax;const n=this.encodeCentroid(t,r),i=t.centroid();for(const t of e.partIndices){const r=this.centroidData[t];r.centroidXY.x===df.x&&r.centroidXY.y===df.y||(r.centroidXY=n),r.min=e.mergedMin,r.max=e.mergedMax,r.groupCentroidPos=i;}}this.buildingGroups.clear();}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((t,r)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[r].borders[e][0]);}splitToSubtiles(){const e=[];for(let t=0;t<this.centroidData.length;t++){const r=this.centroidData[t],n=+(r.min.y+r.max.y>qn),i=2*n+(+(r.min.x+r.max.x>qn)^n);for(let n=0;n<r.polygonSegLen;n++){const s=r.polygonSegIdx+n;e.push({centroidIdx:t,subtile:i,polygonSegmentIdx:s,triangleSegmentIdx:this.polygonSegments[s].triangleSegIdx});}}const t=new yl;e.sort((e,t)=>e.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let r=0,n=0,i=0;for(const t of e){if(t.triangleSegmentIdx!==r)break;i++;}const s=e.length;for(;n!==e.length;){r=e[n].triangleSegmentIdx;let a=0,o=n,l=n;for(let t=o;t<i&&e[t].subtile===a;t++)l++;for(;o!==i;){const n=e[o];a=n.subtile;const s=this.centroidData[n.centroidIdx].min.clone(),u=this.centroidData[n.centroidIdx].max.clone(),c={vertexOffset:this.segments.segments[r].vertexOffset,primitiveOffset:t.length,vertexLength:this.segments.segments[r].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let r=o;r<l;r++){const n=e[r],i=this.polygonSegments[n.polygonSegmentIdx],a=this.centroidData[n.centroidIdx].min,o=this.centroidData[n.centroidIdx].max,l=this.indexArray.uint16;for(let e=i.triangleArrayOffset;e<i.triangleArrayOffset+i.triangleCount;e++)t.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);c.primitiveLength+=i.triangleCount,s.x=Math.min(s.x,a.x),s.y=Math.min(s.y,a.y),u.x=Math.max(u.x,o.x),u.y=Math.max(u.y,o.y);}c.primitiveLength>0&&this.triangleSubSegments.push({segment:c,min:s,max:u}),o=l;for(let t=o;t<i&&e[t].subtile===e[o].subtile;t++)l++;}n=i;for(let t=n;t<s&&e[t].triangleSegmentIdx===e[n].triangleSegmentIdx;t++)i++;}t._trim(),this.indexArray=t;}getVisibleSegments(e,t,r){const n=new Xl;if(this.wallMode){for(const e of this.triangleSubSegments)n.segments.push(e.segment);return n}let i=0,s=0;const a=1<<e.canonical.z;if(t){const r=t.getMinMaxForTile(e);r&&(i=r.min,s=r.max);}s+=this.maxHeight;const o=e.toUnwrapped();let l;const u=[o.canonical.x/a+o.wrap,o.canonical.y/a],c=[(o.canonical.x+1)/a+o.wrap,(o.canonical.y+1)/a],h=(e,t,r)=>[e[0]*(1-r[0])+t[0]*r[0],e[1]*(1-r[1])+t[1]*r[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/qn,d[1]=e.min.y/qn,p[0]=e.max.x/qn,p[1]=e.max.y/qn;const t=h(u,c,d),a=h(u,c,p);if(0===new zc([t[0],t[1],i],[a[0],a[1],s]).intersectsPrecise(r)){l&&(n.segments.push(l),l=void 0);continue}const o=e.segment;l&&l.vertexOffset!==o.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=o.vertexLength,l.primitiveLength+=o.primitiveLength):l={vertexOffset:o.vertexOffset,primitiveLength:o.primitiveLength,vertexLength:o.vertexLength,primitiveOffset:o.primitiveOffset,sortKey:void 0,vaos:{}};}return l&&n.segments.push(l),n}encodeCentroid(e,t){const r=e.centroid(),n=t.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),s=Math.min(6,Math.round(n.y*this.tileToMeter/10));return new Me(Ee(r.x,1,8191)<<3|i,Ee(r.y,1,8191)<<3|s)}encodeBorderCentroid(e){if(!e.borders)return new Me(0,0);const t=e.borders,r=Number.MAX_VALUE;if(t[0][0]!==r||t[1][0]!==r){const e=t[0][0]!==r?0:1;return new Me(6|(t[0][0]!==r?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==r?2:3;return new Me((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==r?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];if(t.flags&=pf,0!==t.groupCentroidPos.x||0!==t.groupCentroidPos.y){const e=t.span(),r=Math.min(7,Math.round(e.x*this.tileToMeter/10)),n=Math.min(6,Math.round(e.y*this.tileToMeter/10));t.centroidXY=new Me(Ee(t.groupCentroidPos.x,1,8191)<<3|r,Ee(t.groupCentroidPos.y,1,8191)<<3|n);}else t.centroidXY=new Me(0,0);this.writeCentroidToBuffer(t);}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,r=e.vertexCount+e.vertexArrayOffset,n=-1073741824&e.flags?df:e.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==n.y||i!==n.x){for(let e=t;e<r;++e)this.centroidVertexArray.emplace(e,n.x,n.y);this.needsCentroidUpdate=!0;}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e);}updateReplacement(e,t,r){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped());if(Yp(this.activeReplacements,n))return;if(this.activeReplacements=n,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const e of this.centroidData)e.flags&=1073741823;const i=[];for(const t of this.activeReplacements){if(t.order<r)continue;const n=Math.max(1,Math.pow(2,t.footprintTileId.canonical.z-e.canonical.z));if(t.footprint.buildingIds)for(const e of this.centroidData)e.flags&pf||e.flags&ff||t.min.x>e.max.x||e.min.x>t.max.x||t.min.y>e.max.y||e.min.y>t.max.y||t.footprint.buildingIds.has(e.buildingId)&&(e.flags|=t.clipMask!==nf.None?-1073741824:pf);else for(const r of this.centroidData)if(!(r.flags&pf||r.flags&ff||t.min.x>r.max.x||r.min.x>t.max.x||t.min.y>r.max.y||r.min.y>t.max.y))for(let s=0;s<r.footprintSegLen;s++){const a=this.footprintSegments[r.footprintSegIdx+s];if(i.length=0,Rf(this.footprintVertices,a.vertexOffset,a.vertexCount,t.footprintTileId.canonical,e.canonical,i),Qp(t.footprint,i,this.footprintIndices.uint16,a.indexOffset,a.indexCount,-a.vertexOffset,-n)){r.flags|=t.clipMask!==nf.None?-1073741824:pf;break}}}for(const e of this.centroidData)this.writeCentroidToBuffer(e);this.borderDoneWithNeighborZ=[-1,-1,-1,-1];}footprintContainsPoint(e,t,r){let n=!1;for(let i=0;i<r.footprintSegLen;i++){const s=this.footprintSegments[r.footprintSegIdx+i];let a=0;for(const r of s.ringIndices){for(let i=a,o=r+a-1;i<r+a;o=i++){const r=this.footprintVertices.int16[2*(i+s.vertexOffset)+0],a=this.footprintVertices.int16[2*(i+s.vertexOffset)+1],l=this.footprintVertices.int16[2*(o+s.vertexOffset)+1];a>t!=l>t&&e<(this.footprintVertices.int16[2*(o+s.vertexOffset)+0]-r)*(t-a)/(l-a)+r&&(n=!n);}a=r;}}return n}getHeightAtTileCoord(e,t){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(e+qn)*qn+(t+qn);if(this.partLookup.hasOwnProperty(i)){const e=this.partLookup[i];return e?{height:e.height,hidden:!!(e.flags&pf)}:void 0}for(const s of this.centroidData)e>s.max.x||s.min.x>e||t>s.max.y||s.min.y>t||s.height<=r||this.footprintContainsPoint(e,t,s)&&(r=s.height,this.partLookup[i]=s,n=!!(s.flags&pf));if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.partLookup[i]=void 0;}}function Bf(e,t){const r=e.add(t)._unit();return e.x*r.x+e.y*r.y}function Pf(e,t,r,n){const i=t.sub(e)._perp()._unit(),s=r.sub(t)._perp()._unit();return Tf(e,t,r,Bf(i,s),n)}function Tf(e,t,r,n,i){const s=Math.sqrt(1-n*n);return Math.min(e.dist(t)/3,t.dist(r)/3,i*s/n)}function zf(e,t,r){return e.x<r[0].x&&t.x<r[0].x||e.x>r[1].x&&t.x>r[1].x||e.y<r[0].y&&t.y<r[0].y||e.y>r[1].y&&t.y>r[1].y}function kf(e,t){return e.x<t[0].x||e.x>t[1].x||e.y<t[0].y||e.y>t[1].y}function Ff(e){return e.every(e=>e.x<=0)||e.every(e=>e.x>=qn)||e.every(e=>e.y<=0)||e.every(e=>e.y>=qn)}function Vf(e,t,r){if(e.x<0||e.x>=qn||t.x<0||t.x>=qn||r.x<0||r.x>=qn)return !1;const n=r.sub(t),i=n.perp(),s=e.sub(t);return (n.x*s.x+n.y*s.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(s.x*s.x+s.y*s.y))>-.866&&i.x*s.x+i.y*s.y<0}function Df(e,t,r){const n=t?2|e:-3&e;return r?1|n:-2&n}function Ef(){const e=Math.PI/32,t=Math.tan(e),r=Cu;return r*Math.sqrt(1+2*t*t)-r}function Cf(e,t,r){const n=1<<r.z,i=$u(r.x/n),s=$u((r.x+1)/n),a=qu(r.y/n),o=qu((r.y+1)/n);return function(e,t,r,n,i=0,s){const a=[];if(!e.length||!r||!n)return a;const o=(e,t)=>{for(const r of e)a.push({polygon:r,bounds:t});},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let e=0;e<Math.abs(c);e++)h.push(c>0?0:1);for(let e=0;e<Math.min(l,u);e++)h.push(0),h.push(1);let d=e;if(d=_p(d,t[0].y-i,t[1].y+i,1),d=_p(d,t[0].x-i,t[1].x+i,0),!d.length)return a;const p=[];for(h.length?p.push({polygons:d,bounds:t,depth:0}):o(d,t);p.length;){const e=p.pop(),t=e.depth,r=h[t],n=e.bounds[0],a=e.bounds[1],l=0===r?n.x:n.y,u=0===r?a.x:a.y,c=s?s(r,l,u):.5*(l+u),d=_p(e.polygons,l-i,c+i,r),f=_p(e.polygons,c-i,u+i,r);if(d.length){const e=[n,new Me(0===r?c:a.x,1===r?c:a.y)];h.length>t+1?p.push({polygons:d,bounds:e,depth:t+1}):o(d,e);}if(f.length){const e=[new Me(0===r?c:n.x,1===r?c:n.y),a];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):o(f,e);}}return a}(e,t,Math.ceil((s-i)/11.25),Math.ceil((a-o)/11.25),1,(e,t,i)=>{if(0===e)return .5*(t+i);{const e=qu((r.y+t/qn)/n);return (ju(.5*(qu((r.y+i/qn)/n)+e))*n-r.y)*qn}})}function Rf(e,t,r,n,i,s){const a=Math.pow(2,n.z-i.z);for(let o=0;o<r;o++){let r=e.int16[2*(o+t)+0],l=e.int16[2*(o+t)+1];r=(r+i.x*qn)*a-n.x*qn,l=(l+i.y*qn)*a-n.y*qn,s.push(new Me(r,l));}}let Lf,Of;ra(Sf,"FillExtrusionBucket",{omit:["layers","features"]}),ra(bf,"PartData"),ra(vf,"FootprintSegment"),ra(wf,"BorderCentroidData"),ra(Mf,"GroundEffect");class Uf extends Me{constructor(e,t,r){super(e,t),this.z=r;}}class Nf extends Uf{constructor(e,t,r,n){super(e,t,r),this.w=n;}}function jf(e,t,r,n){const i="x"===r?"y":"x",s=(n-e[r])/(t[r]-e[r]);e[i]=Math.round(e[i]+(t[i]-e[i])*s),e[r]=n,e.hasOwnProperty("z")&&(e.z=yr(e.z,t.z,s)),e.hasOwnProperty("w")&&(e.w=yr(e.w,t.w,s));}function Gf(e,t,r,n){const i=r,s=n;for(const r of ["x","y"]){let n=e,a=t;n[r]>=a[r]&&(n=t,a=e),n[r]<i&&a[r]>i&&jf(n,a,r,i),n[r]<s&&a[r]>s&&jf(a,n,r,s);}}function $f(e,t,r,n,i,s){const a=[];for(let o=0;o<e.length;o++){const l=e[o];let u;const c=a.length;let h=0;for(let e=0;e<l.length-1;e++){let c=l[e],d=l[e+1],p=0;const f=h;let m,y;s&&(p=Math.hypot(d.x-c.x,d.y-c.y),h+=p,m=c,y=d),c.x<t&&d.x<t||(c.x<t?c=new Me(t,c.y+(t-c.x)/(d.x-c.x)*(d.y-c.y))._round():d.x<t&&(d=new Me(t,c.y+(t-c.x)/(d.x-c.x)*(d.y-c.y))._round()),c.y<r&&d.y<r||(c.y<r?c=new Me(c.x+(r-c.y)/(d.y-c.y)*(d.x-c.x),r)._round():d.y<r&&(d=new Me(c.x+(r-c.y)/(d.y-c.y)*(d.x-c.x),r)._round()),c.x>=n&&d.x>=n||(c.x>=n?c=new Me(n,c.y+(n-c.x)/(d.x-c.x)*(d.y-c.y))._round():d.x>=n&&(d=new Me(n,c.y+(n-c.x)/(d.x-c.x)*(d.y-c.y))._round()),c.y>=i&&d.y>=i||(c.y>=i?c=new Me(c.x+(i-c.y)/(d.y-c.y)*(d.x-c.x),i)._round():d.y>=i&&(d=new Me(c.x+(i-c.y)/(d.y-c.y)*(d.x-c.x),i)._round()),u&&c.equals(u[u.length-1])||(u=[c],a.push(u),s&&s.push({progress:{min:f+Hf(m,y,c)*p,max:1},parentIndex:o,prevPoint:m,nextPoint:y})),u.push(d),s&&(s[s.length-1].progress.max=f+Hf(m,y,d)*p,s[s.length-1].nextPoint=y)))));}if(s&&h>0)for(let e=c;e<a.length;e++)s[e].progress.min/=h,s[e].progress.max/=h;}return a}function qf(e,t,r,n,i){if(e.length<2)return void n.push(e);const s=[];for(;t.valid();){const[r,n]=t.get();for(let t=0;t<e.length-1;t++){const i=e[t],a=e[t+1],o=Gc(i,a,r,n);if(o){const[e]=o,r=new Me(yr(i.x,a.x,e),yr(i.y,a.y,e));s.push({t:t+e,distance:0,point:r});}}t.next();}if(0===s.length)return void n.push(e);s.sort((e,t)=>e.t-t.t);let a=0,o=0,l=[];for(n.push(l);a!==e.length;){if(o===s.length){for(;a!==e.length;)0!==l.length&&l[l.length-1].equals(e[a])||l.push(e[a]),a++;break}s[o].t<=a?(0!==l.length&&l[l.length-1].equals(s[o].point)||l.push(s[o].point),Math.trunc(s[o].t),o++):(0!==l.length&&l[l.length-1].equals(e[a])||l.push(e[a]),a++);}}function Hf(e,t,r){return e.x!==t.x?(r.x-e.x)/(t.x-e.x):e.y!==t.y?(r.y-e.y)/(t.y-e.y):0}function Xf(e,t){return e.x*t.x+e.y*t.y}function Zf(e,t){if(1===e.length){let r=0;const n=t[r++];let i;for(;!i||n.equals(i);)if(i=t[r++],!i)return 1/0;for(;r<t.length;r++){const s=t[r],a=e[0],o=i.sub(n),l=s.sub(n),u=a.sub(n),c=Xf(o,o),h=Xf(o,l),d=Xf(l,l),p=Xf(u,o),f=Xf(u,l),m=c*d-h*h,y=(d*p-h*f)/m,g=(c*f-h*p)/m,x=n.z*(1-y-g)+i.z*y+s.z*g;if(isFinite(x))return x}return 1/0}{let e=1/0;for(const r of t)e=Math.min(e,r.z);return e}}function Wf(e,t,r){let n=1/0;Lc(r,t)&&(n=Zf(r,t[0]));for(let i=0;i<t.length;i++){const s=t[i],a=e[i];for(let e=0;e<s.length-1;e++){const t=s[e],i=[t,s[e+1],a[e+1],a[e],t];Cc(r,i)&&(n=Math.min(n,Zf(r,i)));}}return n!==1/0&&n}function Yf(e,t,r,n,i,s,a,o,l,u,c){return "globe"===e.projection.name?function(e,t,r,n,i,s,a,o,l,u,c){const h=[],d=[],p=e.projection.upVectorScale(c,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],y=(e,t,r,n)=>{e[0]=t,e[1]=r,e[2]=n,e[3]=1;},g=Ef();r>0&&(r+=g),n+=g;for(const g of t){const t=[],x=[];for(const h of g){const d=h.x+i.x,g=h.y+i.y,v=e.projection.projectTilePoint(d,g,c),b=e.projection.upVector(c,h.x,h.y);let w=r,_=n;if(a){const e=Jf(d,g,r,n,a,o,l,u);w+=e.base,_+=e.top;}0!==r?y(f,v.x+b[0]*p*w,v.y+b[1]*p*w,v.z+b[2]*p*w):y(f,v.x,v.y,v.z),y(m,v.x+b[0]*p*_,v.y+b[1]*p*_,v.z+b[2]*p*_),j(f,f,s),j(m,m,s),t.push(new Uf(f[0],f[1],f[2])),x.push(new Uf(m[0],m[1],m[2]));}h.push(t),d.push(x);}return [h,d]}(e,t,r,n,i,s,a,o,l,u,c):a?function(e,t,r,n,i,s,a,o,l){const u=[],c=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const u of d){const c=u.x+n.x,d=u.y+n.y,f=Jf(c,d,t,r,s,a,o,l);h[0]=c,h[1]=d,h[2]=f.base,h[3]=1,ee(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new Uf(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=d,h[2]=f.top,h[3]=1,ee(h,h,i),h[3]=Math.max(h[3],1e-5);const y=new Uf(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(y);}u.push(e),c.push(p);}return [u,c]}(t,r,n,i,s,a,o,l,u):function(e,t,r,n,i){const s=[],a=[],o=i[8]*t,l=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*r,d=i[9]*r,p=i[10]*r,f=i[11]*r;for(const t of e){const e=[],r=[];for(const s of t){const t=s.x+n.x,a=s.y+n.y,m=i[0]*t+i[4]*a+i[12],y=i[1]*t+i[5]*a+i[13],g=i[2]*t+i[6]*a+i[14],x=i[3]*t+i[7]*a+i[15],v=m+o,b=y+l,w=g+u,_=Math.max(x+c,1e-5),A=m+h,I=y+d,M=g+p,S=Math.max(x+f,1e-5);e.push(new Uf(v/_,b/_,w/_)),r.push(new Uf(A/S,I/S,M/S));}s.push(e),a.push(r);}return [s,a]}(t,r,n,i,s)}function Jf(e,t,r,n,i,s,a,o){const l=a*i.getElevationAt(e,t,!0,!0),u=0!==s[0],c=u?0===s[1]?a*(s[0]/7-450):a*function(e,t,r){const n=Math.floor(t[0]/8),i=Math.floor(t[1]/8),s=10*(t[0]-8*n),a=10*(t[1]-8*i),o=e.getElevationAt(n,i,!0,!0),l=e.getMeterToDEM(r),u=Math.floor(.5*(s*l-1)),c=Math.floor(.5*(a*l-1)),h=e.tileCoordToPixel(n,i),d=2*u+1,p=2*c+1,f=function(e,t,r,n,i){return [e.getElevationAtPixel(t,r,!0),e.getElevationAtPixel(t+i,r,!0),e.getElevationAtPixel(t,r+i,!0),e.getElevationAtPixel(t+n,r+i,!0)]}(e,h.x-u,h.y-c,d,p),m=Math.abs(f[0]-f[1]),y=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),x=Math.min(.25,.5*l*(m+y)/d),v=Math.min(.25,.5*l*g/p);return o+Math.max(x*s,v*a)}(i,s,o):l;return {base:l+(0===r?-1:r),top:u?Math.max(c+n,l+r+2):l+n}}const Kf=4096;class Qf{constructor(e){this.module=e,this.memoryStack=this.module.malloc(Kf),this.memoryStackNextFree=this.memoryStack;}createIntArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Kf?-1:(new Int32Array(this.module.heap32.buffer,t,e.length).set(e),t)}createFloatArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Kf?-1:(new Float32Array(this.module.heapF32.buffer,t,e.length).set(e),t)}readStringBuffer(e){let t="";for(;0!==this.module.heapU8[e];)t+=String.fromCharCode(this.module.heapU8[e]),++e;return t}setStyle(e){const t=e.normalScale;this.module.setStyle(t[0],t[1],t[2],e.tileToMeters);}setAOOptions(e,t){this.module.setAOOptions(e?1:0,t);}setMetricOptions(e,t){this.module.setMetricOptions(e?1:0,t);}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0);}setFacadeOptions(e,t){this.module.setFacadeOptions(e,t?1:0);}setFauxFacadeOptions(e,t,r){this.module.setFauxFacadeOptions(e?1:0,t?1:0,r);}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e);}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const t of e){const e=this.createIntArray(t.ringIndices),r=this.createFloatArray(t.coordinates);if(-1===e||-1===r)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(t.id,t.sourceId,t.minHeight,t.height,t.roofType,r,e,t.ringIndices.length-1);}for(const e of t){let t;t=e.entrances?JSON.parse(e.entrances):[];const r=this.createFloatArray(t),n=this.createFloatArray(e.coordinates);if(-1===r||-1===n)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(e.sourceId,e.crossPerc,e.distanceToRoad,r,t.length,n,e.coordinates.length);}if(!this.module.generateMesh()){const e=this.module.getLastError();return this.readStringBuffer(e)}const r=this.module.getMeshCount(),n=new Array(r);for(let e=0;e<r;e++){const t=this.module.getPositionsPtr(e),r=this.module.getPositionsLength(e),i=new Float32Array(this.module.heapF32.buffer,t,r),s=this.module.getNormalsPtr(e),a=this.module.getNormalsLength(e),o=new Float32Array(this.module.heapF32.buffer,s,a),l=this.module.getAOPtr(e),u=this.module.getAOLength(e),c=new Float32Array(this.module.heapF32.buffer,l,u),h=this.module.getUVPtr(e),d=this.module.getUVLength(e),p=new Float32Array(this.module.heapF32.buffer,h,d),f=this.module.getFauxFacadePtr(e),m=this.module.getFauxFacadeLength(e),y=new Uint8Array(this.module.heapU8.buffer,f,m),g=this.module.getIndicesPtr(e),x=this.module.getIndicesLength(e),v=new Int16Array(this.module.heap16.buffer,g,x),b=this.module.getBuildingPart(e);n[e]={positions:i,normals:o,ao:c,uv:p,isFauxFacade:y,indices:v,buildingPart:b};}const i=this.module.getRingCount(),s=[];for(let e=0;e<i;e++){const t=this.module.getRingPtr(e),r=this.module.getRingLength(e),n=new Float32Array(this.module.heapF32.buffer,t,r);s.push(n);}return {meshes:n,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:s}}}let em,tm=null,rm=null,nm=null,im=null,sm=null;function am(){return nm}const om=5120,lm=5121,um=5122,cm=5123,hm=5125,dm=5126,pm={[om]:Int8Array,[lm]:Uint8Array,[um]:Int16Array,[cm]:Uint16Array,[hm]:Uint32Array,[dm]:Float32Array},fm={[om]:"DT_INT8",[lm]:"DT_UINT8",[um]:"DT_INT16",[cm]:"DT_UINT16",[hm]:"DT_UINT32",[dm]:"DT_FLOAT32"},mm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function ym(e,t,r){const n=r.json.bufferViews.length,i=r.buffers.length;t.bufferView=n,r.json.bufferViews[n]={buffer:i,byteLength:e.byteLength},r.buffers[i]=e;}const gm="KHR_draco_mesh_compression";function xm(e,t){const r=e.extensions&&e.extensions[gm];if(!r)return;const n=new tm.Decoder,i=Mm(t,r.bufferView),s=new tm.Mesh;if(!n.DecodeArrayToMesh(i,i.byteLength,s))throw new Error("Failed to decode Draco mesh");const a=t.json.accessors[e.indices],o=pm[a.componentType],l=a.count*o.BYTES_PER_ELEMENT,u=tm._malloc(l);o===Uint16Array?n.GetTrianglesUInt16Array(s,l,u):n.GetTrianglesUInt32Array(s,l,u),ym(tm.memory.buffer.slice(u,u+l),a,t),tm._free(u);for(const i of Object.keys(r.attributes)){const a=n.GetAttributeByUniqueId(s,r.attributes[i]),o=t.json.accessors[e.attributes[i]],l=fm[o.componentType],u=o.count*mm[o.type]*pm[o.componentType].BYTES_PER_ELEMENT,c=tm._malloc(u);n.GetAttributeDataArrayForAllPoints(s,a,tm[l],u,c),ym(tm.memory.buffer.slice(c,c+u),o,t),tm._free(c);}n.destroy(),s.destroy(),delete e.extensions[gm];}const vm="EXT_meshopt_compression";function bm(e,t){if(!e.extensions||!e.extensions[vm])return;const r=e.extensions[vm],n=new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),i=new Uint8Array(r.count*r.byteStride);rm.decodeGltfBuffer(i,r.count,r.byteStride,n,r.mode,r.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=i.buffer,delete e.extensions[vm];}const wm=1179937895,_m=new TextDecoder("utf8");function Am(e,t){return new URL(e,t).href}async function Im(e,t,r,n,i){const s=await fetch(Am(e.uri,n),{signal:i}),a=await s.arrayBuffer();t.buffers[r]=a;}function Mm(e,t){const r=e.json.bufferViews[t];return new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength)}async function Sm(e,t,r,n,i){if(e.uri){const s=Am(e.uri,n),a=await fetch(s,{signal:i}),o=await a.blob(),l=await createImageBitmap(o);t.images[r]=l;}else if(void 0!==e.bufferView){const n=Mm(t,e.bufferView),i=new Blob([n],{type:e.mimeType}),s=await createImageBitmap(i);t.images[r]=s;}}async function Bm(e,t=0,r,n){const i={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===wm){const r=new Uint32Array(e,t);let n=2;const s=(r[n++]>>2)-3,a=r[n++]>>2;if(n++,i.json=JSON.parse(_m.decode(r.subarray(n,n+a))),n+=a,n<s){const s=r[n++];n++;const a=t+(n<<2);i.buffers[0]=e.slice(a,a+s);}}else i.json=JSON.parse(_m.decode(new Uint8Array(e,t)));const{buffers:s,images:a,meshes:o,extensionsUsed:l,bufferViews:u}=i.json;if(s){const e=[];for(let t=0;t<s.length;t++){const a=s[t];a.uri?e.push(Im(a,i,t,r,n)):i.buffers[t]||(i.buffers[t]=null);}await Promise.all(e);}if(n&&n.aborted)throw new DOMException("Aborted","AbortError");const c=[],h=l&&l.includes(gm),d=l&&l.includes(vm);if(h&&c.push(function(){if(!tm)return null!=em?em:(em=function(e){let t,r=null;function n(){t=new Uint8Array(r.buffer);}function i(){throw new Error("Unexpected Draco error.")}const s={a:{a:i,d:function(e,r,n){return t.copyWithin(e,r,r+n)},c:function(e){const i=t.length,s=Math.max(e>>>0,Math.ceil(1.2*i)),a=Math.ceil((s-i)/65536);try{return r.grow(a),n(),!0}catch(e){return !1}},b:i}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,s):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,s))).then(e=>{const{Rb:i,Qb:s,P:a,T:o,X:l,Ja:u,La:c,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:y,e:g,yb:x,zb:v,Ab:b,Bb:w,Db:_,Gb:A}=e.instance.exports;r=g;const I=(()=>{let e=0,r=0,n=0,a=0;return o=>{n&&(i(a),i(e),r+=n,n=e=0),e||(r+=128,e=s(r));const l=o.length+7&-8;let u=e;l>=r&&(n=l,u=a=s(l));for(let e=0;e<o.length;e++)t[u+e]=o[e];return u}})();return n(),y(),{memory:g,_free:i,_malloc:s,Mesh:class{constructor(){this.ptr=a();}destroy(){o(this.ptr);}},Decoder:class{constructor(){this.ptr=u();}destroy(){m(this.ptr);}DecodeArrayToMesh(e,t,r){const n=I(e),i=c(this.ptr,n,t,r.ptr);return !!l(i)}GetAttributeByUniqueId(e,t){return {ptr:h(this.ptr,e.ptr,t)}}GetTrianglesUInt16Array(e,t,r){d(this.ptr,e.ptr,t,r);}GetTrianglesUInt32Array(e,t,r){p(this.ptr,e.ptr,t,r);}GetAttributeDataArrayForAllPoints(e,t,r,n,i){f(this.ptr,e.ptr,t.ptr,r,n,i);}},DT_INT8:x(),DT_UINT8:v(),DT_INT16:b(),DT_UINT16:w(),DT_UINT32:_(),DT_FLOAT32:A()}})}(fetch(ut())),em.then(e=>{tm=e,em=void 0;}))}()),d&&c.push(function(){if(rm)return;const e=function(e){let t;const r=WebAssembly.instantiateStreaming(e,{}).then(e=>{t=e.instance,t.exports.__wasm_call_ctors();}),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return {ready:r,supported:!0,decodeGltfBuffer(e,r,s,a,o,l){!function(e,t,r,n,i,s,a){const o=e.exports.sbrk,l=n+3&-4,u=o(l*i),c=o(s.length),h=new Uint8Array(e.exports.memory.buffer);h.set(s,c);const d=t(u,n,i,c,s.length);if(0===d&&a&&a(u,l,i),r.set(h.subarray(u,u+n*i)),o(u-o(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(t,t.exports[i[o]],e,r,s,a,t.exports[n[l]]);}}}(fetch(ct()));return e.ready.then(()=>{rm=e;})}()),a)for(let e=0;e<a.length;e++)c.push(Sm(a[e],i,e,r,n));if(c.length&&await Promise.all(c),n&&n.aborted)throw new DOMException("Aborted","AbortError");if(h&&o)for(const{primitives:e}of o)for(const t of e)xm(t,i);if(d&&o&&u)for(const e of u)bm(e,i);return i}async function Pm(e,t){const r=await async function(e,t){if(t&&t.aborted)throw new DOMException("Aborted","AbortError");return new Promise((r,n)=>{const i=Gt(e,(e,t)=>{e?n(e):r(t);});t&&t.addEventListener("abort",()=>{i.cancel(),n(new DOMException("Aborted","AbortError"));},{once:!0});})}({url:e,type:"arrayBuffer"},t);return Bm(r,0,e,t)}function Tm(e){switch(e){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function zm(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class km{constructor(e,t,r,n){this.context=e,this.format=r,this.useMipmap=n&&n.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:n&&n.premultiply});}update(e,t){const r=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,n=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:i}=this,{gl:s}=i,{x:a,y:o}=t&&t.position?t.position:{x:0,y:0},l=a+r,u=o+n;this.size&&(this.size[0]!==l||this.size[1]!==u)&&(!t||void 0===t.recreateWhenResize||t.recreateWhenResize)&&(s.bindTexture(s.TEXTURE_2D,null),s.deleteTexture(this.texture),this.texture=s.createTexture(),this.size=null),s.bindTexture(s.TEXTURE_2D,this.texture),i.pixelStoreUnpackFlipY.set(!1),i.pixelStoreUnpack.set(1),i.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA8&&(!t||!1!==t.premultiply));const c=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&u>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,u)))+1:1;s.texStorage2D(s.TEXTURE_2D,e,this.format,l,u),this.size=[l,u];}this.size&&(c?s.texSubImage2D(s.TEXTURE_2D,0,a,o,Tm(this.format),zm(this.format),e):"data"in e&&e.data&&s.texSubImage2D(s.TEXTURE_2D,0,a,o,r,n,Tm(this.format),zm(this.format),e.data)),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D);}bind(e,t,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),e!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrapS=t);}bindExtraParam(e,t,r,n,i){const{context:s}=this,{gl:a}=s;a.bindTexture(a.TEXTURE_2D,this.texture),t!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap?e===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,n),this.wrapT=n),i!==this.compareMode&&(i?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_FUNC,i)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_MODE,a.NONE),this.compareMode=i);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}class Fm{constructor(e,t){this.context=e,this.texture=t;}bind(e,t){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}}const Vm=Ho([{name:"a_pos_3f",components:3,type:"Float32"}]),Dm=Ho([{name:"a_color_3f",components:3,type:"Float32"}]),Em=Ho([{name:"a_color_4f",components:4,type:"Float32"}]),Cm=Ho([{name:"a_uv_2f",components:2,type:"Float32"}]),Rm=Ho([{name:"a_normal_3f",components:3,type:"Float32"}]),Lm=Ho([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Om=Ho([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Um(e,t){const r=jm(e.projection,e.zoom,e.width,e.height),n=function(e,t,r,n,i){const s=new Lu(r.lng-180*Gm,r.lat),a=new Lu(r.lng+180*Gm,r.lat),o=e.project(s.lng,s.lat),l=e.project(a.lng,a.lat),c=-Math.atan2(l.y-o.y,l.x-o.x),d=Ku.fromLngLat(r);d.y=Ee(d.y,-1+Gm,1-Gm);const f=d.toLngLat(),m=e.project(f.lng,f.lat),g=Ku.fromLngLat(f);g.x+=Gm;const x=g.toLngLat(),v=e.project(x.lng,x.lat),b=qm(v.x-m.x,v.y-m.y,c),w=Ku.fromLngLat(f);w.y+=Gm;const _=w.toLngLat(),A=e.project(_.lng,_.lat),I=qm(A.x-m.x,A.y-m.y,c),M=Math.abs(b.x)/Math.abs(I.y),S=u([]);y(S,S,-c*(1-(i?0:n)));const B=u([]);return p(B,B,[1,1-(1-M)*n,1]),B[4]=-I.x/I.y*n,y(B,B,c),h(B,S,B),B}(e.projection,0,e.center,r,t),i=Nm(e);return p(n,n,[i,i,1]),n}function Nm(e){const t=e.projection,r=jm(e.projection,e.zoom,e.width,e.height),n=$m(t,e.center),i=$m(t,Lu.convert(t.center));return Math.pow(2,n*r+(1-r)*i)}function jm(e,t,r,n,i=1/0){const s=e.range;if(!s)return 0;const a=Math.min(i,Math.max(r,n)),o=Math.log2(a/1024);return Ce(s[0]+o,s[1]+o,t)}const Gm=1/4e4;function $m(e,t){const r=Ee(t.lat,-85.051129,Xu),n=new Lu(t.lng-180*Gm,r),i=new Lu(t.lng+180*Gm,r),s=e.project(n.lng,r),a=e.project(i.lng,r),o=Ku.fromLngLat(n),l=Ku.fromLngLat(i),u=a.x-s.x,c=a.y-s.y,h=l.x-o.x,d=l.y-o.y,p=Math.sqrt((h*h+d*d)/(u*u+c*c));return Math.log2(p)}function qm(e,t,r){const n=Math.cos(r),i=Math.sin(r);return {x:e*n-t*i,y:e*i+t*n}}function Hm(e,t,r){u(e),y(e,e,Te(t[2])),f(e,e,Te(t[0])),m(e,e,Te(t[1])),p(e,e,r),h(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);}function Xm(e,t,r,n,i,s,a,o){const l=[r[0]-t[0],r[1]-t[1],0],u=[n[0]-t[0],n[1]-t[1],0];if(I(l)<1e-12||I(u)<1e-12)return re(e);const c=U([],l,u);L(c,c),P(u,n,t),l[2]=(s-i)*o,u[2]=(a-i)*o;const h=l;return U(h,l,u),L(h,h),ue(e,c,h)}function Zm(e,t,r=!1){const n=Vh(t.zoom),i=function(e,t,r){const n=t.worldSize,i=[e[12],e[13],e[14]],s=qu(i[1]/n),a=$u(i[0]/n),o=u([]),l=Gu(1,s)*n,c=Gu(1,0)*n*Wu(s,t.zoom),f=1/zh(n);let m=c*f;if(r){const e=jm(t.projection,t.zoom,t.width,t.height,1024);m=f*t.projection.pixelSpaceConversion(t.center.lat,n,e);}const y=Eu(s,a);B(y,y,F([],L([],y),l*m*i[2]));const g=function(e){const t=[e[0],e[1],e[2]];let r=[0,1,0];const n=U([],r,t);return U(r,t,n),0===C(r)&&(r=[0,1,0],U(n,t,r)),L(n,n),L(r,r),L(t,t),[n[0],n[1],n[2],0,r[0],r[1],r[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(y);p(o,o,[m,m,m*l]),d(o,o,[-i[0],-i[1],-i[2]]);const x=h([],t.globeMatrix,g);return h(x,x,o),h(x,x,e),x}(e,t,r);if(n>0){const r=function(e,t){const r=t.worldSize,n=Gu(1,0)*r*Wu(t.center.lat,t.zoom)/zh(r),i=Gu(1,t.center.lat)*r,s=u([]);m(s,s,Te(t.center.lng)),f(s,s,Te(t.center.lat)),d(s,s,[0,0,Tu]),p(s,s,[n,n,n*i]);const a=t.point;return d(s,s,[-a.x,-a.y,0]),h(s,s,e),h(s,t.globeMatrix,s)}(e,t);return function(e,t,r){const n=(e,t,r)=>{const n=I(e),i=I(t),s=vh(e,t,r);return F(s,s,1/I(s)*yr(n,i,r))},i=n([e[0],e[1],e[2]],[t[0],t[1],t[2]],r),s=n([e[4],e[5],e[6]],[t[4],t[5],t[6]],r),a=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],r),o=vh([e[12],e[13],e[14]],[t[12],t[13],t[14]],r);return [i[0],i[1],i[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,o[0],o[1],o[2],1]}(i,r,n)}return i}function Wm(e,t,r,n){const i=zc.projectAabbCorners(n,r);let s=Number.MAX_VALUE;for(let e=0;e<i.length;++e){const r=i[e];r[0]=(.5*r[0]+.5)*t.width,r[1]=(.5-.5*r[1])*t.height,r[2]<s&&(s=r[2]);}const a=function(e){const t=[];let r=0;for(let t=1;t<e.length;t++)(e[t][0]<e[r][0]||e[t][0]===e[r][0]&&e[t][1]<e[r][1])&&(r=t);let n,i=r;const s=new Uint8Array(e.length);do{if(s[i])break;t.push(new Me(e[i][0],e[i][1])),s[i]=1,n=(i+1)%e.length;for(let t=0;t<e.length;t++){if(e[t][0]===e[n][0]&&e[t][1]===e[n][1]||e[t][0]===e[i][0]&&e[t][1]===e[i][1])continue;const r=[e[t][0]-e[i][0],e[t][1]-e[i][1]],s=[e[n][0]-e[i][0],e[n][1]-e[i][1]],a=r[0]*s[1]-r[1]*s[0];(a>0||0===a&&r[0]*s[0]+r[1]*s[1]>=0&&r[0]*r[0]+r[1]*r[1]>s[0]*s[0]+s[1]*s[1])&&(n=t);}i=n;}while(i!==r);return t.length>0&&t.push(t[0]),t}(i);if(Cc(e,a))return s}const Ym=64,Jm={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Km(e,t,r,n,i,s,a,o,l,c=!1){const f=r.zoom,m=r.project(n),y=Wu(n.lat,f),g=1/y;u(e),d(e,e,[m.x+a[0]*g,m.y+a[1]*g,a[2]]);let x=1,v=1;const w=r.worldSize;if(c){if("mercator"===r.projection.name){let e=0;r.elevation&&(e=r.elevation.getAtPointOrZero(new Ku(m.x/w,m.y/w),0));const t=ee([],[m.x,m.y,e,1],r.projMatrix)[3]/r.cameraToCenterDistance;x=t,v=t*Wu(r.center.lat,f);}else if("globe"===r.projection.name){const t=Zm(e,r),i=[0,0,0,1];ee(i,i,h([],r.projMatrix,t));const s=i[3]/r.cameraToCenterDistance,a=Vh(f),o=r.projection.pixelsPerMeter(n.lat,w)*Wu(n.lat,f),l=r.projection.pixelsPerMeter(r.center.lat,w)*Wu(r.center.lat,f);x=s/yr(o,Zu(r.center.lat),a),v=s*y/o,x*=l,v*=l;}}else x=g;p(e,e,[x,x,v]);const _=[...e],A=t.orientation,I=[];if(Hm(I,[A[0]+(i?i[0]:0),A[1]+(i?i[1]:0),A[2]+(i?i[2]:0)],s),h(e,_,I),o&&r.elevation){let i=0;const s=[];if(l&&r.elevation){i=function(e,t,r,n,i){const s=t.elevation;if(!s)return 0;const a=zc.projectAabbCorners(r,n),o=Gu(1,i.lat)*t.worldSize,l=function(e,t){const r=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const i of n){const n=e[i.corners[0]],s=e[i.corners[1]],a=e[i.corners[2]],o=[s[0]-n[0],s[1]-n[1],t*(s[2]-n[2])],l=U(o,o,[a[0]-n[0],a[1]-n[1],t*(a[2]-n[2])]);L(l,l),i.dotProductWithUp=O(l,r);}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(a,o),u=a[l[0]],c=a[l[1]],h=a[l[2]],d=a[l[3]],p=s.getAtPointOrZero(new Ku(u[0]/t.worldSize,u[1]/t.worldSize),0),f=s.getAtPointOrZero(new Ku(c[0]/t.worldSize,c[1]/t.worldSize),0),m=s.getAtPointOrZero(new Ku(h[0]/t.worldSize,h[1]/t.worldSize),0),y=s.getAtPointOrZero(new Ku(d[0]/t.worldSize,d[1]/t.worldSize),0),g=(p+y)/2,x=(f+m)/2;return g>x?f<m?Xm(e,c,d,u,f,y,p,o):Xm(e,h,u,d,m,p,y,o):p<y?Xm(e,u,c,h,p,f,m,o):Xm(e,d,h,c,y,m,f,o),Math.max(g,x)}(s,r,t.aabb,e,n);const a=h([],b([],s),I);h(e,_,a);}else i=r.elevation.getAtPointOrZero(new Ku(m.x/w,m.y/w),0);0!==i&&(e[14]+=i);}}class Qm{constructor(e,t,r,n,i){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=t,this.position=null!=r?new Lu(r[0],r[1]):new Lu(0,0),this.orientation=null!=n?n:[0,0,0],this.nodes=i,this.uploaded=!1,this.aabb=new zc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[];}_applyTransformations(e,t){h(e.globalMatrix,t,e.localMatrix);const r=this.nodeOverrides.get(e.name);if(void 0!==r){const t=[];i=r.orientation,u(n=t),m(n,n,Te(i[1])),y(n,n,Te(i[2])),f(n,n,Te(i[0])),h(e.globalMatrix,e.globalMatrix,t);}var n,i;if(e.meshes)for(const t of e.meshes){const r=zc.applyTransformFast(t.aabb,e.globalMatrix);this.aabb.encapsulate(r);}if(e.children)for(const t of e.children)this._applyTransformations(t,e.globalMatrix);}computeBoundsAndApplyParent(){const e=u([]);this.aabb=new zc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const t of this.nodes)this._applyTransformations(t,e);}computeModelMatrix(e,t,r,n,i,s,a=!1){Km(this.matrix,this,e.transform,this.position,t,r,n,i,s,a);}upload(e){if(!this.uploaded){for(const t of this.nodes)ry(t,e);for(const e of this.nodes)ny(e);this.uploaded=!0;}}destroy(){for(const e of this.nodes)sy(e);}}function ey(e,t,r=!1){e.uploaded||(e.gfxTexture=new km(t,e.image,r?t.gl.R8:t.gl.RGBA8,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null);}function ty(e,t,r){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Vm.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Rm.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Cm.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Dm:Em).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Om.members,!0)),e.segments=Xl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&ey(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&ey(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&ey(n.normalTexture,t),n.occlusionTexture&&ey(n.occlusionTexture,t,r),n.emissionTexture&&ey(n.emissionTexture,t);}function ry(e,t,r){if(e.meshes)for(const n of e.meshes)ty(n,t,r);if(e.children)for(const n of e.children)ry(n,t,r);}function ny(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)ny(t);}function iy(e){e.pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy();}function sy(e){if(e.meshes)for(const t of e.meshes)t.vertexBuffer&&(t.vertexBuffer.destroy(),t.indexBuffer.destroy(),t.normalBuffer&&t.normalBuffer.destroy(),t.texcoordBuffer&&t.texcoordBuffer.destroy(),t.colorBuffer&&t.colorBuffer.destroy(),t.pbrBuffer&&t.pbrBuffer.destroy(),t.segments.destroy(),t.material&&iy(t.material));if(e.footprintDebugMesh&&(e.footprintDebugMesh.vertexBuffer.destroy(),e.footprintDebugMesh.indexBuffer.destroy(),e.footprintDebugMesh.segments.destroy()),e.children)for(const t of e.children)sy(t);}function ay(e,t){const r=e.json.bufferViews[t.bufferView],n=pm[t.componentType];return new n(e.buffers[r.buffer],(t.byteOffset||0)+(r.byteOffset||0),t.count*(r.byteStride&&r.byteStride!==mm[t.type]*n.BYTES_PER_ELEMENT?r.byteStride/n.BYTES_PER_ELEMENT:mm[t.type]))}function oy(e,t,r,n){const i=pm[t.componentType],s=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(i),a=e.json.bufferViews[t.bufferView],o=a.byteStride?a.byteStride/i.BYTES_PER_ELEMENT:mm[t.type],l=r.float32,u=l.length/r.capacity;for(let e=0,r=0;e<t.count*o;e+=o,r+=u)for(let t=0;t<u;t++)l[r+t]=n[e+t]*s;r._trim();}function ly(e,t,r){const n=e.indices,i=e.attributes,s={};s.indexArray=new yl;const a=t.json.accessors[n],o=a.count/3;s.indexArray.reserve(o);const l=ay(t,a);for(let e=0;e<o;e++)s.indexArray.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);s.indexArray._trim(),s.vertexArray=new nl;const u=t.json.accessors[i.POSITION];s.vertexArray.reserve(u.count);const c=ay(t,u);for(let e=0;e<u.count;e++)s.vertexArray.emplaceBack(c[3*e],c[3*e+1],c[3*e+2]);if(s.vertexArray._trim(),s.aabb=new zc(u.min,u.max),s.centroid=function(e,t){const r=[0,0,0],n=e.length;if(n>0){for(let i=0;i<n;i++){const n=3*e[i];r[0]+=t[n],r[1]+=t[n+1],r[2]+=t[n+2];}r[0]/=n,r[1]/=n,r[2]/=n;}return r}(l,c),void 0!==i.COLOR_0){const e=t.json.accessors[i.COLOR_0],r=mm[e.type],n=ay(t,e);s.colorArray=3===r?new nl:new ul,s.colorArray.resize(e.count),oy(t,e,s.colorArray,n);}if(void 0!==i.NORMAL){s.normalArray=new nl;const e=t.json.accessors[i.NORMAL];s.normalArray.resize(e.count);const r=ay(t,e);oy(t,e,s.normalArray,r);}if(void 0!==i.TEXCOORD_0&&r.length>0){s.texcoordArray=new Il;const e=t.json.accessors[i.TEXCOORD_0];s.texcoordArray.resize(e.count);const r=ay(t,e);oy(t,e,s.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const e=t.json.accessors[i._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(s.featureData=ay(t,e));}void 0!==i._FEATURE_RGBA4444&&(s.featureData=new Uint32Array(ay(t,t.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=e.material;return s.material=function(e,t){const{emissiveFactor:r=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:i=.5,normalTexture:s,occlusionTexture:a,emissiveTexture:o,doubleSided:l,name:u}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=a?t[a.index]:void 0;if(a&&a.extensions&&a.extensions.KHR_texture_transform&&m){const e=a.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]];}return {name:u,pbrMetallicRoughness:{baseColorFactor:new dr(...c),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new dr(...r),alphaMode:n,alphaCutoff:i,normalTexture:s?t[s.index]:void 0,occlusionTexture:m,emissionTexture:o?t[o.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},r),s}function uy(e,t,r){const{matrix:n,rotation:i,translation:s,scale:a,mesh:o,extras:u,children:c,name:h}=e,d={};if(d.name=h,d.localMatrix=n||function(e,t,r,n){var i=t[0],s=t[1],a=t[2],o=t[3],l=i+i,u=s+s,c=a+a,h=i*l,d=i*u,p=i*c,f=s*u,m=s*c,y=a*c,g=o*l,x=o*u,v=o*c,b=n[0],w=n[1],_=n[2];return e[0]=(1-(f+y))*b,e[1]=(d+v)*b,e[2]=(p-x)*b,e[3]=0,e[4]=(d-v)*w,e[5]=(1-(h+y))*w,e[6]=(m+g)*w,e[7]=0,e[8]=(p+x)*_,e[9]=(m-g)*_,e[10]=(1-(h+f))*_,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}([],i||[0,0,0,1],s||[0,0,0],a||[1,1,1]),d.globalMatrix=l(d.localMatrix),void 0!==o){d.meshes=r[o];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:r,max:n}=t.aabb;e[0]+=r[0]+n[0],e[1]+=r[1]+n[1];}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2);}if(u&&(u.id&&(d.id=u.id),u.lights&&(d.lights=function(e){if(!e.length)return [];const t=function(e){const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.codePointAt(e);return r}(e),r=[],n=t.length/24,i=new Uint16Array(t.buffer),s=new Float32Array(t.buffer);for(let e=0;e<n;e++){const t=i[2*e*6]/30,n=i[2*e*6+1]/30,a=i[2*e*6+10]/100,o=s[6*e+1],l=s[6*e+2],u=s[6*e+3],c=s[6*e+4],h=u-o,d=c-l,p=Math.hypot(h,d);r.push({pos:[o+.5*h,l+.5*d,n],normal:[d/p,-h/p,0],width:p,height:t,depth:a,points:[o,l,u,c]});}return r}(u.lights)),u.MAPBOX_geometry_bloom&&(d.isGeometryBloom=u.MAPBOX_geometry_bloom)),c){const e=[];for(const n of c)e.push(uy(t.json.nodes[n],t,r));d.children=e;}return d}function cy(e){if(0===e.vertices.length||0===e.indices.length)return null;const t=new Vp(e.vertices,e.indices,8,256),[r,n]=[t.min.clone(),t.max.clone()];return {vertices:e.vertices,indices:e.indices,grid:t,min:r,max:n}}function hy(e){if(!e.extras||!e.extras.ground)return null;const t=e.extras.ground;if(!t||!Array.isArray(t)||0===t.length)return null;const r=t[0];if(!r||!Array.isArray(r)||0===r.length)return null;const n=[];for(const e of r){if(!Array.isArray(e)||2!==e.length)continue;const t=e[0],r=e[1];"number"==typeof t&&"number"==typeof r&&n.push(new Me(t,r));}if(n.length<3)return null;n.length>1&&n[n.length-1].equals(n[0])&&n.pop();let i=0;for(let e=0;e<n.length;e++){const t=n[e],r=n[(e+1)%n.length],s=n[(e+2)%n.length];i+=(t.x-r.x)*(s.y-r.y)-(s.x-r.x)*(t.y-r.y);}i>0&&n.reverse();const s=ld(n.flatMap(e=>[e.x,e.y]),[]);return 0===s.length?null:{vertices:n,indices:s}}function dy(e,t){const r=[],n=[];let i=0;const s=[];for(const a of e){i=r.length;const e=a.vertexArray.float32,o=a.indexArray.uint16;for(let n=0;n<a.vertexArray.length;n++)s[0]=e[3*n+0],s[1]=e[3*n+1],s[2]=e[3*n+2],j(s,s,t),r.push(new Me(s[0],s[1]));for(let e=0;e<3*a.indexArray.length;e++)n.push(o[e]+i);}if(n.length%3!=0)return null;for(let e=0;e<n.length;e+=3){const t=r[n[e+0]],i=r[n[e+1]],s=r[n[e+2]];(t.x-i.x)*(s.y-i.y)-(s.x-i.x)*(t.y-i.y)>0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]]);}return {vertices:r,indices:n}}function py(e){const t=function(e,t){const r=[],n=WebGL2RenderingContext;if(e.json.textures)for(const i of e.json.textures){const s={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==i.sampler&&Object.assign(s,e.json.samplers[i.sampler]),r.push({image:t[i.source],sampler:s,uploaded:!1});}return r}(e,e.images),r=function(e,t){const r=[];for(const n of e.json.meshes){const i=[];for(const r of n.primitives)i.push(ly(r,e,t));r.push(i);}return r}(e,t),{scenes:n,scene:i,nodes:s}=e.json,a=n?n[i||0].nodes:[...s.keys()],o=[];for(const t of a)o.push(uy(s[t],e,r));return function(e,t,r){const n={},i=new Set;for(let s=0;s<e.length;s++){const e=r[t[s]];if(!e.extras)continue;const a=e.extras["mapbox:footprint:version"],o=e.extras["mapbox:footprint:id"];(a||o)&&i.add(s),"1.0.0"===a&&o&&(n[o]=s);}for(let s=0;s<e.length;s++){if(i.has(s))continue;const a=e[s],o=r[t[s]];if(!o.extras)continue;let l=null;a.id in n&&(l=dy(e[n[a.id]].meshes,a.localMatrix)),l||(l=hy(o)),l&&(a.footprint=cy(l));}if(i.size>0){const t=Array.from(i.values()).sort((e,t)=>e-t);for(let r=t.length-1;r>=0;r--)e.splice(t[r],1);}}(o,a,e.json.nodes),o}function fy(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,r=e.aabb.min[0]-1,n=e.aabb.min[1]-1,i=Ym/(e.aabb.max[0]-r+2),s=Ym/(e.aabb.max[1]-n+2);for(let a=0;a<t.length;a+=3){const o=t[a+2],l=(t[a+0]-r)*i|0,u=(t[a+1]-n)*s|0;o>e.heightmap[u*Ym+l]&&(e.heightmap[u*Ym+l]=o);}}function my(e,t,r,n,i){r.reserve(r.length+4*e.length),n.reserve(n.length+10*e.length),i.reserve(i.length+10*e.length);let s=n.length;for(const a of e){const e=Math.min(10,Math.max(4,1.3*a.height))*t,o=[-a.normal[1],a.normal[0],0],l=Math.min(.29,.1*a.width/a.depth),u=a.width-2*a.depth*t*(l+.01),c=V([],a.pos,o,u/2),h=V([],a.pos,o,-u/2),d=[c[0],c[1],c[2]+a.height],p=[h[0],h[1],h[2]+a.height],f=V([],a.normal,o,l);F(f,f,e);const m=V([],a.normal,o,-l);F(m,m,e),B(f,c,f),B(m,h,m),c[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]);const y=u/e/2;i.emplaceBack(-y-l,-1,y,.8),i.emplaceBack(y+l,-1,y,.8),i.emplaceBack(-y,0,y,1.3),i.emplaceBack(y,0,y,1.3),i.emplaceBack(y+l,-.8,y,.7),i.emplaceBack(y+l,-.8,y,.7),i.emplaceBack(0,0,y,1.3),i.emplaceBack(0,0,y,1.3),i.emplaceBack(y+l,-1.2,y,.8),i.emplaceBack(y+l,-1.2,y,.8),r.emplaceBack(6+s,4+s,8+s),r.emplaceBack(7+s,9+s,5+s),r.emplaceBack(0+s,1+s,2+s),r.emplaceBack(1+s,3+s,2+s),s+=10;}}function yy(e,t){const r={};r.indexArray=new yl,r.vertexArray=new nl,r.colorArray=new ul,my(e,t,r.indexArray,r.vertexArray,r.colorArray);const n={defined:!0};n.emissiveFactor=dr.black;const i={};return i.baseColorFactor=dr.white,n.pbrMetallicRoughness=i,r.material=n,r.aabb=new zc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}const gy=Ho([{name:"a_pos_3f",components:3,type:"Float32"}]),xy=Ho([{name:"a_normal_3",components:3,type:"Int16"}]),vy=Ho([{name:"a_centroid_3",components:3,type:"Int16"}]),by=Ho([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),wy=Ho([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),_y=Ho([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Ay=Ho([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Iy=Ho([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),My=Ho([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),Sy=lc.types,By=32767;function Py(e,t){const r=qn+t;for(const n of e)for(const e of n)if(e.x<-t||e.x>r||e.y<-t||e.y>r)return !1;return !0}function Ty(e){switch(e){case "flat":return 3;case "hipped":return 1;case "gabled":return 2;case "parapet":return 0;case "mansard":return 4;case "skillion":return 5;case "pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${e}`)}}class zy{constructor(){this.layoutVertexArray=new nl,this.layoutAttenuationArray=new ul,this.layoutColorArray=new hl,this.indexArray=new yl,this.indexArrayForConflation=new yl,this.segmentsBucket=new Xl;}}class ky{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new Xl,this.entranceBloom=new zy;const t=66560;this.layoutVertexArray=new nl,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new Wo,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new Wo,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new hl,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new Tl,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new zl,this.layoutAOArray.reserve(t),this.indexArray=new yl,this.indexArray.reserve(66560),this.indexArrayForConflation=new yl,this.segmentsBucket=new Xl,this.entranceBloom=new zy,e&&(this.layoutFacadePaintArray=new hl,this.layoutFacadeDataArray=new sl,this.layoutFacadeVerticalRangeArray=new hl);}reserve(e,t,r){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(t),r&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e));}}class Fy{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Il,this.footprintsIndices=new Sl,this.footprintsMin=new Me(1/0,1/0),this.footprintsMax=new Me(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new ky(!1),this.buildingWithFacade=new ky(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new Au(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.groundEffect=new Mf(e),this.groundEffect.groundRadiusArray=new Jo,this.hasAppearances=null;}updateFootprints(e,t){const r=new Vp([],[],1),n={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:n,id:e});}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}prepare(){return function(){if(null!=nm||null!=im)return null;if(null!=sm)return sm;const e=fetch(ht());return sm=function(e){let t,r,n,i,s;function a(){t=new Uint8Array(s.buffer),r=new Int16Array(s.buffer),n=new Int32Array(s.buffer),i=new Float32Array(s.buffer);}function o(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},u={a:{a:o,f:function(e){const r=t.length,n=Math.max(e>>>0,Math.ceil(1.2*r)),i=Math.ceil((n-r)/65536);try{return s.grow(i),a(),!0}catch(e){return !1}},g:o,b:l,c:l,d:l,e:l}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,u):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,u))).then(e=>{const o=e.instance.exports;return (0,o.g)(),s=o.f,a(),new Qf({setStyle:o.h,setAOOptions:o.i,setMetricOptions:o.j,setStructuralOptions:o.k,setFacadeOptions:o.l,setFauxFacadeOptions:o.m,setFacadeClassifierOptions:o.n,addFeature:o.o,addFacade:o.p,generateMesh:o.q,getLastError:o.r,getOuterRingLength:o.s,getMeshCount:o.t,getPositionsPtr:o.u,getPositionsLength:o.v,getNormalsPtr:o.w,getNormalsLength:o.x,getAOPtr:o.y,getAOLength:o.z,getUVPtr:o.A,getUVLength:o.B,getFauxFacadePtr:o.C,getFauxFacadeLength:o.D,getIndicesPtr:o.E,getIndicesLength:o.F,getBuildingPart:o.G,getRingCount:o.H,getRingPtr:o.I,getRingLength:o.J,malloc:o.K,free:o.L,heapU8:t,heap16:r,heap32:n,heapF32:i})})}(e).then(e=>(sm=null,nm=e,nm)).catch(e=>{Ze("Could not load building-gen"),sm=null,im=e instanceof Error?e:new Error("Unknown error");}),sm}()}populate(e,t,r,n){const i=am();if(!i)return;const s=Ju(r);this.tileToMeter=s,this.brightness=t.brightness,i.setStyle({normalScale:[1,-1,s],tileToMeters:s}),i.setAOOptions(!1,.3),i.setMetricOptions(!1,16),i.setStructuralOptions(!0),i.setFacadeClassifierOptions(3);const a=new Map,o=new Map;let l=0;for(const{feature:t}of e){if("LineString"!==Sy[t.type]){a.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new to(this.zoom),t,r))continue;const i=oc(t,e);if(!e&&!this.layers[0]._featureFilter.filter(new to(this.zoom),i,r))continue;const s=e?i.geometry:ac(t,r,n),u=[];for(const e of s)for(const t of e)u.push(t.x),u.push(t.y);const c={coordinates:u,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},h=t.properties.source_id;let d=o.get(h);d||(d=[],o.set(h,d)),d.push(c),++l;}this.maxHeight=0;const u=new Array,c=new Set,h=e=>{null!=e&&c.add(e);},d=(e,t)=>{null!=e&&u.push({buildingId:e,footprintIndex:t});},p=64*(e.length-l),f=p/2;this.buildingWithFacade.reserve(p,f,!0),this.buildingWithoutFacade.reserve(2*p,2*f,!1),this.footprintsIndices.reserve(16*(e.length-l)),this.footprintsVertices.reserve(8*(e.length-l));for(const{feature:l,id:u,index:p,sourceLayerIndex:f}of e){if("LineString"===Sy[l.type])continue;const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new to(this.zoom),l,r))continue;let m=null;if(l.properties&&l.properties.hasOwnProperty("building_id")&&(m=Number(l.properties.building_id),c.has(m)))continue;const y=oc(l,e);if(!e&&!this.layers[0]._featureFilter.filter(new to(this.zoom),y,r))continue;const g=e?y.geometry:ac(l,r,n),x=Dd(g,500);let v=!1;for(const e of x)if(1!==e.length){v=!0;break}if(v){h(m);continue}if(!Py(g,163)){h(m);continue}const b=this.layers[0],w=Ty(b.layout.get("building-roof-shape").evaluate(l,{},r)),_=b.layout.get("building-base").evaluate(l,{},r),A=b.layout.get("building-height").evaluate(l,{},r),I=b.layout.get("building-flood-light-ground-radius").evaluate(l,{},r),M=b.paint.get("building-ambient-occlusion-intensity"),S=I/this.tileToMeter;l.properties["building-part"]="roof";const B=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),P=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="wall";const T=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),z=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="window";const k=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),F=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="door";const V=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),D=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);let E=b.layout.get("building-flood-light-wall-radius").evaluate(l,{},r);E=Ee(E,0,2048);const C=E/2048*By,R=a.get(u),L=o.get(R)||[],O=0!==L.length&&b.layout.get("building-facade").evaluate(l,{},r);i.setFacadeOptions(4,!0),i.setFauxFacadeOptions(O,!1,1);let U=0,N=0,j=0,G=0,$=0,q=0,H=0,X=0,Z=0,W=0,Y=0;if(O){let e=Math.round(b.layout.get("building-facade-floors").evaluate(l,{},r));if(0===_){e=Math.max(1,e-(L.length>0?1:0));let t=4;if(A>100){const e=[10,13,15];t=e[l.id?l.id%e.length:0];}else A<=10&&(t=3);i.setFacadeOptions(t,!0),$=(A<15?1.3:1.61803)*t/s;}else $=_/s;q=A/s,$=Math.min($,q),j=b.layout.get("building-facade-unit-width").evaluate(l,{},r)/s,G=(q-$)/e,i.setFauxFacadeOptions(!0,!0,j);const t=b.layout.get("building-facade-window").evaluate(l,{},r);U=t[0],N=t[1],H=Math.floor(65535*Math.min(1,$/qn)),X=Math.floor(65535*Math.min(1,q/qn)),Z=Math.floor(255*U)<<8|Math.floor(255*N),W=Math.floor(65535*Math.min(1,j/qn)),Y=Math.floor(65535*Math.min(1,G/qn));}const J=Array(x.length),K={x:1/0,y:1/0},Q={x:-1/0,y:-1/0},ee={x:0,y:0};let te=0;for(let e=0;e<x.length;e++){const t=x[e];if(t.length>0){const r=[],n=Array(t.length+1);n[0]=0;for(let e=0;e<t.length;e++){const i=t[e];for(let e=0;e<i.length;e++){const t=i[i.length-e-1];K.x=Math.min(K.x,t.x),K.y=Math.min(K.y,t.y),Q.x=Math.max(Q.x,t.x),Q.y=Math.max(Q.y,t.y),ee.x+=t.x,ee.y+=t.y,te++,r.push(t.x),r.push(t.y);}n[e+1]=r.length;}J[e]={id:l.id?l.id:0,height:A,minHeight:_,sourceId:0,roofType:w,coordinates:r,ringIndices:n};}}ee.x/=te||1,ee.y/=te||1;const re=i.generateMesh(J,L);if("string"==typeof re){Ze(`Unable to generate building ${l.id}: ${re}`),h(m);continue}if(0===re.meshes.length||0===re.modifiedPolygonRings.length){h(m);continue}const ne=O?this.buildingWithFacade:this.buildingWithoutFacade;let ie=0;for(const e of re.meshes)ie+=e.positions.length/3;const se=ne.segmentsBucket.prepareSegment(ie,ne.layoutVertexArray,ne.indexArray),ae=[];let oe=null,le=0,ue=-1;const ce=ne.layoutVertexArray.length,he=ce+ie;ne.layoutVertexArray.resize(he),ne.layoutCentroidArray.resize(he),ne.layoutNormalArray.resize(he),ne.layoutAOArray.resize(he),ne.layoutColorArray.resize(he),ne.layoutFloodLightDataArray.resize(he),O&&(ne.layoutFacadePaintArray.resize(he),ne.layoutFacadeDataArray.resize(he),ne.layoutFacadeVerticalRangeArray.resize(he));const de=ne.indexArray.length;let pe=0,fe=ce;for(const e of re.meshes){let t,r;if(1===e.buildingPart)t=B,r=P;else if(0===e.buildingPart)t=T,r=z;else if(2===e.buildingPart)t=k,r=F;else {if(3!==e.buildingPart)continue;t=V,r=D;}if(r=Ee(r,0,1),3===e.buildingPart){const t=new Array;for(let r=0;r<e.positions.length;r+=12){const n=e.positions[r+0],i=e.positions[r+1],s=e.positions[r+3],a=e.positions[r+4],o=e.positions[r+2],l=e.positions[r+8]-o,u=1,c=s-n,h=a-i,d=Math.hypot(c,h);t.push({pos:[n+.5*c,i+.5*h,o],normal:[h/d,-c/d,0],width:d,height:l,depth:u,points:[n,i,s,a]});}const r=ne.entranceBloom.segmentsBucket.prepareSegment(10*t.length,ne.entranceBloom.layoutVertexArray,ne.entranceBloom.indexArray),n=ne.entranceBloom.layoutVertexArray.length;le=ne.entranceBloom.indexArray.length,my(t,.5/this.tileToMeter,ne.entranceBloom.indexArray,ne.entranceBloom.layoutVertexArray,ne.entranceBloom.layoutAttenuationArray);const i=ne.entranceBloom.layoutVertexArray.length-n;ue=ne.entranceBloom.indexArray.length-le;for(let e=0;e<i;e++)ne.entranceBloom.layoutColorArray.emplaceBack(255*V.r<<8|255*V.g,255*V.b<<8|51*D);r.vertexLength+=i,r.primitiveLength+=ue,oe={part:e.buildingPart,vertexOffset:n,vertexLength:i};}ne.layoutVertexArray.float32.set(e.positions,3*fe);const n=e.positions.length/3;for(let i=0;i<n;++i){const n=3*i;pe=Math.max(pe,e.positions[n+2]);const s=e.normals[n+1]*By,a=e.normals[n+2]*By,o=3*(fe+i);ne.layoutNormalArray.int16[o]=e.normals[n]*By,ne.layoutNormalArray.int16[o+1]=s,ne.layoutNormalArray.int16[o+2]=a;const l=e.ao[i];ne.layoutAOArray.uint8[fe+i]=255*l;const u=1+(l-1)*M,c=255*t.b*u<<8|255*r;ne.layoutColorArray.uint16[2*(fe+i)]=255*t.r*u<<8|255*t.g*u,ne.layoutColorArray.uint16[2*(fe+i)+1]=c;}const i=Math.min(8191,Math.max(0,Math.floor(ee.x))),s=Math.min(8191,Math.max(0,Math.floor(ee.y))),a=Math.floor(A),o=20,l=4*i+Math.min(3,Math.round((Q.x-K.x)*this.tileToMeter/o)),u=4*s+Math.min(3,Math.round((Q.y-K.y)*this.tileToMeter/o));for(let e=0;e<n;++e){const t=3*(fe+e);ne.layoutCentroidArray.int16[t]=l,ne.layoutCentroidArray.int16[t+1]=u,ne.layoutCentroidArray.int16[t+2]=a;}if(ne.layoutFloodLightDataArray.int16.fill(0===e.buildingPart?C:0,fe,fe+n),O){const t=255*k.r<<8|255*k.g,r=255*k.b<<8|255*F;for(let e=0;e<n;++e){const n=2*(fe+e);ne.layoutFacadePaintArray.uint16[n]=t,ne.layoutFacadePaintArray.uint16[n+1]=r;}for(let t=0;t<n;++t)if(e.isFauxFacade[t]){const r=Math.min(65535,Math.floor(e.uv[2*t]*re.outerRingLength));ne.layoutFacadeDataArray.emplace(fe+t,1|r,Z,W,Y),ne.layoutFacadeVerticalRangeArray.emplace(fe+t,H,X);}else ne.layoutFacadeDataArray.emplace(fe+t,0,0,0,0),ne.layoutFacadeVerticalRangeArray.emplace(fe+t,0,0);}const c=se.vertexLength,h=e.indices.length/3,d=ne.indexArray.length;ne.indexArray.resize(d+h);for(let t=0;t<h;++t){const r=3*t,n=3*d+r;ne.indexArray.uint16[n]=c+e.indices[r],ne.indexArray.uint16[n+1]=c+e.indices[r+1],ne.indexArray.uint16[n+2]=c+e.indices[r+2];}1!==e.buildingPart&&0!==e.buildingPart&&2!==e.buildingPart&&3!==e.buildingPart||ae.push({part:e.buildingPart,vertexOffset:fe,vertexLength:e.positions.length/3}),fe+=n,se.vertexLength+=n,se.primitiveLength+=e.indices.length/3;}this.maxHeight=Math.max(this.maxHeight,pe);const me=ne.indexArray.length-de,ye=this.footprintsIndices.length,ge=this.footprintsVertices.length,xe=[],ve=new Me(1/0,1/0),be=new Me(-1/0,-1/0),we=this.groundEffect.vertexArray.length;for(const e of re.modifiedPolygonRings){const t=[],r=new Me(1/0,1/0),n=new Me(-1/0,-1/0);for(let i=0;i<e.length;i+=2){const s=e.length-i-2;r.x=Math.min(r.x,e[s]),r.y=Math.min(r.y,e[s+1]),n.x=Math.max(n.x,e[s]),n.y=Math.max(n.y,e[s+1]);const a=new Me(e[s],e[s+1]);t.push(a),xe.push(a.x,a.y),this.footprintsVertices.emplaceBack(a.x,a.y);}ve.x=Math.min(ve.x,r.x),ve.y=Math.min(ve.y,r.y),be.x=Math.max(be.x,n.x),be.y=Math.max(be.y,n.y),this.groundEffect.addData(t,[r,n],S);}const _e=this.groundEffect.vertexArray.length-we;this.groundEffect.groundRadiusArray.reserveForAdditional(_e);for(let e=0;e<_e;e++)this.groundEffect.groundRadiusArray.emplaceBack(I);(K.x<0||Q.x>qn||K.y<0||Q.y>qn)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{const e=ld(xe,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+e.length),this.footprintsIndices.uint16.set(e,ye),this.buildingIds.add(null!=m?m:l.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,ve.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,ve.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,be.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,be.y);const t={footprintVertexOffset:ge,footprintVertexLength:this.footprintsVertices.length-ge,footprintIndexOffset:ye,footprintIndexLength:this.footprintsIndices.length-ye,min:ve,max:be,hiddenFlags:0,indicesOffset:de,indicesLength:me,bloomIndicesOffset:le,bloomIndicesLength:ue,groundEffectVertexOffset:we,groundEffectVertexLength:_e,hasFauxFacade:O,height:pe,promoteId:u,feature:y,parts:ae,buildingBloom:oe},r=this.footprints.length;void 0!==l.id&&this.featureFootprintLookup.set(l.id,r),d(m,r),this.footprints.push(t);}this.programConfigurations.populatePaintArrays(ne.layoutVertexArray.length,l,p,{},t.availableImages,r,t.brightness),this.groundEffect.addPaintPropertiesData(l,p,{},t.availableImages,r,t.brightness),t.featureIndex.insert(l,g,p,f,this.index,ce);}u.forEach(({buildingId:e,footprintIndex:t})=>{c.has(e)&&(this.footprints[t].hiddenFlags|=4);});const m=new Set;this.buildingIds.forEach((e,t,r)=>{c.has(e)||m.add(e);}),this.buildingIds=m,this.groundEffect.prepareBorderSegments();}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a),this.groundEffect.update(e,t,i,r,n,s,a),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1;}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=t=>{t.layoutVertexBuffer=e.createVertexBuffer(t.layoutVertexArray,gy.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,xy.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,vy.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,My.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,_y.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,Ay.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,gy.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,Iy.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e);};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){const e=e=>{e.layoutVertexBuffer&&(e.layoutVertexBuffer.destroy(),e.layoutNormalBuffer.destroy(),e.layoutColorBuffer.destroy(),e.segmentsBucket.destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.entranceBloom.layoutVertexBuffer&&(e.entranceBloom.layoutVertexBuffer.destroy(),e.entranceBloom.layoutColorBuffer.destroy(),e.entranceBloom.layoutAttenuationBuffer.destroy(),e.entranceBloom.indexBuffer.destroy(),e.entranceBloom.segmentsBucket.destroy()));};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy();}updateFootprintHiddenFlags(e,t,r=!0){let n=!1;const i=r?t:0,s=0|(r?-1:~t);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of e){const e=this.footprints[t],r=e.hiddenFlags&s|i;e.hiddenFlags!==r&&(e.hiddenFlags=r,n=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags));}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=e=>{0!==e.indexArray.length&&(e.indexArrayForConflation.resize(e.indexArray.length),e.indexArrayForConflation.uint16.set(e.indexArray.uint16),e.entranceBloom.indexArrayForConflation.resize(e.entranceBloom.indexArray.length),e.entranceBloom.indexArrayForConflation.uint16.set(e.entranceBloom.indexArray.uint16));};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const e of this.footprints){const t=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,r=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let n=e.indicesOffset;n<r;n++)t.indexArrayForConflation.uint16[3*n+0]=0,t.indexArrayForConflation.uint16[3*n+1]=0,t.indexArrayForConflation.uint16[3*n+2]=0;const n=e.bloomIndicesOffset+e.bloomIndicesLength;for(let r=e.bloomIndicesOffset;r<n;r++)t.entranceBloom.indexArrayForConflation.uint16[3*r+0]=0,t.entranceBloom.indexArrayForConflation.uint16[3*r+1]=0,t.entranceBloom.indexArrayForConflation.uint16[3*r+2]=0;}}const r=t=>{0!==t.indexArray.length&&(t.indexBuffer?t.indexBuffer.updateData(t.indexArrayForConflation):t.indexBuffer=e.createIndexBuffer(t.indexArrayForConflation,!0),t.entranceBloom.indexBuffer?t.entranceBloom.indexBuffer.updateData(t.entranceBloom.indexArrayForConflation):t.entranceBloom.indexBuffer=e.createIndexBuffer(t.entranceBloom.indexArrayForConflation,!0));};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0;}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,by.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,wy.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,by.members,!0);};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0;}evaluate(e,t){const r=e.paint.get("building-ambient-occlusion-intensity");for(const n of this.footprints){if(4&n.hiddenFlags)continue;const i=t[n.promoteId],s=n.feature;s.properties["building-part"]="roof";const a=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),o=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),u=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="window";const c=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,i=a;1===e.part?(i=a,t=o):0===e.part?(i=l,t=u):2===e.part?(i=c,t=h):3===e.part&&(i=d,t=p),t=Ee(t,0,1);for(let s=0;s<e.vertexLength;s++){const a=e.vertexOffset+s,o=1+(f.layoutAOArray.uint8[a]/255-1)*r;f.layoutColorArray.emplace(a,i.r*o*255<<8|i.g*o*255,i.b*o*255<<8|255*t),n.hasFauxFacade&&f.layoutFacadePaintArray.emplace(a,255*c.r<<8|255*c.g,255*c.b<<8|255*h);}}const m=n.buildingBloom;if(m)for(let e=0;e<m.vertexLength;e++)f.entranceBloom.layoutColorArray.emplace(m.vertexOffset+e,255*d.r<<8|255*d.g,255*d.b<<8|51*p);}}needsEvaluation(){return !this.colorBufferUploaded}updateReplacement(e,t,r){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped());if(Yp(this.activeReplacements,n))return;this.activeReplacements=n;for(const e of this.footprints)e.hiddenFlags&=-2;const i=[];for(const t of this.activeReplacements){if(t.order<r)continue;const n=Math.max(1,Math.pow(2,t.footprintTileId.canonical.z-e.canonical.z));for(const r of this.footprints)r.min.x>t.max.x||r.max.x<t.min.x||r.min.y>t.max.y||r.max.y<t.min.y||(i.length=0,Dy(this.footprintsVertices,r.footprintVertexOffset,r.footprintVertexLength,t.footprintTileId.canonical,e.canonical,i),Qp(t.footprint,i,this.footprintsIndices.uint16,r.footprintIndexOffset,r.footprintIndexLength,0,-n)&&(r.hiddenFlags|=1));}0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags);this.indexArrayForConflationUploaded=!1;}getFootprint(e){if(void 0!==e.id){const t=this.featureFootprintLookup.get(e.id);return this.footprints[t]}return null}getHeightAtTileCoord(e,t){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(e+qn)*qn+(t+qn);if(this.footprintLookup.hasOwnProperty(i)){const e=this.footprintLookup[i];return e?{height:e.height,hidden:0!==e.hiddenFlags}:void 0}const s=new Me(e,t);for(const a of this.footprints)e>a.max.x||a.min.x>e||t>a.max.y||a.min.y>t||a.height<=r||Vy(s,this.footprintsVertices.float32.subarray(2*a.footprintVertexOffset,2*(a.footprintVertexOffset+a.footprintVertexLength)),this.footprintsIndices.uint16.subarray(a.footprintIndexOffset,a.footprintIndexOffset+a.footprintIndexLength))&&(r=a.height,this.footprintLookup[i]=a,n=0!==a.hiddenFlags);if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.footprintLookup[i]=void 0;}}function Vy(e,t,r){for(let n=0;n<r.length;n+=3){const i=r[n],s=r[n+1],a=r[n+2],o=t[2*i+0],l=t[2*i+1],u=t[2*s+0],c=t[2*s+1],h=t[2*a+0],d=t[2*a+1],p=(o-h)*(e.y-d)-(l-d)*(e.x-h),f=(u-o)*(e.y-l)-(c-l)*(e.x-o);if(p<0!=f<0&&0!==p&&0!==f)continue;const m=(h-u)*(e.y-c)-(d-c)*(e.x-u);if(0===m||m<0==p+f<=0)return !0}return !1}function Dy(e,t,r,n,i,s){const a=Math.pow(2,n.z-i.z);for(let o=0;o<r;o++){let r=e.float32[2*(o+t)+0],l=e.float32[2*(o+t)+1];r=(r+i.x*qn)*a-n.x*qn,l=(l+i.y*qn)*a-n.y*qn,s.push(new Me(r,l));}}let Ey,Cy;ra(Fy,"BuildingBucket",{omit:["layers"]}),ra(ky,"BuildingGeometry"),ra(zy,"BuildingBloomGeometry");const Ry=Ho([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),Ly=Ho([{name:"a_z_offset_width",components:3,type:"Float32"}],4),Oy=Ho([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:Uy}=Ry,Ny=Ho([{name:"a_packed",components:3,type:"Float32"}]),{members:jy}=Ny,Gy=Ho([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:$y}=Gy;class qy{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new ed({width:e,height:t}),this.positions={},this.uploaded=!1;}getDash(e,t){const r=this.getKey(e,t);return this.positions[r]}trim(){const e=this.width,t=this.height=Ne(this.nextRow);this.image.resize({width:e,height:t});}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,r){const n=[];let i=e.length%2==1?-e[e.length-1]*r:0,s=e[0]*r,a=!0;n.push({left:i,right:s,isDash:a,zeroLength:0===e[0]});let o=e[0];for(let t=1;t<e.length;t++){a=!a;const l=e[t];i=o*r,o+=l,s=o*r,n.push({left:i,right:s,isDash:a,zeroLength:0===l});}return n}addRoundDash(e,t,r){const n=t/2;for(let t=-r;t<=r;t++){const i=this.width*(this.nextRow+r+t);let s=0,a=e[s];for(let o=0;o<this.width;o++){o/a.right>1&&(a=e[++s]);const l=Math.abs(o-a.left),u=Math.abs(o-a.right),c=Math.min(l,u);let h;const d=t/r*(n+1);if(a.isDash){const e=n-Math.abs(d);h=Math.sqrt(c*c+e*e);}else h=n-Math.sqrt(c*c+d*d);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const r=e[t],n=e[t+1];r.zeroLength?e.splice(t,1):n&&n.isDash===r.isDash&&(n.left=r.left,e.splice(t,1));}const r=e[0],n=e[e.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let s=0,a=e[s];for(let r=0;r<this.width;r++){r/a.right>1&&(a=e[++s]);const n=Math.abs(r-a.left),o=Math.abs(r-a.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128));}}addDash(e,t){const r=this.getKey(e,t);if(this.positions[r])return this.positions[r];const n="round"===t,i=n?7:0,s=2*i+1;if(this.nextRow+s>this.height)return Ze("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t<e.length;t++)e[t]<0&&(Ze("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),a+=e[t];if(0!==a){const r=this.width/a,s=this.getDashRanges(e,this.width,r);n?this.addRoundDash(s,r,i):this.addRegularDash(s,"square"===t?.5*r:0);}const o=this.nextRow+i;this.nextRow+=s;const l=Math.floor(a),u={tl:[o,i],br:[l,Math.round(65535*(a-l))]};return this.positions[r]=u,u}}ra(qy,"LineAtlas");const Hy=lc.types,Xy=Math.cos(Math.PI/180*37.5),Zy=Math.cos(Math.PI/180*5);class Wy{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.zoom=e.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=e.overscaling,this.pixelRatio=e.pixelRatio,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={};}),this.layoutVertexArray=new rl,this.layoutVertexArray2=new nl,this.patternVertexArray=new nl,this.indexArray=new yl,this.programConfigurations=new Au(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new Xl,this.maxLineLength=0,this.zOffsetVertexArray=new nl,this.elevationGroundScaleVertexArray=new Jo,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.hasPattern=Rd("line",this.layers,this.pixelRatio,t);const i=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Ju(r);const s=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===s)this.elevationType="road";else {const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==s&&"ground"!==s&&t?"none":"offset","offset"===this.elevationType&&"none"===s&&Ze(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference="sea"===s;}const a=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==a;const o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=oc(s,e);if(!this.layers[0]._featureFilter.filter(new to(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:ac(s,r,n),patterns:{},sortKey:h};o.push(d);}i&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:u}=t,c=this.addConstantDashes(l);for(const n of o){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(c&&this.addFeatureDashes(n,l),this.hasPattern){const e=Ld("line",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,i,s,r,l.positions,t.availableImages,t.brightness,t.elevationFeatures);u.insert(e[s].feature,i,s,a,this.index);}}addConstantDashes(e){let t=!1;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,i=r.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==i.kind)t=!0;else {const t=i.value,r=n.value;if(!r)continue;e.addDash(r,t);}}return t}addFeatureDashes(e,t){const r=this.zoom;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===s.kind)continue;let a,o;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:r},e);o="constant"===s.kind?s.value:s.evaluate({zoom:r},e),t.addDash(a,o),e.patterns[n.id]=[t.getKey(a,o)];}}update(e,t,r,n,i,s,a,o,l){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,l);}addFeatures(e,t,r,n,i,s){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,s,e.elevationFeatures);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,jy)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,$y)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Ly.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,Oy.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Uy),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(e,t){let r,n;if(t&&t>0?(r=`mapbox_clip_start_${t}`,n=`mapbox_clip_end_${t}`):(r="mapbox_clip_start",n="mapbox_clip_end"),e.properties&&e.properties.hasOwnProperty(r)&&e.properties.hasOwnProperty(n))return {start:+e.properties[r],end:+e.properties[n]}}addFeature(e,t,r,n,i,s,a,o){const l=this.layers[0].layout,u=l.get("line-join").evaluate(e,{}),c=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const p=!(!e.properties||!e.properties.hasOwnProperty("mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const f=this.layers[0].paint.get("line-width").value;if("constant"!==f.kind&&!1===f.isLineProgressConstant&&(this.variableWidthValue=f),this.isSeaLevelReference){const e=l.get("line-elevation-ground-scale").value;"constant"===e.kind&&0===e.value||(this.elevationGroundScaleValue=e);}if("road"===this.elevationType){const r=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,n,o,u,c,h,d)){const[i,s]=this.clipRuntimeLinesToTile(t,1);for(let t=0;t<i.length;t++){const r=i[t],a=s[t],o={progress:{min:a.progress.min,max:a.progress.max},nextDir:this.computeSegNextDir(a,r),prevDir:this.computeSegPrevDir(a,r)};this.addLine(r,e,n,u,c,h,d,o,p&&a.parentIndex>0?a.parentIndex:null);}this.fillNonElevatedRoadSegment(r);}}else for(let r=0;r<t.length;r++)this.addLine(t[r],e,n,u,c,h,d,void 0,p&&r>0?r:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,i,s,n,a,void 0,this.worldview);}computeSegNextDir(e,t){return e.nextPoint.sub(t.at(-2)).unit()}computeSegPrevDir(e,t){return t[1].sub(e.prevPoint).unit()}clipLinesToTile(e,t){return $f(e,-t,-t,qn+t,qn+t)}clipRuntimeLinesToTile(e,t){const r=[];return [$f(e,-t,-t,qn+t,qn+t,r),r]}addElevatedRoadFeature(e,t,r,n,i,s,a,o){const l=[],u=Vc.getElevationFeature(e,n);if(u){const e=this.clipLinesToTile(t,1),n=this.prepareElevatedLines(e,u,r);for(const e of n)l.push({geometry:e,elevation:u,elevationTileID:r,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}});}if(0===l.length)return !1;for(const t of l){const n=this.layoutVertexArray.length;this.addLine(t.geometry,e,r,i,s,a,o);const l=new Dc(r,t.elevationTileID);if(t.elevation)for(let e=n;e<this.layoutVertexArray.length;e++){const r=new Me(this.layoutVertexArray.int16[6*e]>>1,this.layoutVertexArray.int16[6*e+1]>>1),n=l.pointElevation(r,t.elevation,.05);this.updateHeightRange(n),this.zOffsetVertexArray.emplaceBack(n,0,0);}else this.fillNonElevatedRoadSegment(n);}return !0}prepareElevatedLines(e,t,r){if(null!=t.constantHeight)return e;const n=[],i=1/Ju(r);for(const r of e)qf(r,new kc(t,i),0,n);return n}fillNonElevatedRoadSegment(e){for(let t=e;t<this.layoutVertexArray.length;t++)this.zOffsetVertexArray.emplaceBack(0,0,0);}updateHeightRange(e){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,e),this.heightRange.max=Math.max(this.heightRange.max,e)):this.heightRange={min:e,max:e};}addLine(e,t,r,n,i,s,a,o,l){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0,this.lineClips=l?this.lineFeatureClips(t,l):this.lineClips;const u="none"===n;this.patternJoinNone=this.hasPattern&&u,this.currentLineJoinType=n,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];const c=o&&o.progress.min>0,h=o&&o.progress.max<1;if(this.lineClips){let r={min:this.lineClips.start,max:this.lineClips.end},n=1;if(o){const e=this.lineClips.end-this.lineClips.start;r=function(e,t,r){return {min:ot(e.min,t,r),max:ot(e.max,t,r)}}(o.progress,{min:0,max:1},r),e>0&&(n=(r.max-r.min)/e);}const i=+t.properties.mapbox_clip_feature_len,s=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(i)||Number.isNaN(s)){for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);const t=this.totalDistance/(r.max-r.min);this.totalFeatureLength=Number.isFinite(t)?t:0,this.lineClips.start=r.min,this.lineClips.end=r.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance);}else this.totalFeatureLength=i,this.distance=s*n,this.lineClips.start=r.min,this.lineClips.end=r.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance();}const d="Polygon"===Hy[t.type];let p=e.length;for(;p>=2&&e[p-1].equals(e[p-2]);)p--;let f=0;for(;f<p-1&&e[f].equals(e[f+1]);)f++;if(p<(d?3:2))return;"bevel"===n&&(s=1.05);const m=this.segments.prepareSegment(10*p,this.layoutVertexArray,this.indexArray);let y,g,x,v,b,w,_,A;o&&o.prevDir&&(w=o.prevDir.perp()),o&&o.nextDir&&(_=o.nextDir.perp()),this.e1=this.e2=-1,d&&(y=e[p-2],b=e[f].sub(y)._unit()._perp());for(let t=f;t<p;t++){if(x=t===p-1?d?e[f+1]:void 0:e[t+1],x&&e[t].equals(x))continue;b&&(v=b),y&&(g=y),y=e[t],A=this.evaluateLineProgressFeatures(g?g.dist(y):0),b=x?x.sub(y)._unit()._perp():v,v=v||b;const r=g&&x;let o=r?n:d||u?"butt":i;const l=v.x*b.x+v.y*b.y;if(u){const e=function(e){if(e.patternJoinNone){const t=e.segmentPoints.length/2,r=e.lineSoFar-e.segmentStart;for(let n=0;n<t;++n){const t=e.segmentPoints[2*n+1],i=Math.round(e.segmentPoints[2*n])+.5+.25*t;e.patternVertexArray.emplaceBack(i,r,e.segmentStart),e.patternVertexArray.emplaceBack(i,r,e.segmentStart);}e.segmentPoints.length=0;}e.e1=e.e2=-1;};if(r&&l<Zy){this.updateDistance(g,y),this.addCurrentVertex(y,v,1,1,m,A),e(this),this.addCurrentVertex(y,b,-1,-1,m,A);continue}if(g){if(!x){this.updateDistance(g,y),this.addCurrentVertex(y,v,1,1,m,A),e(this);continue}o="miter";}}let I=v.add(b);0===I.x&&0===I.y||I._unit();const M=I.x*b.x+I.y*b.y,S=0!==M?1/M:1/0,B=2*Math.sqrt(2-2*M),P=M<Xy&&g&&x,T=v.x*b.y-v.y*b.x>0,z=this.overscaling<=16?122880/(512*this.overscaling):0;if(r&&"round"===o)if(S<a)o="miter";else if(S<=2){const e=Yy(y,-10,8202);o="offset"===this.elevationType&&(e||this.hasCrossSlope)?"miter":"fakeround";}if("miter"===o&&S>s&&(o="bevel"),"bevel"===o&&(S>2&&(o="flipbevel"),S<s&&(o="miter")),g&&!("miter"===o&&P)&&this.updateDistance(g,y),"miter"===o)if(P){const e=y.dist(g);if(e>2*z){const t=y.sub(y.sub(g)._mult(z/e)._round());this.updateDistance(g,t),this.addCurrentVertex(t,v,0,0,m,A),g=t;}this.updateDistance(g,y),I._mult(S),this.addCurrentVertex(y,I,0,0,m,A);const t=y.dist(x);if(t>2*z){const e=y.add(x.sub(y)._mult(z/t)._round());this.updateDistance(y,e),this.addCurrentVertex(e,b,0,0,m,A),y=e;}}else I._mult(S),this.addCurrentVertex(y,I,0,0,m,A);else if("flipbevel"===o){if(S>100)I=b.mult(-1);else {const e=S*v.add(b).mag()/v.sub(b).mag();I._perp()._mult(e*(T?-1:1));}this.addCurrentVertex(y,I,0,0,m,A),this.addCurrentVertex(y,I.mult(-1),0,0,m,A);}else if("bevel"===o||"fakeround"===o){const e=y.dist(g);let t=1;if("offset"===this.elevationType&&"bevel"===o&&"round"!==this.currentLineJoinType&&!this.patternJoinNone&&null!=A&&g&&x){const r=4*z;e<r&&(t=Math.max(0,e/r));}null!=A&&g&&this.addCurrentVertex(y,_||v,-t,-t,m,A);const r=e<=2*z&&"bevel"!==o,n=I.mult(T?1:-1);n._mult(S);const i=b.mult(T?-1:1),s=v.mult(T?-1:1),a=this.evaluateLineProgressFeatures(this.distance);if(null==A&&(this.addHalfVertex(y,n.x,n.y,!1,!T,0,m,a),r||this.addHalfVertex(y,n.x+2*s.x,n.y+2*s.y,!1,T,0,m,a)),"fakeround"===o){const e=Math.round(180*B/Math.PI/20);this.addHalfVertex(y,s.x,s.y,!1,T,0,m,a);for(let t=0;t<e;t++){let r=t/e;if(.5!==r){const e=r-.5;r+=r*e*(r-1)*((1.0904+l*(l*(3.55645-1.43519*l)-3.2452))*e*e+(.848013+l*(.215638*l-1.06021)));}const n=i.sub(s)._mult(r)._add(s)._unit();this.addHalfVertex(y,n.x,n.y,!1,T,0,m,a);}this.addHalfVertex(y,i.x,i.y,!1,T,0,m,a);}r||null!=A||this.addHalfVertex(y,n.x+2*i.x,n.y+2*i.y,!1,T,0,m,a),null!=A&&x&&this.addCurrentVertex(y,w||b,t,t,m,A);}else if("butt"===o)this.addCurrentVertex(y,I,0,0,m,A);else if("square"===o){if(!g){const e=c?0:-1;this.addCurrentVertex(y,I,e,e,m,A);}if(this.addCurrentVertex(y,I,0,0,m,A),g){const e=h?0:1;this.addCurrentVertex(y,I,e,e,m,A);}}else if("round"===o){if(g){const e=!r&&_?_:v;this.addCurrentVertex(y,e,0,0,m,A),!r&&h||this.addCurrentVertex(y,e,1,1,m,A,!0);}if(x){const e=!r&&w?w:b;!r&&c||this.addCurrentVertex(y,e,-1,-1,m,A,!0),this.addCurrentVertex(y,e,0,0,m,A);}}}}addVerticesTo(e,t,r,n,i,s,a,o,l,u){const c=(t.w-e.w)/this.tessellationStep|0;let h=0;const d=this.scaledDistance;if(c>1){this.lineSoFar=e.w;const r=(t.x-e.x)/c,n=(t.y-e.y)/c,i=(t.z-e.z)/c,s=(t.w-e.w)/c,a=t.x-e.x,o=t.y-e.y,d=Math.sqrt(a*a+o*o);if(0===d)return;const p=-o/d,f=a/d,m=p,y=f,g=-p,x=-f;for(let t=1;t<c;++t){e.x+=r,e.y+=n,e.z+=i,this.lineSoFar+=s,h+=s;const t=this.evaluateLineProgressFeatures(this.prevDistance+h);this.scaledDistance=(this.prevDistance+h)/this.totalDistance,this.addHalfVertex(e,m,y,u,!1,0,l,t),this.addHalfVertex(e,g,x,u,!0,0,l,t);}}this.lineSoFar=t.w,this.scaledDistance=d;const p=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(t,r,n,u,!1,a,l,p),this.addHalfVertex(t,i,s,u,!0,-o,l,p);}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&"offset"!==this.elevationType)return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+e)/this.totalFeatureLength):Ze(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let t=0;this.variableWidthValue&&"constant"!==this.variableWidthValue.kind&&(t=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);const r=this.evaluateElevationGroundScale();return "offset"!==this.elevationType?{zOffset:0,variableWidth:t,elevationGroundScale:r}:"constant"===this.zOffsetValue.kind?{zOffset:this.zOffsetValue.value,variableWidth:t,elevationGroundScale:r}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:t,elevationGroundScale:r}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?"constant"===this.elevationGroundScaleValue.kind?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(e,t,r,n,i,s,a=!1){const o=t.x+t.y*r,l=t.y-t.x*r,u=t.y*n-t.x,c=-t.y-t.x*n;if(null!=s){const t="offset"===this.elevationType,h="offset"===this.elevationType?2:10,d=-h,p=qn+h,f=s.zOffset,m=new Nf(e.x,e.y,f,this.lineSoFar),y=!!t&&Yy(e,d,p),g=this.lineSoFar,x=this.distance;if(this.currentVertex)if(y){const t=this.currentVertexIsOutside,s=this.currentVertex,h=new Nf(e.x,e.y,f,this.lineSoFar);if(Gf(s,h,d,p),!Yy(h,d,p)){if(t){this.e1=this.e2=-1,this.distance-=s.dist(m),this.lineSoFar=s.w;const e=this.evaluateLineProgressFeatures(s.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(s,o,l,a,!1,r,i,e),this.addHalfVertex(s,u,c,a,!0,-n,i,e),this.prevDistance=this.distance;}this.distance=this.prevDistance+s.dist(h),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(s,h,o,l,u,c,r,n,i,a),this.distance=x,this.scaledDistance=this.distance/this.totalDistance;}}else {const e=this.currentVertex;if(this.currentVertexIsOutside){Gf(e,m,d,p),this.e1=this.e2=-1,this.distance-=e.dist(m),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e.w;const t=this.evaluateLineProgressFeatures(e.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(e,o,l,a,!1,r,i,t),this.addHalfVertex(e,u,c,a,!0,-n,i,t),this.prevDistance=this.distance,this.distance=x,this.scaledDistance=this.distance/this.totalDistance;}this.addVerticesTo(e,m,o,l,u,c,r,n,i,a);}else y||(this.addHalfVertex(e,o,l,a,!1,r,i,s),this.addHalfVertex(e,u,c,a,!0,-n,i,s));this.currentVertex=m,this.currentVertexIsOutside=y,this.lineSoFar=g;}else this.addHalfVertex(e,o,l,a,!1,r,i,s),this.addHalfVertex(e,u,c,a,!0,-n,i,s);}addHalfVertex({x:e,y:t},r,n,i,s,a,o,l){if(this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),s||this.segmentPoints.push(this.lineSoFar-this.segmentStart,a)),this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(t<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){const e=yr(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,e);}const u=o.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),s?this.e2=u:this.e1=u,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth),this.elevationGroundScaleValue){const e=l?l.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(e);}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance;}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance();}}function Yy(e,t,r){return e.x<t||e.x>r||e.y<t||e.y>r}let Jy,Ky;function Qy(e,t,r){return t*(qn/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}ra(Wy,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const eg=(e,t,r)=>(1-r)*e+r*t;function tg(e,t){return 1/Qy(e,1,t.tileZoom)}function rg(e,t,r,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const ng=e=>{const t=[];ig(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT"),"multiply"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_MULTIPLY");const r=e.paint.get("line-trim-offset");0===r[0]&&0===r[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const n="none"===e.layout.get("line-join").constantOr("miter"),i=!!e.paint.get("line-pattern").constantOr(1);return n&&i&&t.push("LINE_JOIN_NONE"),t};function ig(e){const t=e.paint.get("line-dasharray").value;return "constant"!==t.kind||t.value}let sg;const ag=()=>sg||(sg={layout:Jy||(Jy=new fo({"line-cap":new ho(mo.layout_line["line-cap"]),"line-join":new ho(mo.layout_line["line-join"]),"line-miter-limit":new co(mo.layout_line["line-miter-limit"]),"line-round-limit":new co(mo.layout_line["line-round-limit"]),"line-sort-key":new ho(mo.layout_line["line-sort-key"]),"line-z-offset":new ho(mo.layout_line["line-z-offset"]),"line-elevation-reference":new co(mo.layout_line["line-elevation-reference"]),"line-cross-slope":new co(mo.layout_line["line-cross-slope"]),visibility:new co(mo.layout_line.visibility),"line-width-unit":new co(mo.layout_line["line-width-unit"]),"line-elevation-ground-scale":new ho(mo.layout_line["line-elevation-ground-scale"])})),paint:Ky||(Ky=new fo({"line-opacity":new ho(mo.paint_line["line-opacity"]),"line-color":new ho(mo.paint_line["line-color"]),"line-translate":new co(mo.paint_line["line-translate"]),"line-translate-anchor":new co(mo.paint_line["line-translate-anchor"]),"line-width":new ho(mo.paint_line["line-width"]),"line-gap-width":new ho(mo.paint_line["line-gap-width"]),"line-offset":new ho(mo.paint_line["line-offset"]),"line-blur":new ho(mo.paint_line["line-blur"]),"line-dasharray":new ho(mo.paint_line["line-dasharray"]),"line-pattern":new ho(mo.paint_line["line-pattern"]),"line-pattern-cross-fade":new co(mo.paint_line["line-pattern-cross-fade"]),"line-gradient":new po(mo.paint_line["line-gradient"]),"line-trim-offset":new co(mo.paint_line["line-trim-offset"]),"line-trim-fade-range":new co(mo.paint_line["line-trim-fade-range"]),"line-trim-color":new co(mo.paint_line["line-trim-color"]),"line-emissive-strength":new ho(mo.paint_line["line-emissive-strength"]),"line-border-width":new ho(mo.paint_line["line-border-width"]),"line-border-color":new ho(mo.paint_line["line-border-color"]),"line-occlusion-opacity":new co(mo.paint_line["line-occlusion-opacity"]),"line-blend-mode":new co(mo.paint_line["line-blend-mode"]),"line-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},sg);class og extends ho{possiblyEvaluate(e,t){return t=new to(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,n){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,r,n)}}let lg;function ug(e,t){return t>0?t+2*e:e}const cg=Ho([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),hg=Ho([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),dg=Ho([{name:"a_projected_pos",components:4,type:"Float32"}],4);Ho([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const pg=Ho([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),fg=Ho([{name:"a_feature_index",components:1,type:"Float32"}],4),mg=Ho([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),yg=Ho([{name:"a_texb",components:2,type:"Uint16"}]),gg=Ho([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),xg=Ho([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Ho([{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 vg=Ho([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),bg=Ho([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ho([{name:"triangle",components:3,type:"Uint16"}]),Ho([{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"}]),Ho([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),Ho([{type:"Float32",name:"offsetX"}]),Ho([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const wg=class e{constructor(t=null,r=0,n=4096){this.batchIndex=r,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=t||null,this.propsDwords=n,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array(e.HEADER_DWORDS),this.propertiesData=new Float32Array(this.propsDwords),this.blockIndicesData=new Uint32Array(this.propsDwords);for(let e=0;e<this.propsDwords;e++)this.blockIndicesData[e]=e;t&&this._initBuffers(t);}_initBuffers(t){const r=t.gl;if(this.totalBytes>t.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${t.maxUniformBlockSize}`);if(this.headerBuffer=r.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(r.bindBuffer(r.UNIFORM_BUFFER,this.headerBuffer),r.bufferData(r.UNIFORM_BUFFER,e.HEADER_BYTES,r.DYNAMIC_DRAW),this.propertiesBuffer=r.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(r.bindBuffer(r.UNIFORM_BUFFER,this.propertiesBuffer),r.bufferData(r.UNIFORM_BUFFER,this.totalBytes,r.DYNAMIC_DRAW),this.blockIndicesBuffer=r.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");r.bindBuffer(r.UNIFORM_BUFFER,this.blockIndicesBuffer),r.bufferData(r.UNIFORM_BUFFER,this.totalBytes,r.DYNAMIC_DRAW),r.bindBuffer(r.UNIFORM_BUFFER,null);}writeHeader(e){const t=this.headerData;t[0]=e.dataDrivenMask,t[1]=e.zoomDependentMask,t[2]=e.dataDrivenBlockSizeVec4,t[3]=e.offsets[0],t[4]=e.offsets[1],t[5]=e.offsets[2],t[6]=e.offsets[3],t[7]=e.offsets[4],t[8]=e.offsets[5],t[9]=e.offsets[6],t[10]=e.offsets[7],t[11]=e.offsets[8];}writeDataDrivenBlock(e,t,r){const n=4*r.dataDrivenBlockSizeVec4;if(0===n)return;const i=t*n;if(i+n>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${t} exceeds propertiesData capacity`);for(let t=0;t<9;t++)r.dataDrivenMask&1<<t&&null!=e[t]&&this._writeProperty(i+r.offsets[t],t,e[t],r.zoomDependentMask);}static getMaxFeatureCount(t,r=4096-e.HEADER_DWORDS){const n=4*t.dataDrivenBlockSizeVec4;return 0===n?1/0:Math.floor(r/n)}_writeProperty(e,t,r,n){const i=this.propertiesData,s=8===t,a=!!(n&1<<t);if(t<2){const t=r;i[e]=t[0],i[e+1]=t[1],i[e+2]=t[2],i[e+3]=t[3];}else if(s&&a){const t=r;i[e]=t[0],i[e+1]=t[1],i[e+2]=t[2],i[e+3]=t[3];}else if(s){const t=r;i[e]=t[0],i[e+1]=t[1];}else if(a){const t=r;i[e]=t[0],i[e+1]=t[1];}else i[e]=r;}upload(e){this.context||(this.context=e);const t=e.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(e),t.bindBuffer(t.UNIFORM_BUFFER,this.headerBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.headerData),t.bindBuffer(t.UNIFORM_BUFFER,this.propertiesBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.propertiesData),t.bindBuffer(t.UNIFORM_BUFFER,this.blockIndicesBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.blockIndicesData),t.bindBuffer(t.UNIFORM_BUFFER,null);}bind(e,t){const r=e.gl,n=(e,n,i)=>{if(!n)return;const s=r.getUniformBlockIndex(t,e);s!==r.INVALID_INDEX&&(r.uniformBlockBinding(t,s,i),r.bindBufferBase(r.UNIFORM_BUFFER,i,n));},i=3*this.batchIndex;n("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,i),n("SymbolPaintPropertiesUniform",this.propertiesBuffer,i+1),n("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,i+2);}destroy(){if(this.context){const e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null);}}};wg.HEADER_DWORDS=12,wg.HEADER_BYTES=48;let _g=wg;function Ag(e,t,r,n){return [Zl(255*e,255*t),Zl(255*r,255*n)]}function Ig(e,t,r,n,i,s,a,o){return !!e&&("constant"===e.kind?"none"===e.value:"composite"===e.kind||"source"===e.kind?"none"===e.evaluate({zoom:0,brightness:s,worldview:o},t,r,i,n,a):"string"==typeof e&&"none"===e)}ra(_g,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class Mg{constructor(e,t,r,n,i="",s,a){this.layer=e,this.zoom=t,this.lut=r,this.isText=n,this.propDefs=this._getPropDefs(),this.worldview=i,this.maxUniformBufferBindings=s||24,this.uboSizeDwords=a||4096,this.featureVertexRangesFromId=new Map,this.allFeatures=[],this.ubos=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex=new Map,this.canDeduplicate=this._checkIfAllPropertiesAreConstant(e,n),this.cachedParams=null,this.cachedParamsNext=null,this.cachedBrightness=void 0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=new Map;}_getPropDefs(){const e=this.isText?"text":"icon";return [{name:`${e}-color`,useThemeName:`${e}-color-use-theme`,isColor:!0},{name:`${e}-halo-color`,useThemeName:`${e}-halo-color-use-theme`,isColor:!0},{name:`${e}-opacity`,useThemeName:null,isColor:!1},{name:`${e}-halo-width`,useThemeName:null,isColor:!1},{name:`${e}-halo-blur`,useThemeName:null,isColor:!1},{name:`${e}-emissive-strength`,useThemeName:null,isColor:!1},{name:`${e}-occlusion-opacity`,useThemeName:null,isColor:!1},{name:"symbol-z-offset",useThemeName:null,isColor:!1},{name:`${e}-translate`,useThemeName:null,isColor:!1,isVec2:!0}]}buildHeader(){const e=this.layer.paint,t=this.propDefs;let r=0,n=0,i=0,s=0;const a=[0,0,0,0,0,0,0,0,0];for(let o=0;o<9;o++){const{name:l,isColor:u,isVec2:c}=t[o],h=e.get(l),d=!(!h||"function"!=typeof h.isConstant||h.isConstant()),p=this._appearancesHavePaintProperties(l),f=d||p,m=!(!h||!h.value||"composite"!==h.value.kind),y=this.layer._transitionablePaint._values[l],g=!f&&"camera"===(y&&y.value&&y.value.expression&&y.value.expression.kind);f?(r|=1<<o,m&&(n|=1<<o),u?(s%4!=0&&(s=s+3&-4),a[o]=s,s+=4):c?m?(s%4!=0&&(s=s+3&-4),a[o]=s,s+=4):(s%4==3&&s++,a[o]=s,s+=2):(a[o]=s,s+=m?2:1)):g&&(i|=1<<o);}return {dataDrivenMask:r,zoomDependentMask:n,cameraMask:i,dataDrivenBlockSizeVec4:(0===s?0:s+3&-4)/4,offsets:a}}get hasCameraExpression(){return !(!this.cachedHeader||!this.cachedHeader.cameraMask)}evaluateAllProperties(e,t,r,n,i,s,a){const{params:o,paramsNext:l}=this._getCachedParams(i),u={feature:e,featureState:t,canonical:r,availableImages:n,params:o,paramsNext:l,formattedSection:s},c=this.cachedHeader,h=this.propDefs,d=new Array(9).fill(null);for(let e=0;e<9;e++){const{name:t,useThemeName:r,isColor:n,isVec2:s}=h[e],o=!!(c&&c.zoomDependentMask&1<<e);d[e]=n?this._evaluateColorValue(t,r,u,i,o,a):s?this._evaluateTranslateValue(t,o,u,a):this._evaluateFloatValue(t,o,u,a);}return d}_evaluateColorValue(e,t,r,n,i,s){const a=this.layer.paint,o=e,l=s&&s.hasPaintProperty(o)?s.paintProperties.get(o):a.get(e),u=t,c=t&&s&&s.hasPaintProperty(u)?s.paintProperties.get(u):t?a.get(t):void 0;if(!l)return [0,0,0,1];const h=Ig(c&&"string"!=typeof c?c.value:void 0,r.feature,r.featureState,r.availableImages,r.canonical,n,r.formattedSection,this.worldview)?null:this.lut;let d,p;l.isConstant()?d=p=l.constantOr(dr.transparent):(d=l.property.evaluate(l.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,l.iconImageUseTheme,r.formattedSection),p=i?l.property.evaluate(l.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,l.iconImageUseTheme,r.formattedSection):d);const f=(d||dr.transparent).toNonPremultipliedRenderColor(h),m=(p||dr.transparent).toNonPremultipliedRenderColor(h);if(i){const[e,t]=Ag(f.r,f.g,f.b,f.a),[r,n]=Ag(m.r,m.g,m.b,m.a);return [e,t,r,n]}const[y,g]=Ag(f.r,f.g,f.b,f.a);return [y,g,0,0]}_evaluateFloatValue(e,t,r,n){const i=this.layer.paint,s=e.endsWith("opacity")?1:0,a=e,o=n&&n.hasPaintProperty(a)?n.paintProperties.get(a):i.get(e);if(!o)return s;if(o.isConstant())return o.constantOr(s);const l=o.property.evaluate(o.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,o.iconImageUseTheme,r.formattedSection),u=null!=l?l:s;if(t){const e=o.property.evaluate(o.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,o.iconImageUseTheme,r.formattedSection);return [u,null!=e?e:s]}return u}_evaluateTranslateValue(e,t,r,n){const i=this.layer.paint,s=e,a=n&&n.hasPaintProperty(s)?n.paintProperties.get(s):i.get(e);if(!a)return [0,0];if("function"!=typeof a.isConstant)return a||[0,0];if(a.isConstant())return a.constantOr([0,0]);const o=a.property.evaluate(a.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,a.iconImageUseTheme,r.formattedSection)||[0,0];if(t){const e=a.property.evaluate(a.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,a.iconImageUseTheme,r.formattedSection)||[0,0];return [o[0],o[1],e[0],e[1]]}return o}_getCachedParams(e){return this.cachedParams&&this.cachedParamsNext&&this.cachedBrightness===e||(this.cachedParams=new to(this.zoom,{brightness:e,worldview:this.worldview}),this.cachedParamsNext=new to(this.zoom+1,{brightness:e,worldview:this.worldview}),this.cachedBrightness=e),{params:this.cachedParams,paramsNext:this.cachedParamsNext}}_appearancesHavePaintProperties(e){return this.layer.getAppearances().some(void 0!==e?t=>t.hasPaintProperty(e):this.isText?e=>e.hasTextPaintProperties():e=>e.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(e,t){const r=e.paint,n=t?"text":"icon",i=[`${n}-color`,`${n}-halo-color`,`${n}-opacity`,`${n}-halo-width`,`${n}-halo-blur`,`${n}-emissive-strength`,`${n}-occlusion-opacity`,"symbol-z-offset",`${n}-translate`];for(const e of i){const t=r.get(e);if(t&&"object"==typeof t&&"isConstant"in t&&!t.isConstant())return !1}return !this._appearancesHavePaintProperties()}_hashDataDrivenValues(e,t){if(0===t.dataDrivenMask)return "";const r=[];for(let n=0;n<9;n++){if(!(t.dataDrivenMask&1<<n))continue;const i=e[n];null==i?r.push("null"):Array.isArray(i)?r.push(i.join(",")):r.push(String(i));}return r.join("|")}getCurrentBatchIndex(){return this.cachedHeader&&0!==this.maxFeaturesPerBatch?Math.floor(this.featureCount/this.maxFeaturesPerBatch):0}populateUBO(e,t,r,n,i,s,a){const o=e.id;if(!this.cachedHeader){this.cachedHeader=this.buildHeader();const e=_g.getMaxFeatureCount(this.cachedHeader,this.uboSizeDwords);this.maxFeaturesPerBatch=isFinite(e)?e:Number.MAX_SAFE_INTEGER;}const l=this.cachedHeader,u=this.evaluateAllProperties(e,{},r,n,i,s);if(this.canDeduplicate){const e=this._hashDataDrivenValues(u,l),r=this.propertyHashToUBOIndex.get(e);if(void 0!==r){const e=isFinite(this.maxFeaturesPerBatch)?Math.floor(r/this.maxFeaturesPerBatch):0,n=isFinite(this.maxFeaturesPerBatch)?r%this.maxFeaturesPerBatch:r,i={batchIndex:e,localFeatureIndex:n,vtFeatureIndex:t,featureId:o};return this.allFeatures.push(i),null!=o&&(this.featureVertexRangesFromId.has(o)||this.featureVertexRangesFromId.set(o,[]),this.featureVertexRangesFromId.get(o).push(i)),n}this.propertyHashToUBOIndex.set(e,this.featureCount);}const c=this.featureCount++,h=isFinite(this.maxFeaturesPerBatch)?Math.floor(c/this.maxFeaturesPerBatch):0,d=isFinite(this.maxFeaturesPerBatch)?c%this.maxFeaturesPerBatch:c,p=a?a.maxUniformBufferBindings:this.maxUniformBufferBindings;if(3*h+2>=p){Ze(`Too many symbol features: batch ${h} requires binding points up to ${3*h+2}, device limit ${p}. Some features will render incorrectly.`);const e={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:t,featureId:o};return this.allFeatures.push(e),null!=o&&(this.featureVertexRangesFromId.has(o)||this.featureVertexRangesFromId.set(o,[]),this.featureVertexRangesFromId.get(o).push(e)),0}this.ubos[h]||(this.ubos[h]=new _g(a,h,this.uboSizeDwords),this.ubos[h].writeHeader(l)),this.ubos[h].writeDataDrivenBlock(u,d,l);const f={batchIndex:h,localFeatureIndex:d,vtFeatureIndex:t,featureId:o};return this.allFeatures.push(f),null!=o&&(this.featureVertexRangesFromId.has(o)||this.featureVertexRangesFromId.set(o,[]),this.featureVertexRangesFromId.get(o).push(f)),d}updateFeatures(e,t,r,n,i,s,a){if(this.layer=t,this.cachedConstantUniforms=null,!this.cachedHeader)return;const o=this.cachedHeader;for(const t of e){const e=this.featureVertexRangesFromId.get(t);if(!e)continue;const l=s[t]||{};for(const s of e){if(!r)continue;const e=r.feature(s.vtFeatureIndex);if(!e)continue;const u={type:e.type,id:t,properties:e.properties||{},geometry:[]},c=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(s.vtFeatureIndex):void 0,h=this.evaluateAllProperties(u,l,n,i,a,void 0,c);this.ubos[s.batchIndex]&&this.ubos[s.batchIndex].writeDataDrivenBlock(h,s.localFeatureIndex,o);}}}updateDynamicExpressions(e,t,r,n,i,s){if(this.layer=e,this.cachedConstantUniforms=null,!this.cachedHeader)return;const a=this.cachedHeader;for(const e of this.allFeatures){if(!t)continue;const o=t.feature(e.vtFeatureIndex);if(!o)continue;const l=null!=e.featureId&&i[e.featureId]||{},u={type:o.type,id:e.featureId,properties:o.properties||{},geometry:[]},c=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(e.vtFeatureIndex):void 0,h=this.evaluateAllProperties(u,l,r,n,s,void 0,c);this.ubos[e.batchIndex]&&this.ubos[e.batchIndex].writeDataDrivenBlock(h,e.localFeatureIndex,a);}}updateFeaturePaintForAppearance(e,t,r,n,i,s,a){if(!this.layer)return !1;if(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(e,a||null),!this.cachedHeader)return !1;const o=this.cachedHeader;if(0===o.dataDrivenMask)return !1;let l=!1;for(const u of this.allFeatures){if(u.vtFeatureIndex!==e)continue;const c=this.evaluateAllProperties(t,r,n,i,s,void 0,a);this.ubos[u.batchIndex]&&(this.ubos[u.batchIndex].writeDataDrivenBlock(c,u.localFeatureIndex,o),l=!0);}return l}getConstantUniformValues(e,t){const r=this.cachedHeader,n=!(!r||!r.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===t&&(!n||this.cachedConstantRenderZoom===e))return this.cachedConstantUniforms;const i=this.layer.paint,s=this.propDefs,a=n?new to(e,{brightness:t,worldview:this.worldview}):null,o={type:1,id:void 0,properties:{},geometry:[]},l=e=>{const n=s[e],l=i.get(n.name);if(!l)return [0,0,0,1];const u=n.useThemeName?i.get(n.useThemeName):void 0,c=Ig(u&&"string"!=typeof u?u.value:void 0,o,{},[],void 0,t,void 0,this.worldview)?null:this.lut;let h;h=r&&r.cameraMask&1<<e&&a?l.property.evaluate(l.value,a,o,{},void 0,[]):l.constantOr(dr.transparent);const d=(h||dr.transparent).toNonPremultipliedRenderColor(c);return [d.r,d.g,d.b,d.a]},u=(e,t)=>{const n=i.get(s[e].name);if(!n)return t;if(r&&r.cameraMask&1<<e&&a){const e=n.property.evaluate(n.value,a,o,{},void 0,[]);return null!=e?e:t}return n.constantOr(t)},c={fill_np_color:l(0),halo_np_color:l(1),opacity:u(2,1),halo_width:u(3,0),halo_blur:u(4,0),emissive_strength:u(5,0),occlusion_opacity:u(6,1),z_offset:u(7,0)};return this.cachedConstantUniforms=c,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=t,c}upload(e){for(const t of this.ubos)t.upload(e);}bind(e,t,r=0){this.ubos[r]&&this.ubos[r].bind(e,t);}destroy(){for(const e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId.clear(),this.allFeatures=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex&&this.propertyHashToUBOIndex.clear();}}ra(Mg,"SymbolPropertyBinderUBO",{omit:["layer","cachedParams","cachedParamsNext","cachedBrightness","propertyHashToUBOIndex","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","activeAppearanceByVtIndex"]});var Sg=24;function Bg(e,t,r){return e.sections.forEach(e=>{e.text=function(e,t,r){const n=t.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Qa.applyArabicShaping&&(e=Qa.applyArabicShaping(e)),e}(e.text,t,r);}),e}const Pg={"!":"︕","#":"＃",$:"＄","%":"％","&":"＆","(":"︵",")":"︶","*":"＊","+":"＋",",":"︐","-":"︲",".":"・","/":"／",":":"︓",";":"︔","<":"︿","=":"＝",">":"﹀","?":"︖","@":"＠","[":"﹇","\\":"＼","]":"﹈","^":"＾",_:"︳","`":"｀","{":"︷","|":"―","}":"︸","~":"～","¢":"￠","£":"￡","¥":"￥","¦":"￤","¬":"￢","¯":"￣","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"￦","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","！":"︕","（":"︵","）":"︶","，":"︐","－":"︲","．":"・","：":"︓","；":"︔","＜":"︿","＞":"﹀","？":"︖","［":"﹇","］":"﹈","＿":"︳","｛":"︷","｜":"―","｝":"︸","｟":"︵","｠":"︶","｡":"︒","｢":"﹁","｣":"﹂","←":"↑","→":"↓"};function Tg(e){return "︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"｀"===e||"￣"===e||"︑"===e||"︒"===e}function zg(e){return "︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const kg=4294967296,Fg=1/kg,Vg="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let Dg=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length;}readFields(e,t,r=this.length){for(;this.pos<r;){const r=this.readVarint(),n=r>>3,i=this.pos;this.type=7&r,e(n,t,this),this.pos===i&&this.skip(r);}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*kg;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*kg;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let r,n;return n=t[this.pos++],r=127&n,n<128?r:(n=t[this.pos++],r|=(127&n)<<7,n<128?r:(n=t[this.pos++],r|=(127&n)<<14,n<128?r:(n=t[this.pos++],r|=(127&n)<<21,n<128?r:(n=t[this.pos],r|=(15&n)<<28,function(e,t,r){const n=r.buf;let i,s;if(s=n[r.pos++],i=(112&s)>>4,s<128)return Eg(e,i,t);if(s=n[r.pos++],i|=(127&s)<<3,s<128)return Eg(e,i,t);if(s=n[r.pos++],i|=(127&s)<<10,s<128)return Eg(e,i,t);if(s=n[r.pos++],i|=(127&s)<<17,s<128)return Eg(e,i,t);if(s=n[r.pos++],i|=(127&s)<<24,s<128)return Eg(e,i,t);if(s=n[r.pos++],i|=(1&s)<<31,s<128)return Eg(e,i,t);throw new Error("Expected varint not more than 10 bytes")}(r,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Vg?Vg.decode(this.buf.subarray(t,e)):function(e,t,r){let n="",i=t;for(;i<r;){const t=e[i];let s,a,o,l=null,u=t>239?4:t>223?3:t>191?2:1;if(i+u>r)break;1===u?t<128&&(l=t):2===u?(s=e[i+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===u?(s=e[i+1],a=e[i+2],128==(192&s)&&128==(192&a)&&(l=(15&t)<<12|(63&s)<<6|63&a,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(s=e[i+1],a=e[i+2],o=e[i+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&(l=(15&t)<<18|(63&s)<<12|(63&a)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),i+=u;}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const r=this.readPackedEnd();for(;this.pos<r;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(e){const t=7&e;if(0===t)for(;this.buf[this.pos++]>127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else {if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8;}}writeTag(e,t){this.writeVarint(e<<3|t);}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){const e=new Uint8Array(t);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=t;}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4;}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4;}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Fg),!0),this.pos+=8;}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Fg),!0),this.pos+=8;}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let r,n;if(e>=0?(r=e%4294967296|0,n=e/4294967296|0):(r=~(-e%4294967296),n=~(-e/4294967296),4294967295^r?r=r+1|0:(r=0,n=n+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,r.buf[r.pos]=127&(e>>>=7);}(r,0,t),function(e,t){const r=(7&e)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))));}(n,t);}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))));}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e);}writeBoolean(e){this.writeVarint(+e);}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,r){for(let n,i,s=0;s<t.length;s++){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){n>56319||s+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):i=n;continue}if(n<56320){e[r++]=239,e[r++]=191,e[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(e[r++]=239,e[r++]=191,e[r++]=189,i=null);n<128?e[r++]=n:(n<2048?e[r++]=n>>6|192:(n<65536?e[r++]=n>>12|224:(e[r++]=n>>18|240,e[r++]=n>>12&63|128),e[r++]=n>>6&63|128),e[r++]=63&n|128);}return r}(this.buf,e,this.pos);const r=this.pos-t;r>=128&&Cg(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r;}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4;}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8;}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let r=0;r<t;r++)this.buf[this.pos++]=e[r];}writeRawMessage(e,t){this.pos++;const r=this.pos;e(t,this);const n=this.pos-r;n>=128&&Cg(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;}writeMessage(e,t,r){this.writeTag(e,2),this.writeRawMessage(t,r);}writePackedVarint(e,t){t.length&&this.writeMessage(e,Rg,t);}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Lg,t);}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Ng,t);}writePackedFloat(e,t){t.length&&this.writeMessage(e,Og,t);}writePackedDouble(e,t){t.length&&this.writeMessage(e,Ug,t);}writePackedFixed32(e,t){t.length&&this.writeMessage(e,jg,t);}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Gg,t);}writePackedFixed64(e,t){t.length&&this.writeMessage(e,$g,t);}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,qg,t);}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t);}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t);}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t);}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t);}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t);}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t);}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t);}writeStringField(e,t){this.writeTag(e,2),this.writeString(t);}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t);}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t);}writeBooleanField(e,t){this.writeVarintField(e,+t);}};function Eg(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Cg(e,t,r){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(n);for(let t=r.pos-1;t>=e;t--)r.buf[t+n]=r.buf[t];}function Rg(e,t){for(let r=0;r<e.length;r++)t.writeVarint(e[r]);}function Lg(e,t){for(let r=0;r<e.length;r++)t.writeSVarint(e[r]);}function Og(e,t){for(let r=0;r<e.length;r++)t.writeFloat(e[r]);}function Ug(e,t){for(let r=0;r<e.length;r++)t.writeDouble(e[r]);}function Ng(e,t){for(let r=0;r<e.length;r++)t.writeBoolean(e[r]);}function jg(e,t){for(let r=0;r<e.length;r++)t.writeFixed32(e[r]);}function Gg(e,t){for(let r=0;r<e.length;r++)t.writeSFixed32(e[r]);}function $g(e,t){for(let r=0;r<e.length;r++)t.writeFixed64(e[r]);}function qg(e,t){for(let r=0;r<e.length;r++)t.writeSFixed64(e[r]);}function Hg(e,t,r){t.glyphs=[],1===e&&r.readMessage(Xg,t);}function Xg(e,t,r){if(3===e){const{id:e,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(Zg,{});t.glyphs.push({id:e,bitmap:new ed({width:i+6,height:s+6},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}else 4===e?t.ascender=r.readSVarint():5===e&&(t.descender=r.readSVarint());}function Zg(e,t,r){1===e?t.id=r.readVarint():2===e?t.bitmap=r.readBytes():3===e?t.width=r.readVarint():4===e?t.height=r.readVarint():5===e?t.left=r.readSVarint():6===e?t.top=r.readSVarint():7===e&&(t.advance=r.readVarint());}const Wg={horizontal:1,vertical:2,horizontalOnly:3};class Yg{constructor(){this.scale=1,this.fontStack="",this.image=null;}static forText(e,t){const r=new Yg;return r.scale=e||1,r.fontStack=t,r}static forImage(e){const t=new Yg;return t.image=e,t}}class Jg{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(e,t,r,n=1){const i=new Jg;for(let s=0;s<e.sections.length;s++){const a=e.sections[s];a.image?i.addImageSection(a,r,n):i.addTextSection(a,t);}return i}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=function(e,t){let r="";for(let n=0;n<e.length;n++){const i=e.charCodeAt(n+1)||null,s=e.charCodeAt(n-1)||null;r+=!t&&(i&&Oa(i)&&!Pg[e[n+1]]||s&&Oa(s)&&!Pg[e[n-1]])||!Pg[e[n]]?e[n]:Pg[e[n]];}return r}(this.text,e);}trim(){let e=0;for(let t=0;t<this.text.length&&Qg[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let r=this.text.length-1;r>=0&&r>=e&&Qg[this.text.charCodeAt(r)];r--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t);}substring(e,t){const r=new Jg;return r.text=this.text.substring(e,t),r.sectionIndex=this.sectionIndex.slice(e,t),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Yg.forText(e.scale,e.fontStack||t));const r=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(r);}addImageSection(e,t,r=1){const n=e.image?e.image.getPrimary():null;if(!n)return void Ze("Can't add FormattedSection with an empty image.");n.scaleSelf(t*r);const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCodePoint(i),this.sections.push(Yg.forImage(n)),this.sectionIndex.push(this.sections.length-1)):Ze("Reached maximum number of images 6401");}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kg(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m=1,y=1){const g=Jg.fromFeature(e,i,m,y);h===Wg.vertical&&g.verticalizePunctuation(d);let x=[];const v=function(e,t,r,n,i,s,a=1){if(!e)return [];const o=[],l=function(e,t,r,n,i,s,a=1){let o=0;for(let r=0;r<e.length();r++){const l=e.getSection(r);o+=tx(e.getCodePoint(r),l,n,i,t,s,a);}return o/Math.max(1,Math.ceil(o/r))}(e,t,r,n,i,s,a),u=e.text.indexOf("​")>=0;let c=0;for(let r=0;r<e.length();r++){const h=e.getSection(r),d=e.getCodePoint(r);if(Qg[d]||(c+=tx(d,h,n,i,t,s,a)),r<e.length()-1){const t=Ca(d);(ex[d]||t||h.image)&&o.push(ix(r+1,c,l,o,nx(d,e.getCodePoint(r+1),t&&u),!1));}}return sx(ix(e.length(),c,l,o,0,!0))}(g,u,s,t,n,p,y),{processBidirectionalText:b,processStyledBidirectionalText:w}=Qa;if(b&&1===g.sections.length){const e=b(g.toString(),v);for(const t of e){const e=new Jg;e.text=t,e.sections=g.sections;for(let r=0;r<t.length;r++)e.sectionIndex.push(0);x.push(e);}}else if(w){const e=w(g.text,g.sectionIndex,v);for(const t of e){const e=new Jg;e.text=t[0],e.sectionIndex=t[1],e.sections=g.sections,x.push(e);}}else x=function(e,t){const r=[],n=e.text;let i=0;for(const n of t)r.push(e.substring(i,n)),i=n;return i<n.length&&r.push(e.substring(i,n.length)),r}(g,v);const _=[],A={positionedLines:_,text:g.toString(),top:c[1],bottom:c[1],left:c[0],right:c[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(e,t,r,n,i,s,a,o,l,u,c,h,d=1){let p=0,f=0,m=0;const y="right"===o?1:"left"===o?0:.5;let g=!1;for(const e of i){const r=e.getSections();for(const e of r){if(e.image)continue;const r=t[e.fontStack];if(r&&(g=void 0!==r.ascender&&void 0!==r.descender,!g))break}if(!g)break}let x=0;for(const a of i){a.trim();const i=a.getMaxScale(),o=(i-1)*Sg,v={positionedGlyphs:[],lineOffset:0};e.positionedLines[x]=v;const b=v.positionedGlyphs;let w=0;if(!a.length()){f+=s,++x;continue}let _=0,A=0;for(let s=0;s<a.length();s++){const o=a.getSection(s),m=a.getSectionIndex(s),y=a.getCodePoint(s);let x=o.scale,v=null,I=null,M=null,S=Sg,B=0,P=l;P===Wg.vertical&&La(y)&&(P=Wg.horizontal);const T=!(P===Wg.horizontal||!c&&!Ra(y)||c&&(Qg[y]||Ua(y)));if(o.image){const t=n.get(o.image.toString());if(!t)continue;M=o.image,e.iconsInText=e.iconsInText||!0,I=t.paddedRect;const r=t.displaySize,s=r[0]*d,a=r[1]*d;x=x*Sg/h,v={width:s,height:a,left:0,top:-3,advance:T?a:s,localGlyph:!1},B=g?-v.height*x:i*Sg-17-a*x,S=v.advance;const l=(T?s:a)*x-Sg*i;l>0&&l>w&&(w=l);}else {const e=r[o.fontStack];if(!e)continue;e[y]&&(I=e[y]);const n=t[o.fontStack];if(!n)continue;const s=n.glyphs[y];if(!s)continue;if(v=s.metrics,S=8203!==y?Sg:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,r=(e+t)*x;_<r&&(_=r,A=(e-t)/2*x),B=-e*x;}else B=(i-x)*Sg-17;}T?(e.verticalizable=!0,b.push({glyph:y,image:M,x:p,y:f+B,vertical:T,scale:x,localGlyph:v.localGlyph,fontStack:o.fontStack,sectionIndex:m,metrics:v,rect:I}),p+=S*x+u):(b.push({glyph:y,image:M,x:p,y:f+B,vertical:T,scale:x,localGlyph:v.localGlyph,fontStack:o.fontStack,sectionIndex:m,metrics:v,rect:I}),p+=v.advance*x+u);}0!==b.length&&(m=Math.max(p-u,m),g?ox(b,y,w,A,s*i/2):ox(b,y,w,0,s/2)),p=0;const I=s*i+w;v.lineOffset=Math.max(w,o),f+=I,++x;}const v=f,{horizontalAlign:b,verticalAlign:w}=ax(a);((function(e,t,r,n,i,s){const a=(t-r)*i,o=-s*n;for(const t of e)for(const e of t.positionedGlyphs)e.x+=a,e.y+=o;}))(e.positionedLines,y,b,w,m,v),e.top+=-w*v,e.bottom=e.top+v,e.left+=-b*m,e.right=e.left+m,e.hasBaseline=g;}(A,t,r,n,x,a,o,l,h,u,d,f,y),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return !1;return !0}(_))return A}const Qg={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},ex={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 tx(e,t,r,n,i,s,a=1){if(t.image){const e=n.get(t.image.toString());return e?e.displaySize[0]*a*t.scale*Sg/s+i:0}{const n=r[t.fontStack],s=n&&n.glyphs[e];return s?s.metrics.advance*t.scale+i:0}}function rx(e,t,r,n){const i=Math.pow(e-t,2);return n?e<t?i/2:2*i:i+Math.abs(r)*r}function nx(e,t,r){let n=0;return 10===e&&(n-=1e4),r&&(n+=150),40!==e&&65288!==e||(n+=50),41!==t&&65289!==t||(n+=50),n}function ix(e,t,r,n,i,s){let a=null,o=rx(t,r,i,s);for(const e of n){const n=rx(t-e.x,r,i,s)+e.badness;n<=o&&(a=e,o=n);}return {index:e,x:t,priorBreak:a,badness:o}}function sx(e){return e?sx(e.priorBreak).concat(e.index):[]}function ax(e){let t=.5,r=.5;switch(e){case "right":case "top-right":case "bottom-right":t=1;break;case "left":case "top-left":case "bottom-left":t=0;}switch(e){case "bottom":case "bottom-right":case "bottom-left":r=1;break;case "top":case "top-right":case "top-left":r=0;}return {horizontalAlign:t,verticalAlign:r}}function ox(e,t,r,n,i){if(!(t||r||n||i))return;const s=e.length-1,a=e[s],o=(a.x+a.metrics.advance*a.scale)*t;for(let t=0;t<=s;t++)e[t].x-=o,e[t].y+=r+n+i;}function lx(e){return void 0!==e.imagePrimary&&void 0!==e.top&&void 0!==e.bottom&&void 0!==e.left&&void 0!==e.right}function ux(e,t,r,n){const{horizontalAlign:i,verticalAlign:s}=ax(n),a=r[0]-e.displaySize[0]*i,o=r[1]-e.displaySize[1]*s;return {imagePrimary:e,imageSecondary:t,top:o,bottom:o+e.displaySize[1],left:a,right:a+e.displaySize[0]}}function cx(e,t,r,n,i,s){const a=e.imagePrimary;let o;if(a.content){const e=a.content,t=a.pixelRatio||1;o=[e[0]/t,e[1]/t,a.displaySize[0]-e[2]/t,a.displaySize[1]-e[3]/t];}const l=t.left*s,u=t.right*s;let c,h,d,p;"width"===r||"both"===r?(p=i[0]+l-n[3],h=i[0]+u+n[1]):(p=i[0]+(l+u-a.displaySize[0])/2,h=p+a.displaySize[0]);const f=t.top*s,m=t.bottom*s;return "height"===r||"both"===r?(c=i[1]+f-n[0],d=i[1]+m+n[2]):(c=i[1]+(f+m-a.displaySize[1])/2,d=c+a.displaySize[1]),{imagePrimary:a,imageSecondary:void 0,top:c,right:h,bottom:d,left:p,collisionPadding:o}}function hx(e){return !e.imagePrimary.stretchX}function dx(e){return !e.imagePrimary.stretchY}function px(e){return {width:e.right-e.left,height:e.bottom-e.top}}const fx=128;function mx(e,t,r,n){const{expression:i}=t;if("constant"===i.kind)return {kind:"constant",layoutSize:i.evaluate(new to(e+1,{worldview:r}),void 0,void 0,void 0,n)};if("source"===i.kind)return {kind:"source"};{const{zoomStops:t,interpolationType:s}=i;let a=0;for(;a<t.length&&t[a]<=e;)a++;a=Math.max(0,a-1);let o=a;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const l=t[a],u=t[o];return "composite"===i.kind?{kind:"composite",minZoom:l,maxZoom:u,interpolationType:s}:{kind:"camera",minZoom:l,maxZoom:u,minSize:i.evaluate(new to(l,{worldview:r}),void 0,void 0,void 0,n),maxSize:i.evaluate(new to(u,{worldview:r}),void 0,void 0,void 0,n),interpolationType:s}}}function yx(e,{uSize:t,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===e.kind?n/fx:"composite"===e.kind?yr(n/fx,i/fx,r):t}function gx(e,t,r=1){let n=0,i=0;if("constant"===e.kind)i=e.layoutSize*r;else if("source"!==e.kind){const{interpolationType:s,minZoom:a,maxZoom:o}=e,l=s?Ee(Yi.interpolationFactor(s,t,a,o),0,1):0;"camera"===e.kind?i=yr(e.minSize,e.maxSize,l)*r:n=l*r;}return {uSizeT:n,uSize:i}}class xx extends Me{constructor(e,t,r,n,i){super(e,t),this.angle=n,this.z=r,void 0!==i&&(this.segment=i);}clone(){return new xx(this.x,this.y,this.z,this.angle,this.segment)}}function vx(e,t,r,n,i){if(void 0===t.segment)return !0;let s=t,a=t.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=e[a].dist(s),s=e[a];}o+=e[a].dist(e[a+1]),a++;const l=[];let u=0;for(;o<r/2;){const t=e[a],r=e[a+1];if(!r)return !1;let s=e[a-1].angleTo(t)-t.angleTo(r);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:o,angleDelta:s}),u+=s;o-l[0].distance>n;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=t.dist(r);}return !0}function bx(e){let t=0;for(let r=0;r<e.length-1;r++)t+=e[r].dist(e[r+1]);return t}function wx(e,t,r){return e?.6*t*r:0}function _x(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function Ax(e,t,r,n,i,s){const a=wx(r,i,s),o=_x(r,n)*s;let l=0;const u=bx(e)/2;for(let r=0;r<e.length-1;r++){const n=e[r],i=e[r+1],s=n.dist(i);if(l+s>u){const c=(u-l)/s,h=yr(n.x,i.x,c),d=yr(n.y,i.y,c),p=new xx(h,d,0,i.angleTo(n),r);return !a||vx(e,p,o,a,t)?p:void 0}l+=s;}}function Ix(e,t,r,n,i,s,a,o,l){const u=wx(n,s,a),c=_x(n,i),h=c*a,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h<t/4&&(t=h+t/4),Mx(e,d?t/2*o%t:(c/2+2*s)*a*o%t,t,u,r,h,d,!1,l)}function Mx(e,t,r,n,i,s,a,o,l){const u=s/2,c=bx(e);let h=0,d=t-r,p=[];for(let t=0;t<e.length-1;t++){const a=e[t],o=e[t+1],f=a.dist(o),m=o.angleTo(a);for(;d+r<h+f;){d+=r;const y=(d-h)/f,g=yr(a.x,o.x,y),x=yr(a.y,o.y,y);if(g>=0&&g<l&&x>=0&&x<l&&d-u>=0&&d+u<=c){const r=new xx(g,x,0,m,t);n&&!vx(e,r,s,n,i)||p.push(r);}}h+=f;}return o||p.length||a||(p=Mx(e,h/2,r,n,i,s,a,!0,l)),p}function Sx(e){let t=0,r=0;for(const n of e)t+=n.w*n.h,r=Math.max(r,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let i=0,s=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const r=n[e];if(!(t.w>r.w||t.h>r.h)){if(t.x=r.x,t.y=r.y,s=Math.max(s,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===r.w&&t.h===r.h){const t=n.pop();t&&e<n.length&&(n[e]=t);}else t.h===r.h?(r.x+=t.w,r.w-=t.w):t.w===r.w?(r.y+=t.h,r.h-=t.h):(n.push({x:r.x+t.w,y:r.y,w:r.w-t.w,h:t.h}),r.y+=t.h,r.h-=t.h);break}}return {w:i,h:s,fill:t/(i*s)||0}}function Bx(e,t){return e.id<t.id?-1:e.id>t.id?1:e.version<t.version?-1:e.version>t.version?1:e.sx<t.sx?-1:e.sx>t.sx?1:e.sy<t.sy?-1:e.sy>t.sy?1:0}function Px(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return t}function Tx(e,t){return (e<<5)-e+t}function zx(e,t,r,n){for(const[i]of e.entries()){const e=n&&n.get(i)||Nr.parse(i),s=e.id.toString(),a=t.get(s)||0;r.push({id:i,version:a,sx:e.sx,sy:e.sy});}}ra(xx,"Anchor");class kx{constructor(e,t,r,n,i){this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=t.size>0,zx(e,r,this.iconDescriptors,i),zx(t,r,this.patternDescriptors,i),this.iconDescriptors.sort(Bx),this.patternDescriptors.sort(Bx);let s=0;const a=n?n.data:"";a&&(s=Tx(s,Px(a))),s=Tx(s,1);for(const e of this.iconDescriptors)s=Tx(s,Px(e.id)),s=Tx(s,e.version),s=Tx(s,e.sx),s=Tx(s,e.sy);s=Tx(s,1);for(const e of this.patternDescriptors)s=Tx(s,Px(e.id)),s=Tx(s,e.version),s=Tx(s,e.sx),s=Tx(s,e.sy);this.hash=s;}subsetOf(e){return this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,Bx)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,Bx)}isSubsetArray(e,t,r){let n=0,i=0;if(e.length>t.length)return !1;for(;n<e.length&&i<t.length;){const s=r(e[n],t[i]);if(0===s)n++,i++;else {if(s<0)return !1;i++;}}return n===e.length}}ra(kx,"AtlasContentDescriptor");class Fx{static getImagePositionScale(e,t,r){if(t&&e){const{sx:t,sy:r}=e;return {x:t,y:r}}return {x:r,y:r}}constructor(e,t,r,n){this.paddedRect=e;const{pixelRatio:i,version:s,stretchX:a,stretchY:o,content:l,sdf:u,usvg:c}=t;this.pixelRatio=i,this.stretchX=a,this.stretchY=o,this.content=l,this.version=s,this.padding=r,this.sdf=u,this.usvg=c,this.scale=Fx.getImagePositionScale(n,c,i);}get tl(){return [this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return [this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return [(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function Vx(e,t,r){const n=Nr.parse(e),i=function(e,t,r=[1,1]){return {x:0,y:0,w:(e.data?e.data.width:e.width*r[0])+2*t,h:(e.data?e.data.height:e.height*r[1])+2*t}}(t,r,[n.sx,n.sy]);return {bin:i,imagePosition:new Fx(i,t,r,n),imageVariant:n}}function Dx(e,t){const r=[];for(const[n,i]of e.entries()){const e=Nr.parse(n);e&&(r.push({key:n,value:i,variant:e}),t&&t.set(n,e));}r.sort((e,t)=>{const r=e.variant.id.toString().localeCompare(t.variant.id.toString());return 0!==r?r:e.variant.sx!==t.variant.sx?e.variant.sx-t.variant.sx:e.variant.sy!==t.variant.sy?e.variant.sy-t.variant.sy:0});const n=new Map;for(const e of r)n.set(e.key,e.value);return n}class Ex{constructor(e){this.sourceAtlasHash=e;}}class Cx{constructor(e,t,r,n){const i=new Map,s=new Map;this.haveRenderCallbacks=[];const a=[],o=void 0!==n,l=o?new Map:void 0,u=o?Dx(e,l):e,c=o?Dx(t,l):t;this.addImages(u,i,1,a),this.addImages(c,s,2,a);const{w:h,h:d}=Sx(a),p=new td({width:h||1,height:d||1});for(const[e,t]of u.entries()){const r=i.get(e).paddedRect;td.copy(t.data,p,{x:0,y:0},{x:r.x+1,y:r.y+1},t.data,null,t.sdf);}for(const[e,t]of c.entries()){const n=s.get(e),i=n.paddedRect;let a=n.padding;const o=i.x+a,l=i.y+a,u=t.data.width,c=t.data.height;a=a>1?a-1:a,td.copy(t.data,p,{x:0,y:0},{x:o,y:l},t.data,r),td.copy(t.data,p,{x:0,y:c-a},{x:o,y:l-a},{width:u,height:a},r),td.copy(t.data,p,{x:0,y:0},{x:o,y:l+c},{width:u,height:a},r),td.copy(t.data,p,{x:u-a,y:0},{x:o-a,y:l},{width:a,height:c},r),td.copy(t.data,p,{x:0,y:0},{x:o+u,y:l},{width:a,height:c},r),td.copy(t.data,p,{x:u-a,y:c-a},{x:o-a,y:l-a},{width:a,height:a},r),td.copy(t.data,p,{x:0,y:c-a},{x:o+u,y:l-a},{width:a,height:a},r),td.copy(t.data,p,{x:0,y:0},{x:o+u,y:l+c},{width:a,height:a},r),td.copy(t.data,p,{x:u-a,y:0},{x:o-a,y:l+c},{width:a,height:a},r);}this.lut=r,this.image=p,this.iconPositions=i,this.patternPositions=s,o&&(this.contentDescriptor=new kx(u,c,n,r,l));}addImages(e,t,r,n){for(const[i,s]of e.entries()){const{bin:e,imagePosition:a,imageVariant:o}=Vx(i,s,r);t.set(i,a),n.push(e),s.hasRenderCallback&&this.haveRenderCallbacks.push(o.id);}}patchUpdatedImages(e,t,r,n){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const i of e.getUpdatedImages(r)){for(const n of this.iconPositions.keys()){const s=Nr.parse(n);if(lr.isEqual(s.id,i)){const s=e.getImage(i,r);this.patchUpdatedImage(this.iconPositions.get(n),s,t,null);}}for(const s of this.patternPositions.keys()){const a=Nr.parse(s);if(lr.isEqual(a.id,i)){const a=e.getImage(i,r);this.patchUpdatedImage(this.patternPositions.get(s),a,t,n||this.lut);}}}}patchUpdatedImage(e,t,r,n=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[i,s]=e.tl,a=e.sdf;if(this.lut||a){const e={width:t.data.width,height:t.data.height},o=new td(e);td.copy(t.data,o,{x:0,y:0},{x:0,y:0},e,n,a),r.update(o,{position:{x:i,y:s},recreateWhenResize:!1});}else r.update(t.data,{position:{x:i,y:s},recreateWhenResize:!1});}}ra(Fx,"ImagePosition"),ra(Cx,"ImageAtlas",{omit:["lut"]}),ra(Ex,"ImageAtlasReference");class Rx{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.useServerFontComposition=!e||void 0===e.useServerFontComposition||e.useServerFontComposition;}loadGlyphRange(e,t,r,n,i){if(this.useServerFontComposition)return void Rx.loadGlyphRange(e,t,r,n,i);const s=e.split(",").map(e=>e.trim()).filter(e=>e.length>0);0!==s.length?1!==s.length?this._loadMultipleFonts(s,t,r,n,i):this._loadFont(s[0],t,r,n,i):i(new Error("Empty fontstack"));}_loadMultipleFonts(e,t,r,n,i){const s=e.map(()=>null),a={completed:0,firstError:null,callbackCalled:!1},o=(t,r,n)=>{if(!a.callbackCalled&&(r&&!a.firstError&&(a.firstError=r),n&&(s[t]=n),a.completed++,a.completed===e.length)){a.callbackCalled=!0;const e=s.filter(e=>null!==e);if(0===e.length)return void i(a.firstError||new Error("All fonts failed to load"));const t=this._composeGlyphs(e);i(null,t);}};for(let i=0;i<e.length;i++)this._loadFont(e[i],t,r,n,(e,t)=>{o(i,e,t);});}_loadFont(e,t,r,n,i){const s=`${e}:${t}`;if(this.cachedRanges.has(s)){const e=this.cachedRanges.get(s);return void wt.frame(()=>i(null,e))}const a=this.pendingRequests.get(s);a?a.push(i):(this.pendingRequests.set(s,[i]),Rx.loadGlyphRange(e,t,r,n,(e,t)=>{e||this.cachedRanges.set(s,t||null);const r=this.pendingRequests.get(s);if(this.pendingRequests.delete(s),r)for(const n of r)n(e,t);}));}_composeGlyphs(e){const t={};let r,n;for(const i of e)if(void 0===r&&void 0!==i.ascender&&(r=i.ascender),void 0===n&&void 0!==i.descender&&(n=i.descender),i.glyphs)for(const e in i.glyphs)void 0===t[e]&&(t[e]=i.glyphs[e]);return {glyphs:t,ascender:r,descender:n}}}Rx.loadGlyphRange=function(e,t,r,n,i){const s=256*t,a=s+255,o=n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",`${s}-${a}`),Ot.Glyphs);$t(o,(e,t)=>{if(e)i(e);else if(t){const e={},r=function(e){return new Dg(e).readFields(Hg,{})}(t);for(const t of r.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:r.ascender,descender:r.descender});}});};const Lx=1e20;function Ox(e,t,r,n,i,s,a,o,l){for(let u=t;u<t+n;u++)Ux(e,r*s+u,s,i,a,o,l);for(let u=r;u<r+i;u++)Ux(e,u*s+t,1,n,a,o,l);}function Ux(e,t,r,n,i,s,a){s[0]=0,a[0]=-Lx,a[1]=Lx,i[0]=e[t];for(let o=1,l=0,u=0;o<n;o++){i[o]=e[t+o*r];const n=o*o;do{const e=s[l];u=(i[o]-i[e]+n-e*e)/(o-e)/2;}while(u<=a[l]&&--l>-1);l++,s[l]=o,a[l]=u,a[l+1]=Lx;}for(let o=0,l=0;o<n;o++){for(;a[l+1]<o;)l++;const n=s[l],u=o-n;e[t+o*r]=i[n]+u*u;}}const Nx={none:0,ideographs:1,all:2};class jx{constructor(e,t,r,n){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=r,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new Rx({useServerFontComposition:n});}setURL(e){this.url=e;}prefetchRange(e,t){const r=this.url||lt.GLYPHS_URL;if(!r)return;let n=this.entries[e];n||(n=this.entries[e]={glyphs:{},requests:{},ranges:{}}),n.ranges[t]||n.requests[t]||(n.requests[t]=[],this.glyphLoader.loadGlyphRange(e,t,r,this.requestManager,(e,r)=>{if(r){n.ascender=r.ascender,n.descender=r.descender;for(const e in r.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=r.glyphs[+e]);n.ranges[t]=!0;}for(const i of n.requests[t]||[])i(e,r);delete n.requests[t];}));}getGlyphs(e,t){const r=[],n=this.url||lt.GLYPHS_URL;for(const t in e)for(const n of e[t])r.push({stack:t,id:n});Le(r,({stack:e,id:t},r)=>{let i=this.entries[e];i||(i=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=i.glyphs[t];if(void 0!==s)return void r(null,{stack:e,id:t,glyph:s});if(s=this._tinySDF(i,e,t),s)return i.glyphs[t]=s,void r(null,{stack:e,id:t,glyph:s});const a=Math.floor(t/256);if(256*a>65535)return Ze("glyphs > 65535 not supported"),void r(null,{stack:e,id:t,glyph:s});if(i.ranges[a])return void r(null,{stack:e,id:t,glyph:s});let o=i.requests[a];o||(o=i.requests[a]=[],this.glyphLoader.loadGlyphRange(e,a,n,this.requestManager,(e,t)=>{if(t){i.ascender=t.ascender,i.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(i.glyphs[+e]=t.glyphs[+e]);i.ranges[a]=!0;}for(const r of o)r(e,t);delete i.requests[a];})),o.push((n,i)=>{n?r(n):i&&r(null,{stack:e,id:t,glyph:i.glyphs[t]||null});});},(e,r)=>{if(e)t(e);else if(r){const e={};for(const{stack:t,id:n,glyph:i}of r)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e);}});}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Nx.none&&(this.localGlyphMode===Nx.all?!!this.localFontFamily:!!this.localFontFamily&&(_a(e)||Ma(e)||pa(e)||fa(e)||da(e)||wa(e)||(t=e)>=131072&&t<=173791||(e=>e>=66736&&e<=66815)(e)));var t;}_tinySDF(e,t,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=e.tinySDF;if(!i){let r="400";/bold/i.test(t)?r="900":/medium/i.test(t)?r="500":/light/i.test(t)&&(r="200"),i=e.tinySDF=new jx.TinySDF({fontFamily:n,fontWeight:r,fontSize:48,buffer:6,radius:16}),i.fontWeight=r;}const s=i.fontWeight;if(this.localGlyphs[s][r])return this.localGlyphs[s][r];const a=String.fromCodePoint(r),{data:o,width:l,height:u,glyphWidth:c,glyphHeight:h,glyphLeft:d,glyphTop:p,glyphAdvance:f}=i.draw(a);return this.localGlyphs[s][r]={id:r,bitmap:new ed({width:l,height:u},o),metrics:{width:c/2,height:h/2,left:d/2,top:p/2-27,advance:f/2,localGlyph:!0}}}}function Gx(e,t){return e+t[1]-t[0]}function $x(e,t,r,n,i=1){const s=[],a=e.imagePrimary,o=a.pixelRatio,l=a.paddedRect.w-2,u=a.paddedRect.h-2,c=(e.right-e.left)*i,h=(e.bottom-e.top)*i,d=a.stretchX||[[0,l]],p=a.stretchY||[[0,u]],f=d.reduce(Gx,0),m=p.reduce(Gx,0),y=l-f,g=u-m;let x=0,v=f,b=0,w=m,_=0,A=y,I=0,M=g;if(a.content&&n){const e=a.content;x=Hx(d,0,e[0]),b=Hx(p,0,e[1]),v=Hx(d,e[0],e[2]),w=Hx(p,e[1],e[3]),_=e[0]-x,I=e[1]-b,A=e[2]-e[0]-v,M=e[3]-e[1]-w;}const S=(n,s,l,u)=>{const d=Wx(n.stretch-x,v,c,e.left*i),p=Yx(n.fixed-_,A,n.stretch,f),y=Wx(s.stretch-b,w,h,e.top*i),g=Yx(s.fixed-I,M,s.stretch,m),S=Wx(l.stretch-x,v,c,e.left*i),B=Yx(l.fixed-_,A,l.stretch,f),P=Wx(u.stretch-b,w,h,e.top*i),T=Yx(u.fixed-I,M,u.stretch,m),z=new Me(d,y),k=new Me(S,y),F=new Me(S,P),V=new Me(d,P),D=new Me(p/o,g/o),E=new Me(B/o,T/o),C=t*Math.PI/180;if(C){const e=Math.sin(C),t=Math.cos(C),r=[t,-e,e,t];z._matMult(r),k._matMult(r),V._matMult(r),F._matMult(r);}const R=n.stretch+n.fixed,L=l.stretch+l.fixed,O=s.stretch+s.fixed,U=u.stretch+u.fixed,N=e.imageSecondary;return {tl:z,tr:k,bl:V,br:F,texPrimary:{x:a.paddedRect.x+1+R,y:a.paddedRect.y+1+O,w:L-R,h:U-O},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+O,w:L-R,h:U-O}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:E,minFontScaleX:A/o/c,minFontScaleY:M/o/h,isSDF:r}};if(a.stretchX||a.stretchY){const e=Xx(d,y,f),t=Xx(p,g,m);for(let r=0;r<e.length-1;r++){const n=e[r],i=e[r+1];for(let e=0;e<t.length-1;e++)s.push(S(n,t[e],i,t[e+1]));}}else s.push(S({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:u+1}));return s}function qx(e,t){const r=e.stretchY||[[0,e.paddedRect.h-2]];return e.stretchX||e.stretchY?Zx(e.stretchX||[[0,e.paddedRect.w-2]])*Zx(r):1}function Hx(e,t,r){let n=0;for(const i of e)n+=Math.max(t,Math.min(r,i[1]))-Math.max(t,Math.min(r,i[0]));return n}function Xx(e,t,r){const n=[{fixed:-1,stretch:0}];for(const[t,r]of e){const e=n[n.length-1];n.push({fixed:t-e.stretch,stretch:e.stretch}),n.push({fixed:t-e.stretch,stretch:e.stretch+(r-t)});}return n.push({fixed:t+1,stretch:r}),n}function Zx(e){return 2*e.length+1}function Wx(e,t,r,n){return e/t*r+n}function Yx(e,t,r,n){return e-t*r/n}function Jx(e,t,r,n){const i=t+e.positionedLines[n].lineOffset;return 0===n?r+i/2:r+(i+(t+e.positionedLines[n-1].lineOffset))/2}function Kx(e,t,r,n,i,s,a,o,l,u=1){const c=[];if(0===t.positionedLines.length)return c;const h=(void 0!==l?l:n.layout.get("text-rotate").evaluate(s,{}))*Math.PI/180,d=function(e){const t=e[0],r=e[1],n=t*r;return n>0?[t,-r]:n<0?[-t,r]:0===t?[r,t]:[r,-t]}(r);let p=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)p-=e.lineOffset;const f=t.positionedLines.length,m=p/f;let y=t.top-r[1];for(let e=0;e<f;++e){const n=t.positionedLines[e];y=Jx(t,m,y,e);for(const e of n.positionedGlyphs){if(!e.rect)continue;const n=e.rect||{};let s=4,l=!0,p=1,f=0;if(e.image){const t=a.get(e.image.toString());if(!t)continue;if(t.sdf){Ze("SDF images are not supported in formatted text and will be ignored.");continue}l=!1,p=t.pixelRatio,s=1/p,t.usvg||(p/=u);}const m=(i||o)&&e.vertical,g=e.metrics.advance*e.scale/2,x=e.metrics,v=e.rect;if(null===v)continue;o&&t.verticalizable&&(f=e.image?g-e.metrics.width*e.scale/2:0);const b=i?[e.x+g,e.y]:[0,0];let w=[0,0],_=[0,0],A=!1;i||(m?(_=[e.x+g+d[0],e.y+d[1]-f],A=!0):w=[e.x+g+r[0],e.y+r[1]-f]);const I=v.w*e.scale/(p*(e.localGlyph?2:1)),M=v.h*e.scale/(p*(e.localGlyph?2:1));let S,B,P,T;if(m){const t=e.y-y,r=new Me(-g,g-t),n=-Math.PI/2,i=new Me(..._);S=new Me(-g+w[0],w[1]),S._rotateAround(n,r)._add(i),S.x+=-t+g,S.y-=(x.left-s)*e.scale;const a=e.image?x.advance*e.scale:Sg*e.scale,o=String.fromCodePoint(e.glyph);Tg(o)?S.x+=(1-s)*e.scale:zg(o)?S.x+=a-x.height*e.scale+(-s-1)*e.scale:S.x+=e.image||x.width+2*s===v.w&&x.height+2*s===v.h?(a-M)/2:(a-(x.height+2*s)*e.scale)/2,B=new Me(S.x,S.y-I),P=new Me(S.x+M,S.y),T=new Me(S.x+M,S.y-I);}else {const t=(x.left-s)*e.scale-g+w[0],r=(-x.top-s)*e.scale+w[1],n=t+I,i=r+M;S=new Me(t,r),B=new Me(n,r),P=new Me(t,i),T=new Me(n,i);}if(h){let e;e=i?new Me(0,0):A?new Me(d[0],d[1]):new Me(r[0],r[1]),S._rotateAround(h,e),B._rotateAround(h,e),P._rotateAround(h,e),T._rotateAround(h,e);}const z=new Me(0,0),k=new Me(0,0);c.push({tl:S,tr:B,bl:P,br:T,texPrimary:n,texSecondary:void 0,writingMode:t.writingMode,glyphOffset:b,sectionIndex:e.sectionIndex,isSDF:l,pixelOffsetTL:z,pixelOffsetBR:k,minFontScaleX:0,minFontScaleY:0});}}return c}function Qx(e,t=1,r=!1){let n=1/0,i=1/0,s=-1/0,a=-1/0;const o=e[0];for(let e=0;e<o.length;e++){const t=o[e];(!e||t.x<n)&&(n=t.x),(!e||t.y<i)&&(i=t.y),(!e||t.x>s)&&(s=t.x),(!e||t.y>a)&&(a=t.y);}const l=Math.min(s-n,a-i);let u=l/2;const c=new $n([],ev);if(0===l)return new Me(n,i);for(let t=n;t<s;t+=l)for(let r=i;r<a;r+=l)c.push(new tv(t+u,r+u,u,e));let h=function(e){let t=0,r=0,n=0;const i=e[0];for(let e=0,s=i.length,a=s-1;e<s;a=e++){const s=i[e],o=i[a],l=s.x*o.y-o.x*s.y;r+=(s.x+o.x)*l,n+=(s.y+o.y)*l,t+=3*l;}return new tv(r/t,n/t,0,e)}(e),d=c.length;for(;c.length;){const n=c.pop();(n.d>h.d||!h.d)&&(h=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-h.d<=t||(u=n.h/2,c.push(new tv(n.p.x-u,n.p.y-u,u,e)),c.push(new tv(n.p.x+u,n.p.y-u,u,e)),c.push(new tv(n.p.x-u,n.p.y+u,u,e)),c.push(new tv(n.p.x+u,n.p.y+u,u,e)),d+=4);}return r&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function ev(e,t){return t.max-e.max}jx.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:s="normal",fontStyle:a="normal",lang:o=null}={}){this.buffer=t,this.cutoff=n,this.radius=r,this.lang=o;const l=this.size=e+4*t,u=this._createCanvas(l),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${s} ${e}px ${i}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(e),a=Math.ceil(r),o=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=o+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),d=new Uint8ClampedArray(h),p={data:d,width:u,height:c,glyphWidth:o,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===o||0===l)return p;const{ctx:f,buffer:m,gridInner:y,gridOuter:g}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,o,l),f.fillText(e,m,m+a);const x=f.getImageData(m,m,o,l);g.fill(Lx,0,h),y.fill(0,0,h);for(let e=0;e<l;e++)for(let t=0;t<o;t++){const r=x.data[4*(e*o+t)+3]/255;if(0===r)continue;const n=(e+m)*u+t+m;if(1===r)g[n]=0,y[n]=Lx;else {const e=.5-r;g[n]=e>0?e*e:0,y[n]=e<0?e*e:0;}}Ox(g,0,0,u,c,u,this.f,this.v,this.z),Ox(y,m,m,o,l,u,this.f,this.v,this.z);for(let e=0;e<h;e++){const t=Math.sqrt(g[e])-Math.sqrt(y[e]);d[e]=Math.round(255-255*(t/this.radius+this.cutoff));}return p}};class tv{constructor(e,t,r,n){this.p=new Me(e,t),this.h=r,this.d=function(e,t){let r=!1,n=1/0;for(let i=0;i<t.length;i++){const s=t[i];for(let t=0,i=s.length,a=i-1;t<i;a=t++){const i=s[t],o=s[a];i.y>e.y!=o.y>e.y&&e.x<(o.x-i.x)*(e.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,qc(e,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const rv=Object.keys,nv=Number.POSITIVE_INFINITY,iv=Math.sqrt(2);function sv(e,t,r,n,i,s){const a=lx(e)&&e.collisionPadding?e.collisionPadding:[0,0,0,0],o={top:e.top-a[1],bottom:e.bottom+a[3],left:e.left-a[0],right:e.right+a[2],scaled:!1};return void 0!==n&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0;}(o,n),s&&(o.left+=s[0],o.right+=s[0],o.top+=s[1],o.bottom+=s[1]),r&&function(e,t,r){if(!t)return;const n=Te(t),i=new Me(r?r[0]:0,r?r[1]:0),s=new Me(e.left,e.top),a=new Me(e.right,e.top),o=new Me(e.left,e.bottom),l=new Me(e.right,e.bottom);s._rotateAround(n,i),a._rotateAround(n,i),o._rotateAround(n,i),l._rotateAround(n,i),e.left=Math.min(s.x,a.x,o.x,l.x),e.right=Math.max(s.x,a.x,o.x,l.x),e.top=Math.min(s.y,a.y,o.y,l.y),e.bottom=Math.max(s.y,a.y,o.y,l.y);}(o,r,i),t?{top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom),left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),scaled:t.scaled||o.scaled}:o}function av(e,[t,r]){let n=0,i=0;if(r===nv){t<0&&(t=0);const r=t/iv;switch(e){case "top-right":case "top-left":i=r-7;break;case "bottom-right":case "bottom-left":i=7-r;break;case "bottom":i=7-t;break;case "top":i=t-7;}switch(e){case "top-right":case "bottom-right":n=-r;break;case "top-left":case "bottom-left":n=r;break;case "left":n=t;break;case "right":n=-t;}}else {switch(t=Math.abs(t),r=Math.abs(r),e){case "top-right":case "top-left":case "top":i=r-7;break;case "bottom-right":case "bottom-left":case "bottom":i=7-r;}switch(e){case "top-right":case "bottom-right":case "right":n=-t;break;case "top-left":case "bottom-left":case "left":n=t;}}return [n,i]}function ov(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f){const m=e.layers[0],y=m.appearances;if(0===y.length)return {iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const g={iconBBox:null,iconVerticalBBox:null},x={textBBox:null,textVerticalBBox:null},{baseIconRotate:v,baseTextRotate:b,iconScaleFactor:w}=function(e,t,r){const n=e.get("icon-rotate").evaluate(t,{},r),i=e.get("text-rotate").evaluate(t,{},r),[s,a]=e.get("icon-size-scale-range");return {baseIconRotate:n,baseTextRotate:i,iconScaleFactor:Ee(1,s,a)}}(n,i,s);t&&(g.iconBBox=sv(t,g.iconBBox,v),r)&&(g.iconVerticalBBox=sv(r,g.iconVerticalBBox,v+90));const _=Bv(h.horizontal);_&&(x.textBBox=sv(_,x.textBBox,b,1,p)),h.vertical&&(x.textVerticalBBox=sv(h.vertical,x.textVerticalBBox,b+90,1,p));for(const r of y)r.hasIconLayoutProperties()&&lv(g,e,m,r,i,s,o,v,a,l,t,u,w,c,f),r.hasTextLayoutProperties()&&cv(x,m,r,i,s,p,b,d,_,h.vertical);return {iconBBox:g.iconBBox,iconVerticalBBox:g.iconVerticalBBox,textBBox:x.textBBox,textVerticalBBox:x.textVerticalBBox}}function lv(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f){const{appearanceIconOffset:m,appearanceIconRotate:y,appearanceIconSize:g}=uv(n,r,i,s,a,o,l,u.iconScaleFactor);let x=null,v=null,b=null;n.hasLayoutProperty("icon-image")?b=function(e,t,r,n,i,s,a,o){let l=null;const u=t.getAppearanceValueAndResolveTokens(r,"icon-image",n,i,o);if(u){const c=e.getResolvedImageFromTokens(u),h=r.hasLayoutProperty("icon-size")?r.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"],d=fv(c,mx(e.zoom,h,e.worldview,o),h,i,e.zoom,n,e.pixelRatio,a,e.worldview,o);l=s.get(d.iconPrimary.toString());}return l}(t,r,n,i,s,h,d,f):c&&(b=c.imagePrimary),b&&(x=ux(b,null,m,p),t.allowVerticalPlacement&&(v=ux(b,null,m,p)));const w=l>0?g/l:1;x&&(e.iconBBox=sv(x,e.iconBBox,y,1!==w?w:void 0)),v&&(e.iconVerticalBBox=sv(v,e.iconVerticalBBox,y+90,1!==w?w:void 0));}function uv(e,t,r,n,i,s,a,o){const l=e.hasLayoutProperty("icon-offset")?t.getAppearanceValueAndResolveTokens(e,"icon-offset",r,n,[]):null,u=l&&Array.isArray(l)?l:i,c=e.hasLayoutProperty("icon-rotate")?t.getAppearanceValueAndResolveTokens(e,"icon-rotate",r,n,[]):null,h="number"==typeof c?c:s,d=e.hasLayoutProperty("icon-size")?t.getAppearanceValueAndResolveTokens(e,"icon-size",r,n,[]):null;return {appearanceIconOffset:u,appearanceIconRotate:h,appearanceIconSize:"number"==typeof d?d*o:a}}function cv(e,t,r,n,i,s,a,o,l,u){const{appearanceTextOffset:c,appearanceTextRotate:h,appearanceTextSize:d}=hv(r,t,n,i,s,a,o),p=d/o,f=[(c[0]-s[0])*p,(c[1]-s[1])*p],m=0!==f[0]||0!==f[1];l&&(e.textBBox=sv(l,e.textBBox,h,p,c,m?f:void 0)),u&&(e.textVerticalBBox=sv(u,e.textVerticalBBox,h+90,p,c,m?f:void 0));}function hv(e,t,r,n,i,s,a){const o=e.hasLayoutProperty("text-offset")?t.getAppearanceValueAndResolveTokens(e,"text-offset",r,n,[]):null,l=o&&Array.isArray(o)?[o[0]*Sg,o[1]*Sg]:i,u=e.hasLayoutProperty("text-rotate")?t.getAppearanceValueAndResolveTokens(e,"text-rotate",r,n,[]):null,c="number"==typeof u?u:s,h=e.hasLayoutProperty("text-size")?t.getAppearanceValueAndResolveTokens(e,"text-size",r,n,[]):null;return {appearanceTextOffset:l,appearanceTextRotate:c,appearanceTextSize:"number"==typeof h?h:a}}function dv(e,t,r,n,i,s,a,o,l){if(!t||!t.usvg)return;const u=px(n),c=px(i),h="both"!==s&&"width"!==s||!hx(n)?1:c.width/u.width,d="both"!==s&&"height"!==s||!dx(n)?1:c.height/u.height;r.scaleSelf(h,d);const p=r.toString();a.set(p,r),o.set(p,t);const{imagePosition:f}=Vx(p,t,1);l.set(p,f);}function pv(e,t,r,n,i,s,a,o,l,u){if(!e)return;const c=function(e,t,r,n,i,s,a){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new to(e.maxZoom,{worldview:s}),r,a).evaluate(i,{},r,a),o=t.possiblyEvaluate(new to(e.minZoom,{worldview:s}),r,a).evaluate(i,{},r,a);return Math.max(n,o)}return t.possiblyEvaluate(new to(n,{worldview:s}),r,a).evaluate(i,{},r,a)}(t,r,n,i,s,l,u);return e.scaleSelf(c*o*a)}function fv(e,t,r,n,i,s,a,o,l,u){return {iconPrimary:pv(e.getPrimary(),t,r,n,i,s,a,o,l,u),iconSecondary:pv(e.getSecondary(),t,r,n,i,s,a,o,l,u)}}function mv(e,t,r){if(!t)return;const n=r.get(e.toString()),i=r.get(t.toString());n&&i&&(n.paddedRect.w===i.paddedRect.w&&n.paddedRect.h===i.paddedRect.h||Ze(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),n.usvg!==i.usvg&&Ze(`Mismatch in icon variant image types: ${e.id} and ${t.id}`));}function yv(e,t,r,n){if(!e)return;const i=t.get(r.toString());if(i&&(e.imagePrimary=i),n){const r=t.get(n.toString());e.imageSecondary=r;}}function gv(e,t){for(const r in e.horizontal)xv(e.horizontal[r],t);xv(e.vertical,t);}function xv(e,t){if(e)for(const r of e.positionedLines)for(const e of r.positionedGlyphs)if(null!==e.image){const r=e.image.toString();e.rect=t.get(r).paddedRect;}}function vv(e){switch(e){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function bv(e,t,r,n,i,s,a,o,l){const u=Bv(s.horizontal)||s.vertical,c=r.get("icon-text-fit-padding").evaluate(n,{},i);let h,d=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&s.vertical&&(h=cx(t,s.vertical,l,c,o,a)),u&&(d=cx(t,u,l,c,o,a))),{defaultShapedIcon:d,verticallyShapedIcon:h}}function wv(e,t){return e*t/24}function _v(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A){let I=a.textMaxSize.evaluate(t,{},d);void 0===I?I=o*a.textScaleFactor:I*=a.textScaleFactor;const M=e.layers[0].layout,S=wv(o,a.textScaleFactor),B=Bv(r.horizontal)||r.vertical,P=e.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),T=e.getAppearanceFeatureData(t.index);("none"!==y||P)&&T&&(T.textShaping=B,T.iconTextFitPadding=M.get("icon-text-fit-padding").evaluate(t,{},d),T.fontScale=S,T.textScaleFactor=a.textScaleFactor);const z="globe"===p.name,k=e.tilePixelRatio*I/24,F=(L=e.overscaling,e.zoom>18&&L>2&&(L>>=1),Math.max(qn/(512*L),1)*M.get("symbol-spacing")),V=M.get("text-padding")*e.tilePixelRatio,D=M.get("icon-padding")*e.tilePixelRatio,E=Te(M.get("text-max-angle")),C="map"===M.get("icon-rotation-alignment")&&"point"!==v,R=F/2;var L;!1===e.hasAnyIconTextFit&&"none"!==y&&(e.hasAnyIconTextFit=!0);const O=t.properties?+t.properties[mc]:null,U=O&&e.elevationFeatureIdToIndex?e.elevationFeatureIdToIndex.get(O):65535,N=(o,l,v)=>{if(l.x<0||l.x>=qn||l.y<0||l.y>=qn)return;let A=null;if(z){const{x:e,y:t,z:r}=p.projectTilePoint(l.x,l.y,v);A={anchor:new xx(e,t,r,0,void 0),up:p.upVector(v,l.x,l.y)};}!function(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,I,M,S,B,P,T,z,k){const F=e.addToLineVertexArray(t,n);let V,D,E,C,R,L,O,U=0,N=0,j=0,G=0,$=-1,q=-1;const H={};let X=rr("");const Z=r?r.anchor:t,W="none"!==B;let Y=0,J=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(b,{},I);Y=e[0]*Sg,J=e[1]*Sg;}else Y=l.layout.get("text-radial-offset").evaluate(b,{},I)*Sg,J=nv;if(e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(f)L=Tv(e),o&&(O=Tv(o));else {const r=l.layout.get("text-rotate").evaluate(b,{},I)+90;E=Pv(u,Z,t,c,h,d,e,p,r,m,k),o&&(C=Pv(u,Z,t,c,h,d,o,g,r,null,z));}}if(s){const n=l.layout.get("icon-rotate").evaluate(b,{},I),i=$x(s,n,_,W,w.iconScaleFactor),a=o?$x(o,n,_,W,w.iconScaleFactor):void 0;D=Pv(u,Z,t,c,h,d,s,g,n,null,T);const p=function(e,t,r,n,i,s,a,o,l,u){const c=e.layers[0],h=c.appearances;let d=t.length;if(r&&(d=Math.max(d,r.length)),0===h.length)return d;const[p,f]=n.get("icon-size-scale-range"),m=Ee(1,p,f);for(const t of h)if(t.hasLayoutProperty("icon-image")){const r=c.getAppearanceValueAndResolveTokens(t,"icon-image",s,a,u);if(r){const n=e.getResolvedImageFromTokens(r);if(n){const r=t.hasLayoutProperty("icon-size")?t.getUnevaluatedLayoutProperty("icon-size"):i._values["icon-size"],l=fv(n,mx(e.zoom,r,e.worldview,u),r,a,e.zoom,s,e.pixelRatio,m,e.worldview,u),c=o.get(l.iconPrimary.toString());c&&(d=Math.max(d,qx(c)));}}}return d}(e,i,a,l.layout,l._unevaluatedLayout,b,I,e.iconAtlasPositions,0,A);U=4*p;const f=l.layout.get("icon-size").evaluate(b,{},I,A),m=w.compositeIconSizes?w.compositeIconSizes[0].evaluate(b,{},I,A):0,y=w.compositeIconSizes?w.compositeIconSizes[1].evaluate(b,{},I,A):0,B=Sv(e.layerIds[0],e.iconSizeData,f,w.iconScaleFactor,m,y);e.addSymbols(e.icon,i,B,v,x,b,void 0,r,t,F.lineStartIndex,F.lineLength,-1,A,I,M,S,e.symbolInstances.length,p),$=e.icon.placedSymbolArray.length-1,a&&(N=4*p,e.addSymbols(e.icon,a,B,v,x,b,Wg.vertical,r,t,F.lineStartIndex,F.lineLength,-1,A,I,M,S,e.symbolInstances.length,p),q=e.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=n,o=i.horizontal[s];V||(X=rr(o.text),f?R=Tv(o):V=Pv(u,Z,t,c,h,d,o,p,l.layout.get("text-rotate").evaluate(b,{},I),m,k));const y=1===o.positionedLines.length;if(j+=Mv(e,r,t,o,a,l,f,b,m,F,i.vertical?Wg.horizontal:Wg.horizontalOnly,y?rv(i.horizontal):[s],H,$,w,A,I,e.symbolInstances.length,M),y)break}i.vertical&&(G+=Mv(e,r,t,i.vertical,a,l,f,b,m,F,Wg.vertical,["vertical"],H,q,w,A,I,e.symbolInstances.length,M));let K=-1;const Q=(e,t)=>e?Math.max(e,t):t;K=Q(R,K),K=Q(L,K),K=Q(O,K);const ee=K>-1?1:0;e.glyphOffsetArray.length>=65535&&Ze("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,Z.x,Z.y,Z.z,H.right>=0?H.right:-1,H.center>=0?H.center:-1,H.left>=0?H.left:-1,H.vertical>=0?H.vertical:-1,$,q,X,void 0!==V?V:e.collisionBoxArray.length,void 0!==V?V+1:e.collisionBoxArray.length,void 0!==E?E:e.collisionBoxArray.length,void 0!==E?E+1:e.collisionBoxArray.length,void 0!==D?D:e.collisionBoxArray.length,void 0!==D?D+1:e.collisionBoxArray.length,C||e.collisionBoxArray.length,C?C+1:e.collisionBoxArray.length,c,j,G,U,N,ee,0,Y,J,K,0,W?1:0,P);}(e,l,A,o,r,n,s,i,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,V,x,u,0,D,C,g,t,a,c,h,d,f,m,y,U,b,w,_);};if("line"===v)for(const i of $f(t.geometry,0,0,qn,qn)){const t=Ix(i,F,E,r.vertical||B,n,24,k,e.overscaling,qn);for(const r of t)B&&zv(e,B.text,R,r)||N(i,r,d);}else if("line-center"===v){for(const e of t.geometry)if(e.length>1){const t=Ax(e,E,r.vertical||B,n,24,k);t&&N(e,t,d);}}else if("Polygon"===t.type)for(const e of Dd(t.geometry,0)){const t=Qx(e,16);N(e[0],new xx(t.x,t.y,0,0,void 0),d);}else if("LineString"===t.type)for(const e of t.geometry)N(e,new xx(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)N([t],new xx(t.x,t.y,0,0,void 0),d);}const Av=255,Iv=Av*fx;function Mv(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x){const v=Kx(0,n,l,s,a,o,i,e.allowVerticalPlacement,void 0,f.textScaleFactor),b=s.layout.get("text-size").evaluate(o,{},y),w=f.compositeTextSizes?f.compositeTextSizes[0].evaluate(o,{},y):0,_=f.compositeTextSizes?f.compositeTextSizes[1].evaluate(o,{},y):0,A=Sv(e.layerIds[0],e.textSizeData,b,f.textScaleFactor,w,_);e.addSymbols(e.text,v,A,l,a,o,c,t,r,u.lineStartIndex,u.lineLength,p,m,y,x,!1,g,v.length);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*v.length}function Sv(e,t,r,n,i,s){const a=t;let o=null;return "source"===a.kind?(o=[fx*r*n],o[0]>Iv&&Ze(`${e}: Value for "text-size" is >= ${Av}. Reduce your "text-size".`)):"composite"===a.kind&&(o=[fx*i*n,fx*s*n],(o[0]>Iv||o[1]>Iv)&&Ze(`${e}: Value for "text-size" is >= ${Av}. Reduce your "text-size".`)),o}function Bv(e){for(const t in e)return e[t];return null}function Pv(e,t,r,n,i,s,a,o,l,u,c){let h,d,p,f;if(h=c?c.top:a.top,d=c?c.bottom:a.bottom,p=c?c.left:a.left,f=c?c.right:a.right,lx(a)&&a.collisionPadding){const e=a.collisionPadding;p-=e[0],h-=e[1],f+=e[2],d+=e[3];}if(l){const e=new Me(p,h),t=new Me(f,h),r=new Me(p,d),n=new Me(f,d),i=Te(l);let s=new Me(0,0);u&&(s=new Me(u[0],u[1])),e._rotateAround(i,s),t._rotateAround(i,s),r._rotateAround(i,s),n._rotateAround(i,s),p=Math.min(e.x,t.x,r.x,n.x),f=Math.max(e.x,t.x,r.x,n.x),h=Math.min(e.y,t.y,r.y,n.y),d=Math.max(e.y,t.y,r.y,n.y);}return e.emplaceBack(t.x,t.y,t.z,r.x,r.y,p,h,f,d,o,n,i,s),e.length-1}function Tv(e){lx(e)&&e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function zv(e,t,r,n){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])<r)return !0}else i[t]=[];return i[t].push(n),!1}function kv(e,t){const r=e.fovAboveCenter,n=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,i=Math.min(n,e.isOrthographic?-10*t:0),s=(e._camera.position[2]*e.worldSize-i)/Math.cos(e._pitch),a=Math.sin(r)*s/Math.sin(Math.max(Math.PI/2-e._pitch-r,.01));let o=Math.sin(e._pitch)*a+s;const l=s*(1/e._horizonShift);if(!e.elevation||0===e.elevation.exaggeration()){let t=Math.max(e.zoom-17,0);e.isOrthographic&&(t/=10),o*=1+t;}return Math.min(1.01*o,l)}function Fv(e,t){if(!t.isReprojectedInTileSpace)return {scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const r=Math.pow(2,-e.z),n=e.x*r,i=(e.x+1)*r,s=e.y*r,a=(e.y+1)*r,o=$u(n),l=$u(i),u=qu(s),c=qu(a),h=t.project(o,u),d=t.project(l,u),p=t.project(l,c),f=t.project(o,c);let m=Math.min(h.x,d.x,p.x,f.x),y=Math.min(h.y,d.y,p.y,f.y),g=Math.max(h.x,d.x,p.x,f.x),x=Math.max(h.y,d.y,p.y,f.y);const v=r/16;function b(e,r,n,i,s,a){const o=(n+s)/2,l=(i+a)/2,u=t.project($u(o),qu(l)),c=Math.max(0,m-u.x,y-u.y,u.x-g,u.y-x);m=Math.min(m,u.x),g=Math.max(g,u.x),y=Math.min(y,u.y),x=Math.max(x,u.y),c>v&&(b(e,u,n,i,o,l),b(u,r,o,l,s,a));}b(h,d,n,s,i,s),b(d,p,i,s,i,a),b(p,f,i,a,n,a),b(f,h,n,a,n,s),m-=v,y-=v,g+=v,x+=v;const w=1/Math.max(g-m,x-y);return {scale:w,x:m*w,y:y*w,x2:g*w,y2:x*w,projection:t}}function Vv(e,{x:t,y:r},n=0){return new Me(((t-n)*e.scale-e.x)*qn,(r*e.scale-e.y)*qn)}const Dv=u(new Float32Array(16));class Ev{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7];}project(e,t){return {x:0,y:0,z:0}}unproject(e,t){return new Lu(0,0)}projectTilePoint(e,t,r){return {x:e,y:t,z:0}}locationPoint(e,t,r,n=!0){return e._coordinatePoint(e.locationCoordinate(t,r),n)}pixelsPerMeter(e,t){return Gu(1,e)*t}pixelSpaceConversion(e,t,r){return 1}farthestPixelDistance(e){return kv(e,e.pixelsPerMeter)}pointCoordinate(e,t,r,n){const i=e.horizonLineFromTop(!1),s=new Me(t,Math.max(i,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(s,n))}pointCoordinate3D(e,t,r){const n=new Me(t,r);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return [t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return !this.pointCoordinate3D(e,t.x,t.y);const r=e.horizonLineFromTop();return t.y<r}createInversionMatrix(e,t){return Dv}createTileMatrix(e,t,r){let n,i,s;const a=r.canonical,o=u(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=Fv(a,this);n=1,i=l.x+r.wrap*l.scale,s=l.y,p(o,o,[n/l.scale,n/l.scale,e.pixelsPerMeter/t]);}else n=t/e.zoomScale(a.z),i=(a.x+Math.pow(2,a.z)*r.wrap)*n,s=a.y*n;return d(o,o,[i,s,0]),p(o,o,[n/qn,n/qn,1]),o}upVector(e,t,r){return [0,0,1]}upVectorScale(e,t,r){return {metersToTile:1}}}class Cv extends Ev{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,r]=this.parallels=e.parallels||[29.5,45.5],n=Math.sin(Te(t));this.n=(n+Math.sin(Te(r)))/2,this.c=1+n*(2*this.n-n),this.r0=Math.sqrt(this.c)/this.n;}project(e,t){const{n:r,c:n,r0:i}=this,s=Te(e-this.center[0]),a=Te(t),o=Math.sqrt(n-2*r*Math.sin(a))/r;return {x:o*Math.sin(s*r),y:o*Math.cos(s*r)-i,z:0}}unproject(e,t){const{n:r,c:n,r0:i}=this,s=i+t;let a=Math.atan2(e,Math.abs(s))*Math.sign(s);s*r<0&&(a-=Math.PI*Math.sign(e)*Math.sign(s));const o=Te(this.center[0])*r;a=Re(a,-Math.PI-o,Math.PI-o);const l=Ee(ze(a/r)+this.center[0],-180,180),u=Math.asin(Ee((n-(e*e+s*s)*r*r)/(2*r),-1,1)),c=Ee(ze(u),-85.051129,Xu);return new Lu(l,c)}}const Rv=1.340264,Lv=-.081106,Ov=893e-6,Uv=.003796,Nv=Math.sqrt(3)/2;class jv extends Ev{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const r=Math.asin(Nv*Math.sin(t)),n=r*r,i=n*n*n;return {x:.5*(e*Math.cos(r)/(Nv*(Rv+3*Lv*n+i*(7*Ov+9*Uv*n)))/Math.PI+.5),y:1-.5*(r*(Rv+Lv*n+i*(Ov+Uv*n))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,n=r*r,i=n*n*n;for(let e,s,a,o=0;o<12&&(s=r*(Rv+Lv*n+i*(Ov+Uv*n))-t,a=Rv+3*Lv*n+i*(7*Ov+9*Uv*n),e=s/a,r=Ee(r-e,-Math.PI/3,Math.PI/3),n=r*r,i=n*n*n,!(Math.abs(e)<1e-12));++o);const s=Nv*e*(Rv+3*Lv*n+i*(7*Ov+9*Uv*n))/Math.cos(r),a=Math.asin(Math.sin(r)/Nv),o=Ee(180*s/Math.PI,-180,180),l=Ee(180*a/Math.PI,-85.051129,Xu);return new Lu(o,l)}}class Gv extends Ev{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){return {x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const r=360*(e-.5),n=Ee(360*(.5-t),-85.051129,Xu);return new Lu(r,n)}}const $v=Math.PI/2;function qv(e){return Math.tan(($v+e)/2)}class Hv extends Ev{constructor(e){super(e),this.center=e.center||[0,30];const[t,r]=this.parallels=e.parallels||[30,30];let n=Te(t),i=Te(r);this.southernCenter=n+i<0,this.southernCenter&&(n=-n,i=-i);const s=Math.cos(n),a=qv(n);this.n=n===i?Math.sin(n):Math.log(s/Math.cos(i))/Math.log(qv(i)/a),this.f=s*Math.pow(qv(n),this.n)/this.n;}project(e,t){t=Te(t),this.southernCenter&&(t=-t),e=Te(e-this.center[0]);const r=1e-6,{n,f:i}=this;i>0?t<-$v+r&&(t=-$v+r):t>$v-r&&(t=$v-r);const s=i/Math.pow(qv(t),n);let a=s*Math.sin(n*e),o=i-s*Math.cos(n*e);return a=.5*(a/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:a,y:this.southernCenter?o:1-o,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:r,f:n}=this,i=n-t,s=Math.sign(i),a=Math.sign(r)*Math.sqrt(e*e+i*i);let o=Math.atan2(e,Math.abs(i))*s;i*r<0&&(o-=Math.PI*Math.sign(e)*s);const l=Ee(ze(o/r)+this.center[0],-180,180),u=Ee(ze(2*Math.atan(Math.pow(n/a,1/r))-$v),-85.051129,Xu);return new Lu(l,this.southernCenter?-u:u)}}class Xv extends Ev{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(e,t){return {x:Nu(e),y:ju(t),z:0}}unproject(e,t){const r=$u(e),n=qu(t);return new Lu(r,n)}}const Zv=Te(Xu);class Wv extends Ev{project(e,t){const r=(t=Te(t))*t,n=r*r;return {x:.5*((e=Te(e))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const e=s*s;i=(r*(1.007226+s*(.015085+e*(.028874*s-.044475-.005916*e)))-t)/(1.007226+s*(.045255+e*(.259866*s-.311325-.005916*11*e))),r=Ee(r-i,-Zv,Zv);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const a=Ee(ze(e/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),o=ze(r);return new Lu(a,o)}}const Yv=Te(Xu);class Jv extends Ev{project(e,t){t=Te(t),e=Te(e);const r=Math.cos(t),n=2/Math.PI,i=Math.acos(r*Math.cos(e/2)),s=Math.sin(i)/i,a=.5*(e*n+2*r*Math.sin(e/2)/s)||0,o=.5*(t+Math.sin(t)/s)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(e,t){let r=e=(2*e-.5)*Math.PI,n=t=(2*(1-t)-1)*Math.PI,i=25;const s=1e-6;let a=0,o=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),d=Math.sin(r/2),p=2*h*d,f=d*d,m=1-c*h*h,y=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,x=.5*(2*g*i*d+2*r/Math.PI)-e,v=.5*(g*s+n)-t,b=.5*y*(c*f+g*i*h*u)+1/Math.PI,w=y*(p*l/4-g*s*d),_=.125*y*(l*d-g*s*c*p),A=.5*y*(u*h+g*f*i)+.5,I=w*_-A*b;a=(v*w-x*A)/I,o=(x*_-v*b)/I,r=Ee(r-a,-Math.PI,Math.PI),n=Ee(n-o,-Yv,Yv);}while((Math.abs(a)>s||Math.abs(o)>s)&&--i>0);return new Lu(ze(r),ze(n))}}class Kv extends Ev{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Te(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){const{scale:r,cosPhi:n}=this;return {x:Te(e)*n*r+.5,y:-Math.sin(Te(t))/n*r+.5,z:0}}unproject(e,t){const{scale:r,cosPhi:n}=this,i=-(t-.5)/r,s=Ee(ze((e-.5)/r)/n,-180,180),a=Math.asin(Ee(i*n,-1,1)),o=Ee(ze(a),-85.051129,Xu);return new Lu(s,o)}}class Qv extends Xv{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(e,t,r){const n=Mh(e,t,r);return j(n,n,Ph(xh(r))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,r){const n=Eu(t.lat,t.lng),i=L([],n),s=r?e._centerAltitude+r:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;V(n,n,i,Gu(1,0)*qn*s);const a=u(new Float64Array(16));return h(a,e.pixelMatrix,e.globeMatrix),j(n,n,a),new Me(n[0],n[1])}pixelsPerMeter(e,t){return Gu(1,0)*t}pixelSpaceConversion(e,t,r){const n=Gu(1,e)*t,i=yr(Gu(1,45)*t,n,r);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,r){const n=Th(xh(r.canonical));return h(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:r}=e,n=Ph(xh(t));return m(n,n,Te(r.lng)),f(n,n,Te(r.lat)),p(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,r,n){return mh(e,t,r,!0)||new Ku(0,0)}pointCoordinate3D(e,t,r){const n=this.pointCoordinate(e,t,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(e,t){return !mh(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const r=e.cameraToCenterDistance,n=e._centerAltitude*t,i=e._camera,s=e._camera.forward(),a=B([],F([],s,-r),[0,0,n]),o=e.worldSize/(2*Math.PI),l=[0,0,-o],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=F([],i.up(),c),d=F([],i.right(),c*u),p=L([],B([],B([],s,h),d)),f=[];let m;if(new Ac(a,p).closestPointOnSphere(l,o,f)){const t=B([],f,l),r=X([],t,a);m=Math.cos(e.fovAboveCenter)*I(r);}else {const e=X([],a,l),t=X([],l,a);L(t,t);const r=I(e)-o;m=Math.sqrt(r*(r+2*o));const n=Math.acos(m/(o+r))-Math.acos(O(s,t));m*=Math.cos(n);}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=Vh(e.zoom);if(r>0){const n=kv(e,Gu(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),s=Math.max(e.width,e.height)/e.worldSize*Math.PI;return yr(t,n+i*(1-Math.cos(s)),Math.pow(r,10))}return t}upVector(e,t,r){return Mh(t,r,e,1)}upVectorScale(e){return {metersToTile:ph(Sh(xh(e)))}}}function eb(e){const t=e.parallels,r=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case "mercator":return new Xv(e);case "equirectangular":return new Gv(e);case "naturalEarth":return new Wv(e);case "equalEarth":return new jv(e);case "winkelTripel":return new Jv(e);case "albers":return r?new Kv(e):new Cv(e);case "lambertConformalConic":return r?new Kv(e):new Hv(e);case "globe":return new Qv(e)}throw new Error(`Invalid projection name: ${e.name}`)}class tb{constructor(e,t){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=t,this.appearances=e;const r=e.map(e=>function(e){if(!e.condition)return {featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const t=e.condition.expression;return {featureDependent:!bi(t),stateDependent:!wi(t),zoomDependent:!_i(t,["zoom"]),pitchDependent:!_i(t,["pitch"]),brightnessDependent:!_i(t,["brightness","measure-light"]),worldviewDependent:!_i(t,["worldview"])}}(e));this.anyFeatureDependent=r.some(e=>e.featureDependent),this.anyStateDependent=r.some(e=>e.stateDependent);}update(e,t){const r=this.lastParams,n=!r||r.zoom!==e.zoom||r.pitch!==(e.pitch||0)||r.brightness!==(e.brightness||0)||r.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};const i=t&&this.anyStateDependent;if(!n&&!i&&-2!==this.lastAllFeaturesIndex)return {kind:"no-changes"};if(!this.anyFeatureDependent&&!i){const t=this.evaluateAllFeatures(e);return t===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=t,{kind:"all-features",appearanceIndex:t})}return {kind:"per-feature"}}evaluateAllFeatures(e){for(let t=0;t<this.appearances.length;t++){const r=this.appearances[t];if(r.condition&&r.condition.evaluate(e,void 0,void 0,void 0))return t}return -1}}const rb=lc.types,nb=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ib(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=o?Math.min(Iv,Math.round(o[0])):0,f=o?Math.min(Iv,Math.round(o[1])):0;e.emplaceBack(t,r,Math.round(32*n),Math.round(32*i),s,a,(p<<1)+(l?1:0),0+(f<<1),16*u,16*c,256*h,256*d);}function sb(e,t,r){e.emplaceBack(t,r);}function ab(e,t,r,n,i,s,a){e.emplaceBack(t,r,n,i,s,a);}const ob=(e,t,r,n)=>{for(let i=0;i<t;i++)e.emplaceBack(r[0],r[1],r[2],n[0],n[1],n[2]);};function lb(e,t,r,n,i){e.emplaceBack(t,r,n,i),e.emplaceBack(t,r,n,i),e.emplaceBack(t,r,n,i),e.emplaceBack(t,r,n,i);}function ub(e){for(const t of e.sections)if(Ga(t.text))return !0;return !1}const cb=12;class hb{constructor(e){this.layoutVertexArray=new ol,this.indexArray=new yl,this.programConfigurations=e,this.segments=new Xl,this.dynamicLayoutVertexArray=new ul,this.opacityVertexArray=new cl,this.placedSymbolArray=new Dl,this.iconTransitioningVertexArray=new hl,this.globeExtVertexArray=new ll,this.zOffsetVertexArray=new Jo,this.orientationVertexArray=new vl,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new Jo,this.featureIdBuffer=null,this.cachedBatchIndices=null,this.cachedBatchSegments=null;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}getBatchGrouping(e){const t=e.get().length===this.segments.get().length;if(t&&this.cachedBatchIndices&&this.cachedBatchSegments)return {batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};const r=new Map;for(const t of e.get()){const e=void 0!==t.batchIndex?t.batchIndex:0;r.has(e)||r.set(e,[]),r.get(e).push(t);}const n=Array.from(r.keys()).sort((e,t)=>e-t),i=new Map;for(const e of n){const t=r.get(e);i.set(e,new Xl(t));}return t&&(this.cachedBatchIndices=n,this.cachedBatchSegments=i),{batchIndices:n,batchSegments:i}}snapshotSymbolVertexData(e,t){const r=e*cb;return this.layoutVertexArray.uint16.slice(r,r+t*cb)}restoreSymbolVertexData(e,t){this.layoutVertexArray.uint16.set(t,e*cb);}updateSymbolVertexData(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=this.layoutVertexArray.uint16,f=e*cb;p[f]=t,p[f+1]=r,p[f+2]=n,p[f+3]=i,p[f+4]=s,p[f+5]=a,p[f+6]=o,p[f+7]=l,p[f+8]=u,p[f+9]=c,p[f+10]=h,p[f+11]=d;}upload(e,t,r,n,i,s){this.isEmpty()||(r&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,cg.members,!!s),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,dg.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,nb,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,yg.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,hg.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,pg.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,mg.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,fg.members,!1))),(r||n)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.upload(e)));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy());}}ra(hb,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class db{constructor(e,t,r){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new r,this.segments=new Xl,this.collisionVertexArray=new ml,this.collisionVertexArrayExt=new ul;}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,gg.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,xg.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}ra(db,"CollisionBuffers");class pb{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=u([]),this.placementViewportMatrix=u([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.disableSymbolUBO=e.disableSymbolUBO,this.textSizeData=mx(this.zoom,t["text-size"],this.worldview,e.availableImages),this.iconSizeData=mx(this.zoom,t["icon-size"],this.worldview,e.availableImages);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.lut=e.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(e=>Wg[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map;}hasAnyAppearanceLayoutProperty(e){const t=this.layers[0].getAppearances();if(!t||0===t.length)return !1;const r=Array.isArray(e)?e:[e];return t.some(e=>r.some(t=>e.hasLayoutProperty(t)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new hb(new Au(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new hb(new Au(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new Mg(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Mg(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new Rl,this.lineVertexArray=new Ll,this.symbolInstances=new Cl;}calculateGlyphDependencies(e,t,r,n,i){for(const r of e){const e=r.codePointAt(0);if(void 0===e)break;if(t[e]=!0,n&&i&&e<=65535){const e=Pg[r];e&&(t[e.charCodeAt(0)]=!0);}}}calculateEffectiveAppearanceIconSize(e,t,r,n,i,s,a){if(!e.hasLayoutProperty("icon-size"))return a*s;let o=1;const l=e.getUnevaluatedLayoutProperty("icon-size"),u=mx(this.zoom,l,this.worldview,i),c=gx(u,t);if("constant"!==u.kind&&"camera"!==u.kind||(o=c.uSize),"composite"===u.kind){const{minZoom:e,maxZoom:t}=u,s=l.possiblyEvaluate(new to(e,{worldview:this.worldview}),n),a=l.possiblyEvaluate(new to(t,{worldview:this.worldview}),n),h=s.evaluate(r,{},n,i);o=h+(a.evaluate(r,{},n,i)-h)*c.uSizeT;}return "source"===u.kind&&(o=l.possiblyEvaluate(new to(this.zoom,{worldview:this.worldview}),n).evaluate(r,{},n,i)),o*s}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return !Yp(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(e){return "string"==typeof e?jr.build(e):e}populate(e,t,r,n){const i=this.layers[0],s=i.layout,a="globe"===this.projection.name,o=s.get("text-font"),l=s.get("text-field"),u=s.get("icon-image"),[c,h]=s.get("icon-size-scale-range"),d=Ee(t.scaleFactor||1,c,h),[p,f]=s.get("text-size-scale-range"),m=Ee(t.scaleFactor||1,p,f),y=("constant"!==l.value.kind||l.value.value instanceof Ur&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),g="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,x=this.hasAnyAppearanceLayoutProperty("icon-image"),v=s.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!y&&!g&&!x)return;const b=t.iconDependencies,w=t.glyphDependencies,_=t.availableImages,A=new to(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),I=e=>{const t=e.id.toString();b.has(t)?b.get(t).push(e):b.set(t,[e]);};for(const t of e){const{feature:e,id:l,index:u,sourceLayerIndex:c}=t,h=i._featureFilter.needGeometry,p=oc(e,h);if(!i._featureFilter.filter(A,p,r))continue;if(h||(p.geometry=ac(e,r,n)),a&&1!==e.type&&r.z<=5){const e=p.geometry,t=.98078528056,n=(e,n)=>O(Mh(e.x,e.y,r,1),Mh(n.x,n.y,r,1))<t;for(let t=0;t<e.length;t++)e[t]=rc(e[t],n);}let f,M;if(y){const e=i.getValueAndResolveTokens("text-field",p,r,_),t=Ur.factory(e);ub(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Ja()||this.hasRTLText&&Qa.isParsed())&&(f=Bg(t,i,p));}if(g){const e=i.getValueAndResolveTokens("icon-image",p,r,_);M=this.getResolvedImageFromTokens(e);}const S=this.layers[0];let B=!1;if(!M&&x){const e=S.getAppearances();for(const t of e)if(t.getLayoutProperty("icon-image")){const e=S.getAppearanceValueAndResolveTokens(t,"icon-image",p,r,_);if(e){M=this.getResolvedImageFromTokens(e),B=!0;break}}}if(!f&&!M)continue;const P=this.sortFeaturesByKey?v.evaluate(p,{},r):void 0,T={id:l,text:f,icon:M,index:u,sourceLayerIndex:c,geometry:p.geometry,properties:e.properties,type:rb[e.type],sortKey:P};if(this.features.push(T),this.featureAppearanceData.set(u,{id:l,properties:e.properties,usesAppearanceIconAsPlaceholder:B,isUsingAppearanceIconVertexData:!1,isUsingAppearanceTextVertexData:!1,layoutBasedIconVertexData:new Uint16Array(0),layoutBasedTextVertexData:new Uint16Array(0),activeAppearanceIndex:-2}),M){const e=S._unevaluatedLayout._values,{iconPrimary:t,iconSecondary:n}=fv(M,this.iconSizeData,e["icon-size"],r,this.zoom,T,this.pixelRatio,d,this.worldview,_);I(t),n&&(this.hasAnySecondaryIcon=!0,I(n));}const z=S.getAppearances();if(0!==z.length&&z.forEach(e=>{if(!e.getLayoutProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,S,p,r,_,T,d);t&&I(t);}),f){const e=o.evaluate(p,{},r).join(","),t="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Wg.vertical)>=0;for(const r of f.sections)if(r.image){const e=r.image.getPrimary().scaleSelf(this.pixelRatio*m),t=e.id.toString(),n=b.get(t)||[];n.push(e),b.set(t,n);}else {const n=Va(f.toString()),i=r.fontStack||e,s=w[i]=w[i]||{};this.calculateGlyphDependencies(r.text,s,t,this.allowVerticalPlacement,n);}}}if("line"===s.get("symbol-placement")&&(this.features=function(e){const t={},r={},n=[];let i=0;function s(t){n.push(e[t]),i++;}function a(e,t,i){const s=r[e];return delete r[e],r[t]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(e,r,i){const s=t[r];return delete t[r],t[e]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(e,t,r){const n=r?t[0][t[0].length-1]:t[0][0];return `${e}:${n.x}:${n.y}`}for(let u=0;u<e.length;u++){const c=e[u],h=c.geometry,d=c.text?c.text.toString():null;if(!d){s(u);continue}const p=l(d,h),f=l(d,h,!0);if(p in r&&f in t&&r[p]!==t[f]){const e=o(p,f,h),i=a(p,f,n[e].geometry);delete t[p],delete r[f],r[l(d,n[i].geometry,!0)]=i,n[e].geometry=null;}else p in r?a(p,f,h):f in t?o(p,f,h):(s(u),t[p]=i-1,r[f]=i-1);}return n.filter(e=>e.geometry)}(this.features)),"hd-road-markup"===s.get("symbol-elevation-reference")){if(this.elevationType="road",t.elevationFeatures){!this.elevationFeatures&&t.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const e of t.elevationFeatures)this.elevationFeatureIdToIndex.set(e.id,this.elevationFeatures.length),this.elevationFeatures.push(e);}}else s.get("symbol-z-elevate")&&(this.elevationType="offset");"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey);}getCombinedIconPrimary(e,t,r,n,i,s,a){let o,l;if(e.hasLayoutProperty("icon-image")){const s=t.getAppearanceValueAndResolveTokens(e,"icon-image",r,n,i);o=this.getResolvedImageFromTokens(s);}else {const e=t.getValueAndResolveTokens("icon-image",r,n,i);o=this.getResolvedImageFromTokens(e);}if(o){const r=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"];l=fv(o,mx(this.zoom,r,this.worldview,i),r,n,this.zoom,s,this.pixelRatio,a,this.worldview,i).iconPrimary;}return l}updateSymbolInstanceIconVertices(e,t,r,n,i,s){const{canonical:a,availableImages:o,globalProperties:l,layer:u,iconScaleFactor:c,featureState:h,layoutIconOffset:d,layoutIconSize:p,layoutIconRotate:f}=s;if(e.placedIconSymbolIndex<0)return {vertexOffsetDelta:0,hasChanges:!1};if(t.activeAppearanceIndex===r)return {vertexOffsetDelta:e.numIconVertices,hasChanges:!1};const m=r>=0?u.appearances[r]:null;if(m){const r=this.getCombinedIconPrimary(m,u,n,a,o,{sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:t.properties,type:"Point",id:t.id},c);if(!r)return {vertexOffsetDelta:0,hasChanges:!1};const s=r.toString(),y=this.iconAtlasPositions&&this.iconAtlasPositions.get(s);if(y){const{appearanceIconOffset:r,appearanceIconRotate:s}=uv(m,u,n,a,d,f,p,c);let g=ux(y,void 0,r,u.layout.get("icon-anchor").evaluate(n,h,a));const x=y.sdf,v=u.layout.get("icon-text-fit").constantOr("none");"none"!==v&&t.textShaping&&t.iconTextFitPadding&&t.fontScale&&(g=cx(g,t.textShaping,v,t.iconTextFitPadding,r,t.fontScale));const b=this.calculateEffectiveAppearanceIconSize(m,l.zoom,n,a,o,c,p),w=0,_=1+(Math.min(Iv,Math.round(b*fx))<<1),A=$x(g,s,x,"none"!==v,c);t.isUsingAppearanceIconVertexData||(t.isUsingAppearanceIconVertexData=!0,t.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(i,e.numIconVertices));const I=Math.floor(e.numIconVertices/4),M=Math.min(A.length,I);let S=i;for(let r=0;r<M;++r){const n=A[r],i=t.layoutBasedIconVertexData[0]||e.tileAnchorX,s=t.layoutBasedIconVertexData[1]||e.tileAnchorY,a=16*n.pixelOffsetTL.x,o=16*n.pixelOffsetTL.y,l=16*n.pixelOffsetBR.x,u=16*n.pixelOffsetBR.y,c=16*n.minFontScaleX,h=16*n.minFontScaleY;this.icon.updateSymbolVertexData(S,i,s,Math.round(32*n.tl.x),Math.round(32*n.tl.y),n.texPrimary.x,n.texPrimary.y,w,_,a,o,c,h),this.icon.updateSymbolVertexData(S+1,i,s,Math.round(32*n.tr.x),Math.round(32*n.tr.y),n.texPrimary.x+n.texPrimary.w,n.texPrimary.y,w,_,l,o,c,h),this.icon.updateSymbolVertexData(S+2,i,s,Math.round(32*n.bl.x),Math.round(32*n.bl.y),n.texPrimary.x,n.texPrimary.y+n.texPrimary.h,w,_,a,u,c,h),this.icon.updateSymbolVertexData(S+3,i,s,Math.round(32*n.br.x),Math.round(32*n.br.y),n.texPrimary.x+n.texPrimary.w,n.texPrimary.y+n.texPrimary.h,w,_,l,u,c,h),S+=4;}const B=e.numIconVertices-4*M;for(let e=0;e<B;++e)this.icon.updateSymbolVertexData(S+e,0,0,0,0,0,0,0,0,0,0,0,0);return {vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}}else {if(t.usesAppearanceIconAsPlaceholder)return this.icon.updateSymbolVertexData(i,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(i+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(i+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(i+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:e.numIconVertices,hasChanges:!0};if(t.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(i,t.layoutBasedIconVertexData),t.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:t.layoutBasedIconVertexData.length/cb,hasChanges:!0}}return {vertexOffsetDelta:e.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(e,t,r,n,i,s){const{canonical:a,layer:o,textScaleFactor:l,imageMap:u,featureState:c,layoutTextOffset:h,layoutTextSize:d,layoutTextRotate:p,layoutMinZoomSize:f,layoutMaxZoomSize:m,layoutTextSizeMinZoom:y,layoutTextSizeMaxZoom:g,availableImages:x}=s,v=e.numHorizontalGlyphVertices>0||e.numVerticalGlyphVertices>0;if(!v)return {vertexOffsetDelta:v?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(t.activeAppearanceIndex===r)return {vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};const b=r>=0?o.appearances[r]:null;if(b&&t.textShaping){const{appearanceTextOffset:r,appearanceTextRotate:s,appearanceTextSize:v}=hv(b,o,n,a,h,p,d);t.fontScale=wv(v,t.textScaleFactor);const w=b.getUnevaluatedLayoutProperty("text-size");let _=this.textSizeData,A=y,I=g;b.hasLayoutProperty("text-size")&&(_=mx(this.zoom,w,this.worldview,x),A="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,I="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0);const M=t.textShaping.bottom-h[1],S=t.textShaping.left-h[0],B=t.textShaping.right-h[0];t.textShaping.top=r[1]+(t.textShaping.top-h[1]),t.textShaping.bottom=r[1]+M,t.textShaping.left=r[0]+S,t.textShaping.right=r[0]+B;const P=Kx(0,t.textShaping,r,o,!1,n,u,this.allowVerticalPlacement,s),T=v&&"composite"===_.kind?w.possiblyEvaluate(new to(A,{}),a).evaluate(n,c,a):f,z=v&&"composite"===_.kind?w.possiblyEvaluate(new to(I,{}),a).evaluate(n,c,a):m,k=Sv(b.name,_,v,l,T,z),F=Array.isArray(k)?k[1]:v,V=0,D=1+(Math.min(Iv,Math.round(F*fx))<<1);t.isUsingAppearanceTextVertexData||(t.isUsingAppearanceTextVertexData=!0,t.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(i,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let t=0;t<P.length&&t<(e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices)/4;++t){const r=P[t],n=r.glyphOffset[1],s=e.tileAnchorX,a=e.tileAnchorY,o=i+4*t;this.text.updateSymbolVertexData(o,s,a,Math.round(32*r.tl.x),Math.round(32*(n+r.tl.y)),r.texPrimary.x,r.texPrimary.y,V,D,r.pixelOffsetTL.x,r.pixelOffsetTL.y,r.minFontScaleX,r.minFontScaleY),this.text.updateSymbolVertexData(o+1,s,a,Math.round(32*r.tr.x),Math.round(32*(n+r.tr.y)),r.texPrimary.x+r.texPrimary.w,r.texPrimary.y,V,D,r.pixelOffsetBR.x,r.pixelOffsetTL.y,r.minFontScaleX,r.minFontScaleY),this.text.updateSymbolVertexData(o+2,s,a,Math.round(32*r.bl.x),Math.round(32*(n+r.bl.y)),r.texPrimary.x,r.texPrimary.y+r.texPrimary.h,V,D,r.pixelOffsetTL.x,r.pixelOffsetBR.y,r.minFontScaleX,r.minFontScaleY),this.text.updateSymbolVertexData(o+3,s,a,Math.round(32*r.br.x),Math.round(32*(n+r.br.y)),r.texPrimary.x+r.texPrimary.w,r.texPrimary.y+r.texPrimary.h,V,D,r.pixelOffsetBR.x,r.pixelOffsetBR.y,r.minFontScaleX,r.minFontScaleY);}return {vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!0}}return t.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(i,t.layoutBasedTextVertexData),t.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:t.layoutBasedTextVertexData.length/cb,hasChanges:!0}):{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1}}update(e,t,r,n,i,s,a,o){if(this.text.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,this.worldview),this.icon.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,this.worldview),o)if(s)this.text.uboBinder&&this.text.uboBinder.updateDynamicExpressions(i[0],t,o,r,e,a),this.icon.uboBinder&&this.icon.uboBinder.updateDynamicExpressions(i[0],t,o,r,e,a);else if(Object.keys(e).length>0){const n=new Set(Object.keys(e).map(e=>{const t=Number(e);return !isNaN(t)&&Number.isSafeInteger(t)&&String(t)===e?t:e}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(n,i[0],t,o,r,e,a),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(n,i[0],t,o,r,e,a);}}updateRoadElevation(e){if("road"!==this.elevationType||!this.elevationFeatures)return;if(this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let t=!1;const r=Ju(e),n=1/r;let i=!1,s=!1;for(let e=0;e<this.symbolInstances.length;e++){const a=this.symbolInstances.get(e),o=M(1,0,0),l=M(0,1,0),{numHorizontalGlyphVertices:u,numVerticalGlyphVertices:c,numIconVertices:h,numVerticalIconVertices:d}=a,p=u>0||c>0,f=h>0,m=this.elevationFeatures[a.elevationFeatureIndex];if(m){const e=new Me(a.tileAnchorX,a.tileAnchorY),u=.075+m.pointElevation(e);a.zOffset!==u&&(t=!0,a.zOffset=u),0!==u&&(this.hasAnyZOffset=!0);const c=m.computeSlopeNormal(e,n),h=ue(te(),M(0,0,1),c);$(o,o,h),$(l,l,h),o[2]*=r,l[2]*=r,1===o[0]&&0===o[1]&&0===o[2]&&0===l[0]&&1===l[1]&&0===l[2]||(i=i||p,s=s||f);}if(p&&(ob(this.text.orientationVertexArray,u,o,l),ob(this.text.orientationVertexArray,c,o,l)),f){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:t}=a;e>=0&&ob(this.icon.orientationVertexArray,h,o,l),t>=0&&ob(this.icon.orientationVertexArray,d,o,l);}}i||(this.text.orientationVertexArray=void 0),s||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0);}updateZOffset(){const e=(e,t,n)=>{r+=t,r>e.length&&e.resize(r);for(let i=-t;i<0;i++)e.emplace(i+r,n);},t=(e,t,r)=>{n+=t,n>e.length&&e.resize(n);for(let i=-t;i<0;i++)e.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r<this.symbolInstances.length;r++){const n=this.symbolInstances.get(r),{numHorizontalGlyphVertices:i,numVerticalGlyphVertices:s,numIconVertices:a}=n,o=n.zOffset,l=a>0;if((i>0||s>0)&&(e(this.text.zOffsetVertexArray,i,o),e(this.text.zOffsetVertexArray,s,o)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:r}=n;e>=0&&t(this.icon.zOffsetVertexArray,a,o),r>=0&&t(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,o);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,t,r,n,i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(e=>e.appearances&&e.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0;}updateAppearances(e,t,r,n,i,s=!1){const a={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!r||!this.featureAppearanceData)return a;const o=t||{},l=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,u=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!l&&!u)return a;const c=this.layers[0],h=c.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===c.appearancesVersion||(this.featureAppearances=new tb(c.appearances,c.appearancesVersion));const d=this.featureAppearances.update(n,s);if("no-changes"===d.kind)return a;let p=1,f=0,m=!1,y=!1;if(l){const[e,t]=h.get("icon-size-scale-range");p=Ee(1,e,t);}let g=1,x=0,v=!1;if(u){const[e,t]=h.get("text-size-scale-range");g=Ee(1,e,t);}const b=new Map;if(i&&r)for(const e of r){const t=i.getImage(e,c.scope);if(t){const r=new Nr(e.toString());b.set(r.toString(),t);}}for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t),s=this.getAppearanceFeatureData(i.featureIndex);if(!s)continue;const a=s.id,w=void 0!==a?o[String(a)]:void 0,_={type:"Point",id:s.id,properties:s.properties,geometry:[]};let A;if("all-features"===d.kind)A=d.appearanceIndex;else {const t=c.appearances?c.appearances.findIndex(t=>t.isActive({globals:n,feature:_,canonical:e,featureState:w})):-1;A=t>=0?t:-1;}const I=s.activeAppearanceIndex!==A;if(u){const t=h.get("text-size"),n="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,a="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0,o={canonical:e,layer:c,featureState:w,availableImages:r,textScaleFactor:g,imageMap:b,layoutTextOffset:h.get("text-offset").evaluate(_,w,e).map(e=>e*Sg),layoutTextSize:t.evaluate(_,w,e),layoutTextRotate:h.get("text-rotate").evaluate(_,w,e),layoutMinZoomSize:t.evaluate(_,{zoom:n},e),layoutMaxZoomSize:t.evaluate(_,{zoom:a},e),layoutTextSizeMinZoom:n,layoutTextSizeMaxZoom:a},l=this.updateSymbolInstanceTextVertices(i,s,A,_,x,o);x+=l.vertexOffsetDelta,v=v||l.hasChanges;}if(l){const t={canonical:e,layer:c,featureState:w,availableImages:r,globalProperties:n,iconScaleFactor:p,layoutIconOffset:h.get("icon-offset").evaluate(_,w,e),layoutIconSize:h.get("icon-size").evaluate(_,w,e,r),layoutIconRotate:h.get("icon-rotate").evaluate(_,w,e)},a=this.updateSymbolInstanceIconVertices(i,s,A,_,f,t);f+=a.vertexOffsetDelta,m=m||a.hasChanges;}if(I){const t=i.featureIndex,s=n?n.brightness:null,a=w||{},o=A>=0?c.appearances[A]:null;this.text.uboBinder&&(this.text.uboBinder.layer=c,y=this.text.uboBinder.updateFeaturePaintForAppearance(t,_,a,e,r,s,o)||y),this.icon.uboBinder&&(this.icon.uboBinder.layer=c,y=this.icon.uboBinder.updateFeaturePaintForAppearance(t,_,a,e,r,s,o)||y);}s.activeAppearanceIndex=A;}return m&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),v&&this.text.layoutVertexBuffer&&null!==this.text.layoutVertexArray.arrayBuffer&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:m||v,hasUboChanges:y}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=eb(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(e,t){const r=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:r}of t)this.lineVertexArray.emplaceBack(e,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g){const x=e.indexArray,v=e.layoutVertexArray,b=e.globeExtVertexArray,w=g,_=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,A=e.segments.prepareSegment(4*w,v,x,this.canOverlap?s.sortKey:void 0,_),I=this.glyphOffsetArray.length,M=A.vertexLength,S=this.allowVerticalPlacement&&a===Wg.vertical?Math.PI/2:0,B=s.text&&s.text.sections;let P=v.length,T=-1;for(let n=0;n<t.length;n++){const{tl:i,tr:a,bl:u,br:c,texPrimary:h,texSecondary:y,pixelOffsetTL:g,pixelOffsetBR:w,minFontScaleX:_,minFontScaleY:I,glyphOffset:M,isSDF:z,sectionIndex:k}=t[n],F=A.vertexLength,V=M[1];if(ib(v,l.x,l.y,i.x,V+i.y,h.x,h.y,r,z,g.x,g.y,_,I),ib(v,l.x,l.y,a.x,V+a.y,h.x+h.w,h.y,r,z,w.x,g.y,_,I),ib(v,l.x,l.y,u.x,V+u.y,h.x,h.y+h.h,r,z,g.x,w.y,_,I),ib(v,l.x,l.y,c.x,V+c.y,h.x+h.w,h.y+h.h,r,z,w.x,w.y,_,I),o){const{x:t,y:r,z:n}=o.anchor,[i,s,a]=o.up;ab(b,t,r,n,i,s,a),ab(b,t,r,n,i,s,a),ab(b,t,r,n,i,s,a),ab(b,t,r,n,i,s,a),lb(e.dynamicLayoutVertexArray,t,r,n,S);}else lb(e.dynamicLayoutVertexArray,l.x,l.y,l.z,S);if(m){const t=y||h;sb(e.iconTransitioningVertexArray,t.x,t.y),sb(e.iconTransitioningVertexArray,t.x+t.w,t.y),sb(e.iconTransitioningVertexArray,t.x,t.y+t.h),sb(e.iconTransitioningVertexArray,t.x+t.w,t.y+t.h);}if(x.emplaceBack(F,F+1,F+2),x.emplaceBack(F+1,F+2,F+3),A.vertexLength+=4,A.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(M[0]),(n===t.length-1||k!==t[n+1].sectionIndex)&&(e.programConfigurations.populatePaintArrays(v.length,s,s.index,{},d,p,f,B&&B[k],this.worldview),e.uboBinder&&e.featureIdArray)){const t=e.uboBinder.populateUBO(s,s.index,p,d,f,B&&B[k],void 0);T=t;const r=v.length-P;for(let n=0;n<r;n++)e.featureIdArray.emplaceBack(t);P=v.length;}}const z=g-t.length;if(0!==z&&(this._addNullVertices(z,v,r,o,b,e,m,A,x),e.uboBinder&&e.featureIdArray&&T>=0)){const t=4*z;for(let r=0;r<t;r++)e.featureIdArray.emplaceBack(T);}const k=o?o.anchor:l;e.placedSymbolArray.emplaceBack(k.x,k.y,k.z,l.x,l.y,I,this.glyphOffsetArray.length-I,M,u,c,l.segment,r?r[0]:0,r?r[1]:0,n[0],n[1],a,0,0,0,h,0),e.symbolInstanceIndices.push(y);}_addNullVertices(e,t,r,n,i,s,a,o,l){for(let u=0;u<e;u++){for(let e=0;e<4;e++)ib(t,0,0,0,0,0,0,r,!1,0,0,0,0),n?(ab(i,0,0,0,0,0,0),lb(s.dynamicLayoutVertexArray,0,0,0,0)):lb(s.dynamicLayoutVertexArray,0,0,0,0),a&&sb(s.iconTransitioningVertexArray,0,0);const e=o.vertexLength;l.emplaceBack(e,e+1,e+2),l.emplaceBack(e+1,e+2,e+3),o.vertexLength+=4,o.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0);}}_commitLayoutVertex(e,t,r,n,i,s,a){e.emplaceBack(t,r,n,i,s,Math.round(a.x),Math.round(a.y));}_addCollisionDebugVertices(e,t,r,n,i,s,a){const o=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),l=o.vertexLength,u=a.tileAnchorX,c=a.tileAnchorY;for(let e=0;e<4;e++)r.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(r.collisionVertexArrayExt,t,e.padding,a.zOffset),this._commitLayoutVertex(r.layoutVertexArray,n,i,s,u,c,new Me(e.x1,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,n,i,s,u,c,new Me(e.x2,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,n,i,s,u,c,new Me(e.x2,e.y2)),this._commitLayoutVertex(r.layoutVertexArray,n,i,s,u,c,new Me(e.x1,e.y2)),o.vertexLength+=4;const h=r.indexArray;h.emplaceBack(l,l+1),h.emplaceBack(l+1,l+2),h.emplaceBack(l+2,l+3),h.emplaceBack(l+3,l),o.primitiveLength+=4;}_addTextDebugCollisionBoxes(e,t,r,n,i,s){for(let a=n;a<i;a++){const n=r.get(a),i=this.getSymbolInstanceTextSize(e,s,t,a);this._addCollisionDebugVertices(n,i,this.textCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,s);}}_addIconDebugCollisionBoxes(e,t,r,n,i,s){for(let a=n;a<i;a++){const n=r.get(a),i=this.getSymbolInstanceIconSize(e,t,s.placedIconSymbolIndex);this._addCollisionDebugVertices(n,i,this.iconCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,s);}}generateCollisionDebugBuffers(e,t,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new db(pl,vg.members,hl),this.iconCollisionBox=new db(pl,vg.members,hl);const n=gx(this.iconSizeData,e),i=gx(this.textSizeData,e,r);for(let r=0;r<this.symbolInstances.length;r++){const s=this.symbolInstances.get(r);this._addTextDebugCollisionBoxes(i,e,t,s.textBoxStartIndex,s.textBoxEndIndex,s),this._addTextDebugCollisionBoxes(i,e,t,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s),this._addIconDebugCollisionBoxes(n,e,t,s.iconBoxStartIndex,s.iconBoxEndIndex,s),this._addIconDebugCollisionBoxes(n,e,t,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex,s);}}getSymbolInstanceTextSize(e,t,r,n){const i=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),s=yx(this.textSizeData,e,i)/Sg;return this.tilePixelRatio*s}getSymbolInstanceIconSize(e,t,r){const n=this.icon.placedSymbolArray.get(r),i=yx(this.iconSizeData,e,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,r,n){e.emplaceBack(t,-r,-r,n),e.emplaceBack(t,r,-r,n),e.emplaceBack(t,r,r,n),e.emplaceBack(t,-r,r,n);}_updateTextDebugCollisionBoxes(e,t,r,n,i,s,a){for(let a=n;a<i;a++){const n=r.get(a),i=this.getSymbolInstanceTextSize(e,s,t,a);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,i,n.padding,s.zOffset);}}_updateIconDebugCollisionBoxes(e,t,r,n,i,s,a){for(let a=n;a<i;a++){const n=r.get(a),i=this.getSymbolInstanceIconSize(e,t,s.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,i,n.padding,s.zOffset);}}updateCollisionDebugBuffers(e,t,r,n){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=gx(this.iconSizeData,e,n),s=gx(this.textSizeData,e,r);for(let a=0;a<this.symbolInstances.length;a++){const o=this.symbolInstances.get(a);this._updateTextDebugCollisionBoxes(s,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o,r),this._updateTextDebugCollisionBoxes(s,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o,r),this._updateIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o,n),this._updateIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o,n);}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt);}_deserializeCollisionBoxesForSymbol(e,t,r,n,i,s,a,o,l){const u={};if(t<r){const{x1:r,y1:n,x2:i,y2:s,padding:a,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(t);u.textBox={x1:r,y1:n,x2:i,y2:s,padding:a,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d},u.textFeatureIndex=p;}if(n<i){const{x1:t,y1:r,x2:i,y2:s,padding:a,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(n);u.verticalTextBox={x1:t,y1:r,x2:i,y2:s,padding:a,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d},u.verticalTextFeatureIndex=p;}if(s<a){const{x1:t,y1:r,x2:n,y2:i,padding:a,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(s);u.iconBox={x1:t,y1:r,x2:n,y2:i,padding:a,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d},u.iconFeatureIndex=p;}if(o<l){const{x1:t,y1:r,x2:n,y2:i,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(o);u.verticalIconBox={x1:t,y1:r,x2:n,y2:i,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:d},u.verticalIconFeatureIndex=p;}return u}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const r=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const r=e.placedSymbolArray.get(t),n=r.vertexStartIndex+4*r.numGlyphs;for(let t=r.vertexStartIndex;t<n;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3);}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),r=Math.cos(e),n=[],i=[],s=[];for(let e=0;e<this.symbolInstances.length;++e){s.push(e);const a=this.symbolInstances.get(e);n.push(0|Math.round(t*a.tileAnchorX+r*a.tileAnchorY)),i.push(a.featureIndex);}return s.sort((e,t)=>n[e]-n[t]||i[t]-i[e]),s}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e);}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort((e,t)=>this.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===t?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1});}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else {this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:o}=t;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}getOrCreateSortedSymbolsByBatch(e,t){const r=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(const r of this.symbolsByBatch.values())for(const n of r){const r=this.symbolInstances.get(n.index);n.rotatedY=0|Math.round(e*r.tileAnchorX+t*r.tileAnchorY);}else {this.symbolsByBatch=new Map;for(let n=0;n<this.symbolInstances.length;n++){const i=this.symbolInstances.get(n),s=Math.floor(n/r),a=0|Math.round(e*i.tileAnchorX+t*i.tileAnchorY);this.symbolsByBatch.has(s)||this.symbolsByBatch.set(s,[]),this.symbolsByBatch.get(s).push({index:n,rotatedY:a,featureIndex:i.featureIndex});}}for(const e of this.symbolsByBatch.values())e.sort((e,t)=>e.rotatedY-t.rotatedY||t.featureIndex-e.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(e,t){for(const r of e){const e=r.batchIndex;if(void 0===e)continue;const n=t.get(e);if(!n){r.primitiveOffset=this.text.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.text.indexArray.length;const i=this.text.indexArray.length;for(const{index:e}of n){const t=this.symbolInstances.get(e),{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s}=t;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s);}r.primitiveLength=this.text.indexArray.length-i;}}rebuildIconSegmentIndices(e,t){for(const r of e){const e=r.batchIndex;if(void 0===e)continue;const n=t.get(e);if(!n){r.primitiveOffset=this.icon.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.icon.indexArray.length;const i=this.icon.indexArray.length;for(const{index:e}of n){const t=this.symbolInstances.get(e),{placedIconSymbolIndex:r,verticalPlacedIconSymbolIndex:n}=t;r>=0&&this.addIndicesForPlacedSymbol(this.icon,r),n>=0&&this.addIndicesForPlacedSymbol(this.icon,n);}r.primitiveLength=this.icon.indexArray.length-i;}}sortFeaturesWithinSegments(){this.featureSortOrder=[];const e=Math.sin(this.sortedAngle),t=Math.cos(this.sortedAngle),r=this.getOrCreateSortedSymbolsByBatch(e,t),n=Array.from(r.keys()).sort((e,t)=>e-t);for(const e of n){const t=r.get(e);for(const{index:e}of t){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),r),this.rebuildIconSegmentIndices(this.icon.segments.get(),r),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}getElevationFeatureForText(e){const t=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex;let r;return this.elevationFeatures&&t<this.elevationFeatures.length&&(r=this.elevationFeatures[t]),r}}function fb(e,t){return t.replace(/{([^{}]+)}/g,(t,r)=>r in e?String(e[r]):"")}let mb,yb,gb;ra(pb,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),pb.addDynamicAttributes=lb;class xb{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:wr,this.defaultValue=e;}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}ra(xb,"FormatSectionOverride",{omit:["defaultValue"]});const vb=()=>gb||(gb={layout:mb||(mb=new fo({"symbol-placement":new co(mo.layout_symbol["symbol-placement"]),"symbol-spacing":new co(mo.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new co(mo.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ho(mo.layout_symbol["symbol-sort-key"]),"symbol-z-order":new co(mo.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new co(mo.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new co(mo.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new co(mo.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new co(mo.layout_symbol["icon-ignore-placement"]),"icon-optional":new co(mo.layout_symbol["icon-optional"]),"icon-rotation-alignment":new co(mo.layout_symbol["icon-rotation-alignment"]),"icon-size":new ho(mo.layout_symbol["icon-size"]),"icon-size-scale-range":new co(mo.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ho(mo.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ho(mo.layout_symbol["icon-text-fit-padding"]),"icon-image":new ho(mo.layout_symbol["icon-image"]),"icon-image-use-theme":new co({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ho(mo.layout_symbol["icon-rotate"]),"icon-padding":new co(mo.layout_symbol["icon-padding"]),"icon-keep-upright":new co(mo.layout_symbol["icon-keep-upright"]),"icon-offset":new ho(mo.layout_symbol["icon-offset"]),"icon-anchor":new ho(mo.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new co(mo.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new co(mo.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new co(mo.layout_symbol["text-rotation-alignment"]),"text-field":new ho(mo.layout_symbol["text-field"]),"text-font":new ho(mo.layout_symbol["text-font"]),"text-size":new ho(mo.layout_symbol["text-size"]),"text-size-scale-range":new co(mo.layout_symbol["text-size-scale-range"]),"text-max-width":new ho(mo.layout_symbol["text-max-width"]),"text-line-height":new ho(mo.layout_symbol["text-line-height"]),"text-letter-spacing":new ho(mo.layout_symbol["text-letter-spacing"]),"text-justify":new ho(mo.layout_symbol["text-justify"]),"text-radial-offset":new ho(mo.layout_symbol["text-radial-offset"]),"text-variable-anchor":new co(mo.layout_symbol["text-variable-anchor"]),"text-anchor":new ho(mo.layout_symbol["text-anchor"]),"text-max-angle":new co(mo.layout_symbol["text-max-angle"]),"text-writing-mode":new co(mo.layout_symbol["text-writing-mode"]),"text-rotate":new ho(mo.layout_symbol["text-rotate"]),"text-padding":new co(mo.layout_symbol["text-padding"]),"text-keep-upright":new co(mo.layout_symbol["text-keep-upright"]),"text-transform":new ho(mo.layout_symbol["text-transform"]),"text-offset":new ho(mo.layout_symbol["text-offset"]),"text-allow-overlap":new co(mo.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new co(mo.layout_symbol["text-ignore-placement"]),"text-optional":new co(mo.layout_symbol["text-optional"]),visibility:new co(mo.layout_symbol.visibility)})),paint:yb||(yb=new fo({"icon-opacity":new ho(mo.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ho(mo.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ho(mo.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ho(mo.paint_symbol["text-emissive-strength"]),"icon-color":new ho(mo.paint_symbol["icon-color"]),"icon-halo-color":new ho(mo.paint_symbol["icon-halo-color"]),"icon-halo-width":new ho(mo.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ho(mo.paint_symbol["icon-halo-blur"]),"icon-translate":new co(mo.paint_symbol["icon-translate"]),"icon-translate-anchor":new co(mo.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new co(mo.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ho(mo.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ho(mo.paint_symbol["text-occlusion-opacity"]),"text-color":new ho(mo.paint_symbol["text-color"],{runtimeType:Mr,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ho(mo.paint_symbol["text-halo-color"]),"text-halo-width":new ho(mo.paint_symbol["text-halo-width"]),"text-halo-blur":new ho(mo.paint_symbol["text-halo-blur"]),"text-translate":new co(mo.paint_symbol["text-translate"]),"text-translate-anchor":new co(mo.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new co(mo.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new co(mo.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new co(mo.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new co(mo.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ho(mo.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},gb);class bb extends No{constructor(e,t,r,n){super(e,vb(),t,r,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=u([]),this.hasOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint);}_handleSpecialPaintPropertyUpdate(e){"icon-occlusion-opacity"!==e&&"text-occlusion-opacity"!==e||(this.hasOcclusionOpacityProperties=!0);}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(r=>{r.recalculate(e,t,this.iconImageUseTheme);}),"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 r=this.layout.get("text-writing-mode");if(r){const e=[];for(const t of r)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getColorAdjustmentMatrix(e,t,r,n){return this._saturation===e&&this._contrast===t&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(e,t,r,n){e=at(e),t=st(t);const i=o(),s=e/3,a=1-2*s,l=[a,s,s,0,s,a,s,0,s,s,a,0,0,0,0,1],u=.5-.5*t,c=n-r;return h(i,[c,0,0,0,0,c,0,0,0,0,c,0,r,r,r,1],[t,0,0,0,0,t,0,0,0,0,t,0,u,u,u,1]),h(i,i,l),i}(e,t,r,n),this._saturation=e,this._contrast=t,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,r,n){const i=this.layout.get(e).evaluate(t,{},r,n),s=this._unevaluatedLayout._values[e];return s.isDataDriven()||$s(s.value)||!i?i:fb(t.properties,i)}getAppearanceValueAndResolveTokens(e,t,r,n,i){const s=e.getLayoutProperty(t);if(!s)return;const a=s.evaluate(r,{},n,i),o=e.getUnevaluatedLayoutProperties()._values[t];return o.isDataDriven()||$s(o.value)||!a||"string"!=typeof a?a:fb(r.properties,a)}createBucket(e){return new pb(e)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const e of vb().paint.overridableProperties){if(!bb.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),r=new xb(t),n=new Gs(r,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Hs("source",n):new Xs("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new lo(t.property,i,t.parameters);}}_handleOverridablePaintPropertyUpdate(e,t,r){return !(!this.layout||t.isDataDriven()||r.isDataDriven())&&bb.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const r=e.get("text-field"),n=vb().paint.properties[t];let i=!1;const s=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Ur)s(r.value.value.sections);else if("source"===r.value.kind){const e=t=>{i||(t instanceof Xr&&qr(t.value)===Tr?s(t.value.sections):t instanceof Jr?s(t.sections):t.eachChild(e));},t=r.value;t._styleExpression&&e(t._styleExpression.expression);}return i}getProgramIds(){return ["symbol"]}getDefaultProgramParams(e,t,r){return {config:new _u(this,{zoom:t,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let wb,_b,Ab,Ib;var Mb=Ho([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function Sb(e,t,r,n,i,o,l,u){const c=[e,t,1,r,n,1,i,o,1],h=[l,u,1],d=s([],c),[p,f,m]=G(h,h,d);return a(c,c,[p,0,0,0,f,0,0,0,m])}function Bb(e,t,r,n,i,o,l,u){const c=function(e,t,r,n,i,o,l,u){const c=Sb(0,0,1,0,1,1,0,1),h=Sb(e,t,r,n,i,o,l,u);return a(h,h,s([],c))}(e,t,r,n,i,o,l,u);return [c[2]/c[8]/qn,c[5]/c[8]/qn]}function Pb(e){return [e[0],Math.min(Math.max(e[1],-85.051129),Xu)]}class Tb extends or{constructor(e,t,r,n){super(),this.id=e,this.dispatcher=r,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=t,this._dirty=!1;}load(e,t){if(this._loaded=t||!1,this.fire(new nr("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Zt(this.map._requestManager.transformRequest(this.url,Ot.Image),(t,r)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new ir(t)):r&&(this.image=r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading());});}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Fm(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new nr("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Fm||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],r=e[0][1];for(const n of e)n[1]>r&&(r=n[1]),n[1]<t&&(t=n[1]);const n=(r+t)/2;if(n>Xu?this.onNorthPole=!0:n<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(Ku.fromLngLat);this.tileID=function(e){let t=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of e)t=Math.min(t,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);const s=Math.max(n-t,i-r),a=Math.max(0,Math.floor(-Math.log2(s))),o=Math.pow(2,a);let l=Math.floor((t+n)/2*o);return l>1&&(l-=1),new ih(a,l,Math.floor((r+i)/2*o))}(t),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new nr("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Fm||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const t=Fv(new ih(0,0,0),this.map.transform.projection),r=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,r=e[1].y-e[0].y,n=e[2].x-e[1].x,i=e[2].y-e[1].y,s=e[3].x-e[2].x,a=e[3].y-e[2].y,o=e[0].x-e[3].x,l=e[0].y-e[3].y,u=t*i-n*r,c=n*a-s*i,h=s*l-o*a,d=o*r-t*l;return u>0&&c>0&&h>0&&d>0||u<0&&c<0&&h<0&&d<0}(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=Fv(this.tileID,this.map.transform.projection),[i,o,l,u]=this.coordinates.map(e=>{const t=n.projection.project(e[0],e[1]);return Vv(n,t)._round()});this.perspectiveTransform=Bb(i.x,i.y,o.x,o.y,l.x,l.y,u.x,u.y);const c=this._boundsArray=new Yo;c.emplaceBack(i.x,i.y,0,0),c.emplaceBack(o.x,o.y,qn,0),c.emplaceBack(u.x,u.y,0,qn),c.emplaceBack(l.x,l.y,qn,qn),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Mb.members),this.boundsSegments=Xl.simpleSegment(0,0,4,2);const h=[],d=function(e){return [Pb(e[0]),Pb(e[1]),Pb(e[2]),Pb(e[3])]}(this.coordinates),[p,f,m,y]=function(e){let t=e[0][0],r=t,n=e[0][1],i=n;for(let s=1;s<e.length;s++)e[s][0]<t?t=e[s][0]:e[s][0]>r&&(r=e[s][0]),e[s][1]<n?n=e[s][1]:e[s][1]>i&&(i=e[s][1]);return [t,n,r-t,i-n]}(d);{const n=new Yo,[i,o,l,u]=function(e){let t=e[0].x,r=t,n=e[0].y,i=n;for(let s=1;s<e.length;s++)e[s].x<t?t=e[s].x:e[s].x>r&&(r=e[s].x),e[s].y<n?n=e[s].y:e[s].y>i&&(i=e[s].y);return [t,n,r-t,i-n]}(r),c=e=>[(e.x-i)/l,(e.y-o)/u],[d,g,x,v]=r.map(c),b=function(e,t,r,n,i,o,l,u){const c=Sb(0,0,1,0,1,1,0,1);return a(c,c,s([],Sb(e,t,r,n,i,o,l,u)))}(d[0],d[1],g[0],g[1],x[0],x[1],v[0],v[1]);this.elevatedGlobePerspectiveTransform=Bb(d[0],d[1],g[0],g[1],x[0],x[1],v[0],v[1]);const w=(e,t)=>{h.push(e.lng);const r=Math.round((e.lng-p)/m*qn),i=Math.round((e.lat-f)/y*qn),s=c(t),a=G([],[s[0],s[1],1],b),o=Math.round(a[0]/a[2]*qn),l=Math.round(a[1]/a[2]*qn);n.emplaceBack(r,i,o,l);},_=r[3].x-r[0].x,A=r[3].y-r[0].y,I=r[2].x-r[1].x,M=r[2].y-r[1].y;for(let e=0;e<65;e++){const n=e/64,i=[r[0].x+n*_,r[0].y+n*A],s=[r[1].x+n*I,r[1].y+n*M],a=s[0]-i[0],o=s[1]-i[1];for(let e=0;e<65;e++){const r=e/64,n={x:i[0]+a*r,y:i[1]+o*r};w(t.projection.unproject(n.x,n.y),n);}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(n,Mb.members);}{this.maxLongitudeTriangleSize=0;let t=[],r=new yl;const n=(e,n,i)=>{r.emplaceBack(e,n,i);const s=h[e],a=h[n],o=h[i],l=Math.min(Math.min(s,a),o),u=Math.max(Math.max(s,a),o)-l;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),t.push(l+u/2);};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const r=65*e+t,i=r+1,s=r+65,a=s+1;n(r,s,i),n(i,s,a);}[t,r]=function(e,t){const r=Array.from({length:e.length},(e,t)=>t);r.sort((t,r)=>e[t]-e[r]);const n=[],i=new yl;for(let s=0;s<r.length;s++){const a=r[s];n.push(e[a]);const o=3*a,l=o+1;i.emplaceBack(t.uint16[o],t.uint16[l],t.uint16[l+1]);}return [n,i]}(t,r),this.elevatedGlobeTrianglesCenterLongitudes=t,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(r);}this.elevatedGlobeSegments=Xl.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,m/qn,0,y/qn,0,0,f,p,0]);}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const t=this.map.painter.context,r=t.gl;!this._dirty||this.texture instanceof Fm||(this.texture?this.texture.update(this.image):(this.texture=new km(t,this.image,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(t);}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null));}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}getSegmentsForLongitude(e){const t=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!t)return null;const r=this.elevatedGlobeTrianglesCenterLongitudes;let n=(i=e+180)+360*Math.round((r[0]-i)/360);var i;const s=new Xl,a=(e,r)=>{s.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}});},o=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=o){const e=it(r,0,r.length,n+o);return e===r.length||a(e,nt(r,e+1,r.length,n+360-o)-e),s}n<r[0]&&(n+=360);const l=nt(r,0,r.length,n-o);if(l===r.length)return a(0,r.length),s;a(0,l-0);const u=it(r,l+1,r.length,n+o);return u!==r.length&&a(u,r.length-u),s}}const zb=1024,kb=(Math.pow(zb,2)-1)/268170240;class Fb extends No{constructor(e,t,r,n){super(e,{layout:Ab||(Ab=new fo({visibility:new co(mo.layout_raster.visibility)})),paint:Ib||(Ib=new fo({"raster-opacity":new co(mo.paint_raster["raster-opacity"]),"raster-color":new po(mo.paint_raster["raster-color"]),"raster-color-mix":new co(mo.paint_raster["raster-color-mix"]),"raster-color-range":new co(mo.paint_raster["raster-color-range"]),"raster-hue-rotate":new co(mo.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new co(mo.paint_raster["raster-brightness-min"]),"raster-brightness-max":new co(mo.paint_raster["raster-brightness-max"]),"raster-saturation":new co(mo.paint_raster["raster-saturation"]),"raster-contrast":new co(mo.paint_raster["raster-contrast"]),"raster-resampling":new co(mo.paint_raster["raster-resampling"]),"raster-fade-duration":new co(mo.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new co(mo.paint_raster["raster-emissive-strength"]),"raster-array-band":new co(mo.paint_raster["raster-array-band"]),"raster-elevation":new co(mo.paint_raster["raster-elevation"]),"raster-elevation-reference":new co(mo.paint_raster["raster-elevation-reference"]),"raster-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this.updateColorRamp(),this._curRampRange=[NaN,NaN];}getProgramIds(){return ["raster"]}hasColorMap(){return !!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(e){return !(e&&e._source instanceof Tb&&(e._source.onNorthPole||e._source.onSouthPole))&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(e){"raster-color"!==e&&"raster-color-range"!==e||(this._curRampRange=[NaN,NaN],this.updateColorRamp());}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}updateColorRamp(e){if(!this.hasColorMap())return;if(!this._curRampRange)return;const t=this._transitionablePaint._values["raster-color"].value.expression,[r,n]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(n)||r===this._curRampRange[0]&&n===this._curRampRange[1]||(this.colorRamp=nd({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:n}],resolution:zb}),this.colorRampTexture=null,this._curRampRange=[r,n]);}is3D(e){return this.paint.get("raster-elevation")>0}}let Vb,Db,Eb,Cb,Rb,Lb,Ob;class Ub extends No{constructor(e,t,r,n){super(e,{layout:Vb||(Vb=new fo({visibility:new co(mo["layout_raster-particle"].visibility)})),paint:Db||(Db=new fo({"raster-particle-array-band":new co(mo["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new co(mo["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new po(mo["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new co(mo["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new co(mo["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new co(mo["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new co(mo["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new co(mo["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp(),this.lastInvalidatedAt=wt.now();}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null);}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy();}hasColorMap(){return !!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return ["rasterParticle"]}hasOffscreenPass(){return "none"!==this.visibility}isDraped(e){return !1}_handleSpecialPaintPropertyUpdate(e){"raster-particle-color"!==e&&"raster-particle-max-speed"!==e||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===e&&this._invalidateAnimationState();}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=nd({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null;}_invalidateAnimationState(){this.lastInvalidatedAt=wt.now();}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class Nb extends No{constructor(e,t){super(e,{},t,null),this.implementation=e,e.slot&&(this.slot=e.slot);}is3D(e){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl);}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl);}}function jb(e,t,r){const n=[0,0,1],i=re([]);return ie(i,i,r?-Te(e)+Math.PI:Te(e)),ne(i,i,-Te(t)),$(n,n,i),L(n,n)}class Gb{constructor(e,t,r,n){this.message=(e?`${e}: `:"")+r,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__);}}function $b(e,t){const r=-1===e.indexOf("://");try{return new URL(e,r&&t?"http://example.com":void 0),!0}catch(e){return !1}}class qb{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class Hb{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new Bl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}colorForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let n=Math.floor(r[t+2]);const i=1.05*(r[t+2]-n);return n/=100,[r[t]%1*1.05,r[t+1]%1*1.05,i,n]}tileCoordinatesForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let n=r[t+0];return n=n>qn?n-qn:n,new Me(Math.trunc(n),Math.trunc(r[t+1]))}translationForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+4],r[t+5],r[t+6]]}rotationScaleForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+7],r[t+8],r[t+9],r[t+10],r[t+11],r[t+12],r[t+13],r[t+14],r[t+15]]}transformForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+7],r[t+8],r[t+9],r[t+4],r[t+10],r[t+11],r[t+12],r[t+5],r[t+13],r[t+14],r[t+15],r[t+6],0,0,0,1]}}class Xb{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.tileToMeter=Ju(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const s="hd-road-markup"===this.layers[0].paint.get("model-elevation-reference")?t.elevationFeatures:void 0;for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of e){const e=null!=o?o:a.properties&&a.properties.hasOwnProperty("id")?a.properties.id:void 0,c=oc(a,i);if(!this.layers[0]._featureFilter.filter(new to(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h={id:e,sourceLayerIndex:u,index:l,geometry:i?c.geometry:ac(a,r,n),properties:a.properties,type:a.type,patterns:{}},d=this.addFeature(h,h.geometry,c,s,r);d&&t.featureIndex.insert(a,h.geometry,l,u,this.index,this.instancesPerModel[d].instancedDataArray.length,256);}this.lookup=null;}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let r=0;for(const n of this.modelUris){const i=e.getModel(n,t);if(!i)continue;const s=this.instancesPerModel[n];if(s){const e=.5*D(i.aabb.max,i.aabb.min)*s.maxScale+s.maxXYTranslationDistance,t=Math.min(qn,Math.max(e/this.tileToMeter,256));r=Math.max(t,r);}}return r}update(e,t,r,n){for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const t in e)r.idToFeaturesIndex.hasOwnProperty(t)&&(this.evaluate(r.features[r.idToFeaturesIndex[t]],e[t],r,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const t of r.features){const n=this.layers[0],i=t.feature,s=this.canonical,a=n.paint.get("model-rotation").evaluate(i,{},s),o=n.paint.get("model-scale").evaluate(i,{},s),l=n.paint.get("model-translation").evaluate(i,{},s);H(t.rotation,a)&&H(t.scale,o)&&H(t.translation,l)||(this.evaluate(t,t.featureStates,r,!0),e=!0);}}return e}updateReplacement(e,t,r,n){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(Yp(this.activeReplacements,i))return !1;this.activeReplacements=i;let s=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t],a=i.instancedDataArray;for(const t of i.features){const i=t.instancedDataOffset,o=t.instancedDataCount;for(let t=0;t<o;t++){const o=16*(t+i);let l=a.float32[o+0];const u=l>qn;l=u?l-qn:l;const c=Math.floor(l),h=Math.floor(a.float32[o+1]);let d=!1;for(const t of this.activeReplacements)if(!Hp(t,r,nf.Model,n)&&!(t.min.x>c||c>t.max.x||t.min.y>h||h>t.max.y)&&(d=rf(tf(c,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;a.float32[o]=d?l+qn:l,s=s||d!==u;}}}return s}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,Lm.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(e){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(e&&t&&this.modelUris&&this.modelsRequested)for(const e of this.modelUris)t.removeModel(e,"",!0);}addFeature(e,t,r,n,i){const s=this.layers[0],a=s.layout.get("model-id"),o=s.layout.get("model-allow-density-reduction"),l=a.evaluate(r,{},this.canonical);if(!l)return Ze(`modelId is not evaluated for layer ${s.id} and it is not going to get rendered.`),l;($b(l,!1)||void 0!==this.styleDefinedModelURLs[l])&&(this.modelUris.includes(l)||this.modelUris.push(l)),this.instancesPerModel[l]||(this.instancesPerModel[l]=new Hb);const u=this.instancesPerModel[l],c=u.instancedDataArray,h=new qb(r,c.length);let d;n&&(d=Vc.getElevationFeature(e,n));for(const e of t)for(const t of e){if(t.x<0||t.x>=qn||t.y<0||t.y>=qn)continue;if(0!==this.lookupDim&&o){const e=(this.lookupDim-1)/qn,r=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}}this.instanceCount++;const e=c.length;if(c.resize(e+1),n){u.instancesRoadElevation||(u.instancesRoadElevation=[]);const e=d?d.pointElevation(new Me(t.x,t.y)):0;u.instancesRoadElevation.push(e);}u.instancesEvaluatedElevation.push(0),c.float32[16*e]=t.x,c.float32[16*e+1]=t.y;}return h.instancedDataCount=u.instancedDataArray.length-h.instancedDataOffset,h.instancedDataCount>0&&(e.id&&(u.idToFeaturesIndex[e.id]=u.features.length),u.features.push(h),this.evaluate(h,{},u,!1)),l}getModelUris(){return this.modelUris}evaluate(e,t,r,n){const i=this.layers[0],s=e.feature,a=this.canonical,o=e.rotation=i.paint.get("model-rotation").evaluate(s,t,a),l=e.scale=i.paint.get("model-scale").evaluate(s,t,a),u=e.translation=i.paint.get("model-translation").evaluate(s,t,a),c=Object.assign({},i.paint.get("model-color").evaluate(s,t,a));c.a=i.paint.get("model-color-mix-intensity").evaluate(s,t,a);const h=[];this.maxVerticalOffset<u[2]&&(this.maxVerticalOffset=u[2]);const d=u[0]*u[0]+u[1]*u[1],p=d>0?Math.sqrt(d):0;r.maxScale=Math.max(Math.max(r.maxScale,l[0]),Math.max(l[1],l[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,p),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Hm(h,o,l);const f=Math.round(100*c.a)+c.b/1.05;for(let t=0;t<e.instancedDataCount;++t){const i=e.instancedDataOffset+t,s=16*i,o=r.instancedDataArray.float32;let l=0;n&&(l=o[s+6]-r.instancesEvaluatedElevation[i]);const d=0|o[s+1];o[s]=(0|o[s])+c.r/1.05,o[s+1]=d+c.g/1.05,o[s+2]=f,o[s+3]=1/(a.z>10?this.tileToMeter:Ju(a,d)),o[s+4]=u[0],o[s+5]=u[1],o[s+6]=u[2]+(r.instancesRoadElevation?r.instancesRoadElevation[i]:0)+l,o[s+7]=h[0],o[s+8]=h[1],o[s+9]=h[2],o[s+10]=h[4],o[s+11]=h[5],o[s+12]=h[6],o[s+13]=h[8],o[s+14]=h[9],o[s+15]=h[10],r.instancesEvaluatedElevation[i]=u[2];}}}ra(Xb,"ModelBucket",{omit:["layers"]}),ra(Hb,"PerModelAttributes"),ra(qb,"ModelFeature");class Zb{constructor(e,t,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=r;}static create(e,t,r){const n=r||e.findDEMTileFor(t);if(!n||!n.dem)return;const i=n.dem,s=n.tileID,a=1<<t.canonical.z-s.canonical.z;return new Zb(n,i.dim/qn/a,[(t.canonical.x/a-s.canonical.x)*i.dim,(t.canonical.y/a-s.canonical.y)*i.dim])}tileCoordToPixel(e,t){const r=t*this._scale+this._offset[1];return new Me(Math.floor(e*this._scale+this._offset[0]),Math.floor(r))}getElevationAt(e,t,r,n){const i=e*this._scale+this._offset[0],s=t*this._scale+this._offset[1],a=Math.floor(i),o=Math.floor(s),l=this._dem;return n=!!n,r?yr(yr(l.get(a,o,n),l.get(a,o+1,n),s-o),yr(l.get(a+1,o,n),l.get(a+1,o+1,n),s-o),i-a):l.get(a,o,n)}getElevationAtPixel(e,t,r){return this._dem.get(e,t,!!r)}getMeterToDEM(e){return (1<<this._demTile.tileID.canonical.z)*Gu(1,e)*this._dem.stride}}const Wb=new Float32Array(262144),Yb=new Uint8Array(262144);function Jb(e){let t=0;if(e.meshes)for(const r of e.meshes)t=Math.max(t,r.aabb.max[2]);if(e.children)for(const r of e.children)t=Math.max(t,Jb(r));return t}function Kb(e,t,r){if(e.meshes)for(const n of e.meshes){if(n.aabb.min[0]===1/0)continue;const i=zc.applyTransform(n.aabb,e.globalMatrix);r.insert(t,i.min[0],i.min[1],i.max[0],i.max[1]);}if(e.children)for(const n of e.children)Kb(n,t,r);}const Qb=["","wall","door","roof","window","lamp","logo"];class ew{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedTranslation=[0,0,0],this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Jb(e)}},this.aabb=this._getLocalBounds(),this.state=null;}_getLocalBounds(){if(!this.node.meshes)return new zc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new zc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const r of this.node.meshes)this.node.lightMeshIndex!==e&&(r.transformedAabb=zc.applyTransformFast(r.aabb,this.node.globalMatrix),t.encapsulate(r.transformedAabb)),e++;this.aabb=t;}return this.aabb}}class tw{constructor(e,t,r,n,i,s,a,o){this.id=r,this.layers=e,this.layerIds=this.layers.map(e=>e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=Jm.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=Jm.HasMapboxMeshFeatures),i&&(this.modelTraits|=Jm.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=s,this.worldview=o,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new ew(e)),Kb(e,a.featureIndexArray.length,a.grid),a.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,a.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null;}updateFootprints(e,t){for(const r of this.getNodesInfo()){const n=r.node;n.footprint&&t.push({footprint:n.footprint,id:e});}}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const r=t?this.stateDependentLayers:this.layers;if(!Se(e,this.states))for(const t of r)this.evaluate(t,e);this.states=structuredClone(e);}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const r of t){const t=r.node;this.uploaded?this.updatePbrBuffer(t):ry(t,e,!0);}for(const e of t)ny(e.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const r of e.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),t=!0);return t}needsReEvaluation(e,t,r){const n=e.transform.projectionOptions,i=e.style.getBrightness(),s=this.brightness!==i;if(!this.uploaded||this.dirty||n.name!==this.projection.name||rw(r.paint.get("model-color").value,s)||rw(r.paint.get("model-color-mix-intensity").value,s)||rw(r.paint.get("model-roughness").value,s)||rw(r.paint.get("model-emissive-strength").value,s)||rw(r.paint.get("model-height-based-emissive-strength-multiplier").value,s)){this.projection=n,this.brightness=i;const e=this.getNodesInfo();for(const t of e)t.state=null;return !0}return !1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const e of r){const r=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(r,{},n),e.evaluatedScale=t.paint.get("model-scale").evaluate(r,{},n);}}evaluate(e,t){const r=this.getNodesInfo();for(const n of r){if(!n.node.meshes)continue;const r=n.feature,i=t&&t[r.id];if(Se(i,n.state))continue;n.state=structuredClone(i);const s=n.node.meshes&&n.node.meshes[0].featureData,a=n.evaluatedColor[2],o=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,s){for(let t=0;t<Qb.length;t++){const s=Qb[t];s.length&&(r.properties.part=s);const a=e.paint.get("model-color").evaluate(r,i,l).toPremultipliedRenderColor(null),o=e.paint.get("model-color-mix-intensity").evaluate(r,i,l);n.evaluatedColor[t]=[a.r,a.g,a.b,o],n.evaluatedRMEA[t][0]=e.paint.get("model-roughness").evaluate(r,i,l),n.evaluatedRMEA[t][2]=e.paint.get("model-emissive-strength").evaluate(r,i,l),n.evaluatedRMEA[t][3]=a.a,n.emissionHeightBasedParams[t]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(r,i,l),!n.hasTranslucentParts&&a.a<1&&(n.hasTranslucentParts=!0);}delete r.properties.part,iw(n,a!==n.evaluatedColor[2]||o!==n.evaluatedRMEA[2],this.modelTraits);}else n.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(r,i,l);n.evaluatedTranslation=e.paint.get("model-translation").evaluate(r,i,l),n.evaluatedScale=e.paint.get("model-scale").evaluate(r,i,l),this.updatePbrBuffer(n.node)||(this.needsUpload=!0);}this.dirty=!1;}elevationUpdate(e,t,r,n){const i=e.findDEMTileFor(r);if(i&&(i.tileID.canonical!==this.terrainTile||t!==this.terrainExaggeration)){if(i.dem&&i.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=i.tileID.overscaledZ;const t=Zb.create(e,r,i);if(!t)return;this.modelTraits&Jm.HasMapboxMeshFeatures&&this.updateDEM(e,t,r,n);for(const e of this.getNodesInfo()){const r=e.node;if(!r.footprint||!r.footprint.vertices||!r.footprint.vertices.length)continue;const n=r.footprint.vertices;let i=t.getElevationAt(n[0].x,n[0].y,!0,!0);for(let e=1;e<n.length;e++)i=Math.min(i,t.getElevationAt(n[e].x,n[e].y,!0,!0));r.elevation=i;}}this.terrainTile=i.tileID.canonical,this.terrainExaggeration=t;}}updateDEM(e,t,r,n){let i=t._dem._modifiedForSources[n];if(void 0===i&&(t._dem._modifiedForSources[n]=[],i=t._dem._modifiedForSources[n]),i.includes(r.canonical))return;const s=t._dem.dim;i.push(r.canonical);let a=!1;for(const e of this.getNodesInfo()){const r=e.node;if(!r.footprint||!r.footprint.grid)continue;const n=r.footprint.grid,i=t.tileCoordToPixel(n.min.x,n.min.y),o=t.tileCoordToPixel(n.max.x,n.max.y),l=Math.min(Math.min(s-o.y,i.x),Math.min(i.y,s-o.x));if(l<0)continue;const u=Ee(l,2,5);let c=Math.max(0,i.x-u),h=Math.max(0,i.y-u),d=Math.min(o.x+u,s-1),p=Math.min(o.y+u,s-1);for(let e=h;e<=p;++e)for(let t=c;t<=d;++t)Yb[e*s+t]=255;let f=0,m=0;for(let e=0;e<n.cellsY;++e)for(let r=0;r<n.cellsX;++r){if(!n.cells[e*n.cellsX+r])continue;const i=t.tileCoordToPixel(n.min.x+r/n.xScale,n.min.y+e/n.yScale),a=t.tileCoordToPixel(n.min.x+(r+1)/n.xScale,n.min.y+(e+1)/n.yScale);for(let e=i.y;e<=Math.min(a.y+1,s-1);++e)for(let r=i.x;r<=Math.min(a.x+1,s-1);++r)255===Yb[e*s+r]&&(Yb[e*s+r]=0,f+=t.getElevationAtPixel(r,e),m++);}const y=f/m;c=Math.max(1,i.x-u),h=Math.max(1,i.y-u),d=Math.min(o.x+u,s-2),p=Math.min(o.y+u,s-2),a=!0;for(let e=h;e<=p;++e)for(let r=c;r<=d;++r)0===Yb[e*s+r]&&(Wb[e*s+r]=t._dem.set(r,e,y));for(let e=1;e<u;++e){c=Math.max(1,i.x-e),h=Math.max(1,i.y-e),d=Math.min(o.x+e,s-2),p=Math.min(o.y+e,s-2);for(let r=h;r<=p;++r)for(let n=c;n<=d;++n){const i=r*s+n;if(255===Yb[i]){let a=0,o=0,l=-1,c=-1;for(let t=-1;t<=1;++t)for(let i=-1;i<=1;++i){const u=(r+t)*s+n+i;if(Yb[u]>=e)continue;const h=Wb[u],d=Math.abs(h);d>o&&(a=h,o=d,l=i,c=t);}if(o>.1){const s=1-(e+.5*Math.abs(l*c))/u;let o=t._dem.get(n,r)+a*s;const h=t._dem.get(n+l,r+c),d=t._dem.get(n-l,r-c,!0);(o-h)*(o-d)>0&&(o=(h+d)/2),Wb[i]=t._dem.set(n,r,o),Yb[i]=e;}}}}}a&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=wt.now());}setFilter(e){this.filter=e?vo(e):null;}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new to(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)ny(t.node),sy(t.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!r.find(e=>e.footprint===t);}}getHeightAtTileCoord(e,t){const r=[],n=[0,0,0],i=u([]);for(const s of this.getNodesInfo()){const a=s.node.meshes[0],o=a.transformedAabb;if(e<o.min[0]||t<o.min[1]||e>o.max[0]||t>o.max[1])continue;if(!0===s.node.hidden)return {height:1/0,maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]};c(i,s.node.globalMatrix),n[0]=e,n[1]=t,j(n,n,i);const l=(n[0]-a.aabb.min[0])/(a.aabb.max[0]-a.aabb.min[0])*Ym|0,u=Math.min(63,(n[1]-a.aabb.min[1])/(a.aabb.max[1]-a.aabb.min[1])*Ym|0)*Ym+Math.min(63,l),h=a.heightmap[u];if(!(h<0&&s.node.footprint)){if(s.hiddenByReplacement)return;return {height:h,maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]}}if(s.node.footprint.grid.query(new Me(e,t),new Me(e,t),r),r.length>0)return {height:void 0,maxHeight:s.feature.properties.height,hidden:s.hiddenByReplacement,verticalScale:s.evaluatedScale[2]}}}}function rw(e,t){return e instanceof Hs&&!e.isLightConstant&&t}function nw(e,t,r,n,i,s,a,o){let l=(61440&t|(61440&t)>>4)>>8,u=(3840&t|(3840&t)>>4)>>4,c=240&t|(240&t)>>4;r[3]>0&&(l=yr(l,255*r[0],r[3]),u=yr(u,255*r[1],r[3]),c=yr(c,255*r[2],r[3]));const h=l<<8|u,d=c<<8|Math.floor(255*n[3]),p=function(e){const t=Ee(e,0,2);return Math.min(Math.round(.5*t*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],f=Ee(i[0],0,1),m=Ee(i[1],0,1),y=Ee(i[2],0,1),g=Ee(i[3],0,1);let x,v,b,w;if(f!==m&&a!==s&&m!==f){const e=a-s;v=1/(e*(m-f)),b=-(s+e*f)/(e*(m-f));const t=Ee(i[4],-1,1);w=Math.pow(10,t),x=255*y<<8|255*g;}else x=65535,v=0,b=1,w=1;if(e.emplaceBack(h,d,p,x,v,b,w),o){const e=o.length;o.clear();for(let t=0;t<e;t++)o.emplaceBack(h,d,p,x,v,b,w);}}function iw(e,t,r){const n=e.node;let i=0;const s=r&Jm.HasMeshoptCompression;for(const r of n.meshes){if(n.lights&&n.lightMeshIndex===i)continue;if(!r.featureData)continue;r.featureArray=new Pl,r.featureArray.reserve(r.featureData.length);let a=t;for(const t of r.featureData){const i=s?65535&t:t>>16&65535,o=s?t>>16&65535:65535&t,l=(15&o)<8?15&o:0,u=e.evaluatedRMEA[l],c=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(a&&2===l&&n.lights&&(d=new Pl,d.resize(10*n.lights.length)),nw(r.featureArray,i,c,u,h,r.aabb.min[2],r.aabb.max[2],d),d&&a){a=!1;const e=n.meshes[n.lightMeshIndex];e.featureArray=d,e.featureArray._trim();}}r.featureArray._trim(),i++;}}ra(tw,"Tiled3dModelBucket",{omit:["layers"]}),ra(ew,"Tiled3dModelFeature");const sw=["id","tile","layer","source","sourceLayer","state"];class aw{constructor(e,t,r,n,i){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=r,this._y=n,this.properties=e?e.properties:{},this.id=i;}clone(){const e=new aw(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},this.layer)),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return void 0===this._geometry&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e;}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const t of sw)void 0!==this[t]&&(e[t]=this[t]);return e}}class ow extends or{constructor(e,t,r,n){super(),this.id=e,this.type="model",this.models=[],this._options=t,this._modelsInfo=new Map,this._abortController=null;}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null);}loadGLTFFromURI(e,t){return Pm(this.map._requestManager.transformRequest(e,Ot.Model).url,t)}async loadModel(e,t,r){try{const n=await this.loadGLTFFromURI(t.uri,r);if(r.aborted)return;const i=this._modelsInfo.get(e);if(!i)return;const s=py(n),a=i.modelSpec,o=new Qm(e,a.uri,a.position,a.orientation,s);ow.applyModelSpecification(o,a),o.computeBoundsAndApplyParent(),this.models.push(o),i.model=o;}catch(r){if(r instanceof Error&&"AbortError"===r.name)return;const n=r instanceof Error?r.message:"Unknown error";this.fire(new ir(new Error(`Could not load model ${e} from ${t.uri}: ${n}`)));}}async load(){this._abortController||(this._abortController=new AbortController);const e=this._abortController.signal,t=[];for(const r in this._options.models){const n=this._options.models[r],i=this._modelsInfo.get(r);if(i&&i.model){i.modelSpec=n;const e=i.model;e.position=null!=n.position?new Lu(n.position[0],n.position[1]):new Lu(0,0),e.orientation=null!=n.orientation?n.orientation:[0,0,0],ow.applyModelSpecification(e,n),e.computeBoundsAndApplyParent(),this.models.push(e);}else i?i.modelSpec=n:(this._modelsInfo.set(r,{modelSpec:n,model:null}),t.push(this.loadModel(r,n,e)));}0!==t.length?(await Promise.allSettled(t),e.aborted||this.fire(new nr("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new nr("data",{dataType:"source",sourceDataType:"metadata"}));}static applyModelSpecification(e,t){t.nodeOverrides&&ow.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&ow.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties);}static convertNodeOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.nodeOverrideNames=[];for(const r of t)e.nodeOverrideNames.push(r);}else Object.entries(t).forEach(([t,r])=>{const n={orientation:[0,0,0]};if(r.hasOwnProperty("orientation")){const e=r.orientation;e&&(n.orientation=e);}e.nodeOverrides.set(t,n);});}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.materialOverrideNames=[];for(const r of t)e.materialOverrideNames.push(r);}else Object.entries(t).forEach(([t,r])=>{const n={color:new dr(1,1,1),colorMix:0,emissionStrength:0,opacity:1},i=r["model-color"];void 0!==i&&(n.color.r=i[0],n.color.g=i[1],n.color.b=i[2]);const s=r["model-color-mix-intensity"];void 0!==s&&(n.colorMix=s);const a=r["model-emissive-strength"];void 0!==a&&(n.emissionStrength=a);const o=r["model-opacity"];void 0!==o&&(n.opacity=o),e.materialOverrides.set(t,n);});}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){if(0===this._modelsInfo.size)return !0;for(const e of this._modelsInfo.values())if(null==e.model)return !1;return !0}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return !1}reload(){this.cancelModelRequests();const e=Fo(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load();}onRemove(e){this.cancelModelRequests();}setModels(e){this.models=[];const t=new Map;for(const r in e){const n=e[r],i=this._modelsInfo.get(r);i&&i.modelSpec.uri===n.uri&&t.set(r,i);}if(this._modelsInfo.size!==t.size){this.cancelModelRequests();for(const[e,r]of t)r.model||t.delete(e);}this._modelsInfo=t,this._options.models=e,this.load();}}function lw(e,t,r,n){const i=1<<e.z;t.lat=qu((n/qn+e.y)/i),t.lng=$u((r/qn+e.x)/i);}function uw(e,t,r,n){const i=e.getNodesInfo()[t];if(!i||i.hiddenByReplacement||!i.node.meshes)return;let s=Number.MAX_VALUE;const a=i.node,o=r.tile,l=n.calculatePosMatrix(o.tileID.toUnwrapped(),n.worldSize),u=i.evaluatedScale;let c=0;n.elevation&&a.elevation&&(c=a.elevation*n.elevation.exaggeration()),d(l,l,[(a.anchor?a.anchor[0]:0)*(u[0]-1),(a.anchor?a.anchor[1]:0)*(u[1]-1),c]),p(l,l,u);const f=r.queryGeometry,m=f.isPointQuery()?f.screenBounds:f.screenGeometry,y=function(e){const t=h([],l,e.globalMatrix);h(t,n.expandedFarZProjMatrix,t);for(let r=0;r<e.meshes.length;++r){const i=e.meshes[r];if(r===e.lightMeshIndex)continue;const a=Wm(m,n,t,i.aabb);null!=a&&(s=Math.min(a,s));}if(e.children)for(const t of e.children)y(t);};if(y(a),s===Number.MAX_VALUE)return;const g=new Lu(0,0);return lw(o.tileID.canonical,g,i.node.anchor[0],i.node.anchor[1]),{intersectionZ:s,position:g,feature:i.feature}}const cw={circle:class extends No{constructor(e,t,r,n){super(e,{layout:rh||(rh=new fo({"circle-sort-key":new ho(mo.layout_circle["circle-sort-key"]),"circle-elevation-reference":new co(mo.layout_circle["circle-elevation-reference"]),visibility:new co(mo.layout_circle.visibility)})),paint:nh||(nh=new fo({"circle-radius":new ho(mo.paint_circle["circle-radius"]),"circle-color":new ho(mo.paint_circle["circle-color"]),"circle-blur":new ho(mo.paint_circle["circle-blur"]),"circle-opacity":new ho(mo.paint_circle["circle-opacity"]),"circle-translate":new co(mo.paint_circle["circle-translate"]),"circle-translate-anchor":new co(mo.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new co(mo.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new co(mo.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new ho(mo.paint_circle["circle-stroke-width"]),"circle-stroke-color":new ho(mo.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new ho(mo.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new co(mo.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}createBucket(e){return new Ec(e)}queryRadius(e){const t=e;return Kc("circle-radius",this,t)+Kc("circle-stroke-width",this,t)+Qc(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,r,n,i,s,a,o){const l=th(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(t,r)+this.paint.get("circle-stroke-width").evaluate(t,r);return Nh(e,n,s,a,o,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return ["circle"]}getDefaultProgramParams(e,t,r){const n=Uh(this);return {config:new _u(this,{zoom:t,lut:r}),defines:n,overrideFog:!1}}is3D(e){return !e&&!!this.layout&&"none"!==this.layout.get("circle-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("circle-elevation-reference")}},heatmap:class extends No{createBucket(e){return new Hh(e)}constructor(e,t,r,n){super(e,{layout:Xh||(Xh=new fo({visibility:new co(mo.layout_heatmap.visibility)})),paint:Zh||(Zh=new fo({"heatmap-radius":new ho(mo.paint_heatmap["heatmap-radius"]),"heatmap-weight":new ho(mo.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new co(mo.paint_heatmap["heatmap-intensity"]),"heatmap-color":new po(mo.paint_heatmap["heatmap-color"]),"heatmap-opacity":new co(mo.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=nd({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);}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}queryRadius(e){return Kc("heatmap-radius",this,e)}queryIntersectsFeature(e,t,r,n,i,s,a,o){const l=this.paint.get("heatmap-radius").evaluate(t,r);return Nh(e,n,s,a,o,!0,!0,new Me(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return ["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t,r){return "heatmap"===e?{config:new _u(this,{zoom:t,lut:r}),overrideFog:!1}:{}}},hillshade:class extends No{constructor(e,t,r,n){super(e,{layout:Wh||(Wh=new fo({visibility:new co(mo.layout_hillshade.visibility)})),paint:Yh||(Yh=new fo({"hillshade-illumination-direction":new co(mo.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new co(mo.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new co(mo.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new co(mo.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new co(mo.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new co(mo.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new co(mo.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return ["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t,r){return {overrideFog:!1}}},fill:class extends No{constructor(e,t,r,n){super(e,{layout:Tp||(Tp=new fo({"fill-sort-key":new ho(mo.layout_fill["fill-sort-key"]),visibility:new co(mo.layout_fill.visibility),"fill-elevation-reference":new co(mo.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new ho(mo.layout_fill["fill-construct-bridge-guard-rail"])})),paint:zp||(zp=new fo({"fill-antialias":new co(mo.paint_fill["fill-antialias"]),"fill-opacity":new ho(mo.paint_fill["fill-opacity"]),"fill-color":new ho(mo.paint_fill["fill-color"]),"fill-outline-color":new ho(mo.paint_fill["fill-outline-color"]),"fill-translate":new co(mo.paint_fill["fill-translate"]),"fill-translate-anchor":new co(mo.paint_fill["fill-translate-anchor"]),"fill-pattern":new ho(mo.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new co(mo.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new co(mo.paint_fill["fill-emissive-strength"]),"fill-z-offset":new ho(mo.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new ho(mo.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new ho(mo.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),r=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(e,t,r){return {config:new _u(this,{zoom:t,lut:r}),overrideFog:!1}}recalculate(e,t){super.recalculate(e,t);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(e){return new Pp(e)}queryRadius(){return Qc(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,r,n,i,s){return !e.queryGeometry.isAboveHorizon&&Lc(eh(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),n)}isTileClipped(){return 0===this.paint.get("fill-z-offset").constantOr(1)}is3D(e){if(0!==this.paint.get("fill-z-offset").constantOr(1))return !0;const t=this.layout&&"none"!==this.layout.get("fill-elevation-reference");return null!=e?t&&!e:t}hasElevation(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}hasShadowPass(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}},"fill-extrusion":class extends No{constructor(e,t,r,n){super(e,{layout:Lf||(Lf=new fo({visibility:new co(mo["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new co(mo["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new co(mo["layout_fill-extrusion"]["source-max-zoom"])})),paint:Of||(Of=new fo({"fill-extrusion-opacity":new co(mo["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new ho(mo["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new co(mo["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new co(mo["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ho(mo["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new co(mo["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new ho(mo["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new ho(mo["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new co(mo["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new co(mo["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new co(mo["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new co(mo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new co(mo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new co(mo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new co(mo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new co(mo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new co(mo["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new co(mo["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new ho(mo["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new ho(mo["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new co(mo["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new co(mo["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new co(mo["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new co(mo["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new co(mo["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new ho(mo["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new ho(mo["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new co(mo["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(e){return new Sf(e)}queryRadius(){return Qc(this.paint.get("fill-extrusion-translate"))}is3D(e){return !0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return !0}getProgramIds(){return [this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,r,n,i,s,a,o,l){const u=th(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,r),h=this.paint.get("fill-extrusion-base").evaluate(t,r),d=[0,0],p=o&&s.elevation,f=s.elevation?s.elevation.exaggeration():1,m=e.tile.getBucket(this);if(m instanceof Sf){const e=m.centroidData.find(e=>l>=e.vertexArrayOffset&&l<e.vertexArrayOffset+e.vertexCount);if(e&&e.flags&ff)return !1;if(p){const e=m.centroidVertexArray,t=l+1;t<e.length&&(d[0]=e.geta_centroid_pos0(t),d[1]=e.geta_centroid_pos1(t));}}if(0===d[0]&&1===d[1])return !1;"globe"===s.projection.name&&(n=Cf([n],[new Me(0,0),new Me(qn,qn)],e.tileID.canonical).map(e=>e.polygon).flat());const y=p?o:null,[g,x]=Yf(s,n,h,c,u,a,y,d,f,s.center.lat,e.tileID.canonical),v=e.queryGeometry;return Wf(g,x,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},building:class extends No{constructor(e,t,r,n){super(e,{layout:Ey||(Ey=new fo({visibility:new co(mo.layout_building.visibility),"building-facade":new ho(mo.layout_building["building-facade"]),"building-facade-floors":new ho(mo.layout_building["building-facade-floors"]),"building-facade-unit-width":new ho(mo.layout_building["building-facade-unit-width"]),"building-facade-window":new ho(mo.layout_building["building-facade-window"]),"building-roof-shape":new ho(mo.layout_building["building-roof-shape"]),"building-height":new ho(mo.layout_building["building-height"]),"building-base":new ho(mo.layout_building["building-base"]),"building-flood-light-wall-radius":new ho(mo.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ho(mo.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ho(mo.layout_building["building-flip-roof-orientation"])})),paint:Cy||(Cy=new fo({"building-opacity":new co(mo.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new co(mo.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new co(mo.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new co(mo.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new co(mo.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new co(mo.paint_building["building-vertical-scale"]),"building-cast-shadows":new co(mo.paint_building["building-cast-shadows"]),"building-color":new ho(mo.paint_building["building-color"]),"building-emissive-strength":new ho(mo.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new co(mo.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new co(mo.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new co(mo.paint_building["building-front-cutoff"]),"building-flood-light-color":new co(mo.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new co(mo.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new co(mo.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(e){return new Fy(e)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return !0}canCastShadows(){return !0}is3D(e){return !0}queryRadius(e){return 0}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){let c=this.layout.get("building-height").evaluate(t,r);const h=this.layout.get("building-base").evaluate(t,r),d=e.tile.getBucket(this).getFootprint(t);if(d){if(0!==d.hiddenFlags)return !1;c=d.height;}const[p,f]=Yf(s,n,h,c,new Me(0,0),a,null,[0,0],1,s.center.lat,e.tileID.canonical),m=e.queryGeometry;return Wf(p,f,m.isPointQuery()?m.screenBounds:m.screenGeometry)}},line:class extends No{constructor(e,t,r,n){const i=ag();super(e,i,t,r,n),i.layout&&(this.layout=new uo(i.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1;}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof ki,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if(lg)return lg;const e=ag();return lg=new og(e.paint.properties["line-width"].specification),lg.useIntegerZoom=!0,lg})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e);}createBucket(e){return new Wy(e)}getProgramIds(){const e=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return "default"!==this.paint.get("line-blend-mode")&&e.push("lineBlendComposite"),e}getDefaultProgramParams(e,t,r){if("lineBlendComposite"===e)return {};const n=ng(this);return {config:new _u(this,{zoom:t,lut:r}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,r=ug(Kc("line-width",this,t),Kc("line-gap-width",this,t)),n=Kc("line-offset",this,t);return r/2+Math.abs(n)+Qc(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,r,n,i,s){if(e.queryGeometry.isAboveHorizon)return !1;const a=eh(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),o=e.pixelToTileUnitsFactor/2*ug(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),l=this.paint.get("line-offset").evaluate(t,r);return l&&(n=function(e,t){const r=[],n=new Me(0,0);for(let i=0;i<e.length;i++){const s=e[i],a=[];for(let e=0;e<s.length;e++){const r=s[e],i=s[e+1],o=0===e?n:r.sub(s[e-1])._unit()._perp(),l=e===s.length-1?n:i.sub(r)._unit()._perp(),u=o._add(l)._unit();u._mult(1/(u.x*l.x+u.y*l.y)),a.push(u._mult(t)._add(r));}r.push(a);}return r}(n,l*e.pixelToTileUnitsFactor)),function(e,t,r){for(let n=0;n<t.length;n++){const i=t[n];if(e.length>=3)for(let t=0;t<i.length;t++)if(Xc(e,i[t]))return !0;if(Oc(e,i,r))return !0}return !1}(a,n,o)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(e){return !this.hasElevatedBuckets||this.layout&&"hd-road-markup"===this.layout.get("line-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("line-elevation-reference")}hasOffscreenPass(){return "default"!==this.paint.get("line-blend-mode")&&0!==this.paint.get("line-opacity").constantOr(1)&&0!==this.paint.get("line-width").constantOr(1)&&"none"!==this.visibility}resize(){this._destroyLineBlendFbo();}_clear(){this._destroyLineBlendFbo();}_destroyLineBlendFbo(){this.lineBlendFbo&&(this.lineBlendFbo.destroy(),this.lineBlendFbo=null),this.lineBlendStencil=null,this.lineBlendDrapeFbo&&(this.lineBlendDrapeFbo.destroy(),this.lineBlendDrapeFbo=null),this.lineBlendDrapeStencil=null;}},symbol:bb,background:class extends No{constructor(e,t,r,n){super(e,{layout:wb||(wb=new fo({visibility:new co(mo.layout_background.visibility)})),paint:_b||(_b=new fo({"background-pitch-alignment":new co(mo.paint_background["background-pitch-alignment"]),"background-color":new co(mo.paint_background["background-color"]),"background-pattern":new co(mo.paint_background["background-pattern"]),"background-opacity":new co(mo.paint_background["background-opacity"]),"background-emissive-strength":new co(mo.paint_background["background-emissive-strength"]),"background-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}getProgramIds(){return [this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,t,r){return {overrideFog:!1}}is3D(e){return "viewport"===this.paint.get("background-pitch-alignment")}},raster:Fb,"raster-particle":Ub,sky:class extends No{constructor(e,t,r,n){super(e,{layout:Eb||(Eb=new fo({visibility:new co(mo.layout_sky.visibility)})),paint:Cb||(Cb=new fo({"sky-type":new co(mo.paint_sky["sky-type"]),"sky-atmosphere-sun":new co(mo.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new co(mo.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new co(mo.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new co(mo.paint_sky["sky-gradient-radius"]),"sky-gradient":new po(mo.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new co(mo.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new co(mo.paint_sky["sky-atmosphere-color"]),"sky-opacity":new co(mo.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp();}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0;}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0);}_updateColorRamp(){this.colorRamp=nd({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return !0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return !1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const r=this.paint.get("sky-atmosphere-sun"),n=!r,i=e.style.light,s=i.properties.get("position");return n&&"viewport"===i.properties.get("anchor")&&Ze("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),n?jb(s.azimuthal,90-s.polar,t):jb(r[0],90-r[1],t)}const r=this.paint.get("sky-gradient-center");return jb(r[0],90-r[1],t)}isSky(){return !0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position");}hasOffscreenPass(){return !0}getProgramIds(){const e=this.paint.get("sky-type");return "atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}},slot:class extends No{constructor(e,t,r,n){super(e,{paint:Rb||(Rb=new fo({}))},t,null);}},model:class extends No{constructor(e,t,r,n){super(e,{layout:Lb||(Lb=new fo({visibility:new co(mo.layout_model.visibility),"model-id":new ho(mo.layout_model["model-id"]),"model-allow-density-reduction":new co(mo.layout_model["model-allow-density-reduction"])})),paint:Ob||(Ob=new fo({"model-opacity":new ho(mo.paint_model["model-opacity"]),"model-rotation":new ho(mo.paint_model["model-rotation"]),"model-scale":new ho(mo.paint_model["model-scale"]),"model-translation":new ho(mo.paint_model["model-translation"]),"model-color":new ho(mo.paint_model["model-color"]),"model-color-mix-intensity":new ho(mo.paint_model["model-color-mix-intensity"]),"model-type":new co(mo.paint_model["model-type"]),"model-cast-shadows":new co(mo.paint_model["model-cast-shadows"]),"model-receive-shadows":new co(mo.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new co(mo.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new ho(mo.paint_model["model-emissive-strength"]),"model-roughness":new ho(mo.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new ho(mo.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new co(mo.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new co(mo.paint_model["model-front-cutoff"]),"model-elevation-reference":new co(mo.paint_model["model-elevation-reference"]),"model-ignore-line-cutout":new co(mo.paint_model["model-ignore-line-cutout"]),"model-color-use-theme":new ho({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this.layer=e,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(e){return new Xb(e)}getProgramIds(){return ["model"]}is3D(e){return !0}hasShadowPass(){return !0}canCastShadows(){return !0}hasLightBeamPass(){return !0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(e){return e instanceof tw?8191:0}queryRenderedFeatures(e,t,r){const n=t.getSource();if(!(n&&n instanceof ow))return {};const i=n,s={};s[this.id]=[];const a=s[this.id];let o=0;for(const n of i.models){const i=t.getFeatureState(this.sourceLayer,n.id),s={type:"Unknown",id:n.id,properties:n.featureProperties},l=this.paint.get("model-rotation").evaluate(s,i),u=this.paint.get("model-scale").evaluate(s,i),c=this.paint.get("model-translation").evaluate(s,i),d=this.paint.get("model-elevation-reference");let p=[];Km(p,n,r,n.position,l,u,c,"ground"===d,"ground"===d,!1),"globe"===r.projection.name&&(p=Zm(p,r));const f=h([],r.projMatrix,p),m=Wm(e.isPointQuery()?e.screenBounds:e.screenGeometry,r,f,n.aabb);if(null!=m){const e=new aw(void 0,0,0,0,n.id);e.layer=this.layer,e.properties=structuredClone(n.featureProperties),e.properties.layer=this.id,e.properties.uri=n.uri,e.properties.orientation=n.orientation,e.sourceLayer=this.sourceLayer,e.geometry={type:"Point",coordinates:[n.position.lng,n.position.lat]},e.state=i,e.source=this.source,a.push({featureIndex:o,feature:e,intersectionZ:m});}++o;}return s}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){if(!this.modelManager)return !1;const c=this.modelManager,d=e.tile.getBucket(this);if(!(d&&d instanceof Xb))return !1;for(const r in d.instancesPerModel){const n=d.instancesPerModel[r],i=void 0!==t.id?t.id:t.properties&&t.properties.hasOwnProperty("id")?t.properties.id:void 0;if(n.idToFeaturesIndex.hasOwnProperty(i)){const t=n.features[n.idToFeaturesIndex[i]],a=c.getModel(r,u||this.scope);if(!a)return !1;let o=[];const l=new Lu(0,0),p=d.canonical;let f=Number.MAX_VALUE;for(let r=0;r<t.instancedDataCount;++r){const i=16*(t.instancedDataOffset+r),u=n.instancedDataArray.float32,c=[u[i+4],u[i+5],u[i+6]];lw(p,l,Math.floor(u[i]),Math.floor(u[i+1])),Km(o,a,s,l,t.rotation,t.scale,c,!1,!1,!1),"globe"===s.projection.name&&(o=Zm(o,s));const d=h([],s.projMatrix,o),m=e.queryGeometry,y=Wm(m.isPointQuery()?m.screenBounds:m.screenGeometry,s,d,a.aabb);null!=y&&(f=Math.min(y,f));}return f!==Number.MAX_VALUE&&f}}return !1}_handleOverridablePaintPropertyUpdate(e,t,r){return !(!this.layout||t.isDataDriven()||r.isDataDriven()||"model-color"!==e&&"model-color-mix-intensity"!==e&&"model-rotation"!==e&&"model-scale"!==e&&"model-translation"!==e&&"model-emissive-strength"!==e)}_isPropertyZoomDependent(e){const t=this._transitionablePaint._values[e];return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof Xs}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends No{constructor(e,t,r,n){super(e,{layout:kp||(kp=new fo({"clip-layer-types":new co(mo.layout_clip["clip-layer-types"]),"clip-layer-scope":new co(mo.layout_clip["clip-layer-scope"]),visibility:new co(mo.layout_clip.visibility)})),paint:Fp||(Fp=new fo({}))},t,r,n);}recalculate(e,t){super.recalculate(e,t);}createBucket(e){return new Ep(e)}is3D(e){return !0}}};class hw{constructor(e){this._callback=e,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(){this._channel=void 0,this._callback=()=>{};}}class dw{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const r=e[t];this._stringToNumber[r]=t,this._numberToString[t]=r;}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}class pw{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ea(qn,16,0),this.featureIndexArray=new Ul,this.promoteId=t,this.is3DTile=!1,this.serializedLayersCache=new Map;}insert(e,t,r,n,i,s=0,a=0){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i,s);const l=this.grid;for(let e=0;e<t.length;e++){const r=t[e],n=[1/0,1/0,-1/0,-1/0];for(let e=0;e<r.length;e++){const t=r[e];n[0]=Math.min(n[0],t.x),n[1]=Math.min(n[1],t.y),n[2]=Math.max(n[2],t.x),n[3]=Math.max(n[3],t.y);}0!==a&&(n[0]-=a,n[1]-=a,n[2]+=a,n[3]+=a),n[0]<qn&&n[1]<qn&&n[2]>=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new pc(new Dg(this.rawTileData)).layers,this.sourceLayerCoder=new dw(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[];}return this.vtLayers}query(e,t){const{tilespaceGeometry:r,transform:n,tileTransform:i,pixelPosMatrix:s,availableImages:a,worldview:o}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,u=r.bufferedTilespaceBounds,c=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(e,t,n,i)=>Zc(r.bufferedTilespaceGeometry,e-l,t-l,n+l,i+l));c.sort(mw);let h=null;n.elevation&&c.length>0&&(h=Zb.create(n.elevation,this.tileID));const d={};let p;for(let l=0;l<c.length;l++){const u=c[l];if(u===p)continue;p=u;const f=this.featureIndexArray.get(u);let m=null;this.is3DTile?this.loadMatchingModelFeature(d,f,e,r,n,o):this.loadMatchingFeature(d,f,e,a,o,(e,a,o,l=0)=>(m||(m=ac(e,this.tileID.canonical,i)),a.queryIntersectsFeature(r,e,o,m,this.z,n,s,h,l,t.scope)));}return d}loadMatchingFeature(e,t,r,n,i,s){const{featureIndex:a,bucketIndex:o,sourceLayerIndex:l,layoutVertexArrayOffset:u}=t,c=this.bucketLayerIDs[o],h=r.layers,d=Object.keys(h);if(d.length&&!He(d,c))return;const p=r.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(a),y=this.getId(m,f);for(let t=0;t<c.length;t++){const r=c[t];if(!h[r])continue;const{styleLayer:o,targets:l}=h[r];let d={};void 0!==y&&(d=p.getFeatureState(o.sourceLayer,y));const f=!s||s(m,o,d,u);if(!f)continue;const g=new aw(m,this.z,this.x,this.y,y);g.tile=this.tileID.canonical,g.state=d;let x=this.serializedLayersCache.get(r);x||(x=o.serialize(),x.id=r,this.serializedLayersCache.set(r,x)),g.source=x.source,g.sourceLayer=x["source-layer"],g.layer=Object.assign({},x),g.layer.paint=fw(x.paint,o.paint,m,d,n),g.layer.layout=fw(x.layout,o.layout,m,d,n);let v=!1;for(const e of l){this.updateFeatureProperties(g,e);const{filter:t}=e;if(t)if(m.properties=g.properties,t.needGeometry){const e=oc(m,!0);if(!t.filter(new to(this.tileID.overscaledZ,{worldview:i}),e,this.tileID.canonical))continue}else if(!t.filter(new to(this.tileID.overscaledZ,{worldview:i}),m))continue;v=!0,e.targetId&&this.addFeatureVariant(g,e);}v&&this.appendToResult(e,r,a,g,f);}}loadMatchingModelFeature(e,t,r,n,i,s){const{featureIndex:a,bucketIndex:o}=t,l=this.bucketLayerIDs[o],u=r.layers,c=Object.keys(u);if(!c.length||He(c,l))for(let t=0;t<l.length;t++){const o=l[t],{styleLayer:c,targets:h}=u[o];if("model"!==c.type)continue;const d=n.tile,p=d.getBucket(c);if(!(p&&p instanceof tw))continue;const f=uw(p,a,n,i);if(!f)continue;const{z:m,x:y,y:g}=d.tileID.canonical,{feature:x,intersectionZ:v,position:b}=f;let w={};void 0!==x.id&&(w=r.sourceCache.getFeatureState(c.sourceLayer,x.id));const _=new aw({},m,y,g,x.id);_.tile=this.tileID.canonical,_.state=w,_.properties=x.properties,_.geometry={type:"Point",coordinates:[b.lng,b.lat]};let A=this.serializedLayersCache.get(o);A||(A=c.serialize(),A.id=o,this.serializedLayersCache.set(o,A)),_.source=A.source,_.sourceLayer=A["source-layer"],_.layer=Object.assign({},A);let I=!1;for(const e of h){this.updateFeatureProperties(_,e);const{filter:t}=e;if(t)if(x.properties=_.properties,t.needGeometry){if(!t.filter(new to(this.tileID.overscaledZ,{worldview:s}),x,this.tileID.canonical))continue}else if(!t.filter(new to(this.tileID.overscaledZ,{worldview:s}),x))continue;I=!0,e.targetId&&this.addFeatureVariant(_,e);}I&&this.appendToResult(e,o,a,_,v);}}updateFeatureProperties(e,t,r){if(t.properties){const n={};for(const i in t.properties){const s=t.properties[i].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,r);null!=s&&(n[i]=s);}e.properties=n;}}addFeatureVariant(e,t,r){const n={target:t.target,namespace:t.namespace,uniqueFeatureID:t.uniqueFeatureID};t.properties&&(n.properties=e.properties),e.variants=e.variants||{},e.variants[t.targetId]=e.variants[t.targetId]||[],e.variants[t.targetId].push(n);}appendToResult(e,t,r,n,i){let s=e[t];void 0===s&&(s=e[t]=[]),s.push({featureIndex:r,feature:n,intersectionZ:i});}lookupSymbolFeatures(e,t,r,n,i,s){const a={};this.loadVTLayers();for(const o of e)this.loadMatchingFeature(a,{bucketIndex:t,sourceLayerIndex:r,featureIndex:o,layoutVertexArrayOffset:0},n,i,s);return a}loadFeature(e){const{featureIndex:t,sourceLayerIndex:r}=e;this.loadVTLayers();const n=this.sourceLayerCoder.decode(r),i=this.vtFeatures[n];if(i[t])return i[t];const s=this.vtLayers[n].feature(t);return i[t]=s,s}hasLayer(e){for(const t of this.bucketLayerIDs)for(const r of t)if(e===r)return !0;return !1}getId(e,t){let r=e.id;if(this.promoteId){const n=Array.isArray(this.promoteId)||"object"!=typeof this.promoteId?this.promoteId:this.promoteId[t];if(null!=n)if(Array.isArray(n)){if(!this.promoteIdExpression){const e=qs(n);if("success"!==e.result){const t=e.value.map(e=>`${e.key}: ${e.message}`).join(", ");return void Ze(`Failed to create expression for promoteId: ${t}`)}this.promoteIdExpression=e.value;}r=this.promoteIdExpression.evaluate({zoom:0},e);}else r=e.properties[n];"boolean"==typeof r&&(r=Number(r));}return r}}function fw(e,t,r,n,i){return Ge(e,(e,s)=>{const a=t instanceof uo?t.get(s):null;return a&&a.evaluate?a.evaluate(r,n,void 0,i):a})}function mw(e,t){return t-e}function yw(e,t){const r={};if(!t)return r;for(const n of e){const e=n.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)r[t.fqid]=n;}}return r}ra(pw,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const gw=32,xw=33,vw=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,r=0,n=0,i=0,s=0,a=0,o=0;for(1&t?i=s=a=gw:r=n=o=gw;(t>>=1)>1;){const e=r+i>>1,l=n+s>>1;1&t?(i=r,s=n,r=a,n=o):(r=i,n=s,i=a,s=o),a=e,o=l;}const l=4*e;vw[l+0]=r,vw[l+1]=n,vw[l+2]=i,vw[l+3]=s;}const bw=new Uint16Array(2178),ww=new Uint8Array(1089),_w=new Uint16Array(1089);function Aw(e){return 0===e?-.03125:32===e?.03125:0}const Iw={Other:0,Symbol:1,FillExtrusion:2},Mw=(()=>({type:2,extent:qn,loadGeometry:()=>[[new Me(0,0),new Me(8193,0),new Me(8193,8193),new Me(0,8193),new Me(0,0)]]}))();class Sw{constructor(){this.tasks={},this.taskQueue=[],je(["process"],this),this.invoker=new hw(this.process),this.nextId=0;}add(e,t){const r=this.nextId++,n=function({type:e,renderSourceType:t,zoom:r}){r=r||0;const n=t===Iw.Symbol;return "message"===e?0:"maybePrepare"!==e||n?"parseTile"!==e||n?"parseTile"===e&&n?300-r:"maybePrepare"===e&&n?400-r:500:200-r:100-r}(t);if(0===n){try{e();}finally{}return null}return this.tasks[r]={fn:e,metadata:t,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn();}finally{}}pick(){let e=null,t=1/0;for(let r=0;r<this.taskQueue.length;r++){const n=this.tasks[this.taskQueue[r]];n.priority<t&&(t=n.priority,e=r);}if(null===e)return null;const r=this.taskQueue[e];return this.taskQueue.splice(e,1),r}remove(){this.invoker.remove();}}const Bw=new dr(0,0,0);function Pw(e,t,r){1===e&&t.icons.push(function(e,t){return function(e){if(e.usvg_tree.height||(e.usvg_tree.height=e.usvg_tree.width),!e.metadata)return e;const{metadata:t}=e;if(t.content_area){const{content_area:r}=t;null==r.left&&(r.left=0),null==r.top&&(r.top=r.left),null==r.width&&(r.width=e.usvg_tree.width),null==r.height&&(r.height=r.width);}if(t.text_placeholder){const{text_placeholder:e}=t;null==e.top&&(e.top=e.left),null==e.height&&(e.height=e.width);}return t.stretch_x&&t.stretch_x.length&&Tw(t,"x"),t.stretch_y&&t.stretch_y.length&&Tw(t,"y"),e}(e.readFields(zw,{name:void 0},t))}(r,r.readVarint()+r.pos));}function Tw(e,t){const r=[],n=e[`stretch_${t}`];let i=null;for(let e=0;e<n.length;e++)null===i?i=0===r.length?n[0]:r[r.length-1][1]+n[e]:(r.push([i,i+n[e]]),i=null);e[`stretch_${t}_areas`]=r;}function zw(e,t,r){1===e?t.name=r.readString():2===e?t.metadata=function(e,t){return e.readFields(kw,{stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]},t)}(r,r.readVarint()+r.pos):3===e&&(t.usvg_tree=function(e,t){return e.readFields(Ew,{width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[]},t)}(r,r.readVarint()+r.pos),t.data="usvg_tree");}function kw(e,t,r){1===e?t.stretch_x=r.readPackedVarint():2===e?t.stretch_y=r.readPackedVarint():3===e?t.content_area=Fw(r,r.readVarint()+r.pos):4===e?t.variables.push(function(e,t){return e.readFields(Dw,{name:void 0},t)}(r,r.readVarint()+r.pos)):5===e&&(t.text_placeholder=Fw(r,r.readVarint()+r.pos));}function Fw(e,t){return e.readFields(Vw,{},t)}function Vw(e,t,r){1===e?t.left=r.readVarint():2===e?t.width=r.readVarint():3===e?t.top=r.readVarint():4===e&&(t.height=r.readVarint());}function Dw(e,t,r){1===e?t.name=r.readString():2===e&&(t.rgb_color=Gw(r.readVarint()),t.value="rgb_color");}function Ew(e,t,r){1===e?t.width=t.height=r.readVarint():2===e?t.height=r.readVarint():3===e?t.children.push(Cw(r,r.readVarint()+r.pos)):4===e?t.linear_gradients.push(function(e,t){return e.readFields(qw,{spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0},t)}(r,r.readVarint()+r.pos)):5===e?t.radial_gradients.push(function(e,t){return e.readFields(Zw,{spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0},t)}(r,r.readVarint()+r.pos)):7===e?t.clip_paths.push(function(e,t){return e.readFields(Ww,{children:[]},t)}(r,r.readVarint()+r.pos)):8===e&&t.masks.push(function(e,t){const r=e.readFields(Yw,{left:0,width:20,mask_type:1,children:[]},t);return null==r.height&&(r.height=r.width),null==r.top&&(r.top=r.left),r}(r,r.readVarint()+r.pos));}function Cw(e,t){return e.readFields(Rw,{},t)}function Rw(e,t,r){1===e?(t.group=function(e,t){return e.readFields(Lw,{opacity:255,children:[]},t)}(r,r.readVarint()+r.pos),t.node="group"):2===e&&(t.path=function(e,t){return e.readFields(Nw,{paint_order:1,commands:[],step:1,diffs:[],rule:1},t)}(r,r.readVarint()+r.pos),t.node="path");}function Lw(e,t,r){1===e?t.transform=Ow(r,r.readVarint()+r.pos):2===e?t.opacity=r.readVarint():5===e?t.clip_path_idx=r.readVarint():6===e?t.mask_idx=r.readVarint():7===e&&t.children.push(Cw(r,r.readVarint()+r.pos));}function Ow(e,t){return e.readFields(Uw,{sx:1,ky:0,kx:0,sy:1,tx:0,ty:0},t)}function Uw(e,t,r){1===e?t.sx=r.readFloat():2===e?t.ky=r.readFloat():3===e?t.kx=r.readFloat():4===e?t.sy=r.readFloat():5===e?t.tx=r.readFloat():6===e&&(t.ty=r.readFloat());}function Nw(e,t,r){1===e?t.fill=function(e,t){return e.readFields(jw,{rgb_color:Bw,paint:"rgb_color",opacity:255},t)}(r,r.readVarint()+r.pos):2===e?t.stroke=function(e,t){return e.readFields($w,{rgb_color:Bw,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1},t)}(r,r.readVarint()+r.pos):3===e?t.paint_order=r.readVarint():5===e?r.readPackedVarint(t.commands):6===e?t.step=r.readFloat():7===e?r.readPackedSVarint(t.diffs):8===e&&(t.rule=r.readVarint());}function jw(e,t,r){1===e?(t.rgb_color=Gw(r.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=r.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=r.readVarint(),t.paint="radial_gradient_idx"):5===e&&(t.opacity=r.readVarint());}function Gw(e){return new dr((e>>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function $w(e,t,r){1===e?(t.rgb_color=Gw(r.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=r.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=r.readVarint(),t.paint="radial_gradient_idx"):5===e?r.readPackedFloat(t.dasharray):6===e?t.dashoffset=r.readFloat():7===e?t.miterlimit=r.readFloat():8===e?t.opacity=r.readVarint():9===e?t.width=r.readFloat():10===e?t.linecap=r.readVarint():11===e&&(t.linejoin=r.readVarint());}function qw(e,t,r){1===e?t.transform=Ow(r,r.readVarint()+r.pos):2===e?t.spread_method=r.readVarint():3===e?t.stops.push(Hw(r,r.readVarint()+r.pos)):4===e?t.x1=r.readFloat():5===e?t.y1=r.readFloat():6===e?t.x2=r.readFloat():7===e&&(t.y2=r.readFloat());}function Hw(e,t){return e.readFields(Xw,{offset:0,opacity:255,rgb_color:Bw},t)}function Xw(e,t,r){1===e?t.offset=r.readFloat():2===e?t.opacity=r.readVarint():3===e&&(t.rgb_color=Gw(r.readVarint()));}function Zw(e,t,r){1===e?t.transform=Ow(r,r.readVarint()+r.pos):2===e?t.spread_method=r.readVarint():3===e?t.stops.push(Hw(r,r.readVarint()+r.pos)):4===e?t.cx=r.readFloat():5===e?t.cy=r.readFloat():6===e?t.r=r.readFloat():7===e?t.fx=r.readFloat():8===e?t.fy=r.readFloat():9===e&&(t.fr=r.readFloat());}function Ww(e,t,r){1===e?t.transform=Ow(r,r.readVarint()+r.pos):2===e?t.clip_path_idx=r.readVarint():3===e&&t.children.push(Cw(r,r.readVarint()+r.pos));}function Yw(e,t,r){1===e?t.left=t.top=r.readFloat():2===e?t.width=t.height=r.readFloat():3===e?t.top=r.readFloat():4===e?t.height=r.readFloat():5===e?t.mask_type=r.readVarint():6===e?t.mask_idx=r.readVarint():7===e&&t.children.push(Cw(r,r.readVarint()+r.pos));}class Jw{static calculate(e={},t=[]){const r=new Map,n=new Map;if(0===Object.keys(e).length)return r;t.forEach(e=>{n.set(e.name,e.rgb_color||new dr(0,0,0));});for(const[t,i]of Object.entries(e))n.has(t)?r.set(n.get(t).toString(),i):console.warn(`Ignoring unknown image variable "${t}"`);return r}}function Kw(e,t=255,r){const n=t/255,i=e.toString(),s=r.has(i)?r.get(i).clone():e.clone();return s.a*=n,s.toString()}function Qw(e,t){if(!bt()){const r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}let e_,t_=null;function r_(e,t,r,n,i){for(const s of n.children)n_(e,t,r,s,i);}function n_(e,t,r,n,i){n.group?(e.save(),function(e,t,r,n,i){const s=null!=n.mask_idx?r.masks[n.mask_idx]:null,a=null!=n.clip_path_idx?r.clip_paths[n.clip_path_idx]:null;if(n.transform&&(t=d_(n.transform).preMultiplySelf(t)),!function(e,t,r){return 255!==e.opacity||t||r}(n,null!=a,null!=s))return void r_(e,t,r,n,i);const o=Qw(e.canvas.width,e.canvas.height),l=o.getContext("2d");r_(l,t,r,n,i),a&&c_(l,t,r,a),s&&h_(l,t,r,s,i),e.globalAlpha=n.opacity/255,e.drawImage(o,0,0);}(e,t,r,n.group,i),e.restore()):n.path&&(e.save(),function(e,t,r,n,i){e.setTransform(t),1===n.paint_order?(i_(e,r,n,i),a_(e,r,n,i)):(a_(e,r,n,i),i_(e,r,n,i));}(e,t,r,n.path,i),e.restore());}function i_(e,t,r,n){const i=r.fill;if(!i)return;const s=i.opacity/255;switch(e.save(),e.beginPath(),p_(r,e),i.paint){case "rgb_color":e.fillStyle=Kw(i.rgb_color,i.opacity,n);break;case "linear_gradient_idx":{const r=t.linear_gradients[i.linear_gradient_idx];r.transform&&e.setTransform(d_(r.transform).preMultiplySelf(e.getTransform())),e.fillStyle=o_(e,r,s,n);break}case "radial_gradient_idx":{const r=t.radial_gradients[i.radial_gradient_idx];r.transform&&e.setTransform(d_(r.transform).preMultiplySelf(e.getTransform())),e.fillStyle=l_(e,r,s,n);}}e.fill(s_(r)),e.restore();}function s_(e){return 1===e.rule?"nonzero":2===e.rule?"evenodd":void 0}function a_(e,t,r,n){const i=r.stroke;if(!i)return;const s=f_(r);e.lineWidth=i.width,e.miterLimit=i.miterlimit,e.setLineDash(i.dasharray),e.lineDashOffset=i.dashoffset;const a=i.opacity/255;switch(i.paint){case "rgb_color":e.strokeStyle=Kw(i.rgb_color,i.opacity,n);break;case "linear_gradient_idx":e.strokeStyle=o_(e,t.linear_gradients[i.linear_gradient_idx],a,n,!0);break;case "radial_gradient_idx":e.strokeStyle=l_(e,t.radial_gradients[i.radial_gradient_idx],a,n,!0);}switch(i.linejoin){case 2:case 1:e.lineJoin="miter";break;case 3:e.lineJoin="round";break;case 4:e.lineJoin="bevel";}switch(i.linecap){case 1:e.lineCap="butt";break;case 2:e.lineCap="round";break;case 3:e.lineCap="square";}e.stroke(s);}function o_(e,t,r,n,i=!1){if(1===t.stops.length){const e=t.stops[0];return Kw(e.rgb_color,e.opacity*r,n)}const{x1:s,y1:a,x2:o,y2:l}=t;let u=new DOMPoint(s,a),c=new DOMPoint(o,l);if(i){const e=d_(t.transform);u=e.transformPoint(u),c=e.transformPoint(c);}const h=e.createLinearGradient(u.x,u.y,c.x,c.y);for(const e of t.stops)h.addColorStop(e.offset,Kw(e.rgb_color,e.opacity*r,n));return h}function l_(e,t,r,n,i=!1){if(1===t.stops.length){const e=t.stops[0];return Kw(e.rgb_color,e.opacity*r,n)}const s=d_(t.transform),{fx:a,fy:o,fr:l,cx:u,cy:c,r:h}=t;let d=new DOMPoint(a,o),p=new DOMPoint(u,c),f=l,m=h;if(i){d=s.transformPoint(d),p=s.transformPoint(p);const e=(s.a+s.d)/2;f=l*e,m=t.r*e;}const y=e.createRadialGradient(d.x,d.y,f,p.x,p.y,m);for(const e of t.stops)y.addColorStop(e.offset,Kw(e.rgb_color,e.opacity*r,n));return y}function u_(e,t,r,n){const i=n.transform?d_(n.transform).preMultiplySelf(t):t,s=Qw(e.canvas.width,e.canvas.height),a=s.getContext("2d");for(const e of n.children)if(e.group)u_(a,i,r,e.group);else if(e.path){const t=e.path,r=new Path2D;r.addPath(f_(t),i),a.fill(r,s_(t));}const o=null!=n.clip_path_idx?r.clip_paths[n.clip_path_idx]:null;o&&c_(a,i,r,o),e.globalCompositeOperation="source-over",e.drawImage(s,0,0);}function c_(e,t,r,n){const i=Qw(e.canvas.width,e.canvas.height);u_(i.getContext("2d"),t,r,n),e.globalCompositeOperation="destination-in",e.drawImage(i,0,0);}function h_(e,t,r,n,i){if(0===n.children.length)return;const s=null!=n.mask_idx?r.masks[n.mask_idx]:null;s&&h_(e,t,r,s,i);const a=e.canvas.width,o=e.canvas.height,l=Qw(a,o),u=l.getContext("2d"),c=n.width,h=n.height,d=n.left,p=n.top,f=new Path2D,m=new Path2D;m.rect(d,p,c,h),f.addPath(m,t),u.clip(f);for(const e of n.children)n_(u,t,r,e,i);const y=u.getImageData(0,0,a,o),g=y.data;if(1===n.mask_type)for(let e=0;e<g.length;e+=4)g[e+3]=g[e+3]/255*(.2126*g[e]+.7152*g[e+1]+.0722*g[e+2]);u.putImageData(y,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l,0,0);}function d_(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function p_(e,t){const r=e.step;let n=e.diffs[0]*r,i=e.diffs[1]*r;t.moveTo(n,i);for(let s=0,a=2;s<e.commands.length;s++)switch(e.commands[s]){case 1:n+=e.diffs[a++]*r,i+=e.diffs[a++]*r,t.moveTo(n,i);break;case 2:n+=e.diffs[a++]*r,i+=e.diffs[a++]*r,t.lineTo(n,i);break;case 3:{const s=n+e.diffs[a++]*r,o=i+e.diffs[a++]*r;n=s+e.diffs[a++]*r,i=o+e.diffs[a++]*r,t.quadraticCurveTo(s,o,n,i);break}case 4:{const s=n+e.diffs[a++]*r,o=i+e.diffs[a++]*r,l=s+e.diffs[a++]*r,u=o+e.diffs[a++]*r;n=l+e.diffs[a++]*r,i=u+e.diffs[a++]*r,t.bezierCurveTo(s,o,l,u,n,i);break}case 5:t.closePath();break;default:m_();}return t}function f_(e){return p_(e,new Path2D)}function m_(e,t){}class y_{constructor(e){this.capacity=e,this.cache=new Map;}get(e){if(!this.cache.has(e))return;const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){this.cache.has(e)?this.cache.delete(e):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(e,t);}delete(e){this.cache.delete(e);}}ra(y_,"LRUCache");class g_{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map;}static _getImage(e){return new td(e,e.data)}getFromCache(e,t,r){return this.cacheMap.has(r)||this.cacheMap.set(r,new y_(150)),this.cacheMap.get(r).get(Fo(e.toString(),t))}setInCache(e,t,r,n){this.cacheDependenciesMap.has(n)||this.cacheDependenciesMap.set(n,new Map),this.cacheMap.has(n)||this.cacheMap.set(n,new y_(150));const i=this.cacheDependenciesMap.get(n),s=Fo(e.id.toString(),r);i.get(s)||i.set(s,new Set);const a=this.cacheMap.get(n),o=e.toString();i.get(s).add(o),a.put(Fo(e.toString(),r),t);}removeImagesFromCacheByIds(e,t,r=0){if(!this.cacheMap.has(r)||!this.cacheDependenciesMap.has(r))return;const n=this.cacheMap.get(r),i=this.cacheDependenciesMap.get(r);for(const r of e){const e=Fo(r.toString(),t);if(i.has(e)){for(const t of i.get(e))n.delete(t);i.delete(e);}}}rasterize(e,t,r,n){const i=this.getFromCache(e,r,n);if(i)return i.clone();const s=function(e,t){const r=Jw.calculate(t.params,e.metadata?e.metadata.variables:[]),n=e.usvg_tree,i=n.width,s=n.height,a=Math.max(1,Math.round(i*t.sx)),o=Math.max(1,Math.round(s*t.sy)),l=new DOMMatrix([a/i,0,0,o/s,0,0]);return null===t_&&(t_=Qw(10,10),e_=t_.getContext("2d",{willReadFrequently:!0})),t_.width=a,t_.height=o,r_(e_,l,n,n,r),e_.getImageData(0,0,a,o)}(t.icon,e),a=g_._getImage(s);return this.setInCache(e,a,r,n),a.clone()}}class x_{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(e,t){const r=this.toIdx(e,t);return {min:this.minimums[r],max:this.maximums[r]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function v_(e,t,r,n){let i=0,s=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(n[a])<1e-15){if(r[a]<e[a]||r[a]>t[a])return null}else {const o=1/n[a];let l=(e[a]-r[a])*o,u=(t[a]-r[a])*o;if(l>u){const e=l;l=u,u=e;}if(l>i&&(i=l),u<s&&(s=u),i>s)return null}return i}function b_(e,t,r,n,i,s,a,o,l,u,c){const h=n-e,d=i-t,p=s-r,f=a-e,m=o-t,y=l-r,g=c[1]*y-c[2]*m,x=c[2]*f-c[0]*y,v=c[0]*m-c[1]*f,b=h*g+d*x+p*v;if(Math.abs(b)<1e-15)return null;const w=1/b,_=u[0]-e,A=u[1]-t,I=u[2]-r,M=(_*g+A*x+I*v)*w;if(M<0||M>1)return null;const S=A*p-I*d,B=I*h-_*p,P=_*d-A*h,T=(c[0]*S+c[1]*B+c[2]*P)*w;return T<0||M+T>1?null:(f*S+m*B+y*P)*w}function w_(e,t,r){return (e-t)/(r-t)}function __(e,t,r,n,i,s,a,o,l){const u=1<<r,c=s-n,h=a-i,d=(e+1)/u*c+n,p=(t+0)/u*h+i,f=(t+1)/u*h+i;o[0]=(e+0)/u*c+n,o[1]=p,l[0]=d,l[1]=f;}class A_{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=Math.ceil(Math.log2(e.dim/8)),r=[];let n=Math.ceil(Math.pow(2,t));const i=1/n,s=(e,t,r,n,i)=>{const s=n?1:0,a=(e+1)*r-s,o=t*r,l=(t+1)*r-s;i[0]=e*r,i[1]=o,i[2]=a,i[3]=l;};let a=new x_(n);const o=[];for(let t=0;t<n*n;t++){s(t%n,Math.floor(t/n),i,!1,o);const r=M_(o[0],o[1],e),l=M_(o[2],o[1],e),u=M_(o[2],o[3],e),c=M_(o[0],o[3],e);a.minimums.push(Math.min(r,l,u,c)),a.maximums.push(Math.max(r,l,u,c)),a.leaves.push(1);}for(r.push(a),n/=2;n>=1;n/=2){const e=r[r.length-1];a=new x_(n);for(let t=0;t<n*n;t++){s(t%n,Math.floor(t/n),2,!0,o);const r=e.getElevation(o[0],o[1]),i=e.getElevation(o[2],o[1]),l=e.getElevation(o[2],o[3]),u=e.getElevation(o[0],o[3]),c=e.isLeaf(o[0],o[1]),h=e.isLeaf(o[2],o[1]),d=e.isLeaf(o[2],o[3]),p=e.isLeaf(o[0],o[3]),f=Math.min(r.min,i.min,l.min,u.min),m=Math.max(r.max,i.max,l.max,u.max),y=c&&h&&d&&p;a.maximums.push(m),a.minimums.push(f),a.leaves.push(m-f<=5&&y?1:0);}r.push(a);}return r}(this.dem),r=t.length-1,n=t[r];this._addNode(n.minimums[0],n.maximums[0],n.leaves[0]),this._construct(t,0,0,r,0);}raycastRoot(e,t,r,n,i,s,a=1){return v_([e,t,-100],[r,n,this.maximums[0]*a],i,s)}raycast(e,t,r,n,i,s,a=1){if(!this.nodeCount)return null;const o=this.raycastRoot(e,t,r,n,i,s,a);if(null==o)return null;const l=[],u=[],c=[],h=[],d=[{idx:0,t:o,nodex:0,nodey:0,depth:0}];for(;d.length>0;){const{idx:o,t:p,nodex:f,nodey:m,depth:y}=d.pop();if(this.leaves[o]){__(f,m,y,e,t,r,n,c,h);const o=1<<y,l=(f+0)/o,u=(f+1)/o,d=(m+0)/o,g=(m+1)/o,x=M_(l,d,this.dem)*a,v=M_(u,d,this.dem)*a,b=M_(u,g,this.dem)*a,w=M_(l,g,this.dem)*a,_=b_(c[0],c[1],x,h[0],c[1],v,h[0],h[1],b,i,s),A=b_(h[0],h[1],b,c[0],h[1],w,c[0],c[1],x,i,s),I=Math.min(null!==_?_:Number.MAX_VALUE,null!==A?A:Number.MAX_VALUE);if(I!==Number.MAX_VALUE)return I;{const e=V([],i,s,p);if(I_(x,v,w,b,w_(e[0],c[0],h[0]),w_(e[1],c[1],h[1]))>=e[2])return p}continue}let g=0;for(let d=0;d<this._siblingOffset.length;d++){__((f<<1)+this._siblingOffset[d][0],(m<<1)+this._siblingOffset[d][1],y+1,e,t,r,n,c,h),c[2]=-100,h[2]=this.maximums[this.childOffsets[o]+d]*a;const p=v_(c,h,i,s);if(null!=p){const e=p;l[d]=e;let t=!1;for(let r=0;r<g&&!t;r++)e>=l[u[r]]&&(u.splice(r,0,d),t=!0);t||(u[g]=d),g++;}}for(let e=0;e<g;e++){const t=u[e];d.push({idx:this.childOffsets[o]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:y+1});}}return null}_addNode(e,t,r){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(r),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,r,n,i){if(1===e[n].isLeaf(t,r))return;this.childOffsets[i]||(this.childOffsets[i]=this.nodeCount);const s=n-1,a=e[s];let o=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const n=2*t+this._siblingOffset[e][0],i=2*r+this._siblingOffset[e][1],s=a.getElevation(n,i),u=a.isLeaf(n,i),c=this._addNode(s.min,s.max,u);u&&(o|=1<<e),l||(l=c);}for(let n=0;n<this._siblingOffset.length;n++)o&1<<n||this._construct(e,2*t+this._siblingOffset[n][0],2*r+this._siblingOffset[n][1],s,l+n);}}function I_(e,t,r,n,i,s){return yr(yr(e,r,s),yr(t,n,s),i)}function M_(e,t,r){const n=r.dim,i=Ee(e*n-.5,0,n-1),s=Ee(t*n-.5,0,n-1),a=Math.floor(i),o=Math.floor(s),l=Math.min(a+1,n-1),u=Math.min(o+1,n-1);return I_(r.get(a,o),r.get(l,o),r.get(a,u),r.get(l,u),i-a,s-o)}const S_={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function B_(e,t,r){return (256*e*256+256*t+r)/10-1e4}function P_(e,t,r){return 256*e+t+r/256-32768}class T_{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,r,n=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(r&&"mapbox"!==r&&"terrarium"!==r)return void Ze(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const i=this.dim=t.height-2,s=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=n,this._modifiedForSources={},!n){for(let e=0;e<i;e++)s[this._idx(-1,e)]=s[this._idx(0,e)],s[this._idx(i,e)]=s[this._idx(i-1,e)],s[this._idx(e,-1)]=s[this._idx(e,0)],s[this._idx(e,i)]=s[this._idx(e,i-1)];s[this._idx(-1,-1)]=s[this._idx(0,0)],s[this._idx(i,-1)]=s[this._idx(i-1,0)],s[this._idx(-1,i)]=s[this._idx(0,i-1)],s[this._idx(i,i)]=s[this._idx(i-1,i-1)];}const a="terrarium"===r?P_:B_;for(let e=0;e<s.length;++e){const t=4*e;this.floatView[e]=a(this.pixels[t],this.pixels[t+1],this.pixels[t+2]);}this._timestamp=wt.now();}_buildQuadTree(){this._tree=new A_(this);}get(e,t,r=!1){r&&(e=Ee(e,-1,this.dim),t=Ee(t,-1,this.dim));const n=this._idx(e,t);return this.floatView[n]}set(e,t,r){const n=this._idx(e,t),i=this.floatView[n];return this.floatView[n]=r,r-i}static getUnpackVector(e){return S_[e]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (t+1)*this.stride+(e+1)}static pack(e,t){const r=[0,0,0,0],n=T_.getUnpackVector(t);let i=Math.floor((e+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new rd({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,i=t*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(t){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=a-1;break;case 1:a=s+1;}const o=-t*this.dim,l=-r*this.dim;for(let t=s;t<a;t++)for(let r=n;r<i;r++){const n=4*this._idx(r,t),i=4*this._idx(r+o,t+l);this.pixels[n+0]=e.pixels[i+0],this.pixels[n+1]=e.pixels[i+1],this.pixels[n+2]=e.pixels[i+2],this.pixels[n+3]=e.pixels[i+3];}}onDeserialize(){this._tree&&(this._tree.dem=this);}}function z_(e,t,r){1===e?t.headerLength=r.readFixed32():2===e?t.x=r.readVarint():3===e?t.y=r.readVarint():4===e?t.z=r.readVarint():5===e&&t.layers.push(function(e,t){return e.readFields(E_,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},t)}(r,r.readVarint()+r.pos));}function k_(e,t,r){1===e?(t.delta_filter=function(e,t){return e.readFields(F_,{blockSize:0},t)}(r,r.readVarint()+r.pos),t.filter="delta_filter"):2===e?(r.readVarint(),t.filter="zigzag_filter"):3===e?(r.readVarint(),t.filter="bitshuffle_filter"):4===e&&(r.readVarint(),t.filter="byteshuffle_filter");}function F_(e,t,r){1===e&&(t.blockSize=r.readVarint());}function V_(e,t,r){1===e?(r.readVarint(),t.codec="gzip_data"):2===e?(r.readVarint(),t.codec="jpeg_image"):3===e?(r.readVarint(),t.codec="webp_image"):4===e&&(r.readVarint(),t.codec="png_image");}function D_(e,t,r){let n=0,i=0;1===e?t.firstByte=r.readFixed64():2===e?t.lastByte=r.readFixed64():3===e?t.filters.push(function(e,t){return e.readFields(k_,{},t)}(r,r.readVarint()+r.pos)):4===e?t.codec=function(e,t){return e.readFields(V_,{},t)}(r,r.readVarint()+r.pos):5===e?i=r.readFloat():6===e?n=r.readFloat():7===e?t.bands.push(r.readString()):8===e?t.offset=r.readDouble():9===e&&(t.scale=r.readDouble()),0===t.offset&&(t.offset=i),0===t.scale&&(t.scale=n);}function E_(e,t,r){1===e?t.version=r.readVarint():2===e?t.name=r.readString():3===e?t.units=r.readString():4===e?t.tileSize=r.readVarint():5===e?t.buffer=r.readVarint():6===e?t.pixelFormat=r.readVarint():7===e&&t.dataIndex.push(function(e,t){return e.readFields(D_,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},t)}(r,r.readVarint()+r.pos));}function C_(e,t,r){if(2===e)!function(e,t,r){e.readFields(R_,r,t);}(r,r.readVarint()+r.pos,t);else if(3===e)throw new Error("Not implemented")}function R_(e,t,r){if(1===e){let e=0;const n=r.readVarint()+r.pos;for(;r.pos<n;)t[e++]=r.readVarint();}}function L_(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let r=t[3];for(let n=2;n>=1;n--){const i=1===n?1:0,s=2===n?1:0;for(let n=0;n<t[0];n++){const a=t[1]*n;for(let n=i;n<t[1];n++){const i=t[2]*(n+a);for(let n=s;n<t[2];n++){const s=t[3]*(n+i);for(let n=0;n<t[3];n++){const t=s+n;e[t]+=e[t-r];}}}}r*=t[n];}return e}function O_(e){for(let t=0,r=e.length;t<r;t++)e[t]=e[t]>>>1^-(1&e[t]);return e}function U_(e,t){switch(t){case "uint32":return e;case "uint16":for(let t=0;t<e.length;t+=2){const r=e[t],n=e[t+1];e[t]=(240&r)>>4|(61440&r)>>8|(240&n)<<4|61440&n,e[t+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return e;case "uint8":for(let t=0;t<e.length;t+=4){const r=e[t],n=e[t+1],i=e[t+2],s=e[t+3];e[t+0]=(192&r)>>6|(192&n)>>4|(192&i)>>2|192&s,e[t+1]=(48&r)>>4|(48&n)>>2|48&i|(48&s)<<2,e[t+2]=(12&r)>>2|12&n|(12&i)<<2|(12&s)<<4,e[t+3]=3&r|(3&n)<<2|(3&i)<<4|(3&s)<<6;}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}ra(T_,"DEMData"),ra(A_,"DemMinMaxQuadTree",{omit:["dem"]});var N_=Uint8Array,j_=Uint16Array,G_=Int32Array,$_=new N_([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),q_=new N_([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),H_=new N_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),X_=function(e,t){for(var r=new j_(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new G_(r[30]);for(n=1;n<30;++n)for(var s=r[n];s<r[n+1];++s)i[s]=s-r[n]<<5|n;return {b:r,r:i}},Z_=X_($_,2),W_=Z_.b,Y_=Z_.r;W_[28]=258,Y_[258]=28;for(var J_=X_(q_,0).b,K_=new j_(32768),Q_=0;Q_<32768;++Q_){var eA=(43690&Q_)>>1|(21845&Q_)<<1;K_[Q_]=((65280&(eA=(61680&(eA=(52428&eA)>>2|(13107&eA)<<2))>>4|(3855&eA)<<4))>>8|(255&eA)<<8)>>1;}var tA=function(e,t,r){for(var n=e.length,i=0,s=new j_(t);i<n;++i)e[i]&&++s[e[i]-1];var a,o=new j_(t);for(i=1;i<t;++i)o[i]=o[i-1]+s[i-1]<<1;a=new j_(1<<t);var l=15-t;for(i=0;i<n;++i)if(e[i])for(var u=i<<4|e[i],c=t-e[i],h=o[e[i]-1]++<<c,d=h|(1<<c)-1;h<=d;++h)a[K_[h]>>l]=u;return a},rA=new N_(288);for(Q_=0;Q_<144;++Q_)rA[Q_]=8;for(Q_=144;Q_<256;++Q_)rA[Q_]=9;for(Q_=256;Q_<280;++Q_)rA[Q_]=7;for(Q_=280;Q_<288;++Q_)rA[Q_]=8;var nA=new N_(32);for(Q_=0;Q_<32;++Q_)nA[Q_]=5;var iA=tA(rA,9),sA=tA(nA,5),aA=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},oA=function(e,t,r){var n=t/8|0;return (e[n]|e[n+1]<<8)>>(7&t)&r},lA=function(e,t){var r=t/8|0;return (e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},uA=function(e){return (e+7)/8|0},cA=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],hA=function(e,t,r){var n=new Error(t||cA[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,hA),!r)throw n;return n},dA=new N_(0);var pA="undefined"!=typeof TextDecoder&&new TextDecoder;try{pA.decode(dA,{stream:!0});}catch(e){}const fA={gzip_data:"gzip"};class mA extends Error{constructor(e){super(e),this.name="MRTError";}}const yA={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},gA={uint32:1,uint16:2,uint8:4},xA={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let vA;class bA{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e;}getLayer(e){const t=this.layers[e];if(!t)throw new mA(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),r=new DataView(e);if(13!==t[0])throw new mA("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),r=this.getHeaderLength(e);if(t.length<r)throw new mA(`Expected header with length >= ${r} but got buffer of length ${t.length}`);const n=new vA(t.subarray(0,r)).readFields(z_,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new mA(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new wA(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],r=this.getLayer(e.layerName);for(let n of e.blockIndices){const i=r.dataIndex[n],s=i.firstByte-e.firstByte,a=i.lastByte-e.firstByte;if(r._blocksInProgress.has(n))continue;const o={layerName:r.name,firstByte:s,lastByte:a,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map(e=>e.filter)};r._blocksInProgress.add(n),t.push(o);}return new _A(t,()=>{t.forEach(e=>r._blocksInProgress.delete(e.blockIndex));},(e,n)=>{if(t.forEach(e=>r._blocksInProgress.delete(e.blockIndex)),e)throw e;n.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e);});})}}class wA{constructor({version:e,name:t,units:r,tileSize:n,pixelFormat:i,buffer:s,dataIndex:a},o){if(this.version=e,1!==this.version)throw new mA(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=r,this.tileSize=n,this.buffer=s,this.pixelFormat=yA[i],this.dataIndex=a,this.bandShape=[n+2*s,n+2*s,gA[this.pixelFormat]],this._decodedBlocks=new y_(o?o.cacheSize:5),this._blocksInProgress=new Set;}get dimension(){return gA[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data);}getBlockForBand(e){let t=0;switch(typeof e){case "string":for(const[r,n]of this.dataIndex.entries()){for(const[i,s]of n.bands.entries())if(s===e)return {bandIndex:t+i,blockIndex:r,blockBandIndex:i};t+=n.bands.length;}break;case "number":for(const[r,n]of this.dataIndex.entries()){if(e>=t&&e<t+n.bands.length)return {bandIndex:e,blockIndex:r,blockBandIndex:e-t};t+=n.bands.length;}break;default:throw new mA(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return {blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let t=1/0,r=-1/0;const n=[],i=new Set;for(const s of e){const{blockIndex:e}=this.getBlockForBand(s);if(e<0)throw new mA(`Invalid band: ${JSON.stringify(s)}`);const a=this.dataIndex[e];n.includes(e)||n.push(e),i.add(e),t=Math.min(t,a.firstByte),r=Math.max(r,a.lastByte);}if(i.size>this.cacheSize)throw new mA(`Number of blocks to decode (${i.size}) exceeds cache size (${this.cacheSize}).`);return {layerName:this.name,firstByte:t,lastByte:r,blockIndices:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:r}=this.getBlockForBand(e);if(t<0)throw new mA(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new mA(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const i=this.dataIndex[t],s=this.bandShape.reduce((e,t)=>e*t,1),a=r*s,o=n.subarray(a,a+s);return {data:o,bytes:new Uint8Array(o.buffer).subarray(o.byteOffset,o.byteOffset+o.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:i.offset,scale:i.scale}}}bA.setPbf=function(e){vA=e;};class _A{constructor(e,t,r){this.tasks=e,this._onCancel=t,this._onComplete=r,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0);}}bA.performDecoding=function(e,t){const r=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:n,lastByte:i,pixelFormat:s,blockShape:a,blockIndex:o,filters:l,codec:u}=e,c=r.subarray(n,i+1),h=new Uint32Array(a[0]*a[1]*a[2]);let d;if("gzip_data"!==u)throw new mA(`Unhandled codec: ${u}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve((a=function(e){31==e[0]&&139==e[1]&&8==e[2]||hA(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(2&t)}(r=e),a+8>r.length&&hA(6,"invalid gzip data"),function(e,t,r,n){var i=e.length;if(!i||t.f&&!t.l)return r||new N_(0);var s=!r,a=s||2!=t.i,o=t.i;s&&(r=new N_(3*i));var l=function(e){var t=r.length;if(e>t){var n=new N_(Math.max(2*t,e));n.set(r),r=n;}},u=t.f||0,c=t.p||0,h=t.b||0,d=t.l,p=t.d,f=t.m,m=t.n,y=8*i;do{if(!d){u=oA(e,c,1);var g=oA(e,c+1,3);if(c+=3,!g){var x=e[(T=uA(c)+4)-4]|e[T-3]<<8,v=T+x;if(v>i){o&&hA(0);break}a&&l(h+x),r.set(e.subarray(T,v),h),t.b=h+=x,t.p=c=8*v,t.f=u;continue}if(1==g)d=iA,p=sA,f=9,m=5;else if(2==g){var b=oA(e,c,31)+257,w=oA(e,c+10,15)+4,_=b+oA(e,c+5,31)+1;c+=14;for(var A=new N_(_),I=new N_(19),M=0;M<w;++M)I[H_[M]]=oA(e,c+3*M,7);c+=3*w;var S=aA(I),B=(1<<S)-1,P=tA(I,S);for(M=0;M<_;){var T,z=P[oA(e,c,B)];if(c+=15&z,(T=z>>4)<16)A[M++]=T;else {var k=0,F=0;for(16==T?(F=3+oA(e,c,3),c+=2,k=A[M-1]):17==T?(F=3+oA(e,c,7),c+=3):18==T&&(F=11+oA(e,c,127),c+=7);F--;)A[M++]=k;}}var V=A.subarray(0,b),D=A.subarray(b);f=aA(V),m=aA(D),d=tA(V,f),p=tA(D,m);}else hA(1);if(c>y){o&&hA(0);break}}a&&l(h+131072);for(var E=(1<<f)-1,C=(1<<m)-1,R=c;;R=c){var L=(k=d[lA(e,c)&E])>>4;if((c+=15&k)>y){o&&hA(0);break}if(k||hA(2),L<256)r[h++]=L;else {if(256==L){R=c,d=null;break}var O=L-254;L>264&&(O=oA(e,c,(1<<(j=$_[M=L-257]))-1)+W_[M],c+=j);var U=p[lA(e,c)&C],N=U>>4;if(U||hA(3),c+=15&U,D=J_[N],N>3){var j=q_[N];D+=lA(e,c)&(1<<j)-1,c+=j;}if(c>y){o&&hA(0);break}a&&l(h+131072);var G=h+O;if(h<D){var $=0-D,q=Math.min(D,G);for($+h<0&&hA(3);h<q;++h)r[h]=n[$+h];}for(;h<G;++h)r[h]=r[h-D];}}t.l=d,t.p=R,t.b=h,t.f=u,d&&(u=1,t.m=f,t.d=p,t.n=m);}while(!u);return h!=r.length&&s?function(e,t,r){return (null==r||r>e.length)&&(r=e.length),new N_(e.subarray(0,r))}(r,0,h):r.subarray(0,h)}(r.subarray(a,-8),{i:2},new N_(((i=r)[(s=i.length)-4]|i[s-3]<<8|i[s-2]<<16|i[s-1]<<24)>>>0),n)));var r,n,i,s,a;const o=fA[t];if(!o)throw new Error(`Unhandled codec: ${t}`);const l=new globalThis.DecompressionStream(o);return new Response(new Blob([e]).stream().pipeThrough(l)).arrayBuffer().then(e=>new Uint8Array(e))}(c,u).then(e=>(function(e,t){e.readFields(C_,t);}(new vA(e),h),new(0,xA[s])(h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case "delta_filter":L_(e,a);break;case "zigzag_filter":O_(e);break;case "bitshuffle_filter":U_(e,s);break;default:throw new mA(`Unhandled filter "${l[t]}"`)}return {layerName:t,blockIndex:o,data:e}}).catch(e=>{throw e})}))},ra(_A,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),ra(bA,"MapboxRasterTile"),ra(wA,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const AA=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class IA{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,r]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const n=r>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=AA[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new IA(a,s,i,e)}constructor(e,t=64,r=Float64Array,n){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const i=AA.indexOf(this.ArrayType),s=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+o,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+o,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e);}add(e,t){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return MA(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=e&&o<=r&&u>=t&&u<=n&&l.push(i[a]);}continue}const d=h+c>>1,p=s[2*d],f=s[2*d+1];p>=e&&p<=r&&f>=t&&f<=n&&l.push(i[d]),(0===u?e<=p:t<=f)&&(o.push(h),o.push(d-1),o.push(1-u)),(0===u?r>=p:n>=f)&&(o.push(d+1),o.push(c),o.push(1-u));}return l}within(e,t,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)TA(i[2*r],i[2*r+1],e,t)<=l&&o.push(n[r]);continue}const d=h+c>>1,p=i[2*d],f=i[2*d+1];TA(p,f,e,t)<=l&&o.push(n[d]),(0===u?e-r<=p:t-r<=f)&&(a.push(h),a.push(d-1),a.push(1-u)),(0===u?e+r>=p:t+r>=f)&&(a.push(d+1),a.push(c),a.push(1-u));}return o}}function MA(e,t,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;SA(e,t,a,n,i,s),MA(e,t,r,n,a-1,1-s),MA(e,t,r,a+1,i,1-s);}function SA(e,t,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);SA(e,t,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=t[2*r+s];let o=n,l=i;for(BA(e,t,n,r),t[2*i+s]>a&&BA(e,t,n,i);o<l;){for(BA(e,t,o,l),o++,l--;t[2*o+s]<a;)o++;for(;t[2*l+s]>a;)l--;}t[2*n+s]===a?BA(e,t,n,l):(l++,BA(e,t,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function BA(e,t,r,n){PA(e,r,n),PA(t,2*r,2*n),PA(t,2*r+1,2*n+1);}function PA(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function TA(e,t,r,n){const i=e-r,s=t-n;return i*i+s*s}e.$=wi,e.A=class{constructor(e,t,r){this.target=e,this.parent=t,this.mapId=r,this.callbacks={},this.cancelCallbacks={},je(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new Sw;}send(e,t,r,n,i=!1,s){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=s,this.callbacks[a]=r);const o=new Set;return this.target.postMessage({id:a,type:e,hasCallback:!!r,targetMapId:n,mustQueue:i,sourceMapId:this.mapId,data:ia(t,o)},o),{cancel:()=>{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:"<cancel>",targetMapId:n,sourceMapId:this.mapId});}}}receive(e){const t=e.data;if(!t)return;const r=t.id;if(r&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[r];delete this.cancelCallbacks[r],e&&e.cancel();}else if(t.mustQueue||Ke(self)){const e=this.callbacks[r],n=this.scheduler.add(()=>this.processTask(r,t),e&&e.metadata||{type:"message"});n&&(this.cancelCallbacks[r]=n);}else this.processTask(r,t);}processTask(e,t){if(delete this.cancelCallbacks[e],"<response>"===t.type){const r=this.callbacks[e];delete this.callbacks[e],r&&(t.error?r(sa(t.error)):r(null,sa(t.data)));}else {const r=new Set,n=t.hasCallback?(t,n)=>{this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?ia(t):null,data:ia(n,r)},r);}:()=>{},i=sa(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,n);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:r,scope:s}=i;this.parent.getWorkerSource(t.sourceMapId,{type:e[0],source:r,scope:s,uid:0})[e[1]](i,n);}else n(new Error(`Could not find function ${t.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}},e.B=ir,e.C=nr,e.D=Nr,e.E=or,e.F=Fo,e.G=2,e.H=Fx,e.I=lr,e.J=Sx,e.K=en,e.L=yo,e.M=Qr,e.N=rn,e.O=Ds,e.P=Me,e.Q=ks,e.R=Ot,e.S=Vs,e.T=km,e.U=$s,e.V=Gb,e.W=go,e.X=qs,e.Y=Zs,e.Z=_i,e._=bi,e.a=function(e){return lt.API_CDN_URL_REGEX.test(e)},e.a$=Dg,e.a0=un,e.a1=nn,e.a2=tn,e.a3=hr,e.a4=xo,e.a5=class extends Gb{},e.a6=Es,e.a7=Fs,e.a8=mo,e.a9=function(e){const t=e.value;return t?tn(t)?$b(t,!0)?[]:[new Gb(e.key,t,`invalid url "${t}"`)]:[new Gb(e.key,t,`string expected, "${Qr(t)}" found`)]:[]},e.aA=Qy,e.aB=function(e){let t=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of e)t=Math.min(t,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {min:new Me(t,r),max:new Me(n,i)}},e.aC=Ee,e.aD=h,e.aE=ee,e.aF=Tu,e.aG=Xc,e.aH=Nu,e.aI=ec,e.aJ=function(e,t){const r={};for(let n=0;n<t.length;n++){const i=t[n];i in e&&(r[i]=e[i]);}return r},e.aK=Ou,e.aL=ju,e.aM=function(e){try{const t=new URL(e).pathname.split("/").pop()||"",r=t.lastIndexOf(".");return r>=0?t.slice(r+1):""}catch{return ""}},e.aN=class{constructor(e){this.entries={},this.scheduler=e;}request(e,t,r,n){const i=this.entries[e]=this.entries[e]||{callbacks:[]};if(i.result){const[e,r]=i.result;return this.scheduler?this.scheduler.add(()=>{n(e,r);},t):n(e,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r((r,n)=>{i.result=[r,n];for(const e of i.callbacks)this.scheduler?this.scheduler.add(()=>{e(r,n);},t):e(r,n);setTimeout(()=>delete this.entries[e],3e3);})),()=>{i.result||(i.callbacks=i.callbacks.filter(e=>e!==n),i.callbacks.length||(i.cancel(),delete this.entries[e]));}}},e.aO=function(e,t,r){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",renderSourceType:e.renderSourceType,zoom:e.tileZoom},t=>{const n=$t(e.request,(e,n,i)=>{e?Nt(e)?t(null,null):t(e):n&&t(null,{rawData:n,vectorTile:r?void 0:new pc(new Dg(n)),responseHeaders:new Map(i.entries())});});return ()=>{n.cancel(),t(null,null);}},t)},e.aP=function(e){return e?{cacheControl:e.get("cache-control"),expires:e.get("expires")}:{cacheControl:void 0,expires:void 0}},e.aQ=function(e){kt++,kt>St&&(e.getActor().send("enforceCacheSizeLimit",Mt),kt=0);},e.aR=ah,e.aS=Fb,e.aT=Ub,e.aU=Lu,e.aV=Tb,e.aW=function(e,t){const r=document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r);};for(let t=0;t<e.length;t++){const n=document.createElement("source");qt(e[t])||(r.crossOrigin="Anonymous"),n.src=e[t],r.appendChild(n);}return {cancel:()=>{}}},e.aX=Fm,e.aY=ow,e.aZ=je,e.a_=bA,e.aa=io,e.ab=fo,e.ac=co,e.ad=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return Je(e.expression.evaluate(t))}interpolate(e,t,r){return {x:yr(e.x,t.x,r),y:yr(e.y,t.y,r),z:yr(e.z,t.z,r),azimuthal:yr(e.azimuthal,t.azimuthal,r),polar:yr(e.polar,t.polar,r)}}},e.ae=to,e.af=Xs,e.ag=Ku,e.ah=j,e.ai=I,e.aj=Ce,e.ak=uo,e.al=Vh,e.am=yr,e.an=qn,e.ao=gr,e.ap=Te,e.aq=dr,e.ar=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return function([e,t]){const r=Je([1,e,t]);return {x:r.x,y:r.y,z:r.z}}(e.expression.evaluate(t))}interpolate(e,t,r){return {x:yr(e.x,t.x,r),y:yr(e.y,t.y,r),z:yr(e.z,t.z,r)}}},e.as=function(e,t,r=0,n=!0){const i=new Me(r,r),s=e.sub(i),a=t.add(i),o=[s,new Me(a.x,s.y),a,new Me(s.x,a.y)];return n&&o.push(s.clone()),o},e.at=function(e,t){const r=[];for(let n=0;n<e.length;n++){const i=Re(n-1,-1,e.length-1),s=Re(n+1,-1,e.length-1),a=e[n],o=e[s],l=e[i].sub(a).unit(),u=o.sub(a).unit(),c=u.angleWithSep(l.x,l.y),h=l.add(u).unit().mult(-1*t/Math.sin(c/2));r.push(a.add(h));}return r},e.au=Vv,e.av=Zc,e.aw=function(e,t,r=0){return M(((t.x-r)*e.scale-e.x)*qn,(t.y*e.scale-e.y)*qn,Hu(t.z,t.y))},e.ax=X,e.ay=L,e.az=Ac,e.b=function(e){return lt.API_FONTS_REGEX.test(e)},e.b$=hu,e.b0=class{constructor(e,t,r,n,i,s){this.tileID=e,this.uid=Ue(),this.uses=0,this.tileSize=t,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection),this.worldview=s,this._hasAppearances=null;}registerFadeDuration(e){const t=e+this.timeAdded;t<wt.now()||void 0!==this.fadeEndTime&&t<this.fadeEndTime||(this.fadeEndTime=t);}wasRequested(){return "errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=Fv(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,r){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=yw(e.buckets,t.style),this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!e.hasTunnelGeometry;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof pb){if(this.hasSymbolBuckets=!0,!r)break;t.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof pb&&t.hasRTLText){this.hasRTLText=!0,eo();break}}this.queryPadding=0;for(const e in this.buckets){const r=this.buckets[e],n=t.style.getOwnLayer(e);if(!n)continue;const i=n.queryRadius(r)||0;this.queryPadding=Math.max(this.queryPadding,i);}e.imageAtlas&&(this.imageAtlas=t.style.imageManager.imageAtlasCache.getOrCache(e.imageAtlas)),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness;}else this.collisionBoxArray=new Fl;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded";}}loadModelData(e,t,r){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets=Object.assign({},this.buckets,yw(e.buckets,t.style)),e.featureIndex&&(this.latestFeatureIndex=e.featureIndex));}getBucket(e){return this.buckets[e.fqid]}upload(e,t){for(const r in this.buckets){const n=this.buckets[r];if(n.uploadPending()){let r={},i=[],s={zoom:0,pitch:0,brightness:0,worldview:""};if(t){if(t.style){i=t.style.listImages();const e=n.layers[0],s=e.sourceLayer||"_geojsonTileLayer",a=t.style.getLayerSourceCache(e);a&&(r=a._state.getState(s,void 0));}s={zoom:t.transform.zoom||0,pitch:t.transform.pitch||0,brightness:t.style.getBrightness()||0,worldview:t.worldview||""};}n.upload(e,this.tileID.canonical,r,i,s);}}const r=e.gl,n=this.imageAtlas;!n||this.imageAtlasTexture&&n.uploaded||(this.imageAtlasTexture=null,this.imageAtlasTexture=t.style.imageManager.imageAtlasCache.getTextureForAtlas(n,e,r.RGBA8),n.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new km(e,this.glyphAtlasImage,r.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new km(e,this.lineAtlas.image,r.R8),this.lineAtlas.uploaded=!0);}prepare(e,t,r){if(this.imageAtlas&&this.imageAtlasTexture&&t){const n=t.style.getLut(r);this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,r,n);}if(!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=t.style.getBrightness(),i=t.style.listImages(),s=i.length,a=t.style._changes.getUpdatedPaintProperties(),o=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>a.has(e.fqid))),l=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>e.hasTransition&&e.hasTransition())),u=this._firstPrepareComplete&&s!==this._lastAvailableImagesCount;null===this._hasAppearances&&(this._hasAppearances=this.hasAppearances(t));const c=this._lastUpdatedBrightness!==n;this._lastAvailableImagesCount=s,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||n||this._hasAppearances||o||l||u)&&(!(this._hasAppearances||o||l||u)&&this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)<.001||(this.updateBuckets(t,c,void 0,u||o||l,a,i),this._lastUpdatedBrightness=n));}evaluateQueryRenderedFeaturePadding(){let e=0;for(const t in this.buckets){const r=this.buckets[t];r.evaluateQueryRenderedFeaturePadding&&(e=Math.max(e,r.evaluateQueryRenderedFeaturePadding()));}return e}queryRenderedFeatures(e,t,r,n,i,s,a){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return {};const o=this.evaluateQueryRenderedFeaturePadding(),l=function(e,t){const r=g([],[.5*e.width,.5*-e.height,1]);return d(r,r,[1,-1,0]),h(r,r,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(r)}(i,this.tileID);return this.latestFeatureIndex.query(e,{tilespaceGeometry:t,pixelPosMatrix:l,transform:n,availableImages:r,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:o,scope:a})}querySourceFeatures(e,t){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),i=t?t.sourceLayer:"",s=n._geojsonTileLayer||n[i];if(!s)return;const a=vo(t&&t.filter),{z:o,x:l,y:u}=this.tileID.canonical,c={z:o,x:l,y:u};for(let t=0;t<s.length;t++){const n=s.feature(t);if(a.needGeometry){const e=oc(n,!0);if(!a.filter(new to(this.tileID.overscaledZ,{worldview:this.worldview}),e,this.tileID.canonical))continue}else if(!a.filter(new to(this.tileID.overscaledZ,{worldview:this.worldview}),n))continue;const h=r.getId(n,i),d=new aw(n,o,l,u,h);d.tile=c,e.push(d);}}loaded(){return "loaded"===this.state||"errored"===this.state}hasData(){return "loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return !!this.imageAtlas&&!!this.imageAtlas.patternPositions.size}setExpiryData(e){const t=this.expirationTime;if(e.cacheControl){const t=Qe(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"]);}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let r=!1;if(this.expirationTime>e)r=!1;else if(t)if(this.expirationTime<t)r=!0;else {const n=this.expirationTime-t;n?this.expirationTime=e+Math.max(n,3e4):r=!0;}else r=!0;r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0;}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}refreshFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!e)return;const r=e.style.listImages();this.updateBuckets(e,!1,t,void 0,void 0,r);}hasAppearances(e){for(const t in this.buckets)if(e.style.hasLayer(t)&&this.buckets[t].layers.some(e=>e.appearances&&e.appearances.length>0))return !0;return !1}updateBuckets(e,t,r,n,i,s){if(!this.latestFeatureIndex)return;if(!e.style)return;const a=s||e.style.listImages(),o=e.style.getBrightness(),l=i||new Set;for(const i in this.buckets){if(!e.style.hasLayer(i))continue;const s=this.buckets[i],u=s.layers[0],c=u.sourceLayer||"_geojsonTileLayer",h=e.style.getLayerSourceCache(u),d=s.layers.some(e=>l.has(e.fqid)),p=(n||d)&&s instanceof pb?e.style.getOwnLayer(i):void 0;let f=r&&r[c]||{};h&&!r&&(f=h._state.getState(c,void 0));const m=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},y=Object.keys(f).length>0&&!t;s.hasAppearances=s.layers.some(e=>e.appearances&&e.appearances.length>0);const g=y?s.stateDependentLayers:s.layers;if(y&&0!==s.stateDependentLayers.length||t||d||n){const r=this.latestFeatureIndex.loadVTLayers()[c];if(s.update(f,r,a,m,g,t,o,this.tileID.canonical),(n||d)&&!t&&s instanceof pb&&p&&"symbol"===p.type){const e=s;e.text&&e.text.uboBinder&&e.text.uboBinder.updateDynamicExpressions(p,r,this.tileID.canonical,a,f,o),e.icon&&e.icon.uboBinder&&e.icon.uboBinder.updateDynamicExpressions(p,r,this.tileID.canonical,a,f,o);}if(s instanceof pb){const t=s,r=e.context;t.text&&t.text.uboBinder&&t.text.uboBinder.upload(r),t.icon&&t.icon.uboBinder&&t.icon.uboBinder.upload(r);}}if(y&&0!==s.stateDependentLayers.length||t||s.hasAppearances){const t={zoom:e.transform.zoom,pitch:e.transform.pitch,brightness:e.style.getBrightness()||0,worldview:e.worldview},r=s.updateAppearances(this.tileID.canonical,f,a,t,e.imageManager,y&&0!==s.stateDependentLayers.length);if(r&&r.hasUboChanges){const t=e.context;s instanceof pb&&s.text&&s.text.uboBinder&&s.text.uboBinder.upload(t),s instanceof pb&&s.icon&&s.icon.uboBinder&&s.icon.uboBinder.upload(t);}}(s instanceof Wy||s instanceof Pp)&&e._terrain&&e._terrain.enabled&&h&&s.uploadPending()&&e._terrain._clearRenderCacheForTile(h.id,this.tileID);const x=e&&e.style&&e.style.getOwnLayer(i);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(s)||0));}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return !this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<wt.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0;}setHoldDuration(e){this.symbolFadeHoldUntil=wt.now()+e;}setTexture(e,t){const r=t.context,n=r.gl;this.texture=this.texture||t.getTileTexture(e.width),this.texture&&this.texture instanceof km?this.texture.update(e):(this.texture=new km(r,e,n.RGBA8,{useMipmap:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));}setDependencies(e,t){const r={};for(const e of t)r[e]=!0;this.dependencies[e]=r;}hasDependency(e,t){for(const r of e){const e=this.dependencies[r];if(e)for(const r of t)if(e[r])return !0}return !1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const r=ac(Mw,this.tileID.canonical,this.tileTransform)[0],n=new Zo,i=new Sl;for(let e=0;e<r.length;e++){const{x:t,y:s}=r[e];n.emplaceBack(t,s),i.emplaceBack(e);}i.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(i),this._tileDebugBuffer=e.createVertexBuffer(n,dh.members),this._tileDebugSegments=Xl.simpleSegment(0,0,n.length,i.length);}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const r=ac(Mw,this.tileID.canonical,this.tileTransform)[0];let n,i;if(this.isRaster){const e=function(e,t){const r=Fv(e,t),n=Math.pow(2,e.z);for(let i=0;i<xw;i++)for(let s=0;s<xw;s++){const a=$u((e.x+(s+Aw(s))/gw)/n),o=qu((e.y+(i+Aw(i))/gw)/n),l=t.project(a,o),u=i*xw+s;bw[2*u+0]=Math.round((l.x*r.scale-r.x)*qn),bw[2*u+1]=Math.round((l.y*r.scale-r.y)*qn);}ww.fill(0),_w.fill(0);for(let e=2045;e>=0;e--){const t=4*e,r=vw[t+0],n=vw[t+1],i=vw[t+2],s=vw[t+3],a=r+i>>1,o=n+s>>1,l=a+o-n,u=o+r-a,c=n*xw+r,h=s*xw+i,d=o*xw+a,p=Math.hypot((bw[2*c+0]+bw[2*h+0])/2-bw[2*d+0],(bw[2*c+1]+bw[2*h+1])/2-bw[2*d+1])>=16;ww[d]=ww[d]||(p?1:0),e<1022&&(ww[d]=ww[d]||ww[(n+u>>1)*xw+(r+l>>1)]||ww[(s+u>>1)*xw+(i+l>>1)]);}const i=new Yo,s=new yl;let a=0;function o(e,t){const r=t*xw+e;return 0===_w[r]&&(i.emplaceBack(bw[2*r+0],bw[2*r+1],e*qn/gw,t*qn/gw),_w[r]=++a),_w[r]-1}function l(e,t,r,n,i,a){const u=e+r>>1,c=t+n>>1;if(Math.abs(e-i)+Math.abs(t-a)>1&&ww[c*xw+u])l(i,a,e,t,u,c),l(r,n,i,a,u,c);else {const l=o(e,t),u=o(r,n),c=o(i,a);s.emplaceBack(l,u,c);}}return l(0,0,gw,gw,gw,0),l(gw,gw,0,0,0,gw),{vertices:i,indices:s}}(this.tileID.canonical,t);n=e.vertices,i=e.indices;}else {n=new Yo,i=new yl;for(const{x:e,y:t}of r)n.emplaceBack(e,t,0,0);const e=ld(n.int16.subarray(0,4*n.length),void 0,4);for(let t=0;t<e.length;t+=3)i.emplaceBack(e[t],e[t+1],e[t+2]);}this._tileBoundsBuffer=e.createVertexBuffer(n,Mb.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(i),this._tileBoundsSegments=Xl.simpleSegment(0,0,n.length,i.length);}_makeGlobeTileDebugBuffers(e,t){const r=t.projection;if(!r||"globe"!==r.name||t.freezeTileCoverage)return;const n=this.tileID.canonical,i=Ph(bh(n,t)),s=Vh(t.zoom);let a;s>0&&(a=c(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,n,t,i,a,s),this._makeGlobeTileDebugTextBuffer(e,n,t,i,a,s);}_globePoint(e,t,r,n,i,s,a){let o=Mh(e,t,r);if(s){const i=1<<r.z,l=Nu(n.center.lng),u=ju(n.center.lat),c=(r.x+.5)/i-l;let h=0;c>.5?h=-1:c<-.5&&(h=1);let d=(e/qn+r.x)/i+h,p=(t/qn+r.y)/i;d=(d-l)*n._pixelsPerMercatorPixel+l,p=(p-u)*n._pixelsPerMercatorPixel+u;const f=[d*n.worldSize,p*n.worldSize,0];j(f,f,s),o=vh(o,f,a);}return j(o,o,i)}_makeGlobeTileDebugBorderBuffer(e,t,r,n,i,s){const a=new Zo,o=new Sl,l=new Wo,u=(e,u,c,h,d)=>{const p=(c-e)/(d-1),f=(h-u)/(d-1),m=a.length;for(let c=0;c<d;c++){const h=e+c*p,d=u+c*f;a.emplaceBack(h,d);const y=this._globePoint(h,d,t,r,n,i,s);l.emplaceBack(y[0],y[1],y[2]),o.emplaceBack(m+c);}},c=qn;u(0,0,c,0,16),u(c,0,c,c,16),u(c,c,0,c,16),u(0,c,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(o),this._tileDebugBuffer=e.createVertexBuffer(a,dh.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(l,hh.members),this._tileDebugSegments=Xl.simpleSegment(0,0,a.length,o.length);}_makeGlobeTileDebugTextBuffer(e,t,r,n,i,s){const a=new Zo,o=new yl,l=new Wo,u=25;o.reserve(32),a.reserve(u),l.reserve(u);const c=(e,t)=>u*e+t;for(let e=0;e<u;e++){const o=2048*e;for(let e=0;e<u;e++){const u=2048*e;a.emplaceBack(u,o);const c=this._globePoint(u,o,t,r,n,i,s);l.emplaceBack(c[0],c[1],c[2]);}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const r=c(e,t),n=c(e,t+1),i=c(e+1,t),s=c(e+1,t+1);o.emplaceBack(r,n,i),o.emplaceBack(i,n,s);}this._tileDebugTextIndexBuffer=e.createIndexBuffer(o),this._tileDebugTextBuffer=e.createVertexBuffer(a,dh.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(l,hh.members),this._tileDebugTextSegments=Xl.simpleSegment(0,0,u,32);}destroy(e=!0){for(const t in this.buckets)this.buckets[t].destroy(e);this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&delete this.imageAtlasTexture,this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),e&&this.texture&&this.texture instanceof km&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof km&&(this.emissiveTexture.destroy(),delete this.emissiveTexture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded";}},e.b1=$t,e.b2=Nt,e.b3=function(e,t){const r=[];for(const n in e)n in t||r.push(n);return r},e.b4=Iw,e.b5=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.b6=Se,e.b7=c,e.b8=l,e.b9=u,e.bA=nf,e.bB=tf,e.bC=rf,e.bD=oc,e.bE=Y,e.bF=ax,e.bG=av,e.bH=vv,e.bI=IA,e.bJ=F,e.bK=W,e.bL=re,e.bM=function(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+i*o,e[1]=i*l-n*o,e[2]=s*l+a*o,e[3]=a*l-s*o,e},e.bN=ne,e.bO=rt,e.bP=g,e.bQ=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.bR=b,e.bS=function(e,t,r,n,i){var s=1/Math.tan(t/2);if(e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){var a=1/(n-i);e[10]=(i+n)*a,e[14]=2*i*n*a;}else e[10]=-1,e[14]=-2*n;return e},e.bT=function(e,t,r,n,i,s,a){var o=1/(t-r),l=1/(n-i),u=1/(s-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*o,e[13]=(i+n)*l,e[14]=(a+s)*u,e[15]=1,e},e.bU=Gu,e.bV=qu,e.bW=function(e,t,r){e[4*t+0]=r[0],e[4*t+1]=r[1],e[4*t+2]=r[2],e[4*t+3]=r[3];},e.bX=nu,e.bY=au,e.bZ=iu,e.b_=su,e.ba=y,e.bb=o,e.bc=function(e,t){const{x:r,y:n}=e.point,i=Fh(r,n,e.worldSize/e._pixelsPerMercatorPixel,0,0);return h(i,i,Th(xh(t)))},e.bd=n,e.be=q,e.bf=D,e.bg=V,e.bh=U,e.bi=O,e.bj=gx,e.bk=Wg,e.bl=yx,e.bm=function(e,t,r,n,i){const s=5*t+2;e.float32[s+0]=r,e.float32[s+1]=n,e.float32[s+2]=i;},e.bn=lb,e.bo=he,e.bp=me,e.bq=pe,e.br=we,e.bs=Re,e.bt=function(e,t,n,i){var s=new r(4);return s[0]=e,s[1]=t,s[2]=n,s[3]=i,s},e.bu=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return !1;const r=t.getSource().maxzoom,n=1<<r,i=Math.floor(e.x),s=Math.floor((e.x-i)*n),a=Math.floor(e.y*n),o=this.findDEMTileFor(new ah(r,i,r,s,a));return !(!o||!o.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,r=!0){if(this.isUsingMockSource())return null;null==t&&(t=null);const n=this._source();if(!n)return t;if(e.y<0||e.y>1)return t;const i=n.getSource().maxzoom,s=1<<i,a=Math.floor(e.x),o=e.x-a,l=new ah(i,a,i,Math.floor(o*s),Math.floor(e.y*s)),u=this.findDEMTileFor(l);if(!u||!u.dem)return t;const c=u.dem,h=1<<u.tileID.canonical.z,d=(o*h-u.tileID.canonical.x)*c.dim,p=(e.y*h-u.tileID.canonical.y)*c.dim,f=Math.floor(d),m=Math.floor(p);return (r?this.exaggeration():1)*yr(yr(c.get(f,m),c.get(f,m+1),p-m),yr(c.get(f+1,m),c.get(f+1,m+1),p-m),d-f)}static getAtTileOffset(e,t,r,n){const i=1<<e.canonical.z;return n?n.pointElevation(t):r?r.getAtPointOrZero(new Ku(e.wrap+(e.canonical.x+t.x/qn)/i,(e.canonical.y+t.y/qn)/i)):0}static getAtTileOffsetFunc(e,t,r,n){return (i,s,a)=>{const o=this.getAtTileOffset(e,i,s,a),l=n.upVector(e.canonical,i.x,i.y);return F(l,l,o*n.upVectorScale(e.canonical,t,r).metersToTile),l}}getForTilePoints(e,t,r,n){if(this.isUsingMockSource())return !1;const i=Zb.create(this,e,n);return !!i&&(t.forEach(e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],r);}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const r=t.dem.tree,n=t.tileID,i=1<<e.canonical.z-n.canonical.z;let s=e.canonical.x/i-n.canonical.x,a=e.canonical.y/i-n.canonical.y,o=0;for(let t=0;t<e.canonical.z-n.canonical.z&&!r.leaves[o];t++){s*=2,a*=2;const e=2*Math.floor(a)+Math.floor(s);o=r.childOffsets[o]+e,s%=1,a%=1;}return {min:this.exaggeration()*r.minimums[o],max:this.exaggeration()*r.maximums[o]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,r){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(0===e.length)return null;let t=!1,r=Number.MAX_VALUE,n=Number.MIN_VALUE;for(const i of e){const e=this.getMinMaxForTile(i.tileID);e&&(r=Math.min(r,e.min),n=Math.max(n,e.max),t=!0);}return t?{min:r,max:n}:null}},e.bv=$f,e.bw=Cc,e.bx=d,e.by=Sg,e.bz=Hp,e.c=pt,e.c$=function(e,t){return e.readFields(Pw,{icons:[]},t)},e.c0=eb,e.c1=function(){var e=new r(4);return r!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},e.c2=function(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+s*o,e[1]=i*l+a*o,e[2]=n*-o+s*l,e[3]=i*-o+a*l,e},e.c3=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},e.c4=H,e.c5=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)},e.c6=le,e.c7=$,e.c8=sh,e.c9=3,e.cA=Um,e.cB=function(e){const t=Um(e,!0);return n([],[t[0],t[1],t[4],t[5]])},e.cC=p,e.cD=Ic,e.cE=f,e.cF=function(e){const{x:t,y:r}=e.point,{lng:n,lat:i}=e._center;return Fh(t,r,e.worldSize,n,i)},e.cG=T,e.cH=ze,e.cI=Wc,e.cJ=5,e.cK=function(e,t,r){let n=0;for(let r=0;r<2;++r){const i=0;e[r]>i&&(n+=(e[r]-i)*(e[r]-i)),t[r]<i&&(n+=(i-t[r])*(i-t[r]));}return n},e.cL=function(e){return e*e*e*e*e},e.cM=Uu,e.cN=45,e.cO=lu,e.cP=function(e,t,r){const n=Math.sqrt(e*e+t*t+r*r),i=n>0?Math.acos(r/n)*Pe:0;let s=0!==e||0!==t?Math.atan2(-t,-e)*Pe+90:0;return s<0&&(s+=360),[n,s,i]},e.cQ=M,e.cR=Je,e.cS=Ju,e.cT=B,e.cU=zc,e.cV=P,e.cW=function(e){return [Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.cX=Pm,e.cY=py,e.cZ=Qm,e.c_=$b,e.ca=2,e.cb=7,e.cc=6,e.cd=N,e.ce=_,e.cf=A,e.cg=0,e.ch=1,e.ci=4,e.cj=5,e.ck=oh,e.cl=Tc,e.cm=Nm,e.cn=ih,e.co=_h,e.cp=function(e,t,r,n,i,s,a,o,l){if("globe"===l.name)return _h(e,t,new ih(r,n,i),!1);const u=Fv({z:r,x:n,y:i},l);return new zc([(s+u.x/u.scale)*t,t*(u.y/u.scale),a],[(s+u.x2/u.scale)*t,t*(u.y2/u.scale),o])},e.cq=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e},e.cr=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e},e.cs=function(e){const t=Math.round((e+45+360)%360/90)%4;return ke[t]},e.ct=Xu,e.cu=J,e.cv=6,e.cw=function(e){const t=u(new Float64Array(16));h(t,e.pixelMatrix,e.globeMatrix);const r=[0,Fu,0],n=[0,Vu,0];return j(r,r,t),j(n,n,t),[r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Eh(e,new Lu(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!Eh(e,new Lu(e.center.lat,-90))]},e.cx=function(e,t){const{scale:r}=e.tileTransform,n=r*qn/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,r){var n=t[1],i=t[2],s=t[3],a=r[0],o=r[1];return e[0]=t[0]*a,e[1]=n*a,e[2]=i*o,e[3]=s*o,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[n,n])},e.cy=jm,e.cz=w,e.d=function(e){return lt.API_TILEJSON_REGEX.test(e)},e.d$=lh,e.d0=Lc,e.d1=class{static calculate(e,t,r){const n=new Set,i=new Map,s=new Set,a=new Set;for(const r of Object.values(e))for(const[e,o]of Object.entries(r.floors)){s.add(e),o.isDefault&&a.add(e),o.conflicts&&i.set(e,o.conflicts);const r=e===t,l=o.connections&&t&&o.connections.has(t);(r||l)&&n.add(e);}const o=e=>{const t=i.get(e)||new Set;for(const r of n)if((i.get(r)||new Set).has(e)||t.has(r))return !0;return !1};if(r)for(const e of r)s.has(e)&&(o(e)||n.add(e));for(const e of a)n.has(e)||o(e)||n.add(e);return n}},e.d2=jx,e.d3=Nx,e.d4=jt,e.d5=function(){return {API_URL:lt.API_URL,DRACO_URL:lt.DRACO_URL,MESHOPT_URL:lt.MESHOPT_URL,MESHOPT_SIMD_URL:lt.MESHOPT_SIMD_URL,BUILDING_GEN_URL:lt.BUILDING_GEN_URL}},e.d6=Za,e.d7=At,e.d8=rr,e.d9=qe,e.dA=ph,e.dB=Zo,e.dC=yl,e.dD=function(e,t){return [Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]},e.dE=i,e.dF=function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=-r,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.dG=G,e.dH=kh,e.dI=st,e.dJ=at,e.dK=zb,e.dL=function(e,t){const r=[0,0,0];return j(r,r,Ph(xh(t.canonical))),j(r,r,e),r},e.dM=e=>({u_matrix:new hu(e),u_texsize:new su(e),u_pixels_to_tile_units:new fu(e),u_device_pixel_ratio:new iu(e),u_width_scale:new iu(e),u_floor_width_scale:new iu(e),u_image:new nu(e),u_units_to_pixels:new su(e),u_tile_units_to_pixels:new iu(e),u_alpha_discard_threshold:new iu(e),u_trim_offset:new su(e),u_trim_fade_range:new su(e),u_trim_gradient_mix_range:new su(e),u_trim_color:new lu(e),u_zbias_factor:new iu(e),u_tile_to_meter:new iu(e),u_ground_shadow_factor:new au(e),u_pattern_transition:new iu(e)}),e.dN=e=>({u_matrix:new hu(e),u_pixels_to_tile_units:new fu(e),u_device_pixel_ratio:new iu(e),u_width_scale:new iu(e),u_floor_width_scale:new iu(e),u_units_to_pixels:new su(e),u_dash_image:new nu(e),u_gradient_image:new nu(e),u_image_height:new iu(e),u_texsize:new su(e),u_tile_units_to_pixels:new iu(e),u_alpha_discard_threshold:new iu(e),u_trim_offset:new su(e),u_trim_fade_range:new su(e),u_trim_gradient_mix_range:new su(e),u_trim_color:new lu(e),u_zbias_factor:new iu(e),u_tile_to_meter:new iu(e),u_ground_shadow_factor:new au(e)}),e.dO=e=>({u_camera_to_center_distance:new iu(e),u_extrude_scale:new fu(e),u_device_pixel_ratio:new iu(e),u_matrix:new hu(e),u_inv_rot_matrix:new hu(e),u_merc_center:new su(e),u_tile_id:new au(e),u_zoom_transition:new iu(e),u_up_dir:new au(e),u_emissive_strength:new iu(e)}),e.dP=fl,e.dQ=bg,e.dR=class{constructor(e,t,r,n){this.context=e,this.format=n,this.size=r,this.texture=e.gl.createTexture();const[i,s,a]=this.size,{gl:o}=e;o.bindTexture(o.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&o.texImage3D(o.TEXTURE_3D,0,this.format,i,s,a,0,Tm(this.format),zm(this.format),t.data);}bind(e,t){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_3D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}},e.dS=Uh,e.dT=(e,t,r,n,i,s)=>{const a=e.transform,o="globe"===a.projection.name;let l;if("map"===s.paint.get("circle-pitch-alignment"))if(o){const e=kh(a.zoom,t.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e]);}else l=a.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(a.projection),u_matrix:e.translatePosMatrix(t.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:wt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Oh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:s.paint.get("circle-emissive-strength")};if(o){u.u_inv_rot_matrix=n,u.u_merc_center=i,u.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],u.u_zoom_transition=Vh(a.zoom);const e=i[0]*qn,r=i[1]*qn;u.u_up_dir=a.projection.upVector(new ih(0,0,0),e,r);}return u},e.dU=ng,e.dV=jr,e.dW=(e,t,r,n,i,s,a,o,l,u)=>{const c=e.transform,h=c.pitch<15?eg(.07,.7,Ee((14-c.zoom)/5,0,1)):.07,d="none"===r.paint.get("line-trim-color-use-theme").constantOr("default");return {u_matrix:rg(e,t,r,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_width_scale:s,u_floor_width_scale:a,u_image:0,u_tile_units_to_pixels:tg(t,c),u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:r.lut).toArray01(),u_zbias_factor:h,u_tile_to_meter:Ju(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:u}},e.dX=(e,t,r,n,i,s,a,o,l,u)=>{const c=e.transform,h=c.calculatePixelsToTileUnitsMatrix(t),d="none"===r.paint.get("line-trim-color-use-theme").constantOr("default"),p=c.pitch<15?eg(.07,.7,Ee((14-c.zoom)/5,0,1)):.07;return {u_matrix:rg(e,t,r,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:s,u_width_scale:a,u_floor_width_scale:o,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:ig(r)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:tg(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:r.lut).toArray01(),u_zbias_factor:p,u_tile_to_meter:Ju(t.tileID.canonical,0),u_ground_shadow_factor:u}},e.dY=Ne,e.dZ=nd,e.d_=Hu,e.da=function(e){const t=e.indexOf(ko);return t>=0?e.slice(0,t):e},e.db=function(e){return e.indexOf(ko)>=0},e.dc=function(e){const t=e.lastIndexOf(ko);return t>=0?e.slice(t+1):""},e.dd=function(e){const t=[],r=e.id;return void 0===r&&t.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},e.de=function(e,t,r,n){return "custom"===e.type?new Nb(e,t):new cw[e.type](e,t,r,n)},e.df=$e,e.dg=vo,e.dh=Vo,e.di=class extends aw{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},e.state)),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer);}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},e.dj=Ya,e.dk=function(e){return e({pluginStatus:Ha,pluginURL:Xa}),Ya.on("pluginStateChange",e),e},e.dl=uu,e.dm=class extends ru{constructor(e){super(e),this.current=du;}set(e,t,r){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}},e.dn=Fe,e.dp=function(e,t,r){const n=Vh(r.zoom),i=e.style.map._antialias,s=e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!i&&!s},e.dq=function(e){const t=e.pixelsPerMeter,r=t/Gu(1,e.center.lat),n=u(new Float64Array(16));return d(n,n,[e.point.x,e.point.y,0]),p(n,n,[r,r,t]),Float32Array.from(n)},e.dr=Ah,e.ds=function(e){const t=80.051129;e=Ee(e,-80.051129,t)/t*90;const r=Math.pow(Math.abs(Math.sin(Te(e))),3);return Math.round(r*(ku.length-1))},e.dt=function(e,t,r,n){const i=t.getNorth(),s=t.getSouth(),o=t.getWest(),l=t.getEast(),u=1<<e.z,c=l-o,h=i-s,d=c/zu,p=-h/ku[r],f=[0,d,0,p,0,0,i,o,0];if(e.z>0){const e=180/n;a(f,f,[e/c+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1]);}return f[2]=u,f[5]=e.x,f[8]=e.y,f},e.du=Ph,e.dv=xh,e.dw=function(e,t,r){const n=u(new Float64Array(16)),i=(t/(1<<e)-.5)*Math.PI*2;return m(n,r.globeMatrix,i),Float32Array.from(n)},e.dx=dh,e.dy=Xl,e.dz=rd,e.e=function(e){return 0===e.indexOf("mapbox:")},e.e$=Eh,e.e0=Sf,e.e1=Ef,e.e2=Wu,e.e3=pf,e.e4=450,e.e5=7,e.e6=function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],s=t[6],a=t[7],o=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=s,e[11]=t[14],e[12]=i,e[13]=a,e[14]=o;}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},e.e7=kb,e.e8=Ho,e.e9=Tl,e.eA=hl,e.eB=Il,e.eC=function(e,t,n,i,s,a,o,l,u,c,h,d,p,f,m,y){var g=new r(16);return g[0]=e,g[1]=t,g[2]=n,g[3]=i,g[4]=s,g[5]=a,g[6]=o,g[7]=l,g[8]=u,g[9]=c,g[10]=h,g[11]=d,g[12]=p,g[13]=f,g[14]=m,g[15]=y,g},e.eD=Cu,e.eE=Al,e.eF=_l,e.eG=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Me(1/0,1/0),max:new Me(-1/0,-1/0)};}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const r=Jp(new Me(0,0),new Me(qn,qn),e),n=[];if(t&&!Wp(r,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Wp(r,t))continue;const i=Kp(t.min,t.max,e);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope});}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const r of e.cache.getVisibleCoordinates()){const n=e.cache.getTile(r).buckets[e.layer];n&&n.updateFootprints(r.toUnwrapped(),t);}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})));}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const r=e.getOrder(),n=e.getClipMask(),i=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=Jp(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint,order:r,clipMask:n,clipScope:i});}this._sourceIds.push(e.getSourceId());}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Xp(e.min,t.min)||Xp(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const r=(e,t)=>e+t;return e.length-t.length||e.reduce(r,"").localeCompare(t.reduce(r,""))}(e.clipScope,t.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],n=this._prevRegions[t];e=r.priority!==n.priority||!Zp(r,n)||r.order!==n.order||r.clipMask!==n.clipMask||!Se(r.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t;}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==$p&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const r=t[e].priority;for(;e<t.length&&t[e].priority===r;)++e;return e};if(this._sourceIds.length>1){let t=0,r=e(t);for(;t!==r;){let n=t;const i=t;for(;n!==r;){const e=this._activeRegions[n];e.hiddenByOverlap=!1;for(let t=0;t<i;t++){const r=this._activeRegions[t];if(!r.hiddenByOverlap&&e.order===$p&&Wp(e,r)&&(e.hiddenByOverlap=ef(e.footprint,e.tileId,r.footprint,r.tileId),e.hiddenByOverlap))break}++n;}t=r,r=e(t);}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let t=e.length-1;t>=0;t--)this._addSource(e[t]);this._computeReplacement();}},e.eH=Yo,e.eI=Mb,e.eJ=Sl,e.eK=$p,e.eL=class{constructor(e){this._createGrid(e),this._createPoles(e);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy();}_fillGridMeshWithLods(e,t){const r=new Zo,n=new yl,i=[],s=e+1+2,a=t[0]+1,o=t[0]+1+(1+t.length),l=(e,t,r)=>{let n=e===s-1?e-2:0===e?e:e-1;return n+=r?24575:0,[n,t]};for(let e=0;e<s;++e)r.emplaceBack(...l(e,0,!0));for(let e=0;e<a;++e)for(let t=0;t<s;++t)r.emplaceBack(...l(t,e,(0===t||t===s-1)&&!0));for(let e=0;e<t.length;++e){const n=t[e];for(let e=0;e<s;++e)r.emplaceBack(...l(e,n,!0));}for(let e=0;e<t.length;++e){const a=n.length,l=t[e]+1+2,u=new yl;for(let r=0;r<l-1;r++){const i=r===l-2,a=i?s*(o-t.length+e-r):s;for(let e=0;e<s-1;e++){const t=r*s+e;0===r||i||0===e||e===s-2?(u.emplaceBack(t+1,t,t+a),u.emplaceBack(t+a,t+a+1,t+1)):(n.emplaceBack(t+1,t,t+a),n.emplaceBack(t+a,t+a+1,t+1));}}const c=Xl.simpleSegment(0,a,r.length,n.length-a);for(let e=0;e<u.uint16.length;e+=3)n.emplaceBack(u.uint16[e],u.uint16[e+1],u.uint16[e+2]);const h=Xl.simpleSegment(0,a,r.length,n.length-a);i.push({withoutSkirts:c,withSkirts:h});}return {vertices:r,indices:n,segments:i}}_createGrid(e){const t=this._fillGridMeshWithLods(zu,ku);this._gridSegments=t.segments,this._gridBuffer=e.createVertexBuffer(t.vertices,dh.members),this._gridIndexBuffer=e.createIndexBuffer(t.indices,!0);}_createPoles(e){const t=new yl;for(let e=0;e<=zu;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const r=new bl,n=new bl,i=new bl,s=new bl;this._poleSegments=[];for(let e=0,t=0;e<6;e++){const a=360/(1<<e);r.emplaceBack(0,-Tu,0,.5,0),n.emplaceBack(0,-Tu,0,.5,1),i.emplaceBack(0,-Tu,0,.5,.5),s.emplaceBack(0,-Tu,0,.5,.5);for(let e=0;e<=zu;e++){let t=e/zu,o=0;const l=yr(0,a,t),[u,c,h]=Du(Rh,Lh,l,Tu);r.emplaceBack(u,c,h,t,o),n.emplaceBack(u,c,h,t,1-o);const d=Te(l);t=.5+.5*Math.sin(d),o=.5+.5*Math.cos(d),i.emplaceBack(u,c,h,t,o),s.emplaceBack(u,c,h,t,1-o);}this._poleSegments.push(Xl.simpleSegment(t,0,66,64)),t+=66;}this._poleNorthVertexBuffer=e.createVertexBuffer(r,ch,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(n,ch,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(i,ch,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(s,ch,!1);}getGridBuffers(e,t){return [this._gridBuffer,this._gridIndexBuffer,t?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,t){return [t?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,t?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}},e.eM=qp,e.eN=Ve,e.eO=function(){return !!document.fullscreenElement||!!document.webkitFullscreenElement},e.eP=De,e.eQ=Yu,e.eR=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e},e.eS=Z,e.eT=Eu,e.eU=C,e.eV=S,e.eW=function([e,t,r]){const n=Math.hypot(e,t,r),i=Math.atan2(e,r),s=.5*Math.PI-Math.acos(-t/n);return new Lu(ze(i),ze(s))},e.eX=K,e.eY=$m,e.eZ=function(e){const t=e.navigator?e.navigator.userAgent:null;return !!function(e){if(null==tt){const t=e.navigator?e.navigator.userAgent:null;tt=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")));}return tt}(e)&&!(!t||!(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},e.e_=function(e,t){Mt=e,St=t;},e.ea=256,e.eb=function(e){return e>>>=0,e=Math.imul(2747636419^e,2654435769)>>>0,e=Math.imul(e^e>>>16,2654435769)>>>0,(e=Math.imul(e^e>>>16,2654435769)>>>0)/4294967296},e.ec=bh,e.ed=Th,e.ee=nl,e.ef=m,e.eg=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},e.eh=bl,e.ei=wl,e.ej=function(e,t,r,n,i){return Ee((e-t)/(r-t)*(i-n)+n,n,i)},e.ek=ie,e.el=function(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=c*a-o*u,d=-c*s+o*l,p=u*s-a*l,f=r*h+n*d+i*p;return f?(e[0]=h*(f=1/f),e[1]=(-c*n+i*u)*f,e[2]=(o*n-i*a)*f,e[3]=d*f,e[4]=(c*r-i*l)*f,e[5]=(-o*r+i*s)*f,e[6]=p*f,e[7]=(-u*r+n*l)*f,e[8]=(a*r-n*s)*f,e):null},e.em=vs,e.en=2,e.eo=R,e.ep=te,e.eq=v,e.er=function(e,t){var n=new r(3);v(n,t);var i=1/n[0],s=1/n[1],a=1/n[2],o=t[0]*i,l=t[1]*s,u=t[2]*a,c=t[4]*i,h=t[5]*s,d=t[6]*a,p=t[8]*i,f=t[9]*s,m=t[10]*a,y=o+h+m,g=0;return y>0?(g=2*Math.sqrt(y+1),e[3]=.25*g,e[0]=(d-f)/g,e[1]=(p-u)/g,e[2]=(l-c)/g):o>h&&o>m?(g=2*Math.sqrt(1+o-h-m),e[3]=(d-f)/g,e[0]=.25*g,e[1]=(l+c)/g,e[2]=(p+u)/g):h>m?(g=2*Math.sqrt(1+h-o-m),e[3]=(p-u)/g,e[0]=(l+c)/g,e[1]=.25*g,e[2]=(d+f)/g):(g=2*Math.sqrt(1+m-o-h),e[3]=(l-c)/g,e[0]=(p+u)/g,e[1]=(d+f)/g,e[2]=.25*g),e},e.es=function(e,r){var n=2*Math.acos(r[3]),i=Math.sin(n/2);return i>t?(e[0]=r[0]/i,e[1]=r[1]/i,e[2]=r[2]/i):(e[0]=1,e[1]=0,e[2]=0),n},e.et=lw,e.eu=Km,e.ev=Zm,e.ew=[1,1,1],e.ex=Zb,e.ey=function(e,t,r,n){var i=t[0],s=t[1],a=t[2],o=t[3];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=a+n*(r[2]-a),e[3]=o+n*(r[3]-o),e},e.ez=Jm,e.f=dt,e.f0=Dh,e.f1=function(e){const t=[0,0,0],r=u(new Float64Array(16));return h(r,e.pixelMatrix,e.globeMatrix),j(t,t,r),new Me(t[0],t[1])},e.f2=Ja,e.f3=function(e,t,r=!1){if(Ha===$a.deferred||Ha===$a.loading||Ha===$a.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Xa=wt.resolveURL(e),Ha=$a.deferred,qa=t,Wa(),r||Ka();},e.f4=ht,e.f5=ct,e.f6=ut,e.f7=function(e){const t=Tt();if(!t)return;const r=t.delete(It);e&&r.then(()=>e()).catch(e);},e.f8=ra,e.f9=ed,e.fA=lc,e.fB=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==wm){const r=new Uint32Array(e,0,7),[,,n,i,s,a]=r;t=r.byteLength+i+s+a+s,(n!==e.byteLength||t>=e.byteLength)&&Ze("Invalid b3dm header information.");}return Bm(e,t)},e.fC=function(e,t){const r=py(e);for(const e of r){for(const t of e.meshes)fy(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(yy(e.lights,t)));}return r},e.fD=tw,e.fE=Ke,e.fF=Qa,e.fG=$a,e.fH=function(e){zt(),null!=Pt&&Pt.then(t=>{t.keys().then(r=>{for(let n=0;n<r.length-e;n++)t.delete(r[n]).catch(e=>Ze(e.message));}).catch(e=>Ze(e.message));}).catch(e=>Ze(e.message));},e.fa=2,e.fb=ri,e.fc=Fv,e.fd=Fl,e.fe=dw,e.ff=pw,e.fg=qy,e.fh=mc,e.fi="hd_road_elevation",e.fj=Vc,e.fk=Ge,e.fl=Pp,e.fm=Od,e.fn=Vx,e.fo=1,e.fp=pb,e.fq=function(e,t,r,n,i,s,a,o=1,l,u,c,h){e.createArrays(),e.tilePixelRatio=qn/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const d=e.layers[0].layout,p=e.layers[0]._unevaluatedLayout._values,f={};f.scaleFactor=o,f.textSizeScaleRange=d.get("text-size-scale-range"),f.iconSizeScaleRange=d.get("icon-size-scale-range");const[m,y]=f.textSizeScaleRange,[g,x]=f.iconSizeScaleRange;f.textScaleFactor=Ee(f.scaleFactor,m,y),f.iconScaleFactor=Ee(f.scaleFactor,g,x);const v=p["text-size"],b=p["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.textSizeData;f.compositeTextSizes=[v.possiblyEvaluate(new to(t,{worldview:c}),s),v.possiblyEvaluate(new to(r,{worldview:c}),s)];}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.iconSizeData;f.compositeIconSizes=[b.possiblyEvaluate(new to(t,{worldview:c}),s,h),b.possiblyEvaluate(new to(r,{worldview:c}),s,h)];}f.layoutTextSize=v.possiblyEvaluate(new to(a+1,{worldview:c}),s),f.layoutIconSize=b.possiblyEvaluate(new to(a+1,{worldview:c}),s,h),f.textMaxSize=v.possiblyEvaluate(new to(18,{worldview:c}),s);const w=d.get("symbol-placement"),_="map"===d.get("text-rotation-alignment")&&"point"!==w,A=d.get("text-size");let I=!1;const M=[];for(const a of e.features){const o=d.get("text-font").evaluate(a,{},s).join(","),m=A.evaluate(a,{},s)*f.textScaleFactor,y=f.layoutTextSize.evaluate(a,{},s)*f.textScaleFactor,g=f.layoutIconSize.evaluate(a,{},s,h)*f.iconScaleFactor,x={horizontal:{},vertical:void 0},v=a.text;let b,S=[0,0];if(v){const n=v.toString(),u=d.get("text-letter-spacing").evaluate(a,{},s)*Sg,c=d.get("text-line-height").evaluate(a,{},s)*Sg,h=Da(n)?u:0,p=d.get("text-anchor").evaluate(a,{},s),g=d.get("text-variable-anchor");if(!g){const e=d.get("text-radial-offset").evaluate(a,{},s);if(e)S=av(p,[e*Sg,nv]);else {const e=d.get("text-offset").evaluate(a,{},s);S=[e[0]*Sg,e[1]*Sg];}}let b=_?"center":d.get("text-justify").evaluate(a,{},s);const A="point"===w,I=A?d.get("text-max-width").evaluate(a,{},s)*Sg:1/0,M=s=>{e.allowVerticalPlacement&&Va(n)&&(x.vertical=Kg(v,t,r,i,o,I,c,p,s,h,S,Wg.vertical,!0,y,m,l,f.textScaleFactor));};if(!_&&g){const e="auto"===b?g.map(e=>vv(e)):[b];let n=!1;for(let s=0;s<e.length;s++){const a=e[s];if(!x.horizontal[a])if(n)x.horizontal[a]=x.horizontal[0];else {const e=Kg(v,t,r,i,o,I,c,"center",a,h,S,Wg.horizontal,!1,y,m,l,f.textScaleFactor);e&&(x.horizontal[a]=e,n=1===e.positionedLines.length);}}M("left");}else {if("auto"===b&&(b=vv(p)),A||d.get("text-writing-mode").indexOf("horizontal")>=0||!Va(n)){const e=Kg(v,t,r,i,o,I,c,p,b,h,S,Wg.horizontal,!1,y,m,l,f.textScaleFactor);e&&(x.horizontal[b]=e);}M(A?"left":b);}}let B,P,T,z,k,F,V=!1;const D=d.get("icon-text-fit").evaluate(a,{},s);if(a.icon&&a.icon.hasPrimary()){const t=fv(a.icon,e.iconSizeData,p["icon-size"],s,e.zoom,a,l,f.iconScaleFactor,c,h);B=t.iconPrimary,T=t.iconSecondary;const r=B.toString();if(P=n.get(r),P&&(k=d.get("icon-offset").evaluate(a,{},s),F=d.get("icon-anchor").evaluate(a,{},s),b=ux(i.get(r),T?i.get(T.toString()):void 0,k,F),V=P.sdf,void 0===e.sdfIcons?e.sdfIcons=P.sdf:e.sdfIcons!==P.sdf&&Ze("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(P.pixelRatio!==e.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),T){const e=T.toString();z=n.get(e);}}I=I||!(!a.icon||!a.icon.hasSecondary());const E=Bv(x.horizontal)||x.vertical;e.iconsInText||(e.iconsInText=!!E&&E.iconsInText);const C=y*f.textScaleFactor/Sg,{defaultShapedIcon:R,verticallyShapedIcon:L}=bv(e,b,d,a,s,x,C,k,D);"none"!==D&&b&&(hx(b)||dx(b))&&(dv(0,P,B,b,R,D,u,n,i),dv(0,z,T,b,R,D,u,n,i),L&&(dv(0,P,B,b,L,D,u,n,i),dv(0,z,T,b,L,D,u,n,i))),b=R;const{iconBBox:O,iconVerticalBBox:U,textBBox:N,textVerticalBBox:j}=ov(e,b,L,d,a,s,g,k,f,i,F,x,y,S,h);M.push({feature:a,shapedTextOrientations:x,shapedText:E,shapedIcon:b,iconPrimary:B,iconSecondary:T,iconOffset:k,iconAnchor:F,verticallyShapedIcon:L,layoutTextSize:y,layoutIconSize:g,textOffset:S,isSDFIcon:V,iconTextFit:D,iconCollisionBounds:O,iconVerticalCollisionBounds:U,textCollisionBounds:N,textVerticalCollisionBounds:j});}return {featureData:M,sizes:f,hasAnySecondaryIcon:I,textAlongLine:_,symbolPlacement:w}},e.fr=Dx,e.fs=kx,e.ft=Ex,e.fu=Cx,e.fv=function(e,t,r,n,i,s,a,o,l,u){e.iconAtlasPositions=u.iconPositions;const{featureData:c,hasAnySecondaryIcon:h,sizes:d,textAlongLine:p,symbolPlacement:f}=t;for(const t of c){const{shapedIcon:r,verticallyShapedIcon:s,feature:c,shapedTextOrientations:m,shapedText:y,layoutTextSize:g,textOffset:x,isSDFIcon:v,iconPrimary:b,iconSecondary:w,iconTextFit:_,iconOffset:A,iconCollisionBounds:I,iconVerticalCollisionBounds:M,textCollisionBounds:S}=t;yv(r,u.iconPositions,b,w),yv(s,u.iconPositions,b,w),gv(m,u.iconPositions),mv(b,w,u.iconPositions),(y||r)&&_v(e,c,m,r,s,l,d,g,0,x,v,n,i,a,o,h,_,A,p,f,I,M,S);}r&&e.generateCollisionDebugBuffers(s,e.collisionBoxArray,d.textScaleFactor);},e.fw=Wy,e.fx=pc,e.fy=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},e.fz=T_,e.g=lt,e.h=function(e,t){return Gt(Object.assign(e,{method:"GET"}),t)},e.i=function(e){return lt.API_STYLE_REGEX.test(e)&&!pt(e)},e.j=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},e.k=Ft,e.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},e.m=function(e,t){return Gt(Object.assign(e,{type:"json"}),t)},e.n=Zt,e.o=wt,e.p=function(e,t){return Gt(Object.assign(e,{method:"POST"}),t)},e.q=td,e.r=Ue,e.s=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return !1}},e.t=Le,e.u=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},e.v=function(e){return !!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e.w=Ze,e.x=class{constructor(e){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(e&&e.maxTextureMemoryMB?e.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures();});}calculateTextureMemory(e){return e.image?Math.ceil(e.image.width*e.image.height*4*(e.patternPositions.size>0?1.33:1)):0}evictTexture(e){const t=this.textures.get(e);if(t){const r=this.calculateTextureMemory(e);t.destroy(),this.textures.delete(e),this.textureAccessTimes.delete(e),this.textureMemoryUsed-=r;}}evictTexturesIfNeeded(e){for(;this.textureMemoryUsed+e>this.maxTextureMemory&&this.textures.size>0;){let e=null,t=1/0;for(const[r]of this.textures.entries()){const n=this.textureAccessTimes.get(r)||0;n<t&&(t=n,e=r);}if(!e)break;this.evictTexture(e);}}findCachedAtlas(e){const t=this.cache.get(e.hash);if(t){const r=t.deref();if(r&&r.contentDescriptor&&this.isMipmapCompatible(e,r.contentDescriptor))return r}for(const[,t]of this.cache.entries()){const r=t.deref();if(r&&r.contentDescriptor){const t=e.subsetOf(r.contentDescriptor),n=this.isMipmapCompatible(e,r.contentDescriptor);if(t&&n)return r}}}getTextureForAtlas(e,t,r){this.textureAccessTimes.set(e,performance.now());let n=this.textures.get(e);if(n)return n;if(e.image){const i=this.calculateTextureMemory(e);return this.evictTexturesIfNeeded(i),n=new km(t,e.image,r,{useMipmap:!!e.patternPositions.size}),this.textures.set(e,n),this.textureMemoryUsed+=i,n}return null}clearExpiredTextures(){for(const[e]of this.textures.entries())if(!this.isAtlasCached(e)){const t=this.textures.get(e);if(t){const r=this.calculateTextureMemory(e);t.destroy(),this.textureMemoryUsed-=r;}this.textures.delete(e),this.textureAccessTimes.delete(e);}}isAtlasCached(e){if(!e.contentDescriptor)return !1;const t=this.cache.get(e.contentDescriptor.hash);return !!t&&t.deref()===e}getOrCache(e){if(!("image"in e)){const t=this.cache.get(e.sourceAtlasHash);if(t){const e=t.deref();if(e)return e}return Ze("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!e.contentDescriptor)return e;const t=e.contentDescriptor,r=t.hash,n=this.cache.get(r);if(n){const e=n.deref();if(e&&e.contentDescriptor&&this.isMipmapCompatible(t,e.contentDescriptor))return e}return this.cache.set(r,new WeakRef(e)),this.finalizationRegistry.register(e,r,e),e}isMipmapCompatible(e,t){return !e.requiresMipMaps||t.requiresMipMaps}destroyTextures(){for(const e of this.textures.values())e&&e.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0;}clear(){for(const e of this.textures.values())e&&e.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0;}},e.y=bt,e.z=g_;});

define(["require","./shared"],function(e,t){function s(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const s of e)t+=`${i(s)},`;return `${t}]`}let t="{";for(const s of Object.keys(e).sort())t+=`${s}:${i(e[s])},`;return `${t}}`}function o(e){let s="";for(const o of t.b5)s+=`/${i(e[o])}`;return s}function n(e,t){return function e(s){return "string"==typeof s&&s===t||(Array.isArray(s)?s.some(e):!(!s||"object"!=typeof s)&&Object.values(s).some(e))}(e)}class r{constructor(e){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),e&&this.replace(e);}replace(e,t){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(e,[],t);}update(e,s,r){this._options=r;for(const s of e)this._layerConfigs[s.id]=s,(this._layers[s.id]=t.de(s,this.scope,null,this._options)).compileFilter(r),this.keyCache[s.id]&&delete this.keyCache[s.id];for(const e of s)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource=Object.create(null);const a=function(e,t){const s=Object.create(null);for(let r=0;r<e.length;r++){const a=e[r];let l=t&&t[a.id];l||("symbol"===a.type?l=a.id:(l=o(a),"line"===a.type&&a.paint&&n(a.paint["line-width"],"line-progress")&&(l+=`/${i(a.paint["line-width"])}`))),t&&(t[a.id]=l);let c=s[l];c||(c=s[l]=[]),c.push(a);}const r=[];for(const e in s)r.push(s[e]);return r}(Object.values(this._layerConfigs),this.keyCache);for(const e of a){const t=e.map(e=>this._layers[e.id]),s=t[0];if("none"===s.visibility)continue;const i=s.source||"";let o=this.familiesBySource[i];o||(o=this.familiesBySource[i]=Object.create(null));const n=s.sourceLayer||"_geojsonTileLayer";let r=o[n];r||(r=o[n]=[]),r.push(t);}}}const a=1*t.fa;class l{constructor(e){const s={},i=[];for(const t in e){const o=e[t],n=s[t]={};for(const e in o.glyphs){const t=o.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const s=t.metrics.localGlyph?a:1,r={x:0,y:0,w:t.bitmap.width+2*s,h:t.bitmap.height+2*s};i.push(r),n[e]=r;}}const{w:o,h:n}=t.J(i),r=new t.f9({width:o||1,height:n||1});for(const i in e){const o=e[i];for(const e in o.glyphs){const n=o.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const l=s[i][e],c=n.metrics.localGlyph?a:1;t.f9.copy(n.bitmap,r,{x:0,y:0},{x:l.x+c,y:l.y+c},n.bitmap);}}this.image=r,this.positions=s;}}function c(e,t,s){e[t]?s&&(e[t].center=s):e[t]={floorIds:new Set,center:s||[0,0],floors:{}};}function h(e,t,s,i){for(const o of t)c(e,o),e[o].floors[s]=i,e[o].floorIds.add(s);}function u(e){return {id:e.properties.id.toString(),center:[e.properties.center_lon||0,e.properties.center_lat||0]}}function d(e,s){const i=e.properties.id.toString(),o=!!e.properties.is_default&&e.properties.is_default,n=e.properties.connected_floor_ids?new Set(e.properties.connected_floor_ids.toString().split(";")):new Set,r=e.properties.conflicted_floor_ids?new Set(e.properties.conflicted_floor_ids.toString().split(";")):new Set,a=e.properties.structure_ids?new Set(e.properties.structure_ids.toString().split(";")):new Set,l=e.properties.name.toString(),c=e.properties.z_index,h=function(e,s){const i=e.loadGeometry();if(!i||0===i.length)return;const o=i.map(i=>i.map(i=>t.fb(i,s,e.extent)));return 0===o.length?void 0:{type:"Polygon",coordinates:[o[0]]}}(e,s);return {id:i,isDefault:o,connections:n,conflicts:r,buildings:a,name:l,zIndex:c,geometry:h}}function f(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function p(e){return f(e,["type","id","name"])&&"structure"===e.properties.type}function g(e){return f(e,["type","id","name","z_index"])&&"floor"===e.properties.type}t.f8(l,"GlyphAtlas");class m{constructor(e){this.tileID=new t.aR(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.request&&e.request.collectResourceTiming,this.promoteId=e.promoteId,this.renderSourceType=e.renderSourceType,this.tileTransform=t.fc(e.tileID.canonical,e.projection),this.projection=e.projection,this.worldview=e.worldview,this.localizableLayerIds=e.localizableLayerIds,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep,this.scaleFactor=e.scaleFactor,this.worldview=e.worldview,this.indoor=e.indoor;}parse(e,s,i,o,n,r){this.status="parsing",this.data=e,this.collisionBoxArray=new t.fd;const a=new t.fe(Object.keys(e.layers).sort()),f=new t.ff(this.tileID,this.promoteId);f.bucketLayerIDs=[];const m={},w=new t.fg(256,256),b={featureIndex:f,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:w,availableImages:i,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(b.activeFloors=function(e,s,i,o){const n=s.indoorState.activeFloorsVisible;if(!s.sourceLayers)return n?s.indoorState.activeFloors:void 0;const r=function(e,s){if(!e)return t.w("No source layers defined in indoor specification"),s;if(0===e.size)return s;const i=e.difference(s);for(const e of i)t.w(`Missing source layer required in indoor specification: ${e}`);return s.intersection(s)}(s.sourceLayers,new Set(Object.keys(e.layers))),a=s.indoorState,l=function(e,s,i,o,n){const r={};for(const i of s){const s=e.layers[i];if(s)for(let e=0;e<s.length;e++){const t=s.feature(e);if(p(t)){const{id:e,center:s}=u(t);c(r,e,s);continue}if(g(t)){const e=d(t,n);h(r,e.buildings,e.id,e);}}else t.w(`indoor source layer not found: ${i}`);}return {buildings:r,activeFloors:t.d1.calculate(r,o,i)}}(e,r,a.activeFloors,a.selectedFloorId,o);return i.send("setIndoorData",l),n?l.activeFloors:void 0}(e,this.indoor,n,this.canonical));const x=[],v=s.familiesBySource[this.source];for(const s in v){const n=e.layers[s];if(!n)continue;let r=!1,l=!1,c=!1,h=!1;for(const e of v[s])"symbol"===e[0].type?r=!0:"fill-extrusion"===e[0].type?l=!0:c=!0,e[0].is3D()&&"model"!==e[0].type&&(h=!0);if(this.extraShadowCaster&&!h)continue;if(this.renderSourceType===t.b4.Symbol&&!r)continue;if(this.renderSourceType===t.b4.FillExtrusion&&!l)continue;if(this.renderSourceType===t.b4.Other&&!c)continue;1===n.version&&t.w(`Vector tile source "${this.source}" layer "${s}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const u=a.encode(s),d=[],p=this.localizableLayerIds&&this.localizableLayerIds.has(s);let g=!1;for(let e=0,i=0;e<n.length;e++){const o=n.feature(e),r=f.getId(o,s),a=o.properties?o.properties.worldview:null;if(p&&this.worldview&&"string"==typeof a)if("all"===a)o.properties.$localized=!0;else {if(!a.split(",").includes(this.worldview))continue;o.properties.$localized=!0,o.properties.worldview=this.worldview;}!g&&o.properties&&o.properties.hasOwnProperty(t.fh)&&(g=!0),d.push({feature:o,id:r,index:i,sourceLayerIndex:u}),i++;}g&&!b.elevationFeatures&&e.layers.hasOwnProperty(t.fi)&&(b.elevationFeatures=t.fj.parseFrom(e.layers[t.fi],this.canonical));for(const e of v[s]){const s=e[0];if(this.extraShadowCaster&&(!s.is3D()||"model"===s.type))continue;if(this.renderSourceType===t.b4.Symbol&&"symbol"!==s.type)continue;if(this.renderSourceType===t.b4.FillExtrusion&&"fill-extrusion"!==s.type)continue;if(this.renderSourceType===t.b4.Other&&("symbol"===s.type||"fill-extrusion"===s.type))continue;if(s.minzoom&&this.zoom<Math.floor(s.minzoom))continue;if(s.maxzoom&&this.zoom>=s.maxzoom)continue;if("none"===s.visibility)continue;y(e,this.zoom,b.brightness,i,this.worldview,b.activeFloors);const n=m[s.id]=s.createBucket({index:f.bucketLayerIDs.length,layers:e,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:u,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:o,worldview:this.worldview,localizable:p,availableImages:i,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});f.bucketLayerIDs.push(e.map(e=>t.F(e.id,e.scope)));let r=n.prepare?n.prepare():null;null!=r?(r=r.then(()=>n.populate(d,b,this.tileID.canonical,this.tileTransform)),x.push(r)):n.populate(d,b,this.tileID.canonical,this.tileTransform);}}const S=()=>{w.trim();const s=!(!b.elevationFeatures||!b.elevationFeatures.some(e=>e.heightRange.min<0));let o,c,h,u,d,p,g;const x={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},v=()=>{if(o)return this.status="done",r(o);if(this.extraShadowCaster)this.status="done",r(null,{buckets:Object.values(m).filter(e=>!e.isEmpty()),featureIndex:f,collisionBoxArray:null,hasTunnelGeometry:s,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:b.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(c&&h&&u&&g){const e=void 0,s=new l(c),o=new Map;for(const[e,s]of h.entries()){const{imagePosition:i}=t.fn(e,s,t.fo);o.set(e,i);}const r={};for(const e in m){const n=m[e];n instanceof t.fp&&(y(n.layers,this.zoom,b.brightness,i,this.worldview,b.activeFloors),r[e]=t.fq(n,c,s.positions,h,o,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,d,this.worldview,i));}const a={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(n,h,d,()=>{a.iconsPending=!1,S(r,s,a,e,g);}),this.rasterizeIfNeeded(n,u,p,()=>{a.patternsPending=!1,S(r,s,a,e,g);});}},S=(e,o,a,l,c)=>{if(a.iconsPending||a.patternsPending)return;const d=h.size>0||u.size>0,p=Object.keys(e).length>0;if(!d&&!p)return this.status="done",void r(null,{buckets:Object.values(m).filter(e=>!e.isEmpty()),featureIndex:f,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:s,glyphAtlasImage:o.image,lineAtlas:w,imageAtlas:null,brightness:b.brightness});const g=(n,a)=>{for(const s in m){const o=m[s];if(s in e)t.fv(o,e[s],this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,h,a);else if(o.hasPattern&&(o instanceof t.fw||o instanceof t.fl||o instanceof t.e0)){y(o.layers,this.zoom,b.brightness,i,this.worldview,b.activeFloors);const e=Object.fromEntries(a.patternPositions);o.addFeatures(b,this.tileID.canonical,e,i,this.tileTransform,this.brightness);}}this.status="done",r(null,{buckets:Object.values(m).filter(e=>!e.isEmpty()),featureIndex:f,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:s,glyphAtlasImage:o.image,lineAtlas:w,imageAtlas:n,brightness:b.brightness});};if(d){const e=new Map,s=t.fr(h,e),i=t.fr(u,e),o=new t.fs(s,i,c,this.lut,e);n.send("checkAtlasCache",{descriptor:o,scope:this.scope},(e,s)=>{let i,o;if(e&&t.w(`[Worker] Error checking atlas cache: ${e.message}`),s)i=new t.ft(s.sourceHash),o=s;else {const e=new t.fu(h,u,this.lut,c);i=e,o=e;}g(i,o);});}else g(null,{iconPositions:new Map,patternPositions:new Map});};if(!this.extraShadowCaster){const e=t.fk(b.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(e).length?n.send("getGlyphs",{uid:this.uid,stacks:e},(e,t)=>{o||(o=e,c=t,v());},void 0,!1,x):c={},g=new Map;const s=Array.from(b.iconDependencies.keys()).map(e=>t.I.parse(e));s.length?n.send("getImages",{images:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,t)=>{if(!o){o=e,h=new Map,d=this.updateImageMapAndGetImageTaskQueue(h,t.images,b.iconDependencies);for(const[e,s]of t.versions.entries())g.set(e,s);v();}},void 0,!1,x):(h=new Map,d=new Map);const i=Array.from(b.patternDependencies.keys()).map(e=>t.I.parse(e));i.length?n.send("getImages",{images:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,t)=>{if(!o){o=e,u=new Map,p=this.updateImageMapAndGetImageTaskQueue(u,t.images,b.patternDependencies);for(const[e,s]of t.versions.entries())g.set(e,s);v();}},void 0,!1,x):(u=new Map,p=new Map);}if(b.elevationFeatures&&b.elevationFeatures.length>0){const s=[];for(const e of Object.values(m))if(e instanceof t.fl){const t=e.getUnevaluatedPortalGraph();t&&s.push(t);}const i=t.fm.evaluate(s);for(const s of Object.values(m))if(s instanceof t.fl){const t=e.layers[a.decode(s.sourceLayerIndex)];s.setEvaluatedPortalGraph(i,t,this.tileID.canonical,b.availableImages,b.brightness);}}v();};x.length>0?Promise.allSettled(x).then(S).catch(r):S();}updateParameters(e){this.scaleFactor=e.scaleFactor,this.showCollisionBoxes=e.showCollisionBoxes,this.projection=e.projection,this.brightness=e.brightness,this.tileTransform=t.fc(e.tileID.canonical,e.projection),this.extraShadowCaster=e.extraShadowCaster,this.lut=e.lut,this.worldview=e.worldview,this.indoor=e.indoor;}rasterizeIfNeeded(e,t,s,i){Array.from(t.values()).some(e=>e.usvg)?this.rasterize(e,t,s,i):i();}updateImageMapAndGetImageTaskQueue(e,t,s){const i=new Map;for(const o of t.keys()){const n=s.get(o)||[];for(const s of n){const o=s.toString(),n=t.get(s.id.toString());n.usvg?i.has(o)||(i.set(o,s),e.set(o,Object.assign({},n))):e.set(o,n);}}return i}rasterize(e,t,s,i){this.rasterizeTask=e.send("rasterizeImages",{scope:this.scope,tasks:s},(e,s)=>{if(!e)for(const[e,i]of s.entries()){const s=Object.assign(t.get(e),{data:i});t.set(e,s);}i();});}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel();}}function y(e,s,i,o,n,r){const a=new t.ae(s,{brightness:i,worldview:n,activeFloors:r});for(const t of e)t.recalculate(a,o);}class w extends t.E{constructor({actor:e,layerIndex:s,availableImages:i,availableModels:o,isSpriteLoaded:n,tileProvider:r,brightness:a,maxUniformBufferBindings:l,maxUniformBlockSizeDwords:c,disableSymbolUBO:h}){super(),this.actor=e,this.layerIndex=s,this.availableImages=i,this.availableModels=o,this.loadVectorData=t.aO,this.tileProvider=r,this.loading={},this.loaded={},this.deduped=new t.aN(e.scheduler),this.isSpriteLoaded=n,this.scheduler=e.scheduler,this.brightness=a,this.maxUniformBufferBindings=l,this.maxUniformBlockSizeDwords=c,this.disableSymbolUBO=h;}loadTileData(e,t){if(!this.tileProvider)return this.loadVectorData(e,t);const s=new AbortController,{z:i,x:o,y:n}=e.tileID.canonical;return this.tileProvider.loadTile({z:i,x:o,y:n},{request:e.request,signal:s.signal}).then(e=>{if(s.signal.aborted)return;if(null==e){const e=new Error("Tile not found");return e.status=404,t(e)}if(null===e.data)return t(null,null);const i=new Map;e.expires&&i.set("expires",e.expires),e.cacheControl&&i.set("cache-control",e.cacheControl),t(null,{rawData:e.data,responseHeaders:i});}).catch(e=>{s.signal.aborted||t(e instanceof Error?e:new Error(String(e)));}),()=>s.abort()}loadTile(e,i){const o=e.uid,n=e&&e.request,r=n&&n.collectResourceTiming,a=this.loading[o]=new m(e);a.maxUniformBufferBindings=this.maxUniformBufferBindings,a.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,a.disableSymbolUBO=this.disableSymbolUBO,a.abort=this.loadTileData(e,(l,c)=>{const h=!this.loading[o];if(delete this.loading[o],a.cancelRasterize(),h||l||!c)return a.status="done",h||(this.loaded[o]=a),i(l);const u=c.rawData,d={},f=t.aP(c.responseHeaders);f&&f.expires&&(d.expires=f.expires),f&&f.cacheControl&&(d.cacheControl=f.cacheControl),a.vectorTile=c.vectorTile||new t.fx(new t.a$(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,t)=>{if(e||!t)return i(e);const o={};if(r){const e=s(n);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)));}i(null,Object.assign({rawTileData:u.slice(0),responseHeaders:c.responseHeaders},t,d,o));});};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",renderSourceType:e.renderSourceType,zoom:e.tileZoom}):p();}),this.loaded=this.loaded||{},this.loaded[o]=a;});}reloadTile(e,t){const s=this.loaded,i=e.uid;if(s&&s[i]){const o=s[i];o.updateParameters(e);const n=(e,s)=>{const i=o.reloadCallback;i&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,i)),t(e,s);};"parsing"===o.status?o.reloadCallback=n:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,n):n());}else t(null,void 0);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.abort&&i.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=this.loaded,i=e.uid;s&&s[i]&&delete s[i],t();}}class b{constructor(e){this.loading={};}loadTile(e,s){const i=e.uid,{cancel:o}=t.b1(e.request,(o,n,r)=>{const a=!this.loading[i];if(delete this.loading[i],a||o||!n)return s(o);this.decodeTile(i,n,e.encoding).then(e=>{const{expires:i,cacheControl:o}=t.aP(r);s(null,Object.assign(e,{expires:i,cacheControl:o}));}).catch(e=>s(e));});this.loading[i]={cancel:o};}async decodeTile(e,s,i){const o=await createImageBitmap(new Blob([new Uint8Array(s)],{type:"image/png"})),n=1-(o.width-t.fy(o.width))/2,r=n<1,a=this.getImageData(o,n);return o.close(),{dem:new t.fz(e,a,i,r),borderReady:r}}reloadTile(e,t){t(null,null);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.cancel(),delete this.loading[s]),t();}removeTile(e,t){t();}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const s=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),s}}t.a_.setPbf(t.a$);class x{constructor(e){this._mrt=new t.a_(e.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=e.uid,this.tileID=e.tileID,this.source=e.source;}parse(e,s){const i=this._mrt;this.status="parsing",this._entireBuffer=e;try{i.parseHeader(e),this._isHeaderLoaded=!0;const o=[];for(const s in i.layers){const n=i.getLayer(s),r=n.getDataRange(n.getBandList()),a=i.createDecodingTask(r),l=e.slice(r.firstByte,r.lastByte+1),c=t.a_.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null));o.push(c);}Promise.allSettled(o).then(()=>s(null,i)).catch(e=>s(e));}catch(e){s(e);}}}class v{constructor({actor:e}){this.actor=e,this.loading={},this.loaded={};}loadTile(e,s){const i=e.uid,o=e.request,n=this.loading[i]=new x(e),{cancel:r}=t.b1(o,(e,t,o)=>{const r=!this.loading[i];if(delete this.loading[i],r||e||!t)return n.status="done",r||(this.loaded[i]=n),s(e);n.parse(t,(e,t)=>{if(e||!t)return s(e);s(null,t,o);}),this.loaded[i]=n;});n.abort=r;}reloadTile(e,t){t(null,void 0);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.abort&&i.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=e.uid;this.loaded[s]&&delete this.loaded[s],t();}decodeRasterArray(e,s){t.a_.performDecoding(e.buffer,e.task).then(e=>s(null,e)).catch(e=>s(e));}}const S=t.fA.prototype.toGeoJSON;class I{constructor(e){this._feature=e,this.extent=t.an,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10));}loadGeometry(){if(1===this._feature.type){const e=[];for(const s of this._feature.geometry)e.push([new t.P(s[0],s[1])]);return e}{const e=[];for(const s of this._feature.geometry){const i=[];for(const e of s)i.push(new t.P(e[0],e[1]));e.push(i);}return e}}toGeoJSON(e,t,s){return S.call(this,e,t,s)}}class M{constructor(e,s){this.name=e,this.extent=t.an,this.length=s.length,this._jsonFeatures=s;}feature(e){return new I(this._jsonFeatures[e])}}class P{constructor(e){this.layers={},this.extent=t.an;for(const t of Object.keys(e))this.layers[t]=new M(t,e[t]);}}const T=64/4096;class k{constructor(){this.features=new Map;}clear(){this.features.clear();}load(e=[],t){for(const s of e){const e=s.id;if(null==e)continue;let i=this.features.get(e);i&&this.updateCache(i,t),s.geometry?(i=z(s),this.updateCache(i,t),this.features.set(e,i)):this.features.delete(e),this.updateCache(i,t);}}updateCache(e,t){for(const{canonical:s,uid:i}of Object.values(t)){const{z:o,x:n,y:r}=s;_(e,Math.pow(2,o),n,r)&&delete t[i];}}getTile(e,t,s){const i=Math.pow(2,e),o=[];for(const e of this.features.values())_(e,i,t,s)&&o.push(O(e,i,t,s));return {features:o}}getFeatures(){return [...this.features.values()]}}function _({minX:e,minY:t,maxX:s,maxY:i},o,n,r){return e<(n+1+T)/o&&t<(r+1+T)/o&&s>(n-T)/o&&i>(r-T)/o}function z(e){const{id:t,geometry:s,properties:i}=e;if(!s)return;if("GeometryCollection"===s.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:o,coordinates:n}=s,r={id:t,type:1,geometry:[],tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=r.geometry;if("Point"===o)D(n,a,r);else if("MultiPoint"===o)for(const e of n)D(e,a,r);else if("LineString"===o)r.type=2,L(n,a,r);else if("MultiLineString"===o)r.type=2,C(n,a,r);else if("Polygon"===o)r.type=3,C(n,a,r,!0);else {if("MultiPolygon"!==o)throw new Error("Input data is not a valid GeoJSON object.");r.type=3;for(const e of n)C(e,a,r,!0);}return r}function D([e,s],i,o){const n=t.aH(e);let r=t.aL(s);r=r<0?0:r>1?1:r,i.push(n,r),o.minX=Math.min(o.minX,n),o.minY=Math.min(o.minY,r),o.maxX=Math.max(o.maxX,n),o.maxY=Math.max(o.maxY,r);}function L(e,t,s,i=!1,o=!1){const n=[];for(const t of e)D(t,n,s);t.push(n),i&&function(e,t){let s=0;for(let t=0,i=e.length,o=i-2;t<i;o=t,t+=2)s+=(e[t]-e[o])*(e[t+1]+e[o+1]);if(s>0===t)for(let t=0,s=e.length;t<s/2;t+=2){const i=e[t],o=e[t+1];e[t]=e[s-2-t],e[t+1]=e[s-1-t],e[s-2-t]=i,e[s-1-t]=o;}}(n,o);}function C(e,t,s,i=!1){for(let o=0;o<e.length;o++)L(e[o],t,s,i,0===o);}function O(e,s,i,o){const{id:n,type:r,geometry:a,tags:l}=e,c=[];if(1===r)!function(e,s,i,o,n){for(let r=0;r<e.length;r+=2){const a=Math.round(t.an*(e[r+0]*s-i)),l=Math.round(t.an*(e[r+1]*s-o));n.push([a,l]);}}(a,s,i,o,c);else if(2===r)for(const e of a)j(e,s,i,o,c);else if(3===r)for(const e of a)F(e,s,i,o,c);return {id:n,type:r,geometry:c,tags:l}}function j(e,s,i,o,n){const r=-128,a=t.an+128;let l;for(let c=0;c<e.length-2;c+=2){let h=Math.round(t.an*(e[c+0]*s-i)),u=Math.round(t.an*(e[c+1]*s-o)),d=Math.round(t.an*(e[c+2]*s-i)),f=Math.round(t.an*(e[c+3]*s-o));const p=d-h,g=f-u;h<r&&d<r||(h<r?(u+=Math.round(g*((r-h)/p)),h=r):d<r&&(f=u+Math.round(g*((r-h)/p)),d=r),u<r&&f<r||(u<r?(h+=Math.round(p*((r-u)/g)),u=r):f<r&&(d=h+Math.round(p*((r-u)/g)),f=r),h>=a&&d>=a||(h>=a?(u+=Math.round(g*((a-h)/p)),h=a):d>=a&&(f=u+Math.round(g*((a-h)/p)),d=a),u>=a&&f>=a||(u>=a?(h+=Math.round(p*((a-u)/g)),u=a):f>=a&&(d=h+Math.round(p*((a-u)/g)),f=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],n.push(l)),l.push([d,f])))));}}function F(e,s,i,o,n){const r=(i-T)/s,a=(o-T)/s,l=(i+1+T)/s,c=(o+1+T)/s;function h(e,t){let s=0;return e<r?s|=1:e>l&&(s|=2),t<a?s|=4:t>c&&(s|=8),s}let u=[];for(let t=1;t<=8;t*=2){let s=e[e.length-2],i=e[e.length-1],o=!(h(s,i)&t);for(let n=0;n<e.length;n+=2){const d=e[n],f=e[n+1],p=!(h(d,f)&t);p!==o&&(8&t?u.push(s+(d-s)*(c-i)/(f-i),c):4&t?u.push(s+(d-s)*(a-i)/(f-i),a):2&t?u.push(l,i+(f-i)*(l-s)/(d-s)):1&t&&u.push(r,i+(f-i)*(r-s)/(d-s))),p&&u.push(d,f),s=d,i=f,o=p;}if(!(e=u).length||8===t)break;u=[];}const d=[];for(let e=0;e<u.length;e+=2)d.push([Math.round(t.an*(u[e]*s-i)),Math.round(t.an*(u[e+1]*s-o))]);d.length&&n.push(d);}function B({name:e,features:s},i){i.writeStringField(1,e),i.writeVarintField(5,t.an);const o=new Map,n=new Map,r={keys:o,values:n,feature:null};for(const e of s)r.feature=e,i.writeMessage(2,A,r);for(const e of o.keys())i.writeStringField(3,e);for(const e of n.keys())i.writeMessage(4,N,e);}function A(e,t){const s=e.feature;void 0!==s.id&&Number.isSafeInteger(+s.id)&&t.writeVarintField(1,+s.id),s.tags&&t.writeMessage(2,E,e),t.writeVarintField(3,s.type),t.writeMessage(4,Z,s);}function E({keys:e,values:t,feature:s},i){for(const o of Object.keys(s.tags)){let n=s.tags[o];if(null===n)continue;let r=e.get(o);void 0===r&&(r=e.size,e.set(o,r)),i.writeVarint(r);const a=typeof n;"string"!==a&&"boolean"!==a&&"number"!==a&&(n=JSON.stringify(n));let l=t.get(n);void 0===l&&(l=t.size,t.set(n,l)),i.writeVarint(l);}}function U(e,t){return (t<<3)+(7&e)}function R(e){return e<<1^e>>31}function Z(e,t){const{geometry:s,type:i}=e;let o=0,n=0;if(1===i){t.writeVarint(U(1,s.length));for(const e of s){const s=e[0]-o,i=e[1]-n;t.writeVarint(R(s)),t.writeVarint(R(i)),o+=s,n+=i;}}else for(const e of s){if(0===e.length)continue;t.writeVarint(U(1,1));const s=e.length-(3===i?1:0);for(let i=0;i<s;i++){1===i&&t.writeVarint(U(2,s-1));const r=e[i][0]-o,a=e[i][1]-n;t.writeVarint(R(r)),t.writeVarint(R(a)),o+=r,n+=a;}3===i&&t.writeVarint(U(7,1));}}function N(e,t){const s=typeof e;"string"===s?t.writeStringField(1,e):"boolean"===s?t.writeBooleanField(7,e):"number"===s&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e));}const X={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Y=Math.fround||($=new Float32Array(1),e=>($[0]=+e,$[0]));var $;class G{constructor(e){this.options=Object.assign(Object.create(X),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:s,maxZoom:i}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;const n=[];for(let t=0;t<e.length;t++){const s=e[t];if(!s.geometry)continue;const[i,o]=s.geometry.coordinates,r=Y(q(i)),a=Y(W(o));n.push(r,a,1/0,t,-1,1),this.options.reduce&&n.push(0);}let r=this.trees[i+1]=this._createTree(n);t&&console.timeEnd(o);for(let e=i;e>=s;e--){const s=+Date.now();r=this.trees[e]=this._createTree(this._cluster(r,e)),t&&console.log("z%d: %d clusters in %dms",e,r.numItems,+Date.now()-s);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let s=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let o=180===e[2]?180:((e[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)s=-180,o=180;else if(s>o){const e=this.getClusters([s,i,180,n],t),r=this.getClusters([-180,i,o,n],t);return e.concat(r)}const r=this.trees[this._limitZoom(t)],a=r.range(q(s),W(n),q(o),W(i)),l=r.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?J(l,t,this.clusterProps):this.points[l[t+3]]);}return c}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),i="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(i);const n=o.data;if(t*this.stride>=n.length)throw new Error(i);const r=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=o.within(n[t*this.stride],n[t*this.stride+1],r),l=[];for(const t of a){const s=t*this.stride;n[s+4]===e&&l.push(n[s+5]>1?J(n,s,this.clusterProps):this.points[n[s+3]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,s){const i=[];return this._appendLeaves(i,e,t=t||10,s=s||0,0),i}getTile(e,t,s){const i=this.trees[this._limitZoom(e)],o=Math.pow(2,e),{extent:n,radius:r}=this.options,a=r/n,l=(s-a)/o,c=(s+1+a)/o,h={features:[]};return this._addTileFeatures(i.range((t-a)/o,l,(t+1+a)/o,c),i.data,t,s,o,h),0===t&&this._addTileFeatures(i.range(1-a/o,l,1,c),i.data,o,s,o,h),t===o-1&&this._addTileFeatures(i.range(0,l,a/o,c),i.data,-1,s,o,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const s=this.getChildren(e);if(t++,1!==s.length)break;e=s[0].properties.cluster_id;}return t}_appendLeaves(e,t,s,i,o){const n=this.getChildren(t);for(const t of n){const n=t.properties;if(n&&n.cluster?o+n.point_count<=i?o+=n.point_count:o=this._appendLeaves(e,n.cluster_id,s,i,o):o<i?o++:e.push(t),e.length===s)break}return o}_createTree(e){const s=new t.bI(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let t=0;t<e.length;t+=this.stride)s.add(e[t],e[t+1]);return s.finish(),s.data=e,s}_addTileFeatures(e,t,s,i,o,n){for(const r of e){const e=r*this.stride,a=t[e+5]>1;let l,c,h;if(a)l=V(t,e,this.clusterProps),c=t[e],h=t[e+1];else {const s=this.points[t[e+3]];l=s.properties;const[i,o]=s.geometry.coordinates;c=q(i),h=W(o);}const u={type:1,geometry:[[Math.round(this.options.extent*(c*o-s)),Math.round(this.options.extent*(h*o-i))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(u.id=d),n.features.push(u);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:s,extent:i,reduce:o,minPoints:n}=this.options,r=s/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let s=0;s<a.length;s+=c){if(a[s+2]<=t)continue;a[s+2]=t;const i=a[s],h=a[s+1],u=e.within(a[s],a[s+1],r),d=a[s+5];let f=d;for(const e of u){const s=e*c;a[s+2]>t&&(f+=a[s+5]);}if(f>d&&f>=n){let e,n=i*d,r=h*d,p=-1;const g=(s/c<<5)+(t+1)+this.points.length;for(const i of u){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const h=a[l+5];n+=a[l]*h,r+=a[l+1]*h,a[l+4]=g,o&&(e||(e=this._map(a,s,!0),p=this.clusterProps.length,this.clusterProps.push(e)),o(e,this._map(a,l)));}a[s+4]=g,l.push(n/f,r/f,1/0,g,-1,f),o&&l.push(p);}else {for(let e=0;e<c;e++)l.push(a[s+e]);if(f>1)for(const e of u){const s=e*c;if(!(a[s+2]<=t)){a[s+2]=t;for(let e=0;e<c;e++)l.push(a[s+e]);}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,s){if(e[t+5]>1){const i=this.clusterProps[e[t+6]];return s?Object.assign({},i):i}const i=this.points[e[t+3]].properties,o=this.options.map(i);return s&&o===i?Object.assign({},o):o}}function J(e,t,s){return {type:"Feature",id:e[t+3],properties:V(e,t,s),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),H(e[t+1])]}};var i;}function V(e,t,s){const i=e[t+5],o=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,n=e[t+6],r=-1===n?{}:Object.assign({},s[n]);return Object.assign(r,{cluster:!0,cluster_id:e[t+3],point_count:i,point_count_abbreviated:o})}function q(e){return e/360+.5}function W(e){const t=Math.sin(e*Math.PI/180),s=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return s<0?0:s>1?1:s}function H(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function Q(e,t,s,i){let o=i;const n=t+(s-t>>1);let r,a=s-t;const l=e[t],c=e[t+1],h=e[s],u=e[s+1];for(let i=t+3;i<s;i+=3){const t=K(e[i],e[i+1],l,c,h,u);if(t>o)r=i,o=t;else if(t===o){const e=Math.abs(i-n);e<a&&(r=i,a=e);}}o>i&&(r-t>3&&Q(e,t,r,i),e[r+2]=o,s-r>3&&Q(e,r,s,i));}function K(e,t,s,i,o,n){let r=o-s,a=n-i;if(0!==r||0!==a){const l=((e-s)*r+(t-i)*a)/(r*r+a*a);l>1?(s=o,i=n):l>0&&(s+=r*l,i+=a*l);}return r=e-s,a=t-i,r*r+a*a}function ee(e,t,s,i){const o={id:e??null,type:t,geometry:s,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)te(o,s);else if("Polygon"===t)te(o,s[0]);else if("MultiLineString"===t)for(const e of s)te(o,e);else if("MultiPolygon"===t)for(const e of s)te(o,e[0]);return o}function te(e,t){for(let s=0;s<t.length;s+=3)e.minX=Math.min(e.minX,t[s]),e.minY=Math.min(e.minY,t[s+1]),e.maxX=Math.max(e.maxX,t[s]),e.maxY=Math.max(e.maxY,t[s+1]);}function se(e,t,s,i){if(!t.geometry)return;const o=t.geometry.coordinates;if(o&&0===o.length)return;const n=t.geometry.type,r=Math.pow(s.tolerance/((1<<s.maxZoom)*s.extent),2);let a=[],l=t.id;if(s.promoteId?l=t.properties[s.promoteId]:s.generateId&&(l=i||0),"Point"===n)ie(o,a);else if("MultiPoint"===n)for(const e of o)ie(e,a);else if("LineString"===n)oe(o,a,r,!1);else if("MultiLineString"===n){if(s.lineMetrics){for(const s of o)a=[],oe(s,a,r,!1),e.push(ee(l,"LineString",a,t.properties));return}ne(o,a,r,!1);}else if("Polygon"===n)ne(o,a,r,!0);else {if("MultiPolygon"!==n){if("GeometryCollection"===n){for(const o of t.geometry.geometries)se(e,{id:l,geometry:o,properties:t.properties},s,i);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const e of o){const t=[];ne(e,t,r,!0),a.push(t);}}e.push(ee(l,n,a,t.properties));}function ie(e,t){t.push(re(e[0]),ae(e[1]),0);}function oe(e,t,s,i){let o,n,r=0;for(let s=0;s<e.length;s++){const a=re(e[s][0]),l=ae(e[s][1]);t.push(a,l,0),s>0&&(r+=i?(o*l-a*n)/2:Math.sqrt(Math.pow(a-o,2)+Math.pow(l-n,2))),o=a,n=l;}const a=t.length-3;t[2]=1,Q(t,0,a,s),t[a+2]=1,t.size=Math.abs(r),t.start=0,t.end=t.size;}function ne(e,t,s,i){for(let o=0;o<e.length;o++){const n=[];oe(e[o],n,s,i),t.push(n);}}function re(e){return e/360+.5}function ae(e){const t=Math.sin(e*Math.PI/180),s=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return s<0?0:s>1?1:s}function le(e,t,s,i,o,n,r,a){if(i/=t,n>=(s/=t)&&r<i)return e;if(r<s||n>=i)return null;const l=[];for(const t of e){const e=t.geometry;let n=t.type;const r=0===o?t.minX:t.minY,c=0===o?t.maxX:t.maxY;if(r>=s&&c<i){l.push(t);continue}if(c<s||r>=i)continue;let h=[];if("Point"===n||"MultiPoint"===n)ce(e,h,s,i,o);else if("LineString"===n)he(e,h,s,i,o,!1,a.lineMetrics);else if("MultiLineString"===n)de(e,h,s,i,o,!1);else if("Polygon"===n)de(e,h,s,i,o,!0);else if("MultiPolygon"===n)for(const t of e){const e=[];de(t,e,s,i,o,!0),e.length&&h.push(e);}if(h.length){if(a.lineMetrics&&"LineString"===n){for(const e of h)l.push(ee(t.id,n,e,t.tags));continue}"LineString"!==n&&"MultiLineString"!==n||(1===h.length?(n="LineString",h=h[0]):n="MultiLineString"),"Point"!==n&&"MultiPoint"!==n||(n=3===h.length?"Point":"MultiPoint"),l.push(ee(t.id,n,h,t.tags));}}return l.length?l:null}function ce(e,t,s,i,o){for(let n=0;n<e.length;n+=3){const r=e[n+o];r>=s&&r<=i&&fe(t,e[n],e[n+1],e[n+2]);}}function he(e,t,s,i,o,n,r){let a=ue(e);const l=0===o?pe:ge;let c,h,u=e.start;for(let d=0;d<e.length-3;d+=3){const f=e[d],p=e[d+1],g=e[d+2],m=e[d+3],y=e[d+4],w=0===o?f:p,b=0===o?m:y;let x=!1;r&&(c=Math.sqrt(Math.pow(f-m,2)+Math.pow(p-y,2))),w<s?b>s&&(h=l(a,f,p,m,y,s),r&&(a.start=u+c*h)):w>i?b<i&&(h=l(a,f,p,m,y,i),r&&(a.start=u+c*h)):fe(a,f,p,g),b<s&&w>=s&&(h=l(a,f,p,m,y,s),x=!0),b>i&&w<=i&&(h=l(a,f,p,m,y,i),x=!0),!n&&x&&(r&&(a.end=u+c*h),t.push(a),a=ue(e)),r&&(u+=c);}let d=e.length-3;const f=e[d],p=e[d+1],g=0===o?f:p;g>=s&&g<=i&&fe(a,f,p,e[d+2]),d=a.length-3,n&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&fe(a,a[0],a[1],a[2]),a.length&&t.push(a);}function ue(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function de(e,t,s,i,o,n){for(const r of e)he(r,t,s,i,o,n,!1);}function fe(e,t,s,i){e.push(t,s,i);}function pe(e,t,s,i,o,n){const r=(n-t)/(i-t);return fe(e,n,s+(o-s)*r,1),r}function ge(e,t,s,i,o,n){const r=(n-s)/(o-s);return fe(e,t+(i-t)*r,n,1),r}function me(e,t){const s=[];for(let i=0;i<e.length;i++){const o=e[i],n=o.type;let r;if("Point"===n||"MultiPoint"===n||"LineString"===n)r=ye(o.geometry,t);else if("MultiLineString"===n||"Polygon"===n){r=[];for(const e of o.geometry)r.push(ye(e,t));}else if("MultiPolygon"===n){r=[];for(const e of o.geometry){const s=[];for(const i of e)s.push(ye(i,t));r.push(s);}}s.push(ee(o.id,n,r,o.tags));}return s}function ye(e,t){const s=[];s.size=e.size,void 0!==e.start&&(s.start=e.start,s.end=e.end);for(let i=0;i<e.length;i+=3)s.push(e[i]+t,e[i+1],e[i+2]);return s}function we(e,t){if(e.transformed)return e;const s=1<<e.z,i=e.x,o=e.y;for(const n of e.features){const e=n.geometry,r=n.type;if(n.geometry=[],1===r)for(let r=0;r<e.length;r+=2)n.geometry.push(be(e[r],e[r+1],t,s,i,o));else for(let r=0;r<e.length;r++){const a=[];for(let n=0;n<e[r].length;n+=2)a.push(be(e[r][n],e[r][n+1],t,s,i,o));n.geometry.push(a);}}return e.transformed=!0,e}function be(e,t,s,i,o,n){return [Math.round(s*(e*i-o)),Math.round(s*(t*i-n))]}function xe(e,t,s,i,o){const n=t===o.maxZoom?0:o.tolerance/((1<<t)*o.extent),r={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:s,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const t of e)ve(r,t,n,o);return r}function ve(e,t,s,i){const o=t.geometry,n=t.type,r=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),"Point"===n||"MultiPoint"===n)for(let t=0;t<o.length;t+=3)r.push(o[t],o[t+1]),e.numPoints++,e.numSimplified++;else if("LineString"===n)Se(r,o,e,s,!1,!1);else if("MultiLineString"===n||"Polygon"===n)for(let t=0;t<o.length;t++)Se(r,o[t],e,s,"Polygon"===n,0===t);else if("MultiPolygon"===n)for(let t=0;t<o.length;t++){const i=o[t];for(let t=0;t<i.length;t++)Se(r,i[t],e,s,!0,0===t);}if(r.length){let s=t.tags||null;if("LineString"===n&&i.lineMetrics){s={};for(const e in t.tags)s[e]=t.tags[e];s.mapbox_clip_start=o.start/o.size,s.mapbox_clip_end=o.end/o.size;}const a={geometry:r,type:"Polygon"===n||"MultiPolygon"===n?3:"LineString"===n||"MultiLineString"===n?2:1,tags:s};null!==t.id&&(a.id=t.id),e.features.push(a);}}function Se(e,t,s,i,o,n){const r=i*i;if(i>0&&t.size<(o?r:i))return void(s.numPoints+=t.length/3);const a=[];for(let e=0;e<t.length;e+=3)(0===i||t[e+2]>r)&&(s.numSimplified++,a.push(t[e],t[e+1])),s.numPoints++;o&&function(e,t){let s=0;for(let t=0,i=e.length,o=i-2;t<i;o=t,t+=2)s+=(e[t]-e[o])*(e[t+1]+e[o+1]);if(s>0===t)for(let t=0,s=e.length;t<s/2;t+=2){const i=e[t],o=e[t+1];e[t]=e[s-2-t],e[t+1]=e[s-1-t],e[s-2-t]=i,e[s-1-t]=o;}}(a,n),e.push(a);}const Ie={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Me{constructor(e,t){const s=(t=this.options=function(e,t){for(const s in t)e[s]=t[s];return e}(Object.create(Ie),t)).debug;if(s&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const s=[];if("FeatureCollection"===e.type)for(let i=0;i<e.features.length;i++)se(s,e.features[i],t,i);else se(s,"Feature"===e.type?e:{geometry:e},t);return s}(e,t);this.tiles={},this.tileCoords=[],s&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),i=function(e,t){const s=t.buffer/t.extent;let i=e;const o=le(e,1,-1-s,s,0,-1,2,t),n=le(e,1,1-s,2+s,0,-1,2,t);return (o||n)&&(i=le(e,1,-s,1+s,0,-1,2,t)||[],o&&(i=me(o,1).concat(i)),n&&(i=i.concat(me(n,-1)))),i}(i,t),i.length&&this.splitTile(i,0,0,0),s&&(i.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)));}splitTile(e,t,s,i,o,n,r){const a=[e,t,s,i],l=this.options,c=l.debug;for(;a.length;){i=a.pop(),s=a.pop(),t=a.pop(),e=a.pop();const h=1<<t,u=Pe(t,s,i);let d=this.tiles[u];if(!d&&(c>1&&console.time("creation"),d=this.tiles[u]=xe(e,t,s,i,l),this.tileCoords.push({z:t,x:s,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,s,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==o){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===o)continue;if(null!=o){const e=o-t;if(s!==n>>e||i!==r>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,p=.5-f,g=.5+f,m=1+f;let y=null,w=null,b=null,x=null,v=le(e,h,s-f,s+g,0,d.minX,d.maxX,l),S=le(e,h,s+p,s+m,0,d.minX,d.maxX,l);e=null,v&&(y=le(v,h,i-f,i+g,1,d.minY,d.maxY,l),w=le(v,h,i+p,i+m,1,d.minY,d.maxY,l),v=null),S&&(b=le(S,h,i-f,i+g,1,d.minY,d.maxY,l),x=le(S,h,i+p,i+m,1,d.minY,d.maxY,l),S=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*s,2*i),a.push(w||[],t+1,2*s,2*i+1),a.push(b||[],t+1,2*s+1,2*i),a.push(x||[],t+1,2*s+1,2*i+1);}}getTile(e,t,s){e=+e,t=+t,s=+s;const i=this.options,{extent:o,debug:n}=i;if(e<0||e>24)return null;const r=1<<e,a=Pe(e,t=t+r&r-1,s);if(this.tiles[a])return we(this.tiles[a],o);n>1&&console.log("drilling down to z%d-%d-%d",e,t,s);let l,c=e,h=t,u=s;for(;!l&&c>0;)c--,h>>=1,u>>=1,l=this.tiles[Pe(c,h,u)];return l&&l.source?(n>1&&(console.log("found parent tile z%d-%d-%d",c,h,u),console.time("drilling down")),this.splitTile(l.source,c,h,u,e,t,s),n>1&&console.timeEnd("drilling down"),this.tiles[a]?we(this.tiles[a],o):null):null}}function Pe(e,t,s){return 32*((1<<e)*s+t)+e}function Te(e,s){const i=e.tileID.canonical;if(!this._geoJSONIndex)return void s(null,null);const o=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!o)return void s(null,null);const n=e=>e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,r=o.features.filter(e=>n(e));let a={_geojsonTileLayer:o.features};r.length>0&&(a={_geojsonTileLayer:o.features.filter(e=>!n(e)),hd_road_elevation:r});const l=new P(a),c=function(e){const s=new t.a$;for(const t of Object.keys(e))s.writeMessage(3,B,{name:t,features:e[t]});return s.finish()}(a).buffer;s(null,{vectorTile:l,rawData:c});}class ke extends w{constructor(e){super(e),this.loadVectorData=Te,this._dynamicIndex=new k;}loadData(e,i){const o=e&&e.request,n=o&&o.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(e,(r,a)=>{if(r||!a)return i(r);if("object"!=typeof a)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{try{if(e.filter){const s=t.X(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===s.result)throw new Error(s.value.map(e=>`${e.key}: ${e.message}`).join(", "));a.features=a.features.filter(e=>s.value.evaluate({zoom:0},e));}e.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),e.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),e.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=e.cluster?new G(function({superclusterOptions:e,clusterProperties:s}){if(!s||!e)return e;const i={},o={},n={accumulated:null,zoom:0},r={properties:null},a=Object.keys(s);for(const e of a){const[n,r]=s[e],a=t.X(r),l=t.X("string"==typeof n?[n,["accumulated"],["get",e]]:n);i[e]=a.value,o[e]=l.value;}return e.map=e=>{r.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(n,r);return t},e.reduce=(e,t)=>{r.properties=t;for(const t of a)n.accumulated=e[t],e[t]=o[t].evaluate(n,r);},e}(e)).load(a.features):e.dynamic?this._dynamicIndex:function(e,t){return new Me(e,t)}(a,e.geojsonVtOptions);}catch(e){return i(e)}const r={};if(n){const t=s(o);t&&(r.resourceTiming={},r.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)));}i(null,r);}});}reloadTile(e,t){const s=this.loaded;return s&&s[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(e,s){if(e.request)t.m(e.request,s);else {if("string"!=typeof e.data)return s(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return s(null,JSON.parse(e.data))}catch(t){return s(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}},0);}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class _e{constructor(e,s,i){this.tileID=new t.aR(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=e.projection,this.brightness=s,this.worldview=i;}parse(e,s,i,o){this.status="parsing";const n=new t.aR(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),r=[],a=s.familiesBySource[i.source],l=new t.ff(n,i.promoteId);l.bucketLayerIDs=[],l.is3DTile=!0,t.fB(e).then(e=>{const s=e.json.extensionsUsed&&e.json.extensionsUsed.includes("MAPBOX_mesh_features")||e.json.asset.extras&&e.json.asset.extras.MAPBOX_mesh_features,c=e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression"),h=new t.ae(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const o in a)for(const u of a[o]){const o=u[0];l.bucketLayerIDs.push(u.map(e=>t.F(e.id,e.scope))),o.recalculate(h,[]);const a=t.fC(e,1/t.cS(i.tileID.canonical)),d=new t.fD(u,a,n,s,c,this.brightness,l,this.worldview);s||(d.needsUpload=!0),r.push(d),d.evaluate(o);}this.status="done",o(null,{buckets:r,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null});}).catch(e=>o(new Error(e.message)));}}class ze{constructor({actor:e,layerIndex:t,availableImages:s,availableModels:i,brightness:o,worldview:n}){this.actor=e,this.layerIndex=t,this.availableImages=s,this.availableModels=i,this.brightness=o,this.loading={},this.loaded={},this.worldview=n;}loadTile(e,s){const i=e.uid,o=this.loading[i]=new _e(e,this.brightness,this.worldview);t.b1(e.request,(t,n)=>{const r=!this.loading[i];return delete this.loading[i],r||t?(o.status="done",r||(this.loaded[i]=o),s(t)):n&&0!==n.byteLength?void o.parse(n,this.layerIndex,e,(e,t)=>{o.status="done",this.loaded=this.loaded||{},this.loaded[i]=o,e||!t?s(e):s(null,t);}):(o.status="done",this.loaded[i]=o,s())});}reloadTile(e,t){const s=this.loaded,i=e.uid;if(s&&s[i]){const o=s[i];o.projection=e.projection,o.brightness=e.brightness;const n=(s,i)=>{o.reloadCallback&&(delete o.reloadCallback,this.loadTile(e,t)),t(s,i);};"parsing"===o.status?o.reloadCallback=n:"done"===o.status&&this.loadTile(e,t);}}abortTile(e,t){const s=e.uid;this.loading[s]&&delete this.loading[s],t();}removeTile(e,t){const s=this.loaded,i=e.uid;s&&s[i]&&delete s[i],t();}}const De=new Map,Le=new Map;class Ce{constructor(e){this.self=e,this.actor=new t.A(e,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new t.z,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=t.c0({name:"mercator"}),this.workerSourceTypes={vector:w,geojson:ke,"raster-dem":b,"raster-array":v,"batched-model":ze},this.workerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=e=>{if(t.fF.isParsed())throw new Error("RTL text plugin already registered.");t.fF.setState({pluginStatus:t.fG.parsed,pluginURL:t.fF.getPluginURL()}),t.fF.applyArabicShaping=e.applyArabicShaping,t.fF.processBidirectionalText=e.processBidirectionalText,t.fF.processStyledBidirectionalText=e.processStyledBidirectionalText;for(const e of this.rtlPluginParsingListeners)e(null,!0);this.rtlPluginParsingListeners=[];};}clearCaches(e,t,s){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],s();}checkIfReady(e,t,s){s();}setReferrer(e,t){this.referrer=t;}spriteLoaded(e,s){this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={});const{scope:i,isLoaded:o}=s;if(this.isSpriteLoaded[e][i]=o,this.workerSources[e]&&this.workerSources[e][i])for(const s in this.workerSources[e][i]){const n=this.workerSources[e][i][s];for(const e in n){const s=n[e];s instanceof w&&(s.isSpriteLoaded=o,s.fire(new t.C("isSpriteLoaded")));}}}setImages(e,t,s){this.availableImages[e]||(this.availableImages[e]={});const{scope:i,images:o}=t;if(this.availableImages[e][i]=o,this.workerSources[e]&&this.workerSources[e][i]){for(const t in this.workerSources[e][i]){const s=this.workerSources[e][i][t];for(const e in s)s[e].availableImages=o;}s();}else s();}setModels(e,{scope:t,models:s},i){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=s,this.workerSources[e]&&this.workerSources[e][t]){for(const i in this.workerSources[e][t]){const o=this.workerSources[e][t][i];for(const e in o)o[e].availableModels=s;}i();}else i();}setProjection(e,s){this.projections[e]=t.c0(s);}setBrightness(e,t,s){this.brightness=t,s();}setContextParams(e,t,s){this.maxUniformBufferBindings=t.maxBindingPoints,this.maxUniformBlockSizeDwords=t.maxUniformBlockSizeDwords,this.disableSymbolUBO=t.disableSymbolUBO,s();}setWorldview(e,t,s){this.worldview=t,s();}setLayers(e,t,s){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),s();}updateLayers(e,t,s){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),s();}loadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).loadTile(t,s);}decodeRasterArray(e,t,s){this.getWorkerSource(e,t).decodeRasterArray(t,s);}reloadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).reloadTile(t,s);}abortTile(e,t,s){this.getWorkerSource(e,t).abortTile(t,s);}removeTile(e,t,s){this.getWorkerSource(e,t).removeTile(t,s);}removeSource(e,t,s){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const i=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==i.removeSource?i.removeSource(t,s):s();}loadTileProvider(e,t,s){(async function(e,t){const s=Le.get(e);if(s)return s;const i=De.get(e);if(void 0!==i)return i;const o=import(/* webpackIgnore: true */
/* @vite-ignore */
t).then(t=>{const s=t.default;if("function"!=typeof s)throw new Error(`TileProvider "${e}" module must default-export a class`);if("function"!=typeof s.prototype.loadTile)throw new Error(`TileProvider "${e}" class must have a loadTile method`);return Le.set(e,s),s}).finally(()=>{De.delete(e);});return De.set(e,o),o})(t.name,t.url).then(s=>{const i=new s(t.options);return this.getWorkerSource(e,{type:t.type,source:t.source,scope:t.scope},i),i.load&&t.request?i.load({request:t.request}):null}).then(e=>s(null,e)).catch(e=>s(e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error")));}loadWorkerSource(e,t,s){try{this.self.importScripts(t.url),s();}catch(e){s(e);}}syncRTLPluginState(e,s,i){if(t.fF.isParsed())i(null,!0);else if(t.fF.isParsing())this.rtlPluginParsingListeners.push(i);else try{t.fF.setState(s);const e=t.fF.getPluginURL();!t.fF.isLoaded()||t.fF.isParsed()||t.fF.isParsing()||null==e||(t.fF.setState({pluginStatus:t.fG.parsing,pluginURL:t.fF.getPluginURL()}),this.self.importScripts(e),t.fF.isParsed()?i(null,!0):this.rtlPluginParsingListeners.push(i));}catch(e){i(e);}}setConfig(e,s){Object.assign(t.g,s);}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let s=this.availableImages[e][t];return s||(s=[]),s}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let s=this.availableModels[e][t];return s||(s={}),s}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let s=this.layerIndexes[e][t];return s||(s=this.layerIndexes[e][t]=new r,s.scope=t),s}getWorkerSource(e,t,s){const{type:i,source:o,scope:n}=t,r=this.workerSources;if(r[e]||(r[e]={}),r[e][n]||(r[e][n]={}),r[e][n][i]||(r[e][n][i]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!r[e][n][i][o]){const t={send:(t,s,i,o,n,r)=>this.actor.send(t,s,i,e,n,r),scheduler:this.actor.scheduler},a=this.workerSourceTypes[i];if(!a)throw new Error(`Unknown worker source type "${i}".`);r[e][n][i][o]=new a({actor:t,layerIndex:this.getLayerIndex(e,n),availableImages:this.getAvailableImages(e,n),availableModels:this.getAvailableModels(e,n),isSpriteLoaded:this.isSpriteLoaded[e][n],tileProvider:s,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});}return r[e][n][i][o]}rasterizeImagesWorker(e,t,s){const i=new Map;for(const[s,{image:o,imageVariant:n}]of t.tasks.entries()){const r=this.imageRasterizer.rasterize(n,o,t.scope,e);i.set(s,r);}s(void 0,i);}removeRasterizedImages(e,t,s){this.imageRasterizer.removeImagesFromCacheByIds(t.imageIds,t.scope,e),s();}enforceCacheSizeLimit(e,s){t.fH(s);}getWorkerPerformanceMetrics(e,t,s){s(void 0,void 0);}}return t.fE(self)&&(self.worker=new Ce(self)),Ce});

define(["./shared"],function(e){var t="3.22.0";const i={create:"create",load:"load",fullLoad:"fullLoad"},o={mark(e){performance.mark(e);},measure(e,t,i){performance.measure(e,t,i);}};function r(t){const i=t.name.split("?")[0];return e.a(i)&&i.includes("mapbox-gl.js")?"javascript":e.a(i)&&i.includes("mapbox-gl.css")?"css":e.b(i)?"fontRange":e.c(i)?"sprite":e.i(i)?"style":e.d(i)?"tilejson":"other"}var n,s={},a=function(){if(n)return s;function e(e){return !t(e)}function t(t){return "undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return !1;var e,t,i=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(i);try{t=new Worker(o),e=!0;}catch(t){e=!1;}return t&&t.terminate(),URL.revokeObjectURL(o),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return !1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===i[o=t&&t.failIfMajorPerformanceCaveat]&&(i[o]=function(t){var i,o=function(t){var i=document.createElement("canvas"),o=Object.create(e.webGLContextAttributes);return o.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",o)}(t);if(!o)return !1;try{i=o.createShader(o.VERTEX_SHADER);}catch(e){return !1}return !(!i||o.isContextLost())&&(o.shaderSource(i,"void main() {}"),o.compileShader(i),!0===o.getShaderParameter(i,o.COMPILE_STATUS))}(o)),i[o]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var o;}n=1,s.supported=e,s.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},s}();function l(e,t,i){const o=document.createElement(e);return null!=t&&(o.className=t),i&&i.appendChild(o),o}function c(e,t,i){const o=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))o.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(o),o}const h="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,d=h&&void 0!==h.userSelect?"userSelect":"WebkitUserSelect";let _;function u(){h&&d&&(_=h[d],h[d]="none");}function p(){h&&d&&(h[d]=_);}function f(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",f,!0);}function m(){window.addEventListener("click",f,!0),window.setTimeout(()=>{window.removeEventListener("click",f,!0);},0);}function g(e,t){const i=e.getBoundingClientRect();return x(e,i,t)}function v(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;r<t.length;r++)o.push(x(e,i,t[r]));return o}function y(e){return /firefox/i.test(navigator.userAgent)&&/macintosh/i.test(navigator.userAgent)&&2===e.button&&e.ctrlKey?0:e.button}function x(t,i,o){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((o.clientX-i.left)*r,(o.clientY-i.top)*r)}const b="01",w="NO_ACCESS_TOKEN";class T{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken();}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return {token:["1",b,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt;}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,o){if(!e.e(i))return i;const r=S(i);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||o)}normalizeGlyphsURL(t,i){if(!e.e(t))return t;const o=S(t);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.e(t))return t;const o=S(t);return o.path=`/models/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeSourceURL(t,i,o,r){if(!e.e(t))return t;const n=S(t);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),o&&n.params.push(`language=${o}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||i)}normalizeIconsetURL(t,i){const o=S(t);return e.e(t)?(o.path=`/styles/v1${o.path}/iconset.pbf`,this._makeAPIURL(o,this._customAccessToken||i)):C(o)}normalizeSpriteURL(t,i,o,r){const n=S(t);return e.e(t)?(n.path=`/styles/v1${n.path}/sprite${i}${o}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${i}${o}`,C(n))}normalizeTileURL(t,i,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.e(t))return t;const r=S(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||o&&"raster"!==r.authority&&512===o?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${e.g.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${e.g.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${e.g.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${e.g.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||e.g.ACCESS_TOKEN;return e.g.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(t,i){const o=S(t);if(!o.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!o.path.match(/\.[\w]+$/))return t;let r="mapbox://";o.path.match(/^\/raster\/v1\//)?r+=`raster/${o.path.replace(`/${e.g.RASTER_URL_PREFIX}/`,"")}`:o.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${o.path.replace(`/${e.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${o.path.replace(`/${e.g.TILE_URL_VERSION}/`,"")}`;let n=o.params;return i&&(n=n.filter(e=>!e.match(/^access_token=/))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(t,i){const o=!!i&&e.e(i),r=[];for(const i of t.tiles||[])e.f(i)?r.push(this.canonicalizeTileURL(i,o)):r.push(i);return r}_makeAPIURL(t,i){const o="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=S(e.g.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1);}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!e.g.REQUIRE_ACCESS_TOKEN)return C(t);if(i=i||e.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${o}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return t.params=t.params.filter(e=>-1===e.indexOf("access_token")),t.params.push(`access_token=${i||""}`),C(t)}}const E=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function S(e){const t=e.match(E);if(!t)throw new Error("Unable to parse URL object");return {protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function C(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const I="mapbox.eventData";function R(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.l(i[1]))}catch(e){return null}}function D(t){return !(!e.g.EVENTS_URL||!t&&!e.g.ACCESS_TOKEN)}class A{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(t){const i=R(e.g.ACCESS_TOKEN);let o="";return o=i&&i.u?e.j(i.u):e.g.ACCESS_TOKEN||"",t?`${I}.${t}:${o}`:`${I}:${o}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(o);t&&(this.anonId=t);const n=localStorage.getItem(r);n&&(this.anonIdTimestamp=Number(n));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<s)&&this.refreshUUID();}catch(t){e.w("Unable to read from LocalStorage");}}refreshUUID(){this.anonId=e.u(),this.anonIdTimestamp=Date.now();}saveEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp"),n=this.anonId,s=this.anonIdTimestamp;if(t&&n)try{localStorage.setItem(o,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),s&&localStorage.setItem(r,s.toString());}catch(t){e.w("Unable to write to LocalStorage");}}processRequests(e){}postEvent(t,i,o,r){if(!e.g.EVENTS_URL)return;const n=S(e.g.EVENTS_URL);n.params.push(`access_token=${r||e.g.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(s,i):s,l={url:C(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.p(l,e=>{this.pendingRequest=null,o(e),this.saveEventData(),this.processRequests(r);});}queueRequest(e,t){this.queue.push(e),this.processRequests(t);}}class L extends A{constructor(e){super("metrics"),e&&(this.data=e);}postMetricsEvent(t){if(!D(t))return;this.anonId||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const i=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:i},t);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e);}}const P=new class extends A{constructor(e){super("appUserTurnstile"),this._customAccessToken=e;}postTurnstileEvent(t,i){D(i)&&Array.isArray(t)&&t.some(t=>e.e(t)||e.f(t))&&this.queueRequest(Date.now(),i);}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const o=R(e.g.ACCESS_TOKEN),r=o?o.u:e.g.ACCESS_TOKEN;let n=r!==this.eventData.tokenU;e.v(this.anonId)||(this.refreshUUID(),n=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;n=n||i>=1||i<-1||e.getDate()!==t.getDate();}else n=!0;n?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=r);},i):this.processRequests();}},O=P.postTurnstileEvent.bind(P),M=new class extends A{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(t,i,o,r){this.skuToken=i,this.errorCb=r,e.g.EVENTS_URL&&(o||e.g.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(w)));}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:o,timestamp:r}=this.queue.shift();o&&this.success[o]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID(),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):o&&(this.success[o]=!0);},i));}remove(){this.errorCb=null;}},z=M.postMapLoadEvent.bind(M),F=new class extends A{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap;}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:o,importedStyles:r}=t;if(!D(e))return;const n=this.getMapInstanceId(i),s={mapInstanceId:n,eventId:this.getEventId(n),style:o};r.length&&(s.importedStyles=r),this.queueRequest({timestamp:Date.now(),payload:s},e);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e);}},B=F.postStyleLoadEvent.bind(F),k=new L({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),N=k.postMetricsEvent.bind(k),U=new L({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),V=U.postMetricsEvent.bind(U),j=new class extends A{constructor(){super("gljs.performance");}postPerformanceEvent(e,t){D(e)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e);}processRequests(o){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:n,performanceData:s}=this.queue.shift(),a=function(o){const n=performance.getEntriesByType("resource"),s=performance.getEntriesByType("mark"),a=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const o of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,n=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,o.startTime),t[r]=Math.max(t[r]||-1/0,o.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==o.transferSize&&0===o.transferSize&&a(s),a(n);}return t}(function(e,t){const i={};if(e)for(const o of e){const e=t(o);void 0===i[e]&&(i[e]=[]),i[e].push(o);}return i}(n,r)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,h=c?c.effectiveType:void 0,d={counters:[],metadata:[],attributes:[]},_=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in a)_(d.counters,e,a[e]);if(o.interactionRange[0]!==1/0&&o.interactionRange[1]!==-1/0&&(_(d.counters,"interactionRangeMin",o.interactionRange[0]),_(d.counters,"interactionRangeMax",o.interactionRange[1])),s)for(const e of Object.values(i)){const t=s.find(t=>t.name===e);t&&_(d.counters,e,t.startTime);}return _(d.counters,"visibilityHidden",o.visibilityHidden),_(d.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.i(t)){const e=t.split("/").slice(-2);if(2===e.length)return `mapbox://styles/${e[0]}/${e[1]}`}}}(n)),_(d.attributes,"terrainEnabled",o.terrainEnabled?"true":"false"),_(d.attributes,"fogEnabled",o.fogEnabled?"true":"false"),_(d.attributes,"projection",o.projection),_(d.attributes,"zoom",o.zoom),_(d.metadata,"devicePixelRatio",l),_(d.metadata,"connectionEffectiveType",h),_(d.metadata,"navigatorUserAgent",navigator.userAgent),_(d.metadata,"screenWidth",window.screen.width),_(d.metadata,"screenHeight",window.screen.height),_(d.metadata,"windowWidth",window.innerWidth),_(d.metadata,"windowHeight",window.innerHeight),_(d.metadata,"mapWidth",o.width/l),_(d.metadata,"mapHeight",o.height/l),_(d.metadata,"webglRenderer",o.renderer),_(d.metadata,"webglVendor",o.vendor),_(d.metadata,"sdkVersion",t),_(d.metadata,"sdkIdentifier","mapbox-gl-js"),d}(s);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(n,a,()=>{},o);}},G=j.postPerformanceEvent.bind(j),Z=new class extends A{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(t,i,o,r){if(!e.g.API_URL||!e.g.SESSION_PATH)return;const n=S(e.g.API_URL+e.g.SESSION_PATH);n.params.push(`sku=${i||""}`),n.params.push(`access_token=${r||e.g.ACCESS_TOKEN||""}`);const s={url:C(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.h(s,e=>{this.pendingRequest=null,o(e),this.saveEventData(),this.processRequests(r);});}getSessionAPI(t,i,o,r){this.skuToken=i,this.errorCb=r,e.g.EVENTS_URL&&e.g.SESSION_PATH&&e.g.API_URL&&(o||e.g.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(w)));}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0);},e);}remove(){this.errorCb=null;}},q=Z.getSessionAPI.bind(Z),H=new Set;function W(e,t){t?H.add(e):H.delete(e);}class ${constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={};}isDirty(){return this._changed}setDirty(){this._changed=!0;}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty();}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e];}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty();}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty();}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty();}getUpdatedImages(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(e.I.toString(t)),this.setDirty();}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear();}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={};}}function X(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}const Y={workerUrl:"",workerClass:null,workerParams:void 0};function K(e){return null!=Y.workerClass?new Y.workerClass:new self.Worker(Y.workerUrl,Object.assign({name:e},Y.workerParams))}const J="mapboxgl_preloaded_worker_pool";class Q{constructor(e){this.active={},this.name=e;}acquire(e,t=Q.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<t;){const t=K(`${this.name||""}WorkerPool: ${e}-${this.workers.length}`);this.workers.push(t);}return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&0===this.numActive()&&(this.workers.forEach(e=>{e.terminate();}),this.workers=null);}isPreloaded(){return !!this.active[J]}numActive(){return Object.keys(this.active).length}}Q.workerCount=2;class ee{constructor(t,i,o="Worker",r=Q.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.r();const n=this.workerPool.acquire(this.id,r);for(let e=0;e<n.length;e++){const t=new ee.Actor(n[e],i,this.id);t.name=`${o} ${e}`,this.actors.push(t);}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0;});}broadcast(t,i,o){e.t(this.actors,(e,o)=>{e.send(t,i,o);},o=o||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove();}),this.actors=[],this.workerPool.release(this.id);}}let te,ie;function oe(){return te||(te=new Q),te}ee.Actor=e.A;class re extends e.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new e.x,this.dirty=!0,this.spriteFormat=t,"raster"!==t&&e.y()&&(this.imageRasterizerDispatcher=new ee((ie||(ie=new Q("ImageRasterizer")),ie),this,"Image Rasterizer Worker",1));}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.imageVersions.set(t,new Map),this.patterns.set(t,new Map),this.atlasImage.set(t,new e.q({width:1,height:1}));}removeScope(e){this.loaded.delete(e),this.imageProviders.delete(e),this.images.delete(e),this.updatedImages.delete(e),this.callbackDispatchedThisFrame.delete(e),this.imageVersions.delete(e),this.patterns.delete(e),this.atlasImage.delete(e);const t=this.atlasTexture.get(e);t&&(t.destroy(),this.atlasTexture.delete(e));}addImageProvider(e,t){this.imageProviders.has(t)||this.imageProviders.set(t,new Map),this.imageProviders.get(t).set(e.id,e);}removeImageProvider(e,t){this.imageProviders.has(t)&&this.imageProviders.get(t).delete(e);}getPendingImageProviders(){const e=[];for(const t of this.imageProviders.values())for(const i of t.values())i.hasPendingRequests()&&e.push(i);return e}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new e.z),this._imageRasterizer}isLoaded(){for(const e of this.loaded.keys())if(!this.loaded.get(e))return !1;return !0}setLoaded(e,t){if(this.loaded.get(t)!==e&&(this.loaded.set(t,e),e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[];}}hasImage(e,t){return !!this.getImage(e,t)}getImage(e,t){return this.images.get(t).get(e.toString())}addImage(e,t,i){if(this._validate(e,i)){this.images.get(t).set(e.toString(),i);const o=this.imageVersions.get(t),r=o.get(e.toString())||0;o.set(e.toString(),r+1);}}_validate(t,i){let o=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.B(new Error(`Image "${t.name}" has invalid "stretchX" value`))),o=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.B(new Error(`Image "${t.name}" has invalid "stretchY" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new e.B(new Error(`Image "${t.name}" has invalid "content" value`))),o=!1),o}_validateStretch(e,t){if(!e)return !0;let i=0;for(const o of e){if(o[0]<i||o[1]<o[0]||t<o[1])return !1;i=o[1];}return !0}_validateContent(e,t){if(!e)return !0;if(4!==e.length)return !1;if(!t.usvg){if(e[0]<0||t.data.width<e[0])return !1;if(e[1]<0||t.data.height<e[1])return !1;if(e[2]<0||t.data.width<e[2])return !1;if(e[3]<0||t.data.height<e[3])return !1}return !(e[2]<e[0]||e[3]<e[1])}updateImage(e,t,i){const o=this.images.get(t).get(e.toString());i.version=o.version+1,this.images.get(t).set(e.toString(),i),this.updatedImages.get(t).add(e);const r=this.imageVersions.get(t),n=r.get(e.toString())||0;r.set(e.toString(),n+1),this.removeFromImageRasterizerCache(e,t);}clearUpdatedImages(e){this.updatedImages.get(e).clear();}removeFromImageRasterizerCache(t,i){"raster"!==this.spriteFormat&&(e.y()?this.imageRasterizerDispatcher.getActor().send("removeRasterizedImages",{imageIds:[t],scope:i}):this.imageRasterizer.removeImagesFromCacheByIds([t],i));}removeImage(e,t){const i=this.images.get(t),o=i.get(e.toString());i.delete(e.toString());const r=this.imageVersions.get(t),n=r.get(e.toString())||0;r.set(e.toString(),n+1),this.patterns.get(t).delete(e.toString()),this.removeFromImageRasterizerCache(e,t),o.userImage&&o.userImage.onRemove&&o.userImage.onRemove();}listImages(t){return Array.from(this.images.get(t).keys()).map(t=>e.I.from(t))}getImageVersions(e){const t=this.imageVersions.get(e);if(t)return t}getImages(e,t,i){const o=[],r=[],n=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){o.push(i);continue}const e=n.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i));}if(0===o.length)return void this._notify(r,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of o)l.has(e.toString())||(s=!1);a||s?this._notify(o,t,i):this.requestors.push({ids:o,scope:t,callback:i});}rasterizeImages(e,t){const i=new Map,{tasks:o,scope:r}=e;for(const[e,t]of o.entries()){const o=this.getImage(t.id,r);o&&i.set(e,{image:o,imageVariant:t});}this._rasterizeImages(r,i,t);}_rasterizeImages(t,i,o){if(e.y())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:i,scope:t},o);else {const e=new Map;for(const[o,{image:r,imageVariant:n}]of i.entries())e.set(o,this.imageRasterizer.rasterize(n,r,t,0));o(void 0,e);}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,o){const r=this.images.get(i),n=new Map;for(const i of t){if(!r.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.C("styleimagemissing",{id:i.name}));}const t=r.get(i.toString());if(!t){e.w(`Image "${i.name}" 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.`);continue}const o={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(o,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),n.set(e.I.toString(i),o);}o(null,{images:n,versions:this.getImageVersions(i)});}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return {width:t,height:i}}getPattern(t,i,o){const r=t.toString(),n=this.patterns.get(i),s=n.get(r),a=this.getImage(t,i);if(!a)return null;if(s){if(s.position.version===a.version)return s.position;s.position.version=a.version;}else {if(a.usvg&&!a.data){const n=this.getPatternInFlightId(r,i);if(this.patternsInFlight.has(n))return null;this.patternsInFlight.add(n);const s=new e.D(t).scaleSelf(e.o.devicePixelRatio),l=new Map([[s.toString(),{image:a,imageVariant:s}]]);return this._rasterizeImages(i,l,(e,t)=>this.storePatternImage(s,i,a,o,t)),null}this.storePattern(t,i,a);}return this._updatePatternAtlas(i,o),n.get(r).position}getPatternInFlightId(t,i){return e.F(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,o,r){const n=e.toString(),s=r?r.get(n):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,o),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)));}storePattern(t,i,o){const r={w:o.data.width+2*e.G,h:o.data.height+2*e.G,x:0,y:0},n=new e.H(r,o,e.G);this.patterns.get(i).set(t.toString(),{bin:r,position:n});}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear();}bind(t,i){const o=t.gl;let r=this.atlasTexture.get(i);r?this.dirty&&(r.update(this.atlasImage.get(i)),this.dirty=!1):(r=new e.T(t,this.atlasImage.get(i),o.RGBA8),this.atlasTexture.set(i,r)),r.bind(o.LINEAR,o.CLAMP_TO_EDGE);}_updatePatternAtlas(t,i){const o=this.patterns.get(t),r=Array.from(o.values()).map(({bin:e})=>e),{w:n,h:s}=e.J(r),a=this.atlasImage.get(t);a.resize({width:n||1,height:s||1});const l=this.images.get(t);for(const[t,{bin:r,position:n}]of o.entries()){let o=n.padding;const s=r.x+o,c=r.y+o,h=l.get(t).data,d=h.width,_=h.height;o=o>1?o-1:o,e.q.copy(h,a,{x:0,y:0},{x:s,y:c},{width:d,height:_},i),e.q.copy(h,a,{x:0,y:_-o},{x:s,y:c-o},{width:d,height:o},i),e.q.copy(h,a,{x:0,y:0},{x:s,y:c+_},{width:d,height:o},i),e.q.copy(h,a,{x:d-o,y:0},{x:s-o,y:c},{width:o,height:_},i),e.q.copy(h,a,{x:0,y:0},{x:s+d,y:c},{width:o,height:_},i),e.q.copy(h,a,{x:d-o,y:_-o},{x:s-o,y:c-o},{width:o,height:o},i),e.q.copy(h,a,{x:0,y:_-o},{x:s+d,y:c-o},{width:o,height:o},i),e.q.copy(h,a,{x:0,y:0},{x:s+d,y:c+_},{width:o,height:o},i),e.q.copy(h,a,{x:d-o,y:0},{x:s-o,y:c+_},{width:o,height:o},i);}this.dirty=!0;}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set);}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const o of e){if(this.callbackDispatchedThisFrame.get(t).has(o.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(o.toString());const e=i.get(o.toString());X(e)&&this.updateImage(o,t,e);}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove();}}function ne(t){const i=t.value,o=t.valueSpec,r=t.style,n=t.styleSpec,s=t.key,a=t.arrayElementValidator||Ie;if(!Array.isArray(i))return [new e.V(s,i,`array expected, ${e.M(i)} found`)];if(o.length&&i.length!==o.length)return [new e.V(s,i,`array length ${o.length} expected, length ${i.length} found`)];if(o["min-length"]&&i.length<o["min-length"])return [new e.V(s,i,`array length at least ${o["min-length"]} expected, length ${i.length} found`)];let l={type:o.value,values:o.values,minimum:o.minimum,maximum:o.maximum,function:void 0};n.$version<7&&(l.function=o.function),e.K(o.value)&&(l=o.value);let c=[];for(let e=0;e<i.length;e++)c=c.concat(a({array:i,arrayIndex:e,value:i[e],valueSpec:l,style:r,styleSpec:n,key:`${s}[${e}]`},!0));return c}function se(t){const i=t.key,o=t.value,r=t.valueSpec;if(!e.N(o))return [new e.V(i,o,`number expected, ${e.M(o)} found`)];if(o!=o)return [new e.V(i,o,"number expected, NaN found")];if("minimum"in r){let n=r.minimum;if(Array.isArray(r.minimum)&&(n=r.minimum[t.arrayIndex]),o<n)return [new e.V(i,o,`${o} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if(Array.isArray(r.maximum)&&(n=r.maximum[t.arrayIndex]),o>n)return [new e.V(i,o,`${o} is greater than the maximum value ${n}`)]}return []}function ae(t){const i=t.key,o=t.value;if(!e.K(o))return [new e.V(i,o,`object expected, ${e.M(o)} found`)];const r=t.valueSpec,n=e.L(o.type);let s,a,l,c={};const h="categorical"!==n&&void 0===o.property,d=!h,_=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.K(i[0][0])}(o),u=Re({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===n)return [new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const o=t.value;return i=i.concat(ne({key:t.key,value:o,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:p})),Array.isArray(o)&&0===o.length&&i.push(new e.V(t.key,o,"array must have at least one stop")),i},default:function(e){return Ie({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===n&&h&&u.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===n||o.stops||u.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===n&&r.expression&&!e.O(r)&&u.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(d&&!e.Q(r)?u.push(new e.V(t.key,t.value,"property functions not supported")):h&&!e.S(r)&&u.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==n&&!_||void 0!==o.property||u.push(new e.V(t.key,t.value,'"property" property is required')),u;function p(t){let i=[];const o=t.value,n=t.key;if(!Array.isArray(o))return [new e.V(n,o,`array expected, ${e.M(o)} found`)];if(2!==o.length)return [new e.V(n,o,`array length 2 expected, length ${o.length} found`)];if(_){if(!e.K(o[0]))return [new e.V(n,o,`object expected, ${e.M(o[0])} found`)];const r=o[0];if(void 0===r.zoom)return [new e.V(n,o,"object stop key must have zoom")];if(void 0===r.value)return [new e.V(n,o,"object stop key must have value")];const s=e.L(r.zoom);if("number"!=typeof s)return [new e.V(n,r.zoom,"stop zoom values must be numbers")];if(l&&l>s)return [new e.V(n,r.zoom,"stop zoom values must appear in ascending order")];s!==l&&(l=s,a=void 0,c={}),i=i.concat(Re({key:`${n}[0]`,value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:se,value:f}}));}else i=i.concat(f({key:`${n}[0]`,value:o[0],style:t.style,styleSpec:t.styleSpec},o));return e.U(e.W(o[1]))?i.concat([new e.V(`${n}[1]`,o[1],"expressions are not allowed in function stops.")]):i.concat(Ie({key:`${n}[1]`,value:o[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function f(t,i){const o=e.M(t.value),l=e.L(t.value),h=null!==t.value?t.value:i;if(s){if(o!==s)return [new e.V(t.key,h,`${o} stop domain type must match previous stop domain type ${s}`)]}else s=o;if("number"!==o&&"string"!==o&&"boolean"!==o&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return [new e.V(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==n){let i=`number expected, ${o} found`;return e.Q(r)&&void 0===n&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,h,i)]}return "categorical"!==n||"number"!==o||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===o&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&l<a?[new e.V(t.key,h,"stop domain values must appear in ascending order")]:(a=l,"categorical"===n&&l in c?[new e.V(t.key,h,"stop domain values must be unique")]:(c[l]=!0,[])):[new e.V(t.key,h,`integer expected, found ${String(l)}`)]}}function le(t){const i=("property"===t.expressionContext?e.Y:e.X)(e.W(t.value),t.valueSpec);if("error"===i.result)return i.value.map(i=>new e.V(`${t.key}${i.key}`,t.value,i.message));const o=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!o.outputDefined())return [new e.V(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.$(o))return [new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return ce(o,t);if("appearance"===t.expressionContext)return he(o,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.Z(o,["zoom","feature-state"]))return [new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e._(o))return [new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function ce(t,i){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.delete(e);if(0===o.size)return [];const r=[];return t instanceof e.a0&&o.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild(e=>{r.push(...ce(e,i));}),r)}function he(t,i){const o=new Set;if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.add(e);if(0===o.size)return [];const r=[];return t instanceof e.a0&&!o.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]:(t.eachChild(e=>{r.push(...he(e,i));}),r)}function de(t){const i=t.key,o=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(e.L(o))&&n.push(new e.V(i,o,`expected one of [${r.values.join(", ")}], ${JSON.stringify(o)} found`)):-1===Object.keys(r.values).indexOf(e.L(o))&&n.push(new e.V(i,o,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(o)} found`)),n}function _e(t){return e.a4(e.W(t.value))?le(Object.assign({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):ue(t)}function ue(t){const i=t.value,o=t.key;if(!Array.isArray(i))return [new e.V(o,i,`array expected, ${e.M(i)} found`)];if(i.length<1)return [new e.V(o,i,"filter array must have at least 1 element")];const r=t.styleSpec;let n=de({key:`${o}[0]`,value:i[0],valueSpec:r.filter_operator});const s=()=>{i.length>=2&&(e.a2(i[1])||n.push(new e.V(`${o}[1]`,i[1],`string expected, ${e.M(i[1])} found`)));for(let t=2;t<i.length;t++)"$type"===e.L(i[1])?n=n.concat(de({key:`${o}[${t}]`,value:i[t],valueSpec:r.geometry_type})):e.a2(i[t])||e.N(i[t])||e.a1(i[t])||n.push(new e.V(`${o}[${t}]`,i[t],`string, number, or boolean expected, ${e.M(i[t])} found.`));};switch(e.L(i[0])){case "<":case "<=":case ">":case ">=":i.length>=2&&"$type"===e.L(i[1])&&n.push(new e.V(o,i,`"$type" cannot be use with operator "${i[0]}"`)),3!==i.length&&n.push(new e.V(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),s();break;case "==":case "!=":3!==i.length&&n.push(new e.V(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),s();break;case "in":case "!in":s();break;case "any":case "all":case "none":for(let e=1;e<i.length;e++)n=n.concat(ue({key:`${o}[${e}]`,value:i[e],style:t.style,styleSpec:t.styleSpec}));break;case "has":case "!has":2!==i.length?n.push(new e.V(o,i,`filter array for "${i[0]}" operator must have 2 elements`)):e.a2(i[1])||n.push(new e.V(`${o}[1]`,i[1],`string expected, ${e.M(i[1])} found`));}return n}function pe(t,i){const o=t.key,r=t.style,n=t.layer,s=t.styleSpec,a=t.value,l=t.objectKey,c=s[`${i}_${t.layerType}`];if(!c)return [];const h=l.match(/^(.*)-use-theme$/);if(h&&c[h[1]])return e.U(e.W(a))?[].concat(Ie({key:o,value:a,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:r,styleSpec:s,expressionContext:"property",propertyType:i,propertyKey:l})):Ie({key:o,value:a,valueSpec:{type:"string"},style:r,styleSpec:s});const d=l.match(/^(.*)-transition$/);if("paint"===i&&d&&c[d[1]]&&c[d[1]].transition)return Ie({key:o,value:a,valueSpec:s.transition,style:r,styleSpec:s});const _=t.valueSpec||c[l];if(!_)return [new e.a5(o,a,`unknown property "${l}"`)];let u;if(e.a2(a)&&e.Q(_)&&!_.tokens&&(u=/^{([^}]+)}$/.exec(a))){const t=`\`{ "type": "identity", "property": ${u?JSON.stringify(u[1]):'"_"'} }\``;return [new e.V(o,a,`"${l}" does not support interpolation syntax\nUse an identity property function instead: ${t}.`)]}const p=[];if("symbol"===t.layerType)"text-field"!==l||!r||r.glyphs||r.imports||p.push(new e.V(o,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===l&&e.a6(e.W(a))&&"identity"===e.L(a.type)&&p.push(new e.V(o,a,'"text-font" does not support identity functions'));else if("model"===t.layerType&&"paint"===i&&n&&n.layout&&n.layout.hasOwnProperty("model-id")&&e.Q(_)&&(e.a7(_)||e.S(_))){const t=e.Y(e.W(a),_).value,i="expression"in t&&t.expression||"_styleExpression"in t&&t._styleExpression&&t._styleExpression.expression;i&&!e.Z(i,["measure-light"])&&("model-emissive-strength"===l&&e._(i)&&e.$(i)||p.push(new e.V(o,a,`${l} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)));}return p.concat(Ie({key:t.key,value:a,valueSpec:_,style:r,styleSpec:s,expressionContext:"property",propertyType:i,propertyKey:l}))}function fe(e){return pe(e,"paint")}function me(e){return pe(e,"layout")}function ge(t){let i=[];const o=t.value,r=t.key,n=t.style,s=t.styleSpec;if(!e.K(o))return [new e.V(r,o,"object expected")];o.type||o.ref||i.push(new e.V(r,o,'either "type" or "ref" is required'));let a=e.L(o.type);const l=e.L(o.ref);if(o.id){const s=e.L(o.id);for(let a=0;a<t.arrayIndex;a++){const t=n.layers[a];e.L(t.id)===s&&i.push(new e.V(r,o.id,`duplicate layer id "${s}", previously used at line ${t.id.__line__}`));}}if("ref"in o){let t;["type","source","source-layer","filter","layout"].forEach(t=>{t in o&&i.push(new e.V(r,o[t],`"${t}" is prohibited for ref layers`));}),n.layers.forEach(i=>{e.L(i.id)===l&&(t=i);}),t?t.ref?i.push(new e.V(r,o.ref,"ref cannot reference another ref layer")):a=e.L(t.type):"string"==typeof l&&i.push(new e.V(r,o.ref,`ref layer "${l}" not found`));}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(o.source)if(e.a2(o.source)){const t=n.sources&&n.sources[o.source],s=t&&e.L(t.type);t?"vector"===s&&"raster"===a?i.push(new e.V(r,o.source,`layer "${o.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new e.V(r,o.source,`layer "${o.id}" requires a vector source`)):"vector"!==s||o["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new e.V(r,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"===a&&o.paint&&(o.paint["line-gradient"]||o.paint["line-trim-offset"])&&"geojson"===s&&!t.lineMetrics?i.push(new e.V(r,o,`layer "${o.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==s&&i.push(new e.V(r,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):i.push(new e.V(r,o.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(r,o,`layer "${o.id}" must specify a "source-layer"`)):i.push(new e.V(r,o.source,`source "${o.source}" not found`));}else i.push(new e.V(`${r}.source`,o.source,'"source" must be a string'));else i.push(new e.V(r,o,'missing required property "source"'));return i=i.concat(Re({key:r,value:o,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Ie({key:`${r}.type`,value:o.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:o,objectKey:"type"}),filter:e=>_e(Object.assign({layerType:a},e)),layout:e=>Re({layer:o,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>me(Object.assign({layerType:a},e))}}),paint:e=>Re({layer:o,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>fe(Object.assign({layerType:a,layer:o},e))}}),appearances(t){const i=ne({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:o,layerType:r}=t,n=e.L(t.value),s=e.L(n.name),a=e.L(n.condition),l=Re({key:i,value:n,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...le({key:t.key,value:t.object.condition,valueSpec:e.a8.appearance.condition,expressionContext:"appearance"})),i}(Object.assign({layer:o,layerType:r},t)),properties:t=>function(t){const i=[],{styleSpec:o,layer:r,layerType:n}=t,s=o[`paint_${n}`],a=o[`layout_${n}`],l=t.object[t.objectKey];for(const o in l){const c=o in s?"paint":o in a?"layout":void 0;if(!c){i.push(new e.V(t.key,o,`unknown property "${o}" for layer type "${n}"`));continue}const h=Object.assign({},t,{key:`${t.key}.${o}`,object:l,objectKey:o,layer:r,layerType:n,value:l[o],valueSpec:"paint"===c?s[o]:a[o]});i.push(...pe(h,c));}return i}(Object.assign({layer:o,layerType:r},t))}});return "hidden"!==s&&void 0===a&&l.push(new e.V(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}(Object.assign({layerType:a,layer:o},t))}),r=Array.isArray(t.value)?t.value:[],n=new Set;return r.forEach((r,s)=>{const a=e.L(r.name);if(a)if(n.has(a)){const r=e.L(o.id);i.push(new e.V(t.key,a,`Duplicated appearance name "${a}" for layer "${r}"`));}else n.add(a);}),i}}})),i}function ve({key:t,value:i}){return e.a2(i)?[]:[new e.V(t,i,`string expected, ${e.M(i)} found`)]}const ye={promoteId:function t({key:i,value:o}){if(e.a2(o))return ve({key:i,value:o});if(Array.isArray(o)){const t=[],r=e.W(o),n=e.X(r);return "error"===n.result?(n.value.forEach(o=>{t.push(new e.V(`${i}${o.key}`,null,`${o.message}`));}),t):(e.Z(n.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||t.push(new e.V(`${i}`,null,"promoteId expression should be only feature dependent")),t)}if(!e.K(o))return [new e.V(i,o,`string, expression or object expected, "${e.M(o)}" found`)];const r=[];for(const e in o)r.push(...t({key:`${i}.${e}`,value:o[e]}));return r}};function xe(t){const i=t.value,o=t.key,r=t.styleSpec,n=t.style;if(!e.K(i))return [new e.V(o,i,`object expected, ${e.M(i)} found`)];if(!("type"in i))return [new e.V(o,i,'"type" is required')];const s=e.L(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&("url"in i||"tiles"in i||a.push(new e.a5(o,i,'Either "url" or "tiles" is required.'))),s){case "vector":case "raster":case "raster-dem":case "raster-array":return a=a.concat(Re({key:o,value:i,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:ye})),a;case "geojson":if(a=Re({key:o,value:i,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:ye}),"cluster"in i&&"clusterProperties"in i){if(!e.K(i.clusterProperties))return [new e.V(`${o}.clusterProperties`,i,`object expected, ${e.M(i)} found`)];for(const t in i.clusterProperties){const r=i.clusterProperties[t];if(!Array.isArray(r))return [new e.V(`${o}.clusterProperties.${t}`,r,"array expected")];const[n,s]=r,l="string"==typeof n?[n,["accumulated"],["get",t]]:n;a.push(...le({key:`${o}.${t}.map`,value:s,expressionContext:"cluster-map"})),a.push(...le({key:`${o}.${t}.reduce`,value:l,expressionContext:"cluster-reduce"}));}}return a;case "video":return Re({key:o,value:i,valueSpec:r.source_video,style:n,styleSpec:r});case "image":return Re({key:o,value:i,valueSpec:r.source_image,style:n,styleSpec:r});case "canvas":return [new e.V(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return de({key:`${o}.type`,value:i.type,valueSpec:{values:be(r)}})}}function be(e){return e.source.reduce((t,i)=>{const o=e[i];return "enum"===o.type.type&&(t=t.concat(Object.keys(o.type.values||{}))),t},[])}function we(t){const i=t.value,o=t.styleSpec,r=o.light,n=t.style;if(void 0===i)return [];if(!e.K(i))return [new e.V("light",i,`object expected, ${e.M(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);s=s.concat(l&&r[l[1]]?Ie({key:t,value:i[t],valueSpec:{type:"string"},style:n,styleSpec:o}):a&&r[a[1]]&&r[a[1]].transition?Ie({key:t,value:i[t],valueSpec:o.transition,style:n,styleSpec:o}):r[t]?Ie({key:t,value:i[t],valueSpec:r[t],style:n,styleSpec:o}):[new e.V(t,i[t],`unknown property "${t}"`)]);}return s}function Te(t){const i=t.value;if(!i)return [];const o=t.key;if(!e.K(i))return [new e.V(o,i,`object expected, ${e.M(i)} found`)];let r=[];const n=t.styleSpec,s=n["light-3d"],a=t.style,l=t.style.lights;for(const t of ["type","id"])if(!(t in i))return r=r.concat([new e.V(o,i,`missing property "${t}"`)]),r;if(!e.a2(i.type))return r=r.concat([new e.V(`${o}.type`,i.type,"string expected")]),r;if(l)for(let n=0;n<t.arrayIndex;n++){const t=e.L(i.type),s=l[n];e.L(s.type)===t&&r.push(new e.V(o,i.id,`duplicate light type "${i.type}", previously defined at line ${s.id.__line__}`));}const c=`properties_light_${i.type}`;if(!(c in n))return r=r.concat([new e.V(`${o}.type`,i,`Invalid light type ${i.type}`)]),r;const h=n[c];for(const o in i)if("properties"===o){const s=i[o];if(!e.K(s))return r=r.concat([new e.V("properties",s,`object expected, ${e.M(s)} found`)]),r;for(const l in s){const c=l.match(/^(.*)-transition$/),d=l.match(/^(.*)-use-theme$/);r=r.concat(d&&h[d[1]]?Ie({key:o,value:s[l],valueSpec:{type:"string"},style:a,styleSpec:n}):c&&h[c[1]]&&h[c[1]].transition?Ie({key:o,value:i[o],valueSpec:n.transition,style:a,styleSpec:n}):h[l]?Ie({key:l,value:s[l],valueSpec:h[l],style:a,styleSpec:n}):[new e.a5(t.key,s[l],`unknown property "${l}"`)]);}}else r=r.concat(s[o]?Ie({key:o,value:i[o],valueSpec:s[o],style:a,styleSpec:n}):[new e.a5(o,i[o],`unknown property "${o}"`)]);return r}function Ee(t){const i=t.value,o=t.key,r=t.style,n=t.styleSpec,s=n.terrain;if(null==i)return [];if(!e.K(i))return [new e.V("terrain",i,`object expected, ${e.M(i)} found`)];let a=[];for(const t in i){const o=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);a=a.concat(l&&s[l[1]]?Ie({key:t,value:i[t],valueSpec:{type:"string"},style:r,styleSpec:n}):o&&s[o[1]]&&s[o[1]].transition?Ie({key:t,value:i[t],valueSpec:n.transition,style:r,styleSpec:n}):s[t]?Ie({key:t,value:i[t],valueSpec:s[t],style:r,styleSpec:n}):[new e.a5(t,i[t],`unknown property "${t}"`)]);}if(i.source)if(e.a2(i.source)){const t=r.sources&&r.sources[i.source],n=t&&e.L(t.type);t?"raster-dem"!==n&&a.push(new e.V(`${o}.source`,i.source,`terrain cannot be used with a source of type ${n}, it only be used with a "raster-dem" source type`)):a.push(new e.V(`${o}.source`,i.source,`source "${i.source}" not found`));}else a.push(new e.V(`${o}.source`,i.source,"source must be a string"));else a.push(new e.V(o,i,'terrain is missing required property "source"'));return a}function Se(t){const i=t.value,o=t.style,r=t.styleSpec,n=r.fog;if(void 0===i)return [];if(!e.K(i))return [new e.V("fog",i,`object expected, ${e.M(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);s=s.concat(l&&n[l[1]]?Ie({key:t,value:i[t],valueSpec:{type:"string"},style:o,styleSpec:r}):a&&n[a[1]]&&n[a[1]].transition?Ie({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?Ie({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new e.a5(t,i[t],`unknown property "${t}"`)]);}return s}const Ce={"*":()=>[],array:ne,boolean:function(t){const i=t.value,o=t.key;return e.a1(i)?[]:[new e.V(o,i,`boolean expected, ${e.M(i)} found`)]},number:se,color:function({key:t,value:i}){return e.a2(i)?null===e.a3.parseCSSColor(i)?[new e.V(t,i,`color expected, "${i}" found`)]:[]:[new e.V(t,i,`color expected, ${e.M(i)} found`)]},enum:de,filter:_e,function:ae,layer:ge,object:Re,source:xe,model:e.a9,light:we,"light-3d":Te,terrain:Ee,fog:Se,string:ve,formatted:function(e){return 0===ve(e).length?[]:le(e)},resolvedImage:function(e){return 0===ve(e).length?[]:le(e)},projection:function(t){const i=t.value,o=t.styleSpec,r=o.projection,n=t.style;if(e.K(i)){let e=[];for(const t in i)e=e.concat(Ie({key:t,value:i[t],valueSpec:r[t],style:n,styleSpec:o}));return e}return e.a2(i)?[]:[new e.V("projection",i,`object or string expected, ${e.M(i)} found`)]},import:function(t){const i=t.key,{value:o,styleSpec:r}=t;if(!e.K(o))return [new e.V(i,o,"import must be an object")];const{data:n,...s}=o;Object.defineProperty(s,"__line__",{value:o.__line__,enumerable:!1});let a=Re(Object.assign({},t,{value:s,valueSpec:r.import}));return ""===e.L(s.id)&&a.push(new e.V(`${t.key}.id`,s,"import id can't be an empty string")),n&&(a=a.concat(Ae(n,r,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,o=t.key,r=t.styleSpec,n=t.style;if(!e.K(i))return [new e.V(o,i,"object expected")];if(!i.type)return [new e.V(o,i,'"type" is required')];const s=e.L(i.type);let a=[];if(a=a.concat(Re({key:o,value:i,valueSpec:r[`iconset_${s}`],style:n,styleSpec:r})),function(e,t){return !("source"!==e||!t.source)}(s,i)){const t=n.sources&&n.sources[i.source],r=t&&e.L(t.type);t?"raster-array"!==r&&a.push(new e.V(o,i.source,`iconset cannot be used with a source of type ${String(r)}, it only be used with a "raster-array" source type`)):a.push(new e.V(o,i.source,`source "${i.source}" not found`));}return a}};function Ie(t,i=!1){const o=t.value,r=t.valueSpec,n=t.styleSpec;if(r.expression){if(e.a6(e.L(o)))return ae(t);if(e.U(e.W(o)))return le(t)}if(r.type&&Ce[r.type]){const e=Ce[r.type](t);return !0===i&&e.length>0&&Array.isArray(t.value)?le(t):e}return Re(Object.assign({},t,{valueSpec:r.type?n[r.type]:r}))}function Re(t){const i=t.key,o=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},s=t.style,a=t.styleSpec;if(!e.K(o))return [new e.V(i,o,`object expected, ${e.M(o)} found`)];let l=[];for(const t in o){const c=t.split(".")[0];let h;n[c]?h=n[c]:r[c]?h=Ie:n["*"]?h=n["*"]:r["*"]&&(h=Ie),h?l=l.concat(h({key:(i?`${i}.`:i)+t,value:o[t],valueSpec:r[c]||r["*"],style:s,styleSpec:a,object:o,objectKey:t},o)):l.push(new e.a5(i,o[t],`unknown property "${t}"`));}for(const t in r){if(n[t])continue;const s=r[t];s.required&&void 0===s.default&&void 0===o[t]&&l.push(new e.V(i,o,`missing required property "${t}"`));}return l}function De({key:t,value:i}){const o=ve({key:t,value:i});if(o.length)return o;const r=i;return -1===r.indexOf("{fontstack}")&&o.push(new e.V(t,i,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new e.V(t,i,'"glyphs" url must include a "{range}" token')),o}function Ae(t,i=e.a8,o={}){return Re({key:o.key||"",value:t,valueSpec:Object.assign(i.$root,{"*":{type:"*"}}),styleSpec:i,style:t,objectElementValidators:{glyphs:De}})}function Le(t,i=e.a8){return Ze(Ae(t,i))}const Pe=e=>Ze(xe(e)),Oe=e=>Ze(we(e)),Me=e=>Ze(Te(e)),ze=e=>Ze(Ee(e)),Fe=e=>Ze(Se(e)),Be=t=>Ze(function(t){const i=t.value,o=t.style,r=t.styleSpec,n=r.snow;if(void 0===i)return [];if(!e.K(i))return [new e.V("snow",i,`object expected, ${e.M(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?Ie({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?Ie({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new e.a5(t,i[t],`unknown property "${t}"`)]);}return s}(t)),ke=t=>Ze(function(t){const i=t.value,o=t.style,r=t.styleSpec,n=r.rain;if(void 0===i)return [];if(!e.K(i))return [new e.V("rain",i,`object expected, ${e.M(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?Ie({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?Ie({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new e.a5(t,i[t],`unknown property "${t}"`)]);}return s}(t)),Ne=e=>Ze(ge(e)),Ue=e=>Ze(_e(e)),Ve=e=>Ze(fe(e)),je=e=>Ze(me(e)),Ge=t=>Ze(e.a9(t));function Ze(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function qe(t,i){let o=!1;if(i&&i.length)for(const r of i)r instanceof e.a5?e.w(r.message):(t.fire(new e.B(new Error(r.message))),o=!0);return o}const He=e.a8.light;let We;class $e extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.aa(We||(We=new e.ab({anchor:new e.ac(He.anchor),position:new e.ad(He.position),color:new e.ac(He.color),intensity:new e.ac(He.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(Oe,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&qe(this,t.call(Le,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a8})))}}const Xe=e.a8.terrain;let Ye=class extends e.E{constructor(t,i,o,r,n){super(),this.scope=o,this._transitionable=new e.aa(new e.ab({source:new e.ac(Xe.source),exaggeration:new e.ac(Xe.exaggeration)}),o,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=n;}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.ae(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let o=-1,r=-1,n=1;for(const t of i.zoomStops)n=i.evaluate(new e.ae(t,{worldview:this.worldview})),n>.01?(o=t,r=-1):r=t;return n<.01&&o>0&&r>o?[o,r]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.af}};const Ke=.05;function Je(t,i,o,r){const n=e.aj(45,65,o),[s,a]=Qe(t,r);let l=1-Math.min(1,Math.exp((i-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*n*t.alpha}function Qe(e,t){const i=.5/Math.tan(.5*t);return [e.range[0]+i,e.range[1]+i]}function et(t,i,o,r,n){const s=e.ah([],[i,o,r],n.mercatorFogMatrix);return Je(t,e.ai(s),n.pitch,n._fov)}function tt(t,i,o,r,n,s,a){const l=[[o,r,0],[n,r,0],[n,s,0],[o,s,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const o=e.ah([],t,i),r=e.ai(o);c=Math.min(c,r),h=Math.max(h,r);}return [Je(t,c,a.pitch,a._fov),Je(t,h,a.pitch,a._fov)]}const it=e.a8.fog;class ot extends e.E{constructor(t,i,o,r){super();const n=new e.ab({range:new e.ac(it.range),color:new e.ac(it.color),"color-use-theme":new e.ac({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.ac(it["high-color"]),"high-color-use-theme":new e.ac({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.ac(it["space-color"]),"space-color-use-theme":new e.ac({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.ac(it["horizon-blend"]),"star-intensity":new e.ac(it["star-intensity"]),"vertical-range":new e.ac(it["vertical-range"])});this._transitionable=new e.aa(n,o,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ak(n),this.scope=o;}get state(){const t=this._transform,i="globe"===t.projection.name,o=e.al(t.zoom),r=this.properties.get("range"),n=[.5,3];return {range:i?[e.am(n[0],r[0],o),e.am(n[1],r[1],o)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Fe,e,i))return;const o=Object.assign({},e);for(const e of Object.keys(it))void 0===o[e]&&(o[e]=it[e].default);this._options=o,this._transitionable.setTransitionOrValue(this._options,t);}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return ("globe"===this._transform.projection.name?1:e.aj(45,65,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,o){const r=e.ag.fromLngLat(i),n=o.elevation?o.elevation.getAtPointOrZero(r):0;return et(t,r.x,r.y,n,o)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return [1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return tt(this.state,i,0,0,e.an,e.an,this._transform)}getOpacityForBounds(e,t,i,o,r){return this._transform.projection.supportsFog?tt(this.state,e,t,i,o,r,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?Qe(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return !1;const i=[4,5,6,7];for(const o of i){const i=t.points[o];let r;if(i[2]>=0)r=i;else {const n=t.points[o-4];r=e.ao(n,i,n[2]/(n[2]-i[2]));}if(et(this.state,r[0],r[1],0,this._transform)>=Ke)return !0}return !1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e));}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&qe(this,t.call(Le,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a8})))}}let rt,nt,st,at=class extends e.E{constructor(t,i,o,r){super();const n=rt||(rt=new e.ab({density:new e.ac(e.a8.snow.density),intensity:new e.ac(e.a8.snow.intensity),color:new e.ac(e.a8.snow.color),opacity:new e.ac(e.a8.snow.opacity),vignette:new e.ac(e.a8.snow.vignette),"vignette-color":new e.ac(e.a8.snow["vignette-color"]),"center-thinning":new e.ac(e.a8.snow["center-thinning"]),direction:new e.ac(e.a8.snow.direction),"flake-size":new e.ac(e.a8.snow["flake-size"])}));this._transitionable=new e.aa(n,o,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ak(n),this.scope=o;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),r=e.ap(o[0]),n=-Math.max(e.ap(o[1]),.01),s=[Math.cos(r)*Math.cos(n),Math.sin(r)*Math.cos(n),Math.sin(n)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color");return l.a=a,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.aq(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(Be,t,o))return;const r=Object.assign({},t),n=e.a8.snow;for(const e of Object.keys(n))void 0===r[e]&&(r[e]=n[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e));}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&qe(this,t.call(Le,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a8})))}},lt=class extends e.E{constructor(t,i,o,r){super();const n=nt||(nt=new e.ab({density:new e.ac(e.a8.rain.density),intensity:new e.ac(e.a8.rain.intensity),color:new e.ac(e.a8.rain.color),opacity:new e.ac(e.a8.rain.opacity),vignette:new e.ac(e.a8.rain.vignette),"vignette-color":new e.ac(e.a8.rain["vignette-color"]),"center-thinning":new e.ac(e.a8.rain["center-thinning"]),direction:new e.ac(e.a8.rain.direction),"droplet-size":new e.ac(e.a8.rain["droplet-size"]),"distortion-strength":new e.ac(e.a8.rain["distortion-strength"])}));this._transitionable=new e.aa(n,o,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ak(n),this.scope=o;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),r=e.ap(o[0]),n=-Math.max(e.ap(o[1]),.01),s=[Math.cos(r)*Math.cos(n),Math.sin(r)*Math.cos(n),Math.sin(n)],a=this.properties.get("vignette-color");return a.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.aq(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(ke,t,o))return;const r=Object.assign({},t),n=e.a8.rain;for(const e of Object.keys(n))void 0===r[e]&&(r[e]=n[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e));}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&qe(this,t.call(Le,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a8})))}};class ct extends e.E{constructor(t,i,o,r){super(),this.scope=o,this._options=t,this.properties=new e.ak(i),this._transitionable=new e.aa(i,o,new Map(r)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned();}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e));}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t);}shadowsEnabled(){return !!this.properties&&!0===this.properties.get("cast-shadows")}}const ht=()=>st||(st=new e.ab({color:new e.ac(e.a8.properties_light_ambient.color),"color-use-theme":new e.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.ac(e.a8.properties_light_ambient.intensity)}));let dt;const _t=()=>dt||(dt=new e.ab({direction:new e.ar(e.a8.properties_light_directional.direction),color:new e.ac(e.a8.properties_light_directional.color),"color-use-theme":new e.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.ac(e.a8.properties_light_directional.intensity),"cast-shadows":new e.ac(e.a8.properties_light_directional["cast-shadows"]),"shadow-quality":new e.ac(e.a8.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.ac(e.a8.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new e.ac(e.a8.properties_light_directional["shadow-draw-before-layer"])}));class ut{constructor(e,t,i){this.screenBounds=e,this.cameraPoint=i.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=t,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i);}static createFromScreenPoints(t,i){let o,r;if(t instanceof e.P||"number"==typeof t[0]){const n=e.P.convert(t);o=[n],r=i.isPointAboveHorizon(n);}else {const n=e.P.convert(t[0]),s=e.P.convert(t[1]),a=n.add(s)._div(2);o=[n,s],r=e.as(n,s).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a);}return new ut(o,r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.as(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.as(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<o.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=o.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.at(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.as(i,o,t),n=this.cameraPoint.clone(),s=Number(n.x>i.x)+Number(n.x>o.x);switch(3*(Number(n.y>i.y)+Number(n.y>o.y))+s){case 0:r[0]=n,r[4]=n.clone();break;case 1:r.splice(1,0,n);break;case 2:r[1]=n;break;case 3:r.splice(4,0,n);break;case 5:r.splice(2,0,n);break;case 6:r[3]=n;break;case 7:r.splice(3,0,n);break;case 8:r[2]=n;}return r}containsTile(t,i,o,r=0){const n=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,s=o?this._bufferedCameraMercator(n,i):this._bufferedScreenMercator(n,i);let a=t.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map(i=>e.au(t.tileTransform,i,a));if(!e.av(l,0,0,e.an,e.an))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map(i=>e.aw(t.tileTransform,i,a)),h=c.map(t=>new e.P(t[0],t[1])),d=i.getFreeCameraOptions().position||new e.ag(0,0,0),_=e.aw(t.tileTransform,d,a),u=c.map(t=>{const i=e.ax(t,t,_);return e.ay(i,i),new e.az(_,i)}),p=e.aA(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:u,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(f=e.aB(l),f.min.x=e.aC(f.min.x,0,e.an),f.min.y=e.aC(f.min.y,0,e.an),f.max.x=e.aC(f.max.x,0,e.an),f.max.y=e.aC(f.max.y,0,e.an),f),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var f;}_bufferedScreenMercator(e,t){const i=mt(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=mt(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.aD([],i.pixelMatrix,i.globeMatrix),r=[0,-e.aF,0,1],n=[0,e.aF,0,1],s=[0,0,0,1];e.aE(r,r,o),e.aE(n,n,o),e.aE(s,s,o);const a=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(n[0]/n[3],n[1]/n[3]),c=e.aG(t,a)&&r[3]<s[3],h=e.aG(t,l)&&n[3]<s[3];if(!c&&!h)return null;const d=function(e,t,i){for(let o=1;o<e.length;o++){const r=ft(t.pointCoordinate3D(e[o-1]).x),n=ft(t.pointCoordinate3D(e[o]).x);if(i<0){if(r<n)return {idx:o,t:-r/(n-1-r)}}else if(n<r)return {idx:o,t:(1-r)/(n+1-r)}}return null}(t,i,c?-1:1);if(!d)return null;const{idx:_,t:u}=d;let p=_>1?pt(t.slice(0,_),i):[],f=_<t.length?pt(t.slice(_),i):[];p=p.map(t=>new e.P(ft(t.x),t.y)),f=f.map(t=>new e.P(ft(t.x),t.y));const m=[...p];0===m.length&&m.push(f[f.length-1]);const g=e.am(m[m.length-1].y,(0===f.length?p[0]:f[0]).y,u);let v;return v=c?[new e.P(0,g),new e.P(0,0),new e.P(1,0),new e.P(1,g)]:[new e.P(1,g),new e.P(1,1),new e.P(0,1),new e.P(0,g)],m.push(...v),0===f.length?m.push(p[0]):m.push(...f),{polygon:m.map(t=>new e.ag(t.x,t.y)),unwrapped:!1}}(t,i);if(o)return o;const r=function(t,i){let o=!1,r=-1/0,n=0;for(let e=0;e<t.length-1;e++)t[e].x>r&&(r=t[e].x,n=e);for(let e=0;e<t.length-1;e++){const i=(n+e)%(t.length-1),r=t[i],s=t[i+1];Math.abs(r.x-s.x)>.5&&(r.x<s.x?(r.x+=1,0===i&&(t[t.length-1].x+=1)):(s.x+=1,i+1===t.length-1&&(t[0].x+=1)),o=!0);}const s=e.aH(i.center.lng);return o&&s<Math.abs(s-1)&&t.forEach(e=>{e.x-=1;}),{polygon:t,unwrapped:o}}(pt(t,i).map(t=>new e.P(ft(t.x),t.y)),i);return {polygon:r.polygon.map(t=>new e.ag(t.x,t.y)),unwrapped:r.unwrapped}}}function pt(t,i){return e.aI(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;},1/256)}function ft(e){return e<0?1+e%1:e%1}function mt(e){return 100*e|0}function gt(t,i,o){try{i=function(e){if(!e.variants)return e;if(!Array.isArray(e.variants))throw new Error("variants must be an array");for(const t of e.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(t.capabilities))throw new Error("capabilities must be an array");if(1===t.capabilities.length&&"meshopt"===t.capabilities[0])return Object.assign(e,t)}return e}(i);}catch(e){return new Error("Failed to process TileJSON variants",{cause:e})}const r=e.aJ(Object.assign({},i,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return t.url&&i.tiles&&t.tiles&&(r.tiles=i.tiles),r.tiles=o.canonicalizeTileset(r,t.url),r}function vt(t,i,o,r,n){const s=function(e,o){if(e)return n(e);if(o){t.url&&o.tiles&&t.tiles&&delete t.tiles;const e=gt(t,o,i);if(e instanceof Error)return n(e);n(null,e);}},a=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const o=Object.values(e.language||{});if(0===o.length)return null;const r=Object.values(e.worldview||{});if(0===r.length)return null;const n=o.every(e=>e===t),s=r.every(e=>e===i);return n&&s?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(t.data,o,r);return a?e.o.frame(()=>s(null,a)):t.url?e.m(i.transformRequest(i.normalizeSourceURL(t.url,null,o,r),e.R.Source),s):e.o.frame(()=>{const{data:e,...i}=t;s(null,i);})}function yt(t,i){const o=Math.pow(2,i.z),r=Math.floor(e.aH(t.getWest())*o),n=Math.floor(e.aL(t.getNorth())*o),s=Math.ceil(e.aH(t.getEast())*o),a=Math.ceil(e.aL(t.getSouth())*o);return i.x>=r&&i.x<s&&i.y>=n&&i.y<a}class xt{constructor(t,i,o){this.bounds=t?e.aK.convert(this.validateBounds(t)):null,this.minzoom=i||0,this.maxzoom=o||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}addExtraBounds(t){if(t){this.extraBounds||(this.extraBounds=[]);for(const i of t)this.extraBounds.push(e.aK.convert(this.validateBounds(i)));}}contains(e){if(e.z>this.maxzoom||e.z<this.minzoom)return !1;if(this.bounds&&!yt(this.bounds,e))return !1;if(!this.extraBounds)return !0;for(const t of this.extraBounds)if(yt(t,e))return !0;return !1}static fromTileJSON(e){if(!e.bounds&&!e.extra_bounds)return null;const t=new xt(e.bounds,e.minzoom,e.maxzoom);return t.addExtraBounds(e.extra_bounds),t}}class bt extends e.E{constructor(t,i,o,r){if(super(),this.id=t,this.dispatcher=o,this.type="vector",this.provider=i.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,e.aJ(i,["url","scheme","tileSize","promoteId"])),this._options=Object.assign({type:"vector"},i),this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.aN;}load(t){this._loaded=!1,this.fire(new e.C("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview(),r=(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.B(r))):n&&(this._setTileJSON(n),O(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.C("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);};this.provider=this._options.provider;const n=function(t){if("provider"in t&&!t.provider)return null;let i=t.provider;if(!i&&"url"in t&&t.url&&(i=e.aM(t.url)),!i)return null;const o=e.g.TILE_PROVIDER_URLS[i];if(!o)return null;let r;try{r=new URL(o,e.g.API_URL).href;}catch(t){return e.w(`TileProvider "${i}" has an invalid URL: "${o}"`),null}return {name:i,url:r}}(this._options);if(this.provider&&!n)return this._loaded=!0,this.fire(new e.B(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t());this._tileJSONRequest=n?this._loadWithProvider(n,r):vt(this._options,this.map._requestManager,i,o,r);}_loadWithProvider(t,i){this.provider=t.name;const o=new AbortController,r=this._options.url&&!this._options.tiles?this.map._requestManager.transformRequest(this._options.url,e.R.Source):void 0,n=r?Object.assign({},this._options,{url:r.url}):this._options;return this.dispatcher.broadcast("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:n,request:r},(e,t)=>{if(o.signal.aborted)return;if(e)return void i(e);const r=t?t.find(e=>null!=e):null;if(r){const e=gt(this._options,r,this.map._requestManager);e instanceof Error?i(e):i(null,e);}else i(null,{tiles:this._options.tiles});}),{cancel:()=>{o.abort();}}}_setTileJSON(e){if(Object.assign(this,e),this.hasWorldviews=!!e.worldview_options,e.worldview_default&&(this.worldviewDefault=e.worldview_default),e.vector_layers){this.vectorLayers=e.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const t of e.vector_layers)this.vectorLayerIds.push(t.id),e.worldview&&e.worldview[t.source]&&this.localizableLayerIds.add(t.id);}this.tileBounds=xt.fromTileJSON(e);}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest();}serialize(){return Object.assign({},this._options)}loadTile(t,i){const o=t.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(o),n=this.map._requestManager.transformRequest(r,e.R.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,a=s?{image:s.image.clone()}:null,l={request:n,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&e.e(o)&&(l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else {const i=e.aO.call({deduped:this._deduped},l,(i,o)=>{if(i||!o)c.call(this,i);else {const i=e.aP(o.responseHeaders);l.data={rawData:o.rawData.slice(0),expires:i.expires,cacheControl:i.cacheControl},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0);}},!0);t.request={cancel:i};}function c(o,r){return delete t.request,t.aborted?i(null):o?i(o):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.aQ(this.dispatcher),i(null,r),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,t){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}class wt extends e.E{constructor(t,i,o,r){super(),this.id=t,this.dispatcher=o,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},i),Object.assign(this,e.aJ(i,["url","scheme","tileSize"]));}load(t){this._loaded=!1,this.fire(new e.C("dataloading",{dataType:"source"}));const i=this.map.getWorldview();this._tileJSONRequest=vt(this._options,this.map._requestManager,null,i,(i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.B(i)):o&&(Object.assign(this,o),o.raster_layers&&(this.rasterLayers=o.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=xt.fromTileJSON(o),O(o.tiles),this.fire(new e.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.C("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i);});}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest();}serialize(){return Object.assign({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.o.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);t.request=e.n(this.map._requestManager.transformRequest(r,e.R.Tile),(o,r,n)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(o)return t.state="errored",i(o);if(!r)return i(null);const s=e.aP(n);this.map._refreshExpiredTiles&&t.setExpiryData(s),t.setTexture(r,this.map.painter),t.state="loaded",e.aQ(this.dispatcher),i(null);});}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t();}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i();}hasTransition(){return !1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}function Tt([t,i],o,r,{scaled:n=!0}={}){const{tileSize:s,buffer:a}=r,{x:l,y:c,z:h}=o;if(!isFinite(l)||!isFinite(c)||!isFinite(h))throw new Error("Invalid MRT header");const d=2**h,_=d*e.aH(t),u=d*e.aL(i);return function([e,t],i,{scaled:o=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:r,tileSize:n,buffer:s,offset:a,scale:l,dimension:c}=i;if(e<-s||e>n+s||t<-s||t>n+s)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${n}, buffer=${s}`);const h=(t+s)*(n+2*s)+(e+s);if(4294967295===new Uint32Array(r.buffer)[h])return null;let d=[];d=o?[]:new(0,i.data.constructor)(c);for(let e=0;e<c;e++)d[e]=Math.round(1e12*(r[c*h+e]*l+a))/1e12;return d}([Math.min(Math.max(-a,Math.floor((_-l)*s)),s-1+a),Math.min(Math.max(-a,Math.floor((u-c)*s)),s-1+a)],r,{scaled:n})}class Et extends wt{constructor(e,t,i,o){super(e,t,i,o),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options=Object.assign({type:"raster-array"},t);}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint();}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(o,e.R.Tile),n={request:r,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};t.source=this.id,t.scope=this.scope,t.requestParams=r,t.actor||(t.actor=this.dispatcher.getActor());const s=(o,r,n)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(o){if("AbortError"===o.name)return;return t.state="errored",i(o)}if(this.map._refreshExpiredTiles&&r){const i=e.aP(n);t.setExpiryData(i);}if(this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!r)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=r;}i(null);};t.request=this.partial?t.fetchHeader(void 0,s.bind(this)):t.actor.send("loadTile",n,s.bind(this),void 0,!0);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,t){const i=e.texturePerLayer;if(e.flushAllQueues(),i.size){e.destroy(!1);for(const e of i.values())this.map.painter.saveTileTexture(e);}else e.destroy();}prepareTile(t,i,o,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,o,r,(i,r)=>{i?(t.state="errored",this.fire(new e.B(i))):r&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(o,r,this.map.painter),t.state="loaded"),this.triggerRepaint(t);}));}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find(({id:t})=>t===e),i=t&&t.fields,o=i&&i.bands&&i.bands;return o?o[0]:0}getTextureDescriptor(t,i,o){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let n=null;i instanceof e.aS?n=i.paint.get("raster-array-band"):i instanceof e.aT&&(n=i.paint.get("raster-particle-array-band"));const s=n||this.getInitialBand(r);if(null==s)return;if(!t.textureDescriptorPerLayer.get(i.id))return void this.prepareTile(t,r,i.id,s);if(t.updateNeeded(i.id,s)&&!o)return;const a=t.textureDescriptorPerLayer.get(i.id);return Object.assign({},a,{texture:t.texturePerLayer.get(i.id)})}getImages(t,i){const o=new Map;for(const r of t)for(const t of i){const[i,n]=t.split("/"),s=r.getLayer(i);if(!s)continue;if(!s.hasBand(n)||!s.hasDataForBand(n))continue;const{bytes:a,tileSize:l,buffer:c}=s.getBandView(n),h=l+2*c,d={data:new e.q({width:h,height:h},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};o.set(t,d);}return o}queryRasterArrayValueByBandId(t,i,o){const r=i._mrt;return new Promise(n=>{const s={},a=new Set;for(const[l,c]of Object.entries(r.layers)){if(o.layerName&&l!==o.layerName)continue;const h={};s[l]=h;for(const{bands:d}of c.dataIndex)for(const _ of d)o.bands&&!o.bands.includes(_)||(a.add(e.F(l,_)),i.fetchBand(l,null,_,i=>{e.o.frame(()=>{h[_]=i?null:Tt([t.lng,t.lat],r,c.getBandView(_)),a.delete(e.F(l,_)),0===a.size&&n(s);});},!1));}0===a.size&&n(s);})}_loadTileForQuery(t,i){if(this._loadTileLoaded[t.uid])return void i(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(i);this._loadTilePending[t.uid]=[i];const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(o,e.R.Tile);t.actor.send("loadTile",{request:r,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(i,o,r)=>{if(i)return this._loadTilePending[t.uid].forEach(e=>e(i,null)),void delete this._loadTilePending[t.uid];if(!o)return this._loadTilePending[t.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&o){const i=e.aP(r);t.setExpiryData(i);}t._mrt=o,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(e=>e(null,o)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid];},void 0,!0);}queryRasterArrayValueByAllBands(e,t,i){return new Promise((o,r)=>{this._loadTileForQuery(t,(n,s)=>{n?r(n):o(s?this.queryRasterArrayValueByBandId(e,t,i):null);});})}queryRasterArrayValue(t,i){const o=e.aU.convert(t),r=this.findLoadedParent(o);return r&&r._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(o,r,i):this.queryRasterArrayValueByAllBands(o,r,i):Promise.resolve(null)}findLoadedParent(t){const i=e.ag.fromLngLat(t,this.map.transform.tileSize),o=this.maxzoom+1,r=1<<o,n=Math.floor(i.x),s=Math.floor((i.x-n)*r),a=Math.floor(i.y*r),l=this.map.style.getSourceCache(this.id),c=new e.aR(o,n,o,s,a);return l.findLoadedParent(c,this.minzoom)}}const St={vector:bt,raster:wt,"raster-dem":class extends wt{constructor(e,t,i,o){super(e,t,i,o),this.type="raster-dem",this.maxzoom=22,this._options=Object.assign({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox";}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(o,e.R.Tile),n={uid:t.uid,tileID:t.tileID,source:this.id,type:this.type,scope:this.scope,request:r,encoding:this.encoding};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,function(e,o){return delete t.request,t.aborted?(t.state="unloaded",i(null)):e?(t.state="errored",i(e)):void(o?(this.map._refreshExpiredTiles&&t.setExpiryData(o),o.borderReady||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID)),t.dem=o.dem,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null)):i(null))}.bind(this),void 0,!0));}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),t&&t();}_getNeighboringTiles(t){const i=t.canonical,o=Math.pow(2,i.z),r=(i.x-1+o)%o,n=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+o)%o,a=i.x+1===o?t.wrap+1:t.wrap,l={};return l[new e.aR(t.overscaledZ,n,i.z,r,i.y).key]={backfilled:!1},l[new e.aR(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.aR(t.overscaledZ,n,i.z,r,i.y-1).key]={backfilled:!1},l[new e.aR(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aR(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<o&&(l[new e.aR(t.overscaledZ,n,i.z,r,i.y+1).key]={backfilled:!1},l[new e.aR(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.aR(t.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}},"raster-array":Et,geojson:class extends e.E{constructor(t,i,o,r){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=o.getActor(),this.setEventedParent(r),this._data=i.data,this._options=Object.assign({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),void 0!==i.minzoom&&(this.minzoom=i.minzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const n=e.an/this.tileSize;this.workerOptions=Object.assign({source:this.id,scope:this.scope,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*n,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*n,extent:e.an,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.an,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*n,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter,dynamic:i.dynamic},i.workerOptions);}onAdd(e){this.map=e,this.setData(this._data);}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(t){if(!this._options.dynamic)return this.fire(new e.B(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if("string"!=typeof t&&("Feature"===t.type&&(t={type:"FeatureCollection",features:[t]}),"FeatureCollection"!==t.type))return this.fire(new e.B(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&"string"!=typeof t&&"string"!=typeof this._data&&"FeatureCollection"===this._data.type){const e=new Map;for(const t of this._data.features)e.set(t.id,t);for(const i of t.features)e.set(i.id,i);this._data.features=[...e.values()];}else this._data=t;return this._updateWorkerData(!0),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterLeaves(e,t,i,o){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:i},o),this}_updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.C("dataloading",{dataType:"source"})),this._loaded=!1;const i=Object.assign({append:t},this.workerOptions);i.scope=this.scope;const o=this._data;"string"==typeof o?(i.request=this.map._requestManager.transformRequest(e.o.resolveURL(o),e.R.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(o),this._pendingLoad=this.actor.send(`${this.type}.loadData`,i,(i,o)=>{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.B(i));else {const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&o&&o.resourceTiming&&o.resourceTiming[this.id]&&(i.resourceTiming=o.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.C("data",i)),this._partialReload=!1,this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1);});}loaded(){return this._loaded}reload(){const t=e.F(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData();}loadTile(t,i){const o=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,n=r?{image:r.image.clone()}:null,s=this._partialReload,a={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:n,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:s,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};t.request=this.actor.send(o,a,(e,r)=>s&&!r?(t.state="loaded",i(null)):(delete t.request,t.destroy(!1),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===o),i(null))),void 0,"loadTile"===o);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0;}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel();}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends e.aV{constructor(e,t,i,o){super(e,t,i,o),this.roundZoom=!0,this.type="video",this.options=t;}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aW(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.B(t)):i&&(this.video=i,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(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.B(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,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 t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t);}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aV,model:e.aY,"batched-model":class extends e.E{constructor(e,t,i,o){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(o);}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}load(t){this._loaded=!1,this.fire(new e.C("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=vt(this._options,this.map._requestManager,i,o,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.B(r))):n&&(Object.assign(this,n),n.bounds&&(this.tileBounds=new xt(n.bounds,this.minzoom,this.maxzoom)),O(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.C("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);});}hasTransition(){return !1}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(o,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.o.devicePixelRatio,promoteId:this.promoteId};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else {if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",r,n.bind(this));}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,n.bind(this),void 0,!0);function n(e,o){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&o&&t.setExpiryData(o),t.loadModelData(o,this.map.painter),t.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.aV{constructor(t,i,o,r){super(t,i,o,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.B(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.B(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.B(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.B(new e.V(`sources.${t}`,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 e.B(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.B(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(e){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.aX||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i);}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends e.E{constructor(t,i,o,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=i,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.B(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.B(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new xt(this._implementation.bounds,this.minzoom,this.maxzoom));const n=i;n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.aJ(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return e.aJ(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.C("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.C("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:o,z:r}=e.tileID.canonical,n=new AbortController,s=Promise.resolve(this._implementation.loadTile({x:i,y:o,z:r},{signal:n.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(i=>{"AbortError"!==i.name&&(e.state="errored",t(i));});s.cancel=()=>n.abort(),e.request=s;}loadTileData(e,t){e.setTexture(t,this.map.painter);}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:o}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:o});}i&&i();}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&t();}hasTransition(){return !1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){const t=e.F(this.id,this.scope);this.map.style.clearSource(t);}_update(){this.fire(new e.C("data",{dataType:"source",sourceDataType:"content"}));}}},Ct=function(t,i,o,r){const n=new St[i.type](t,i,o,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return e.aZ(["load","abort","unload","serialize","prepare"],n),n};function It(e,t,i=""){return `${i}:${t.id||""}:${t.layer.id}:${function(e){if("layerId"in e)return `layer:${e.layerId}`;{const{featuresetId:t,importId:i}=e;return `featureset:${t}${i?`:import:${i}`:""}`}}(e.target)}`}function Rt(e,t,i,o=""){if(e.uniqueFeatureID){const r=It(e,t,o);if(i.has(r))return !0;i.add(r);}return !1}function Dt(e,t,i,o,r=!1,n=void 0){const s=t.sourceCache.transform,a=t.sourceCache.tilesIn(e,t.has3DLayers,r);a.sort(Pt);const l=[];for(const e of a){const a=e.tile.queryRenderedFeatures(t,e,i,o,s,r,n);Object.keys(a).length&&l.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:a});}for(const i in t.layers){const r=t.layers[i];if(r.styleLayer){const i=r.styleLayer.queryRenderedFeatures(e,t.sourceCache,o);Object.keys(i).length&&l.push({wrappedTileID:0,queryResults:i});}}return 0===l.length?{}:function(e){const t={},i={};for(const o of e){const e=o.queryResults,r=o.wrappedTileID,n=i[r]=i[r]||{};for(const i in e){const o=e[i],r=n[i]=n[i]||{},s=t[i]=t[i]||[];for(const e of o)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e));}}return t}(l)}function At(e,t,i,o,r,n){const s={},a=o.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(r[e]);l.sort(Pt);for(const e of l){const o=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,n);for(const t in o){const i=s[t]=s[t]||[],r=o[t];r.sort((t,i)=>{const o=e.featureSortOrder;if(o){const e=o.indexOf(t.featureIndex);return o.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of r)i.push(e);}}return s}function Lt(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),o=[],r={};for(let e=0;e<i.length;e++){const n=i[e],s=n.tileID.canonical.key;r[s]||(r[s]=!0,n.querySourceFeatures(o,t));}return o}function Pt(e,t){const i=e.tileID,o=t.tileID;return i.overscaledZ-o.overscaledZ||i.canonical.y-o.canonical.y||i.wrap-o.wrap||i.canonical.x-o.canonical.x}e.a_.setPbf(e.a$);class Ot extends e.b0{constructor(e,t,i,o,r){super(e,t,i,o,r),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map;}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(e){return this._mrt&&this._mrt.getLayer(e)}setTexturePerLayer(t,i,o){const r=o.context,n=r.gl;let s=this.texturePerLayer.get(t)||o.getTileTexture(i.width);s&&s instanceof e.T?s.update(i,{premultiply:!1}):s=new e.T(r,i,n.RGBA8,{premultiply:!1}),this.texturePerLayer.has(t)||this.texturePerLayer.set(t,s);}flushQueues(e){const t=this._workQueuePerLayer.get(e)||[],i=this._fetchQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();for(;i.length;)i.pop()();}flushAllQueues(){for(const e of this._workQueuePerLayer.keys()){const t=this._workQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();}for(const e of this._fetchQueuePerLayer.keys()){const t=this._fetchQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();}}fetchHeader(t=16384,i){const o=this._mrt=new e.a_(30),r=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=e.b1(r,(e,r,n)=>{if(e)i(e);else try{const e=o.getHeaderLength(r);if(e>t)return void(this.request=this.fetchHeader(e,i));o.parseHeader(r),this._isHeaderLoaded=!0;let s=0;for(const e of Object.values(o.layers))s=Math.max(s,e.dataIndex[e.dataIndex.length-1].lastByte);r.byteLength>=s&&(this.entireBuffer=r),i(null,this.entireBuffer||r,n);}catch(e){i(e);}}),this.request}fetchBandForRender(e,t,i,o){this.fetchBand(e,t,i,r=>{if(r)return void o(r);this.updateTextureDescriptor(e,t,i);const n=this.textureDescriptorPerLayer.get(t);o(null,n?n.img:null);});}fetchBand(t,i,o,r,n=!0){const s=this._mrt;if(!this._isHeaderLoaded||!s)return void r(new Error("Tile header is not ready"));const a=this.actor;if(!a)return void r(new Error("Can't fetch tile band without an actor"));let l;const c=e.F(String(o),e.F(this.tileID.key,t));let h=this._taskQueue.get(c);h?h.add(r):(h=new Set,h.add(r),this._taskQueue.set(c,h));const d=(e,t)=>{l.complete(e,t),e?r(e):(h.forEach(e=>e(null,t)),this._taskQueue.delete(c));},_=(e,t)=>{if(e)return r(e);const o=a.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:l},d,void 0,!0);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{o&&o.cancel(),l.cancel();}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e);}};let u;try{u=s.getLayer(t);}catch(e){if("reloading"===this.state)return;throw e}if(!u)return void r(new Error(`Unknown sourceLayer "${t}"`));if(u.hasDataForBand(o))return h.forEach(e=>e(null,null)),void this._taskQueue.delete(c);const p=u.getDataRange([o]);if(l=s.createDecodingTask(p),!l||l.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)_(null,this.entireBuffer.slice(p.firstByte,p.lastByte+1));else {const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${p.firstByte}-${p.lastByte}`}}),o=e.b1(t,_);if(null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{o.cancel(),l.cancel();}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,e);}}}updateNeeded(e,t){return (!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,o){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(o)||!r.hasDataForBand(o))return;const{bytes:n,tileSize:s,buffer:a,offset:l,scale:c}=r.getBandView(o),h=s+2*a,d=new e.q({width:h,height:h},n),_=this.texturePerLayer.get(i);_&&_ instanceof e.T&&_.update(d,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:o,img:d,buffer:a,offset:l,tileSize:s,format:r.pixelFormat,mix:[c,256*c,65536*c,16777216*c]});}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const t of this.texturePerLayer.values())t&&t instanceof e.T&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1;}}class Mt{constructor(e,t){this.max=e,this.onRemove=t,this.reset();}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const o=e.wrapped().key;void 0===this.data[o]&&(this.data[o]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r);},i)),this.data[o].push(r),this.order.push(o),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,o=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][o];return this.data[i].splice(o,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const o of this.data[i])e(o.value)||t.push(o);for(const e of t)this.remove(e.value.tileID,e);}}class zt{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,t,i){const o=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},Object.assign(this.stateChanges[e][o],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])i[t]||(this.deletedStates[e][o][t]=null);}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const o=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][o]&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][o])for(i in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][i]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null;}getState(e,t){const i=this.state[e]||{},o=this.stateChanges[e]||{},r=this.deletedStates[e];if(null===r)return {};if(void 0!==t){const e=String(t),n=Object.assign({},i[e],o[e]);if(r){const e=r[t];if(null===e)return {};for(const t in e)delete n[t];}return n}const n=Object.assign({},i,o);if(r)for(const e in r)delete n[e];return n}initializeTileState(e,t){e.refreshFeatureState(t);}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),Object.assign(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i];}i[e]=i[e]||{},Object.assign(i[e],t);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const o in e)e[o].refreshFeatureState(t,i);}}class Ft extends e.E{constructor(e,t,i){super(),this.id=e,this._renderSourceType=i,this._maxzoomOverride=null,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));}),t.on("error",()=>{this._sourceErrored=!0;}),this._source=t,this._tiles={},this._cache=new Mt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new zt,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"_dataType"in this._source&&"raster"===this._source._dataType,this._supportsFading="raster"===this._source.type||"raster-array"===this._source.type||"image"===this._source.type||"video"===this._source.type||"custom"===this._source.type,this._isRasterElevatedOverTerrain=!1;}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const e in this._tiles)if(!this._tiles[e].loaded())return !1;return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform);}setMaxzoomOverride(e){this._maxzoomOverride=e;}_loadTile(e,t){return e.renderSourceType=this._renderSourceType,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e)}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e)}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e,this.map?this.map.painter:void 0),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Bt).map(e=>e.key)}getRenderableIds(t,i){const o=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&o.push(this._tiles[e]);return t?o.sort((t,i)=>{const o=t.tileID,r=i.tileID,n=new e.P(o.canonical.x,o.canonical.y)._rotate(this.transform.angle),s=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return o.overscaledZ-r.overscaledZ||s.y-n.y||s.x-n.x}).map(e=>e.tileID.key):o.map(e=>e.tileID).sort(Bt).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading");}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)));}_tileLoaded(t,i,o,r,n){if(r){if(t.state="errored",e.b2(r)){if(this._source.fire(new e.C("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}else this._source.fire(new e.B(r,{tile:t}));return}t.timeAdded=e.o.now(),"expired"===o&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let s=new Map;n&&n.responseHeaders&&(s=n.responseHeaders),this._source.fire(new e.C("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:s}));}_hasTunnelGeometry(){for(const e in this._tiles){const t=this._tiles[e];if(t&&t.hasTunnelGeometry)return !0}return !1}_backfillDEM(e){const t=this.getRenderableIds();for(let o=0;o<t.length;o++){const r=t[o];if(e.neighboringTiles&&e.neighboringTiles[r]){const t=this.getTileByID(r);i(e,t),i(t,e);}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const o=t.tileID.canonical.y-e.tileID.canonical.y,r=Math.pow(2,e.tileID.canonical.z),n=t.tileID.key;0===i&&0===o||Math.abs(o)>1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,o),e.neighboringTiles&&e.neighboringTiles[n]&&(e.neighboringTiles[n].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,o){for(const r in this._tiles){let n=this._tiles[r];if(o[r]||!n.hasData()||n.tileID.overscaledZ<=t||n.tileID.overscaledZ>i)continue;let s=n.tileID;for(;n&&n.tileID.overscaledZ>t+1;){const e=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[e.key],n&&n.hasData()&&(s=e);}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){o[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),o=this._getLoadedTile(t);if(o)return o}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,o=Math.ceil(e.height/t)+1,r=Math.floor(i*o*5),n="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(s);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const o=this._tiles[i];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),e[o.tileID.key]=o;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e]);}}update(t,i,o,r,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!o)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const s="batched-model"===this._source.type;let a,l=this._source.maxzoom;null!==this._maxzoomOverride&&(l=Math.min(l,this._maxzoomOverride));const c=this.map&&this.map.painter?this.map.painter._terrain:null;if(c&&c.sourceCache===this&&c.attenuationRange()){const e=c.attenuationRange()[0],t=Math.floor(e)-Math.log2(c.getDemUpscale());l>t&&(l=t);}const h=null===this._maxzoomOverride&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.aR(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const r=t.clone();r.tileCoverLift=this.tileCoverLift,a=r.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:h,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aR(1,0,1,0,0)),a.push(new e.aR(1,0,1,1,0)),a.push(new e.aR(1,0,1,0,1)),a.push(new e.aR(1,0,1,1,1)));}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:h,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter(t=>e(t));}}else a=[];if(a.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!this._supportsFading){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!o}),c=Math.min(e,l);if(s){const e=t.extendTileCover(a,c);for(const t of e)a.push(t);}else if(n){const e=this.transform.getFrustum(c),i=t.extendTileCoverToNearPlane(a,e,c);for(const e of i)a.push(e);if(c>=18&&this._hasTunnelGeometry()){const i=t.extendTileCoverForTunnels(a,e,c,20);for(const e of i)a.push(e);}}else if(this.castsShadows&&r){const e=t.extendTileCover(a,c,r,16);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t);}}const d=this._updateRetainedTiles(a);if(this._supportsFading&&0!==a.length){const t={},i={},o=e.o.now(),r=Object.keys(d);for(const e of r){const r=d[e],n=this._tiles[e];if(!n||void 0!==n.fadeEndTime&&n.fadeEndTime<=o)continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-Ft.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[e]=r;}const n=a[a.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(d[e]||!t.hasData())continue;let o=t.tileID;for(;o.overscaledZ>n;){o=o.scaledTo(o.overscaledZ-1);const r=this._tiles[o.key];if(r&&r.hasData()&&i[o.key]){d[e]=t.tileID;break}}}for(const e in t)d[e]||(this._coveredTiles[e]=!0,d[e]=t[e]);}for(const e in d)this._tiles[e].clearFadeHold();const _=e.b3(this._tiles,d);for(const e of _){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e);}this._updateLoadedParentTileCache(),this._renderSourceType===e.b4.Symbol&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e);}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},o=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),r=e[0].overscaledZ,n=Math.max(r-Ft.maxOverzooming,this._source.minzoom),s=Math.max(r+Ft.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||o<this._source.maxzoom&&(a[i.key]=i);}this._retainLoadedChildren(a,o,s,t);for(const o of e){let e=this._tiles[o.key];if(e.hasData())continue;if(o.canonical.z>=this._source.maxzoom){const e=o.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else {const e=o.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let s=o.overscaledZ-1;s>=n;--s){const n=o.scaledTo(s);if(i[n.key])break;if(i[n.key]=!0,e=this.getTile(n),!e&&r&&(e=this._addTile(n)),e&&(t[n.key]=n,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){i=this._loadedParentTiles[o.key];break}t.push(o.key);const e=o.scaledTo(o.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;o=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_addTile(t){let i=this._tiles[t.key];if(i)return !0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const o=Boolean(i);if(!o){const o=this.map?this.map.painter:null,r=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Ot(t,r,this.transform.tileZoom,o,this._isRaster):new e.b0(t,r,this.transform.tileZoom,o,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state));}return i.uses++,this._tiles[t.key]=i,o||this._source.fire(new e.C("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e];},i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id);}tilesIn(t,i,o){const r=[],n=this.transform;if(!n)return r;const s="globe"===n.projection.name,a=e.aH(n.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(o&&c.clearQueryDebugViz(),c.holdingForFade())continue;let h;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aC(a,...kt(t,-1))-a),Math.abs(e.aC(a,...kt(t,1))-a)];h=[0,2*i.indexOf(Math.min(...i))-1];}else {const i=[Math.abs(e.aC(a,...kt(t,-1))-a),Math.abs(e.aC(a,...kt(t,0))-a),Math.abs(e.aC(a,...kt(t,1))-a)];h=[i.indexOf(Math.min(...i))-1];}}else h=[0];for(const e of h){const o=t.containsTile(c,n,i,e);o&&r.push(o);}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),o="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=o?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,o=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<<e.canonical.z);r[e.key]=((e.canonical.x+.5)*t+e.wrap-i[0])*o[0]+((e.canonical.y+.5)*t-i[1])*o[1]-i[2]*o[2];}return t.sort((e,t)=>r[e.key]-r[t.key]),t}hasTransition(){if(this._source.hasTransition())return !0;if(this._supportsFading){const t=e.o.now();for(const e in this._tiles){const i=this._tiles[e];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=t)return !0}}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const o=this._tiles[e];o&&o.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter(i=>!i.hasDependency(e,t));}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i));};return void this._source.on("data",e)}const o=new Map,r=Array.isArray(t)?t:[t],n=this.map.painter.terrain,s=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)o.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}const a=Array.from(o.values());e.t(a,(t,i)=>{const o=new e.b0(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(o,e=>{"raster-dem"===this._source.type&&o.dem&&this._backfillDEM(o),i(e,o);});},i);}}function Bt(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),o=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||o-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function kt(e,t){const i=1<<e.z;return [e.x/i+t,(e.x+1)/i+t]}Ft.maxOverzooming=10,Ft.maxUnderzooming=3;class Nt{constructor(e){this.style=e,this.layersGotHidden=!1,this.layers=[];}processLayersChanged(){this.layers=[];const e=!1,t=!1;for(const i in this.style._mergedLayers){const o=this.style._mergedLayers[i];if("fill-extrusion"===o.type||"building"===o.type)this.layers.push({layer:o,visible:e,visibilityChanged:t});else if("model"===o.type){const i=this.style.getLayerSource(o);i&&"batched-model"===i.type&&this.layers.push({layer:o,visible:e,visibilityChanged:t});}}}onNewFrame(e){this.layersGotHidden=!1;for(const t of this.layers){const i=t.layer;let o=!1;"fill-extrusion"===i.type?o=!i.isHidden(e)&&i.paint.get("fill-extrusion-opacity")>0:"building"===i.type?o=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(o=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!o&&t.visible,t.visible=o;}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,o=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type?r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(r=e.visible?i.paint.get("building-vertical-scale"):0);let n=o?o.getTile(t):null;if(!n&&o)for(const e in o._tiles){const i=o._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){n=i;break}}this.currentBuildingBuckets.push({bucket:n?n.getBucket(i):null,tileID:n?n.tileID:t,verticalScale:r});}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o<e.symbolInstances.length;o++){const r=e.symbolInstances.get(o),n=r.zOffset,s=this._getHeightAtTileOffset(t,r.tileAnchorX,r.tileAnchorY);r.zOffset=s!==Number.NEGATIVE_INFINITY?s:n,i||n===r.zOffset||(i=!0),e.hasAnyZOffset||0===r.zOffset||(e.hasAnyZOffset=!0);}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0);}_mapCoordToOverlappingTile(t,i,o,r){let n=i,s=o;if(t.canonical.z!==r.canonical.z){const a=r.canonical,l=1/(1<<t.canonical.z-a.z);n=(i+t.canonical.x*e.an)*l-a.x*e.an|0,s=(o+t.canonical.y*e.an)*l-a.y*e.an|0;}return {tileX:n,tileY:s}}_getHeightAtTileOffset(e,t,i){let o,r;for(let n=0;n<this.layers.length;++n){const s=this.layers[n].layer;if("fill-extrusion"!==s.type&&"building"!==s.type)continue;const{bucket:a,tileID:l,verticalScale:c}=this.currentBuildingBuckets[n];if(!a)continue;const{tileX:h,tileY:d}=this._mapCoordToOverlappingTile(e,t,i,l),_=a.getHeightAtTileCoord(h,d);_&&void 0!==_.height&&(_.hidden?o=_.height:r=Math.max(_.height*c,r||0));}if(void 0!==r)return r;for(let r=0;r<this.layers.length;++r){const n=this.layers[r];if("model"!==n.layer.type||!n.visible)continue;const{bucket:s,tileID:a}=this.currentBuildingBuckets[r];if(!s)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,i,a),h=s.getHeightAtTileCoord(l,c);if(h&&!h.hidden)return void 0===h.height&&void 0!==o?Math.min(h.maxHeight,o)*h.verticalScale:h.height?h.height*h.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}function Ut(t,i){const o={};for(const e in t)"ref"!==e&&(o[e]=t[e]);return e.b5.forEach(e=>{e in i&&(o[e]=i[e]);}),o}function Vt(e){e=e.slice();const t=Object.create(null);for(const i of e)t[i.id]=i;for(let i=0;i<e.length;i++){const o=e[i];if(o&&"ref"in o){const r=t[o.ref];r&&(e[i]=Ut(o,r));}}return e}const jt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",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",setSnow:"setSnow",setRain:"setRain",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport",addIconset:"addIconset",removeIconset:"removeIconset"};function Gt(e,t,i){i.push({command:jt.addSource,args:[e,t[e]]});}function Zt(e,t,i){t.push({command:jt.removeSource,args:[e]}),i[e]=!0;}function qt(e,t,i,o){Zt(e,i,o),Gt(e,t,i);}function Ht(t,i,o){let r;for(r in t[o])if(t[o].hasOwnProperty(r)&&"data"!==r&&!e.b6(t[o][r],i[o][r]))return !1;for(r in i[o])if(i[o].hasOwnProperty(r)&&"data"!==r&&!e.b6(t[o][r],i[o][r]))return !1;return !0}function Wt(t,i,o,r,n,s){let a;for(a in i=i||{},t=t||{})t.hasOwnProperty(a)&&(e.b6(t[a],i[a])||o.push({command:s,args:[r,a,i[a],n]}));for(a in i)i.hasOwnProperty(a)&&!t.hasOwnProperty(a)&&(e.b6(t[a],i[a])||o.push({command:s,args:[r,a,i[a],n]}));}function $t(e){return e.id}function Xt(e,t){return e[t.id]=t,e}function Yt(t,i,o){const r=i.createTileMatrix(t,t.worldSize,o.toUnwrapped());return e.aD(new Float32Array(16),t.projMatrix,r)}function Kt(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const o=i.clone();return o.setProjection(t.projection),Yt(o,t.getProjection(),e)}function Jt(e,t,i){return t.name===i.projection.name?e.projMatrix:Yt(i,t,e)}class Qt{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding;}lerp(t){if(1===this.points.length)return this.points[0];t=e.aC(t,0,1);let i=1,o=this._distances[i];const r=t*this.paddedLength+this.padding;for(;o<r&&i<this._distances.length;)o=this._distances[++i];const n=i-1,s=this._distances[n],a=o-s,l=a>0?(r-s)/a:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}class ei{constructor(e,t,i){const o=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)o.push([]),r.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0;}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,o,r){this._forEachCell(t,i,o,r,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(o),this.bboxes.push(r);}insertCircle(e,t,i,o){this._forEachCell(t-o,i-o,t+o,i+o,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(o);}_insertBoxCell(e,t,i,o,r,n){this.boxCells[r].push(n);}_insertCircleCell(e,t,i,o,r,n){this.circleCells[r].push(n);}_query(e,t,i,o,r,n){if(i<0||e>this.width||o<0||t>this.height)return !r&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(r)return !0;for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],o=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-o,y1:i-o,x2:t+o,y2:i+o});}return n?s.filter(n):s}return this._forEachCell(e,t,i,o,this._queryCell,s,{hitTest:r,seenUids:{box:{},circle:{}}},n),r?s.length>0:s}_queryCircle(e,t,i,o,r){const n=e-i,s=e+i,a=t-i,l=t+i;if(s<0||n>this.width||l<0||a>this.height)return !o&&[];const c=[];return this._forEachCell(n,a,s,l,this._queryCellCircle,c,{hitTest:o,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),o?c.length>0:c}query(e,t,i,o,r){return this._query(e,t,i,o,!1,r)}hitTest(e,t,i,o,r){return this._query(e,t,i,o,!0,r)}hitTestCircle(e,t,i,o){return this._queryCircle(e,t,i,!0,o)}_queryCell(e,t,i,o,r,n,s,a){const l=s.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&o>=r[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return n.push(!0),!0;n.push({key:this.boxKeys[h],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]});}}}const h=this.circleCells[r];if(null!==h){const r=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,o)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return n.push(!0),!0;{const e=r[h],t=r[h+1],i=r[h+2];n.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,o,r,n,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return n.push(!0),!0}}const d=this.circleCells[r];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return n.push(!0),!0}}}_forEachCell(e,t,i,o,r,n,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),d=this._convertToYCellCoord(o);for(let _=l;_<=h;_++)for(let l=c;l<=d;l++)if(r.call(this,e,t,i,o,this.xCellCount*l+_,n,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,o,r,n){const s=o-e,a=r-t,l=i+n;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,o,r,n,s){const a=(n-o)/2,l=Math.abs(e-(o+a));if(l>a+i)return !1;const c=(s-r)/2,h=Math.abs(t-(r+c));if(h>c+i)return !1;if(l<=a||h<=c)return !0;const d=l-a,_=h-c;return d*d+_*_<=i*i}}const ti=Math.tan(85*Math.PI/180);function ii(t,i,o,r,n,s,a){const l=e.bb();if(o)if("globe"===s.name){const t=e.bc(n,i);e.aD(l,l,t);}else {const t=e.bd([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.ba(l,l,n.angle);}else e.aD(l,n.labelPlaneMatrix,t);return l}function oi(e,t,i,o,r,n,s){const a=ii(e,t,i,o,r,n,s);return "globe"===n.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ri(t,i,o,r,n,s,a){if(o){if("globe"===s.name){const l=ii(t,i,o,r,n,s,a);return e.b7(l,l),e.aD(l,t,l),l}{const i=e.b8(t),o=e.b9([]);return o[0]=a[0],o[1]=a[1],o[4]=a[2],o[5]=a[3],e.aD(i,i,o),r||e.ba(i,i,-n.angle),i}}return n.glCoordMatrix}function ni(t,i,o,r){const n=[t,i,o,1];o?e.aE(n,n,r):mi(n,n,r);const s=n[3];return n[0]/=s,n[1]/=s,n[2]/=s,n}function si(e,t){return Math.min(.5+e/t*.5,1.5)}function ai(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function li(t,i,o,r,n,s,a,l,c,h,d=1){const _=o.transform,u=r?t.textSizeData:t.iconSizeData,p=e.bj(u,o.transform.zoom,d),f="globe"===_.projection.name,m=[256/o.width*2+1,256/o.height*2+1],g=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let v=null;f&&(v=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,b=o.transform.width/o.transform.height;let w,T=!1;for(let r=0;r<x.length;r++){const d=x.get(r),{numGlyphs:f,writingMode:E}=d;if(E!==e.bk.vertical||T||w===e.bk.horizontal||(T=!0),w=E,(d.hidden||E===e.bk.vertical)&&!T){fi(f,g);continue}T=!1;const S=new e.P(d.tileAnchorX,d.tileAnchorY),C="road"===t.elevationType,I=!!_.elevation||C;let{x:R,y:D,z:A}=_.projection.projectTilePoint(S.x,S.y,h.canonical),L=null;if(I){const e=C?t.getElevationFeatureForText(r):null;L={getElevation:c,elevation:_.elevation,elevationFeature:e};const[i,o,n]=c(S,_.elevation,e);R+=i,D+=o,A+=n;}const P=[R,D,A,1];if(e.aE(P,P,i),!ai(P,m)){fi(f,g);continue}const O=P[3],M=si(o.transform.getCameraToCenterDistance(_.projection),O),z=e.bl(u,p,d),F=a?z/M:z*M,B=ni(R,D,A,n);if(B[3]<=0){fi(f,g);continue}let k={};const N=e.ap(t.layers[0].layout.get("text-max-angle")),U=Math.cos(N),V=a?null:L,j=di(d,F,!1,l,i,n,s,t.glyphOffsetArray,y,g,v,B,S,k,b,V,_.projection,h,a,U);T=j.useVertical,V&&j.needsFlipping&&(k={}),(j.notEnoughRoom||T||j.needsFlipping&&di(d,F,!0,l,i,n,s,t.glyphOffsetArray,y,g,v,B,S,k,b,V,_.projection,h,a,U).notEnoughRoom)&&fi(f,g);}r?(t.text.dynamicLayoutVertexBuffer.updateData(g),v&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(v)):(t.icon.dynamicLayoutVertexBuffer.updateData(g),v&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(v));}function ci(e,t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m){const{lineStartIndex:g,glyphStartIndex:v,segment:y}=a,x=v+a.numGlyphs,b=g+a.lineLength,w=t.getoffsetX(v),T=t.getoffsetX(x-1),E=pi(e*w,i,o,r,n,s,y,g,b,l,c,h,d,_,!0,u,p,f,m);if(!E)return null;const S=pi(e*T,i,o,r,n,s,y,g,b,l,c,h,d,_,!0,u,p,f,m);return S?{first:E,last:S}:null}function hi(t,i,o,r){return t===e.bk.horizontal&&Math.abs(r)>Math.abs(o)?{useVertical:!0}:t===e.bk.vertical?r>0?{needsFlipping:!0}:null:0!==i&&function(e,t){return 0===e||Math.abs(t/e)>ti}(o,r)?1===i?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function di(t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m,g,v,y,x){const b=i/24,w=t.lineOffsetX*b,T=t.lineOffsetY*b,{lineStartIndex:E,glyphStartIndex:S,numGlyphs:C,segment:I,writingMode:R,flipState:D}=t,A=E+t.lineLength,L=t=>{if(d){const[i,o,r]=t.up,n=h.length;e.bm(d,n+0,i,o,r),e.bm(d,n+1,i,o,r),e.bm(d,n+2,i,o,r),e.bm(d,n+3,i,o,r);}const[i,o,r]=t.point;e.bn(h,i,o,r,t.angle);};if(C>1){const e=ci(b,l,w,T,o,_,u,t,c,s,p,m,!1,g,v,y,x);if(!e)return {notEnoughRoom:!0};if(r&&!o){let[i,o,r]=e.first.point,[n,s,l]=e.last.point;[i,o]=ni(i,o,r,a),[n,s]=ni(n,s,l,a);const c=hi(R,D,(n-i)*f,s-o);if(t.flipState=c&&c.needsFlipping?1:2,c)return c}L(e.first);for(let e=S+1;e<S+C-1;e++){const t=pi(b*l.getoffsetX(e),w,T,o,_,u,I,E,A,c,s,p,m,!1,!1,g,v,y,x);if(!t)return h.length-=4*(e-S),{notEnoughRoom:!0};L(t);}L(e.last);}else {if(r&&!o){const i=ni(u.x,u.y,0,n),o=E+I+1,r=new e.P(c.getx(o),c.gety(o)),s=ni(r.x,r.y,0,n),a=s[3]>0?s:ui(u,r,i,1,n,void 0,g,v.canonical),l=hi(R,D,(a[0]-i[0])*f,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=pi(b*l.getoffsetX(S),w,T,o,_,u,I,E,A,c,s,p,m,!1,!1,g,v,y,x);if(!i)return {notEnoughRoom:!0};L(i);}return {}}function _i(e,t,i,o,r){const{x:n,y:s,z:a}=o.projectTilePoint(e.x,e.y,t);if(!r)return ni(n,s,a,i);const[l,c,h]=r.getElevation(e,r.elevation,r.elevationFeature);return ni(n+l,s+c,a+h,i)}function ui(t,i,o,r,n,s,a,l){const c=_i(t.sub(i)._unit()._add(t),l,n,a,s);return e.ax(c,o,c),e.ay(c,c),e.bg(c,o,c,r)}function pi(t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m,g,v,y){const x=r?t-i:t+i;let b=x>0?1:-1,w=0;r&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=l+a+(b>0?0:1)|0,E=n,S=n,C=0,I=0;const R=Math.abs(x),D=[],A=[];let L=s,P=L,O=e.be([]);const M=()=>ui(P,L,S,R-C+1,d,u,m,g.canonical);for(;C+I<=R;){if(T+=b,T<l||T>=c)return null;if(S=E,P=L,D.push(S),p&&A.push(P),L=new e.P(h.getx(T),h.gety(T)),E=_[T],!E){const e=_i(L,g.canonical,d,m,u);E=e[3]>0?_[T]=e:M();}C+=I;const t=e.ax([],E,S),i=e.bf(S,E);if(o&&i>0&&I>0&&e.bi(O,t)/(I*i)<y)return null;I=i,O=t;}f&&u&&(_[T]&&(E=M(),I=e.bf(S,E),O=e.ax([],E,S)),_[T]=E);const z=(R-C)/I,F=L.sub(P)._mult(z)._add(P),B=e.bg([],S,O,z);let k=[0,0,1],N=O[0],U=O[1];if(v&&(k=m.upVector(g.canonical,F.x,F.y),0!==k[0]||0!==k[1]||1!==k[2])){const t=[k[2],0,-k[0]],i=e.bh([],k,t);e.ay(t,t),e.ay(i,i),N=e.bi(O,t),U=e.bi(O,i);}if(o){const t=e.bh([],k,O);e.ay(t,t),e.bg(B,B,t,o*b);}const V=w+Math.atan2(U,N);return D.push(B),p&&A.push(F),{point:B,angle:V,path:D,tilePath:A,up:k}}function fi(e,t){const i=t.length,o=i+4*e;t.resize(o),t.float32.fill(-1/0,4*i,4*o);}function mi(e,t,i){const o=t[0],r=t[1];return e[0]=i[0]*o+i[4]*r+i[12],e[1]=i[1]*o+i[5]*r+i[13],e[3]=i[3]*o+i[7]*r+i[15],e}const gi=100;class vi{constructor(e,t,i=new ei(e.width+200,e.height+200,25),o=new ei(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=o,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+gi,this.screenBottomBoundary=e.height+gi,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t,this.clippedSymbols=new Map;}clearClippedSymbolsForBucket(e){this.clippedSymbols.delete(e);}markSymbolAsClipped(e,t){let i=this.clippedSymbols.get(e);i||(i=new Set,this.clippedSymbols.set(e,i)),i.add(t);}placeCollisionBox(t,i,o,r,n,s,a,l,c,h,d){let _=o.projectedAnchorX,u=o.projectedAnchorY,p=o.projectedAnchorZ;const f=o.tileAnchorX,m=o.tileAnchorY,g=o.elevation,v=o.tileID,y=t.getProjection();if(g&&v){const[e,t,i]=y.upVector(v.canonical,o.tileAnchorX,o.tileAnchorY),r=y.upVectorScale(v.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;_+=e*g*r,u+=t*g*r,p+=i*g*r;}const x="globe"===t.projection.name,b="globe"===t.projection.name?e.al(this.transform.zoom):0;if(v&&x&&b<1&&!s){const t=1<<v.canonical.z,i=e.bo(f,m);e.bp(i,i,1/e.an),e.bq(i,i,e.bo(v.canonical.x,v.canonical.y)),e.bp(i,i,1/t),e.br(i,i,e.bo(r[0],r[1])),i[0]=e.bs(i[0],-.5,.5),e.bp(i,i,e.an);const o=e.bt(i[0],i[1],e.an/(2*Math.PI),1);e.aE(o,o,n),_=e.am(_,o[0],b),u=e.am(u,o[1],b),p=e.am(p,o[2],b);}const w=this.projectAndGetPerspectiveRatio(h,_,u,p,o.tileID,"globe"===y.name||!!g||this.transform.pitch>0,y),T=c*w.perspectiveRatio,E=(o.x1*i+a.x-o.padding)*T+w.point.x,S=(o.y1*i+a.y-o.padding)*T+w.point.y,C=(o.x2*i+a.x+o.padding)*T+w.point.x,I=(o.y2*i+a.y+o.padding)*T+w.point.y,R=w.perspectiveRatio<=.55||w.occluded;return !this.isInsideGrid(E,S,C,I)||!l&&this.grid.hitTest(E,S,C,I,d)||R?{box:[],offscreen:!1,occluded:w.occluded}:{box:[E,S,C,I],offscreen:this.isOffscreen(E,S,C,I),occluded:!1}}placeCollisionCircles(t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m){const g=[],v=this.transform.elevation,y=t.getProjection(),x="road"===t.elevationType,b=!!v||x,w=e.bu.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y),T=new e.P(o.tileAnchorX,o.tileAnchorY),E=new e.P(o.tileAnchorX,o.tileAnchorY);let{x:S,y:C,z:I}=y.projectTilePoint(E.x,E.y,m.canonical),R=null;if(b){const e=x?t.getElevationFeatureForText(r):null;R={getElevation:w,elevation:v,elevationFeature:e};const[i,o,n]=w(T,v,e);S+=i,C+=o,I+=n;}const D="globe"===y.name,A=this.projectAndGetPerspectiveRatio(l,S,C,I,m,D||!!v||this.transform.pitch>0,y),{perspectiveRatio:L}=A,P=(_?a/L:a*L)/e.by,O=ni(S,C,I,c),M=o.lineOffsetX*P,z=o.lineOffsetY*P,F=e.ap(t.layers[0].layout.get("text-max-angle")),B=Math.cos(F),k=A.signedDistanceFromCamera>0?ci(P,s,M,z,x&&1===o.flipState,O,E,o,n,c,{},b&&!_?R:null,_&&b,y,m,_,B):null;let N=!1,U=!1,V=!0;if(k&&!A.occluded){const t=.5*p*L+f,o=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),n=new Qt,{first:s,last:a}=k,l=s.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(s.path[e]);for(let e=1;e<a.path.length;e++)c.push(a.path[e]);const _=2.5*t;h&&(c=c.map(([e,t,i],o)=>(b&&!D&&(i=w(o<l-1?s.tilePath[l-1-o]:a.tilePath[o-l+2],v,R.elevationFeature)[2]),ni(e,t,i,h))),c.some(e=>e[3]<=0)&&(c=[]));let m=[];if(c.length>0){let t=1/0,i=-1/0,n=1/0,s=-1/0;for(const e of c)t=Math.min(t,e[0]),n=Math.min(n,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=o.x&&t<=r.x&&s>=o.y&&n<=r.y&&(m=[c.map(t=>new e.P(t[0],t[1]))],(t<o.x||i>r.x||n<o.y||s>r.y)&&(m=e.bv(m,o.x,o.y,r.x,r.y)));}for(const e of m){n.reset(e,.25*t);let o=0;o=n.length<=.5*t?1:Math.ceil(n.paddedLength/_)+1;for(let e=0;e<o;e++){const r=e/Math.max(o-1,1),s=n.lerp(r),a=s.x+gi,l=s.y+gi;g.push(a,l,t,0);const c=a-t,h=l-t,_=a+t,p=l+t;if(V=V&&this.isOffscreen(c,h,_,p),U=U||this.isInsideGrid(c,h,_,p),!i&&this.grid.hitTestCircle(a,l,t,u)&&(N=!0,!d))return {circles:[],offscreen:!1,collisionDetected:N,occluded:!1}}}}return {circles:!d&&N||!U?[]:g,offscreen:V,collisionDetected:N,occluded:A.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let o=1/0,r=1/0,n=-1/0,s=-1/0;for(const a of t){const t=new e.P(a.x+gi,a.y+gi);o=Math.min(o,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),s=Math.max(s,t.y),i.push(t);}const a=this.grid.query(o,r,n,s).concat(this.ignoredGrid.query(o,r,n,s)),l={},c={};for(const t of a){const o=t.key;if(void 0===l[o.bucketInstanceId]&&(l[o.bucketInstanceId]={}),l[o.bucketInstanceId][o.featureIndex])continue;const r=this.clippedSymbols.get(o.bucketInstanceId);if(r&&r.has(o.featureIndex))continue;const n=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.bw(i,n)&&(l[o.bucketInstanceId][o.featureIndex]=!0,void 0===c[o.bucketInstanceId]&&(c[o.bucketInstanceId]=[]),c[o.bucketInstanceId].push(o.featureIndex));}return c}insertCollisionBox(e,t,i,o,r){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:o,collisionGroupID:r},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,o,r){const n=t?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:o,collisionGroupID:r};for(let t=0;t<e.length;t+=4)n.insertCircle(s,e[t],e[t+1],e[t+2]);}projectAndGetPerspectiveRatio(t,i,o,r,n,s,a){const l=[i,o,r,1];let c=!1;if(r||this.transform.pitch>0){if(e.aE(l,l,t),this.fogState&&n&&"globe"!==a.name){const t=function(t,i,o,r,n,s){const a=s.calculateFogTileMatrix(n),l=[i,o,r];return e.ah(l,l,a),Je(t,e.ai(l),s.pitch,s._fov)}(this.fogState,i,o,r,n.toUnwrapped(),this.transform);c=t>.9;}}else mi(l,l,t);const h=l[3];return {point:new e.P((l[0]/h+1)/2*this.transform.width+gi,(-l[1]/h+1)/2*this.transform.height+gi),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:s&&l[2]>h||c}}isOffscreen(e,t,i,o){return i<gi||e>=this.screenRightBoundary||o<gi||t>this.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e<this.gridRightBoundary&&o>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.b9([]);return e.bx(t,t,[-100,-100,0]),t}}class yi{constructor(e,t,i,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):o&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class xi{constructor(e,t,i,o,r,n=!1){this.text=new yi(e?e.text:null,t,i,r),this.icon=new yi(e?e.icon:null,t,o,r),this.clipped=n;}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class bi{constructor(e,t,i,o=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=o;}}class wi{constructor(){this.invProjMatrix=e.bb(),this.viewportMatrix=e.bb(),this.circles=[];}}class Ti{constructor(e,t,i,o,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=o,this.tileID=r;}}class Ei{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function Si(t,i,o,r,n){const{horizontalAlign:s,verticalAlign:a}=e.bF(t),l=-(s-.5)*i,c=-(a-.5)*o,h=e.bG(t,r);return new e.P(l+h[0]*n,c+h[1]*n)}function Ci(t,i,o,r,n){const s=new e.P(t,i);return o&&s._rotate(r?n:-n),s}class Ii{constructor(e,t,i,o,r,n){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new vi(this.transform,r),this.buildingIndex=n,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Ei(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0;}getBucketParts(t,i,o,r,n=1){const s=o.getBucket(i),a=o.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const l=s.layers[0].layout,c=s.layers[0].paint,h=o.collisionBoxArray,d=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),_=o.tileSize/e.an,u=o.tileID.toUnwrapped();this.transform.setProjection(s.projection);const p=(f=o.tileID,m=s.getProjection(),g=this.transform,m.name===this.projection?g.calculateProjMatrix(f.toUnwrapped()):Yt(g,m,f));var f,m,g;const v="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const x=i.dynamicFilter(),b=i.dynamicFilterNeedsFeature(),w=i.dynamicFilterNeedsGeometry(),T=this.transform.calculatePixelsToTileUnitsMatrix(o),E=oi(p,o.tileID.canonical,v,y,this.transform,s.getProjection(),T);let S=null;const C=s.getProjection().createInversionMatrix(this.transform,o.tileID.canonical);if(v){const t=ri(p,o.tileID.canonical,v,y,this.transform,s.getProjection(),T);S=e.aD([],this.transform.labelPlaneMatrix,t);}let I=null;x&&o.latestFeatureIndex&&(I={unwrappedTileID:u,dynamicFilter:x,dynamicFilterNeedsFeature:b,needGeometry:w}),this.retainedQueryData[s.bucketInstanceId]=new Ti(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,o.tileID);const[R,D]=s.layers[0].layout.get("text-size-scale-range"),A=e.aC(n,R,D),[L,P]=l.get("icon-size-scale-range"),O=e.aC(n,L,P),M={bucket:s,layout:l,paint:c,posMatrix:p,invMatrix:C,mercatorCenter:[e.aH(this.transform.center.lng),e.aL(this.transform.center.lat)],textLabelPlaneMatrix:E,labelToScreenMatrix:S,clippingData:I,scale:d,textPixelRatio:_,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:e.bj(s.textSizeData,this.transform.zoom,A),partiallyEvaluatedIconSize:e.bj(s.iconSizeData,this.transform.zoom,O),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:o.latestFeatureIndex};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r,parameters:M});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:M});}attemptAnchorPlacement(e,t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m,g,v,y,x){const{textOffset0:b,textOffset1:w,crossTileID:T}=p,E=[b,w],S=Si(e,n,s,E,a),C=this.collisionIndex.placeCollisionBox(m,a,t,i,o,r,Ci(S.x,S.y,l,c,this.transform.angle),u,h,d,_.predicate);if(v){const e=m.getSymbolInstanceIconSize(x,this.transform.zoom,p.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(m,e,v,i,o,r,Ci(S.x,S.y,l,c,this.transform.angle),u,h,d,_.predicate).box.length)return}if(C.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[T]&&this.prevPlacement.placements[T]&&this.prevPlacement.placements[T].text&&(t=this.prevPlacement.variableOffsets[T].anchor),this.variableOffsets[T]={textOffset:E,width:n,height:s,anchor:e,textScale:a,prevAnchor:t},this.markUsedJustification(m,e,p,g),m.allowVerticalPlacement&&(this.markUsedOrientation(m,g,p),this.placedOrientations[T]=g),{shift:S,placedGlyphBoxes:C}}}placeLayerBucketPart(t,i,o,r,n=1){const{bucket:s,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:d,clippingData:_,textPixelRatio:u,mercatorCenter:p,invMatrix:f,holdingForFade:m,collisionBoxArray:g,partiallyEvaluatedTextSize:v,partiallyEvaluatedIconSize:y,collisionGroup:x,latestFeatureIndex:b}=t.parameters,w=a.get("text-optional"),T=a.get("icon-optional"),E=a.get("text-allow-overlap"),S=a.get("icon-allow-overlap"),C="map"===a.get("text-rotation-alignment"),I="map"===a.get("icon-rotation-alignment"),R="map"===a.get("text-pitch-alignment"),D=l.get("symbol-z-offset"),A="sea"===a.get("symbol-elevation-reference"),L=a.get("symbol-placement"),[P,O]=a.get("text-size-scale-range"),[M,z]=a.get("icon-size-scale-range"),F=e.aC(n,P,O),B=e.aC(n,M,z),k=a.get("text-variable-anchor"),N=C&&"point"!==L,U=I&&"point"!==L,V=k&&s.hasTextData(),j=s.hasIconTextFit()&&V&&s.hasIconData();this.transform.setProjection(s.projection);const G=V||N,Z=U||j;let q=E&&(S||!s.hasIconData()||T),H=S&&(E||!s.hasTextData()||w);const W=!D.isConstant();!s.collisionArrays&&g&&s.deserializeCollisionBoxes(g),o&&r&&s.updateCollisionDebugBuffers(this.transform.zoom,g,F,B);const $=(t,r,n)=>{const{crossTileID:l,numVerticalGlyphVertices:g}=t;let I=null;if(_&&_.dynamicFilterNeedsFeature||W){const i=this.retainedQueryData[s.bucketInstanceId],o=b.loadFeature({featureIndex:t.featureIndex,bucketIndex:i.bucketIndex,sourceLayerIndex:i.sourceLayerIndex,layoutVertexArrayOffset:0}),r=o.properties?o.properties.worldview:null;if(s.localizable&&s.worldview&&"string"==typeof r)if("all"===r)o.properties.$localized=!0;else {if(!r.split(",").includes(s.worldview))return;o.properties.$localized=!0,o.properties.worldview=s.worldview;}I=_&&_.needGeometry?e.bD(o,!0):o;}if(_&&!(0,_.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:s.worldview},I,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(_.unwrappedTileID)))return this.placements[l]=new bi(!1,!1,!1,!0),void i.add(l);const L=D.evaluate(I,{});if((t.zOffset||0)+(L||0)>0&&this.frontCutoffStart>0){const o=2*this.frontCutoffStart-1,r=[t.tileAnchorX,t.tileAnchorY,0,1],n=e.aE(e.bE(),r,c);if(n[1]/n[3]<o)return this.placements[l]=new bi(!1,!1,!1,!0),void i.add(l)}if(i.has(l))return;if(m)return void(this.placements[l]=new bi(!1,!1,!1));let P=!1,O=!1,M=!0,z=!1,F=!1,B=null,N={box:null,offscreen:null,occluded:null},U={box:null},V=null,j=null,$=null,X=0,Y=0,K=0;n.textFeatureIndex?X=n.textFeatureIndex:t.useRuntimeCollisionCircles&&(X=t.featureIndex),n.verticalTextFeatureIndex&&(Y=n.verticalTextFeatureIndex);const J=s.elevationFeatures?s.elevationFeatures[t.elevationFeatureIndex]:void 0,Q=i=>{i.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const o=this.transform.elevation;i.elevation=A?L:L+e.bu.getAtTileOffset(i.tileID,new e.P(i.tileAnchorX,i.tileAnchorY),o,J),i.elevation+=t.zOffset;},ee=n.textBox;if(ee){Q(ee);const i=i=>{let o=e.bk.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[l];e&&(this.placedOrientations[l]=e,o=e,this.markUsedOrientation(s,o,t));}return o},o=(t,i)=>{if(s.allowVerticalPlacement&&g>0&&n.verticalTextBox){for(const o of s.writingModes)if(o===e.bk.vertical?(N=i(),U=N):N=t(),N&&N.box&&N.box.length)break}else N=t();};if(k){let a=k;if(this.prevPlacement&&this.prevPlacement.variableOffsets[l]){const e=this.prevPlacement.variableOffsets[l];a.indexOf(e.anchor)>0&&(a=a.filter(t=>t!==e.anchor),a.unshift(e.anchor));}const h=(e,i,o)=>{const n=s.getSymbolInstanceTextSize(v,t,this.transform.zoom,r),l=(e.x2-e.x1)*n+2*e.padding,h=(e.y2-e.y1)*n+2*e.padding,d=t.hasIconTextFit&&!S?i:null;d&&Q(d);let _={box:[],offscreen:!1,occluded:!1};const m=E?2*a.length:a.length;for(let i=0;i<m;++i){const m=this.attemptAnchorPlacement(a[i%a.length],e,p,f,G,l,h,n,C,R,u,c,x,i>=a.length,t,r,s,o,d,v,y);if(m&&(_=m.placedGlyphBoxes,_&&_.box&&_.box.length)){P=!0,B=m.shift;break}}return _};o(()=>h(ee,n.iconBox,e.bk.horizontal),()=>{const t=n.verticalTextBox;return t&&Q(t),s.allowVerticalPlacement&&!(N&&N.box&&N.box.length)&&g>0&&t?h(t,n.verticalIconBox,e.bk.vertical):{box:null,offscreen:null,occluded:null}}),N&&(P=N.box,M=N.offscreen,z=N.occluded);const d=i(!(!N||!N.box));if(!P&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[l];e&&(this.variableOffsets[l]=e,this.markUsedJustification(s,e.anchor,t,d));}}else {const a=(i,o)=>{const n=s.getSymbolInstanceTextSize(v,t,this.transform.zoom,r),a=this.collisionIndex.placeCollisionBox(s,n,i,p,f,G,new e.P(0,0),E,u,c,x.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(s,o,t),this.placedOrientations[l]=o),a};o(()=>a(ee,e.bk.horizontal),()=>{const t=n.verticalTextBox;return s.allowVerticalPlacement&&g>0&&t?(Q(t),a(t,e.bk.vertical)):{box:null,offscreen:null,occluded:null}}),i(!!(N&&N.box&&N.box.length));}}if(V=N,P=V&&V.box&&V.box.length>0,M=V&&V.offscreen,z=V&&V.occluded,t.useRuntimeCollisionCircles){const i=t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex,r=s.text.placedSymbolArray.get(i),n=e.bl(s.textSizeData,v,r),l=a.get("text-padding");j=this.collisionIndex.placeCollisionCircles(s,E,r,i,s.lineVertexArray,s.glyphOffsetArray,n,c,h,d,o,R,x.predicate,t.collisionCircleDiameter*n/e.by,l,this.retainedQueryData[s.bucketInstanceId].tileID),P=E||j.circles.length>0&&!j.collisionDetected,M=M&&j.offscreen,z=j.occluded;}if(n.iconFeatureIndex&&(K=n.iconFeatureIndex),n.iconBox){const i=i=>{Q(i);const o=t.hasIconTextFit&&B?Ci(B.x,B.y,C,R,this.transform.angle):new e.P(0,0),r=s.getSymbolInstanceIconSize(y,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,r,i,p,f,Z,o,S,u,c,x.predicate)};U&&U.box&&U.box.length&&n.verticalIconBox?($=i(n.verticalIconBox),O=$.box.length>0):($=i(n.iconBox),O=$.box.length>0),M=M&&$.offscreen,F=$.occluded;}const te=w||0===t.numHorizontalGlyphVertices&&0===g,ie=T||0===t.numIconVertices;if(te||ie?ie?te||(O=O&&P):P=O&&P:O=P=O&&P,P&&V&&V.box&&this.collisionIndex.insertCollisionBox(V.box,a.get("text-ignore-placement"),s.bucketInstanceId,U&&U.box&&Y?Y:X,x.ID),O&&$&&this.collisionIndex.insertCollisionBox($.box,a.get("icon-ignore-placement"),s.bucketInstanceId,K,x.ID),j&&(P&&this.collisionIndex.insertCollisionCircles(j.circles,a.get("text-ignore-placement"),s.bucketInstanceId,X,x.ID),o)){const e=s.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new wi);for(let e=0;e<j.circles.length;e+=4)t.circles.push(j.circles[e+0]),t.circles.push(j.circles[e+1]),t.circles.push(j.circles[e+2]),t.circles.push(j.collisionDetected?1:0);}const oe="globe"!==s.projection.name;q=q&&(oe||!z),H=H&&(oe||!F),this.placements[l]=new bi(P||q,O||H,M||s.justReloaded),i.add(l);},X=this.retainedQueryData[s.bucketInstanceId].tileID;if("offset"===s.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(s,X),"road"===s.elevationType&&s.updateRoadElevation(X.canonical),s.updateZOffset(),s.sortFeaturesByY){const t=s.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];$(s.symbolInstances.get(i),i,s.collisionArrays[i]);}s.hasAnyZOffset&&e.w(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(s.hasAnyZOffset){const e=s.getSortedIndexesByZOffset();for(let t=0;t<e.length;++t){const i=e[t];$(s.symbolInstances.get(i),i,s.collisionArrays[i]);}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)$(s.symbolInstances.get(e),e,s.collisionArrays[e]);if(o&&s.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[s.bucketInstanceId];e.b7(t.invProjMatrix,c),t.viewportMatrix=this.collisionIndex.getViewportMatrix();}s.justReloaded=!1;}markUsedJustification(t,i,o,r){const{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=o,h=e.bH(i),d=r===e.bk.vertical?l:"left"===h?n:"center"===h?s:"right"===h?a:-1;n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=d>=0&&n!==d?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=d>=0&&s!==d?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=d>=0&&a!==d?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=d>=0&&l!==d?0:c);}markUsedOrientation(t,i,o){const r=i===e.bk.horizontal||i===e.bk.horizontalOnly?i:0,n=i===e.bk.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;s>=0&&(h.get(s).placedOrientation=r),a>=0&&(h.get(a).placedOrientation=r),l>=0&&(h.get(l).placedOrientation=r),c>=0&&(h.get(c).placedOrientation=n);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const o=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},n=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],n=r[e];n?(this.opacities[e]=new xi(n,o,t.text,t.icon,null,t.clipped),i=i||t.text!==n.text.placed||t.icon!==n.icon.placed):(this.opacities[e]=new xi(null,o,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new xi(t,o,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed);}}for(const e in n)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=n[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t,i,o){o&&(this.lastReplacementSourceUpdateTime=o.updateTime);const r=new Set;for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,n,n.collisionBoxArray,i,o,n.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,n.tileID),"road"===t.elevationType&&t.updateRoadElevation(n.tileID.canonical),t.updateZOffset());}}updateBucketOpacities(t,i,o,r,n,s,a,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,h=t.layers[0].paint,d=!!t.layers[0].dynamicFilter(),_=new xi(null,0,!1,!1,!0),u=c.get("text-allow-overlap"),p=c.get("icon-allow-overlap"),f=c.get("text-variable-anchor"),m="map"===c.get("text-rotation-alignment"),g="map"===c.get("text-pitch-alignment"),v=h.get("symbol-z-offset"),y="sea"===c.get("symbol-elevation-reference"),x=!v.isConstant(),b=new xi(null,0,u&&(p||!t.hasIconData()||c.get("icon-optional")),p&&(u||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const w=(e,t,i)=>{for(let o=0;o<t/4;o++)e.opacityVertexArray.emplaceBack(i);};let T=0;s&&t.updateReplacement(a,s),this.collisionIndex.clearClippedSymbolsForBucket(t.bucketInstanceId);for(let r=0;r<t.symbolInstances.length;r++){const c=t.symbolInstances.get(r),{numHorizontalGlyphVertices:h,numVerticalGlyphVertices:u,crossTileID:p,numIconVertices:E,tileAnchorX:S,tileAnchorY:C}=c;let I=null;const R=this.retainedQueryData[t.bucketInstanceId];x&&c&&R&&(I=o.latestFeatureIndex.loadFeature({featureIndex:c.featureIndex,bucketIndex:R.bucketIndex,sourceLayerIndex:R.sourceLayerIndex,layoutVertexArrayOffset:0}));const D=v.evaluate(I,{}),A=i.has(p);let L=this.opacities[p];A?L=_:L||(L=b,this.opacities[p]=L),i.add(p);const P=h>0||u>0,O=E>0,M=this.placedOrientations[p],z=M===e.bk.vertical,F=M===e.bk.horizontal||M===e.bk.horizontalOnly;!P&&!O||L.isHidden()||T++;let B=!1;if((P||O)&&s)for(const i of t.activeReplacements){if(e.bz(i,n,e.bA.Symbol,l))continue;if(i.min.x>S||S>i.max.x||i.min.y>C||C>i.max.y)continue;const t=e.bB(S,C,a.canonical,i.footprintTileId.canonical);if(B=e.bC(t,i.footprint),B)break}if(B&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,c.featureIndex),P){const e=B?Bi:Fi(L.text);w(t.text,h,z?Bi:e),w(t.text,u,F?Bi:e);const i=L.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:s}=c,a=t.text.placedSymbolArray,l=i||z?1:0;o>=0&&(a.get(o).hidden=l),r>=0&&(a.get(r).hidden=l),n>=0&&(a.get(n).hidden=l),s>=0&&(a.get(s).hidden=i||F?1:0);const d=this.variableOffsets[p];d&&this.markUsedJustification(t,d.anchor,c,M);const _=this.placedOrientations[p];_&&(this.markUsedJustification(t,"left",c,_),this.markUsedOrientation(t,_,c));}if(O){const e=B?Bi:Fi(L.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=c,r=t.icon.placedSymbolArray,n=L.icon.isHidden()?1:0;i>=0&&(w(t.icon,E,z?Bi:e),r.get(i).hidden=n),o>=0&&(w(t.icon,c.numVerticalIconVertices,F?Bi:e),r.get(o).hidden=n);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let o=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(f){const e=this.variableOffsets[p];e?(o=Si(e.anchor,e.width,e.height,e.textOffset,e.textScale),m&&o._rotate(g?this.transform.angle:-this.transform.angle)):r=!1;}d&&(r=!L.clipped),i.textBox&&Ri(t.textCollisionBox.collisionVertexArray,L.text.placed,!r||z,D,y,o.x,o.y),i.verticalTextBox&&Ri(t.textCollisionBox.collisionVertexArray,L.text.placed,!r||F,D,y,o.x,o.y);}const n=r&&Boolean(!F&&i.verticalIconBox);i.iconBox&&Ri(t.iconCollisionBox.collisionVertexArray,L.icon.placed,n,D,y,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0),i.verticalIconBox&&Ri(t.iconCollisionBox.collisionVertexArray,L.icon.placed,!n,D,y,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0);}}}if(t.fullyClipped=0===T,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId];}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}isStale(){return this.stale}setStale(){this.stale=!0;}}function Ri(e,t,i,o,r,n,s){e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0);}const Di=Math.pow(2,25),Ai=Math.pow(2,24),Li=Math.pow(2,17),Pi=Math.pow(2,16),Oi=Math.pow(2,9),Mi=Math.pow(2,8),zi=Math.pow(2,1);function Fi(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Di+t*Ai+i*Li+t*Pi+i*Oi+t*Mi+i*zi+t}const Bi=0;class ki{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[];}continuePlacement(e,t,i,o,r,n){const s=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(s,o,e[this._currentTileIndex],this._sortAcrossTiles,n),this._currentTileIndex++,r())return !0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<s.length;){const e=s[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart,n),this._currentPartIndex++,r())return !0}return !1}}class Ni{startNewPlacement(e,t,i,o,r,n,s,a){return this.placement=new Ii(e,o,r,n,s,a),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=i,this._fadeDuration=o,this._done=!1,this._inProgressLayer=null,this}requestFullPlacement(){this._forceFullPlacement=!0;}isFullPlacementRequested(){return this._forceFullPlacement}setStale(){this.placement&&(this.placement.stale=!0);}isStale(){return !!this.placement&&this.placement.stale}isDone(){return this._done}continuePlacement(t,i,o,r,n){const s=e.o.now(),a=()=>{const t=e.o.now()-s;return !this.isFullPlacementRequested()&&0!==this._fadeDuration&&t>2};for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&"none"!==s.visibility&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){const t=s,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),h="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),d=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),_=h&&d,u=this._inProgressLayer=this._inProgressLayer||new ki(t),p=e.F(s.source,s.scope);if(u.continuePlacement(i||_?r[p]:o[p],this.placement,this._showCollisionBoxes,s,a,n))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._forceFullPlacement=!1,this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const Ui=512/e.an/2;class Vi{constructor(t,i,o){this.tileID=t,this.bucketInstanceId=o,this.index=new e.bI(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.an,n=t.canonical.y*e.an;for(let e=0;e<i.length;e++){const{key:t,crossTileID:o,tileAnchorX:s,tileAnchorY:a}=i.get(e),l=Math.floor((r+s)*Ui),c=Math.floor((n+a)*Ui);this.index.add(l,c),this.keys.push(t),this.crossTileIDs.push(o);}this.index.finish();}findMatches(t,i,o){const r=this.tileID.canonical.z<i.canonical.z?1:Math.pow(2,this.tileID.canonical.z-i.canonical.z),n=Ui/Math.pow(2,i.canonical.z-this.tileID.canonical.z),s=i.canonical.x*e.an,a=i.canonical.y*e.an;for(let e=0;e<t.length;e++){const i=t.get(e);if(i.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:h}=i,d=Math.floor((s+c)*n),_=Math.floor((a+h)*n),u=this.index.range(d-r,_-r,d+r,_+r).sort((e,t)=>e-t);for(const e of u){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!o.has(t)){o.add(t),i.crossTileID=t;break}}}}}class ji{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class Gi{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],o={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),o[r.tileID.key]=r;}this.indexes[e]=o;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const o=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const r=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in r){const n=r[i];n.tileID.isChildOf(e)&&n.findMatches(t.symbolInstances,e,o);}else {const n=r[e.scaledTo(Number(i)).key];n&&n.findMatches(t.symbolInstances,e,o);}}for(let e=0;e<t.symbolInstances.length;e++){const r=t.symbolInstances.get(e);r.crossTileID||(r.crossTileID=i.generate(),o.add(r.crossTileID));}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Vi(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.crossTileIDs)this.usedCrossTileIDs[e].delete(i);}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const o=this.indexes[i];for(const r in o)e[o[r].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,o[r]),delete o[r],t=!0);}return t}}class Zi{constructor(){this.layerIndexes={},this.crossTileIDs=new ji,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={};}addLayer(e,t,i,o){let r=this.layerIndexes[e.fqid];void 0===r&&(r=this.layerIndexes[e.fqid]=new Gi);let n=!1;const s={};"globe"!==o.name&&r.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(i.tileID,t,this.crossTileIDs)&&(n=!0),s[t.bucketInstanceId]=!0);}return r.removeStaleBuckets(s)&&(n=!0),n}pruneUnusedLayers(e){const t={};e.forEach(e=>{t[e]=!0;});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}const qi=771;class Hi{constructor(e,t,i,o){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=o;}}Hi.Replace=[1,0,1,0],Hi.disabled=new Hi(Hi.Replace,e.aq.transparent,[!1,!1,!1,!1]),Hi.unblended=new Hi(Hi.Replace,e.aq.transparent,[!0,!0,!0,!0]),Hi.alphaBlended=new Hi([1,qi,1,qi],e.aq.transparent,[!0,!0,!0,!0]),Hi.alphaBlendedNonPremultiplied=new Hi([770,qi,770,qi],e.aq.transparent,[!0,!0,!0,!0]),Hi.multiply=new Hi([774,0,774,0],e.aq.transparent,[!0,!0,!0,!0]),Hi.multiplyAccumulateAlpha=new Hi([774,0,1,qi],e.aq.transparent,[!0,!0,!0,!0]),Hi.additive=new Hi([1,1,1,1],e.aq.transparent,[!0,!0,!0,!0]);class Wi{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Wi.ReadOnly=!1,Wi.ReadWrite=!0,Wi.disabled=new Wi(519,Wi.ReadOnly,[0,1]);const $i=7680;class Xi{constructor(e,t,i,o,r,n){this.test=e,this.ref=t,this.mask=i,this.fail=o,this.depthFail=r,this.pass=n;}}Xi.disabled=new Xi({func:519,mask:0},0,0,$i,$i,$i);const Yi=1029,Ki=2305;class Ji{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}function Qi(t,i){const o=e.bO(t,3);e.bR(t,i),e.bW(t,3,o);}function eo(t,i){const o=e.bL([]);return e.bM(o,o,-i),e.bN(o,o,-t),o}function to(t,i){const o=[t[0],t[1],0],r=[i[0],i[1],0];if(e.ai(o)>=1e-15){const t=e.ay([],o);e.bJ(r,t,e.bi(r,t)),i[0]=r[0],i[1]=r[1];}const n=e.bh([],i,t);if(e.bK(n)<1e-15)return null;const s=Math.atan2(-n[1],n[0]);return eo(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}Ji.disabled=new Ji(!1,Yi,Ki),Ji.backCCW=new Ji(!0,Yi,Ki),Ji.backCW=new Ji(!0,Yi,2304),Ji.frontCW=new Ji(!0,1028,2304),Ji.frontCCW=new Ji(!0,1028,Ki);class io{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(t){if(t){const i=t instanceof e.ag?t:new e.ag(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bs(i.x,0,1)),this._position=i;}else this._position=null;}lookAtPoint(t,i,o){if(this.orientation=null,!this.position)return;const r=this.position,n=o||(this._elevation?this._elevation.getAtPointOrZero(e.ag.fromLngLat(t)):0),s=e.ag.fromLngLat(t,n),a=[s.x-r.x,s.y-r.y,s.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=to(a,i);}setPitchBearing(t,i){this.orientation=eo(e.ap(t),e.ap(-i));}}class oo{constructor(t,i){this._transform=e.b9([]),this.orientation=i,this.position=t;}get mercatorPosition(){const t=this.position;return new e.ag(t[0],t[1],t[2])}get position(){const t=e.bO(this._transform,3);return [t[0],t[1],t[2]]}set position(t){var i;t&&e.bW(this._transform,3,[(i=t)[0],i[1],i[2],1]);}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.bL([]),t&&Qi(this._transform,this._orientation);}getPitchBearing(){const e=this.forward(),t=this.right();return {bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=eo(e,t),Qi(this._transform,this._orientation);}forward(){const t=e.bO(this._transform,2);return [-t[0],-t[1],-t[2]]}up(){const t=e.bO(this._transform,1);return [-t[0],-t[1],-t[2]]}right(){const t=e.bO(this._transform,0);return [t[0],t[1],t[2]]}getCameraToWorld(t,i){const o=new Float64Array(16);return e.b7(o,this.getWorldToCamera(t,i)),o}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,o){const r=this.position;e.bJ(r,r,-t);const n=new Float64Array(16);return e.bP(n,[o,o,o]),e.bx(n,n,r),n[10]*=i,n}getWorldToCamera(t,i){const o=new Float64Array(16),r=new Float64Array(4),n=this.position;return e.bQ(r,this._orientation),e.bJ(n,n,-t),e.bR(o,r),e.bx(o,o,n),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=i,o[9]*=i,o[10]*=i,o[11]*=i,o}getCameraToClipPerspective(t,i,o,r){const n=new Float64Array(16);return e.bS(n,t,i,o,r),n}getCameraToClipOrthographic(t,i,o,r,n,s){const a=new Float64Array(16);return e.bT(a,t,i,o,r,n,s),a}getDistanceToElevation(t,i=!1){const o=0===t?0:e.bU(t,i?e.bV(this.position[1]):this.position[1]),r=this.forward();return (o-this.position[2])/r[2]}clone(){return new oo([...this.position],[...this.orientation])}}const ro=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t});class no{constructor(e=0,t=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=o;}interpolate(t,i,o){return null!=i.top&&null!=t.top&&(this.top=e.am(t.top,i.top,o)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.am(t.bottom,i.bottom,o)),null!=i.left&&null!=t.left&&(this.left=e.am(t.left,i.left,o)),null!=i.right&&null!=t.right&&(this.right=e.am(t.right,i.right,o)),this}getCenter(t,i){const o=e.aC((this.left+t-this.right)/2,0,t),r=e.aC((this.top+i-this.bottom)/2,0,i);return new e.P(o,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new no(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const so=15;class ao{constructor(t,i,o,r,n,s,a){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=o??0,this._maxPitch=r??60,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.aU(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new no,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new oo,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1;}clone(){const e=new ao(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._nearClipOffset=this._nearClipOffset,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e._allowWorldUnderZoom=this._allowWorldUnderZoom,e}get isOrthographic(){return "globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<so}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices());}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(e){this._nearClipOffset=e,this._calcMatrices();}get depthOcclusionForSymbolsAndCircles(){return "globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices();}getProjection(){return e.aJ(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=e.c0(this.projectionOptions);const o=this.getProjection(),r=!e.b6(i,o);return r&&this._calcMatrices(),this.mercatorFromTransition=!1,r}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.c0({name:"mercator"});const i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e));}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e));}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e));}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e));}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bU(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bs(this.rotation,-180,180)}set bearing(e){this.rotation=e;}get rotation(){return -this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=e.c1(),e.c2(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.aC(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices());}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.ap(t),this._calcMatrices());}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={};}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices());}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom;}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e);}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){if(void 0===this._centerAltitudeValidForExaggeration)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e);}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],o=this.horizonLineFromTop();let r=0,n=0;for(let s=0;s<i.length;s++){const a=new e.P(i[s][0]*this.width,o+i[s][1]*(this.height-o)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);r+=l[3]*c,n+=c;}return 0===n?NaN:r/n}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices());}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,o=this._mercatorZfromZoom(e),r=this._mercatorZfromZoom(this._maxZoom),n=Math.max(o-i,r);this._setZoom(this._zoomFromMercatorZ(n));}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}equals(e){const t=this.elevation,i=e.elevation,o=null!=t!=(null!=i)||t&&i&&t.exaggeration()!==i.exaggeration();return this.width===e.width&&this.height===e.height&&this.center.lng===e.center.lng&&this.center.lat===e.center.lat&&this.zoom===e.zoom&&this.bearing===e.bearing&&this.pitch===e.pitch&&this.fov===e.fov&&this.projection.name===e.projection.name&&this._edgeInsets.equals(e.padding)&&!o}computeZoomRelativeTo(t){const i=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let o;o=t.z<this._camera.position[2]?[i.x,i.y,i.z]:[t.x,t.y,t.z];const r=e.ai(e.ax([],this._camera.position,o));return e.aC(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let i=!1;if(t.orientation&&!e.c3(t.orientation,this._camera.orientation)&&(i=this._setCameraOrientation(t.orientation)),t.position){const o=[t.position.x,t.position.y,t.position.z];e.c4(o,this._camera.position)||(this._setCameraPosition(o),i=!0);}i&&(this._updateStateFromCamera(),this.recenterOnTerrain());}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,i=new io;return i.position=new e.ag(t[0],t[1],t[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this.renderWorldCopies,i}_setCameraOrientation(t){if(!e.c5(t))return !1;e.c6(t,t);const i=e.c7([],[0,0,-1],t),o=e.c7([],[0,-1,0],t);if(o[2]<0)return !1;const r=to(i,o);return !!r&&(this._camera.orientation=r,!0)}_setCameraPosition(t){const i=this.zoomScale(this.minZoom)*this.tileSize,o=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;t[2]=e.aC(t[2],r/o,r/i),this._camera.position=t;}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const i=[new e.c8(0,t)];if(this.renderWorldCopies){const o=this.pointCoordinate(new e.P(0,0)),r=this.pointCoordinate(new e.P(this.width,0)),n=this.pointCoordinate(new e.P(this.width,this.height)),s=this.pointCoordinate(new e.P(0,this.height)),a=Math.floor(Math.min(o.x,r.x,n.x,s.x)),l=Math.floor(Math.max(o.x,r.x,n.x,s.x)),c=1;for(let o=a-c;o<=l+c;o++)0!==o&&i.push(new e.c8(o,t));}return i}isLODDisabled(e){return (!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(t,i,o,r){let n=[];const s=null!=o,a=!s;if(a&&this.zoom<i)return n;if(s&&0===o[0]&&0===o[1])return n;const l=new Set,c=(t,i,o,r,s)=>{const a=e.ck(i,t,o,r,s);l.has(a)||(n.push(new e.aR(t,i,o,r,s)),l.add(a));};for(let e=0;e<t.length;e++){const n=t[e];if(a&&n.canonical.z!==i)continue;if(s&&void 0!==r&&r>n.canonical.z)continue;const l=n.canonical,h=n.overscaledZ,d=n.wrap,_=1<<l.z,u=l.x+1<_,p=l.x>0,f=l.y+1<_,m=l.y>0,g=n.wrap-(p?0:1),v=n.wrap+(u?0:1),y=p?l.x-1:_-1,x=u?l.x+1:0;if(s)o[0]<0?(c(h,v,l.z,x,l.y),o[1]<0&&f&&(c(h,d,l.z,l.x,l.y+1),c(h,v,l.z,x,l.y+1)),o[1]>0&&m&&(c(h,d,l.z,l.x,l.y-1),c(h,v,l.z,x,l.y-1))):o[0]>0?(c(h,g,l.z,y,l.y),o[1]<0&&f&&(c(h,d,l.z,l.x,l.y+1),c(h,g,l.z,y,l.y+1)),o[1]>0&&m&&(c(h,d,l.z,l.x,l.y-1),c(h,g,l.z,y,l.y-1))):o[1]<0&&f?c(h,d,l.z,l.x,l.y+1):m&&c(h,d,l.z,l.x,l.y-1);else {const e=n.visibleQuadrants;1&e&&(c(h,g,l.z,y,l.y),m&&(c(h,d,l.z,l.x,l.y-1),c(h,g,l.z,y,l.y-1))),2&e&&(c(h,v,l.z,x,l.y),m&&(c(h,d,l.z,l.x,l.y-1),c(h,v,l.z,x,l.y-1))),4&e&&(c(h,g,l.z,y,l.y),f&&(c(h,d,l.z,l.x,l.y+1),c(h,g,l.z,y,l.y+1))),8&e&&(c(h,v,l.z,x,l.y),f&&(c(h,d,l.z,l.x,l.y+1),c(h,v,l.z,x,l.y+1)));}}const h=[];for(const e of n)n.some(t=>e.isChildOf(t))||h.push(e);if(n=h.filter(e=>!t.some(t=>!!(e.overscaledZ<i&&t.isChildOf(e))||e.equals(t)||e.isChildOf(t))),a){const e=1<<i,t="globe"===this.projection.name?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),o=[e*t.x,e*t.y],r=4,s=r*r;n=n.filter(e=>{const t=e.canonical.x+.5-o[0],i=e.canonical.y+.5-o[1];return t*t+i*i<s});}return n}extendTileCoverToNearPlane(t,i,o){const r=[],n=new Set;for(const e of t)n.add(e.key);const s=(t,i,o,s,a)=>{const l=e.ck(i,t,o,s,a);n.has(l)||(r.push(new e.aR(t,i,o,s,a)),n.add(l));},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),o),l=1<<o,c=[new e.P(0,0),new e.P(e.an,0),new e.P(e.an,e.an),new e.P(0,e.an)],h=new e.P(0,0),d=new e.P(0,0),_=(t,i)=>{const r=Math.floor(t[0]),n=Math.floor(t[1]),_=(t[0]-r)*e.an,u=(t[1]-n)*e.an,p=Math.floor(i[0]),f=Math.floor(i[1]),m=(i[0]-p)*e.an,g=(i[1]-f)*e.an;for(let t=-1;t<=1;t++){const i=r+t;if(!(i<0||i>=l)){h.x=_-t*e.an,d.x=m-(i-p)*e.an;for(let t=-1;t<=1;t++){const r=n+t;h.y=u-t*e.an,d.y=g-(r-f)*e.an,e.cI(h,d,c)&&s(a,0,o,i,r);}}}},u=i.points,p=u[e.c9],f=u[e.ca],m=this._projectToGround(p,u[e.cb]),g=this._projectToGround(f,u[e.cc]);return _(p,m),_(f,g),r}_projectToGround(t,i){return e.cd(e.ce(),t,i,t[2]/(t[2]-i[2]))}_projectToZ(t,i,o){const r=t[2]-i[2];return Math.abs(r)<1e-6?e.cf(t):e.cd(e.ce(),t,i,(t[2]-o)/r)}extendTileCoverForTunnels(t,i,o,r){if(o<18)return [];const n=i.points,s=n[e.cg],a=n[e.ch],l=n[e.ci],c=n[e.cj];if(l[2]>=0&&c[2]>=0||s[2]<=0||a[2]<=0)return [];const h=l[2]<0?this._projectToZ(s,l,0):l,d=c[2]<0?this._projectToZ(a,c,0):c,_=-r,u=l[2]<_?this._projectToZ(s,l,_):l,p=c[2]<_?this._projectToZ(a,c,_):c,f=this._findExtensionTilesInQuad(t,o,[p,u,d,h],[.5*(h[0]+d[0]),.5*(h[1]+d[1])]);return f.length>3&&(f.length=3),f}_findExtensionTilesInQuad(t,i,o,r){const n=[],s=new Set;for(const e of t)s.add(e.key);const a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),i),l=1<<i,c=[new e.P(o[0][0],o[0][1]),new e.P(o[1][0],o[1][1]),new e.P(o[3][0],o[3][1]),new e.P(o[2][0],o[2][1]),new e.P(o[0][0],o[0][1])],h=o[0][0],d=o[1][0],_=o[2][0],u=o[3][0],p=o[0][1],f=o[1][1],m=o[2][1],g=o[3][1],v=Math.max(0,Math.floor(Math.min(h,d,_,u))),y=Math.min(l-1,Math.ceil(Math.max(h,d,_,u))-1),x=Math.max(0,Math.floor(Math.min(p,f,m,g))),b=Math.min(l-1,Math.ceil(Math.max(p,f,m,g))-1);for(let t=x;t<=b;t++)for(let o=v;o<=y;o++){if(!e.av(c,o,t,o+1,t+1))continue;const r=e.ck(0,a,i,o,t);s.has(r)||(n.push(new e.aR(a,0,i,o,t)),s.add(r));}const w=r[0],T=r[1];return n.sort((e,t)=>{const i=e.canonical.x+.5-w,o=e.canonical.y+.5-T,r=t.canonical.x+.5-w,n=t.canonical.y+.5-T;return i*i+o*o-(r*r+n*n)||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y}),n}coveringTiles(t){let i=this.coveringZoomLevel(t);const o=i,r=this.elevation&&this.elevation.exaggeration(),n=r&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&i<t.minzoom)return [];void 0!==t.maxzoom&&i>t.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<<i,h=[c*a.x,c*a.y,0],d="globe"===this.projection.name,_=!d,u=e.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,_),p=d?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=c*e.bU(1,this.center.lat),m=this._camera.position[2]/e.bU(1,this.center.lat),g=[c*p.x,c*p.y,m*(_?1:f)],v=d||r,y=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),x=this.isLODDisabled(!0)?i:0;let b;if(this._elevation&&t.isTerrainDEM)b=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();b=e?e.max:this._centerAltitude;}else b=this._centerAltitude;const w=t.isTerrainDEM?-b:this._elevation?this._elevation.getMinElevationBelowMSL():0,T=this.projection.isReprojectedInTileSpace?e.cm(this):1,E=t=>{const i=1/4e4,o=new e.ag(t.x+i,t.y,t.z),r=new e.ag(t.x,t.y+i,t.z),n=t.toLngLat(),s=o.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(n),c=this.locationCoordinate(s),h=this.locationCoordinate(a),d=Math.hypot(c.x-l.x,c.y-l.y),_=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(d*_)*T/i},S=t=>{const i=b,o=w;return {aabb:e.cp(this,c,0,0,0,t,o,i,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:i,wrap:t,fullyVisible:!1}},C=[];let I=[];const R=i,D=t.reparseOverscaled?o:i,A=(m-this._centerAltitude)*f,L=e=>{if(!this._elevation||!e.tileID||!s)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=O(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},P=(e,t)=>{if(.707*t<e)return 1;const i=t/e;return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)},O=t=>{if(t.zoom<x)return !0;if(t.zoom===R)return !1;if(null!=t.shouldSplit)return t.shouldSplit;const i=t.aabb.distanceX(g),r=t.aabb.distanceY(g);let a=A,c=1;if(d){a=t.aabb.distanceZ(g);const i=Math.pow(2,t.zoom),o=e.bV((t.y+1)/i),r=e.bV(t.y/i),n=Math.min(Math.max(l,o),r),s=e.cM(n)/e.cM(l);if(c=n===l?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,s/this._mercatorScaleRatio),this.zoom<=e.cJ&&t.zoom===R-1&&s>=.9)return !0}else if(n&&(a=t.aabb.distanceZ(g)*f),this.projection.isReprojectedInTileSpace&&o<=5){const i=Math.pow(2,t.zoom),o=E(new e.ag((t.x+.5)/i,(t.y+.5)/i));c=o>.85?1:o;}if(!s&&!d){const e=Math.sqrt(i*i+r*r+a*a);let o=(1<<R-t.zoom)*y*c;return o*=P(Math.max(a,A),e),e<o}let _=Number.MAX_VALUE,u=0;const p=t.aabb.getCorners(),m=[];for(const t of p){e.ax(m,t,g),d||(n?m[2]*=f:m[2]=A);const i=e.bi(m,this._camera.forward());i<_&&(_=i,u=Math.abs(m[2]));}let v=(1<<R-t.zoom)*y*c;if(v*=P(Math.max(u,A),_),_<v)return !0;const b=t.aabb.closestPoint(h);return b[0]===h[0]&&b[1]===h[1]};if(this.renderWorldCopies)for(let e=1;e<=3;e++)C.push(S(-e)),C.push(S(e));for(C.push(S(0));C.length>0;){const o=C.pop(),r=o.x,a=o.y;let l=o.fullyVisible;const _=()=>"globe"===this.projection.name&&(0===o.y||o.y===(1<<o.zoom)-1);if(!l){let t=v?o.aabb.intersects(u):o.aabb.intersectsFlat(u);if(0===t&&_()){const i=new e.cn(o.zoom,r,a);t=e.co(this,c,i,!0).intersects(u);}if(0===t)continue;l=2===t;}if(o.zoom===R||!O(o)){const n=o.zoom===R?D:o.zoom;if(t.minzoom&&t.minzoom>n)continue;let s=0;if(!l){let i=v?o.aabb.intersectsPrecise(u):o.aabb.intersectsPreciseFlat(u);if(0===i&&_()){const t=new e.cn(o.zoom,r,a);i=e.co(this,c,t,!0).intersectsPrecise(u);}if(0===i)continue;if(t.calculateQuadrantVisibility)if(u.containsPoint(o.aabb.center))s=15;else for(let e=0;e<4;e++)0!==o.aabb.quadrant(e).intersects(u)&&(s|=1<<e);}const d=h[0]-(.5+r+(o.wrap<<o.zoom))*(1<<i-o.zoom),p=h[1]-.5-a,f=o.tileID?o.tileID:new e.aR(n,o.wrap,o.zoom,r,a);t.calculateQuadrantVisibility&&(f.visibleQuadrants=s),I.push({tileID:f,distanceSq:d*d+p*p});continue}for(let t=0;t<4;t++){const i=(r<<1)+t%2,h=(a<<1)+(t>>1),_={aabb:s?o.aabb.quadrant(t):e.cp(this,c,o.zoom+1,i,h,o.wrap,o.minZ,o.maxZ,this.projection),zoom:o.zoom+1,x:i,y:h,wrap:o.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:o.minZ,maxZ:o.maxZ};n&&!d&&(_.tileID=new e.aR(o.zoom+1===R?D:o.zoom+1,o.wrap,o.zoom+1,i,h),L(_)),C.push(_);}}if(this.fogCullDistSq){const i=this.fogCullDistSq,o=this.horizonLineFromTop();I=I.filter(r=>{const n=[0,0,0,1],s=[e.an,e.an,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.aE(n,n,a),e.aE(s,s,a);const l=e.cq([],n,s),c=e.cr([],n,s),h=e.cK(l,c);if(0===h)return !0;let d=!1;const _=this._elevation;if(_&&h>i&&0!==o){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;t.isTerrainDEM||(n=_.getMinMaxForTile(r.tileID)),n||(n={min:w,max:b});const s=e.cs(this.rotation),a=[s[0]*e.an,s[1]*e.an,n.max];e.ah(a,a,i),d=(1-a[1])*this.height*.5<o;}return h<i||d});}return I.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log2(e)}project(t){const i=e.aC(t.lat,-e.ct,e.ct),o=this.projection.project(t.lng,i);return new e.P(o.x*this.worldSize,o.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.bU(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let o,r;const n=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;o=(i.x-n.x)/e,r=(i.y-n.y)/e;}else {const e=this.pointCoordinate(i),t=this.pointCoordinate(n);o=e.x-t.x,r=e.y-t.y;}const s=this.locationCoordinate(t);this.setLocation(new e.ag(s.x-o,s.y-r));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(t,i){const o=i?e.bU(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.ag(r.x,r.y,o)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const o=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],n=[t.x,t.y,1,1];e.aE(r,r,this.pixelMatrixInverse),e.aE(n,n,this.pixelMatrixInverse);const s=n[3];e.cu(r,r,1/r[3]),e.cu(n,n,1/s);const a=r[2],l=n[2];return {p0:r,p1:n,t:a===l?0:(o-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];return e.aE(i,i,this.pixelMatrixInverse),e.aE(o,o,this.pixelMatrixInverse),e.cu(i,i,1/i[3]),e.cu(o,o,1/o[3]),i[2]=e.bU(i[2],this._center.lat)*this.worldSize,o[2]=e.bU(o[2],this._center.lat)*this.worldSize,e.cu(i,i,1/this.worldSize),e.cu(o,o,1/this.worldSize),new e.az([i[0],i[1],i[2]],e.ay([],e.ax([],o,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:o,t:r}=t,n=e.bU(i[2],this._center.lat),s=e.bU(o[2],this._center.lat);return new e.ag(e.am(i[0],o[0],r)/this.worldSize,e.am(i[1],o[1],r)/this.worldSize,e.am(n,s,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let o=this.projection.pointCoordinate3D(this,t.x,t.y);if(o)return new e.ag(o[0],o[1],o[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t,i);const s=.02*n,a=t.clone();for(let t=0;t<10&&n-r>s;t++){a.y=e.am(r,n,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(n=a.y,o=t):r=a.y;}return o?new e.ag(o[0],o[1],o[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return !1;if(this.elevation||this.zoom>=e.cv)return !this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const o=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,o+t.toAltitude(),1];return e.aE(r,r,this.pixelMatrix),r[3]>0?new e.P(r[0]/r[3],r[1]/r[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,n=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(r,t)),a=this.pointLocation3D(new e.P(r,o)),l=this.pointLocation3D(new e.P(i,o));let c=Math.min(n.lng,s.lng,a.lng,l.lng),h=Math.max(n.lng,s.lng,a.lng,l.lng),d=Math.min(n.lat,s.lat,a.lat,l.lat),_=Math.max(n.lat,s.lat,a.lat,l.lat);const u=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,f=(t,i,o,r,n)=>{const s=(t+o)/2,a=(i+r)/2,l=new e.P(s,a),{lng:m,lat:g}=this.pointLocation3D(l),v=Math.max(0,c-m,d-g,m-h,g-_);c=Math.min(c,m),h=Math.max(h,m),d=Math.min(d,g),_=Math.max(_,g),(n<p||v>u)&&(f(t,i,s,a,n+1),f(s,a,o,r,n+1));};if(f(i,t,r,t,1),f(r,t,r,o,1),f(r,o,i,o,1),f(i,o,i,t,1),"globe"===this.projection.name){const[t,i]=e.cw(this);t?(_=90,h=180,c=-180):i&&(d=-90,h=180,c=-180);}return new e.aK(new e.aU(c,d),new e.aU(h,_))}_getBoundsRectangular(t,i){const{top:o,left:r}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(r,o),l=new e.P(s,o),c=new e.P(s,n),h=new e.P(r,n);let d=this.pointCoordinate(a,t),_=this.pointCoordinate(l,t);const u=this.pointCoordinate(c,i),p=this.pointCoordinate(h,i),f=(e,t)=>(t.y-e.y)/(t.x-e.x);return d.y>1&&_.y>=0?d=new e.ag((1-p.y)/f(p,d)+p.x,1):d.y<0&&_.y<=1&&(d=new e.ag(-p.y/f(p,d)+p.x,0)),_.y>1&&d.y>=0?_=new e.ag((1-u.y)/f(u,_)+u.x,1):_.y<0&&d.y<=1&&(_=new e.ag(-u.y/f(u,_)+u.x,0)),(new e.aK).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(_)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(u))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0]);}return e},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return "mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.ct,this.maxLat=e.ct,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.aH(this.minLng)*this.tileSize,this.worldMaxX=e.aH(this.maxLng)*this.tileSize,this.worldMinY=e.aL(this.maxLat)*this.tileSize,this.worldMaxY=e.aL(this.minLat)*this.tileSize,this._constrain();}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(t){const i=t.key,o=this._distanceTileDataCache;if(o[i])return o[i];const r=t.canonical,n=1/this.height,s=this.cameraWorldSize,a=s/this.zoomScale(r.z),l=(r.x+Math.pow(2,r.z)*t.wrap)*a,c=r.y*a,h=this.point;h.x*=s/this.worldSize,h.y*=s/this.worldSize;const d=this.angle,_=Math.sin(-d),u=-Math.cos(-d);return o[i]={bearing:[_,u],center:[(h.x-l)*n,(h.y-c)*n],scale:a/e.an*n},o[i]}calculateFogTileMatrix(t){const i=t.key,o=this._fogTileMatrixCache;if(o[i])return o[i];const r=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return e.aD(r,this.worldToFogMatrix,r),o[i]=new Float32Array(r),o[i]}calculateProjMatrix(t,i=!1,o=!1){const r=t.key;let n;if(n=o?this._expandedProjMatrixCache:i?this._alignedProjMatrixCache:this._projMatrixCache,n[r])return n[r];const s=this.calculatePosMatrix(t,this.worldSize);let a;return a=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:o?this.expandedFarZProjMatrix:i?this.alignedProjMatrix:this.projMatrix,e.aD(s,a,s),n[r]=new Float32Array(s),n[r]}calculatePixelsToTileUnitsMatrix(t){const i=t.tileID.key,o=this._pixelsToTileUnitsCache;if(o[i])return o[i];const r=e.cx(t,this);return o[i]=r,o[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const t=1/this.worldSize,i=e.bP([],[t,t,t]);return e.aD(i,i,this.globeMatrix),i}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const i=e.bU(1,this._center.lat)*this.worldSize,o=this._computeCameraPosition(i),r=this._camera.forward(),n=e.bU(1,this._center.lat);o[2]/=n,r[2]/=n,e.ay(r,r);const s=t.raycast(o,r,t.exaggeration());if(s){const t=e.bg([],o,r,s),i=new e.ag(t[0],t[1],e.bU(t[2],e.bV(t[1]))),a=(i.z+e.ai([i.x-o[0],i.y-o[1],i.z-o[2]*n]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=i.toAltitude(),this._center=this.coordinateLocation(i),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices();}}_constrainCamera(t=!1){if(!this._elevation)return;const i=this._elevation,o=e.bU(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(o),n=i.getAtPointOrZero(new e.ag(...r)),s=this.pixelsPerMeter/this.worldSize*n,a=this._minimumHeightOverTerrain(),l=r[2]-s;if(l<=a)if(l<0||t){const t=this.locationCoordinate(this._center,this._centerAltitude),i=[r[0],r[1],t.z-r[2]],o=e.ai(i);i[2]-=(a-l)/this._pixelsPerMercatorPixel;const n=e.ai(i);if(0===n)return;e.bJ(i,i,o/n*this._pixelsPerMercatorPixel),this._camera.position=[r[0],r[1],t.z*this._pixelsPerMercatorPixel-i[2]],this._updateStateFromCamera();}else this._isCameraConstrained=!0;}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const i=this.center;return i.lat=e.aC(i.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(i.lng=e.aC(i.lng,this.minLng,this.maxLng)),this.center=i,void(this._constraining=!1)}const i=this._unmodified,{x:o,y:r}=this.point;let n=0,s=o,a=r;const l=this.width/2,c=this.height/2,h=this.worldMinY*this.scale,d=this.worldMaxY*this.scale;if(r-c<h&&(a=h+c),r+c>d&&(a=d-c),d-h<this.height&&(n=Math.max(n,this.height/(d-h)),a=(d+h)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,i=this.worldSize/2-(e+t)/2;s=(o+i+this.worldSize)%this.worldSize-i,s-l<e&&(s=e+l),s+l>t&&(s=t-l),t-e<this.width&&(n=Math.max(n,this.width/(t-e)),s=(t+e)/2);}s===o&&a===r||this._allowWorldUnderZoom||(this.center=this.unproject(new e.P(s,a))),n&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(n)),this._constrainCamera(),this._unmodified=i,this._constraining=!1;}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,i="globe"===this.projection.name,o=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=e.bU(1,this.center.lat)/e.bU(1,e.cN));const r=e.cy(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,r),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const n="meters"===this.projection.zAxisUnit?o:1,s=this._camera.getWorldToCamera(this.worldSize,n);let a;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,this.isOrthographic){let i=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),o=i*this.aspect,r=-o,n=-i;o-=t.x,r-=t.x,i+=t.y,n+=t.y,a=this._camera.getCameraToClipOrthographic(r,o,n,i,this._nearZ+this._nearClipOffset,this._farZ),((t,i,o,r)=>{for(let n=0;n<16;n++)t[n]=e.am(i[n],o[n],r);})(a,a,l,e.cL(this.pitch>=so?1:this.pitch/so));}else a=l;const c=e.cz([],l,s);let h=e.cz([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.b9([]);e.bx(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.aD(i,i,e.cA(this)),e.bx(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.aD(h,h,i),e.aD(c,c,i),this.inverseAdjustmentMatrix=e.cB(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.cC([],h,[this.worldSize,this.worldSize,this.worldSize/n,1]),this.projMatrix=h,this.invProjMatrix=e.b7(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.cz([],i,s);}else this.expandedFarZProjMatrix=this.projMatrix;const d=e.b7([],a);this.frustumCorners=e.cD.fromInvProjectionMatrix(d,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const _=new Float32Array(16);e.b9(_),e.cC(_,_,[1,-1,1]),e.cE(_,_,this._pitch),e.ba(_,_,this.angle);const u=e.bS(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.b8(u);const p=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;u[8]=2*-t.x/this.width,u[9]=2*(t.y+p)/this.height,this.skyboxMatrix=e.aD(_,u,_);const f=this.point,m=f.x,g=f.y,v=this.width%2/2,y=this.height%2/2,x=Math.cos(this.angle),b=Math.sin(this.angle),w=m-Math.round(m)+x*v+b*y,T=g-Math.round(g)+x*y+b*v,E=new Float64Array(h);if(e.bx(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,h=e.bb(),e.cC(h,h,[this.width/2,-this.height/2,1]),e.bx(h,h,[1,-1,0]),this.labelPlaneMatrix=h,h=e.bb(),e.cC(h,h,[1,-1,1]),e.bx(h,h,[-1,-1,0]),e.cC(h,h,[2/this.width,2/this.height,1]),this.glCoordMatrix=h,this.pixelMatrix=e.aD(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},h=e.b7(new Float64Array(16),this.pixelMatrix),!h)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=h,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.cF(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.ah(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=h;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,o=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,n=[t,t,i];e.bJ(n,n,r),e.bJ(o,o,-1),e.cG(o,o,n);const s=e.bb();e.bx(s,s,o),e.cC(s,s,n),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [o.x/this.worldSize-i[0]*r,o.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition());}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),o=this._camera.position[2],r=t[2];let n=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(n=Math.min((i-o)/r,1)),this._camera.position=e.bg([],this._camera.position,t,n),this._updateStateFromCamera();}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:o,bearing:r}=this._camera.getPitchBearing(),n=e.bU(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.ap(this._maxPitch)),a=Math.max((t[2]-n)/Math.cos(o),s),l=this._zoomFromMercatorZ(a);e.bg(t,t,i,a),this._pitch=e.aC(o,e.ap(this.minPitch),e.ap(this.maxPitch)),this.angle=e.bs(r,-Math.PI,Math.PI),this._setZoom(e.aC(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ag(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices();}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,o=e.cv,r=0,n=1/0;for(;o-i>1e-6&&o>i;){const e=i+.5*(o-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);c<n&&(n=c,r=e),e<l?i=e:o=e;}return r}_terrainEnabled(){return !(!this._elevation||!this.projection.supportsTerrain&&(e.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,i){const o=Math.min(t.x,i.x),r=Math.max(t.x,i.x),n=Math.min(t.y,i.y),s=Math.max(t.y,i.y);if(n<this.horizonLineFromTop(!1))return !0;if("mercator"!==this.projection.name)return !1;const a=[new e.P(o,n),new e.P(r,s),new e.P(o,s),new e.P(r,n)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return !0;const i=this.rayIntersectionCoordinate(t);if(i.x<l||i.y<0||i.x>c||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+e.cH(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const o=e.ai(e.ax([],this._camera.position,t)),r=this._zoomFromMercatorZ(o)+i;return o-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,o],r){const n=[t,i,o,1];e.aE(n,n,r);const s=n[3]=Math.max(n[3],1e-6);return n[0]/=s,n[1]/=s,n[2]/=s,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,o=this.worldSize){const r=e.cy(t,i,this.width,this.height,1024),n=t.pixelSpaceConversion(this.center.lat,o,r);let s=.5/Math.tan(.5*this._fov)*this.height*n;return this.isOrthographic&&(s=e.am(1,s,e.cL(this.pitch>=so?1:this.pitch/so))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&e.aD(t,t,this.globeMatrix),t}getFrustum(t){return e.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const lo=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=t.transform,r=o.pitch,n=o.isLODDisabled(!1)?60:30;if(r<n-15)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const s=o._farZ-o._nearZ,a=i*o.height*1.3,l=Math.pow(2,.85*Math.max(o._zoom-t.minCutoffZoom,0)),c=1.4*o.cameraToCenterDistance*l,h=e.aj(n-15,n,r),d=(1-(_=h))*(o._farZ+a)+_*c;var _;const u=Math.min(a,d-o._nearZ);return {shouldRenderCutoff:h>0,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(d-o._nearZ)/s,(d-u-o._nearZ)/s]}}},co=2048;class ho{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class _o{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new ho(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,o){const r=e.cU.fromPoints(t.points);let n=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!r.intersectsAabb(s.aabb))continue;s.aabb.min=r.closestPoint(s.aabb.min),s.aabb.max=r.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t<o.length;t++){let r=!0;for(const n of a){const s=[n[0]*i,n[1]*i,n[2]];if(e.ah(s,s,o[t].matrix),s[0]<-1||s[0]>1||s[1]<-1||s[1]>1){r=!1;break}}if(s.lastCascade=t,n=Math.max(n,t),r)break}}return n+1}}class uo{constructor(e){this.painter=e,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new _o,this._depthMode=new Wi(e.context.gl.LEQUAL,Wi.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1;}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(t,i){const o=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!i||!i.properties)return;const r=i.properties.get("shadow-intensity"),n=i.properties.get("shadow-draw-before-layer");if(!i.shadowsEnabled()||r<=0)return;let s=-1,a=0;for(const e of o.style.order){const i=o.style._mergedLayers[e];i.hasShadowPass()&&!i.isHidden(t.zoom)&&(s=a),!n||n!==e&&n!==i.slot||(this._drawShadowAfterLayer=a>0?a-1:0),a+=1;}if(this._enabled=s>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=s);const l=o.context,c=co,h=co;if(0===this._cascades.length||co!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<2;++t){const t=l.gl,i=l.createFramebuffer(c,h,0,"texture"),o=new e.T(l,{width:c,height:h,data:null},t.DEPTH_COMPONENT16);i.depthAttachment.set(o.texture),this._cascades.push({framebuffer:i,texture:o,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.cl,scale:0});}}this.shadowDirection=fo(i);let d=0;if(t.elevation){const e=t.elevation,i=[1e4,-1e4];e.visibleDemTiles.filter(e=>e.dem).forEach(e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);}),1e4!==i[0]&&(d=(i[1]-i[0])*e.exaggeration());}const _=1.5*t.cameraToCenterDistance,u=3*_,p=new Float64Array(16);for(let i=0;i<this._cascades.length;++i){const o=this._cascades[i];let r=t.height/50,n=1;0===i?n=_:(r=_,n=u);const[s,a]=go(t,this.shadowDirection,r,n,co,d);o.scale=t.scale,o.matrix=s,o.boundingSphereRadius=a,e.b7(p,o.matrix),o.frustum=e.cl.fromInvProjectionMatrix(p,1,0,!0),o.far=n;}const f=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[f].far,this._cascades[f].far],this._uniformValues.u_shadow_intensity=r,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=.00048828125,this._uniformValues.u_shadow_map_resolution=co,this._uniformValues.u_shadowmap_0=11,this._uniformValues.u_shadowmap_1=12,this._groundShadowTiles=o.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const m=o.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(m){const i=m.getMinMaxForTile(e);i&&(t=i);}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max);}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(e){this._enabled=e;}drawShadowPass(t,i){if(!this.enabled)return;const o=this.painter,r=o.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(o.transform.getFrustum(0),o.transform.worldSize,this._cascades),r.viewport.set([0,0,co,co]);for(let n=0;n<this._numCascadesToRender;++n){o.currentShadowCascade=n,r.bindFramebuffer.set(this._cascades[n].framebuffer.framebuffer),r.clear({color:e.aq.white,depth:1});for(const e of t.order){const r=t._mergedLayers[e];if(!r.hasShadowPass()||r.isHidden(o.transform.zoom))continue;const n=t.getLayerSourceCache(r),s=n?i[n.id]:void 0;("model"===r.type||s&&s.length)&&o.renderLayer(o,n,r,s);}}o.currentShadowCascade=0;}drawGroundShadows(){if(!this.enabled)return;const e=this.painter,t=e.style,i=e.context,o=i.gl,r=t.directionalLight,n=t.ambientLight;if(!r||!n)return;const s=[],a=lo(e,e.longestCutoffRange);a.shouldRenderCutoff&&s.push("RENDER_CUTOFF"),s.push("RENDER_SHADOWS"),this.useNormalOffset&&s.push("NORMAL_OFFSET");const l=mo(t,r,n),c=new Wi(o.LEQUAL,Wi.ReadOnly,e.depthRangeFor3D),h=new Xi({func:o.EQUAL,mask:255},0,255,o.KEEP,o.KEEP,o.KEEP);for(const t of this._groundShadowTiles){const r=t.toUnwrapped(),n=e.isTileAffectedByFog(t),d=e.getOrCreateProgram("groundShadow",{defines:s,overrideFog:n});this.setupShadows(r,d),e.uploadCommonUniforms(i,d,r,null,a);const _=ro(e.transform.calculateProjMatrix(r),l);d.draw(e,o.TRIANGLES,c,h,Hi.multiply,Ji.disabled,_,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,null,e.transform.zoom,null,null);}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(t){const i=this.painter.transform,o=i.calculatePosMatrix(t,i.worldSize);return e.aD(o,this._cascades[this.painter.currentShadowCascade].matrix,o),Float32Array.from(o)}calculateShadowPassMatrixFromMatrix(t){const i=e.b8(t);return e.aD(i,this._cascades[this.painter.currentShadowCascade].matrix,t),i}setupShadows(t,i,o){if(!this.enabled)return;const r=this.painter.transform,n=this.painter.context,s=n.gl,a=this._uniformValues,l=new Float64Array(16),c=r.calculatePosMatrix(t,r.worldSize);for(let t=0;t<this._cascades.length;t++)e.aD(l,this._cascades[t].matrix,c),a[0===t?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(l),n.activeTexture.set(s.TEXTURE0+11+t),this._cascades[t].texture.bindExtraParam(s.LINEAR,s.LINEAR,s.CLAMP_TO_EDGE,s.CLAMP_TO_EDGE,s.GREATER);if(this.useNormalOffset=!!o,this.useNormalOffset){const i=e.cS(t.canonical),n=2/r.tileSize*e.an/co,s=n*this._cascades[0].boundingSphereRadius,l=n*this._cascades[this._cascades.length-1].boundingSphereRadius,c=("vector-tile"===o?1:3)*function(t){const i=e.aC((t-22)/-22,0,1);return .125*(1-i)+4*i}(r.zoom);a.u_shadow_normal_offset=[i,s*c,l*c],a.u_shadow_bias=[1e-4,.0012,.012];}else a.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(n,a);}setupShadowsFromMatrix(t,i,o=!1){if(!this.enabled)return;const r=this.painter.context,n=r.gl,s=this._uniformValues,a=new Float64Array(16);for(let i=0;i<2;i++)e.aD(a,this._cascades[i].matrix,t),s[0===i?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(a),r.activeTexture.set(n.TEXTURE0+11+i),this._cascades[i].texture.bindExtraParam(n.LINEAR,n.LINEAR,n.CLAMP_TO_EDGE,n.CLAMP_TO_EDGE,n.GREATER);this.useNormalOffset=o,o?(s.u_shadow_normal_offset=[1,3,3],s.u_shadow_bias=[6e-5,.0012,.012]):s.u_shadow_bias=[36e-5,.0012,.012],i.setShadowUniformValues(r,s);}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,i,o,r){if(r[2]>=0)return {};const n=function(t,i,o){const r=o/(1<<t.canonical.z);return new e.cU([t.canonical.x*r+t.wrap*o,t.canonical.y*r+t.wrap*o,0],[(t.canonical.x+1)*r+t.wrap*o,(t.canonical.y+1)*r+t.wrap*o,i])}(t,i,o).getCorners(),s=i/-r[2];r[0]<0?(e.cT(n[0],n[0],[r[0]*s,0,0]),e.cT(n[3],n[3],[r[0]*s,0,0])):r[0]>0&&(e.cT(n[1],n[1],[r[0]*s,0,0]),e.cT(n[2],n[2],[r[0]*s,0,0])),r[1]<0?(e.cT(n[0],n[0],[0,r[1]*s,0]),e.cT(n[1],n[1],[0,r[1]*s,0])):r[1]>0&&(e.cT(n[2],n[2],[0,r[1]*s,0]),e.cT(n[3],n[3],[0,r[1]*s,0]));const a={};return a.vertices=n,a.planes=[po(n[1],n[0],n[4]),po(n[2],n[1],n[5]),po(n[3],n[2],n[6]),po(n[0],n[3],n[7])],a}addShadowReceiver(t,i,o){this._receivers.add(t,e.cU.fromTileIdAndHeight(t,i,o));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function po(t,i,o){const r=e.ax([],o,i),n=e.ax([],t,i),s=e.bh([],r,n),a=e.ai(s);return 0===a?[0,0,1,0]:(e.bJ(s,s,1/a),[s[0],s[1],s[2],-e.bi(s,i)])}function fo(t){const i=t.properties.get("direction"),o=e.cP(i.x,i.y,i.z);o[2]=e.aC(o[2],0,75);const r=e.cR([o[0],o[1],o[2]]);return e.cQ(r.x,r.y,r.z)}function mo(t,i,o){const r="none"===i.properties.get("color-use-theme"),n=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===o.properties.get("color-use-theme"),h=o.properties.get("color"),d=o.properties.get("intensity"),_=Math.max(e.bi([0,0,1],l),0),u=[0,0,0];e.bJ(u,h.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),d);const p=[0,0,0];return e.bJ(p,n.toPremultipliedRenderColor(r?null:t.getLut(o.scope)).toArray01Linear().slice(0,3),_*s),e.cW([u[0]>0?u[0]/(u[0]+p[0]):0,u[1]>0?u[1]/(u[1]+p[1]):0,u[2]>0?u[2]/(u[2]+p[2]):0])}function go(t,i,o,r,n,s){const a=t.zoom,l=t.scale,c=t.worldSize,h=1/c,d=t.aspect,_=Math.sqrt(1+d*d)*Math.tan(.5*t.fovX),u=_*_,p=r-o,f=r+o;let m,g;u>p/f?(m=r,g=r*_):(m=.5*f*(1+u),g=.5*Math.sqrt(p*p+2*(r*r+o*o)*u+f*f*u*u));const v=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),x=[0,0,-m*h];e.ah(x,x,y);let b=g*h;const w=function(i){return i[0]/=l,i[1]/=l,i[2]=e.bU(i[2],t._center.lat),i},T=t._edgeInsets;if(!(0===T.left&&0===T.top&&0===T.right&&0===T.bottom||T.left===T.right&&T.top===T.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?v:1),n=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,o,r);n[8]=2*-t.centerOffset.x/t.width,n[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.cz(s,n,i);const l=new Float64Array(16);e.b7(l,s);const h=e.cl.fromInvProjectionMatrix(l,c,a,!0);for(const t of h.points){const i=w(t);b=Math.max(b,e.bK(e.cV([],x,i)));}}b*=n/(n-1);const E=Math.acos(i[2]),S=Math.atan2(-i[0],-i[1]),C=new oo;C.position=x,C.setPitchBearing(E,S);const I=C.getWorldToCamera(c,v),R=b*c,D=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*R),A=C.getCameraToClipOrthographic(-R,R,-R,R,D,(R+s*v)/i[2]),L=new Float64Array(16);e.aD(L,A,I);const P=e.cQ(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),O=.5*n,M=[0,0,0];e.ah(M,P,L),e.bJ(M,M,O);const z=[Math.floor(M[0]),Math.floor(M[1]),Math.floor(M[2])],F=[0,0,0];e.ax(F,M,z),e.bJ(F,F,-1/O);const B=new Float64Array(16);return e.b9(B),e.bx(B,B,F),e.aD(L,B,L),[L,R]}class vo extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={};}loadModel(t,i){return e.cX(this.requestManager.transformRequest(i,e.R.Model).url).then(o=>{const r=e.cY(o),n=new e.cZ(t,i,void 0,void 0,r);return n.computeBoundsAndApplyParent(),n}).catch(o=>{if(o&&404===o.status)return null;this.fire(new e.B(new Error(`Could not load model ${t} from ${i}: ${o.message}`)));})}load(t,i,o={forceReload:!1}){this.models[i]||(this.models[i]={});const r=Object.keys(t),n=[],s=[];for(const e of r){const r=t[e];this.hasURLBeenRequested(r)&&!o.forceReload||(this.modelByURL[r]={modelId:e,scope:i},n.push(this.loadModel(e,r)),s.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1});}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+s.length,Promise.allSettled(n).then(t=>{for(let e=0;e<t.length;e++){const{status:o}=t[e];if("rejected"===o)continue;const{value:r}=t[e];this.models[i][s[e]]||(this.models[i][s[e]]={model:null,numReferences:1}),this.models[i][s[e]].model=r;}this.numModelsLoading[i]-=s.length,this.fire(new e.C("data",{dataType:"style"}));}).catch(t=>{this.fire(new e.B(new Error(`Could not load models: ${t.message}`)));});}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return !1;return !0}hasModel(e,t,i={exactIdMatch:!1}){return !!(i.exactIdMatch?this.getModel(e,t):this.getModelByURL(this.modelUris[t][e]))}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}getModelByURL(e){if(!e)return null;const t=this.modelByURL[e];return t?this.models[t.scope][t.modelId].model:null}hasModelBeenAdded(e,t){return this.models[t]&&void 0!==this.models[t][e]}getModelURIs(e){return this.modelUris[e]||{}}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const o=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===o)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(o)){const{scope:e,modelId:t}=this.modelByURL[o];this.models[e][t].numReferences++;}else this.modelUris[i][e]=o,this.load({[e]:this.modelUris[i][e]},i);}addModelURLs(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i=this.modelUris[t];for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t]);}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0});}addModelsFromBucket(t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const o={};for(const r of t)this.hasModel(r,i,{exactIdMatch:!0})||this.hasURLBeenRequested(r)?this.models[i][r].numReferences++:this.modelUris[i][r]&&!this.hasURLBeenRequested(r)?o[r]=this.modelUris[i][r]:!this.hasURLBeenRequested(r)&&e.c_(r,!1)&&(this.modelUris[i][r]=this.requestManager.normalizeModelURL(r),o[r]=this.modelUris[i][r]);this.load(o,i);}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,o=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||o)){const o=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[o];const r=this.models[t][e].model;if(!r)return;delete this.models[t][e],r.destroy();}}destroy(){for(const e of Object.keys(this.models))for(const t of Object.keys(this.models[e])){const i=this.models[e][t].model;delete this.models[e][t],i&&i.destroy();}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={};}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context);}}const yo=e.a8.colorTheme,xo=new e.ab({data:new e.ac(yo.data)});function bo(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.o.devicePixelRatio,{left:o,top:r,width:n,height:s}=t.metadata.content_area,a=o*i,l=r*i;return [a,l,a+n*i,l+s*i]}function wo(t){if(t)return t.map(([t,i])=>[t*e.o.devicePixelRatio,i*e.o.devicePixelRatio])}class To{constructor(e,t,i){this.id=e,this.scope=t,this.sourceCache=i,this.pendingRequests=new Set,this.missingRequests=new Set;}addPendingRequest(e){this.missingRequests.has(e.name)||this.pendingRequests.has(e.name)||this.pendingRequests.add(e.name);}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;const o=this.sourceCache.getSource();if(!(o instanceof Et))return t;const r=i.map(e=>this.sourceCache.getTile(e)),n=o.getImages(r,Array.from(this.pendingRequests));for(const[i,o]of n)t.set(e.I.from({name:i,iconsetId:this.id}),o),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}class Eo{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16;}findClosestBuilding(e,t,i,o,r){if(i<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let n=null,s=Number.MAX_VALUE,a=Number.MAX_VALUE,l=!1;const c=this._previousClosestBuildingId?e[this._previousClosestBuildingId]:null;this._previousClosestBuildingId&&c&&this._isBuildingVisible(c,o,r)&&(l=!0,a=this._calculateDistance(t,c));for(const[i,a]of Object.entries(e)){if(!this._isBuildingVisible(a,o,r))continue;const e=this._calculateDistance(t,a);e<s&&(s=e,n=i);}return l&&n&&this._previousClosestBuildingId&&n!==this._previousClosestBuildingId?s>a*this._hysteresisRatio&&(n=this._previousClosestBuildingId):l&&!n&&(n=this._previousClosestBuildingId),this._previousClosestBuildingId=n,n}_calculateDistance(e,t){if(!t.center)return Number.MAX_VALUE;const i=e.lat-t.center[1],o=e.lng-t.center[0];return i*i+o*o}_isBuildingVisible(t,i,o){if(!o)return !1;for(const i of t.floorIds){const r=t.floors[i];if(!r.geometry)continue;const n=r.geometry;if("Polygon"===n.type){const t=this._convertRingToPoints(n.coordinates[0]);if(e.bw(t,o))return !0}else if("MultiPolygon"===n.type){const t=this._convertMultiPolygonToPoints(n.coordinates);if(e.d0(o,t))return !0}}return !1}_convertRingToPoints(t){return t.map(t=>new e.P(t[0],t[1]))}_convertMultiPolygonToPoints(t){return t.map(t=>0===t.length?[]:t[0].map(t=>new e.P(t[0],t[1])))}}class So extends e.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Eo,this._initialLoadDone=!1,e.aZ(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI();}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI));});}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null;}selectFloor(e){e===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=e,this._recalculateActiveFloors());}setActiveFloorsVisibility(e){this._updateActiveFloors(e),this._updateIndoorSelector();}setIndoorData(e){let t=!1;for(const[i,o]of Object.entries(e.buildings))if(this._buildings[i])for(const e of o.floorIds)this._buildings[i].floorIds.add(e),this._buildings[i].floors[e]?this._mergeFloors(this._buildings[i].floors[e],o.floors[e]):(this._buildings[i].floors[e]=o.floors[e],t=!0);else this._buildings[i]=o,t=!0;t&&this._recalculateActiveFloors();}getIndoorTileOptions(e,t){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(e,t),indoorState:this._indoorState}:null}getControlState(){const e=this._buildings,t=this._closestBuildingId,i=t&&e?e[t]:void 0;if(!i)return {selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let o=null;for(const e of i.floorIds)if(this._activeFloors&&this._activeFloors.has(e)){o=e;break}const r=Array.from(i.floorIds).map(e=>({id:e,name:i.floors[e].name,zIndex:i.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex).filter((e,t,i)=>0===t||e.zIndex!==i[t-1].zIndex);return {selectedFloorId:o,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:r}}_updateUI(){this._initialLoadDone=!0;const e=this._style.map.transform,t=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,e.center,e.zoom,e.getBounds(),this._makeViewportPolygon());if(t!==this._closestBuildingId){const e=this._closestBuildingId;this._closestBuildingId=t,this._onBuildingTransition(e,t),this._updateIndoorSelector();}}_onBuildingTransition(e,t){if(!this._indoorState)return;const i=!!t&&!e;!t&&e?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):i&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0));}_updateIndoorSelector(){this.fire(new e.C("selector-update",this.getControlState()));}_updateActiveFloors(e){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:e,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0;}_recalculateActiveFloors(){if(!this._buildings)return;const t=e.d1.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(e,t){if(e===t)return !0;if(!e||!t)return !1;if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0})(t,this._activeFloors)||(this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector());}_mergeFloors(e,t){t.geometry&&(e.geometry?("Polygon"===e.geometry.type&&(e.geometry={type:"MultiPolygon",coordinates:[e.geometry.coordinates]}),"Polygon"===t.geometry.type?e.geometry.coordinates.push(t.geometry.coordinates):"MultiPolygon"===t.geometry.type&&e.geometry.coordinates.push(...t.geometry.coordinates)):e.geometry=t.geometry);}_makeViewportPolygon(){const t=this._style.map.transform,i=t.width,o=t.height;return [t.pointLocation(new e.P(0,0)),t.pointLocation(new e.P(i,0)),t.pointLocation(new e.P(i,o)),t.pointLocation(new e.P(0,o))].map(t=>new e.P(t.lng,t.lat))}}const Co=(e,t)=>qe(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),Io=e.aJ(jt,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),Ro=e.aJ(jt,["setCenter","setZoom","setBearing","setPitch"]),Do=new Set(["background","sky","slot","custom"]),Ao={version:8,layers:[],sources:{}},Lo={duration:300,delay:0};class Po extends e.E{constructor(t,i={}){if(super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=Object.assign({},Lo),this._buildingIndex=new Nt(this),this.crossTileSymbolIndex=new Zi,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedFillExtrusionSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new $,this._hasDataDrivenEmissive=!1,this.indoorManager=new So(this),this.dispatcher=i.dispatcher?i.dispatcher:new ee(oe(),this),this.map.painter&&this.map.painter.context){const e=this.map.painter.context.maxUniformBufferBindings,t=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:e,maxUniformBlockSizeDwords:t,disableSymbolUBO:this.map.painter.context.disableSymbolUBO});}i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new re(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.d2(t._requestManager,i.localFontFamily?e.d3.all:i.localIdeographFontFamily?e.d3.ideographs:e.d3.none,i.localFontFamily||i.localIdeographFontFamily,i.useServerFontComposition),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new vo(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._fillExtrusionSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._indoorDependentLayers=i.indoorDependentLayers?i.indoorDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.d4()),this.dispatcher.broadcast("setConfig",e.d5());const o=this;this._rtlTextPluginCallback=Po.registerForPluginStateChange(t=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,i)=>{if(e.d6(t),i&&i.every(e=>e))for(const e in o._sourceCaches){const t=o._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload();}});}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i);}});}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.e(t))return t;const i=e.d7(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return `json://${e.d8(JSON.stringify(t))}`}_diffStyle(t,i,o){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,o));}catch(e){t(e,!1);}};if("string"==typeof t){const o=this.map._requestManager.normalizeStyleURL(t),n=this.map._requestManager.transformRequest(o,e.R.Style);e.m(n,(t,o)=>{t?this.fire(new e.B(t)):o&&r(o,i);});}else "object"==typeof t&&r(t,i);}loadURL(t,i={}){this.fire(new e.C("dataloading",{dataType:"style"}));const o="boolean"==typeof i.validate?i.validate:!e.e(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const r=this.importsCache.get(t);if(r)return this._load(r,o);const n=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.m(n,(i,r)=>{if(this._request=null,i)this.fire(new e.B(i));else if(r)return this.importsCache.set(t,r),this._load(r,o)});}loadJSON(t,i={}){this.fire(new e.C("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.o.frame(()=>{this._request=null,this._load(t,!1!==i.validate);});}loadEmpty(){this.fire(new e.C("dataloading",{dataType:"style"})),this._load(Ao,!1);}_loadImports(t,i,o){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const n of t){const t=this._createFragmentStyle(n),s=new Promise(e=>{t.once("style.import.load",e),t.once("error",e);}).then(()=>{this.mergeAll(),this.fire(new e.C("data",{dataType:"style"}));});if(r.push(s),this.resolvedImports.has(n.url)){t.loadEmpty();continue}const a=n.data||this.importsCache.get(n.url);a?(n.data?(t.fire(new e.C("dataloading",{dataType:"style"})),t.globalId=t._getGlobalId(a),queueMicrotask(()=>t._load(a,i))):t.loadJSON(a,{validate:i}),this._isInternalStyle(a)&&(t.globalId=null)):n.url?t.loadURL(n.url,{validate:i}):t.loadEmpty();const l={style:t,id:n.id,config:n.config};if(o){const e=this.fragments.findIndex(({id:e})=>e===o);this.fragments=this.fragments.slice(0,e).concat(l).concat(this.fragments.slice(e));}else this.fragments.push(l);}return Promise.allSettled(r)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return [...t.values()]}_createFragmentStyle(t){const i=this.scope?e.F(t.id,this.scope):t.id;let o;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(o=Object.assign({},t.config,r));const n=new Po(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:o,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return n.setEventedParent(this.map,{style:n}),n}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle();}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e=Object.assign({},Ao,{imports:[{id:"basemap",data:t,url:""}]},t.center?{center:t.center}:{},t.bearing?{bearing:t.bearing}:{},t.pitch?{pitch:t.pitch}:{},t.zoom?{zoom:t.zoom}:{},t.light?{light:t.light}:{});return this._importedAsBasemap=!0,void this._load(e,i)}if(this.updateConfig(this._config,t.schema),i&&Co(this,Le(t)))return;this._loaded=!0;for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});this.stylesheet=e.d9(t);const o=()=>{if(t.iconsets)for(const e in t.iconsets)this.addIconset(e,t.iconsets[e]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const o=Vt(this.stylesheet.layers);if(this._order=o.map(e=>e.id),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new $e(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new $e(this.stylesheet.light)),this._layers={};for(const t of o){const i=e.de(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(i.fqid),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i;const o=this.getOwnLayerSourceCache(i),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();o&&i.canCastShadows()&&r&&(o.castsShadows=!0);}if(this.glyphManager.url){const e=new Set;for(const t in this._layers){const i=this._layers[t];if("symbol"===i.type&&i.layout){const t=i.layout.get("text-font");t&&t.value&&"constant"===t.value.kind&&e.add(t.value.value.join(","));}}for(const t of e)this.glyphManager.prefetchRange(t,0);}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const r=this.stylesheet.terrain;r&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(r,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.C("data",{dataType:"style"}));const n=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(),this.fire(new e.C(n?"style.load":"style.import.load"));}).catch(t=>{this.fire(new e.B(new Error("Failed to load imports",t))),this.fire(new e.C(n?"style.load":"style.import.load"));}):(this._reloadImports(),this.fire(new e.C(n?"style.load":"style.import.load")));};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const r=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(r){const t=this._evaluateColorThemeData(r);this._loadColorTheme(t).then(()=>{o();}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),o();});}else this._styleColorTheme.lut=null,o();}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances||this.fragments.some(e=>e.style.hasAppearances())}mergeAll(){let e,t,i,o,r,n,s,a,l,c;const h={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(d=>{if(d.stylesheet){if(null!=d.light&&(e=d.light),d.stylesheet.lights)for(const e of d.stylesheet.lights)"ambient"===e.type&&null!=d.ambientLight&&(t=d.ambientLight),"directional"===e.type&&null!=d.directionalLight&&(i=d.directionalLight);o=this._prioritizeTerrain(o,d.terrain,d.stylesheet.terrain),d.stylesheet.fog&&null!=d.fog&&(r=d.fog),d.stylesheet.snow&&null!=d.snow&&(n=d.snow),d.stylesheet.rain&&null!=d.rain&&(s=d.rain),null!=d.stylesheet.camera&&(c=d.stylesheet.camera),null!=d.stylesheet.projection&&(a=d.stylesheet.projection),null!=d.stylesheet.transition&&(l=d.stylesheet.transition),h[d.scope]=d._styleColorTheme;}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=r,this.snow=n,this.rain=s,this._styleColorThemeForScope=h,null===o?delete this.terrain:this.terrain=o,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},Lo,l),this.mergeSources(),this.mergeLayers(),this.mergeIndoor();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const o=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:o?e:null:null!=t&&(!e||o||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain);}),null===e?delete this.terrain:this.terrain=e;}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection);}),this.projection=e||{name:"mercator"};}mergeSources(){const t={},i={},o={},r={};this.forEachFragmentStyle(n=>{for(const i in n._sourceCaches){const o=e.F(i,n.scope);t[o]=n._sourceCaches[i];}for(const t in n._otherSourceCaches){const o=e.F(t,n.scope);i[o]=n._otherSourceCaches[t];}for(const t in n._symbolSourceCaches){const i=e.F(t,n.scope);o[i]=n._symbolSourceCaches[t];}for(const t in n._fillExtrusionSourceCaches){const i=e.F(t,n.scope);r[i]=n._fillExtrusionSourceCaches[t];}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=o,this._mergedFillExtrusionSourceCaches=r;}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const o=i,r=e.F(o.sourceId,t.scope);this._mergedIndoor[r]=new Set(o.sourceLayers||[]);}});}mergeLayers(){const t={},i=[],o={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(o=>{for(const r of o._order){const n=o._layers[r];if("slot"===n.type){const i=e.da(r);if(t[i])continue;t[i]=[];}n.slot&&t[n.slot]?t[n.slot].push(n):i.push(n);}}),this._mergedOrder=[];let r=-1;const n=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.da(s.id);t[i]&&n(t[i]),this._mergedSlots.push(i);}else {const t=e.F(s.id,s.scope);this._mergedOrder.push(t),o[t]=s,s.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0);}};if(n(i),this._has3DLayers){const e={};for(let t=0;t<this._mergedOrder.length;++t){const i=this._mergedOrder[t];e[i]=t===r?1:t<r?o[i].hasOcclusionOpacityProperties?2:0:4;}this._mergedOrder.sort((t,i)=>e[t]-e[i]);}this._mergedLayers=o,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,o){const r=Object.assign({},i);for(const e of Object.keys(yo))void 0===r[e]&&(r[e]=yo[e].default);const n=new e.aa(xo,t,new Map(o));return n.setTransitionOrValue(r,o),n.untransitioned().possiblyEvaluate(new e.ae(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((o,r)=>{const n="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void o();let s=t;s.startsWith(n)||(s=n+s);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=s,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"));},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void o();this._styleColorTheme.lutLoading=!1;const{width:n,height:s,data:c}=e.o.getImageData(l);if(s>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(n!==s*s)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.q({width:n,height:s},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const h=this.imageManager.getImage(a,this.scope);h?(this._styleColorTheme.lut={image:h.data,data:t},o()):r(new Error("Missing LUT image."));};})}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection();}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0));}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection));}_loadSprite(t){this._spriteRequest=function(t,i,o){let r,n,s;const a=e.o.devicePixelRatio>1?"@2x":"";let l=e.m(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),(e,t)=>{l=null,s||(s=e,r=t,h());}),c=e.n(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),(e,t)=>{c=null,s||(s=e,n=t,h());});function h(){if(s)o(s);else if(r&&n){const t=e.o.getImageData(n),i={};for(const o in r){const{width:n,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:d,stretchY:_,content:u}=r[o],p=new e.q({width:n,height:s});e.q.copy(t,p,{x:a,y:l},{x:0,y:0},{width:n,height:s},null),i[o]={data:p,pixelRatio:void 0!==h?h:1,sdf:void 0!==c&&c,stretchX:d,stretchY:_,content:u,usvg:!1,version:0};}o(null,i);}}return {cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null);}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.B(t));else if(i){const t=new Map;for(const o in i)t.set(e.I.from(o),i[o]);this.addImages(t);}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.C("data",{dataType:"style"}));});}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const o=this.getOwnSourceCache(i.source);if(!o)return void this.fire(new e.B(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const r=o.getSource();if("raster-array"!==r.type)return void this.fire(new e.B(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));r.partial=!1;const n=new To(t,this.scope,o);this.imageManager.addImageProvider(n,this.scope);}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope);}_loadIconset(t){if(!e.e(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var o,r;this._spriteRequest=(r=(o,r)=>{if(this._spriteRequest=null,o)i?this._loadSprite(t):this.fire(new e.B(o));else if(r){const t=new Map;for(const i in r)t.set(e.I.from(i),r[i]);this.addImages(t);}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.C("data",{dataType:"style"}));},e.b1((o=this.map._requestManager).transformRequest(o.normalizeIconsetURL(t),e.R.Iconset),(t,i)=>{if(t)return void r(t);const o={},n=e.c$(new e.a$(i));for(const t of n.icons){const i={version:1,pixelRatio:e.o.devicePixelRatio,content:bo(t),stretchX:t.metadata?wo(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?wo(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};o[t.name]=i;}r(null,o);}));}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const o=t.sourceLayer;o&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(o))&&this.fire(new e.B(new Error(`Source layer "${o}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return !1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return !1;if(!this.imageManager.isLoaded())return !1;if(this.imageManager.hasPatternsInFlight())return !1;if(!this.modelManager.isLoaded())return !1;if(this._styleColorTheme.lutLoading)return !1;for(const{style:e}of this.fragments)if(!e.loaded())return !1;return !0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e})}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize());}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize());}return t}hasLightTransitions(){return !(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return !!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return !!this.snow&&this.snow.hasTransition()}hasRainTransition(){return !!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;if(this.hasSnowTransition())return !0;if(this.hasRainTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_updateDataDrivenEmissiveStrength(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];if(t._transitionablePaint&&t._transitionablePaint._values){const e=t._transitionablePaint._values["line-emissive-strength"];if(e&&e.value&&e.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1;}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(e){return e?this.order:this._mergedOrder}isLayerDraped(e){return !!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.B(new Error(`The layer '${t}' does not exist in the map's style.`)));}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.B(new Error(`The source '${t}' does not exist in the map's style.`)));}precompilePrograms(e,t){const i=this.map.painter;if(i)for(let o=e.minzoom||0;o<(e.maxzoom||25.5);o++){const o=e.getProgramIds();if(o)for(const r of o){const o=e.getDefaultProgramParams(r,t.zoom,this._styleColorTheme.lut);o&&(i.style=this,this.fog&&(i._fogVisible=!0,o.overrideFog=!0,i.getOrCreateProgram(r,o)),i._fogVisible=!1,o.overrideFog=!1,i.getOrCreateProgram(r,o),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(o.overrideRtt=!0,i.getOrCreateProgram(r,o)));}}}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const o=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:o}=e[t];(i||o)&&(this._updateWorkerLayers(t,i,o),r=!0);}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset();}const n={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];n[e]=t.used,t.used=!1,t.tileCoverLift=0;}const s={};for(const i of this._mergedOrder){const o=this._mergedLayers[i];if(("none"!==o.visibility||o.hasTransition())&&o.recalculate(t,this._availableImages),!o.isHidden(t.zoom)){const e=this.getLayerSourceCache(o);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,o.tileCoverLift()));}if("fill-extrusion"===o.type){const t=e.F(o.source,o.scope);if(t in this._mergedFillExtrusionSourceCaches){const e=o.layout&&o.layout.get("source-max-zoom");if(null!=e){const i=s[t];s[t]=null==i?e:Math.min(i,e);}}}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(o,t);}):this.precompilePrograms(o,t));}this._shouldPrecompile&&(this._precompileDone=!0);for(const e in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[e].setMaxzoomOverride(null!=s[e]?s[e]:null);this.terrain&&r&&this.mergeLayers();const a=this.imageManager.getPendingImageProviders();for(const e of a)e.sourceCache.used=!0;for(const t in n){const i=this._mergedSourceCaches[t];n[t]!==i.used&&i.getSource().fire(new e.C("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}));}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),o&&this.fire(new e.C("data",{dataType:"style"}));}updateImageProviders(){const e=this.imageManager.getPendingImageProviders();for(const t of e){const e=t.resolvePendingRequests(),i=this.getFragmentStyle(t.scope);i&&i.addImages(e);}}_updateTilesForChangedImages(){const e={};for(const t in this._mergedSourceCaches){const i=this._mergedSourceCaches[t].getSource().scope;e[i]=e[i]||this._changes.getUpdatedImages(i),0!==e[i].length&&this._mergedSourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e[i]);}for(const t in e)this._changes.resetUpdatedImages(t);}_updateWorkerLayers(e,t,i){const o=this.getFragmentStyle(e);o&&this.dispatcher.broadcast("updateLayers",{layers:t?o._serializeLayers(t):[],scope:e,removedIds:i||[],options:o.options});}setState(t,i){if(this._checkLoaded(),Co(this,Le(t)))return !1;(t=e.d9(t)).layers=Vt(t.layers);const o=function(t,i){if(!t)return [{command:jt.setStyle,args:[i]}];let o=[];try{if(!e.b6(t.version,i.version))return [{command:jt.setStyle,args:[i]}];if(e.b6(t.center,i.center)||o.push({command:jt.setCenter,args:[i.center]}),e.b6(t.zoom,i.zoom)||o.push({command:jt.setZoom,args:[i.zoom]}),e.b6(t.bearing,i.bearing)||o.push({command:jt.setBearing,args:[i.bearing]}),e.b6(t.pitch,i.pitch)||o.push({command:jt.setPitch,args:[i.pitch]}),e.b6(t.sprite,i.sprite)||o.push({command:jt.setSprite,args:[i.sprite]}),e.b6(t.glyphs,i.glyphs)||o.push({command:jt.setGlyphs,args:[i.glyphs]}),e.b6(t.imports,i.imports)||function(t=[],i=[],o){i=i||[];const r=(t=t||[]).map($t),n=i.map($t),s=t.reduce(Xt,{}),a=i.reduce(Xt,{}),l=r.slice();let c,h,d,_;for(c=0,h=0;c<r.length;c++)d=r[c],a.hasOwnProperty(d)?h++:(o.push({command:jt.removeImport,args:[d]}),l.splice(l.indexOf(d,h),1));for(c=0,h=0;c<n.length;c++)d=n[n.length-1-c],l[l.length-1-c]!==d&&(s.hasOwnProperty(d)?(o.push({command:jt.removeImport,args:[d]}),l.splice(l.lastIndexOf(d,l.length-h),1)):h++,_=l[l.length-c],o.push({command:jt.addImport,args:[a[d],_]}),l.splice(l.length-c,0,d));for(const t of i){const i=s[t.id];i&&(delete i.data,e.b6(i,t)||o.push({command:jt.updateImport,args:[t.id,t]}));}}(t.imports,i.imports,o),e.b6(t.transition,i.transition)||o.push({command:jt.setTransition,args:[i.transition]}),e.b6(t.light,i.light)||o.push({command:jt.setLight,args:[i.light]}),e.b6(t.fog,i.fog)||o.push({command:jt.setFog,args:[i.fog]}),e.b6(t.snow,i.snow)||o.push({command:jt.setSnow,args:[i.snow]}),e.b6(t.rain,i.rain)||o.push({command:jt.setRain,args:[i.rain]}),e.b6(t.projection,i.projection)||o.push({command:jt.setProjection,args:[i.projection]}),e.b6(t.lights,i.lights)||o.push({command:jt.setLights,args:[i.lights]}),e.b6(t.camera,i.camera)||o.push({command:jt.setCamera,args:[i.camera]}),e.b6(t.iconsets,i.iconsets)||function(t,i,o){let r;for(r in i=i||{},t=t||{})t.hasOwnProperty(r)&&(i.hasOwnProperty(r)||o.push({command:jt.removeIconset,args:[r]}));for(r in i){if(!i.hasOwnProperty(r))continue;const n=i[r];t.hasOwnProperty(r)?e.b6(t[r],n)||(o.push({command:jt.removeIconset,args:[r]}),o.push({command:jt.addIconset,args:[r,n]})):o.push({command:jt.addIconset,args:[r,n]});}}(t.iconsets,i.iconsets,o),!e.b6(t["color-theme"],i["color-theme"]))return [{command:jt.setStyle,args:[i]}];const r={},n=[];!function(t,i,o,r){let n;for(n in i=i||{},t=t||{})t.hasOwnProperty(n)&&(i.hasOwnProperty(n)||Zt(n,o,r));for(n in i){if(!i.hasOwnProperty(n))continue;const s=i[n];t.hasOwnProperty(n)?e.b6(t[n],s)||("geojson"===t[n].type&&"geojson"===s.type&&Ht(t,i,n)?o.push({command:jt.setGeoJSONSourceData,args:[n,s.data]}):qt(n,i,o,r)):Gt(n,i,o);}}(t.sources,i.sources,n,r);const s=[];t.layers&&t.layers.forEach(e=>{e.source&&r[e.source]?o.push({command:jt.removeLayer,args:[e.id]}):s.push(e);});let a=t.terrain;a&&r[a.source]&&(o.push({command:jt.setTerrain,args:[void 0]}),a=void 0),o=o.concat(n),e.b6(a,i.terrain)||o.push({command:jt.setTerrain,args:[i.terrain]}),function(t,i,o){i=i||[];const r=(t=t||[]).map($t),n=i.map($t),s=t.reduce(Xt,{}),a=i.reduce(Xt,{}),l=r.slice(),c=Object.create(null);let h,d,_,u,p,f,m;for(h=0,d=0;h<r.length;h++)_=r[h],a.hasOwnProperty(_)?d++:(o.push({command:jt.removeLayer,args:[_]}),l.splice(l.indexOf(_,d),1));for(h=0,d=0;h<n.length;h++)_=n[n.length-1-h],l[l.length-1-h]!==_&&(s.hasOwnProperty(_)?(o.push({command:jt.removeLayer,args:[_]}),l.splice(l.lastIndexOf(_,l.length-d),1)):d++,f=l[l.length-h],o.push({command:jt.addLayer,args:[a[_],f]}),l.splice(l.length-h,0,_),c[_]=!0);for(h=0;h<n.length;h++)if(_=n[h],u=s[_],p=a[_],!c[_]&&!e.b6(u,p))if(e.b6(u.source,p.source)&&e.b6(u["source-layer"],p["source-layer"])&&e.b6(u.type,p.type)){for(m in Wt(u.layout,p.layout,o,_,null,jt.setLayoutProperty),Wt(u.paint,p.paint,o,_,null,jt.setPaintProperty),e.b6(u.slot,p.slot)||o.push({command:jt.setSlot,args:[_,p.slot]}),e.b6(u.filter,p.filter)||o.push({command:jt.setFilter,args:[_,p.filter]}),e.b6(u.minzoom,p.minzoom)&&e.b6(u.maxzoom,p.maxzoom)||o.push({command:jt.setLayerZoomRange,args:[_,p.minzoom,p.maxzoom]}),u)u.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&"slot"!==m&&(0===m.indexOf("paint.")?Wt(u[m],p[m],o,_,m.slice(6),jt.setPaintProperty):e.b6(u[m],p[m])||o.push({command:jt.setLayerProperty,args:[_,m,p[m]]}));for(m in p)p.hasOwnProperty(m)&&!u.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&"slot"!==m&&(0===m.indexOf("paint.")?Wt(u[m],p[m],o,_,m.slice(6),jt.setPaintProperty):e.b6(u[m],p[m])||o.push({command:jt.setLayerProperty,args:[_,m,p[m]]}));}else o.push({command:jt.removeLayer,args:[_]}),f=l[l.lastIndexOf(_)+1],o.push({command:jt.addLayer,args:[p,f]});}(s,i.layers,o);}catch(e){console.warn("Unable to compute style diff:",e),o=[{command:jt.setStyle,args:[i]}];}return o}(this.serialize(),t).filter(e=>!(e.command in Ro));if(0===o.length)return !1;const r=o.filter(e=>!(e.command in Io));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);const n=[];return o.forEach(e=>{n.push(this[e.command](...e.args));}),i&&Promise.all(n).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages});}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels});}addImages(t){if(0===t.size)return this;for(const[i,o]of t.entries()){if(this.getImage(i))return this.fire(new e.B(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,o),this._changes.updateImage(i,this.scope);}return this._updateWorkerImages(),this.fire(new e.C("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.B(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.C("data",{dataType:"style"})),this)}updateImage(t,i,o=!1){this.imageManager.updateImage(t,this.scope,i),o&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.C("data",{dataType:"style"})));}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.C("data",{dataType:"style"})),this):this.fire(new e.B(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new e.C("data",{dataType:"style"})),this}addModel(t,i,o={}){return this._checkLoaded(),this._validate(Ge,`models.${t}`,i,null,o)||(this.modelManager.addModel(t,i,this.getActualScope()),this.fire(new e.C("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new e.C("data",{dataType:"style"})),this):this.fire(new e.B(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,i,o={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(Pe,`sources.${t}`,i,null,o))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=Ct(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const n=t=>{const i=(t===e.b4.Symbol?"symbol:":t===e.b4.FillExtrusion?"fill-extrusion:":"other:")+r.id,o=e.F(i,this.scope),n=this._sourceCaches[i]=new Ft(o,r,t);t===e.b4.Symbol?this._symbolSourceCaches[r.id]=n:t===e.b4.FillExtrusion?this._fillExtrusionSourceCaches[r.id]=n:this._otherSourceCaches[r.id]=n,n.onAdd(this.map);};n(e.b4.Other),"vector"!==i.type&&"geojson"!==i.type||(n(e.b4.Symbol),"vector"===i.type&&n(e.b4.FillExtrusion)),r.onAdd&&r.onAdd(this.map),o.isInitialLoad||(this.mergeSources(),this._changes.setDirty());}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.B(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.B(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const i=Object.entries(this.stylesheet.iconsets).find(([e,i])=>"source"===i.type&&i.source===t);if(i)return this.fire(new e.B(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const o=this.getOwnSourceCaches(t);for(const t of o){const i=e.da(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.C("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty();}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource());}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}setLights(t){if(this._checkLoaded(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const e of t){if(this._validate(Me,"lights",e))return;switch(e.type){case "ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i);}else this.ambientLight=new ct(e,ht(),this.scope,this.options);break;case "directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i);}else this.directionalLight=new ct(e,_t(),this.scope,this.options);}}const o=Object.assign(i,{worldview:this.map.getWorldview()}),r=new e.ae(this.z||0,o);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness);}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const o=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),n=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.cP(s.x,s.y,s.z)[2]/90,l=o(r)*n*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),h=i.properties.get("intensity"),d=o(c)*h;return Number(((l+d)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return !!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(null==t||""===t&&this.isRootStyle())return this;if(e.db(t)){const i=e.dc(t),o=this.fragments.find(({id:e})=>e===i);if(!o)return;const r=e.da(t);return o.style.getFragmentStyle(r)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const o in t){const r={},n=this._featuresetSelectors[o]=[];for(const s of t[o].selectors){if(s.featureNamespace){const t=this.getOwnLayer(s.layer);if(!t){e.w(`Layer is undefined for selector: ${s.layer}`);continue}const n=i(t.source,t.sourceLayer);if(n in r&&r[n]!==s.featureNamespace){e.w(`"featureNamespace ${s.featureNamespace} of featureset ${o}'s selector is not associated to the same source, skip this selector`);continue}r[n]=s.featureNamespace;}let t;if(s.properties)for(const i in s.properties){const o=e.X(s.properties[i]);"success"===o.result&&(t=t||{},t[i]=o.value);}n.push({layerId:s.layer,namespace:s.featureNamespace,properties:t,uniqueFeatureID:s._uniqueFeatureID});}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return [];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const o=this.getFragmentStyle(i),r=o.stylesheet.featuresets;if(!r||!r[t])return this.fire(new e.B(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const n=[];for(const e of r[t].selectors){const t=o.getOwnLayer(e.layer);t&&n.push(t);}return n}getConfigProperty(t,i){const o=this.getFragmentStyle(t);if(!o)return null;const r=e.F(i,o.scope),n=o.options.get(r),s=n?n.value||n.default:null;return s?s.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,i){const o=e.F(t,i);return this._mergedIndoor[o]}setIndoorData(e,t){this.indoorManager.setIndoorData(t);}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint();}setConfigProperty(t,i,o){const r=this.getFragmentStyle(t);if(!r)return;const n=r.stylesheet.schema;if(!n||!n[i])return;const s=e.X(o);if("success"!==s.result)return void Co(this,s.value);const a=s.value.expression,l=e.F(i,r.scope),c=r.options.get(l);if(!c)return;let h;const{minValue:d,maxValue:_,stepValue:u,type:p,values:f}=n[i],m=e.X(n[i].default);"success"===m.result&&(h=m.value.expression),h?(this.options.set(l,Object.assign({},c,{value:a,default:h,minValue:d,maxValue:_,stepValue:u,type:p,values:f})),this.updateConfigDependencies(i)):this.fire(new e.B(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)));}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const o=i.stylesheet.schema;if(!o)return null;const r={};for(const t in o){const o=e.F(t,i.scope),n=i.options.get(o),s=n?n.value||n.default:null;r[t]=s?s.serialize():null;}return r}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies());}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies());}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const o in i){let r,n;const s=e.X(i[o].default);if("success"===s.result&&(r=s.value.expression),t&&void 0!==t[o]){const i=e.X(t[o]);"success"===i.result&&(n=i.value.expression);}const{minValue:a,maxValue:l,stepValue:c,type:h,values:d}=i[o];if(r){const t=e.F(o,this.scope);this.options.set(t,{default:r,value:n,minValue:a,maxValue:l,stepValue:c,type:h,values:d});}else this.fire(new e.B(new Error(`No schema defined for config option "${o}".`)));}else this.fire(new e.B(new Error("Attempting to set config for a style without schema.")));}_updateLayers(e,t=()=>!0){for(const i of e){const e=this.getLayer(i);e&&t(e)&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty());}}updateConfigDependencies(e){this._updateLayers(this._configDependentLayers,t=>!e||t.expressionDependencies.configDependencies.has(e)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t);}}),this._changes.setDirty();}addLayer(t,i,o={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.B(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===t.type){if(Co(this,e.dd(t)))return;n=e.de(t,this.scope,this._styleColorTheme.lut,this.options);}else {if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.d9(t),t=Object.assign(t,{source:r})),this._validate(Ne,`layers.${r}`,t,{arrayIndex:-1},o))return;n=e.de(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}});}const s=e.F(n.source,n.scope);0!==n.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(s),n.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(s);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.B(new Error(`Layer with id "${i}" does not exist on this map.`)));n.slot&&n.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):a=t;}this._order.splice(a,0,r),this._handleLayerOrderChange(),this._layers[r]=n;const l=this.getOwnLayerSourceCache(n),c=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&n.canCastShadows()&&c&&(l.castsShadows=!0);const h=this._changes.getRemovedLayer(n);if(h&&n.source&&l&&"custom"!==n.type){this._changes.discardLayerRemoval(n);const t=e.F(n.source,n.scope);h.type!==n.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),l.pause());}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),n.scope=this.scope,this.mergeLayers();}moveLayer(t,i){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let n=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.B(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot&&o.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):n=t;}this._order.splice(n,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers();}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const o=this.getOwnLayerSourceCache(t);if(o&&o.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}o.castsShadows=e;}t.onRemove&&t.onRemove(this.map),this.mergeLayers();}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return !0;return !1}setLayerZoomRange(e,t,i){this._checkLoaded();const o=this._checkLayer(e);o&&(o.minzoom===t&&o.maxzoom===i||(null!=t&&(o.minzoom=t),null!=i&&(o.maxzoom=i),this._updateLayer(o)));}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i));}setFilter(t,i,o={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.b6(r.filter,i))return null==i?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Ue,`layers.${r.id}.filter`,i,{layerType:r.type},o)||(r.filter=e.d9(i),this._updateLayer(r)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.d9(i.filter)}setLayoutProperty(t,i,o,r={}){this._checkLoaded();const n=this._checkLayer(t);if(n&&!e.b6(n.getLayoutProperty(i),o)){if(null!=o&&(!r||!1!==r.validate)&&Co(n,je.call(Le,{key:`layers.${t}.layout.${i}`,layerType:n.type,objectKey:i,value:o,styleSpec:e.a8,style:{glyphs:!0,sprite:!0}})))return;n.setLayoutProperty(i,o),0!==n.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(n.fqid),n.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(n.fqid),this._updateLayer(n);}}setLayerProperty(e,t,i,o={}){this._checkLoaded();const r=this._checkLayer(e);r&&("appearances"===t?(r.setAppearances(i),this._updateLayer(r)):r.isPaintProperty(t)?this.setPaintProperty(e,t,i,o):this.setLayoutProperty(e,t,i,o));}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,o,r={}){this._checkLoaded();const n=this._checkLayer(t);if(!n)return;if(e.b6(n.getPaintProperty(i),o))return;if(null!=o&&(!r||!1!==r.validate)&&Co(n,Ve.call(Le,{key:`layers.${t}.paint.${i}`,layerType:n.type,objectKey:i,value:o,styleSpec:e.a8})))return;const s=n.setPaintProperty(i,o);0!==n.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(n.fqid),n.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(n.fqid),s&&this._updateLayer(n),this._changes.updatePaintProperties(n);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:o}=t.target,r=this.getFragmentStyle(o),n=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:o}of n)r.setFeatureState({id:t.id,source:e,sourceLayer:o},i);}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);this.setFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer},i);}return}const o=t.source,r=t.sourceLayer,n=this._checkSource(o);if(!n)return;const s=n.type;if("geojson"===s&&r)return void this.fire(new e.B(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new e.B(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.B(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.setFeatureState(r,t.id,i);}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:o}=t.target,r=this.getFragmentStyle(o),n=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:o}of n)r.removeFeatureState({id:t.id,source:e,sourceLayer:o},i);}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);this.removeFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer},i);}return}const o=t.source,r=this._checkSource(o);if(!r)return;const n=r.type,s="vector"===n?t.sourceLayer:void 0;if("vector"===n&&!s)return void this.fire(new e.B(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.B(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.removeFeatureState(s,t.id,i);}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:o,importId:r}=t.target,n=this.getFragmentStyle(r),s=n.getFeaturesetLayers(o);for(const{source:o,sourceLayer:r}of s){const s=n.getFeatureState({id:t.id,source:o,sourceLayer:r});if(s&&!i)i=s;else if(!e.b6(i,s))return void this.fire(new e.B(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);i=this.getFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer});}return i}const i=t.source,o=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||o)return void 0===t.id&&this.fire(new e.B(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(o,t.id);this.fire(new e.B(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(e){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(e){e!==this._worldview&&(this._worldview=e,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources());}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.df({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],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:this._serializeSources(),layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t);}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),o=e.F(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[o]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(o,"reload"),i.pause()),t.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,o={},r=[];for(let n=i.length-1;n>=0;n--){const s=i[n];if(t(s)){o[s]=n;for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t);}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const n=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&o[t.layer.id]<s)break;n.push(t),r.pop();}else for(const t of e){const e=t[a];if(e)for(const t of e)n.push(t.feature);}}return n}queryRasterValue(t,i,o){const r=this.getOwnSource(t);return r?"raster-array"!==r.type?(this.fire(new e.B(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):r.queryRasterArrayValue(i,o):(this.fire(new e.B(new Error(`Source with id "${t}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(t,i,o){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Ue,"queryRenderedFeatures.filter",i.filter,null,i),r=e.dg(i.filter));const n={},s=e=>{if(Do.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=n[t.id]=n[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:r});};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.B(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.B(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s(i);}}else for(const e in this._layers)s(this._layers[e]);const a=this._queryRenderedFeatures(t,n,o),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.dh(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,o){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Ue,"queryRenderedFeatures.filter",i.filter,null,i),r=e.dg(i.filter));const n="mock",s=[];if(i&&i.target)s.push(Object.assign({},i,{targetId:n,filter:r}));else {const e=this.getFeaturesetDescriptors();for(const t of e)s.push({targetId:n,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)s.push({targetId:n,filter:r,target:e});}}const a=this.queryRenderedTargets(t,s,o),l=[],c=new Set;for(const t of a)for(const i of t.variants[n])Rt(i,t,c)||l.push(new e.di(t,i));return l}queryRenderedTargets(t,i,o){const r={},n=(e,t,i,o)=>{const n=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(n.layers[e.fqid]=n.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(n.has3DLayers=!0),!o)return i.uniqueFeatureID=!1,void n.layers[e.fqid].targets.push(i);n.layers[e.fqid].targets.push(Object.assign({},i,{namespace:o.namespace,properties:o.properties,uniqueFeatureID:o.uniqueFeatureID}));};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:o}=t.target,r=this.getFragmentStyle(o);if(!r||!r._featuresetSelectors)continue;const s=r._featuresetSelectors[i];if(!s){this.fire(new e.B(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of s){const i=r.getOwnLayer(e.layerId);i&&!Do.has(i.type)&&n(i,r.getOwnLayerSourceCache(i),t,e);}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||Do.has(i.type))continue;n(i,this.getLayerSourceCache(i),t);}const s=this._queryRenderedFeatures(t,r,o);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(t,i,o){const r=[],n=!!this.map._showQueryGeometry,s=ut.createFromScreenPoints(t,o);for(const e in i){const t=Dt(s,i[e],this._availableImages,o,n,this.getActualScope());Object.keys(t).length&&r.push(t);}if(this.placement)for(const t in i){if(i[t].sourceCache._renderSourceType!==e.b4.Symbol)continue;const o=At(s.screenGeometry,i[t],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(o).length&&r.push(o);}return r}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Ue,"querySourceFeatures.filter",i,null,t);let o=[];const r=this.getOwnSourceCaches(e);for(const e of r)o=o.concat(Lt(e,t));return o}addSourceType(e,t,i){return Po.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Po.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,o={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const i in t)if(!e.b6(t[i],r[i])){n=!0;break}if(!n)return;const s=this._getTransitionParameters();this.light.setLight(t,i,o),this.light.updateTransitions(s);}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0);}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."));}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let o=t;const r=!("source"in t)||null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("source"in o&&"object"==typeof o.source){const t="terrain-dem-src";this.addSource(t,o.source),o=e.d9(o),o=Object.assign(o,{source:t});}const t=Object.assign({},o),i={};if(this.terrain&&r){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize());}if(this._validate(ze,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!o)return;this._createTerrain(o,i),this.fire(new e.C("data",{dataType:"style"}));}else {const i=this.terrain,r=i.get();for(const t of Object.keys(e.a8.terrain))!o.hasOwnProperty(t)&&e.a8.terrain[t].default&&(o[t]=e.a8.terrain[t].default);for(const o in t)if(!e.b6(t[o],r[o])){i.set(t,this.options),this.stylesheet.terrain=t;const o=this._getTransitionParameters({duration:0});i.updateTransitions(o),this.fire(new e.C("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new ot(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createSnow(e){const t=this.snow=new at(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createRain(e){const t=this.rain=new lt(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity();});}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!e.b6(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createFog(t);this._markersNeedUpdate=!0;}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.b6(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createSnow(t);this._markersNeedUpdate=!0;}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.b6(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createRain(t);this._markersNeedUpdate=!0;}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles();},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const o=this._evaluateColorThemeData(i);this._loadColorTheme(o).then(()=>{this.fire(new e.C("colorthemeset")),t();}).catch(t=>{e.w(`Couldn't set color theme: ${t}`);});}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme();}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme());}_getTransitionParameters(t){return {now:e.o.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i of this._mergedOrder)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new Ye(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const o=this._getTransitionParameters({duration:0});i.updateTransitions(o);}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t);}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t);}}_validate(t,i,o,r,n={}){if(n&&!1===n.validate)return !1;const s=Object.assign({},this.serialize());return Co(this,t.call(Le,Object.assign({key:i,style:s,value:o,styleSpec:e.a8},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.dj.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}clearLayers(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];t._clear&&t._clear();}}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}reloadSources(){for(const e of this.getSources())e.reload&&e.reload();}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope);});}updateSources(e){let t;this.directionalLight&&(t=fo(this.directionalLight));const i=new Set,o=new Set,r=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];"building"===t.type?i.add(t.source):"raster"===t.type&&t.paint&&"ground"===t.paint.get("raster-elevation-reference")&&r.add(t.source),t.hasElevation()&&!o.has(t.source)&&o.add(t.source);}for(const n in this._mergedSourceCaches){const s=this._mergedSourceCaches[n],a=o.has(s._source.id);s._isRasterElevatedOverTerrain=r.has(s._source.id),i.has(s._source.id)&&(s._source.reparseOverscaled=!1),s.update(e,void 0,void 0,t,a);}}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new e.C("neworder"));}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Ni),this.pauseablePlacement.requestFullPlacement();}_setLabelPlacementStale(){this.placement&&this.placement.setStale();}_updatePlacement(t,i,o,r,n){this.pauseablePlacement||(this.pauseablePlacement=new Ni);let s=!1,a=!1;const l={},c={};for(const i of this._mergedOrder){const o=this._mergedLayers[i];if("symbol"!==o.type)continue;const r=e.F(o.source,o.scope);let n=l[r];if(!n){const e=this.getLayerSourceCache(o);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));c[r]=t.slice(),n=l[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1));}const a=this.crossTileSymbolIndex.addLayer(o,n,t.center.lng,t.projection);s=s||a;}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const h=Boolean(this.placement&&!t.equals(this.placement.transform)),d=Boolean(this.placement&&(0!==this.placement.lastReplacementSourceUpdateTime&&!n||this.placement.lastReplacementSourceUpdateTime!==n.updateTime)),_=h||d||s,u=(_||this.pauseablePlacement.isStale())&&0===o,p=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.o.now(),t.zoom)&&0!==o;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||u||p)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,i,o,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){const e=this.map.painter.maxFrontCutoffRawStart;if(e>0){const i=180*t.pitch/Math.PI;if(i>=15){const t=Math.min(1,Math.max(0,(i-15)/5)),o=t*t*(3-2*t);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-o)+e*o;}}}if(this.pauseablePlacement.isDone()?_&&0!==o&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,l,c,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.o.now()),a=!0),s&&this.pauseablePlacement.setStale()),a||s){this._buildingIndex.onNewFrame(t.zoom);for(let t=0;t<this._mergedOrder.length;t++){const i=this._mergedLayers[this._mergedOrder[t]];if("symbol"!==i.type)continue;if("none"===i.visibility)continue;const o=this.isLayerClipped(i);this.placement.updateLayerOpacities(i,l[e.F(i.source,i.scope)],t,o?n:null);}}return !this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(e.o.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles();}addImport(t,i){this._checkLoaded();const o=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==o.findIndex(({id:e})=>e===t.id))return void this.fire(new e.B(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return o.push(t),this._loadImports([t],!0);const r=o.findIndex(({id:e})=>e===i);return -1===r&&this.fire(new e.B(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=o.slice(0,r).concat(t).concat(o.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const o=this.stylesheet.imports||[],r=this.getImportIndex(t);return -1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==o[r].url&&this.setImportUrl(t,i.url),e.b6(i.config,o[r].config)||this.setImportConfig(t,i.config,i.data.schema),e.b6(i.data,o[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const o=this.getImportIndex(e);if(-1===o)return this;const r=this.getImportIndex(t);if(-1===r)return this;const n=i[o],s=this.fragments[o];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,r).concat(n).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(s).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],o=this.getImportIndex(e);if(-1===o)return this;i[o].url=t;const r=this.fragments[o];return r.style=this._createFragmentStyle(i[o]),r.style.on("style.import.load",()=>this.mergeAll()),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete o[i].data,this.setImportUrl(e,o[i].url))}setImportConfig(e,t,i){this._checkLoaded();const o=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===o)return this;t?r[o].config=t:delete r[o].config;const n=this.fragments[o];i&&n.style.stylesheet&&(n.style.stylesheet.schema=i);const s=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.updateConfig(t,s),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports());}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex(e=>e.id===t);return -1===i&&this.fire(new e.B(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource());}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const o=e.F(t,i);return this._mergedOtherSourceCaches[o]}getLayerSourceCache(t){const i=e.F(t.source,t.scope);return "symbol"===t.type?this._mergedSymbolSourceCaches[i]:"fill-extrusion"===t.type&&this._mergedFillExtrusionSourceCaches[i]||this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),this._mergedFillExtrusionSourceCaches[e]&&t.push(this._mergedFillExtrusionSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t);}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e);}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e);}getImages(t,i,o){this.imageManager.getImages(i.images,i.scope,o),this._updateTilesForChangedImages();const r=t=>{if(t){const o=i.images.map(t=>e.I.toString(t));t.setDependencies(i.tileID.key,i.type,o);}},n=e.F(i.source,i.scope);r(this._mergedOtherSourceCaches[n]),r(this._mergedSymbolSourceCaches[n]),i.images.some(e=>e.iconsetId)&&this.fire(new e.C("data",{dataType:"style"}));}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i);}checkAtlasCache(e,t,i){const o=this.imageManager.imageAtlasCache.findCachedAtlas(t.descriptor);i(null,o&&o.contentDescriptor?{iconPositions:o.iconPositions,patternPositions:o.patternPositions,sourceHash:o.contentDescriptor.hash}:null);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i);}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return "symbol"===e.type?this._symbolSourceCaches[e.source]:"fill-extrusion"===e.type&&this._fillExtrusionSourceCaches[e.source]||this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),this._fillExtrusionSourceCaches[e]&&t.push(this._fillExtrusionSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.B(new Error(`There is no source with ID '${t}'`))),!1):i.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return !1;const i="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),o="building"===e.type;if(e.is3D(!!this.terrain)){if(i||o||t&&"batched-model"===t.type)return !0;if("model"===e.type)return !0}else if("symbol"===e.type)return !0;return !1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches");}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(e=>{e.style._remove();}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}}Po.getSourceType=function(e){return St[e]},Po.setSourceType=function(e,t){St[e]=t;},Po.registerForPluginStateChange=e.dk;var Oo="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",Mo="\n#ifdef DUAL_SOURCE_BLENDING\nlayout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;\n#elif defined(FLOAT_RENDER_TARGET)\nlayout(location=0) out highp vec4 glFragColor;\n#else\nlayout(location=0) out vec4 glFragColor;\n#endif\n#ifdef USE_MRT1\nlayout(location=1) out vec4 out_Target1;\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nconst float DITHER_THRESHOLDS[16]=float[16](\n1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0\n);vec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}float cutoutGroundRoofOpacity(vec4 groundRoof) {\n#ifdef INDICATOR_CUTOUT\nfloat fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity);\n#else\nreturn 1.0;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",zo="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\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;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef 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) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}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 vec2 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 (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)\n{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",Fo="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out 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;}",Bo="\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\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;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;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 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*texture(u_dem,pos).r;\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=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;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*texture(u_dem_prev,pos).r;\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=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;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) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif",ko="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",No="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}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;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",Uo="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",Vo="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}",jo="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif",Go="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);\n#endif\nreturn texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);\n#else\nlight_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const Zo=/#include\s+"([^"]+)"/g,qo=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,Ho=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,Wo=new Set(["ifdef","ifndef","elif","if","defined"]),$o=new Set;ir(Oo,$o),ir(zo,$o),ir(Mo,$o);const Xo={"_prelude_fog.vertex.glsl":ko,"_prelude_terrain.vertex.glsl":Bo,"_prelude_shadow.vertex.glsl":jo,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { \nif (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; \n}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":No,"_prelude_shadow.fragment.glsl":Go,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif","_prelude_raster_array.glsl":Uo,"_prelude_raster_particle.glsl":Vo},Yo={};rr("",Bo),rr(No,ko),rr(Go,jo),rr(Uo,""),rr(Vo,"");const Ko=rr(Mo,zo),Jo=Oo,Qo=["\n#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)\n#extension GL_EXT_blend_func_extended : require\n#endif","precision mediump float;",Jo,Ko.fragmentSource].join("\n"),er=["precision highp float;",Jo,Ko.vertexSource].join("\n");var tr={background:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef FEATURE_CUTOUT\nvec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nfloat factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor);\n#else\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifndef FEATURE_CUTOUT\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\n}'),backgroundPattern:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),building:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nhighp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\n#else\nshadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,v_pos.z);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=color;\n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;\n#ifdef FLOOD_LIGHT\nin int a_flood_light_wall_radius_1i16;\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;\n#endif\nuniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nout vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);\n#ifdef BUILDING_FAUX_FACADE\nvec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}\n#endif\nv_pos=a_pos_3f;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nfloat halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);\n#endif\n#endif\n}'),buildingBloom:rr("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\n#ifdef RENDER_CUTOFF\nopacity*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}"),buildingDepth:rr("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),circle:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in 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\nuniform float u_emissive_strength;void 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 blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\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;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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;\n#endif\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\n#endif\nout vec3 v_data;out 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.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),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() {\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 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nsurface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);\n#endif\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\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\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();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;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:rr("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:rr('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in 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);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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;\n#endif\nout 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() {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(vec2(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(vec2(a_pos)*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=vec3(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=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=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:rr("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:rr("in float v_placed;in 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);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_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+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}'),collisionCircle:rr("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in 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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out 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;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));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=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:rr("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);\n#endif\n}'),elevatedStructuresDepth:rr("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:rr("#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}"),elevatedStructures:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin vec3 v_normal;in float v_height;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nvec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),fill:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=opacity;\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\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;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),fillOutlinePattern:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillPattern:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),lineBlendComposite:rr("uniform sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;in vec2 v_pos;\n#define ADDITIVE 1\nvoid main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);float t=density/(1.0+density);glFragColor=vec4(avgColor*t*u_opacity,t*u_opacity);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);}\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,h);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nuniform highp float u_vertical_scale;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\nout vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;\n#else\nh=t > 0.0 ? height : base;\n#endif\npos=vec3(pos_nx.xy,h);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}}\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);\n#endif\n#ifdef RENDER_CUTOFF\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w);\n#endif\n#endif\n}'),fillExtrusionDepth:rr("void main() {}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}'),fillExtrusionPattern:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,height);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(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\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.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=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:rr('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);\n#endif\n#ifdef FEATURE_CUTOUT\nshadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:rr("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=float(a_hidden_by_landmark);\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:rr("precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 a_texture_pos;out 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=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(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);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),line:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nin float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\nfloat linearstep(float edge0,float edge1,float x) {return  clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat dist=length(v_normal)*v_width2_dilute.x;\n#ifdef VARIABLE_LINE_WIDTH\nblur=mix(blur,0.0,stub_side);\n#endif\nfloat diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);\n#ifdef VARIABLE_LINE_WIDTH\nalpha=mix(alpha,1.0,stub_side);\n#endif\nalpha=side_z_offset > 0.0 ? 1.0-alpha : alpha;\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;\n#ifdef RENDER_LINE_GRADIENT\ngradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);\n#endif\nhighp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nfloat edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}out_color*=v_width2_dilute.w;}\n#endif\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*diluted_opacity);\n#ifdef LINE_BLEND_MULTIPLY\nglFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);HANDLE_WIREFRAME_DEBUG;return;\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec3 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nin highp vec3 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin 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;uniform float u_width_scale;uniform highp float u_floor_width_scale;\n#ifdef RENDER_LINE_CURVE\nuniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;\n#endif\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nout float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\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\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\n#ifdef RENDER_LINE_CURVE\nvec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*(\n2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3\n);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(\n(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2\n);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\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\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nhighp float line_progress=0.0;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nline_progress=a_packed[2];\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;\n#ifdef RENDER_LINE_CURVE\nCurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;\n#endif\ngapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\nfloat 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);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0);\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0);\n#endif\n#endif\n#ifndef ELEVATED\n#ifndef VARIABLE_LINE_WIDTH\n#ifndef RENDER_TO_TEXTURE\nfloat base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else\n{\n#ifdef RENDER_LINE_BORDER\nfloat border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);\n#endif\n}}\n#endif\n#endif\n#ifdef ELEVATED_ROADS\ngl_Position=gl_Position+projected_extrude;\n#else\ngl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nvec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y);\n#endif\nv_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\n#endif\nglFragColor=color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec3 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\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=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;\n#endif\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;in uvec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT);\n#endif\nglobe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nvec4 world_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);  \nfloat tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;\n#endif\nvec4 merc_world_pos=vec4(0.0);   \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat ele=0.0;vec2 decodedPos=vec2(a_pos);\n#ifdef ELEVATION_REFERENCE_GROUND\nvec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;\n#else\nuv=vec2(a_texture_pos)/8192.0;\n#endif\nworld_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);\n#ifdef FOG\nv_fog_pos=fog_position(decodedPos);\n#endif\n#endif\nfloat w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef ELEVATED\nfloat z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);\n#endif\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:rr("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:rr("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:rr('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return  clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:rr('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef USE_PAINT_PROPERTIES_UBO\nin lowp float v_opacity;\n#ifdef RENDER_SDF\nin lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nin lowp float v_emissive_strength;\n#endif\n#else\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\n#pragma mapbox: define lowp float emissive_strength\n#endif\nvoid main() {\n#ifdef USE_PAINT_PROPERTIES_UBO\nlowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0;\n#ifdef RENDER_SDF\nfill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur;\n#endif\nlowp float emissive_strength=0.0;\n#ifdef LIGHTING_3D_MODE\nemissive_strength=v_emissive_strength;\n#endif\n#else\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\n#pragma mapbox: initialize lowp float emissive_strength\n#endif\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef RENDER_SDF\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;\n#else\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define USING_APPEARANCE 1.0\nin ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin uvec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\n#endif\nuniform 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_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef USE_PAINT_PROPERTIES_UBO\n#ifndef MAX_UBO_SIZE_VEC4\n#define MAX_UBO_SIZE_VEC4 1024u\n#endif\n#define SPP_HEADER_SIZE_VEC4 3u\n#define DWORDS_PER_VEC4 4u\nstruct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform float u_zoom;uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform lowp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity;\n#ifdef RENDER_SDF\nout lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nout lowp float v_emissive_strength;\n#endif\nPropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask=u_spp_header.header[0][0];uint zoomDependentMask=u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color       =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3]);header.halo_np_color       =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0]);header.opacity             =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1]);header.halo_width          =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2]);header.halo_blur           =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3]);header.emissive_strength   =getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0]);header.occlusion_opacity   =getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1]);header.z_offset            =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2]);header.translate           =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3]);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,u_zoom);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {vec2 minVal=slot.xy;vec2 maxVal=slot.zw;return mix(minVal,maxVal,u_zoom);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,u_zoom);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color       =header.fill_np_color.isDataDriven     ? readColorProperty(header.fill_np_color,sizeVec4)     : u_spp_fill_np_color;props.halo_np_color       =header.halo_np_color.isDataDriven     ? readColorProperty(header.halo_np_color,sizeVec4)     : u_spp_halo_np_color;props.opacity             =header.opacity.isDataDriven           ? readFloatProperty(header.opacity,sizeVec4)           : u_spp_opacity;props.halo_width          =header.halo_width.isDataDriven        ? readFloatProperty(header.halo_width,sizeVec4)        : u_spp_halo_width;props.halo_blur           =header.halo_blur.isDataDriven         ? readFloatProperty(header.halo_blur,sizeVec4)         : u_spp_halo_blur;props.emissive_strength   =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity   =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset            =header.z_offset.isDataDriven          ? readFloatProperty(header.z_offset,sizeVec4)          : u_spp_z_offset;props.translate           =header.translate.isDataDriven          ? readVec2Property(header.translate,sizeVec4)           : vec2(0.0);return props;}\n#else\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\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\n#endif\nvec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {\n#ifdef USE_PAINT_PROPERTIES_UBO\nSymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;\n#ifdef RENDER_SDF\nv_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_emissive_strength=paint_properties.emissive_strength;\n#endif\nlowp float occlusion_opacity=paint_properties.occlusion_opacity;lowp float z_offset=paint_properties.z_offset;\n#else\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\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\n#endif\nvec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\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 font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);    \n#endif\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,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_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\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\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\n#ifdef ELEVATED_ROADS\nvec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);\n#ifdef USE_PAINT_PROPERTIES_UBO\n{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(\nu_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y\n);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=vec2(a_texb)/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nin vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:rr("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:rr('#include "_prelude_fog.fragment.glsl"\nin 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=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Fo),skyboxGradient:rr('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Fo),skyboxCapture:rr("\nin 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;precision highp float;\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;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out 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:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nuniform float u_far_z_cutoff;in vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:rr('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}"),model:rr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;\n#ifdef DITHERED_DISCARD\nuniform float u_dithered_discard_threshold;\n#endif\nuniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return  depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));\n#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef DITHERED_DISCARD\nif (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp uvec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:rr("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\n}"),stars:rr("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}"),snowParticle:rr("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:rr("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:rr("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:rr("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}')};function ir(e,t){const i=e.split("\n");for(let e of i){if(e=e.trimStart(),"#"!==e[0])continue;if(!e.includes("if"))continue;if(e.startsWith("#endif"))continue;const i=e.match(Ho);if(i)for(const e of i)Wo.has(e)||t.add(e);}}function or(e){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(e)}function rr(e,t){const i=new Set,o=[],r=[];e=e.replace(Zo,(e,t)=>(r.push(t),"")),t=t.replace(Zo,(e,t)=>(o.push(t),""));let n=new Set($o);ir(e,n),ir(t,n);for(const e of [...o,...r])Yo[e]||(Yo[e]=new Set,ir(Xo[e],Yo[e])),n=new Set([...n,...Yo[e]]);return {fragmentSource:e=e.replace(qo,(e,t,o,r,n)=>(i.add(n),"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\n${or(r)?"flat ":""}in ${o} ${r} ${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n    ${o} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n    in ${o} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(qo,(e,t,o,r,n)=>{const s=`MATERIAL_ATTRIBUTE_OFFSET_${n}`,a="float"===r?"vec2":r,l=`GET_ATTRIBUTE_${a}(a_${n}, materialInfo, ${s})`,c=n.match(/color/)?"color":a;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${o} ${r} a_${n};\n#endif\n`:i.has(n)?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\n    #if !defined(${s})\n        in ${o} ${a} a_${n};\n    #endif\n${or(r)?"flat ":""}out ${o} ${r} ${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize"===t?"vec4"===c||"uvec4"===c?`\n#ifndef HAS_UNIFORM_u_${n}\n    ${n} = a_${n};\n#else\n    ${o} ${r} ${n} = u_${n};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${n})\n    #ifdef ${s}\n        ${n} = unpack_mix_${c}(${l}, u_${n}_t);\n    #else\n        ${n} = unpack_mix_${c}(a_${n}, u_${n}_t);\n    #endif\n#else\n    ${o} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n    in ${o} ${r} a_${n};\n    out ${o} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n    ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\n    #if !defined(${s})\n        in ${o} ${a} a_${n};\n    #endif\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${o} ${a} a_${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n    ${o} ${r} ${n} = a_${n};\n#endif\n`:"vec4"===c||"uvec4"===c?`\n#ifndef HAS_UNIFORM_u_${n}\n    #ifdef ${s}\n        ${o} ${r} ${n} = ${l};\n    #else\n        ${o} ${r} ${n} = a_${n};\n    #endif\n#else\n    ${o} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n    #ifdef ${s}\n        ${o} ${r} ${n} = unpack_mix_${c}(${l}, u_${n}_t);\n    #else\n        ${o} ${r} ${n} = unpack_mix_${c}(a_${n}, u_${n}_t);\n    #endif\n#else\n    ${o} ${r} ${n} = u_${n};\n#endif\n`}),usedDefines:n,vertexIncludes:o,fragmentIncludes:r}}class nr{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,o,r,n,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!l&&e<o.length;e++)this.boundPaintVertexBuffers[e]!==o[e]&&(l=!0);let c=this.boundDynamicVertexBuffers.length!==s.length;for(let e=0;!c&&e<s.length;e++)this.boundDynamicVertexBuffers[e]!==s[e]&&(c=!0);if(!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||l||c||this.boundIndexBuffer!==r||this.boundVertexOffset!==n)this.freshBind(t,i,o,r,n,s,a);else {e.bindVertexArrayOES.set(this.vao);for(const i of s)i&&(i.bind(),a&&i.instanceCount&&i.setVertexAttribDivisor(e.gl,t,a));r&&r.dynamicDraw&&r.bind();}}freshBind(e,t,i,o,r,n,s){const a=this.context,l=a.gl;this.vao&&this.destroy(),this.vao=a.gl.createVertexArray(),a.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=o,this.boundVertexOffset=r,this.boundDynamicVertexBuffers=n,t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r);for(const t of i)t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r);for(const t of n)t&&(t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,r),s&&t.instanceCount&&t.setVertexAttribDivisor(l,e,s));o&&o.bind();}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null);}}function sr(t,i){const o=Math.pow(2,i.canonical.z),r=i.canonical.y;return [new e.ag(0,r/o).toLngLat().lat,new e.ag(0,(r+1)/o).toLngLat().lat]}function ar(t,i,o,r,n,s,a){const l=t.context,c=l.gl,h=o.hillshadeFBO;if(!h)return;t.prepareDrawTile();const d=t.isTileAffectedByFog(i),_=[];t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&_.push("USE_MRT1");const u=t.getOrCreateProgram("hillshade",{overrideFog:d,defines:_});l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,h.colorAttachment0.get());const p=((t,i,o,r)=>{const n=o.paint.get("hillshade-shadow-color"),s="none"===o.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=o.paint.get("hillshade-highlight-color"),l="none"===o.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=o.paint.get("hillshade-accent-color"),h="none"===o.paint.get("hillshade-accent-color-use-theme").constantOr("default"),d=o.paint.get("hillshade-emissive-strength");let _=e.ap(o.paint.get("hillshade-illumination-direction"));if("viewport"===o.paint.get("hillshade-illumination-anchor"))_-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),o=e.cP(i.x,i.y,i.z);_=e.ap(o[1]);}const u=!t.options.moving;return {u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),u),u_image:0,u_latrange:sr(0,i.tileID),u_light:[o.paint.get("hillshade-exaggeration"),_],u_shadow:n.toPremultipliedRenderColor(s?null:o.lut),u_highlight:a.toPremultipliedRenderColor(l?null:o.lut),u_emissive_strength:d,u_accent:c.toPremultipliedRenderColor(h?null:o.lut)}})(t,o,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,u,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(o);u.draw(t,c.TRIANGLES,n,s,a,Ji.disabled,p,r.id,f,m,g);}function lr(t,i,o){if(!i.needsDEMTextureUpload)return;const r=t.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(o.stride);const s=o.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(r,s,n.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function cr(t,i,o){const r=t.context,n=r.gl;if(!i.dem)return;const s=i.dem;if(r.activeTexture.set(n.TEXTURE1),lr(t,i,s),!i.demTexture)return;i.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE);const a=s.dim;r.activeTexture.set(n.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:a,height:a,data:null},n.RGBA8);t.bind(n.LINEAR,n.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(a,a,1,"renderbuffer"),l.colorAttachment0.set(t.texture);}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:d}=t.getMercatorTileBoundsBuffers(),_=[];t.linearFloatFilteringSupported()&&_.push("TERRAIN_DEM_FLOAT_FORMAT"),t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&_.push("USE_MRT1"),t.getOrCreateProgram("hillshadePrepare",{defines:_}).draw(t,n.TRIANGLES,Wi.disabled,Xi.disabled,Hi.unblended,Ji.disabled,((t,i)=>{const o=i.stride,r=e.bb();return e.bT(r,0,e.an,-e.an,0,0,1),e.bx(r,r,[0,-e.an,0]),{u_matrix:r,u_image:1,u_dimension:[o,o],u_zoom:t.overscaledZ}})(i.tileID,s),o.id,c,h,d),i.needsHillshadePrepare=!1;}class hr{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1;}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default);}}class dr extends hr{getDefault(){return e.aq.transparent.toNonPremultipliedRenderColor(null)}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class _r extends hr{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class ur extends hr{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class pr extends hr{getDefault(){return [!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class fr extends hr{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class mr extends hr{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class gr extends hr{getDefault(){return {func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1);}}class vr extends hr{getDefault(){const e=this.gl;return [e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1);}}class yr extends hr{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1;}}class xr extends hr{getDefault(){return [0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1);}}class br extends hr{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1;}}class wr extends hr{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class Tr extends hr{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1;}}class Er extends hr{getDefault(){const e=this.gl;return [e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Sr extends hr{getDefault(){return e.aq.transparent.toNonPremultipliedRenderColor(null)}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Cr extends hr{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1);}}class Ir extends hr{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1;}}class Rr extends hr{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class Dr extends hr{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let Ar=class extends hr{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class Lr extends hr{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class Pr extends hr{getDefault(){const e=this.gl;return [0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Or extends hr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1;}}class Mr extends hr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class zr extends hr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1;}}class Fr extends hr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class Br extends hr{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class kr extends hr{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class Nr extends hr{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1;}}class Ur extends hr{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1;}}class Vr extends hr{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1;}}class jr extends hr{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class Gr extends jr{constructor(e,t,i=0){super(e,t),this.attachmentPoint=e.gl.COLOR_ATTACHMENT0+i;}setDirty(){this.dirty=!0;}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachmentPoint,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class Zr extends jr{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class qr extends jr{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class Hr extends Zr{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Wr=(e,t,i,o)=>({u_matrix:e,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:i,u_emissive_texture_available:o}),$r=(e,t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(o),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:n,u_image0:0,u_image1:1,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:d,u_viewport:_,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:u,u_far_z_cutoff:p,u_emissive_texture_available:f});function Xr(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Yr=new class{constructor(){this.operations={};}newMorphing(e,t,i,o,r){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i);}else this.operations[e]={startTime:o,phase:0,duration:r,from:t,to:i,queued:null};}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return {from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return !!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},Kr={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Jr(e,t,i){if(0===t)return 0;const o=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*o}function Qr(e,t){const i=1<<e.z;return !t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}function en(e,t){if(!e.style||!e.style.enable3dLights())return;const i=e.context,o=i.gl;i.activeTexture.set(o.TEXTURE1),t?t.bind(o.LINEAR,o.CLAMP_TO_EDGE):e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);}const tn=e=>({u_matrix:e});function on(t,i,o,r,n){if(n>0){const s=e.o.now(),a=(s-t.timeAdded)/n,l=i?(s-i.timeAdded)/n:-1,c=o.getSource(),h=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),_=d&&t.refreshedUponExpiration?1:e.aC(d?a:1-l,0,1);return i?{opacity:1,mix:1-_,isFading:a<1}:{opacity:_,mix:0,isFading:a<1}}return {opacity:1,mix:0,isFading:!1}}class rn extends Ft{constructor(e){const t={type:"raster-dem",maxzoom:Math.ceil(e.transform.maxZoom)},i=Ct("mock-dem",t,e.style.dispatcher,e.style);super("mock-dem",i,null),i.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state="loaded",t(null);}}class nn extends Ft{constructor(e){const t=Ct("proxy",{type:"geojson",maxzoom:Math.ceil(e.transform.maxZoom)},e.style.dispatcher,e.style);super("proxy",t,null),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}update(t,i,o){if(t.freezeTileCoverage)return;this.transform=t;const r=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((i,o)=>{if(i[o.key]="",!this._tiles[o.key]){const i=new e.b0(o,this._source.tileSize*o.overscaleFactor(),t.tileZoom,void 0,void 0,this._source.worldview);i.state="loaded",this._tiles[o.key]=i;}return i},{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class sn extends e.aR{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i;}}class an extends e.bu{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[o,r,n]=function(){const t=new e.dB,i=new e.dC,o=131;t.reserve(17161),i.reserve(33800);const r=e.an/128,n=e.an+r/2,s=n+r;for(let i=-r;i<s;i+=r)for(let o=-r;o<s;o+=r){const r=o<0||o>n||i<0||i>n?24575:0,s=e.aC(Math.round(o),0,e.an),a=e.aC(Math.round(i),0,e.an);t.emplaceBack(s+r,a);}const a=(e,t)=>{const r=t*o+e;i.emplaceBack(r+1,r,r+o),i.emplaceBack(r+o,r+o+1,r+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return [0,129].forEach(e=>{for(let t=0;t<130;t++)a(t,e),a(e,t);}),[t,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(o,e.dx.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=e.dy.simpleSegment(0,0,o.length,r.length),this.gridNoSkirtSegments=e.dy.simpleSegment(0,0,o.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new nn(i.map),this.orthoMatrix=e.bb(),e.bT(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.an,0,e.an,0,1);const a=s.gl;this._overlapStencilMode=new Xi({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new rn(i.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1;}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache();});}update(t,i,o){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,n=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.o.now();const a=t.terrain&&t.terrain.scope,l=r.get("source"),c=n?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=s?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{this.sourceCache.used&&e.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),i.updateElevation(!0,o),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom;}else this._disable();}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,o=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=o;const r=null!=i?o-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const n=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(n);let a=n-this._previousZoom;const l=this._previousUpdateTimestamp;let c=n;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(n-c)>.5&&(a=.5*(n-c+a)),a*r<0&&(c+=a)),this._evaluationZoom=c;const h=s.getExaggeration(c),d=h===s.getExaggeration(Math.max(0,c-.1));if(d&&Math.abs(h-this._exaggeration)<.01)return h;let _=Math.min(.1,.00375*(this._updateTimestamp-l));return (d||h<.1||Math.abs(a)<1e-4)&&(_=Math.min(.2,4*_)),e.am(this._exaggeration,h,_)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){"source"===e.dataType&&e.coord?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1;}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return [e,e]}set useVertexMorphing(e){this._useVertexMorphing=e;}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(e.ag.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=o.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const o=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(o.x,o.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const o=new e.P(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),n=new e.P(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),s=r.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(o)-s.distSqr(n)});}(r,this.painter);const n=this.proxyToSource||{};this.proxyToSource={},r.forEach(e=>{this.proxyToSource[e.key]={};}),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],n),i.usedForTerrain)continue;const o=t[e];(i.getSource().reparseOverscaled||i._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(o);}this.proxiedCoords[i.id]=r.map(e=>new sn(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i);}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t);});}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const o=this.terrainTileForTile[i],r=o.dem;!r||o.demTexture&&!o.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),lr(this.painter,o,r));}}_prepareDemTileUniforms(e,t,i,o){if(!t||null==t.demTexture)return !1;const r=e.tileID.canonical,n=Math.pow(2,t.tileID.canonical.z-r.z),s=o||"";return i[`u_dem_tl${s}`]=[r.x*n%1,r.y*n%1],i[`u_dem_scale${s}`]=n,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const o=i.dem.tree.minimums[0];return o>0&&e++,t+o},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const o=this._getLoadedAreaMinimum(),r=new e.dz({width:1,height:1},new Float32Array([o]));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new e.T(t,r,i.R32F,{premultiply:!1}),n}setupElevationDraw(t,i,o){const r=this.painter.context,n=r.gl,s={u_dem:2,u_dem_prev:4,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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(o&&o.morphing&&this._useVertexMorphing){const e=o.morphing.srcDemTile,i=o.morphing.dstDemTile;c=o.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?n.LINEAR:n.NEAREST;let d=null;var _;if(this.enabled?l&&a?(d=a.demTexture,r.activeTexture.set(n.TEXTURE4),l.demTexture.bind(h(l),n.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],d=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):d=this.emptyDEMTexture,r.activeTexture.set(n.TEXTURE2),d&&(s.u_dem_size=1===(_=d).size[0]?1:_.size[0]-2,d.bind(h(a),n.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(o&&o.useDepthForOcclusion,i,s),o&&o.useMeterToDem&&a){const t=(1<<a.tileID.canonical.z)*e.bU(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t;}if(o&&o.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=o.labelPlaneMatrixInv),i.setTerrainUniformValues(r,s),"globe"===this.painter.transform.projection.name){const e=this.globeUniformValues(this.painter.transform,t.tileID.canonical,o&&o.useDenormalizedUpVectorScale);i.setGlobeUniformValues(r,e);}}globeUniformValues(t,i,o){const r=t.projection;return {u_tile_tl_up:r.upVector(i,0,0),u_tile_tr_up:r.upVector(i,e.an,0),u_tile_br_up:r.upVector(i,e.an,e.an),u_tile_bl_up:r.upVector(i,0,e.an),u_tile_up_scale:o?e.dA(1):r.upVectorScale(i,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){const i=this.painter,o=this.painter.context;0!==t.length&&(o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),i.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,i,o,r,n){if("globe"===t.transform.projection.name)!function(t,i,o,r,n){const s=t.context,a=s.gl;let l,c;const h=t.transform,d=e.dp(t,s,h),_=(e,i)=>{if(c===i)return;const o=[Kr[i],"PROJECTION_GLOBE_VIEW"];d&&o.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:o,overrideFog:r}),c=i;},u=t.colorModeForRenderPass(),p=new Wi(a.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D);Yr.update(n);const f=e.dq(h),m=[e.aH(h.center.lng),e.aL(h.center.lat)],g=t.globeSharedBuffers,v=[h.width*e.o.devicePixelRatio,h.height*e.o.devicePixelRatio],y=Float32Array.from(h.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const h=t.transform,d=Jr(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of r){const r=o.getTile(c),w=Xi.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];Xr(T,E)&&Yr.newMorphing(c.key,T,E,n,250),en(t,r.emissiveTexture),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=Yr.getMorphValuesForProxy(c.key),C=S?1:0;S&&Object.assign(x,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.dn(S.phase)}});const I=e.dr(c.canonical),R=e.ds(I.getCenter().lat),D=e.dt(c.canonical,I,R,h.worldSize/h._pixelsPerMercatorPixel),A=e.du(e.dv(c.canonical)),L="mrt-fallback"===t.emissiveMode?1:0,P=$r(h.expandedFarZProjMatrix,y,f,A,e.al(h.zoom),m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,d,h._farZ,L,D);if(_(c,C),l&&(i.setupElevationDraw(r,l,x),t.uploadCommonUniforms(s,l,c.toUnwrapped()),g)){const[e,i,o]=g.getGridBuffers(R,0!==d);l.draw(t,b,p,w,u,Ji.backCCW,P,"globe_raster",e,i,o);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&n.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:n});for(const n of r){const{x:r,y:c,z:d}=n.canonical,_=0===c,f=c===(1<<d)-1,[y,b,w,T]=g.getPoleBuffers(d,!1);if(T&&(_||f)){const c=o.getTile(n);en(t,c.emissiveTexture),s.activeTexture.set(a.TEXTURE0),c.texture&&c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let g=e.dw(d,r,h);const E=e.du(e.dv(n.canonical)),S="mrt-fallback"===t.emissiveMode?1:0,C=(e,i)=>e.draw(t,a.TRIANGLES,p,Xi.disabled,u,Ji.disabled,$r(h.expandedFarZProjMatrix,g,g,E,0,m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,0,h._farZ,S),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,x),t.uploadCommonUniforms(s,l,n.toUnwrapped()),_&&t.renderDefaultNorthPole&&C(l,y),f&&t.renderDefaultSouthPole&&(g=e.cC(e.bb(),g,[1,-1,1]),C(l,b));}}}}(t,i,o,r,n);else {const s=t.context,a=s.gl;let l,c;const h=t.shadowRenderer,d=lo(t,t.longestCutoffRange),_=e=>{if(c===e)return;const i=[];i.push(Kr[e]),d.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),h&&(i.push("RENDER_SHADOWS"),h.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e;},u=t.colorModeForRenderPass(),p=new Wi(a.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D);Yr.update(n);const f=t.transform,m=Jr(f.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=mo(t.style,e,i));}{c=-1;const v=a.TRIANGLES,[y,x]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=o.getTile(c),b=Xi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];Xr(w,T)&&Yr.newMorphing(c.key,w,T,n,250),en(t,r.emissiveTexture),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=Yr.getMorphValuesForProxy(c.key),S=E?1:0;let C;E&&(C={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.dn(E.phase)}});const I="mrt-fallback"===t.emissiveMode?1:0,R=Wr(c.projMatrix,Qr(c.canonical,f.renderWorldCopies)?m/10:m,g,I);if(_(S),!l)continue;i.setupElevationDraw(r,l,C);const D=c.toUnwrapped();h&&h.setupShadows(D,l),t.uploadCommonUniforms(s,l,D,null,d),l.draw(t,v,p,b,u,Ji.backCCW,R,"terrain_raster",i.gridBuffer,y,x);}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length));}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,o=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];this._updateFBOs("mrt-fallback"===i.emissiveMode);let c=0;for(const h of n){const n=r.getTileByID(h.proxyTileKey),d=r.proxyCachedFBO[h.key]?r.proxyCachedFBO[h.key][t]:void 0,_=void 0!==d?r.renderCache[d]:this.pool[c++],u=void 0!==d;if(n.texture=_.tex,n.emissiveTexture=_.emissiveTex,u&&!_.dirty){l.push(n.tileID);continue}o.bindFramebuffer.set(_.fb.framebuffer);const p=o.gl;let f;p.drawBuffers("mrt-fallback"===i.emissiveMode?[p.COLOR_ATTACHMENT0,p.COLOR_ATTACHMENT1]:[p.COLOR_ATTACHMENT0]),this.renderedToTile=!1,_.dirty&&(o.clear({color:e.aq.transparent,stencil:0}),_.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),n=r?this.proxyToSource[h.key][r.id]:[h];if(!n)continue;const s=n;o.viewport.set([0,0,_.fb.width,_.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(_,n,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s);}if(p.drawBuffers([p.COLOR_ATTACHMENT0]),0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),n=r?this.proxyToSource[h.key][r.id]:[h];if(!n)continue;const s=n;o.viewport.set([0,0,_.fb.width,_.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(_,n,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s);}this.renderedToTile?(_.dirty=!0,l.push(n.tileID)):u||--c,5===c&&(c=0,this.renderToBackBuffer(l));}return this.renderToBackBuffer(l),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,o=t;for(let r=0;r<t;++r)this._style.isLayerDraped(e._mergedLayers[e.order[r]])?i=Math.max(i,r):o=Math.min(o,r);return o>i}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0]);}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const o=this._visibleDemTiles.filter(e=>e.dem).map(o=>{const r=o.tileID,n=1<<r.overscaledZ,{x:s,y:a}=r.canonical,l=s/n,c=(s+1)/n,h=a/n,d=(a+1)/n;return {minx:l,miny:h,maxx:c,maxy:d,t:o.dem.tree.raycastRoot(l,h,c,d,e,t,i),tile:o}});o.sort((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const r of o){if(null==r.t)return null;const o=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=o)return o}return null}_createFBO(){const t=this.painter.context,i=t.gl,o=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:o[0],height:o[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const n=t.createFramebuffer(o[0],o[1],1,null);let s;return n.colorAttachment0.set(r.texture),this._emissiveTexture&&(s=new e.T(t,{width:o[0],height:o[1],data:null},i.R8),s.bind(i.LINEAR,i.CLAMP_TO_EDGE),n.createColorAttachment(t,1),n.colorAttachment1.set(s.texture)),n.depthAttachment=new Hr(t,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:n,tex:r,emissiveTex:s,dirty:!1}}_updateFBOs(e){if(this._emissiveTexture!==e){for(const t of this.pool)this._updateFBO(t,e);for(const t of this.proxySourceCache.renderCache)this._updateFBO(t,e);this._emissiveTexture=e;}}_updateFBO(t,i){const o=t.fb,r=this.painter.context,n=r.gl,s=this.drapeBufferSize;if(i){const i=new e.T(r,{width:s[0],height:s[1],data:null},n.R8);i.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.emissiveTex=i,o.createColorAttachment(r,1),o.colorAttachment1.set(i.texture);}else t.emissiveTex=void 0,o.removeColorAttachment(r,1);t.dirty=!0;}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO());}_shouldDisableRenderCache(){if(this._debugParams.disableRenderCache)return !0;if(this._style.hasLightTransitions())return !0;for(const e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return !0;return this._style.order.some(e=>{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return "hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof bt){t=!0;break}if(!t)return;const i={};for(let t=0;t<this._style.order.length;++t){const o=this._style._mergedLayers[this._style.order[t]],r=this._style.getLayerSourceCache(o);if(!r||i[r.id])continue;if(o.isHidden(this.painter.transform.zoom)||"line"!==o.type)continue;const n=o.widthExpression(),s=o.emissiveStrengthExpression();if(n instanceof e.af||s instanceof e.af){i[r.id]=!0;for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t)this._clearRenderCacheForTile(r.id,e);}}}}_clearRasterLayersFromRenderCache(){let e=!1;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t]._source instanceof wt){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const i=this._style._mergedLayers[this._style.order[e]],o=this._style.getLayerSourceCache(i);if(!o||t[o.id])continue;if(i.isHidden(this.painter.transform.zoom)||"raster"!==i.type)continue;const r=i.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][o.id];if(t)for(const e of t){const t=on(o.getTile(e),o.findLoadedParent(e,0),o,this.painter.transform,r);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(o.id,e);}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();const t=this._style.order,i=t.length;if(0===i)return;const o=[];this._pendingGroundEffectLayers=[];let r,n=0,s=this._style._mergedLayers[t[n]];for(;!this._style.isLayerDraped(s)&&s.isHidden(this.painter.transform.zoom)&&++n<i;)s=this._style._mergedLayers[t[n]];for(;n<i;++n){const e=this._style._mergedLayers[t[n]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===r&&(r=n):("fill-extrusion"===e.type&&this._pendingGroundEffectLayers.push(n),void 0!==r&&(o.push({start:r,end:n-1}),r=void 0)));}if(void 0!==r&&o.push({start:r,end:n-1}),0!==o.length){const t=o[o.length-1];this._pendingGroundEffectLayers.every(e=>e>t.end)||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.");}this._drapedRenderBatches=o;}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const o=Object.values(e[i]);t.renderCachePool.push(...o);}}return}this._clearRasterLayersFromRenderCache();const i=this.proxyCoords,o=this._tilesDirty;for(let r=i.length-1;r>=0;r--){const n=i[r];if(t.getTileByID(n.key),void 0!==t.proxyCachedFBO[n.key]){const i=e[n.key],r=this.proxyToSource[n.key];let s=0;for(const e in r){const t=r[e],n=i[e];if(!n||n.length!==t.length||t.some((t,i)=>t!==n[i]||o[e]&&o[e].hasOwnProperty(t.key))){s=-1;break}++s;}for(const e in t.proxyCachedFBO[n.key])t.renderCache[t.proxyCachedFBO[n.key][e]].dirty=s<0||s!==Object.values(i).length;}}const r=[...this._drapedRenderBatches];r.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of r)for(const o of i){if(t.proxyCachedFBO[o.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[o.key]={},t.proxyCachedFBO[o.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,n=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:n.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:n.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+s>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref);}clipOrMaskOverlapStencilType(){return "Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Xi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,o=this.painter.context,r=o.gl;i._tileClippingMaskIDs={},o.setColorMode(Hi.disabled),o.setDepthMode(Wi.disabled);const n=i.getOrCreateProgram("clippingMask");for(const o of e){const e=i._tileClippingMaskIDs[o.key]=--t;n.draw(i,r.TRIANGLES,Wi.disabled,new Xi({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Hi.disabled,Ji.disabled,tn(o.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments);}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const o=[t.x,t.y,1,1];e.aE(o,o,i.pixelMatrixInverse),e.cu(o,o,1/o[3]),o[0]/=i.worldSize,o[1]/=i.worldSize;const r=i._camera.position,n=e.bU(1,i.center.lat),s=[r[0],r[1],r[2]/n,0],a=e.cV([],o.slice(0,3),s);e.ay(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.bg(s,s,a,l),s[3]=s[2],s[2]*=n,s):null}_setupProxiedCoordsForOrtho(t,i,o){if(t.getSource()instanceof e.aV)return this._setupProxiedCoordsForImageSource(t,i,o);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords;for(let e=0;e<n.length;e++){const i=n[e],s=this._findTileCoveringTileID(i,t);if(s){const e=this._createProxiedId(i,s,o[i.key]&&o[i.key][t.id]);r.push(e),this.proxyToSource[i.key][t.id]=[e];}}let s=!1;const a=new Set;for(let e=0;e<i.length;e++){const n=t.getTile(i[e]);if(!n||!n.hasData())continue;const l=this._findTileCoveringTileID(n.tileID,this.proxySourceCache);if(l&&l.tileID.canonical.z!==n.tileID.canonical.z){const e=this.proxyToSource[l.tileID.key][t.id],i=this._createProxiedId(l.tileID,n,o[l.tileID.key]&&o[l.tileID.key][t.id]);e?e.splice(e.length-1,0,i):this.proxyToSource[l.tileID.key][t.id]=[i];const c=this.proxyToSource[l.tileID.key][t.id];a.has(c)||a.add(c),r.push(i),s=!0;}}if(this._sourceTilesOverlap[t.id]=s,s&&this._debugParams.sortTilesHiZFirst)for(const e of a)e.sort((e,t)=>t.overscaledZ-e.overscaledZ);}_setupProxiedCoordsForImageSource(t,i,o){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<<a.z),c=s.coordinates.map(e.ag.fromLngLat).reduce((e,t)=>(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(t,i)=>{const o=t.wrap+t.canonical.x/(1<<t.canonical.z),r=t.canonical.y/(1<<t.canonical.z),n=e.an/(1<<t.canonical.z),s=i.wrap+i.canonical.x/(1<<i.canonical.z),a=i.canonical.y/(1<<i.canonical.z);return o+n<s+c.min.x||o>s+c.max.x||r+n<a+c.min.y||r>a+c.max.y};for(let e=0;e<n.length;e++){const s=n[e];for(let e=0;e<i.length;e++){const n=t.getTile(i[e]);if(!n||!n.hasData())continue;if(h(s,n.tileID))continue;const a=this._createProxiedId(s,n,o[s.key]&&o[s.key][t.id]),l=this.proxyToSource[s.key][t.id];l?l.push(a):this.proxyToSource[s.key][t.id]=[a],r.push(a);}}}_createProxiedId(t,i,o){let r=this.orthoMatrix;if(o){const e=o.find(e=>e.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const o=t.canonical.z-i.tileID.canonical.z;let n,s,a;r=e.bb();const l=i.tileID.wrap-t.wrap<<t.overscaledZ;o>0?(n=e.an>>o,s=n*((i.tileID.canonical.x<<o)-t.canonical.x+l),a=n*((i.tileID.canonical.y<<o)-t.canonical.y)):(n=e.an<<-o,s=e.an*(i.tileID.canonical.x-(t.canonical.x+l<<-o)),a=e.an*(i.tileID.canonical.y-(t.canonical.y<<-o))),e.bT(r,0,n,0,n,0,1),e.bx(r,r,[s,a,0]);}return new sn(i.tileID,t.key,r)}_findTileCoveringTileID(t,i){let o=i.getTile(t);if(o&&o.hasData())return o;const r=this._findCoveringTileCache[i.id],n=r[t.key];if(o=n?i.getTileByID(n):null,o&&o.hasData()||null===n)return o;let s=o?o.tileID:t,a=s.overscaledZ;const l=i.getSource().minzoom,c=[];if(!n){const r=i.getSource().maxzoom;if(t.canonical.z>=r){const o=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.aR(a,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o)):0!==o&&(a=r,s=new e.aR(a,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o));}s.key!==t.key&&(c.push(s.key),o=i.getTile(s));}const h=e=>{c.forEach(t=>{r[t]=e;}),c.length=0;};for(a-=1;a>=l&&(!o||!o.hasData());a--){o&&h(o.tileID.key);const e=s.calculateScaledKey(a);if(o=i.getTileByID(e),o&&o.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):o=i.getTileByID(t);}return h(o?o.tileID.key:null),o&&o.hasData()?o:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0;}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0;}}function ln(t,i,o){const r=function(t,i,o){const r=e.bi(i,t),n=e.bi(o,[.2126,.7152,.0722]),s=(e,t,i)=>(1-i)*e+i*t,a=s(1-.3*Math.min(n,1),1,Math.min(r+1,1));return s(.92,1,Math.asin(e.aC(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),n=[0,0,0];e.bJ(n,o.slice(0,3),r);const s=[0,0,0];e.bJ(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.cT(a,n,s),e.cW(a)}const cn=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],hn=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class dn{static cacheKey(e,t,i,o){const r=[t];o&&r.push(o.cacheKey);for(const t of i)("string"==typeof t&&t.includes(" ")||e.usedDefines.has(t))&&r.push(t);return r.join("/")}constructor(t,i,o,r,n,s){const a=t.gl;this.program=a.createProgram(),this.configuration=r,this.name=i,this.fixedDefines=[...s];const l=`#version 300 es\n${(r?r.defines():[]).concat(s.map(e=>`#define ${e}`)).join("\n")}`,c=[l,Qo];for(const e of o.fragmentIncludes)c.push(Xo[e]);c.push(o.fragmentSource);const h=c.join("\n"),d=[l,er];for(const e of o.vertexIncludes)d.push(Xo[e]);this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&o.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&d.push("uniform int u_instanceID;"),d.push(o.vertexSource);let _=d.join("\n");this.forceManualRenderingForInstanceIDShaders&&(_=_.replaceAll("gl_InstanceID","u_instanceID"));const u=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(u,h),a.compileShader(u),a.attachShader(this.program,u);const p=a.createShader(a.VERTEX_SHADER);a.isContextLost()?this.failedToCreate=!0:(a.shaderSource(p,_),a.compileShader(p),a.attachShader(this.program,p),this.attributes={},a.linkProgram(this.program),a.deleteShader(p),a.deleteShader(u),this.fixedUniforms=n(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=r?r.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.bX(t)}))(t)),(s.includes("TERRAIN")||s.includes("ELEVATED")||i.includes("symbol")||i.includes("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.bX(t),u_dem_prev:new e.bX(t),u_dem_tl:new e.b_(t),u_dem_scale:new e.bZ(t),u_dem_tl_prev:new e.b_(t),u_dem_scale_prev:new e.bZ(t),u_dem_size:new e.bZ(t),u_dem_lerp:new e.bZ(t),u_exaggeration:new e.bZ(t),u_depth:new e.bX(t),u_depth_size_inv:new e.b_(t),u_depth_range_unpack:new e.b_(t),u_occluder_half_size:new e.bZ(t),u_occlusion_depth_offset:new e.bZ(t),u_meter_to_dem:new e.bZ(t),u_label_plane_matrix_inv:new e.b$(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bY(t),u_tile_tr_up:new e.bY(t),u_tile_br_up:new e.bY(t),u_tile_bl_up:new e.bY(t),u_tile_up_scale:new e.bZ(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.b$(t),u_fog_range:new e.b_(t),u_fog_color:new e.cO(t),u_fog_horizon_blend:new e.bZ(t),u_fog_vertical_limit:new e.b_(t),u_fog_temporal_offset:new e.bZ(t),u_frustum_tl:new e.bY(t),u_frustum_tr:new e.bY(t),u_frustum_br:new e.bY(t),u_frustum_bl:new e.bY(t),u_globe_pos:new e.bY(t),u_globe_radius:new e.bZ(t),u_globe_transition:new e.bZ(t),u_is_globe:new e.bX(t),u_viewport:new e.b_(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.cO(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bY(t),u_lighting_directional_dir:new e.bY(t),u_lighting_directional_color:new e.bY(t),u_ground_radiance:new e.bY(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.b$(t),u_light_matrix_1:new e.b$(t),u_fade_range:new e.b_(t),u_shadow_normal_offset:new e.bY(t),u_shadow_intensity:new e.bZ(t),u_shadow_texel_size:new e.bZ(t),u_shadow_map_resolution:new e.bZ(t),u_shadow_direction:new e.bY(t),u_shadow_bias:new e.bY(t),u_shadowmap_0:new e.bX(t),u_shadowmap_1:new e.bX(t)}))(t)));}getAttributeLocation(e,t){let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}_drawDebugWireframe(t,i,o,r,n,s,a,l,c,h){const d=t.options.wireframe;if(!1===d.terrain&&!1===d.layers2D&&!1===d.layers3D)return;const _=t.context;if(!(()=>!(!d.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!d.layers2D||t._terrain&&t._terrain.renderingToTexture||!cn.includes(this.name))||!(!d.layers3D||!hn.includes(this.name)))())return;const u=_.gl,p=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,n,_);if(!p)return;const f=[...this.fixedDefines,"DEBUG_WIREFRAME"],m=t.getOrCreateProgram(this.name,{config:this.configuration,defines:f});_.program.set(m.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const o in t[e])i[e][o]&&i[e][o].set(i.program,o,t[e][o].current);};c&&c.setUniforms(m.program,_,m.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,m),g("terrainUniforms",this,m),g("globeUniforms",this,m),g("fogUniforms",this,m),g("lightsUniforms",this,m),g("shadowUniforms",this,m),p.bind(),_.setColorMode(new Hi([u.ONE,u.ONE_MINUS_SRC_ALPHA,u.ZERO,u.ONE],e.aq.transparent,[!0,!0,!0,!1])),_.setDepthMode(new Wi(i.func===u.LESS?u.LEQUAL:i.func,Wi.ReadOnly,i.range)),_.setStencilMode(Xi.disabled);const v=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=h||1;for(let t=0;t<e;++t)m.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",t),u.drawElements(u.LINES,v,u.UNSIGNED_SHORT,y);}else h&&h>1?u.drawElementsInstanced(u.LINES,v,u.UNSIGNED_SHORT,y,h):u.drawElements(u.LINES,v,u.UNSIGNED_SHORT,y);n.bind(),_.program.set(this.program),_.setDepthMode(i),_.setStencilMode(o),_.setColorMode(r);}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const o of Object.keys(i))if(!i[o].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${o} not set but required by ${t} being defined`)}draw(e,t,i,o,r,n,s,a,l,c,h,d,_,u,p,f){const m=e.context,g=m.gl;if(this.failedToCreate)return;m.program.set(this.program),m.setDepthMode(i),m.setStencilMode(o),m.setColorMode(r),m.setCullFace(n);for(const[e,t]of this.fixedUniformsEntries)t.set(this.program,e,s[e]);u&&u.setUniforms(this.program,m,this.binderUniforms,d,{zoom:_});const v={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const y=p||[],x=u?u.getPaintVertexBuffers():[],b=t===g.TRIANGLES&&c,w=f&&f>0?1:void 0;for(const n of h.get()){const s=n.vaos||(n.vaos={});if((s[a]||(s[a]=new nr)).bind(m,this,l,x,c,n.vertexOffset,y,w),this.forceManualRenderingForInstanceIDShaders){const e=f||1;for(let i=0;i<e;++i)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",i),c?g.drawElements(t,n.primitiveLength*v,g.UNSIGNED_SHORT,n.primitiveOffset*v*2):g.drawArrays(t,n.vertexOffset,n.vertexLength);}else f&&f>1?g.drawElementsInstanced(t,n.primitiveLength*v,g.UNSIGNED_SHORT,n.primitiveOffset*v*2,f):c?g.drawElements(t,n.primitiveLength*v,g.UNSIGNED_SHORT,n.primitiveOffset*v*2):g.drawArrays(t,n.vertexOffset,n.vertexLength);b&&this._drawDebugWireframe(e,i,o,r,c,n,d,_,u,f);}}}function _n(t,i,o=0){const r=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,s=n*(i.tileID.canonical.x+i.tileID.wrap*r),a=n*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.aA(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a],u_pattern_transition:o}}const un={terrain:0,flat:1},pn=e.bb(),fn=(t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m,g,v,y=[0,0,1])=>{const x=i.style.light,b=x.properties.get("position"),w=[b.x,b.y,b.z],T=e.dE();"viewport"===x.properties.get("anchor")&&(e.dF(T,-i.transform.angle),e.dG(w,w,T));const E=x.properties.get("color").toPremultipliedRenderColor(null),S=i.transform,C={u_matrix:t,u_lightpos:w,u_lightintensity:x.properties.get("intensity"),u_lightcolor:[E.r,E.g,E.b],u_vertical_gradient:+o,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:pn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:un[h],u_base_type:un[d],u_ao:n,u_edge_radius:s,u_width_scale:a,u_flood_light_color:f,u_vertical_scale:m,u_flood_light_intensity:g,u_ground_shadow_factor:v,u_front_cutoff_params:y};return "globe"===S.projection.name&&(C.u_tile_id=[l.canonical.x,l.canonical.y,1<<l.canonical.z],C.u_zoom_transition=_,C.u_inv_rot_matrix=p,C.u_merc_center=u,C.u_up_dir=S.projection.upVector(new e.cn(0,0,0),u[0]*e.an,u[1]*e.an),C.u_height_lift=c),C},mn=(e,t,i,o,r,n)=>({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:o,u_height_type:un[r],u_base_type:un[n]}),gn=(e,t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m,g)=>{const v=fn(e,t,i,o,r,n,s,a,c,h,d,_,u,p,f,m,1,[0,0,0]),y={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(v,_n(t,l,g),y)},vn=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i}),yn=(e,t,i,o,r,n=0)=>Object.assign(vn(e,t,r),_n(i,o,n)),xn=(e,t,i,o)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:o}),bn=(e,t,i,o,r,n,s=0)=>Object.assign(yn(e,t,i,o,n,s),{u_world:r}),wn=(e,t)=>({u_matrix:e,u_depth_bias:t}),Tn=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),En=(e,t,i,o,r)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:o,u_reset_depth:r}),Sn=(e,t,i)=>({u_image:e,u_opacity:t,u_blend_mode:i}),Cn=(e,t,i,o,r,n,s,a,l,c=[0,0,1])=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:o,u_camera_pos:r,u_tile_to_meter:n,u_facade_emissive_chance:s,u_flood_light_color:a,u_flood_light_intensity:l,u_front_cutoff_params:c}),In=e=>({u_matrix:e}),Rn=e=>({u_matrix:e}),Dn=(t,i,o,r,n,s,a,l)=>{const c=e.an/s.tileSize;return {u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:o.getCameraToCenterDistance(l),u_extrude_scale:[o.pixelsToGLUnits[0]/c,o.pixelsToGLUnits[1]/c],u_zoom_transition:r,u_tile_id:a,u_merc_center:n}},An=(e,t,i,o)=>({u_matrix:e,u_inv_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(o),u_viewport_size:[i.width,i.height]}),Ln=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Pn=e.bb(),On=(t,i,o,r,n,s,a)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.dH(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.aA(o,1,s),d={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:a,u_inv_rot_matrix:Pn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){d.u_inv_rot_matrix=r,d.u_merc_center=n,d.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],d.u_zoom_transition=e.al(l.zoom);const t=n[0]*e.an,o=n[1]*e.an;d.u_up_dir=l.projection.upVector(new e.cn(0,0,0),t,o);}return d};function Mn(e,[t,i,o,r],[n,s]){if(n===s)return [0,0,0,0];const a=255*(e-1)/(e*(s-n));return [t*a,i*a,o*a,r*a]}function zn(e,t,[i,o]){return i===o?0:.5/e+(t-i)*(e-1)/(e*(o-i))}function Fn(t){const i=t.terrain?t.terrain.exaggeration():1;var o;return (t.transform.pitch<15?.07*(1-(o=e.aC((14-t.transform.zoom)/5,0,1)))+.7*o:.07)*i}const Bn=(t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m,g,v,y,x,b,w)=>({u_matrix:i,u_normalize_matrix:o,u_globe_matrix:r,u_merc_matrix:n,u_grid_matrix:s,u_tl_parent:a,u_scale_parent:d,u_fade_t:_.mix,u_opacity:_.opacity*u.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:u.paint.get("raster-brightness-min"),u_brightness_high:u.paint.get("raster-brightness-max"),u_saturation_factor:e.dJ(u.paint.get("raster-saturation")),u_contrast_factor:e.dI(u.paint.get("raster-contrast")),u_spin_weights:kn(u.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:l,u_merc_center:c,u_cutoff_params:h,u_colorization_mix:Mn(e.dK,g,y),u_colorization_offset:zn(e.dK,v,y),u_color_ramp:m,u_texture_offset:[b/(x+2*b),x/(x+2*b)],u_texture_res:[x+2*b,x+2*b],u_emissive_strength:w,u_zbias_factor:Fn(t)});function kn(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Nn=.05,Un=(e,t,i,o,r,n,s,a,l,c,h,d)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:o,u_grid_matrix:r,u_tl_parent:n,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:d,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Vn=(e,t,i,o,r,n,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:o,u_color_ramp:n,u_velocity_res:r,u_max_speed:s,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Nn,Nn]}),jn=(e,t,i,o,r,n,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:o,u_max_speed:r,u_speed_factor:n,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Nn,Nn]}),Gn=e.bb(),Zn=(t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m,g,v,y,x,b,w,T,E)=>{const S=n.transform,C={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:S.getCameraToCenterDistance(y),u_rotate_symbol:+o,u_aspect_ratio:S.width/S.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:d,u_texsize_icon:_,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Gn,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Gn,u_up_vector:[0,-1,0],u_color_adj_mat:w,u_icon_transition:T||0,u_gamma_scale:r?n.transform.getCameraToCenterDistance(y)*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:e.o.devicePixelRatio,u_is_halo:1,u_scale_factor:E||1,u_ground_shadow_factor:x,u_inv_matrix:e.b7(e.bb(),a),u_normal_scale:b,u_lutTexture:10,u_zoom:S.zoom-Math.floor(S.zoom),u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0]};return "globe"===y.name&&(C.u_tile_id=[p.canonical.x,p.canonical.y,1<<p.canonical.z],C.u_zoom_transition=f,C.u_inv_rot_matrix=g,C.u_merc_center=m,C.u_camera_forward=S._camera.forward(),C.u_ecef_origin=e.dL(S.globeMatrix,p.toUnwrapped()),C.u_tile_matrix=Float32Array.from(S.globeMatrix),C.u_up_vector=v),C},qn=(e,t,i,o)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:o}),Hn=(t,i,o,r,n,s,a,l,c)=>Object.assign(function(t,i,o,r,n,s){const{width:a,height:l}=r.imageManager.getPixelSize(i),c=Math.pow(2,s.tileID.overscaledZ),h=s.tileSize*Math.pow(2,r.transform.tileZoom)/c,d=h*(s.tileID.canonical.x+s.tileID.wrap*c),_=h*s.tileID.canonical.y;return {u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[a,l],u_pattern_size:o.displaySize,u_pattern_units_to_pixels:n?[r.transform.width,-1*r.transform.height]:[1/e.aA(s,1,r.transform.tileZoom),1/e.aA(s,1,r.transform.tileZoom)],u_pixel_coord_upper:[d>>16,_>>16],u_pixel_coord_lower:[65535&d,65535&_]}}(0,s,a,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:o}),Wn=new Float32Array(e.b9([])),$n=(t,i,o,r,n,s,a,l,c,h,d,_,u,p=[0,0,0],f,m,g)=>{const v=n.style.light,y=v.properties.get("position"),x=[-y.x,-y.y,y.z],b=e.dE();"viewport"===v.properties.get("anchor")&&(e.dF(b,-n.transform.angle),e.dG(x,x,b));const w="MASK"===d.alphaMode,T=v.properties.get("color").toNonPremultipliedRenderColor(null),E=u.paint.get("model-ambient-occlusion-intensity"),S=u.paint.get("model-color").constantOr(e.aq.white).toNonPremultipliedRenderColor(null);return S.a=u.paint.get("model-color-mix-intensity").constantOr(0),g&&(S.r=g[0],S.g=g[1],S.b=g[2],S.a=g[3]),m&&(S.r=m.color.r,S.g=m.color.g,S.b=m.color.b,S.a=m.colorMix,_=m.emissionStrength,s*=m.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:o,u_node_matrix:r||Wn,u_lightpos:x,u_lightintensity:v.properties.get("intensity"),u_lightcolor:[T.r,T.g,T.b],u_camera_pos:p,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+w,u_alphaCutoff:d.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:S.toArray01(),u_aoIntensity:E,u_emissive_strength:_,u_occlusionTextureTransform:f||[0,0,0,0]}},Xn=(e,t=Wn,i=Wn)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Yn={fillExtrusion:t=>({u_matrix:new e.b$(t),u_lightpos:new e.bY(t),u_lightintensity:new e.bZ(t),u_lightcolor:new e.bY(t),u_vertical_gradient:new e.bZ(t),u_opacity:new e.bZ(t),u_edge_radius:new e.bZ(t),u_width_scale:new e.bZ(t),u_ao:new e.b_(t),u_height_type:new e.bX(t),u_base_type:new e.bX(t),u_tile_id:new e.bY(t),u_zoom_transition:new e.bZ(t),u_inv_rot_matrix:new e.b$(t),u_merc_center:new e.b_(t),u_up_dir:new e.bY(t),u_height_lift:new e.bZ(t),u_flood_light_color:new e.bY(t),u_vertical_scale:new e.bZ(t),u_flood_light_intensity:new e.bZ(t),u_ground_shadow_factor:new e.bY(t),u_front_cutoff_params:new e.bY(t)}),fillExtrusionDepth:t=>({u_matrix:new e.b$(t),u_edge_radius:new e.bZ(t),u_width_scale:new e.bZ(t),u_vertical_scale:new e.bZ(t),u_height_type:new e.bX(t),u_base_type:new e.bX(t)}),fillExtrusionPattern:t=>({u_matrix:new e.b$(t),u_lightpos:new e.bY(t),u_lightintensity:new e.bZ(t),u_lightcolor:new e.bY(t),u_vertical_gradient:new e.bZ(t),u_height_factor:new e.bZ(t),u_edge_radius:new e.bZ(t),u_width_scale:new e.bZ(t),u_ao:new e.b_(t),u_height_type:new e.bX(t),u_base_type:new e.bX(t),u_tile_id:new e.bY(t),u_zoom_transition:new e.bZ(t),u_inv_rot_matrix:new e.b$(t),u_merc_center:new e.b_(t),u_up_dir:new e.bY(t),u_height_lift:new e.bZ(t),u_image:new e.bX(t),u_texsize:new e.b_(t),u_pixel_coord_upper:new e.b_(t),u_pixel_coord_lower:new e.b_(t),u_tile_units_to_pixels:new e.bZ(t),u_opacity:new e.bZ(t),u_pattern_transition:new e.bZ(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.b$(t),u_opacity:new e.bZ(t),u_ao_pass:new e.bZ(t),u_meter_to_tile:new e.bZ(t),u_ao:new e.b_(t),u_flood_light_intensity:new e.bZ(t),u_flood_light_color:new e.bY(t),u_attenuation:new e.bZ(t),u_edge_radius:new e.bZ(t),u_fb:new e.bX(t),u_fb_size:new e.bZ(t),u_dynamic_offset:new e.bZ(t)}),fill:t=>({u_matrix:new e.b$(t),u_emissive_strength:new e.bZ(t),u_ground_shadow_factor:new e.bY(t)}),fillPattern:t=>({u_matrix:new e.b$(t),u_emissive_strength:new e.bZ(t),u_image:new e.bX(t),u_texsize:new e.b_(t),u_pixel_coord_upper:new e.b_(t),u_pixel_coord_lower:new e.b_(t),u_tile_units_to_pixels:new e.bZ(t),u_ground_shadow_factor:new e.bY(t),u_pattern_transition:new e.bZ(t)}),fillOutline:t=>({u_matrix:new e.b$(t),u_emissive_strength:new e.bZ(t),u_world:new e.b_(t),u_ground_shadow_factor:new e.bY(t)}),fillOutlinePattern:t=>({u_matrix:new e.b$(t),u_emissive_strength:new e.bZ(t),u_world:new e.b_(t),u_image:new e.bX(t),u_texsize:new e.b_(t),u_pixel_coord_upper:new e.b_(t),u_pixel_coord_lower:new e.b_(t),u_tile_units_to_pixels:new e.bZ(t),u_ground_shadow_factor:new e.bY(t),u_pattern_transition:new e.bZ(t)}),lineBlendComposite:t=>({u_image:new e.bX(t),u_opacity:new e.bZ(t),u_blend_mode:new e.bX(t)}),building:t=>({u_matrix:new e.b$(t),u_normal_matrix:new e.b$(t),u_opacity:new e.bZ(t),u_faux_facade_ao_intensity:new e.bZ(t),u_camera_pos:new e.bY(t),u_tile_to_meter:new e.bZ(t),u_facade_emissive_chance:new e.bZ(t),u_flood_light_color:new e.bY(t),u_flood_light_intensity:new e.bZ(t),u_front_cutoff_params:new e.bY(t)}),buildingBloom:t=>({u_matrix:new e.b$(t)}),buildingDepth:t=>({u_matrix:new e.b$(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.b$(t),u_depth_bias:new e.bZ(t)}),elevatedStructures:t=>({u_matrix:new e.b$(t),u_ground_shadow_factor:new e.bY(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.b$(t),u_camera_pos:new e.bY(t),u_depth_bias:new e.bZ(t),u_height_scale:new e.bZ(t),u_reset_depth:new e.bZ(t)}),circle:e.dO,collisionBox:t=>({u_matrix:new e.b$(t),u_inv_rot_matrix:new e.b$(t),u_camera_to_center_distance:new e.bZ(t),u_extrude_scale:new e.b_(t),u_zoom_transition:new e.bZ(t),u_merc_center:new e.b_(t),u_tile_id:new e.bY(t)}),collisionCircle:t=>({u_matrix:new e.b$(t),u_inv_matrix:new e.b$(t),u_camera_to_center_distance:new e.bZ(t),u_viewport_size:new e.b_(t)}),debug:t=>({u_color:new e.dl(t),u_matrix:new e.b$(t),u_overlay:new e.bX(t),u_overlay_scale:new e.bZ(t)}),clippingMask:t=>({u_matrix:new e.b$(t)}),heatmap:t=>({u_extrude_scale:new e.bZ(t),u_intensity:new e.bZ(t),u_matrix:new e.b$(t),u_inv_rot_matrix:new e.b$(t),u_merc_center:new e.b_(t),u_tile_id:new e.bY(t),u_zoom_transition:new e.bZ(t),u_up_dir:new e.bY(t)}),heatmapTexture:t=>({u_image:new e.bX(t),u_color_ramp:new e.bX(t),u_opacity:new e.bZ(t)}),hillshade:t=>({u_matrix:new e.b$(t),u_image:new e.bX(t),u_latrange:new e.b_(t),u_light:new e.b_(t),u_shadow:new e.dl(t),u_highlight:new e.dl(t),u_emissive_strength:new e.bZ(t),u_accent:new e.dl(t)}),hillshadePrepare:t=>({u_matrix:new e.b$(t),u_image:new e.bX(t),u_dimension:new e.b_(t),u_zoom:new e.bZ(t)}),line:e.dN,linePattern:e.dM,raster:t=>({u_matrix:new e.b$(t),u_normalize_matrix:new e.b$(t),u_globe_matrix:new e.b$(t),u_merc_matrix:new e.b$(t),u_grid_matrix:new e.dm(t),u_tl_parent:new e.b_(t),u_scale_parent:new e.bZ(t),u_fade_t:new e.bZ(t),u_opacity:new e.bZ(t),u_image0:new e.bX(t),u_image1:new e.bX(t),u_brightness_low:new e.bZ(t),u_brightness_high:new e.bZ(t),u_saturation_factor:new e.bZ(t),u_contrast_factor:new e.bZ(t),u_spin_weights:new e.bY(t),u_perspective_transform:new e.b_(t),u_raster_elevation:new e.bZ(t),u_zoom_transition:new e.bZ(t),u_merc_center:new e.b_(t),u_cutoff_params:new e.cO(t),u_colorization_mix:new e.cO(t),u_colorization_offset:new e.bZ(t),u_color_ramp:new e.bX(t),u_texture_offset:new e.b_(t),u_texture_res:new e.b_(t),u_emissive_strength:new e.bZ(t),u_zbias_factor:new e.bZ(t)}),rasterParticle:t=>({u_matrix:new e.b$(t),u_normalize_matrix:new e.b$(t),u_globe_matrix:new e.b$(t),u_merc_matrix:new e.b$(t),u_grid_matrix:new e.dm(t),u_tl_parent:new e.b_(t),u_scale_parent:new e.bZ(t),u_fade_t:new e.bZ(t),u_opacity:new e.bZ(t),u_image0:new e.bX(t),u_image1:new e.bX(t),u_raster_elevation:new e.bZ(t),u_zoom_transition:new e.bZ(t),u_merc_center:new e.b_(t),u_cutoff_params:new e.cO(t)}),rasterParticleTexture:t=>({u_texture:new e.bX(t),u_opacity:new e.bZ(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.bX(t),u_particle_texture_side_len:new e.bZ(t),u_tile_offset:new e.b_(t),u_velocity:new e.bX(t),u_color_ramp:new e.bX(t),u_velocity_res:new e.b_(t),u_max_speed:new e.bZ(t),u_uv_offset:new e.b_(t),u_data_scale:new e.b_(t),u_data_offset:new e.bZ(t),u_particle_pos_scale:new e.bZ(t),u_particle_pos_offset:new e.b_(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.bX(t),u_particle_texture_side_len:new e.bZ(t),u_velocity:new e.bX(t),u_velocity_res:new e.b_(t),u_max_speed:new e.bZ(t),u_speed_factor:new e.bZ(t),u_reset_rate:new e.bZ(t),u_rand_seed:new e.bZ(t),u_uv_offset:new e.b_(t),u_data_scale:new e.b_(t),u_data_offset:new e.bZ(t),u_particle_pos_scale:new e.bZ(t),u_particle_pos_offset:new e.b_(t)}),symbol:t=>({u_is_size_zoom_constant:new e.bX(t),u_is_size_feature_constant:new e.bX(t),u_size_t:new e.bZ(t),u_size:new e.bZ(t),u_camera_to_center_distance:new e.bZ(t),u_rotate_symbol:new e.bX(t),u_aspect_ratio:new e.bZ(t),u_fade_change:new e.bZ(t),u_matrix:new e.b$(t),u_label_plane_matrix:new e.b$(t),u_coord_matrix:new e.b$(t),u_is_text:new e.bX(t),u_elevation_from_sea:new e.bX(t),u_pitch_with_map:new e.bX(t),u_texsize:new e.b_(t),u_texsize_icon:new e.b_(t),u_texture:new e.bX(t),u_texture_icon:new e.bX(t),u_gamma_scale:new e.bZ(t),u_device_pixel_ratio:new e.bZ(t),u_tile_id:new e.bY(t),u_zoom_transition:new e.bZ(t),u_inv_rot_matrix:new e.b$(t),u_merc_center:new e.b_(t),u_camera_forward:new e.bY(t),u_tile_matrix:new e.b$(t),u_up_vector:new e.bY(t),u_ecef_origin:new e.bY(t),u_is_halo:new e.bX(t),u_icon_transition:new e.bZ(t),u_color_adj_mat:new e.b$(t),u_scale_factor:new e.bZ(t),u_ground_shadow_factor:new e.bY(t),u_inv_matrix:new e.b$(t),u_normal_scale:new e.bZ(t),u_lutTexture:new e.bX(t),u_zoom:new e.bZ(t),u_spp_fill_np_color:new e.cO(t),u_spp_halo_np_color:new e.cO(t),u_spp_opacity:new e.bZ(t),u_spp_halo_width:new e.bZ(t),u_spp_halo_blur:new e.bZ(t),u_spp_emissive_strength:new e.bZ(t),u_spp_occlusion_opacity:new e.bZ(t),u_spp_z_offset:new e.bZ(t),u_spp_translate_rotation:new e.b_(t)}),background:t=>({u_matrix:new e.b$(t),u_emissive_strength:new e.bZ(t),u_opacity:new e.bZ(t),u_color:new e.dl(t)}),backgroundPattern:t=>({u_matrix:new e.b$(t),u_emissive_strength:new e.bZ(t),u_opacity:new e.bZ(t),u_image:new e.bX(t),u_pattern_tl:new e.b_(t),u_pattern_br:new e.b_(t),u_texsize:new e.b_(t),u_pattern_size:new e.b_(t),u_pixel_coord_upper:new e.b_(t),u_pixel_coord_lower:new e.b_(t),u_pattern_units_to_pixels:new e.b_(t)}),terrainRaster:t=>({u_matrix:new e.b$(t),u_image0:new e.bX(t),u_image1:new e.bX(t),u_skirt_height:new e.bZ(t),u_ground_shadow_factor:new e.bY(t),u_emissive_texture_available:new e.bZ(t)}),skybox:t=>({u_matrix:new e.b$(t),u_sun_direction:new e.bY(t),u_cubemap:new e.bX(t),u_opacity:new e.bZ(t),u_temporal_offset:new e.bZ(t)}),skyboxGradient:t=>({u_matrix:new e.b$(t),u_color_ramp:new e.bX(t),u_center_direction:new e.bY(t),u_radius:new e.bZ(t),u_opacity:new e.bZ(t),u_temporal_offset:new e.bZ(t)}),skyboxCapture:t=>({u_matrix_3f:new e.dm(t),u_sun_direction:new e.bY(t),u_sun_intensity:new e.bZ(t),u_color_tint_r:new e.cO(t),u_color_tint_m:new e.cO(t),u_luminance:new e.bZ(t)}),globeRaster:t=>({u_proj_matrix:new e.b$(t),u_globe_matrix:new e.b$(t),u_normalize_matrix:new e.b$(t),u_merc_matrix:new e.b$(t),u_zoom_transition:new e.bZ(t),u_merc_center:new e.b_(t),u_image0:new e.bX(t),u_image1:new e.bX(t),u_grid_matrix:new e.dm(t),u_skirt_height:new e.bZ(t),u_far_z_cutoff:new e.bZ(t),u_frustum_tl:new e.bY(t),u_frustum_tr:new e.bY(t),u_frustum_br:new e.bY(t),u_frustum_bl:new e.bY(t),u_globe_pos:new e.bY(t),u_globe_radius:new e.bZ(t),u_viewport:new e.b_(t),u_emissive_texture_available:new e.bZ(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bY(t),u_frustum_tr:new e.bY(t),u_frustum_br:new e.bY(t),u_frustum_bl:new e.bY(t),u_horizon:new e.bZ(t),u_transition:new e.bZ(t),u_fadeout_range:new e.bZ(t),u_atmosphere_fog_color:new e.cO(t),u_high_color:new e.cO(t),u_space_color:new e.cO(t),u_temporal_offset:new e.bZ(t),u_horizon_angle:new e.bZ(t)}),model:t=>({u_matrix:new e.b$(t),u_lighting_matrix:new e.b$(t),u_normal_matrix:new e.b$(t),u_node_matrix:new e.b$(t),u_lightpos:new e.bY(t),u_lightintensity:new e.bZ(t),u_lightcolor:new e.bY(t),u_camera_pos:new e.bY(t),u_opacity:new e.bZ(t),u_baseColorFactor:new e.cO(t),u_emissiveFactor:new e.cO(t),u_metallicFactor:new e.bZ(t),u_roughnessFactor:new e.bZ(t),u_baseTextureIsAlpha:new e.bX(t),u_alphaMask:new e.bX(t),u_alphaCutoff:new e.bZ(t),u_baseColorTexture:new e.bX(t),u_metallicRoughnessTexture:new e.bX(t),u_normalTexture:new e.bX(t),u_occlusionTexture:new e.bX(t),u_emissionTexture:new e.bX(t),u_lutTexture:new e.bX(t),u_color_mix:new e.cO(t),u_aoIntensity:new e.bZ(t),u_emissive_strength:new e.bZ(t),u_occlusionTextureTransform:new e.cO(t)}),modelDepth:t=>({u_matrix:new e.b$(t),u_instance:new e.b$(t),u_node_matrix:new e.b$(t)}),groundShadow:t=>({u_matrix:new e.b$(t),u_ground_shadow_factor:new e.bY(t)}),stars:t=>({u_matrix:new e.b$(t),u_up:new e.bY(t),u_right:new e.bY(t),u_intensity_multiplier:new e.bZ(t)}),snowParticle:t=>({u_modelview:new e.b$(t),u_projection:new e.b$(t),u_time:new e.bZ(t),u_cam_pos:new e.bY(t),u_velocityConeAperture:new e.bZ(t),u_velocity:new e.bZ(t),u_horizontalOscillationRadius:new e.bZ(t),u_horizontalOscillationRate:new e.bZ(t),u_boxSize:new e.bZ(t),u_billboardSize:new e.bZ(t),u_simpleShapeParameters:new e.b_(t),u_screenSize:new e.b_(t),u_thinningCenterPos:new e.b_(t),u_thinningShape:new e.bY(t),u_thinningAffectedRatio:new e.bZ(t),u_thinningParticleOffset:new e.bZ(t),u_particleColor:new e.cO(t),u_direction:new e.bY(t)}),rainParticle:t=>({u_modelview:new e.b$(t),u_projection:new e.b$(t),u_time:new e.bZ(t),u_cam_pos:new e.bY(t),u_texScreen:new e.bX(t),u_velocityConeAperture:new e.bZ(t),u_velocity:new e.bZ(t),u_boxSize:new e.bZ(t),u_rainDropletSize:new e.b_(t),u_distortionStrength:new e.bZ(t),u_rainDirection:new e.bY(t),u_color:new e.cO(t),u_screenSize:new e.b_(t),u_thinningCenterPos:new e.b_(t),u_thinningShape:new e.bY(t),u_thinningAffectedRatio:new e.bZ(t),u_thinningParticleOffset:new e.bZ(t),u_shapeDirectionalPower:new e.bZ(t),u_shapeNormalPower:new e.bZ(t),u_mode:new e.bZ(t)}),vignette:t=>({u_vignetteShape:new e.bY(t),u_vignetteColor:new e.cO(t)}),occlusion:t=>({u_matrix:new e.b$(t),u_anchorPos:new e.bY(t),u_screenSizePx:new e.b_(t),u_occluderSizePx:new e.b_(t),u_color:new e.cO(t)})};class Kn{constructor(e,t,i,o){this.id=Kn.uniqueIdxCounter,Kn.uniqueIdxCounter++,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||o||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=Kn.uniqueIdxCounter,Kn.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}Kn.uniqueIdxCounter=0;const Jn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Qn{constructor(e,t,i,o,r,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=o,this.instanceCount=n,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||r||t.destroy();}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(const i of this.attributes){const o=t.getAttributeLocation(e,i.name);-1!==o&&e.enableVertexAttribArray(o);}}setVertexAttribPointers(e,t,i){for(const o of this.attributes){const r=t.getAttributeLocation(e,o.name);if(-1!==r){const t=o.offset+this.itemSize*(i||0);"Float32"===o.type?e.vertexAttribPointer(r,o.components,e.FLOAT,!1,this.itemSize,t):e.vertexAttribIPointer(r,o.components,e[Jn[o.type]],this.itemSize,t);}}}setVertexAttribDivisor(e,t,i){for(let o=0;o<this.attributes.length;o++){const r=t.getAttributeLocation(e,this.attributes[o].name);-1!==r&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(r,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class es{constructor(e,t,i,o,r){this.context=e,this.width=t,this.height=i;const n=this.framebuffer=e.gl.createFramebuffer();o>0&&(this.colorAttachment0=new Gr(e,n,0)),o>1&&(this.colorAttachment1=new Gr(e,n,1)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new Zr(e,n):new qr(e,n));}static createWithTexture(t,i,o,r,n){const s=t.gl;if(t.activeTexture.set(s.TEXTURE1),t.viewport.set([0,0,o,r]),i&&i.width===o&&i.height===r)return s.bindTexture(s.TEXTURE_2D,i.colorAttachment0.get()),t.bindFramebuffer.set(i.framebuffer),i;i&&i.destroy();const a=new e.T(t,{width:o,height:r,data:null},t.extRenderToTextureHalfFloat?t.gl.RGBA16F:t.gl.RGBA8);a.bind(s.LINEAR,s.CLAMP_TO_EDGE);const l=t.createFramebuffer(o,r,1,null);if(l.colorAttachment0.set(a.texture),n){const e=t.createRenderbuffer(s.DEPTH24_STENCIL8,o,r);t.bindFramebuffer.set(l.framebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e),l._stencilRbo=e;}return l}createColorAttachment(e,t){0===t?this.colorAttachment0=new Gr(e,this.framebuffer,0):1===t&&(this.colorAttachment1=new Gr(e,this.framebuffer,1));}removeColorAttachment(e,t){const i=this.context.gl;let o;0===t?(o=this.colorAttachment0.get(),this.colorAttachment0=void 0):1===t&&(o=this.colorAttachment1.get(),this.colorAttachment1=void 0),o&&i.deleteTexture(o);}destroy(){const e=this.context.gl;if(this.colorAttachment0){const t=this.colorAttachment0.get();t&&e.deleteTexture(t);}if(this.colorAttachment1){const t=this.colorAttachment1.get();t&&e.deleteTexture(t);}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}else {const t=this.depthAttachment.get();t&&e.deleteTexture(t);}this._stencilRbo&&(e.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),e.deleteFramebuffer(this.framebuffer);}}class ts{constructor(e,t){this.gl=e,this.clearColor=new dr(this),this.clearDepth=new _r(this),this.clearStencil=new ur(this),this.colorMask=new pr(this),this.depthMask=new fr(this),this.stencilMask=new mr(this),this.stencilFunc=new gr(this),this.stencilOp=new vr(this),this.stencilTest=new yr(this),this.depthRange=new xr(this),this.depthTest=new br(this),this.depthFunc=new wr(this),this.blend=new Tr(this),this.blendFunc=new Er(this),this.blendColor=new Sr(this),this.blendEquation=new Cr(this),this.cullFace=new Ir(this),this.cullFaceSide=new Rr(this),this.frontFace=new Dr(this),this.program=new Ar(this),this.activeTexture=new Lr(this),this.viewport=new Pr(this),this.bindFramebuffer=new Or(this),this.bindRenderbuffer=new Mr(this),this.bindTexture=new zr(this),this.bindVertexBuffer=new Fr(this),this.bindElementBuffer=new Br(this),this.bindVertexArrayOES=new kr(this),this.pixelStoreUnpack=new Nr(this),this.pixelStoreUnpackPremultiplyAlpha=new Ur(this),this.pixelStoreUnpackFlipY=new Vr(this),this.options=t?Object.assign({},t):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&-1!==this.renderer.indexOf("PowerVR"),this.disableSymbolUBO=t&&!!t.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=e.getExtension("WEBGL_blend_func_extended");}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.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t,i){return new Kn(this,e,t,i)}createVertexBuffer(e,t,i,o,r){return new Qn(this,e,t,i,o,r)}createRenderbuffer(e,t,i){const o=this.gl,r=o.createRenderbuffer();return this.bindRenderbuffer.set(r),o.renderbufferStorage(o.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,o){return new es(this,e,t,i,o)}clear({color:e,depth:t,stencil:i,colorMask:o}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(o||[!0,!0,!0,!0])),void 0!==t&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n);}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace));}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1);}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1);}setColorMode(t){e.b6(t.blendFunction,Hi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}let is;function os(t,i,o,r,n,s,a){const l=t.context,c=l.gl,h=t.transform,d=[e.aH(h.center.lng),e.aL(h.center.lat)],_=o.layout.get("symbol-placement"),u=o.layout.get("text-variable-anchor"),p="map"===o.layout.get("icon-rotation-alignment"),f="map"===o.layout.get("text-rotation-alignment"),m="point"!==_,g=[];let v=0,y=0;for(let l=0;l<r.length;l++){const _=r[l],x=i.getTile(_),b=x.getBucket(o);if(!b)continue;const w=b.getProjection().createInversionMatrix(h,_.canonical),T=[],E=Kt(_,b,h),S=!a&&p&&m,C=a&&f&&m,I=u&&b.hasTextData(),R=b.hasIconTextFit()&&I&&b.hasIconData(),D=S||C||a&&I||R,A="globe"===b.projection.name,L=A?e.al(h.zoom):0;A&&(T.push("PROJECTION_GLOBE_VIEW"),D&&T.push("PROJECTED_POS_ON_VIEWPORT"));const P=t.getOrCreateProgram("collisionBox",{defines:T});let O=E;0===n[0]&&0===n[1]||(O=t.translatePosMatrix(E,x,n,s));const M=a?b.textCollisionBox:b.iconCollisionBox,z=b.collisionCircleArray;if(z.length>0){const t=e.bb(),i=O;e.cz(t,b.placementInvProjMatrix,h.glCoordMatrix),e.cz(t,t,b.placementViewportMatrix),g.push({circleArray:z,circleOffset:y,transform:i,invTransform:t,projection:b.getProjection()}),v+=z.length/4,y=v;}if(!M)continue;t.terrain&&t.terrain.setupElevationDraw(x,P);const F=A?[_.canonical.x,_.canonical.y,1<<_.canonical.z]:[0,0,0];P.draw(t,c.LINES,Wi.disabled,Xi.disabled,t.colorModeForRenderPass(),Ji.disabled,Dn(O,w,h,L,d,x,F,b.getProjection()),o.id,M.layoutVertexBuffer,M.indexBuffer,M.segments,null,h.zoom,null,[M.collisionVertexBuffer,M.collisionVertexBufferExt]);}if(!a||!g.length)return;const x=t.getOrCreateProgram("collisionCircle"),b=new e.dP;b.resize(4*v),b._trim();let w=0;for(const e of g)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,o=e.circleArray[i+0],r=e.circleArray[i+1],n=e.circleArray[i+2],s=e.circleArray[i+3];b.emplace(w++,o,r,n,s,0),b.emplace(w++,o,r,n,s,1),b.emplace(w++,o,r,n,s,2),b.emplace(w++,o,r,n,s,3);}(!is||is.length<2*v)&&(is=function(t){const i=2*t,o=new e.dC;o.resize(i),o._trim();for(let e=0;e<i;e++){const t=6*e;o.uint16[t+0]=4*e+0,o.uint16[t+1]=4*e+1,o.uint16[t+2]=4*e+2,o.uint16[t+3]=4*e+2,o.uint16[t+4]=4*e+3,o.uint16[t+5]=4*e+0;}return o}(v));const T=l.createIndexBuffer(is,!0),E=l.createVertexBuffer(b,e.dQ.members,!0);for(const i of g){const r=An(i.transform,i.invTransform,h,i.projection);x.draw(t,c.TRIANGLES,Wi.disabled,Xi.disabled,t.colorModeForRenderPass(),Ji.disabled,r,o.id,E,T,e.dy.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,h.zoom);}E.destroy(),T.destroy();}const rs=e.bb();function ns(t){const i=t._camera.getWorldToCamera(t.worldSize,1),o=e.aD([],i,t.globeMatrix);e.b7(o,o);const r=[0,0,0],n=[0,1,0,0];return e.aE(n,n,o),r[0]=n[0],r[1]=n[1],r[2]=n[2],e.ay(r,r),r}function ss({width:t,height:i,anchor:o,textOffset:r,textScale:n},s){const{horizontalAlign:a,verticalAlign:l}=e.bF(o),c=-(a-.5)*t,h=-(l-.5)*i,d=e.bG(o,r);return new e.P((c/n+d[0])*s,(h/n+d[1])*s)}function as(t,i,o,r,n,s,a,l,c,h){const d=t.text.placedSymbolArray,_=t.text.dynamicLayoutVertexArray,u=t.icon.dynamicLayoutVertexArray,p={},f=t.getProjection(),m=Jt(a,f,n),g=n.elevation,v=f.upVectorScale(a.canonical,n.center.lat,n.worldSize).metersToTile;_.clear();for(let u=0;u<d.length;u++){const y=d.get(u),{tileAnchorX:x,tileAnchorY:b,numGlyphs:w}=y,T=y.hidden||!y.crossTileID||t.allowVerticalPlacement&&!y.placedOrientation?null:r[y.crossTileID];if(T){let r=0,d=0,E=0;const S="road"===t.elevationType;if(g||S){const i=S?t.getElevationFeatureForText(u):null,o=e.bu.getAtTileOffset(a,new e.P(x,b),g,i),[n,s,l]=f.upVector(a.canonical,x,b);r=o*n*v,d=o*s*v,E=o*l*v;}let[C,I,R,D]=ni(y.projectedAnchorX+r,y.projectedAnchorY+d,y.projectedAnchorZ+E,o?m:s);const A=si(n.getCameraToCenterDistance(f),D);let L=e.bl(t.textSizeData,c,y)*A/e.by;o&&(L*=t.tilePixelRatio/l);const P=ss(T,L);o?(({x:C,y:I,z:R}=f.projectTilePoint(x+P.x,b+P.y,a.canonical)),[C,I,R]=ni(C+r,I+d,R+E,s)):(i&&P._rotate(-n.angle),C+=P.x,I+=P.y,R=0);const O=t.allowVerticalPlacement&&y.placedOrientation===e.bk.vertical?Math.PI/2:0;for(let t=0;t<w;t++)e.bn(_,C,I,R,O);h&&y.associatedIconIndex>=0&&(p[y.associatedIconIndex]={x:C,y:I,z:R,angle:O});}else fi(w,_);}if(h){u.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const o=i.get(t),{numGlyphs:r}=o,n=p[t];if(o.hidden||!n)fi(r,u);else {const{x:t,y:i,z:o,angle:s}=n;for(let n=0;n<r;n++)e.bn(u,t,i,o,s);}}t.icon.dynamicLayoutVertexBuffer.updateData(u);}t.text.dynamicLayoutVertexBuffer.updateData(_);}function ls(t,i,o,r,n,s,a={}){const l=o.paint.get("icon-translate"),c=o.paint.get("text-translate"),h=o.paint.get("icon-translate-anchor"),d=o.paint.get("text-translate-anchor"),_=o.layout.get("icon-rotation-alignment"),u=o.layout.get("text-rotation-alignment"),p=o.layout.get("icon-pitch-alignment"),f=o.layout.get("text-pitch-alignment"),m=o.layout.get("icon-keep-upright"),g=o.layout.get("text-keep-upright"),v=o.paint.get("icon-color-saturation"),y=o.paint.get("icon-color-contrast"),x=o.paint.get("icon-color-brightness-min"),b=o.paint.get("icon-color-brightness-max"),w="sea"===o.layout.get("symbol-elevation-reference"),T="none"===o.layout.get("icon-image-use-theme"),E=t.context,S=E.gl,C=t.transform,I="map"===_,R="map"===u,D="map"===p,A="map"===f,L=void 0!==o.layout.get("symbol-sort-key").constantOr(1);let P=!1;const O=t.depthModeForSublayer(0,Wi.ReadOnly),M=new Wi(t.context.gl.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D),z=[e.aH(C.center.lng),e.aL(C.center.lat)],F=o.layout.get("text-variable-anchor"),B="globe"===C.projection.name,k=[],N=[0,-1,0];for(const n of r){const r=i.getTile(n),s=r.getBucket(o);if(!s)continue;if("mercator"===s.projection.name&&B)continue;if(s.fullyClipped)continue;const _="globe"===s.projection.name,u=_?e.al(C.zoom):0,p=Jt(n,s.getProjection(),C),f=C.calculatePixelsToTileUnitsMatrix(r),U=F&&s.hasTextData(),V=s.hasIconTextFit()&&U&&s.hasIconData(),j=s.getProjection().createInversionMatrix(C,n.canonical),G=(1<<r.tileID.canonical.z)*e.an/t.transform.worldSize,Z=e=>{let i=[0,0,0];if(e){const e=t.style.directionalLight,o=t.style.ambientLight;e&&o&&(i=mo(t.style,e,o));}return i},q=e=>{if(t.context.disableSymbolUBO)return;e.push("USE_PAINT_PROPERTIES_UBO");const i=Math.floor(t.context.maxUniformBlockSize/4),o=Math.floor(i/4);e.push(`MAX_UBO_SIZE_VEC4 ${o}u`);},H=e=>{C.depthOcclusionForSymbolsAndCircles&&(o.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"));},W=i=>{o.lut&&!T&&(o.lut.texture||(o.lut.texture=new e.dR(t.context,o.lut.image,[o.lut.image.height,o.lut.image.height,o.lut.image.height],E.gl.RGBA8)),E.activeTexture.set(E.gl.TEXTURE0+10),o.lut.texture&&o.lut.texture.bind(E.gl.LINEAR,E.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"));},$=()=>{const i=I&&"point"!==o.layout.get("symbol-placement"),a=[];H(a),W(a);const c=i||V,d="road"===s.elevationType,g=t.shadowRenderer,T=d&&D&&!!g&&g.enabled,R=Z(T),A=d&&D&&!t.terrain?M:O,L=o.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&D&&a.push("PITCH_WITH_MAP_TERRAIN"),_&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),L>0&&s.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!s.icon.zOffsetVertexBuffer||d&&t.terrain||a.push("Z_OFFSET"),0===v&&0===y&&0===x&&1===b||a.push("COLOR_ADJUSTMENT"),s.sdfIcons&&a.push("RENDER_SDF"),T&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),d&&D&&!t.terrain&&s.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),q(a);const P=E.disableSymbolUBO?s.icon.programConfigurations.get(o.id):null,F=t.getOrCreateProgram("symbol",{config:P,defines:a}),k=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],U=s.iconSizeData,$=e.bj(U,C.zoom),X=D||!C.isOrthographic,Y=ii(p,r.tileID.canonical,D,I,C,s.getProjection(),f),K=ri(p,r.tileID.canonical,D,I,C,s.getProjection(),f),J=s.icon.uboBinder&&s.icon.uboBinder.cachedHeader&&256&s.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:l,Q=t.translatePosMatrix(K,r,J,h,!0),ee=t.translatePosMatrix(p,r,J,h),te=c?rs:Y,ie=I&&!D&&!i;let oe=N;!B&&!C.mercatorFromTransition||I||(oe=ns(C));const re=_?oe:N,ne=o.getColorAdjustmentMatrix(v,y,x,b),se=Zn(U.kind,$,ie,D,t,ee,te,Q,w,!1,k,[0,0],0,n,u,z,j,re,s.getProjection(),R,G,ne,L,null),ae=r.imageAtlasTexture?r.imageAtlasTexture:null,le=1!==o.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,ce=s.sdfIcons||t.options.rotating||t.options.zooming||le||X?S.LINEAR:S.NEAREST,he=s.sdfIcons&&0!==o.paint.get("icon-halo-width").constantOr(1),de=t.terrain&&D&&i?e.b7(e.bb(),Y):rs;if(i&&s.icon){const i=e.bu.getAtTileOffsetFunc(n,C.center.lat,C.worldSize,s.getProjection()),a=oi(p,r.tileID.canonical,D,I,C,s.getProjection(),f),l=o.layout.get("icon-size-scale-range"),c=e.aC(t.scaleFactor,l[0],l[1]);li(s,p,t,!1,a,K,D,m,i,n,c);}return {program:F,buffers:s.icon,uniformValues:se,atlasTexture:ae,atlasTextureIcon:null,atlasInterpolation:ce,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:he,depthMode:A,tile:r,renderWithShadows:T,labelPlaneMatrixInv:de}},X=()=>{const i=R&&"point"!==o.layout.get("symbol-placement"),a=[],l=i||F||V,h="road"===s.elevationType,m=t.shadowRenderer,v=h&&A&&!!m&&m.enabled,y=Z(v),x=h&&A&&!t.terrain?M:O;t.terrainRenderModeElevated()&&A&&a.push("PITCH_WITH_MAP_TERRAIN"),_&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!s.text.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),s.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),v&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),h&&A&&!t.terrain&&s.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),H(a),q(a);const b=E.disableSymbolUBO?s.text.programConfigurations.get(o.id):null,T=t.getOrCreateProgram("symbol",{config:b,defines:a});let I,D=[0,0],L=null;const P=s.textSizeData;s.iconsInText&&(D=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],L=r.imageAtlasTexture?r.imageAtlasTexture:null,I=A||!C.isOrthographic||t.options.rotating||t.options.zooming||"composite"===P.kind||"camera"===P.kind?S.LINEAR:S.NEAREST);const k=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],U=o.layout.get("text-size-scale-range"),W=e.aC(t.scaleFactor,U[0],U[1]),$=e.bj(P,C.zoom,W),X=ii(p,r.tileID.canonical,A,R,C,s.getProjection(),f),Y=ri(p,r.tileID.canonical,A,R,C,s.getProjection(),f),K=s.text.uboBinder&&s.text.uboBinder.cachedHeader&&256&s.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:c,J=t.translatePosMatrix(Y,r,K,d,!0),Q=t.translatePosMatrix(p,r,K,d),ee=l?rs:X,te=R&&!A&&!i;let ie=N;!B&&!C.mercatorFromTransition||R||(ie=ns(C));const oe=Zn(P.kind,$,te,A,t,Q,ee,J,w,!0,k,D,0,n,u,z,j,_?ie:N,s.getProjection(),y,G,null,null,W),re=r.glyphAtlasTexture?r.glyphAtlasTexture:null,ne=S.LINEAR,se=0!==o.paint.get("text-halo-width").constantOr(1),ae=t.terrain&&A&&i?e.b7(e.bb(),X):rs;if(i&&s.text){const i=e.bu.getAtTileOffsetFunc(n,C.center.lat,C.worldSize,s.getProjection()),o=oi(p,r.tileID.canonical,A,R,C,s.getProjection(),f);li(s,p,t,!0,o,Y,A,g,i,n,W);}return {program:T,buffers:s.text,uniformValues:oe,atlasTexture:re,atlasTextureIcon:L,atlasInterpolation:ne,atlasInterpolationIcon:I,isSDF:!0,hasHalo:se,depthMode:x,tile:r,renderWithShadows:v,labelPlaneMatrixInv:ae}},Y=s.icon.segments.get().length,K=s.text.segments.get().length,J=Y&&!a.onlyText?$():null,Q=K&&!a.onlyIcons?X():null,ee=o.paint.get("icon-opacity").constantOr(1),te=o.paint.get("text-opacity").constantOr(1);if(L&&s.canOverlap){P=!0;const t=ee&&!a.onlyText?s.icon.segments.get():[],i=te&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)k.push({segments:new e.dy([i]),sortKey:i.sortKey,state:J});for(const t of i)k.push({segments:new e.dy([t]),sortKey:t.sortKey,state:Q});}else a.onlyText||k.push({segments:ee?s.icon.segments:new e.dy([]),sortKey:0,state:J}),a.onlyIcons||k.push({segments:te?s.text.segments:new e.dy([]),sortKey:0,state:Q});}P&&k.sort((e,t)=>e.sortKey-t.sortKey);for(const e of k){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:C.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(C.depthOcclusionForSymbolsAndCircles,i.program),E.activeTexture.set(S.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,S.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(E.activeTexture.set(S.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,S.CLAMP_TO_EDGE,!0)),i.renderWithShadows&&t.shadowRenderer.setupShadows(i.tile.tileID.toUnwrapped(),i.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,cs(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,r,2),r.u_is_halo=0;}else {if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,cs(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,r,1)),r.u_is_halo=0;}cs(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,i.uniformValues,1);}}}function cs(e,t,i,o,r,n,s,a,l,c){const h=o.context,d=h.gl,_=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];e.featureIdBuffer&&_.push(e.featureIdBuffer);const u=e.uboBinder?null:e.programConfigurations.get(i.id);if(e.uboBinder){e.uboBinder.layer=i;const t=o.transform.zoom,r=o.style.getBrightness?o.style.getBrightness():null,n=e.uboBinder.getConstantUniformValues(t,r);l.u_spp_fill_np_color=n.fill_np_color,l.u_spp_halo_np_color=n.halo_np_color,l.u_spp_opacity=n.opacity,l.u_spp_halo_width=n.halo_width,l.u_spp_halo_blur=n.halo_blur,l.u_spp_emissive_strength=n.emissive_strength,l.u_spp_occlusion_opacity=n.occlusion_opacity,l.u_spp_z_offset=n.z_offset;const s=i.paint.get(e.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),a=e.uboBinder.cachedHeader&&256&e.uboBinder.cachedHeader.dataDrivenMask&&"map"===s?o.transform.angle:0;l.u_spp_translate_rotation=[Math.cos(a),Math.sin(a)];}const{batchIndices:p,batchSegments:f}=e.getBatchGrouping(t);for(const t of p){const p=f.get(t);e.uboBinder&&e.uboBinder.bind(h,r.program,t),r.draw(o,d.TRIANGLES,n,s,a,Ji.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,p,i.paint,o.transform.zoom,u,_,c);}}function hs(t,i,o,r,n,s){const a=o.paint.get("line-width"),l=o.paint.get("line-emissive-strength").isConstant(),c=o.paint.get("line-emissive-strength").constantOr(0),h=o.paint.get("line-occlusion-opacity"),d=o.layout.get("line-elevation-reference"),_="meters"===o.layout.get("line-width-unit"),u="sea"===d,p=!(!t.terrain||!t.terrain.enabled),f=t.context,m=f.gl;if(o.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const g=o.layout.get("line-cross-slope"),v=void 0!==g,y=g<1,x=n||t.colorModeForDrapableLayerRenderPass(l?c:null),b=t.terrain&&t.terrain.renderingToTexture||s,w=b?1:e.o.devicePixelRatio,T=o.paint.get("line-dasharray"),E=T.constantOr(1),S=o.layout.get("line-cap"),C=T.constantOr(null),I=S.constantOr(null),R=o.paint.get("line-pattern"),D=R.constantOr(1),A=o.paint.get("line-pattern-cross-fade"),L=R.constantOr(null),P=o.paint.get("line-opacity").constantOr(1);let O=!D&&1!==P||t.depthOcclusion&&h>0&&h<1;const M=o.paint.get("line-gradient"),z=D?"linePattern":"line",F=e.dU(o);let B;if(b&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(O=!1),0!==h&&t.depthOcclusion){const t=o.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?B=t.value:e.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`);}"constant"!==a.value.kind&&!1===a.value.isLineProgressConstant&&F.push("VARIABLE_LINE_WIDTH"),b&&("dual-source-blending"!==t.emissiveMode||l?"mrt-fallback"===t.emissiveMode&&F.push("USE_MRT1"):F.push("DUAL_SOURCE_BLENDING"));const k={},N=(r,n,s,a,l,c)=>{for(const d of r){const r=i.getTile(d);if(D&&!r.patternsLoaded())continue;const u=r.getBucket(o);if(!u)continue;if("none"!==u.elevationType&&!l||"none"===u.elevationType&&l)continue;t.prepareDrawTile();const p=[...n],g=t.shadowRenderer,v="road"===u.elevationType&&!!g&&g.enabled;let y=[0,0,0];if(v){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(y=mo(t.style,e,i)),p.push("RENDER_SHADOWS","NORMAL_OFFSET");}const T=u.programConfigurations.get(o.id);let S=!1;if(L&&r.imageAtlas){const t=e.dV.from(L),i=t.getPrimary().scaleSelf(w).toString(),o=r.imageAtlas.patternPositions.get(i),n=t.getSecondary(),s=n?r.imageAtlas.patternPositions.get(n.scaleSelf(w).toString()):null;S=!!o&&!!s,o&&T.setConstantPatternPositions(o,s);}A>0&&(S||T.getPatternTransitionVertexBuffer("line-pattern"))&&p.push("LINE_PATTERN_TRANSITION"),u.elevationGroundScaleVertexBuffer&&p.push("ELEVATION_GROUND_SCALE");const R=t.isTileAffectedByFog(d),F=t.getOrCreateProgram(z,{config:T,defines:p,overrideFog:R});if(!D&&C&&I&&r.lineAtlas){const e=r.lineAtlas.getDash(C,I);e&&T.setConstantPatternPositions(e);}v&&g.setupShadows(r.tileID.toUnwrapped(),F,"vector-tile");let[N,U]=o.paint.get("line-trim-offset");if("round"===I||"square"===I){const e=1;N!==U&&(0===N&&(N-=e),1===U&&(U+=e));}const V=b?d.projMatrix:null,j=_?1/u.tileToMeter/e.aA(r,1,t.transform.zoom):1,G=_?1/u.tileToMeter/e.aA(r,1,Math.floor(t.transform.zoom)):1,Z=E?o.paint._values["line-floorwidth"]:null;let q;if(Z&&"constant"===Z.value.kind){const e=u.zoom;e in k||(k[e]=Math.max(.01,o.widthExpression().evaluate({zoom:e}))),q=Z.value.value;const i=Math.floor(t.transform.zoom);Z.value.value=k[e]*Math.pow(2,i-r.tileID.overscaledZ);}const H=D?e.dW(t,r,o,V,w,j,G,[N,U],y,A):e.dX(t,r,o,V,u.lineClipsArray.length,w,j,G,[N,U],y);if(M){const r=u.gradients[o.id];let n=r.texture;if(o.gradientVersion!==r.version){let s=256;if(o.stepInterpolant){const o=i.getSource().maxzoom,r=d.canonical.z===o?Math.ceil(1<<t.transform.maxZoom-d.canonical.z):1;s=e.aC(e.dY(u.maxLineLength/e.an*1024*r),256,f.maxTextureSize);}r.gradient=e.dZ({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:s,image:r.gradient||void 0,clips:u.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new e.T(f,r.gradient,m.RGBA8),r.version=o.gradientVersion,n=r.texture;}f.activeTexture.set(m.TEXTURE1),n.bind(o.stepInterpolant?m.NEAREST:m.LINEAR,m.CLAMP_TO_EDGE);}E&&(f.activeTexture.set(m.TEXTURE0),r.lineAtlasTexture&&r.lineAtlasTexture.bind(m.LINEAR,m.REPEAT),T.updatePaintBuffers()),D&&(f.activeTexture.set(m.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(m.LINEAR,m.CLAMP_TO_EDGE),T.updatePaintBuffers()),l&&t.terrain.setupElevationDraw(r,F),t.uploadCommonUniforms(f,F,d.toUnwrapped());const W=e=>{null!=B&&(B.value=P*h),F.draw(t,m.TRIANGLES,s,e,x,Ji.disabled,H,o.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,o.paint,t.transform.zoom,T,[u.layoutVertexBuffer2,u.patternVertexBuffer,u.zOffsetVertexBuffer,u.elevationGroundScaleVertexBuffer]),null!=B&&(B.value=P);};if(O&&!l){const e=t.stencilModeForClipping(d).ref;0===e&&b&&f.clear({stencil:0});const i={func:m.EQUAL,mask:255};H.u_alpha_discard_threshold=.8,W(new Xi(i,e,255,m.KEEP,m.KEEP,m.INVERT)),H.u_alpha_discard_threshold=0,W(new Xi(i,e,255,m.KEEP,m.KEEP,m.KEEP));}else H.u_alpha_discard_threshold=O&&l&&c?.8:0,W(l?a:t.stencilModeForClipping(d));void 0!==q&&(Z.value.value=q);}};let U=t.depthModeForSublayer(0,Wi.ReadOnly);const V=new Wi(t.depthOcclusion?m.GREATER:m.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D);if(o.hasNonElevatedBuckets){const i=!b&&t.terrain;0!==h&&i?e.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?e.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${o.id}.`):N(r,F,U,Xi.disabled,!1,!0);}if(o.hasElevatedBuckets){"hd-road-markup"===d?p||(U=V,F.push("ELEVATED_ROADS")):(F.push("ELEVATED"),U=V,v&&F.push(y?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),u&&F.push("ELEVATION_REFERENCE_SEA"));const e=O?t.stencilModeFor3D():Xi.disabled;t.forceTerrainMode=!0,N(r,F,U,e,!0,!0),O&&N(r,F,U,e,!0,!1),t.forceTerrainMode=!1;}O&&(t.resetStencilClippingMasks(),b&&f.clear({stencil:0})),0===h||t.depthOcclusion||b||t.layersWithOcclusionOpacity.push(t.currentLayer);}const ds={additive:{clearColor:new e.aq(0,0,0,0),colorMode:Hi.additive,compositeUniformValue:1},multiply:{clearColor:new e.aq(1,1,1,1),colorMode:Hi.multiply,compositeUniformValue:0}};function _s(t,i){const o=1<<t.canonical.z,r=(i.x*o-t.canonical.x-t.wrap*o)*e.an,n=(i.y*o-t.canonical.y)*e.an,s=e.d_(i.z,i.y);return e.cQ(r,n,s)}function us(t,i,o,r,n){if(!o.layout||"none"===o.layout.get("fill-elevation-reference")||0===o.paint.get("fill-opacity").constantOr(1))return;const s=t.context.gl,a=new Wi(t.context.gl.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D),l=new Wi(t.context.gl.GREATER,Wi.ReadWrite,t.depthRangeFor3D),c=function(t){let i=.01;return t.isOrthographic&&(i=e.am(1e-4,i,e.cL(t.pitch>=so?1:t.pitch/so))),2*i}(t.transform),h=t.transform.getFreeCameraOptions().position,d="elevatedStructuresDepthReconstruct",_=t.getOrCreateProgram(d,{defines:["DEPTH_RECONSTRUCTION"]}),u=t.getOrCreateProgram(d);for(const e of r){const r=i.getTile(e),d=r.getBucket(o);if(!d)continue;const p=d.elevatedStructures;if(!p)continue;const f=d.elevationBufferData.heightRange,m=_s(e.toUnwrapped(),h),g=t.translatePosMatrix(e.projMatrix,r,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));let v,y,x,b;if("initialize"===n){if(!f||f.min>=1||0===p.depthSegments.segments[0].primitiveLength)continue;v=En(g,m,c,1,0),y=a,x=p.depthSegments,b=_;}else if("reset"===n){if(!f||f.min>=0||0===p.maskSegments.segments[0].primitiveLength)continue;v=En(g,m,0,0,1),y=l,x=p.maskSegments,b=_;}else if("geometry"===n){if(0===p.depthSegments.segments[0].primitiveLength)continue;v=En(g,m,c,1,0),y=a,x=p.depthSegments,b=u;}b.draw(t,s.TRIANGLES,y,Xi.disabled,Hi.disabled,Ji.disabled,v,o.id,p.vertexBuffer,p.indexBuffer,x,o.paint,t.transform.zoom);}}function ps(t,i,o,r){const{painter:n,sourceCache:s,layer:a,coords:l,colorMode:c,elevationType:h,terrainEnabled:d,pass:_}=t,u=n.context.gl,p=a.paint.get("fill-pattern"),f=a.paint.get("fill-pattern-cross-fade"),m=p.constantOr(null);let g=h;"road"!==h||i&&!d||(g="none");const v="road"===g,y=t.painter.shadowRenderer,x=v&&!!y&&y.enabled,b=new Wi(n.context.gl.LEQUAL,Wi.ReadOnly,n.depthRangeFor3D);let w=[0,0,0];if(x){const e=n.style.directionalLight,t=n.style.ambientLight;e&&t&&(w=mo(n.style,e,t));}const T=p&&p.constantOr(1),E=n.terrain&&n.terrain.renderingToTexture,S=(t,_)=>{let p,g,S,C,I;_?(p=T&&!a.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",S=u.LINES):(p=T?"fillPattern":"fill",S=u.TRIANGLES);for(const R of l){const l=s.getTile(R);if(T&&!l.patternsLoaded())continue;const D=l.getBucket(a);if(!D)continue;const A=i?D.elevationBufferData:D.bufferData;if(A.isEmpty())continue;n.prepareDrawTile();const L=A.programConfigurations.get(a.id),P=n.isTileAffectedByFog(R),O=[],M=[];v&&(O.push("ELEVATED_ROADS"),M.push(A.elevatedLayoutVertexBuffer)),x&&O.push("RENDER_SHADOWS","NORMAL_OFFSET"),E&&o&&O.push("USE_MRT1"),T&&(n.context.activeTexture.set(u.TEXTURE0),l.imageAtlasTexture&&l.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),L.updatePaintBuffers());let z=!1;if(m&&l.imageAtlas){const t=l.imageAtlas,i=e.dV.from(m),o=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),r=i.getSecondary(),n=t.patternPositions.get(o),s=r?t.patternPositions.get(r.scaleSelf(e.o.devicePixelRatio).toString()):null;z=!!n&&!!s,n&&L.setConstantPatternPositions(n,s);}f>0&&(z||L.getPatternTransitionVertexBuffer("fill-pattern"))&&O.push("FILL_PATTERN_TRANSITION");const F=n.getOrCreateProgram(p,{config:L,overrideFog:P,defines:O}),B=n.translatePosMatrix(R.projMatrix,l,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));x&&y.setupShadows(l.tileID.toUnwrapped(),F,"vector-tile");const k=a.paint.get("fill-emissive-strength");if(_){C=A.lineIndexBuffer,I=A.lineSegments;const e=n.terrain&&n.terrain.renderingToTexture?n.terrain.drapeBufferSize:[u.drawingBufferWidth,u.drawingBufferHeight];g="fillOutlinePattern"===p&&T?bn(B,k,n,l,e,w,f):xn(B,k,e,w);}else C=A.indexBuffer,I=A.triangleSegments,g=T?yn(B,k,n,l,w,f):vn(B,k,w);n.uploadCommonUniforms(n.context,F,R.toUnwrapped());let N=t;("road"===h&&!d||"offset"===h)&&(N=b),F.draw(n,S,N,r||n.stencilModeForClipping(R),c,Ji.disabled,g,a.id,A.layoutVertexBuffer,C,I,a.paint,n.transform.zoom,L,M);}};n.renderPass===_&&S(n.depthModeForSublayer(1,"opaque"===n.renderPass?Wi.ReadWrite:Wi.ReadOnly),!1),"none"===g&&"translucent"===n.renderPass&&a.paint.get("fill-antialias")&&S(n.depthModeForSublayer(a.getPaintProperty("fill-outline-color")?2:0,Wi.ReadOnly),!0);}function fs(t,i,o,r,n,s,a,l){o.resetLayerRenderingStats(t);const c=t.context,h=c.gl,d=t.transform,_=o.paint.get("fill-extrusion-pattern"),u=o.paint.get("fill-extrusion-pattern-cross-fade"),p=_.constantOr(null),f=_.constantOr(1),m=o.paint.get("fill-extrusion-opacity"),g=t.style.enable3dLights(),v=o.paint.get(g&&!f?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),v],x=o.layout.get("fill-extrusion-edge-radius"),b=x>0&&!o.paint.get("fill-extrusion-rounded-roof"),w=b?0:x,T="globe"===d.projection.name?e.e1():0,E="globe"===d.projection.name,S=E?e.al(d.zoom):0,C=[e.aH(d.center.lng),e.aL(d.center.lat)],I="none"===o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),R=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(I?null:o.lut).toArray01().slice(0,3),D=o.paint.get("fill-extrusion-flood-light-intensity"),A=o.paint.get("fill-extrusion-vertical-scale"),L=0!==o.paint.get("fill-extrusion-line-width").constantOr(1),P=o.paint.get("fill-extrusion-height-alignment"),O=o.paint.get("fill-extrusion-base-alignment"),M=lo(t,o.paint.get("fill-extrusion-cutoff-fade-range")),z=o.paint.get("fill-extrusion-front-cutoff"),F=gs(d.pitch,z,!!t.terrain),B=F[2]<1;B&&(t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,z[0]));const k=[];let N;E&&k.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&k.push("FAUX_AO"),b&&k.push("ZERO_ROOF_RADIUS"),l&&k.push("HAS_CENTROID"),D>0&&k.push("FLOOD_LIGHT"),M.shouldRenderCutoff&&k.push("RENDER_CUTOFF"),B&&k.push("RENDER_FRONT_CUTOFF"),L&&k.push("RENDER_WALL_MODE");const U="shadow"===t.renderPass,V=t.shadowRenderer,j=U&&!!V,G=U?Ji.disabled:Ji.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let Z=[0,0,0];if(V){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(Z=mo(t.style,e,i)),U||(k.push("RENDER_SHADOWS"),V.useNormalOffset&&k.push("NORMAL_OFFSET")),N=k.concat(["SHADOWS_SINGLE_CASCADE"]);}const q=j?"fillExtrusionDepth":f?"fillExtrusionPattern":"fillExtrusion",H=o.getLayerRenderingStats();for(const _ of r){const r=i.getTile(_),g=r.getBucket(o);if(!g||g.projection.name!==d.projection.name)continue;let v=!1;V&&(v=0===V.getMaxCascadeForTile(_.toUnwrapped()));const x=t.isTileAffectedByFog(_),b=g.programConfigurations.get(o.id);let I=!1;if(p&&r.imageAtlas){const t=r.imageAtlas,i=e.dV.from(p),o=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),n=i.getSecondary(),s=t.patternPositions.get(o),a=n?t.patternPositions.get(n.scaleSelf(e.o.devicePixelRatio).toString()):null;I=!!s&&!!a,s&&b.setConstantPatternPositions(s,a);}u>0&&(I||b.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&k.push("FILL_EXTRUSION_PATTERN_TRANSITION");const z=t.getOrCreateProgram(q,{config:b,defines:v?N:k,overrideFog:x});if(t.terrain&&t.terrain.setupElevationDraw(r,z,{useMeterToDem:!0}),!g.centroidVertexBuffer){const e=z.getAttributeLocation(h,"a_centroid_pos");-1!==e&&h.vertexAttribI4ui(e,0,0,0,0);}!U&&V&&V.setupShadows(r.tileID.toUnwrapped(),z,"vector-tile"),f&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers());const B=o.paint.get("fill-extrusion-vertical-gradient"),j=1/g.tileToMeter;let W;if(U&&V){if(Ts(r.tileID,g.maxHeight,t))continue;const e=V.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());W=mn(e,w,j,A,P,O);}else {const e=t.translatePosMatrix(_.expandedProjMatrix,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),i=d.projection.createInversionMatrix(d,_.canonical);W=f?gn(e,t,B,m,y,w,j,_,r,T,P,O,S,C,i,R,A,u):fn(e,t,B,m,y,w,j,_,T,P,O,S,C,i,R,A,D,Z,F);}t.uploadCommonUniforms(c,z,_.toUnwrapped(),null,M);let $=g.segments;if("mercator"===d.projection.name&&!U&&($=g.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!$.get().length))continue;if(H)if(U)for(const e of $.get())H.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of $.get())H.numRenderedVerticesInTransparentPass+=e.primitiveLength;const X=[];(t.terrain||l)&&X.push(g.centroidVertexBuffer),E&&X.push(g.layoutVertexExtBuffer),L&&X.push(g.wallVertexBuffer),z.draw(t,c.gl.TRIANGLES,n,s,a,G,W,o.id,g.layoutVertexBuffer,g.indexBuffer,$,o.paint,t.transform.zoom,b,X);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}class ms{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0;}}function gs(e,t,i){if(!(t[2]<1)||i)return [0,0,1];const o=180*e/Math.PI;if(o<15)return [-.5,t[1],t[2]];const r=Math.min(1,Math.max(0,(o-15)/5)),n=r*r*(3-2*r);return [-.5*(1-n)+t[0]*n,t[1],t[2]]}function vs(t,i,o,r,n,s,a,l,c,h,d,_,u,p,f,m,g,v,y,x,b){const w=i.context,T=w.gl,E=i.transform,S=i.transform.zoom,C=[],I=t.translate,R=t.translateAnchor,D=t.edgeRadius,A=lo(i,t.cutoffFadeRange);"clear"===d?(C.push("CLEAR_SUBPASS"),x&&(C.push("CLEAR_FROM_TEXTURE"),w.activeTexture.set(T.TEXTURE0),x.bind(T.LINEAR,T.CLAMP_TO_EDGE))):"sdf"===d?C.push("SDF_SUBPASS"):"emissive"===d&&(C.push("USE_MRT1"),w.activeTexture.set(T.TEXTURE0),x.bind(T.LINEAR,T.CLAMP_TO_EDGE)),v&&C.push("HAS_CENTROID"),A.shouldRenderCutoff&&C.push("RENDER_CUTOFF");const L=(e,t,o,n,d)=>{let y=C;null!=t.groundRadiusBuffer&&(y=C.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=t.programConfigurations.get(r.id),T=i.isTileAffectedByFog(e),E=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:y,overrideFog:T}),I=((e,t,i,o,r,n,s,a,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:o?1:0,u_meter_to_tile:r,u_ao:n,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h,u_dynamic_offset:1}))(0,n,_,h,d,[u,p*d],f,m,g,S>=17?0:D*d,x?x.size[0]:0),R=[];v&&R.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&R.push(t.groundRadiusBuffer),i.uploadCommonUniforms(w,E,e.toUnwrapped(),null,A),E.draw(i,w.gl.TRIANGLES,s,a,l,c,I,r.id,t.vertexBuffer,t.indexBuffer,o,r.paint,S,b,R);};for(const t of n){const n=o.getTile(t),s=n.getBucket(r);if(!s||s.projection.name!==E.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,n,I,R),o=a.getDefaultSegment();L(t,a,o,e,l);}if(y)for(let s=0;s<4;s++){const a=e.d$[s](t),c=o.getTile(a);if(!c)continue;const h=c.getBucket(r);if(!h||h.projection.name!==E.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const d=h.groundEffect;let _,u;0===s?(_=[-e.an,0,0],u=1):1===s?(_=[e.an,0,0],u=0):2===s?(_=[0,-e.an,0],u=3):(_=[0,e.an,0],u=2);const p=d.regionSegments[u];if(!p)continue;const f=new Float32Array(16);e.bx(f,t.projMatrix,_),L(t,d,p,i.translatePosMatrix(f,n,I,R),l);}}}function ys(t,i,o,r,n,s,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=s?s.findDEMTileFor(o):null;if(!(l&&l.dem||a))return;s&&l&&l.dem&&r.selfDEMTileTimestamp!==l.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=l.dem._timestamp);const c=(t,i)=>{(t.flags|i.flags)&e.e3?(t.flags|=e.e3,i.flags|=e.e3):(t.flags&=~e.e3,i.flags&=~e.e3);},h=t=>new e.P(Math.ceil((t+e.e4)*e.e5),0),d=(t,i,o)=>{const r=Math.ceil((t+e.e4)*e.e5),n=Math.floor(Math.max(0,Math.min(e.an-1,o))/4);return new e.P(r,n<<5|(3&i)<<3|7)},_=e=>{const t=i.getSource().minzoom,o=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(n)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i<t)continue;const r=o(e.calculateScaledKey(e.overscaledZ+i));if(r)return r}},u=[0,0,0],p=(t,i)=>(u[0]=Math.min(t.min.y,i.min.y),u[1]=Math.max(t.max.y,i.max.y),u[2]=e.an-i.min.x>t.max.x?i.min.x-e.an:t.max.x,u),f=(t,i)=>(u[0]=Math.min(t.min.x,i.min.x),u[1]=Math.max(t.max.x,i.max.x),u[2]=e.an-i.min.y>t.max.y?i.min.y-e.an:t.max.y,u),m=[(e,t)=>p(e,t),(e,t)=>p(t,e),(e,t)=>f(e,t),(e,t)=>f(t,e)],g=(t,i,r,n,a,c,h)=>{if(!s)return 0;const d=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],_=h<0?e.an+h:h,u=[c?_:(t+i)/2,c?(t+i)/2:_,0];return 0===r&&h<0||0!==r&&h>0?s.getForTilePoints(a,[u],!0,n):d.push(u),s.getForTilePoints(o,d,!0,l),Math.max(d[0][2],d[1][2],u[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const n=e.d$[t](o),l=_(n);if(!(l&&l instanceof e.e0))continue;const u=s?s.findDEMTileFor(n):null;if(!(u&&u.dem||a))continue;if(s&&u&&u.dem&&r.borderDEMTileTimestamp[t]!==u.dem._timestamp&&(r.borderDoneWithNeighborZ[t]=-1,r.borderDEMTileTimestamp[t]=u.dem._timestamp),r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const p=(t<2?1:5)-t,f=l.borderDoneWithNeighborZ[p]!==r.canonical.z,v=l.borderFeatureIndices[p];let y=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(f)for(const e of v)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[p]=r.canonical.z;continue}const x=new Map,b=new Set,w=new Set;for(let e=0;e<v.length;e++){const t=l.featuresOnBorder[v[e]];void 0!==t.buildingId&&x.set(t.buildingId,e);}for(const o of i){const i=r.featuresOnBorder[o],s=r.centroidData[i.centroidDataIndex];if(void 0===i.buildingId)continue;const h=x.get(i.buildingId);if(void 0===h)continue;const _=l.featuresOnBorder[v[h]],f=l.centroidData[_.centroidDataIndex];b.add(o),w.add(h),a&&c(s,f);const y=0!==s.groupCentroidPos.x||0!==s.groupCentroidPos.y?s.groupCentroidPos:i.centroid(),T=0!==f.groupCentroidPos.x||0!==f.groupCentroidPos.y?f.groupCentroidPos:_.centroid(),E=t<2?Math.round((y.y+T.y)/2):Math.round((y.x+T.x)/2),S=i.intersectsCount()>1||_.intersectsCount()>1;{let i=0;if(u&&u.dem&&!S){const o=m[t](s,f),r=t%2?e.an-1:0;i=g(o[0],Math.min(e.an-1,o[1]),r,u,n,t<2,o[2]);}s.centroidXY=d(i,t,E),f.centroidXY=d(i,p,E);}if(r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(f),void 0!==i.buildingId){for(const e of r.centroidData)e.buildingId===i.buildingId&&e!==s&&(e.centroidXY=s.centroidXY,r.writeCentroidToBuffer(e));for(const e of l.centroidData)e.buildingId===i.buildingId&&e!==f&&(e.centroidXY=f.centroidXY,l.writeCentroidToBuffer(e));}}for(const o of i){if(b.has(o))continue;const i=r.featuresOnBorder[o],s=r.centroidData[i.centroidDataIndex],d=i.borders[t];let _;for(;y<v.length;){if(w.has(y)){y++;continue}_=l.featuresOnBorder[v[y]];const e=_.borders[p];if(e[1]>d[0]+3||e[0]>d[0]-3)break;l.showCentroid(_),y++;}if(_&&y<v.length){let o=y,f=0;for(;;)if(w.has(y)){if(++y===v.length)break;_=l.featuresOnBorder[v[y]];}else {if(_.borders[p][0]>d[1]-3)break;if(f++,++y===v.length)break;_=l.featuresOnBorder[v[y]];}for(;o<v.length&&w.has(o);)o++;if(o>=v.length){r.showCentroid(i);continue}_=l.featuresOnBorder[v[o]];let x=!1;if(f>=1){const e=_.borders[p];Math.abs(d[0]-e[0])<3&&Math.abs(d[1]-e[1])<3&&(f=1,x=!0,y=o+1);}else if(0===f){r.showCentroid(i);continue}const b=l.centroidData[_.centroidDataIndex];a&&x&&c(s,b);const T=i.intersectsCount()>1||_.intersectsCount()>1;if(f>1)y=o,s.centroidXY=b.centroidXY=new e.P(0,0);else if(u&&u.dem&&!T){const i=m[t](s,b),o=t%2?e.an-1:0,r=g(i[0],Math.min(e.an-1,i[1]),o,u,n,t<2,i[2]);s.centroidXY=b.centroidXY=h(r);}else T?s.centroidXY=b.centroidXY=new e.P(0,0):(s.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(_));r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b);}else r.showCentroid(i);}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[p]=r.canonical.z;}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t);}const xs=[1,0,0],bs=[0,1,0],ws=[0,0,1];function Ts(t,i,o){const r=o.transform,n=o.shadowRenderer;if(!n)return !0;const s=t.toUnwrapped(),a=r.tileSize*n._cascades[o.currentShadowCascade].scale;let l=i;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(l+=e.max);}const c=r.scaleZoom(a);l/=e.e2(r.center.lat,c);const h=[...n.shadowDirection];h[2]=-h[2];const d=n.computeSimplifiedTileShadowVolume(s,l,a,h);if(!d)return !1;const _=[xs,bs,ws,h,[h[0],0,h[2]],[0,h[1],h[2]]],u=e.cl.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,c,!("globe"===r.projection.name)),p=n.getCurrentCascadeFrustum();return 0===u.intersectsPrecise(d.vertices,d.planes,_)||0===p.intersectsPrecise(d.vertices,d.planes,_)}function Es(t){const{painter:i,source:o,layer:r,coords:n}=t;let s=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,h=i.shadowRenderer,d=e.e2(i.transform.center.lat,i.transform.zoom),_=lo(i,r.paint.get("building-cutoff-fade-range"));_.shouldRenderCutoff&&(s=s.concat("RENDER_CUTOFF"));const u=r.paint.get("building-front-cutoff"),p=u[2]<1&&!i.terrain,f=gs(i.transform.pitch,u,!!i.terrain);p&&(s=s.concat("RENDER_FRONT_CUTOFF"),i.maxFrontCutoffRawStart=Math.max(i.maxFrontCutoffRawStart,u[0])),t.floodLightIntensity>0&&(s=s.concat("FLOOD_LIGHT"));for(const u of n){const n=o.getTile(u),p=n.getBucket(r);if(!p)continue;h&&0===h.getMaxCascadeForTile(u.toUnwrapped())&&(s=s.concat("SHADOWS_SINGLE_CASCADE"));const m=p.programConfigurations.get(r.id);let g,v,y,x=i.translatePosMatrix(u.expandedProjMatrix,n,[0,0],"map");if(x=e.cC(e.bb(),x,[1,1,t.verticalScale]),l&&h){if(Ts(n.tileID,p.maxHeight*d,i))continue;let o=h.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());o=e.cC(e.bb(),o,[1,1,t.verticalScale]),y=Rn(o),g=v=i.getOrCreateProgram("buildingDepth",{config:m,defines:s,overrideFog:!1});}else if(c)g=v=i.getOrCreateProgram("buildingBloom",{config:m,defines:s,overrideFog:!1}),y=In(x);else {const o=i.transform.calculatePosMatrix(u.toUnwrapped(),i.transform.worldSize);e.cC(o,o,[1,1,t.verticalScale]);const r=e.bb();e.cC(r,o,[1,-1,1/d]),e.b7(r,r),e.e6(r,r);const n=i.transform.getFreeCameraOptions().position,a=1<<u.canonical.z;if(y=Cn(x,r,t.opacity,t.facadeAOIntensity,[((n.x-u.wrap)*a-u.canonical.x)*e.an,(n.y*a-u.canonical.y)*e.an,n.z*a*e.an],p.tileToMeter,t.facadeEmissiveChance,t.floodLightColor,t.floodLightIntensity,f),v=i.getOrCreateProgram("building",{config:m,defines:s,overrideFog:!1}),!0===t.depthOnly)g=v;else {const e=s.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);g=i.getOrCreateProgram("building",{config:m,defines:e,overrideFog:!1});}h&&(h.setupShadowsFromMatrix(o,v,!0),g!==v&&h.setupShadowsFromMatrix(o,g,!0));}const b=(e,o)=>{if(c){const n=e.entranceBloom;o.draw(i,a.gl.TRIANGLES,t.depthMode,Xi.disabled,t.blendMode,Ji.disabled,y,r.id,n.layoutVertexBuffer,n.indexBuffer,n.segmentsBucket,r.paint,i.transform.zoom,m,[n.layoutAttenuationBuffer,n.layoutColorBuffer]);}else {const n=e.segmentsBucket;let s=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(s=s.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),o.draw(i,a.gl.TRIANGLES,t.depthMode,Xi.disabled,t.blendMode,l?Ji.disabled:Ji.backCW,y,r.id,e.layoutVertexBuffer,e.indexBuffer,n,r.paint,i.transform.zoom,m,s);}};i.uploadCommonUniforms(a,v,u.toUnwrapped(),null,_),p.buildingWithoutFacade&&b(p.buildingWithoutFacade,v),p.buildingWithFacade&&(g!==v&&i.uploadCommonUniforms(a,g,u.toUnwrapped(),null,_),b(p.buildingWithFacade,g));}}function Ss(t,i,o,r,n,s,a,l,c,h,d,_,u,p){const f=t.context.gl,m=t.depthModeForSublayer(1,Wi.ReadOnly,f.LEQUAL,!0),g=.1*(1-(v=d))+3*v;var v;const y=t._showOverdrawInspector,x=_,b=new ms;y||vs(b,t,i,o,r,m,new Xi({func:f.ALWAYS,mask:255},255,255,f.KEEP,f.KEEP,f.REPLACE),new Hi([f.ONE,f.ONE,f.ONE,f.ONE],e.aq.transparent,[!1,!1,!1,!0],f.MIN),Ji.disabled,n,"sdf",s,a,l,c,h,g,x,!1,void 0);{const d=y?Xi.disabled:new Xi({func:f.EQUAL,mask:255},255,255,f.KEEP,f.DECR,f.DECR),_=y?t.colorModeForRenderPass():new Hi([f.ONE_MINUS_DST_ALPHA,f.DST_ALPHA,f.ONE,f.ONE],e.aq.transparent,[!0,!0,!0,!0]);vs(b,t,i,o,r,m,d,_,Ji.disabled,n,"color",s,a,l,c,h,g,x,!1,void 0);}}function Cs(t){return [t[0]*e.e7,t[1]*e.e7,t[2]*e.e7,0]}function Is(t,i,o,r,n,s,a,l,c){const h=r.getSource(),d=o.globeSharedBuffers;if(!d)return;let _,u,p;if(i&&(_=r.getTile(i)),h instanceof e.aV?(u=h.texture,p=e.dw(0,0,o.transform)):_&&i&&(u=_.texture,p=e.dw(i.canonical.z,i.canonical.x,o.transform)),!u||!p)return;t||(p=e.cC(e.bb(),p,[1,-1,1]));const f=o.context,m=f.gl,g="nearest"===n.paint.get("raster-resampling")?m.NEAREST:m.LINEAR,v=o.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const x=new Wi(m.LEQUAL,Wi.ReadWrite,o.depthRangeFor3D),b=Float32Array.from(o.transform.expandedFarZProjMatrix),w=Float32Array.from(e.du(e.dv(new e.cn(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),f.activeTexture.set(m.TEXTURE0),u.bind(g,m.CLAMP_TO_EDGE),f.activeTexture.set(m.TEXTURE1),u.bind(g,m.CLAMP_TO_EDGE),"useMipmap"in u&&f.extTextureFilterAnisotropic&&o.transform.pitch>20&&m.texParameterf(m.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);const[T,E,S,C]=i?d.getPoleBuffers(i.canonical.z,!1):d.getPoleBuffers(0,!0),I=n.paint.get("raster-elevation");let R;t?(R=T,o.renderDefaultNorthPole=0!==I):(R=E,o.renderDefaultSouthPole=0!==I);const D=Cs(a.mix),A=((e,t,i,o,r,n,s,a,l,c,h,d,_,u)=>Bn(e,t,i,o,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},s,[0,0]||[0,0],l,2,h,d,_,1,0,u))(o,b,w,p,e.al(o.transform.zoom),0,n,0,I,0,D,a.offset,a.range,s),L=o.getOrCreateProgram("raster",{defines:y});o.uploadCommonUniforms(f,L,null),L.draw(o,m.TRIANGLES,x,c,v,l,A,n.id,R,S,C);}function Rs(e){if(e.isOrthographic)return [0,0,0,0];const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,n=t+r;return [t,i,(n-r-t)/o,(n-t)/o]}function Ds(e,t,i,o){if(e)return t instanceof Et&&e instanceof Ot?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:Cs(o.mix),offset:o.offset,buffer:0,tileSize:1}}var As=e.e8([{name:"a_index",type:"Int16",components:1}]);class Ls{constructor(t,i,o,r){const n={width:o[0],height:o[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,n,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,n,s.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,r),this.lastInvalidatedAt=0;}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const o=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,o.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,o.RGBA8,{premultiply:!1,useMipmap:!1});const n=new e.e9;n.reserve(r);for(let e=0;e<r;e++)n.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(n,As.members,!0),this.particleSegment=e.dy.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=i.width;}update(t){return !(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=e.o.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy();}}function Ps(t,i,o){if(!t)return null;const r=i.getTextureDescriptor(t,o,!0);if(!r)return null;let{texture:n,mix:s,offset:a,tileSize:l,buffer:c,format:h}=r;if(!n||!h)return null;let d=!1;return "uint32"===h&&(d=!0,s[3]=0,s=Mn(e.ea,s,[0,o.paint.get("raster-particle-max-speed")]),a=zn(e.ea,a,[0,o.paint.get("raster-particle-max-speed")])),{texture:n,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:d,scale:s,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[h]]}}function Os(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,n=t+r;return [t,i,(n-r-t)/o,(n-t)/o]}const Ms=new e.aq(1,0,0,1),zs=new e.aq(0,1,0,1),Fs=new e.aq(0,0,1,1),Bs=new e.aq(1,0,1,1),ks=new e.aq(0,1,1,1);function Ns(t,i,o,r,n,s){for(let a=0;a<o.length;a++)if(n){const n=1,l=.8,c=new e.aq(r.r*l,r.g*l,r.b*l,1);Us(t,i,o[a],r,-n,-n,s),Us(t,i,o[a],r,-n,n,s),Us(t,i,o[a],r,n,n,s),Us(t,i,o[a],r,n,-n,s),Us(t,i,o[a],c,0,0,s);}else Us(t,i,o[a],r,0,0,s);}function Us(t,i,o,r,n,s,a){const l=t.context,c=t.transform,h=l.gl,d="globe"===c.projection.name,_=d?["PROJECTION_GLOBE_VIEW"]:[];let u=e.b8(o.projMatrix);if(d&&e.al(c.zoom)>0){const t=e.ec(o.canonical,c),i=e.ed(t);u=e.aD(new Float32Array(16),c.globeMatrix,i),e.aD(u,c.projMatrix,u);}const p=e.bb();p[12]+=2*n/(e.o.devicePixelRatio*c.width),p[13]+=2*s/(e.o.devicePixelRatio*c.height),e.aD(u,p,u);const f=t.getOrCreateProgram("debug",{defines:_}),m=i.getTileByID(o.key);t.terrain&&t.terrain.setupElevationDraw(m,f);const g=Wi.disabled,v=Xi.disabled,y=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),d?m._makeGlobeTileDebugBuffers(t.context,c):m._makeDebugTileBoundsBuffers(t.context,c.projection);const b=m._tileDebugBuffer||t.debugBuffer,w=m._tileDebugIndexBuffer||t.debugIndexBuffer,T=m._tileDebugSegments||t.debugSegments;if(f.draw(t,h.LINE_STRIP,g,v,y,Ji.disabled,Ln(u,r.toPremultipliedRenderColor(null)),x,b,w,T,null,null,null,[m._globeTileDebugBorderBuffer]),a){const e=m.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(r+=` => ${o.overscaledZ}`),r+=` ${m.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,o=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);}(t,r);}const E=i.getTile(o).tileSize,S=512/Math.min(E,512)*(o.overscaledZ/c.zoom)*.5,C=m._tileDebugTextBuffer||t.debugBuffer,I=m._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,R=m._tileDebugTextSegments||t.debugSegments;f.draw(t,h.TRIANGLES,g,v,Hi.alphaBlended,Ji.disabled,Ln(u,e.aq.transparent.toPremultipliedRenderColor(null),S),x,C,I,R,null,null,null,[m._globeTileDebugTextBuffer]);}function Vs(e,t,i,o){Gs(e,0,t+i/2,e.transform.width,i,o);}function js(e,t,i,o){Gs(e,t-i/2,0,i,e.transform.height,o);}function Gs(t,i,o,r,n,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.o.devicePixelRatio,o*e.o.devicePixelRatio,r*e.o.devicePixelRatio,n*e.o.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST);}const Zs=e.e8([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:qs}=Zs;function Hs(e,t,i,o){e.emplaceBack(t,i,o);}class Ws{constructor(t){this.vertexArray=new e.ee,this.indices=new e.dC,Hs(this.vertexArray,-1,-1,1),Hs(this.vertexArray,1,-1,1),Hs(this.vertexArray,-1,1,1),Hs(this.vertexArray,1,1,1),Hs(this.vertexArray,-1,-1,-1),Hs(this.vertexArray,1,-1,-1),Hs(this.vertexArray,-1,1,-1),Hs(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,qs),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.dy.simpleSegment(0,0,36,12);}}function $s(t,i,o,r,n,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),d=((e,t,i,o,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[o.r,o.g,o.b,o.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.eg(e.dE(),r),n,h,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),o.draw(t,a.TRIANGLES,Wi.disabled,Xi.disabled,Hi.unblended,Ji.frontCW,d,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const Xs=e.e8([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Ys{constructor(t){const i=new e.eh;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const o=new e.dC;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Xs.members),this.indexBuffer=t.createIndexBuffer(o),this.segments=e.dy.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const Ks=e.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class Js{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200;}}class Qs{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Hi([1,qi,1,qi],e.aq.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Hi([1,0,1,0],e.aq.transparent,[!1,!1,!1,!0]),this.params=new Js,this.updateNeeded=!0;}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Ys(i);const t=this.params.sizeRange,o=this.params.intensityRange,r=function(t){const i=e.em(30),o=[];for(let r=0;r<t;++r){const t=2*Math.PI*i(),r=Math.acos(1-2*i())-.5*Math.PI;o.push(e.cQ(Math.cos(r)*Math.cos(t),Math.cos(r)*Math.sin(t),Math.sin(r)));}return o}(this.params.starsCount),n=e.em(300),s=new e.ei,a=new e.dC;let l=0;for(let i=0;i<r.length;++i){const c=e.bJ([],r[i],200),h=Math.max(0,1+.01*t*(1*n()-.5)),d=Math.max(0,1+.01*o*(1*n()-.5));s.emplaceBack(c[0],c[1],c[2],-1,-1,h,d),s.emplaceBack(c[0],c[1],c[2],1,-1,h,d),s.emplaceBack(c[0],c[1],c[2],1,1,h,d),s.emplaceBack(c[0],c[1],c[2],-1,1,h,d),a.emplaceBack(l+0,l+1,l+2),a.emplaceBack(l+0,l+2,l+3),l+=4;}this.starsVx=i.createVertexBuffer(s,Ks.members),this.starsIdx=i.createIndexBuffer(a),this.starsSegments=e.dy.simpleSegment(0,0,s.length,a.length);}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy();}drawAtmosphereGlow(t,i){const o=t.context,r=o.gl,n=t.transform,s=new Wi(r.LEQUAL,Wi.ReadOnly,[0,1]),a=e.al(n.zoom),l=t.style.getLut(i.scope),c="none"===i.properties.get("color-use-theme"),h=i.properties.get("color").toNonPremultipliedRenderColor(c?null:l),d="none"===i.properties.get("high-color-use-theme"),_=i.properties.get("high-color").toNonPremultipliedRenderColor(d?null:l),u="none"===i.properties.get("space-color-use-theme"),p=i.properties.get("space-color").toNonPremultipliedRenderColor(u?null:l),f=5e-4,m=e.ej(i.properties.get("horizon-blend"),0,1,f,.25),g=e.dp(t,o,n)&&m===f?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,v=t.frameCounter/1e3%1,y=e.ai(n.globeCenterInViewSpace),x=Math.sqrt(Math.pow(y,2)-Math.pow(g,2)),b=Math.acos(x/y),w=e=>{const i="globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,o,r,n,s,a,l,c,h,d)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:o,u_horizon:r,u_transition:n,u_fadeout_range:s,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:h,u_horizon_angle:d}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,a,m,h,_,p,v,b);t.uploadCommonUniforms(o,l);const d=this.atmosphereBuffer;d&&l.draw(t,r.TRIANGLES,s,Xi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Ji.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",d.vertexBuffer,d.indexBuffer,d.segments);};w(!1),w(!0);}drawStars(t,i){const o=e.aC(i.properties.get("star-intensity"),0,1);if(0===o)return;const r=t.context,n=r.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.bL([]);e.bN(l,l,-s._pitch),e.bM(l,l,-s.angle),e.bN(l,l,e.ap(s._center.lat)),e.ek(l,l,-e.ap(s._center.lng));const c=e.bR(new Float32Array(16),l),h=e.aD([],s.starsProjMatrix,c),d=e.eg([],c),_=e.el([],d),u=[0,1,0];e.dG(u,u,_),e.bJ(u,u,this.params.sizeMultiplier);const p=[1,0,0];e.dG(p,p,_),e.bJ(p,p,this.params.sizeMultiplier);const f=(m=u,g=p,v=o,{u_matrix:Float32Array.from(h),u_up:m,u_right:g,u_intensity_multiplier:v});var m,g,v;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,n.TRIANGLES,Wi.disabled,Xi.disabled,this.colorModeAlphaBlendedWriteRGB,Ji.disabled,f,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}class ea{constructor(){this.visibleTiles=[];}updateBorders(t,i){const o=[],r=[],n=t._getRenderableCoordinates(!1,!0);for(const e of n){const n=t.getTile(e);if(!n.hasData())continue;const s=n.getBucket(i);s&&(s.isEmpty()||(o.push(e.key),r.push({bucket:s,tileID:e.canonical})));}let s=o.length!==this.visibleTiles.length;if(!s){o.sort();for(let e=0;e<o.length;e++)if(o[e]!==this.visibleTiles[e]){s=!0;break}}if(!s)return;const a=new Set;this.visibleTiles=o,r.sort((e,t)=>e.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of r){const i=new Array,o=new Array,r=t.bucket;for(const e of r.featuresOnBorder)a.has(e.featureId)?o.push(e.footprintIndex):(a.add(e.featureId),i.push(e.footprintIndex));r.updateFootprintHiddenFlags(i,e.en,!1),r.updateFootprintHiddenFlags(o,e.en,!0);}}}function ta(t,i){const o=[...t],r=i.cameraWorldSizeForFog/i.worldSize,n=e.b9([]);return e.cC(n,n,[r,r,1]),e.aD(o,n,o),e.aD(o,i.worldToFogMatrix,o),o}function ia(t,i,o,r,n){const s=o.material,a=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:h,occlusionTexture:d,emissionTexture:_}=s;function u(e,i,o){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+o),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:o,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,o,r);}}u(l,"HAS_TEXTURE_u_baseColorTexture",5),u(c,"HAS_TEXTURE_u_metallicRoughnessTexture",6),u(h,"HAS_TEXTURE_u_normalTexture",7),u(d,"HAS_TEXTURE_u_occlusionTexture",8),u(_,"HAS_TEXTURE_u_emissionTexture",9),n&&(n.texture||(n.texture=new e.dR(r.context,n.image,[n.image.height,n.image.height,n.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+10),n.texture&&n.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),o.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(o.texcoordBuffer)),o.colorBuffer&&(t.push(12===o.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(o.colorBuffer)),o.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(o.normalBuffer)),o.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(o.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED");const p=r.shadowRenderer;p&&(t.push("RENDER_SHADOWS"),p.useNormalOffset&&t.push("NORMAL_OFFSET"));}function oa(t,i,o,r,n,s){const a=t.modelOpacity,l=i.context,c=new Wi(i.context.gl.LEQUAL,t.isLightMesh?Wi.ReadOnly:Wi.ReadWrite,i.depthRangeFor3D),h=i.transform,d=t.mesh,_=d.material,u=_.pbrMetallicRoughness,p=i.style.fog;let f;f="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.aD([],r.zScaleMatrix,t.nodeModelMatrix),e.aD(f,r.negCameraPosMatrix,f);const m=e.b7([],f);e.e6(m,m);const g="none"===o.paint.get("model-color-use-theme").constantOr("default"),v=o.paint.get("model-emissive-strength").constantOr(0),y=$n(new Float32Array(t.worldViewProjection),new Float32Array(f),new Float32Array(m),null,i,a,u.baseColorFactor,_.emissiveFactor,u.metallicFactor,u.roughnessFactor,_,v,o,void 0,void 0,t.materialOverride,t.modelColor),x={defines:[]},b=[],w=i.shadowRenderer;w&&(w.useNormalOffset=!1),ia(x.defines,b,d,i,g?null:o.lut);let T=null;if(p){const e=ta(t.nodeModelMatrix,i.transform);if(T=new Float32Array(e),"globe"!==h.projection.name){const t=d.aabb.min,i=d.aabb.max,[o,r]=p.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);x.overrideFog=o>=Ke||r>=Ke;}}const E=lo(i,o.paint.get("model-cutoff-fade-range"));E.shouldRenderCutoff&&x.defines.push("RENDER_CUTOFF");const S=i.getOrCreateProgram("model",x);i.uploadCommonUniforms(l,S,null,T,E),"shadow"!==i.renderPass&&w&&w.setupShadowsFromMatrix(t.nodeModelMatrix,S),S.draw(i,l.gl.TRIANGLES,c,n,s,d.material.doubleSided?Ji.disabled:Ji.backCCW,y,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,i.transform.zoom,void 0,b);}function ra(e,t){return e.style._importedAsBasemap?"basemap":t.scope}function na(t,i,o,r,n,s,a,l,c,h){const d=t.transform,_=!!i.isGeometryBloom&&i.isGeometryBloom;if(_&&"shadow"===t.renderPass)return;const u="globe"===d.projection.name?e.ev(o,d):[...o];e.aD(u,u,i.globalMatrix);const p=e.aD([],r,u);if(i.meshes)for(const t of i.meshes){const r=l.get(t.material.name);if(r&&r.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:n,worldViewProjection:p,nodeModelMatrix:u,isLightMesh:_,materialOverride:r,modelOpacity:c,modelColor:h,node:i,modelMatrix:o});continue}const f=e.ah([],t.centroid,p);!d.isOrthographic&&f[2]<=0||s.push({mesh:t,depth:f[2],modelIndex:n,worldViewProjection:p,nodeModelMatrix:u,isLightMesh:_,materialOverride:r,modelOpacity:c,modelColor:h,node:i,modelMatrix:o});}if(i.children)for(const e of i.children)na(t,e,o,r,n,s,a,l,c,h);}function sa(e,t,i,o){const r=i.shadowRenderer;if(!r)return;const n=r.getShadowPassDepthMode(),s=r.calculateShadowPassMatrixFromMatrix(t),a=Xn(s);i.getOrCreateProgram("modelDepth").draw(i,i.context.gl.TRIANGLES,n,Xi.disabled,Hi.disabled,Ji.disabled,a,o.id,e.vertexBuffer,e.indexBuffer,e.segments,o.paint,i.transform.zoom,void 0,void 0);}function aa(t,i,o,r){const n=function(t,i){if(i.footprintDebugMesh)return i.footprintDebugMesh;if(!i.footprint)return null;const o=t.context,r=i.footprint.vertices,n=i.footprint.indices,s=new e.dB;s.reserve(r.length);for(const e of r)s.emplaceBack(e.x,e.y);const a=new e.dC;a.reserve(n.length);for(let e=0;e<n.length;e+=3)a.emplaceBack(n[e],n[e+1],n[e+2]);const l=o.createVertexBuffer(s,e.dx.members),c=o.createIndexBuffer(a),h=e.dy.simpleSegment(0,0,r.length,n.length),d=i.id||i.name||"footprint";let _;const u=parseInt(d,10);_=isNaN(u)?function(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return t}(d):u;const p=e.eb(_),f=e.eb(_+1),m=e.eb(_+2);return i.footprintDebugMesh={vertexBuffer:l,indexBuffer:c,segments:h,color:new e.aq(p,f,m,.5)},i.footprintDebugMesh}(t,o);if(!n)return;const s=t.context,a=s.gl,l=t.getOrCreateProgram("debug"),c=n.color,h=Wi.disabled;s.activeTexture.set(a.TEXTURE0),t.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),l.draw(t,a.TRIANGLES,h,Xi.disabled,Hi.alphaBlended,Ji.disabled,Ln(r,c.toPremultipliedRenderColor(null)),"$debug",n.vertexBuffer,n.indexBuffer,n.segments);}function la(e,t,i,o,r,n){for(const s of r){const r=Object.assign({},o);r.part=s;const a={type:"Unknown",id:t,properties:r},l={orientation:e.paint.get("model-rotation").evaluate(a,i)};n.set(s,l);}}function ca(e,t,i,o,r,n){for(const s of r){const r=Object.assign({},o);r.part=s;const a={type:"Unknown",id:t,properties:r},l={color:e.paint.get("model-color").evaluate(a,i),colorMix:e.paint.get("model-color-mix-intensity").evaluate(a,i),opacity:e.paint.get("model-opacity").evaluate(a,i),emissionStrength:e.paint.get("model-emissive-strength").evaluate(a,i)};n.set(s,l);}}function ha(e,t,i,o,r){let n=!1;for(const i of o)1!==i.modelOpacity&&(oa(i,e,t,r[i.modelIndex],Xi.disabled,Hi.disabled),n=!0);for(const i of o)oa(i,e,t,r[i.modelIndex],1!==i.modelOpacity?e.stencilModeFor3D():Xi.disabled,e.colorModeForRenderPass());n&&e.resetStencilClippingMasks();const s=Hi.additive;for(const o of i)oa(o,e,t,r[o.modelIndex],Xi.disabled,o.isLightMesh?s:e.colorModeForRenderPass());}function da(t,i,o){const r=i.updateZoomBasedPaintProperties(),n=function(t,i,o){let r,n,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,n=i.findDEMTileFor(o);n&&n.dem?r=e.ex.create(i,o,n):a=0;}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===i.validForDEMTile.id&&r._dem._timestamp===i.validForDEMTile.timestamp))return !1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;e<t.instancedDataArray.length;++e){const o=(r?a*r.getElevationAt(0|t.instancedDataArray.float32[16*e],0|t.instancedDataArray.float32[16*e+1],!0,!0):0)+t.instancesEvaluatedElevation[e];t.instancedDataArray.float32[16*e+6]=o,n=n?Math.min(i.terrainElevationMin,o):o,s=s?Math.max(i.terrainElevationMax,o):o;}}return i.terrainElevationMin=n||0,i.terrainElevationMax=s||0,i.validForExaggeration=a,i.validForDEMTile=r&&r._demTile?{id:r._demTile.tileID,timestamp:r._dem._timestamp}:{id:void 0,timestamp:0},!0}(t,i,o);(r||n)&&(i.uploaded=!1,i.upload(t.context));}const _a={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new e.cU([0,0,0],[e.an,e.an,0])};function ua(t,i){const o=1<<t.canonical.z,r=i.getFreeCameraOptions().position,n=i.elevation,s=t.canonical.x/o,a=(t.canonical.x+1)/o,l=t.canonical.y/o,c=(t.canonical.y+1)/o;let h=i._centerAltitude;if(n){const e=n.getMinMaxForTile(t);e&&e.max>h&&(h=e.max);}const d=e.aC(r.x,s,a)-r.x,_=e.aC(r.y,l,c)-r.y,u=e.bU(h,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(d*d+_*_+u*u))}function pa(e,t,i,o,r,n,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new Wi(a.gl.LEQUAL,Wi.ReadWrite,e.depthRangeFor3D),d=e.isTileAffectedByFog(n),_="globe"===e.transform.projection.name;if(i.meshes)for(const u of i.meshes){const p=_?[]:["MODEL_POSITION_ON_GPU"],f=[];let m,g,v;const y=!_&&o.instancedDataArray.length>20;y&&p.push("INSTANCED_ARRAYS");const x=lo(e,t.paint.get("model-cutoff-fade-range"));if(x.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:p}),g=Xn(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.globalMatrix)),v=Hi.disabled;else {ia(p,f,u,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),m=e.getOrCreateProgram("model",{defines:p,overrideFog:d});const o=u.material,l=o.pbrMetallicRoughness,h=t.paint.get("model-opacity").constantOr(1),_=t.paint.get("model-emissive-strength").constantOr(0);g=$n(n.expandedProjMatrix,Float32Array.from(i.globalMatrix),new Float32Array(16),null,e,h,l.baseColorFactor,o.emissiveFactor,l.metallicFactor,l.roughnessFactor,o,_,t,r),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(n.toUnwrapped(),m,"model-tile"),s.shadowUniformsInitialized=!0)),v=x.shouldRenderCutoff||h<1||"OPAQUE"!==o.alphaMode?Hi.alphaBlended:Hi.unblended;}e.uploadCommonUniforms(a,m,n.toUnwrapped(),null,x);const b=u.material.doubleSided?Ji.disabled:Ji.backCCW;if(y)f.push(o.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,h,Xi.disabled,v,b,g,t.id,u.vertexBuffer,u.indexBuffer,u.segments,t.paint,e.transform.zoom,void 0,f,o.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let r=0;r<o.instancedDataArray.length;++r)g[i]=new Float32Array(o.instancedDataArray.arrayBuffer,64*r,16),m.draw(e,a.gl.TRIANGLES,h,Xi.disabled,v,b,g,t.id,u.vertexBuffer,u.indexBuffer,u.segments,t.paint,e.transform.zoom,void 0,f);}}if(i.children)for(const a of i.children)pa(e,t,a,o,r,n,s);}const fa=[1,-1,1];function ma(t,i,o,r){if(!o.modelManager)return !0;const n=o.modelManager;if(!o.shadowRenderer)return !0;const s=o.shadowRenderer,a=i.aabb;let l=!0,c=t.maxHeight;if(0===c){let e=0;for(const i in t.instancesPerModel){const t=n.getModel(i,r);t?e=Math.max(e,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1;}c=t.maxScale*e*1.41+t.maxVerticalOffset,l&&(t.maxHeight=c);}a.max[2]=c,a.min[2]+=t.terrainElevationMin,a.max[2]+=t.terrainElevationMax,e.ah(a.min,a.min,i.tileMatrix),e.ah(a.max,a.max,i.tileMatrix);const h=a.intersects(s.getCurrentCascadeFrustum());return 0===o.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===h),0===h}function ga(t,i){const o=t.uniformValues.u_cutoff_params[0],r=t.uniformValues.u_cutoff_params[1],n=t.uniformValues.u_cutoff_params[2],s=t.uniformValues.u_cutoff_params[3];return r===o||s===n?1:e.aC(((i-o)/(r-o)-n)/(s-n),0,1)}function va(t,i,o,r){if(i.pitch<20)return 1;const n=i.getWorldToCameraMatrix();e.aD(n,n,t);const s=e.bt(o.min[0],o.min[1],o.min[2],1);let a=e.aE(e.bE(),s,n),l=a,c=a;s[1]=o.max[1],a=e.aE(e.bE(),s,n),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c,s[0]=o.max[0],a=e.aE(e.bE(),s,n),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c,s[1]=o.min[1],a=e.aE(e.bE(),s,n),l=a[1]<l[1]?a:l,c=a[1]>c[1]?a:c;const h=e.aC(r[0],0,1),d=100*i.pixelsPerMeter*e.aC(r[1],0,1),_=e.aC(r[2],0,1),u=e.ey(e.bE(),l,c,h),p=Math.tan(.5*i.fovX),f=-u[2]*p;if(0===d)return u[1]<-Math.abs(f)?_:1;const m=(-Math.abs(f)-u[1])/d,g=(e,t,i)=>(1-i)*e+i*t,v=e.aC(g(1,_,m),_,1);return g(1,v,e.aC((i.pitch-20)/20,0,1))}class ya{}class xa{constructor(){this._storage=new Map;}getLinesFromTrianglesBuffer(t,i,o){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=o.gl,n=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),s=new ArrayBuffer(n),a=new Int16Array(s);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.eA;for(let e=0;e<n/2;e+=3){const t=a[e],i=a[e+1],o=a[e+2];l.emplaceBack(t,i),l.emplaceBack(i,o),l.emplaceBack(o,t);}const c=o.bindVertexArrayOES.current,h=new ya;return h.buf=new Kn(o,l),h.lastUsedFrameIdx=t,this._storage.set(i.id,h),o.bindVertexArrayOES.set(c),h.buf}update(e){for(const[t,i]of this._storage)e-i.lastUsedFrameIdx>30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}class ba{constructor(){this.occluderSize=30,this.depthOffset=-1e-4;}}const wa=e.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class Ta{constructor(e){this.revealStart=11,this.revealRange=2;}}const Ea=e.e8([{type:"Float32",name:"a_pos_2f",components:2}]);class Sa{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy();}draw(t,i){const o=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.eB,o=new e.dC;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,Ea.members),this.vignetteIdx=t.context.createIndexBuffer(o);}const r=e.dy.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,o);const e={u_vignetteShape:(n={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:n.vignetteColor};o.draw(t,t.context.gl.TRIANGLES,Wi.disabled,Xi.disabled,Hi.alphaBlended,Ji.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,r);}var n;}}class Ca{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;}update(t,i){const o=t.getFreeCameraOptions().position,r=o.toAltitude(),n=o.toLngLat(),s=e.ap(n.lng),a=e.ap(n.lat),l=t.pixelsPerMeter/i,c=s*e.eD,h=e.eD*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else {const e=-this._offsetYPrev+h,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=h,this._elevationPrev=r;}}getPosition(){return [this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Ia(e,t){return [-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function Ra(t){const i=e.em(1323123451230),o=[];for(let r=0;r<t;++r){const t=2*i()-1,r=2*i()-1,n=2*i()-1;o.push(e.cQ(t,r,n));}return o}function Da(t,i,o,r,n){const s=e.aC((n-o)/(r-o),0,1);return (1-s)*t+s*i}class Aa{constructor(e){this._movement=new Ca,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new Sa,this._ppmScaleFactor=e;}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy();}updateOnRender(t,i){const o=t.transform;this._movement.update(o,this._ppmScaleFactor);const r=o.starsProjMatrix,n=e.bL([]);e.bN(n,n,e.ap(90)-o._pitch),e.bM(n,n,-o.angle);const s=e.bR(new Float32Array(16),n),a=e.eC(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),l=e.e6([],a),c=e.aD([],l,s),h=Date.now()/1e3;return this._accumulatedTimeFromStart+=(h-this._prevTime)*i,this._prevTime=h,{projectionMatrix:r,modelviewMatrix:c}}}class La extends Aa{constructor(e){super(4.25),this._params={overrideStyleParameters:!1,intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._revealParams=new Ta("Precipitation > Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3;}update(t){const i=t.context;if(!this.particlesVx){const t=Ra(this.particlesCount),o=new e.eE,r=new e.dC;let n=0;const s=e.em(1323123451230);for(let e=0;e<t.length;++e){const i=t[e],a=[2*s()-1,s(),s(),s()];o.emplaceBack(i[0],i[1],i[2],-1,-1,...a),o.emplaceBack(i[0],i[1],i[2],1,-1,...a),o.emplaceBack(i[0],i[1],i[2],1,1,...a),o.emplaceBack(i[0],i[1],i[2],-1,1,...a),r.emplaceBack(n+0,n+1,n+2),r.emplaceBack(n+0,n+2,n+3),n+=4;}this.particlesVx=i.createVertexBuffer(o,wa.members),this.particlesIdx=i.createIndexBuffer(r);}}draw(t){if(!this._params.overrideStyleParameters&&!t.style.rain)return;const i=this._params.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},o=t.transform.zoom;if(i.revealStart>o)return;const r=Da(0,1,i.revealStart,i.revealStart+i.revealRange,o);if(!this.particlesVx||!this.particlesIdx)return;const n=structuredClone(this._params);let s=[-n.direction.x,n.direction.y,-100];e.ay(s,s);const a=structuredClone(this._vignetteParams);a.strength*=r,n.overrideStyleParameters||(n.intensity=t.style.rain.state.density,n.timeFactor=t.style.rain.state.intensity,n.color=structuredClone(t.style.rain.state.color),s=structuredClone(t.style.rain.state.direction),n.screenThinning.intensity=t.style.rain.state.centerThinning,n.dropletSizeX=t.style.rain.state.dropletSize[0],n.dropletSizeYScale=t.style.rain.state.dropletSize[1]/t.style.rain.state.dropletSize[0],n.distortionStrength=100*t.style.rain.state.distortionStrength,a.strength=1,a.color=structuredClone(t.style.rain.state.vignetteColor));const l=this.updateOnRender(t,n.timeFactor),c=t.context,h=c.gl,d=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(c,{width:t.width,height:t.height,data:null},h.RGBA8)),n.distortionStrength>0&&(c.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.copyTexSubImage2D(h.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const _=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(c,_),c.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE);const u=[n.color.r,n.color.g,n.color.b,n.color.a],p=(i,o)=>{const r=Ia(this._movement.getPosition(),i),a=n.dropletSizeX,c=n.dropletSizeX*n.dropletSizeYScale,p=t.width/2,f=t.height/2,m=Da(0,n.screenThinning.start,0,1,n.screenThinning.intensity),g=Da(.001,n.screenThinning.range,0,1,n.screenThinning.intensity),v=Da(0,n.screenThinning.particleOffset,0,1,n.screenThinning.intensity),y=(x={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:r,velocityConeAperture:n.velocityConeAperture,velocity:n.velocity,boxSize:i,rainDropletSize:[a,c],distortionStrength:n.distortionStrength,rainDirection:s,color:u,screenSize:[d.width,d.height],thinningCenterPos:[p,f],thinningShape:[m,g,Math.pow(10,n.screenThinning.fadePower)],thinningAffectedRatio:n.screenThinning.affectedRatio,thinningParticleOffset:v,shapeDirectionalPower:n.shapeDirPower,shapeNormalPower:n.shapeNormalPower,mode:o?0:1},{u_modelview:Float32Array.from(x.modelview),u_projection:Float32Array.from(x.projection),u_time:x.time,u_cam_pos:x.camPos,u_texScreen:0,u_velocityConeAperture:x.velocityConeAperture,u_velocity:x.velocity,u_boxSize:x.boxSize,u_rainDropletSize:x.rainDropletSize,u_distortionStrength:x.distortionStrength,u_rainDirection:x.rainDirection,u_color:x.color,u_screenSize:x.screenSize,u_thinningCenterPos:x.thinningCenterPos,u_thinningShape:x.thinningShape,u_thinningAffectedRatio:x.thinningAffectedRatio,u_thinningParticleOffset:x.thinningParticleOffset,u_shapeDirectionalPower:x.shapeDirectionalPower,u_shapeNormalPower:x.shapeNormalPower,u_mode:x.mode});var x;const b=Math.round(n.intensity*this.particlesCount),w=e.dy.simpleSegment(0,0,4*b,2*b);_.draw(t,h.TRIANGLES,Wi.disabled,Xi.disabled,Hi.alphaBlended,Ji.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,w);};n.distortionStrength>0&&p(n.boxSize,!0),p(n.boxSize,!1),this._vignette.draw(t,a);}}const Pa=e.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class Oa extends Aa{constructor(e){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new Ta("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3;}update(t){const i=t.context;if(!this.particlesVx){const t=Ra(this.particlesCount),o=new e.eF,r=new e.dC;let n=0;const s=e.em(1323123451230);for(let e=0;e<t.length;++e){const i=t[e],a=s(),l=s(),c=s(),h=[e/t.length,a,l,c],d=[s(),s()];o.emplaceBack(i[0],i[1],i[2],-1,-1,...h,...d),o.emplaceBack(i[0],i[1],i[2],1,-1,...h,...d),o.emplaceBack(i[0],i[1],i[2],1,1,...h,...d),o.emplaceBack(i[0],i[1],i[2],-1,1,...h,...d),r.emplaceBack(n+0,n+1,n+2),r.emplaceBack(n+0,n+2,n+3),n+=4;}this.particlesVx=i.createVertexBuffer(o,Pa.members),this.particlesIdx=i.createIndexBuffer(r);}}draw(t){if(!this._params.overrideStyleParameters&&!t.style.snow)return;const i=structuredClone(this._params);let o=[-i.direction.x,i.direction.y,-100];e.ay(o,o);const r=structuredClone(this._vignetteParams),n=i.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},s=t.transform.zoom;if(n.revealStart>s)return;const a=Da(0,1,n.revealStart,n.revealStart+n.revealRange,s);r.strength*=a,i.overrideStyleParameters||(i.intensity=t.style.snow.state.density,i.timeFactor=t.style.snow.state.intensity,i.color=structuredClone(t.style.snow.state.color),o=structuredClone(t.style.snow.state.direction),i.screenThinning.intensity=t.style.snow.state.centerThinning,i.billboardSize=2.79*t.style.snow.state.flakeSize,r.strength=1,r.color=structuredClone(t.style.snow.state.vignetteColor));const l=this.updateOnRender(t,i.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const c=t.context,h=c.gl,d=t.transform,_=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(c,_),((i,r,n)=>{const s=Ia(this._movement.getPosition(),i),a=d.width/2,c=d.height/2,u=Da(0,n.screenThinning.start,0,1,n.screenThinning.intensity),p=Da(.001,n.screenThinning.range,0,1,n.screenThinning.intensity),f=Da(0,n.screenThinning.particleOffset,0,1,n.screenThinning.intensity),m=(g={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:n.velocityConeAperture,velocity:n.velocity,horizontalOscillationRadius:n.horizontalOscillationRadius,horizontalOscillationRate:n.horizontalOscillationRate,boxSize:i,billboardSize:1*n.billboardSize,simpleShapeParameters:[n.shapeFadeStart,n.shapeFadePower],screenSize:[d.width,d.height],thinningCenterPos:[a,c],thinningShape:[u,p,Math.pow(10,n.screenThinning.fadePower)],thinningAffectedRatio:n.screenThinning.affectedRatio,thinningParticleOffset:f,color:[n.color.r,n.color.g,n.color.b,n.color.a],direction:o},{u_modelview:Float32Array.from(g.modelview),u_projection:Float32Array.from(g.projection),u_time:g.time,u_cam_pos:g.camPos,u_velocityConeAperture:g.velocityConeAperture,u_velocity:g.velocity,u_horizontalOscillationRadius:g.horizontalOscillationRadius,u_horizontalOscillationRate:g.horizontalOscillationRate,u_boxSize:g.boxSize,u_billboardSize:g.billboardSize,u_simpleShapeParameters:g.simpleShapeParameters,u_screenSize:g.screenSize,u_thinningCenterPos:g.thinningCenterPos,u_thinningShape:g.thinningShape,u_thinningAffectedRatio:g.thinningAffectedRatio,u_thinningParticleOffset:g.thinningParticleOffset,u_particleColor:g.color,u_direction:g.direction});var g;const v=Math.round(n.intensity*this.particlesCount),y=e.dy.simpleSegment(0,0,4*v,2*v);this.particlesVx&&this.particlesIdx&&_.draw(t,h.TRIANGLES,Wi.disabled,Xi.disabled,Hi.alphaBlended,Ji.disabled,m,"snow_particles",this.particlesVx,this.particlesIdx,y);})(i.boxSize,0,i),this._vignette.draw(t,r);}}const Ma={symbol:function(t,i,o,r,n){if("translucent"!==t.renderPass)return;const s=Xi.disabled,a=t.colorModeForRenderPass(),l=o.layout.get("text-variable-anchor"),c=o.layout.get("text-size-scale-range"),h=e.aC(t.scaleFactor,c[0],c[1]);l&&function(t,i,o,r,n,s,a,l){const c=i.transform,h="map"===n,d="map"===s;for(const i of t){const t=r.getTile(i),n=t.getBucket(o);if(!n||!n.text||!n.text.segments.get().length)continue;const s=e.bj(n.textSizeData,c.zoom,l),_=Jt(i,n.getProjection(),c),u=c.calculatePixelsToTileUnitsMatrix(t),p=ii(_,t.tileID.canonical,d,h,c,n.getProjection(),u),f=n.hasIconTextFit()&&n.hasIconData();s&&as(n,h,d,a,c,p,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),s,f);}}(r,t,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),n,h);const d=0!==o.paint.get("icon-opacity").constantOr(1),_=0!==o.paint.get("text-opacity").constantOr(1);void 0!==o.layout.get("symbol-sort-key").constantOr(1)&&(d||_)?ls(t,i,o,r,s,a):(d&&ls(t,i,o,r,s,a,{onlyIcons:!0}),_&&ls(t,i,o,r,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(os(t,i,o,r,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),os(t,i,o,r,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1));},circle:function(t,i,o,r){if("translucent"!==t.renderPass)return;const n=o.paint.get("circle-opacity"),s=o.paint.get("circle-stroke-width"),a=o.paint.get("circle-stroke-opacity"),l=void 0!==o.layout.get("circle-sort-key").constantOr(1),c=o.paint.get("circle-emissive-strength");if(0===n.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const h=t.context,d=h.gl,_=t.transform,u=!(!t.terrain||!t.terrain.enabled),p=o.layout.get("circle-elevation-reference"),f=t.depthModeForSublayer(0,Wi.ReadOnly),m=new Wi(t.context.gl.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D),g="none"===p||u?f:m,v=Xi.disabled,y=t.colorModeForDrapableLayerRenderPass(c),x="globe"===_.projection.name,b=[e.aH(_.center.lng),e.aL(_.center.lat)],w=[];for(let n=0;n<r.length;n++){const s=r[n],a=i.getTile(s),c=a.getBucket(o);if(!c||c.projection.name!==_.projection.name)continue;const h=c.programConfigurations.get(o.id),d=c.layoutVertexBuffer,u=c.globeExtVertexBuffer,p=c.indexBuffer,f=e.dS(o),m=[u],g=t.isTileAffectedByFog(s);x&&f.push("PROJECTION_GLOBE_VIEW"),f.push("DEPTH_D24"),t.terrain&&_.depthOcclusionForSymbolsAndCircles&&f.push("DEPTH_OCCLUSION"),c.hasElevation&&!t.terrain&&(f.push("ELEVATED_ROADS"),m.push(c.elevatedLayoutVertexBuffer));const v=t.getOrCreateProgram("circle",{config:h,defines:f,overrideFog:g}),y=_.projection.createInversionMatrix(_,s.canonical),T={programConfiguration:h,program:v,layoutVertexBuffer:d,dynamicBuffers:m,indexBuffer:p,uniformValues:e.dT(t,s,a,y,b,o),tile:a};if(l){const t=c.segments.get();for(const i of t)w.push({segments:new e.dy([i]),sortKey:i.sortKey,state:T});}else w.push({segments:c.segments,sortKey:0,state:T});}l&&w.sort((e,t)=>e.sortKey-t.sortKey);const T={useDepthForOcclusion:_.depthOcclusionForSymbolsAndCircles};for(const e of w){const{programConfiguration:i,program:r,layoutVertexBuffer:n,dynamicBuffers:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,u=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,T),t.uploadCommonUniforms(h,r,c.tileID.toUnwrapped()),r.draw(t,d.TRIANGLES,g,v,y,Ji.disabled,l,o.id,n,a,u,o.paint,_.zoom,i,s);}},heatmap:function(t,i,o,r){if(0!==o.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const n=t.context,s=n.gl,a=Xi.disabled,l=new Hi([s.ONE,s.ONE,s.ONE,s.ONE],e.aq.transparent,[!0,!0,!0,!0]),c="globe"===t.transform.projection.name?.5:.25;o.heatmapFbo=es.createWithTexture(n,o.heatmapFbo,t.width*c,t.height*c),n.clear({color:e.aq.transparent});const h=t.transform,d="globe"===h.projection.name,_=d?["PROJECTION_GLOBE_VIEW"]:[],u=d?Ji.frontCCW:Ji.disabled,p=[e.aH(h.center.lng),e.aL(h.center.lat)];for(let e=0;e<r.length;e++){const c=r[e];if(i.hasRenderableParent(c))continue;const f=i.getTile(c),m=f.getBucket(o);if(!m||m.projection.name!==h.projection.name)continue;const g=t.isTileAffectedByFog(c),v=m.programConfigurations.get(o.id),y=t.getOrCreateProgram("heatmap",{config:v,defines:_,overrideFog:g}),{zoom:x}=t.transform;t.terrain&&t.terrain.setupElevationDraw(f,y),t.uploadCommonUniforms(n,y,c.toUnwrapped());const b=h.projection.createInversionMatrix(h,c.canonical);y.draw(t,s.TRIANGLES,Wi.disabled,a,l,u,On(t,c,f,b,p,x,o.paint.get("heatmap-intensity")),o.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,o.paint,t.transform.zoom,v,d?[m.globeExtVertexBuffer]:null);}n.viewport.set([0,0,t.width,t.height]);}else "translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){const o=t.context,r=o.gl,n=i.heatmapFbo;if(!n)return;o.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment0.get()),o.activeTexture.set(r.TEXTURE1);let s=i.colorRampTexture;s||(s=i.colorRampTexture=new e.T(o,i.colorRamp,r.RGBA8)),s.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.getOrCreateProgram("heatmapTexture").draw(t,r.TRIANGLES,Wi.disabled,Xi.disabled,t.colorModeForRenderPass(),Ji.disabled,((e,t)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom);}(t,o));},line:function(e,t,i,o){const r=i.paint.get("line-opacity"),n=i.paint.get("line-width");if(0===r.constantOr(1)||0===n.constantOr(1))return;const s=i.paint.get("line-blend-mode");if("default"!==s&&"globe"!==e.transform.projection.name)return e.terrain&&e.terrain.renderingToTexture?void function(e,t,i,o,r){if("translucent"!==e.renderPass)return;const n=e.context,s=n.gl,a=e.terrain;if(!a)return;const l=n.bindFramebuffer.current,c="mrt-fallback"===e.emissiveMode;i.lineBlendDrapeFbo=es.createWithTexture(n,i.lineBlendDrapeFbo,a.drapeBufferSize[0],a.drapeBufferSize[1],!0),i.lineBlendDrapeStencil=i.lineBlendDrapeFbo._stencilRbo,c&&s.drawBuffers([s.COLOR_ATTACHMENT0]),n.clear({color:ds[r].clearColor,depth:1,stencil:0});const h=e.currentStencilSource,d=e._tileClippingMaskIDs,_=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1;const u=e._terrain;e._terrain=null,e._renderTileClippingMasks(i,t,o),hs(e,t,i,o,ds[r].colorMode,!0),e._terrain=u,e.currentStencilSource=h,e._tileClippingMaskIDs=d,e.nextStencilID=_,n.bindFramebuffer.set(l),c&&s.drawBuffers([s.COLOR_ATTACHMENT0,s.COLOR_ATTACHMENT1]);const p=a.drapeBufferSize;n.viewport.set([0,0,p[0],p[1]]);const f=i.lineBlendDrapeFbo;if(!f)return;n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,f.colorAttachment0.get());const m="additive"===r?1:i.paint.get("line-opacity").constantOr(1),g=i.paint.get("line-emissive-strength").constantOr(0),v="additive"===r?e.colorModeForDrapableLayerRenderPass(g):ds[r].colorMode;e.getOrCreateProgram("lineBlendComposite").draw(e,s.TRIANGLES,Wi.disabled,Xi.disabled,v,Ji.disabled,Sn(0,m,ds[r].compositeUniformValue),i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom);}(e,t,i,o,s):"offscreen"===e.renderPass?void function(e,t,i,o,r){const n=e.context,s=Math.ceil(e.width),a=Math.ceil(e.height);i.lineBlendFbo=es.createWithTexture(n,i.lineBlendFbo,s,a,!0),i.lineBlendStencil=i.lineBlendFbo._stencilRbo,n.clear({color:ds[r].clearColor,depth:1,stencil:0});const l=e.currentStencilSource,c=e._tileClippingMaskIDs,h=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1,e._renderTileClippingMasks(i,t,o);const d=e.renderPass;e.renderPass="translucent",hs(e,t,i,o,ds[r].colorMode),e.renderPass=d,e.currentStencilSource=l,e._tileClippingMaskIDs=c,e.nextStencilID=h,n.viewport.set([0,0,e.width,e.height]);}(e,t,i,o,s):"translucent"===e.renderPass?void function(e,t,i){const o=e.context,r=o.gl,n=t.lineBlendFbo;if(!n)return;o.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment0.get());const s="additive"===i?1:t.paint.get("line-opacity").constantOr(1),a="additive"===i?e.colorModeForDrapableLayerRenderPass(t.paint.get("line-emissive-strength").constantOr(0)):ds[i].colorMode;e.getOrCreateProgram("lineBlendComposite").draw(e,r.TRIANGLES,Wi.disabled,Xi.disabled,a,Ji.disabled,Sn(0,s,ds[i].compositeUniformValue),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom);}(e,i,s):void 0;"translucent"===e.renderPass&&hs(e,t,i,o);},fill:function(t,i,o,r){const n=o.paint.get("fill-color"),s=o.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=o.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=o.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===n.constantOr(e.aq.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";let d="none";"none"!==o.layout.get("fill-elevation-reference")?d="road":0!==o.paint.get("fill-z-offset").constantOr(1)&&(d="offset");const _=!(!t.terrain||!t.terrain.enabled),u={painter:t,sourceCache:i,layer:o,coords:r,colorMode:l,elevationType:d,terrainEnabled:_,pass:h};if("shadow"===t.renderPass)return void(t.shadowRenderer&&"road"===d&&!_&&function(e){const{painter:t,sourceCache:i,layer:o,coords:r}=e,n=t.context.gl,s=e.painter.shadowRenderer;for(const e of r){const r=i.getTile(e),a=r.getBucket(o);if(!a)continue;const l=a.elevatedStructures;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(o.id),h=t.isTileAffectedByFog(e),d=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:h}),_=s.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,d,e.toUnwrapped());const u=wn(_,0);d.draw(t,n.TRIANGLES,s.getShadowPassDepthMode(),Xi.disabled,Hi.disabled,Ji.disabled,u,o.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,o.paint,t.transform.zoom,c);}}(u));const p="mrt-fallback"===t.emissiveMode;if("offset"!==d){if(ps(u,!1,p),"road"===d){const e=!_&&"translucent"===t.renderPass;e&&us(t,i,o,r,"geometry"),ps(u,!0,p,Xi.disabled),e&&function(e){const{painter:t,sourceCache:i,layer:o,coords:r,colorMode:n}=e,s=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new Wi(t.context.gl.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D);let h=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(h=mo(t.style,e,i));}const d=e=>{for(const d of r){const r=i.getTile(d),_=r.getBucket(o);if(!_)continue;const u=_.elevatedStructures;if(!u)continue;let p,f;if(e?(p=u.renderableBridgeSegments,f=u.bridgeProgramConfigurations.get(o.id)):(p=u.renderableTunnelSegments,f=u.tunnelProgramConfigurations.get(o.id)),!p||0===p.segments[0].primitiveLength)continue;f.updatePaintBuffers(),t.prepareDrawTile();const m=t.isTileAffectedByFog(d),g=[];l&&g.push("RENDER_SHADOWS","NORMAL_OFFSET");const v=t.getOrCreateProgram("elevatedStructures",{config:f,overrideFog:m,defines:g}),y=t.translatePosMatrix(d.projMatrix,r,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));l&&a.setupShadows(r.tileID.toUnwrapped(),v,"vector-tile");const x=Tn(y,h);t.uploadCommonUniforms(t.context,v,d.toUnwrapped()),v.draw(t,s.TRIANGLES,c,Xi.disabled,n,Ji.backCCW,x,o.id,u.vertexBuffer,u.indexBuffer,p,o.paint,t.transform.zoom,f,[u.vertexBufferNormal]);}};d(!0),d(!1);}(u);}}else ps(u,!1,p,t.stencilModeFor3D());},"fill-extrusion":function(t,i,o,r){const n=o.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===n)return;const h="mrt-fallback"===t.emissiveMode,d=t.conflationActive&&t.style.isLayerClipped(o,i.getSource()),_=t.style.order.indexOf(o.fqid);if(d&&function(e,t,i,o,r){for(const n of o){const o=t.getTile(n).getBucket(i);o&&(o.updateReplacement(n,e.replacementSource,r),o.uploadCentroid(e.context));}}(t,i,o,r,_),l||d)for(const e of r){const r=i.getTile(e).getBucket(o);r&&ys(t.context,i,e,r,o,l,d);}if("shadow"===t.renderPass&&t.shadowRenderer){if(l&&n<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.af)return;const s=t.shadowRenderer.getShadowPassDepthMode();fs(t,i,o,r,s,Xi.disabled,Hi.disabled,d);}else if("translucent"===t.renderPass){const _=!o.paint.get("fill-extrusion-pattern").constantOr(1),u=o.paint.get("fill-extrusion-color").constantOr(e.aq.white);if(!c&&0!==u.a){const e=new Wi(t.context.gl.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D);1===n&&_?fs(t,i,o,r,e,Xi.disabled,Hi.unblended,d):(fs(t,i,o,r,e,Xi.disabled,Hi.disabled,d),fs(t,i,o,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),d),t.resetStencilClippingMasks());}if(t.style.enable3dLights()&&_&&(!l&&"globe"!==t.transform.projection.name||c)){const n=o.paint.get("fill-extrusion-opacity"),_=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),u=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=o.paint.get("fill-extrusion-flood-light-intensity"),f="none"===o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(f?null:o.lut).toArray01().slice(0,3),g=_>0&&u>0,v=p>0,y=(e,t,i)=>(1-i)*e+i*t,x=new ms;x.translate=o.paint.get("fill-extrusion-translate"),x.translateAnchor=o.paint.get("fill-extrusion-translate-anchor"),x.edgeRadius=o.layout.get("fill-extrusion-edge-radius"),x.cutoffFadeRange=o.paint.get("fill-extrusion-cutoff-fade-range");const b=s=>{const l=t.depthModeForSublayer(1,Wi.ReadOnly,a.LEQUAL,!0),c=o.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),h=y(.1,3,c),f=t._showOverdrawInspector;if(!f){const c=new Xi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),f=new Hi([a.ONE,a.ONE,a.ONE,a.ONE],e.aq.transparent,[!1,!1,!1,!0],a.MIN);vs(x,t,i,o,r,l,c,f,Ji.disabled,s,"sdf",n,_,u,p,m,h,d,!1);}{const c=f?Xi.disabled:new Xi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=f?t.colorModeForRenderPass():new Hi([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.aq.transparent,[!0,!0,!0,!0]);vs(x,t,i,o,r,l,c,g,Ji.disabled,s,"color",n,_,u,p,m,h,d,!1);}};if(c){const c=()=>{const t=l.drapeBufferSize[0],i=l.drapeBufferSize[1];let o=l.framebufferCopyTexture;return o&&(!o||o.size[0]===t&&o.size[1]===i)||(o&&o.destroy(),o=l.framebufferCopyTexture=new e.T(s,new e.q({width:t,height:i}),a.RGBA8)),o.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,i),o},f=(s,l,f)=>{const g=t.depthModeForSublayer(1,Wi.ReadOnly,a.LEQUAL,!1),v=o.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),b=y(.1,3,v);{const c=new Hi([a.ONE,a.ONE,a.ONE,a.ONE],e.aq.transparent,[!1,!1,!1,!0]);vs(x,t,i,o,r,g,Xi.disabled,c,Ji.disabled,s,"clear",n,_,u,p,m,b,d,l);}{const c=new Xi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),h=new Hi([a.ONE,a.ONE,a.ONE,a.ONE],e.aq.transparent,[!1,!1,!1,!0],a.MIN);vs(x,t,i,o,r,g,c,h,Ji.disabled,s,"sdf",n,_,u,p,m,b,d,l);}h&&!s&&(f=c());{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,h=new Xi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),f=new Hi([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.aq.transparent,[!0,!0,!0,!0]);vs(x,t,i,o,r,g,h,f,Ji.disabled,s,"color",n,_,u,p,m,b,d,l);}if(!h||s){const c=new Hi([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.aq.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);vs(x,t,i,o,r,g,Xi.disabled,c,Ji.disabled,s,"clear",n,_,u,p,m,b,d,l,f);}else {a.drawBuffers([a.NONE,a.COLOR_ATTACHMENT1]);const c=new Xi({func:a.EQUAL,mask:255},254,255,a.KEEP,a.DECR,a.DECR),h=new Hi([a.ONE,a.ONE,a.ONE,a.ONE],e.aq.transparent,[!0,!1,!1,!1],a.MAX);vs(x,t,i,o,r,g,c,h,Ji.disabled,s,"emissive",n,_,u,p,m,b,d,l,f),a.drawBuffers([a.COLOR_ATTACHMENT0]);}};if(g||v){let e;t.prepareDrawTile(),h&&!g||(e=c()),g&&f(!0,!1,e),v&&f(!1,!0,e);}}else g&&b(!0),v&&b(!1),(g||v)&&t.resetStencilClippingMasks();}}},building:function(e,t,i,o){e.currentLayer<e.firstLightBeamLayer&&(e.firstLightBeamLayer=e.currentLayer);const r=i.paint.get("building-ambient-occlusion-ground-intensity"),n=i.paint.get("building-ambient-occlusion-ground-radius"),s=i.paint.get("building-ambient-occlusion-ground-attenuation"),a=i.paint.get("building-opacity");if(a<=0)return;let l=r>0&&n>0,c=!0;const h=i.paint.get("building-vertical-scale");if(h<=0)return;e.shadowRenderer||(c=!1);const d=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),_=e.style.order.indexOf(i.fqid);if(function(e,t,i,o,r,n){for(const s of n){const n=t.getTile(s).getBucket(i);n&&(r&&n.updateReplacement(s,e.replacementSource,o),n.uploadUpdatedIndexBuffer(e.context));}}(e,t,i,_,d,o),function(e,t,i,o){for(const r of o){const o=t.getTile(r).getBucket(i);o&&o.needsEvaluation()&&o.uploadUpdatedColorBuffer(e.context);}}(e,t,i,o),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const r=[],n=e.shadowRenderer.getShadowPassDepthMode();Es({painter:e,source:t,layer:i,coords:o,defines:r,blendMode:Hi.disabled,depthMode:n,opacity:a,verticalScale:h,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}else if("translucent"===e.renderPass){let _=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(_=_.concat("RENDER_SHADOWS")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(_=_.concat("NORMAL_OFFSET"));const u=i.paint.get("building-facade-emissive-chance"),p=i.paint.get("building-ambient-occlusion-intensity"),f=i.paint.get("building-flood-light-intensity"),m="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),g=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(m?null:i.lut).toArray01().slice(0,3),v=i.paint.get("building-flood-light-ground-attenuation"),y=f>0,x=new Wi(e.context.gl.LEQUAL,Wi.ReadWrite,e.depthRangeFor3D);a<1&&Es({painter:e,source:t,layer:i,coords:o,defines:_,blendMode:Hi.disabled,depthMode:x,opacity:a,verticalScale:h,facadeEmissiveChance:u,facadeAOIntensity:p,floodLightIntensity:f,floodLightColor:g,depthOnly:!0});const b=e.colorModeForRenderPass();Es({painter:e,source:t,layer:i,coords:o,defines:_,blendMode:b,depthMode:x,opacity:a,verticalScale:h,facadeEmissiveChance:u,facadeAOIntensity:p,floodLightIntensity:f,floodLightColor:g});const w=i.paint.get("building-front-cutoff");gs(e.transform.pitch,w,!!e.terrain),l&&Ss(e,t,i,o,!0,a,r,n,f,g,s,d),y&&Ss(e,t,i,o,!1,a,r,n,f,g,v,d);}else if("light-beam"===e.renderPass){const r=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],n=new Wi(e.context.gl.LEQUAL,Wi.ReadOnly,e.depthRangeFor3D);Es({painter:e,source:t,layer:i,coords:o,defines:r,blendMode:Hi.alphaBlended,depthMode:n,opacity:a,verticalScale:h,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks();},hillshade:function(e,t,i,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,n=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||n?[{},o]:e.stencilConfigForOverlap(o);for(const o of a){const r=t.getTile(o);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)cr(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Wi.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=n&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):s[o.overscaledZ];ar(e,o,r,i,t,c,l);}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks();},raster:function(t,i,o,r,n,s){if("translucent"!==t.renderPass)return;const a=o.paint.get("raster-opacity");if(0===a)return;const l="globe"===t.transform.projection.name,c=0!==o.paint.get("raster-elevation"),h=c&&l,d=t.terrain&&t.terrain.exaggeration()>0&&c&&"ground"===o.paint.get("raster-elevation-reference"),_=!l&&d;if(t.renderElevatedRasterBackface&&!h)return;const u=t.context,p=u.gl,f=i.getSource(),m=function(t,i,o,r,n){const s=i.paint.get("raster-color"),a="raster-array"===t.type,l=[],c=i.paint.get("raster-resampling"),h=i.paint.get("raster-color-mix");let d=i.paint.get("raster-color-range");const _=[h[0],h[1],h[2],0],u=h[3];let p="nearest"===c?r.NEAREST:r.LINEAR;if(a&&(l.push("RASTER_ARRAY"),s||l.push("RASTER_COLOR"),"linear"===c&&l.push("RASTER_ARRAY_LINEAR"),p=r.NEAREST,!d&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(d=e.fields.range);}if(d=d||[0,1],s){l.push("RASTER_COLOR"),o.activeTexture.set(r.TEXTURE2),i.updateColorRamp(d);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,r.RGBA8)),t.bind(p,r.CLAMP_TO_EDGE);}return n&&l.push("USE_MRT1"),{mix:_,range:d,offset:u,defines:l,resampling:p}}(f,o,u,p,t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode);if(f instanceof e.aV&&!r.length&&!l)return;const g=o.paint.get("raster-emissive-strength"),v=t.colorModeForDrapableLayerRenderPass(g),y=t.terrain&&t.terrain.renderingToTexture,x=!t.options.moving,b="nearest"===o.paint.get("raster-resampling")?p.NEAREST:p.LINEAR;if(f instanceof e.aV&&!r.length&&(f.onNorthPole||f.onSouthPole)){const e=c?t.stencilModeFor3D():Xi.disabled;return void Is(!!f.onNorthPole,null,t,i,o,g,m,Ji.disabled,e)}if(!r.length)return;const[w,T]=f instanceof e.aV||y?[{},r]:t.stencilConfigForOverlap(r),E=T[T.length-1].overscaledZ;h&&m.defines.push("PROJECTION_GLOBE_VIEW"),c&&m.defines.push("RENDER_CUTOFF","ELEVATED"),d&&m.defines.push("ELEVATION_REFERENCE_GROUND");const S=(r,n,T)=>{for(const S of r){const r=S.toUnwrapped(),C=i.getTile(S);if(y&&(!C||!C.hasData()))continue;u.activeTexture.set(p.TEXTURE0);const I=Ds(C,f,o,m);if(!I||!I.texture)continue;const{texture:R,mix:D,offset:A,tileSize:L,buffer:P}=I;let O,M;y?(O=Wi.disabled,M=S.projMatrix):c?(O=new Wi(p.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D),M=l?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(r,x)):(O=t.depthModeForSublayer(S.overscaledZ-E,1===a?Wi.ReadWrite:Wi.ReadOnly,p.LESS),M=t.transform.calculateProjMatrix(r,x));const z=t.terrain&&y?t.terrain.stencilModeForRTTOverlap(S):w[S.overscaledZ],F=s?0:o.paint.get("raster-fade-duration");C.registerFadeDuration(F);const B=i.findLoadedParent(S,0),k=on(C,B,i,t.transform,F);let N,U;!k.isFading&&C.refreshedUponExpiration&&(C.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(p.TEXTURE0),R.bind(b,p.CLAMP_TO_EDGE),u.activeTexture.set(p.TEXTURE1),B?(B.texture&&B.texture.bind(b,p.CLAMP_TO_EDGE),N=Math.pow(2,B.tileID.overscaledZ-C.tileID.overscaledZ),U=[C.tileID.canonical.x*N%1,C.tileID.canonical.y*N%1]):R.bind(b,p.CLAMP_TO_EDGE),"useMipmap"in R&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&p.texParameterf(p.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const V=t.transform;let j;const G=c?Rs(V):[0,0,0,0];let Z,q,H,W,$,X=0;if(h&&f instanceof e.aV&&f.coordinates.length>3)Z=Float32Array.from(e.du(e.dv(new e.cn(0,0,0)))),q=Float32Array.from(V.globeMatrix),H=Float32Array.from(e.dq(V)),W=[e.aH(V.center.lng),e.aL(V.center.lat)],j=f.elevatedGlobePerspectiveTransform,$=f.elevatedGlobeGridMatrix||new Float32Array(9);else if(h){const t=e.dr(S.canonical);X=e.ds(t.getCenter().lat),Z=Float32Array.from(e.du(e.dv(S.canonical))),q=Float32Array.from(V.globeMatrix),H=Float32Array.from(e.dq(V)),W=[e.aH(V.center.lng),e.aL(V.center.lat)],j=[0,0],$=Float32Array.from(e.dt(S.canonical,t,X,V.worldSize/V._pixelsPerMercatorPixel));}else j=f instanceof e.aV?f.perspectiveTransform:[0,0],Z=new Float32Array(16),q=new Float32Array(9),H=new Float32Array(16),W=[0,0],$=new Float32Array(9);const Y=Bn(t,M,Z,q,H,$,U||[0,0],e.al(t.transform.zoom),W,G,N||1,k,o,j,c?o.paint.get("raster-elevation"):0,2,D,A,m.range,L,P,g),K=t.isTileAffectedByFog(S),J=t.getOrCreateProgram("raster",{defines:m.defines,overrideFog:K});if(t.uploadCommonUniforms(u,J,r),f instanceof e.aV){const i=f.elevatedGlobeVertexBuffer,r=f.elevatedGlobeIndexBuffer;if(y||!l)f.boundsBuffer&&f.boundsSegments&&J.draw(t,p.TRIANGLES,O,Xi.disabled,v,Ji.disabled,Y,o.id,f.boundsBuffer,t.quadTriangleIndexBuffer,f.boundsSegments);else if(i&&r){const s=V.zoom<=e.cJ?f.elevatedGlobeSegments:f.getSegmentsForLongitude(V.center.lng);s&&J.draw(t,p.TRIANGLES,O,Xi.disabled,v,n,Y,o.id,i,r,s);}}else if(h){O=new Wi(p.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){d&&(t.terrain.setupElevationDraw(C,J),t.uploadCommonUniforms(u,J,C.tileID.toUnwrapped()));const[i,r,s]=e.getGridBuffers(X,!1),a=J.getAttributeLocation(p,"a_texture_pos");-1!==a&&p.vertexAttribI4ui(a,0,0,0,0),J.draw(t,p.TRIANGLES,O,T||z,t.colorModeForRenderPass(),n,Y,o.id,i,r,s);}}else if(_)O=new Wi(p.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D),t.terrain.setupElevationDraw(C,J),t.uploadCommonUniforms(u,J,C.tileID.toUnwrapped()),V.pitch>20&&J.draw(t,p.TRIANGLES,O,Xi.disabled,Hi.disabled,Ji.frontCCW,Y,o.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments),J.draw(t,p.TRIANGLES,O,z,v,Ji.backCCW,Y,o.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments);else {const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(C);J.draw(t,p.TRIANGLES,O,z,v,Ji.disabled,Y,o.id,e,i,r);}}if(!(f instanceof e.aV)&&h)for(const e of r){const r=e.canonical.y===(1<<e.canonical.z)-1;0===e.canonical.y&&Is(!0,e,t,i,o,g,m,n,T||Xi.disabled),r&&Is(!1,e,t,i,o,g,m,n===Ji.frontCW?Ji.backCW:Ji.frontCW,T||Xi.disabled);}};h?S(T,t.renderElevatedRasterBackface?Ji.backCW:Ji.frontCW,t.stencilModeFor3D()):S(T,Ji.disabled,void 0),t.resetStencilClippingMasks();},"raster-particle":function(t,i,o,r,n,s){"offscreen"===t.renderPass&&function(t,i,o,r){if(!r.length)return;const n=t.context,s=n.gl,a=i.getSource();if(!(a instanceof Et))return;const l=Math.ceil(Math.sqrt(o.paint.get("raster-particle-count")));let c=o.particlePositionRGBAImage;if(!c||c.width!==l){const t=function(t){const i=t*t,o=new Uint8Array(4*i),r=.9090909090909091;for(let t=0;t<i;t++){const i=r*(e.eb(2*t+0)+Nn),n=r*(e.eb(2*t+1)+Nn),s=255*i%1,a=255*n%1,l=s,c=n-a/255,h=a;o[4*t+0]=255*(i-s/255),o[4*t+1]=255*l,o[4*t+2]=255*c,o[4*t+3]=255*h;}return o}(l);c=o.particlePositionRGBAImage=new e.q({width:l,height:l},t);}let h=o.particleFramebuffer;h?h.width!==l&&(h.destroy(),h=o.particleFramebuffer=n.createFramebuffer(l,l,1,null)):h=o.particleFramebuffer=n.createFramebuffer(l,l,1,null);const d=[];for(const e of r){const t=i.getTile(e);if(!(t instanceof Ot))continue;const r=Ps(t,a,o);if(!r)continue;const s=[t.tileSize,t.tileSize];let h=o.tileFramebuffer;h||(h=o.tileFramebuffer=n.createFramebuffer(s[0],s[1],1,null));let _=t.rasterParticleState;_||(_=t.rasterParticleState=new Ls(n,e,s,c));const u=_.update(o.lastInvalidatedAt);_.particleTextureDimension!==l&&_.updateParticleTexture(e,c);const p=_.targetColorTexture;_.targetColorTexture=_.backgroundColorTexture,_.backgroundColorTexture=p;const f=_.particleTexture0;_.particleTexture0=_.particleTexture1,_.particleTexture1=f,d.push([e,r,_,u]);}if(0===d.length)return;const _=e.o.now(),u=o.previousDrawTimestamp?.001*(_-o.previousDrawTimestamp):.0167;if(o.previousDrawTimestamp=_,o.hasColorMap()){n.activeTexture.set(s.TEXTURE0+2);let t=o.colorRampTexture;t||(t=o.colorRampTexture=new e.T(n,o.colorRamp,s.RGBA8)),t.bind(s.LINEAR,s.CLAMP_TO_EDGE);}n.bindFramebuffer.set(o.tileFramebuffer.framebuffer),function(t,i,o){const r=t.context,n=r.gl,s=i.tileFramebuffer;r.activeTexture.set(n.TEXTURE0);const a={u_texture:0,u_opacity:1.05*(c=i.paint.get("raster-particle-fade-opacity-factor"))/(c+.05)},l=t.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var c;for(const c of o){const[,,o,h]=c;s.colorAttachment0.set(o.targetColorTexture.texture),r.viewport.set([0,0,s.width,s.height]),r.clear({color:e.aq.transparent}),h&&(o.backgroundColorTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),l.draw(t,n.TRIANGLES,Wi.disabled,Xi.disabled,Hi.alphaBlended,Ji.disabled,a,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments));}}(t,o,d),function(t,i,o,r){const n=t.context,s=n.gl,a=o.tileFramebuffer,l="globe"===t.transform.projection.name,c=o.paint.get("raster-particle-max-speed");for(const h of r){const[r,d,_]=h;n.activeTexture.set(s.TEXTURE0+0),d.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),a.colorAttachment0.set(_.targetColorTexture.texture);const u=t.getOrCreateProgram("rasterParticleDraw",{defines:d.defines,overrideFog:!1});n.activeTexture.set(s.TEXTURE0+1);const p=d.scalarData?[]:[0,1,2,3].map(t=>e.d$[t](r));p.push(r);const f=r.canonical.x,m=r.canonical.y;for(const e of p){const n=i.getTile(l?e.wrapped():e);if(!n)continue;const a=n.rasterParticleState;if(!a)continue;const h=e.canonical.x+(1<<e.canonical.z)*(e.wrap-r.wrap),_=e.canonical.y;a.particleTexture0.bind(s.NEAREST,s.CLAMP_TO_EDGE);const p=Vn(1,a.particleTexture0.size[0],[h-f,_-m],0,d.texture.size,2,c,d.textureOffset,d.scale,d.offset);u.draw(t,s.POINTS,Wi.disabled,Xi.disabled,Hi.alphaBlended,Ji.disabled,p,o.id,a.particleIndexBuffer,void 0,a.particleSegment);}}}(t,i,o,d),n.bindFramebuffer.set(o.particleFramebuffer.framebuffer),function(t,i,o,r){const n=t.context,s=n.gl,a=i.paint.get("raster-particle-max-speed"),l=r*i.paint.get("raster-particle-speed-factor")*.15,c=function(e){return Math.pow(e,6)}(.01+1*i.paint.get("raster-particle-reset-rate-factor")),h=i.particleFramebuffer;n.viewport.set([0,0,h.width,h.height]);for(const r of o){const[,o,d]=r;n.activeTexture.set(s.TEXTURE0+0),o.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),n.activeTexture.set(s.TEXTURE0+1);const _=d.particleTexture0;_.bind(s.NEAREST,s.CLAMP_TO_EDGE);const u=jn(1,_.size[0],0,o.texture.size,a,l,c,o.textureOffset,o.scale,o.offset);h.colorAttachment0.set(d.particleTexture1.texture),n.clear({color:e.aq.transparent}),t.getOrCreateProgram("rasterParticleUpdate",{defines:o.defines}).draw(t,s.TRIANGLES,Wi.disabled,Xi.disabled,Hi.unblended,Ji.disabled,u,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments);}}(t,o,d,u);}(t,i,o,r),"translucent"===t.renderPass&&(function(t,i,o,r){const n=t.context,s=n.gl,a=i.getSource().tileSize,l=5*(1-e.aj(e.cv,e.cv+1,t.transform.zoom))*a+o.paint.get("raster-particle-elevation"),c=!t.options.moving,h="globe"===t.transform.projection.name;if(!r.length)return;const[d,_]=t.stencilConfigForOverlap(r),u=[];h&&u.push("PROJECTION_GLOBE_VIEW");const p=t.stencilModeFor3D();for(const r of _){const a=r.toUnwrapped(),_=i.getTile(r);if(!_.rasterParticleState)continue;const f=_.rasterParticleState,m=100;_.registerFadeDuration(m);const g=i.findLoadedParent(r,0),v=on(_,g,i,t.transform,m);let y,x;t.terrain&&t.terrain.prepareDrawTile(),n.activeTexture.set(s.TEXTURE0),f.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),n.activeTexture.set(s.TEXTURE1),g&&g.rasterParticleState?(g.rasterParticleState.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),y=Math.pow(2,g.tileID.overscaledZ-_.tileID.overscaledZ),x=[_.tileID.canonical.x*y%1,_.tileID.canonical.y*y%1]):f.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const b=h?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(a,c),w=t.transform,T=Os(w),E=e.dr(r.canonical),S=e.ds(E.getCenter().lat);let C,I,R,D,A;h?(C=Float32Array.from(e.du(e.dv(r.canonical))),I=Float32Array.from(w.globeMatrix),R=Float32Array.from(e.dq(w)),D=[e.aH(w.center.lng),e.aL(w.center.lat)],A=Float32Array.from(e.dt(r.canonical,E,S,w.worldSize/w._pixelsPerMercatorPixel))):(C=new Float32Array(16),I=new Float32Array(9),R=new Float32Array(16),D=[0,0],A=new Float32Array(9));const L=Un(b,C,I,R,A,x||[0,0],e.al(t.transform.zoom),D,T,y||1,v,l),P=t.isTileAffectedByFog(r),O=t.getOrCreateProgram("rasterParticle",{defines:u,overrideFog:P});if(t.uploadCommonUniforms(n,O,a),h){const e=new Wi(s.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D),i=0,r=t.globeSharedBuffers;if(r){const[n,a,l]=r.getGridBuffers(S,0!==i);O.draw(t,s.TRIANGLES,e,p,Hi.alphaBlended,t.renderElevatedRasterBackface?Ji.frontCCW:Ji.backCCW,L,o.id,n,a,l);}}else {const e=t.depthModeForSublayer(0,Wi.ReadOnly),i=d[r.overscaledZ],{tileBoundsBuffer:n,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=t.getTileBoundsBuffers(_);O.draw(t,s.TRIANGLES,e,i,Hi.alphaBlended,Ji.disabled,L,o.id,n,a,l);}}t.resetStencilClippingMasks();}(t,i,o,r),t.style.map.triggerRepaint());},background:function(t,i,o,r){const n=o.paint.get("background-color"),s="none"===o.paint.get("background-color-use-theme").constantOr("default"),a=o.paint.get("background-opacity"),l=o.paint.get("background-emissive-strength"),c="viewport"===o.paint.get("background-pitch-alignment");if(0===a)return;const h=t.context,d=h.gl,_=t.transform,u=_.tileSize,p=o.paint.get("background-pattern");let f;if(void 0!==p){if(null===p)return;if(f=t.imageManager.getPattern(e.I.from(p.toString()),o.scope,t.style.getLut(o.scope)),!f)return}const m=!p&&1===n.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==m)return;const g=Xi.disabled,v=t.depthModeForSublayer(0,"opaque"===m?Wi.ReadWrite:Wi.ReadOnly),y=t.colorModeForDrapableLayerRenderPass(l),x=p?"backgroundPattern":"background";let b,w=r;w||(b=t.getBackgroundTiles(),w=Object.values(b).map(e=>e.tileID)),p&&(h.activeTexture.set(d.TEXTURE0),t.imageManager.bind(t.context,o.scope));const T=[];if(t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&T.push("USE_MRT1"),c){const i=t.getOrCreateProgram(x,{overrideFog:!1,overrideRtt:!0,defines:T}),r=new Float32Array(e.b9([])),h=new e.aR(0,0,0,0,0),_=p?Hn(r,l,a,t,0,o.scope,f,c,{tileID:h,tileSize:u}):qn(r,l,a,n.toPremultipliedRenderColor(s?null:o.lut));return void i.draw(t,d.TRIANGLES,v,g,y,Ji.disabled,_,o.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}for(const m of w){const w=t.isTileAffectedByFog(m),E=t.getOrCreateProgram(x,{overrideFog:w,defines:T}),S=m.toUnwrapped(),C=r?m.projMatrix:t.transform.calculateProjMatrix(S);t.prepareDrawTile();const I=i?i.getTile(m):b?b[m.key]:new e.b0(m,u,_.zoom,t),R=p?Hn(C,l,a,t,0,o.scope,f,c,{tileID:m,tileSize:u}):qn(C,l,a,n.toPremultipliedRenderColor(s?null:o.lut));t.uploadCommonUniforms(h,E,S);const{tileBoundsBuffer:D,tileBoundsIndexBuffer:A,tileBoundsSegments:L}=t.getTileBoundsBuffers(I);E.draw(t,d.TRIANGLES,v,g,y,Ji.disabled,R,o.id,D,A,L);}},sky:function(t,i,o){const r=t._atmosphere?e.al(t.transform.zoom):1,n=o.paint.get("sky-opacity")*r;if(0===n)return;const s=t.context,a=o.paint.get("sky-type"),l=new Wi(s.gl.LEQUAL,Wi.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?o.needsSkyboxCapture(t)&&(function(t,i){const o=t.context,r=o.gl;let n=i.skyboxFbo;if(!n){n=i.skyboxFbo=o.createFramebuffer(32,32,1,null),i.skyboxGeometry=new Ws(o),i.skyboxTexture=o.gl.createTexture(),r.bindTexture(r.TEXTURE_CUBE_MAP,i.skyboxTexture),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,r.LINEAR);for(let e=0;e<6;++e)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,r.RGBA,32,32,0,r.RGBA,r.UNSIGNED_BYTE,null);}o.bindFramebuffer.set(n.framebuffer),o.viewport.set([0,0,32,32]);const s=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.b9(l),e.ef(l,l,.5*-Math.PI),$s(t,i,a,l,s,0),e.b9(l),e.ef(l,l,.5*Math.PI),$s(t,i,a,l,s,1),e.b9(l),e.cE(l,l,.5*-Math.PI),$s(t,i,a,l,s,2),e.b9(l),e.cE(l,l,.5*Math.PI),$s(t,i,a,l,s,3),e.b9(l),$s(t,i,a,l,s,4),e.b9(l),e.ef(l,l,Math.PI),$s(t,i,a,l,s,5),o.viewport.set([0,0,t.width,t.height]);}(t,o),o.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,o,r){const n=e.context,s=n.gl,a=e.transform,l=e.getOrCreateProgram("skybox");n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,o,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:o,u_temporal_offset:r}))(a.skyboxMatrix,t.getCenter(e,!1),0,o,r);e.uploadCommonUniforms(n,l),l.draw(e,s.TRIANGLES,i,Xi.disabled,e.colorModeForRenderPass(),Ji.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(t,o,l,n,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,o,r,n){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ws(s)),s.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA8)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const d=((t,i,o,r,n)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.ap(o),u_opacity:r,u_temporal_offset:n}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,n);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,o,Xi.disabled,t.colorModeForRenderPass(),Ji.backCW,d,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,n,c);},custom:function(t,i,o,r){const n=t.context,s=o.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&o.isDraped(i)){if("offscreen"===t.renderPass){const i=s.prerender;if(i){if(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const o=t.transform.pointMerc;i.call(s,n.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.al(t.transform.zoom),[o.x,o.y],t.transform.pixelsPerMeterRatio);}else i.call(s,n.gl,t.transform.customLayerMatrix());n.setDirty(),t.setBaseState();}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=s.renderToTile;if(e){const i=r[0].canonical,o={x:i.x+r[0].wrap*(s.wrapTileId?0:1<<i.z),y:i.y,z:i.z};n.setDepthMode(Wi.disabled),n.setStencilMode(Xi.disabled),n.setColorMode(t.colorModeForRenderPass()),t.setCustomLayerDefaults(),e.call(s,n.gl,o),n.setDirty(),t.setBaseState();}return}t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),n.setStencilMode(Xi.disabled);const i="3d"===s.renderingMode?new Wi(t.context.gl.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Wi.ReadOnly);if(n.setDepthMode(i),"globe"===t.transform.projection.name){const i=t.transform.pointMerc;s.render(n.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.al(t.transform.zoom),[i.x,i.y],t.transform.pixelsPerMeterRatio);}else s.render(n.gl,t.transform.customLayerMatrix());n.setDirty(),t.setBaseState(),n.bindFramebuffer.set(null);}}else e.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.");},model:function(t,i,o,r){if("opaque"===t.renderPass)return;const n=o.paint.get("model-opacity").constantOr(1),s=o.paint.get("model-elevation-reference"),a="ground"===s,l="ground"===s;if(0===n)return;const c=o.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!c)return;if(t.terrain&&n<.65&&o._transitionablePaint._values["model-opacity"].value.expression instanceof e.af)return}const h=t.shadowRenderer,d=o.paint.get("model-receive-shadows");h&&(h.useNormalOffset=!0,d||(h.enabled=!1));const _=()=>{h&&(h.useNormalOffset=!0,d||(h.enabled=!0));},u=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==u.type)return;if("vector"===u.type||"geojson"===u.type)return function(t,i,o,r,n){const s=t.transform,a="globe"===s.projection.name,l=s.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;o.modelManager=c;const h=t.shadowRenderer;if(!o._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const d=o._unevaluatedLayout._values["model-id"],_=Object.assign({},o.layout.get("model-id").parameters),u=t.style.order.indexOf(o.fqid),p=o.paint.get("model-opacity").constantOr(1);for(const f of r){const r=i.getTile(f).getBucket(o);if(!r||r.projection.name!==s.projection.name)continue;const m=r.getModelUris();if(m&&!r.modelsRequested&&(c.addModelsFromBucket(m,n),r.modelsRequested=!0),a)_.zoom=f.overscaledZ;else {const e=ua(f,s);_.zoom=e;}const g=d.possiblyEvaluate(_);if(da(t,r,f),_a.shadowUniformsInitialized=!1,_a.useSingleShadowCascade=!!h&&0===h.getMaxCascadeForTile(f.toUnwrapped()),"shadow"===t.renderPass&&h){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(f.toUnwrapped(),s.worldSize);if(_a.tileMatrix.set(i),_a.shadowTileMatrix=Float32Array.from(h.calculateShadowPassMatrixFromMatrix(i)),_a.aabb.min=[0,0,0],_a.aabb.max[0]=_a.aabb.max[1]=e.an,_a.aabb.max[2]=0,ma(r,_a,t,o.scope))continue}const v=1<<f.canonical.z,y=[((l.x-f.wrap)*v-f.canonical.x)*e.an,(l.y*v-f.canonical.y)*e.an,l.z*v*e.an];t.conflationActive&&Object.keys(r.instancesPerModel).length>0&&t.style.isLayerClipped(o,i.getSource())&&r.updateReplacement(f,t.replacementSource,u,o.scope)&&(r.uploaded=!1,r.upload(t.context));let x=0;const b=new Array,w=new Array,T=new Array;for(let i in r.instancesPerModel){const s=r.instancesPerModel[i];s.features.length>0&&!a&&(i=g.evaluate(s.features[0].feature,{}));const h=c.getModel(i,n);if(h||c.hasURLBeenRequested(i)||r.modelUris.includes(i)||(r.modelUris.push(i),r.modelsRequested=!1),h&&h.uploaded)if(a){const i=e.bJ([],[l.x,l.y,l.z],t.transform.worldSize);e.eo(i,i);for(let o=0;o<s.instancedDataArray.length;++o){const n=[0,0,0],a=[1,1,1],l=e.ep(),c=s.tileCoordinatesForInstance(o),d=s.transformForInstance(o);e.eq(a,d),e.er(l,d),e.es(n,l);const _=s.translationForInstance(o),u=new e.aU(0,0);e.et(r.canonical,u,c.x,c.y);const f=e.bb();e.eu(f,h,t.transform,u,n,a,_,!0,!1,!1);const m=s.colorForInstance(o),g=e.b9([]),v=e.e2(u.lat,t.transform.zoom),y=e.bP([],[1,1,1/v]);e.bx(g,g,i),T.push({zScaleMatrix:y,negCameraPosMatrix:g});for(const e of h.nodes)na(t,e,f,t.transform.expandedFarZProjMatrix,x,b,w,h.materialOverrides,p,m);++x;}}else for(const e of h.nodes)pa(t,o,e,s,y,f,_a);}if(a)if("shadow"===t.renderPass){for(const e of w)sa(e.mesh,e.nodeModelMatrix,t,o);for(const e of b)sa(e.mesh,e.nodeModelMatrix,t,o);}else ha(t,o,b,w,T);}}(t,i,o,r,ra(t,o)),void _();if(!u.loaded())return;if("batched-model"===u.type)return function(t,i,o,r){o.resetLayerRenderingStats(t);const n=t.context,s=t.transform,a=t.style.fog,l=t.shadowRenderer;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D landmark models for ${s.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,h=e.bJ([],[c.x,c.y,c.z],t.transform.worldSize),d=e.eo([],h),_=e.b9([]),u=e.e2(s.center.lat,s.zoom),p=e.bP([],[1,1,1/u]);e.bx(_,_,d);const f=o.paint.get("model-opacity").constantOr(1),m=new Wi(n.gl.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D),g=new Wi(n.gl.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D),v=new e.cU([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),y="shadow"===t.renderPass,x=y&&l?l.getCurrentCascadeFrustum():s.getFrustum(s.scaleZoom(s.worldSize)),b=o.paint.get("model-front-cutoff"),w=b[2]<1,T=lo(t,o.paint.get("model-cutoff-fade-range")),E=o.getLayerRenderingStats();((function(e,t,i,o){const r=e.terrain?e.terrain.exaggeration():0,n=e.transform.zoom;for(const s of o){const o=t.getTile(s).getBucket(i);o&&(o.setFilter(i.filter),e.conflationActive&&o.updateReplacement(s,e.replacementSource),o.evaluateTransform(e,i),e.terrain&&r>0&&o.elevationUpdate(e.terrain,r,s,i.source),o.needsReEvaluation(e,n,i)&&o.evaluate(i));}}))(t,i,o,r),function(){const c=new Map;let d,S,C;w?(d=r.length-1,S=-1,C=-1):(d=0,S=r.length,C=1);const I=new Float64Array(16),R=e.ce(),D=new e.P(0,0);for(let A=d;A!==S;A+=C){const d=r[A],S=i.getTile(d).getBucket(o);if(!S||!S.uploaded)continue;let C=!1;l&&(C=0===l.getMaxCascadeForTile(d.toUnwrapped()));const L=s.calculatePosMatrix(d.toUnwrapped(),s.worldSize),P=S.modelTraits;!y&&w&&(e.b7(I,L),e.ah(R,h,I),D.x=R[0],D.y=R[1]);const O=[];S.setFilter(o.filter);for(const i of S.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const o=i.node;let r=0;t.terrain&&o.elevation&&(r=o.elevation*t.terrain.exaggeration());const n=(()=>{const t=i.aabb;return v.min=[...t.min],v.max=[...t.max],v.min[2]+=r,v.max[2]+=r,e.ah(v.min,v.min,L),e.ah(v.max,v.max,L),v})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===n.intersects(x))continue;if(!y&&w){const t=1/6;i.cameraCollisionOpacity=h[0]>n.min[0]&&h[0]<n.max[0]&&h[1]>n.min[1]&&h[1]<n.max[1]&&h[2]*u<n.max[2]&&o.footprint&&e.bC(D,o.footprint)?Math.max(i.cameraCollisionOpacity-t,0):Math.min(1,i.cameraCollisionOpacity+t);}const l=[...L],c=1/e.cS(d.canonical),_=o.anchor?o.anchor[0]:0,p=o.anchor?o.anchor[1]:0;e.bx(l,l,[_*(a[0]-1)+i.evaluatedTranslation[0]*c,p*(a[1]-1)+i.evaluatedTranslation[1]*c,r+i.evaluatedTranslation[2]]),e.c4(a,e.ew)||e.cC(l,l,a);const m=e.aD([],l,o.globalMatrix),g=e.aD([],s.expandedFarZProjMatrix,m),E=e.aD([],s.expandedFarZProjMatrix,l),S=e.aE([],[_,p,r,1],g)[2];o.hidden=!1;let C=f;y||(w&&(C*=i.cameraCollisionOpacity,C*=va(l,s,i.aabb,b)),C*=ga(T,S)),0!==C?O.push({nodeInfo:i,depth:S,opacity:C,wvpForNode:g,wvpForTile:E,nodeModelMatrix:m,tileModelMatrix:l}):o.hidden=!0;}y||O.sort((e,t)=>!w||1===e.opacity&&1===t.opacity?e.depth<t.depth?-1:1:1===e.opacity?-1:1===t.opacity?1:e.depth>t.depth?-1:1);for(const i of O){const r=i.nodeInfo,h=r.node;if(t._debugParams.show3DModelFootprints&&h.footprint){const e=h.id||h.name||"footprint";c.has(e)||c.set(e,{node:h,mvp:i.wvpForTile});}let d=e.aD([],p,i.tileModelMatrix);e.aD(d,_,d);const u=e.b7([],d);e.e6(u,u),e.cC(u,u,fa),d=e.aD(d,d,h.globalMatrix);const f="light-beam"===t.renderPass,v="none"===o.paint.get("model-color-use-theme").constantOr("default"),x=P&e.ez.HasMapboxMeshFeatures,b=x?0:r.evaluatedRMEA[0][2];for(let e=0;e<h.meshes.length;++e){const c=h.meshes[e],_=e===h.lightMeshIndex;let p=i.wvpForNode;if(_){if(!f&&!t.terrain&&t.shadowRenderer){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);continue}p=i.wvpForTile;}else if(f)continue;const w={defines:[]},T=[];if(!y&&l&&(l.useNormalOffset=!!c.normalBuffer),ia(w.defines,T,c,t,v?null:o.lut),x||w.defines.push("DIFFUSE_SHADED"),C&&w.defines.push("SHADOWS_SINGLE_CASCADE"),E&&(y?E.numRenderedVerticesInShadowPass+=c.vertexArray.length:E.numRenderedVerticesInTransparentPass+=c.vertexArray.length),y){sa(c,i.nodeModelMatrix,t,o);continue}let S=null;if(a){const e=ta(i.nodeModelMatrix,t.transform);if(S=new Float32Array(e),"globe"!==s.projection.name){const t=c.aabb.min,i=c.aabb.max,[o,r]=a.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);w.overrideFog=o>=Ke||r>=Ke;}}const I=c.material;let R;I.occlusionTexture&&I.occlusionTexture.offsetScale&&(R=I.occlusionTexture.offsetScale,w.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const D=t.getOrCreateProgram("model",w);!y&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,D,l.useNormalOffset),t.uploadCommonUniforms(n,D,null,S);const A=I.pbrMetallicRoughness;A.metallicFactor=.9,A.roughnessFactor=.5;const L=$n(new Float32Array(p),new Float32Array(d),new Float32Array(u),new Float32Array(h.globalMatrix),t,i.opacity,A.baseColorFactor,I.emissiveFactor,A.metallicFactor,A.roughnessFactor,I,b,o,[0,0,0],R);!_&&(r.hasTranslucentParts||i.opacity<1)&&D.draw(t,n.gl.TRIANGLES,m,Xi.disabled,Hi.disabled,Ji.backCCW,L,o.id,c.vertexBuffer,c.indexBuffer,c.segments,o.paint,t.transform.zoom,void 0,T),D.draw(t,n.gl.TRIANGLES,_?g:m,Xi.disabled,_||i.opacity<1||r.hasTranslucentParts?Hi.alphaBlended:Hi.unblended,Ji.backCCW,L,o.id,c.vertexBuffer,c.indexBuffer,c.segments,o.paint,t.transform.zoom,void 0,T);}}}if(t._debugParams.show3DModelFootprints&&c.size>0){const e=Array.from(c.keys()).sort();for(const i of e){const{node:e,mvp:o}=c.get(i);aa(t,0,e,o);}}}();}(t,i,o,r),void _();if("model"!==u.type)return;const p=u.getModels(),f=[],m=t.transform.getFreeCameraOptions().position,g=e.bJ([],[m.x,m.y,m.z],t.transform.worldSize);e.eo(g,g);const v=[],y=[];let x=0;for(const r of p){const n=i.getFeatureState("",r.id),s={type:"Unknown",id:r.id,properties:r.featureProperties},c=o.paint.get("model-rotation").evaluate(s,n),h=o.paint.get("model-scale").evaluate(s,n),d=o.paint.get("model-translation").evaluate(s,n),_=o.paint.get("model-opacity").evaluate(s,n);la(o,r.id,n,r.featureProperties,r.nodeOverrideNames,r.nodeOverrides),ca(o,r.id,n,r.featureProperties,r.materialOverrideNames,r.materialOverrides),r.nodeOverrides.size>0&&r.computeBoundsAndApplyParent(),r.computeModelMatrix(t,c,h,d,l,a,!1);const u=e.b9([]),p=e.e2(r.position.lat,t.transform.zoom),m=e.bP([],[1,1,1/p]);e.bx(u,u,g),f.push({zScaleMatrix:m,negCameraPosMatrix:u});for(const e of r.nodes)na(t,e,r.matrix,t.transform.expandedFarZProjMatrix,x,v,y,r.materialOverrides,_);x++;}if(v.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass){if(t._debugParams.show3DModelFootprints){const i=t.transform.projMatrix,o=new Map,r=(t,r)=>{if(t.footprint){const n=t.id||t.name||"footprint";if(!o.has(n)){const s=e.aD([],i,r);o.set(n,{node:t,mvp:s});}}};for(const e of y)r(e.node,e.modelMatrix);for(const e of v)r(e.node,e.modelMatrix);const n=Array.from(o.keys()).sort();for(const e of n){const{node:i,mvp:r}=o.get(e);aa(t,0,i,r);}}ha(t,o,v,y,f),_();}else {for(const e of y)sa(e.mesh,e.nodeModelMatrix,t,o);for(const e of v)sa(e.mesh,e.nodeModelMatrix,t,o);_();}}},za={line:function(e,t,i){if(e.hasElevatedBuckets=!1,e.hasNonElevatedBuckets=!1,void 0!==e._unevaluatedLayout.getValue("line-elevation-reference")||void 0!==e._unevaluatedLayout.getValue("line-z-offset")){if(t){const i=t.getVisibleCoordinates();for(const o of i){const i=t.getTile(o).getBucket(e);if(i&&("none"!==i.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}}else e.hasNonElevatedBuckets=!0;},model:function(e,t,i){const o=t.getSource();if(!o.loaded())return;if("vector"===o.type||"geojson"===o.type)return void(i.modelManager&&i.modelManager.upload(i,ra(i,e)));if("batched-model"===o.type)return;if("model"!==o.type)return;const r=o.getModels();for(const e of r)e.upload(i.context);},raster:function(e,t,i){const o=t.getSource();if(!(o instanceof Et&&o.loaded()))return;const r=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!r)return;const n=e.paint.get("raster-array-band")||o.getInitialBand(r);if(null==n)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,n)&&o.prepareTile(t,r,e.id,n);},"raster-particle":function(e,t,i){const o=t.getSource();if(!(o instanceof Et&&o.loaded()))return;const r=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!r)return;const n=e.paint.get("raster-particle-array-band")||o.getInitialBand(r);if(null==n)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,n)&&o.prepareTile(t,r,e.id,n);}},Fa={fill:us},Ba={fill:function(e,t,i,o){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const r=e.context.gl,n=new Wi(r.LEQUAL,Wi.ReadOnly,e.depthRangeFor3D),s=new Xi({func:r.ALWAYS,mask:255},255,255,r.KEEP,r.KEEP,r.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of o){const o=t.getTile(c),h=o.getBucket(i);if(!h)continue;const d=h.elevatedStructures;if(!d||0===d.depthSegments.segments[0].primitiveLength)continue;const _=_s(c.toUnwrapped(),a),u=e.translatePosMatrix(c.projMatrix,o,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),p=En(u,_,0,1,0);l.draw(e,r.TRIANGLES,n,s,Hi.disabled,Ji.disabled,p,i.id,d.vertexBuffer,d.indexBuffer,d.depthSegments,i.paint,e.transform.zoom);}}};class ka{constructor(t,i,o,r,n){this.context=new ts(t,i),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=e.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,show3DModelFootprints:!1,enabledLayers:{}};const s=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const e of s)this._debugParams.enabledLayers[e]=!0;for(const e of s);this.occlusionParams=new ba,this.setup(),this.numSublayers=Ft.maxUnderzooming+Ft.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.eG,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new uo(this),this._wireframeDebugCache=new xa,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const a=new e.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,a,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,this.maxFrontCutoffRawStart=0,this.worldview=n,this._forceEmissiveMode=!1,this.emissiveMode="constant";}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new an(this,e));const o=this._terrain;this.transform.elevation=i?o:null,o.update(e,this.transform,t),this.transform.elevation&&!o.enabled&&(this.transform.elevation=null);}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,o]=t.getFovAdjustedRange(this.transform._fov);if(i>o)return void(this.transform.fogCullDistSq=null);const r=i+.78*(o-i);this.transform.fogCullDistSq=r*r;}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new an(this,this.style)),this._forceTerrainMode=e;}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.o.devicePixelRatio,this.height=i*e.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize();}setup(){const t=this.context,i=new e.dB;i.emplaceBack(0,0),i.emplaceBack(e.an,0),i.emplaceBack(0,e.an),i.emplaceBack(e.an,e.an),this.tileExtentBuffer=t.createVertexBuffer(i,e.dx.members),this.tileExtentSegments=e.dy.simpleSegment(0,0,4,2);const o=new e.dB;o.emplaceBack(0,0),o.emplaceBack(e.an,0),o.emplaceBack(0,e.an),o.emplaceBack(e.an,e.an),this.debugBuffer=t.createVertexBuffer(o,e.dx.members),this.debugSegments=e.dy.simpleSegment(0,0,4,5);const r=new e.dB;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.dx.members),this.viewportSegments=e.dy.simpleSegment(0,0,4,2);const n=new e.eH;n.emplaceBack(0,0,0,0),n.emplaceBack(e.an,0,e.an,0),n.emplaceBack(0,e.an,0,e.an),n.emplaceBack(e.an,e.an,e.an,e.an),this.mercatorBoundsBuffer=t.createVertexBuffer(n,e.eI.members),this.mercatorBoundsSegments=e.dy.simpleSegment(0,0,4,2);const s=new e.dC;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.eJ;for(const e of [0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.bb();const l=this.context.gl;this.stencilClearMode=new Xi({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now());}getMercatorTileBoundsBuffers(){return {tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Wi.disabled,this.stencilClearMode,Hi.disabled,Ji.disabled,tn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const o=this.context,r=o.gl;this.nextStencilID+i.length>256&&this.clearStencil(),o.setColorMode(Hi.disabled),o.setDepthMode(Wi.disabled);const n=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),o=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);n.draw(this,r.TRIANGLES,Wi.disabled,new Xi({func:r.ALWAYS,mask:0},o,255,r.KEEP,r.KEEP,r.REPLACE),Hi.disabled,Ji.disabled,tn(e.projMatrix),"$clipping",s,a,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Xi({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Xi({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),o=i[i.length-1].overscaledZ,r=i[0].overscaledZ-o+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;i<r;i++)e[i+o]=new Xi({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=r,[e,i]}return [{[o]:Xi.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new Hi([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new e.aq(i,i,i,0),[!0,!0,!0,!0])}return "opaque"===this.renderPass?Hi.unblended:Hi.alphaBlended}colorModeForDrapableLayerRenderPass(t){const i=this.context.gl;return (()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?null!=t&&"mrt-fallback"!==this.emissiveMode||"constant"===this.emissiveMode?new Hi([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.aq(0,0,0,null!=t?t:0),[!0,!0,!0,!0]):"dual-source-blending"===this.emissiveMode?new Hi([i.ONE,i.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,i.ONE_MINUS_SRC_ALPHA],e.aq.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,o=!1){if(this.depthOcclusion)return new Wi(this.context.gl.GREATER,Wi.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!o)return Wi.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Wi(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const t=this.context.gl,i=Math.ceil(this.width),o=Math.ceil(this.height),r=this.context.bindFramebuffer.get(),n=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===i&&this.depthFBO.height===o||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),0!==i&&0!==o&&(this.depthFBO=new es(this.context,i,o,0,"texture"),this.depthTexture=new e.T(this.context,{width:i,height:o,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(r),t.bindTexture(t.TEXTURE_2D,n),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,i,o,0,0,i,o,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current));}updateAverageFPS(){this._fpsHistory.push(0===this._dt?0:1e3/this._dt),this._fpsHistory.length>this._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((e,t)=>e+t/this._fpsHistory.length,0));}render(t,i){const o=e.o.now();this._dt=o-this._timeStamp,this._timeStamp=o,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const r=this.style._mergedLayers,n=!(!this.terrain||!this.terrain.enabled),s=()=>this.style._getOrder(n).filter(e=>{const t=r[e];return !(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]});let a=s(),l=!1,c=!1,h=null,d=0,_=!1;for(const e of a){const t=r[e];"none"!==t.visibility&&("circle"===t.type?l=!0:"building"===t.type?(h=t,++d):"symbol"===t.type&&(t.hasOcclusionOpacityProperties?c=!0:l=!0));}this.updateEmissiveMode();let u=a.map(e=>r[e]);const p=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.o.now()),this.imageManager.beginFrame();for(const e in p){const t=p[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++d);}let f=!1;for(const e of u)e.isHidden(this.transform.zoom)||("clip"===e.type&&(f=!0),this.prepareLayer(e));const m={},g={},v={},y={},x={};for(const e in p){const t=p[e];m[e]=t.getVisibleCoordinates(),g[e]=m[e].slice().reverse(),v[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),x[e]=t.sortCoordinatesByDistance(m[e]);}const b=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(d||f||this._clippingActiveLastFrame){const t=[],i=[];let o=0;for(const e of u)this.isSourceForClippingOrConflation(e,b(e))&&(t.push(e),i.push(o)),o++;if(t&&(f||t.length>1)||this._clippingActiveLastFrame){f=!1;const o=[];for(let r=0;r<t.length;r++){const n=t[r],s=i[r],a=this.style.getLayerSourceCache(n);if(!a||!a.used||!a.getSource().usedInConflation&&"clip"!==n.type&&"building"!==n.type)continue;let l=e.eK,c=e.bA.None;const h=[];let d=!0;if("building"===n.type)l=e.eM;else if("clip"===n.type)if(l=s,n.isHidden(this.transform.zoom))d=!1;else {if(!n.layout){d=!1;continue}for(const t of n.layout.get("clip-layer-types"))c|="model"===t?e.bA.Model:"symbol"===t?e.bA.Symbol:e.bA.FillExtrusion;for(const t of n.layout.get("clip-layer-scope"))h.push(e.F(t,n.scope));f=!0;}d&&o.push({layer:n.fqid,cache:a,order:l,clipMask:c,clipScope:h});}this.replacementSource.setSources(o),_=!0;}}this._clippingActiveLastFrame=f,_||this.replacementSource.clear(),this.conflationActive=_,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let e=0;e<u.length;e++){const t=u[e];if("none"===t.visibility)continue;const i=t.cutoffRange();if(this.longestCutoffRange=Math.max(i,this.longestCutoffRange),i>0){const e=b(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom));}t.is3D(n)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e);}const w=this.style&&this.style.fog;w?(this._fogVisible=0!==w.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=w.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(v),this.opaquePassCutoff=0,a=s(),u=a.map(e=>r[e]));const T=this._shadowRenderer;if(T){T.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in p)for(const t of m[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),T.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.eL(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Qs(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const E=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),S=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(E&&!this._snow&&(this._snow=new Oa(this)),!E&&this._snow&&(this._snow.destroy(),delete this._snow),S&&!this._rain&&(this._rain=new La(this)),!S&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),h){this.buildingTileBorderManager||(this.buildingTileBorderManager=new ea);const e=this.style.getLayerSourceCache(h);this.buildingTileBorderManager.updateBorders(e,h);}if(!H.has(this.context.gl))return;this.renderPass="offscreen";for(const e of u){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const o=i?g[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||o&&o.length)&&this.renderLayer(this,i,e,o);}this.depthRangeFor3D=[0,1-(u.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,y)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const C="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),I=(()=>{if(i.showOverdrawInspector)return e.aq.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!C){const o="none"===t.properties.get("color-use-theme"),r=t.properties.get("color").toNonPremultipliedRenderColor(o?null:i).toArray01();return new e.aq(...r)}if(C){const o="none"===t.properties.get("space-color-use-theme"),r=t.properties.get("space-color").toNonPremultipliedRenderColor(o?null:i).toArray01();return new e.aq(...r)}}return e.aq.transparent})();if(this.context.clear({color:I,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&C&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=u[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const o=i?(e.is3D(n)?x:g)[i.id]:void 0;this._renderTileClippingMasks(e,i,o),this.renderLayer(this,i,e,o);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&C&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.al(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<a.length;this.currentLayer++){const e=u[this.currentLayer],i=t.getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,i,e,i?g[i.id]:void 0);}function R(e,t){let i;return t&&(i=("symbol"===e.type?v:e.is3D(n)?x:g)[t.id]),i}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<a.length;){const e=u[this.currentLayer];if("raster"===e.type||"raster-particle"===e.type){const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,R(e,i));}++this.currentLayer;}this.renderElevatedRasterBackface=!1;}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;const D=T?T.getGroundShadowLayerIndex():-1;let A=!1,L=-1;for(let e=0;e<a.length;++e){const t=u[e];t.isHidden(this.transform.zoom)||t.is3D(n)&&(L=e);}c&&-1===L&&(l=!0);let P=!1;for(;this.currentLayer<a.length;){const e=u[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer);}else {if(!P&&e.is3D(n)&&!n){const e=this.currentLayer,t=e=>{for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const t=u[this.currentLayer];if(Fa[t.type]){const i=this.style.getLayerSourceCache(t);Fa[t.type](this,i,t,R(t,i),e);}}};t("initialize"),t("reset"),this.currentLayer=e,P=!0;}if(l&&!A&&this.terrain&&!this.transform.isOrthographic&&(A=!0,this.blitDepth()),c&&-1!==L&&this.currentLayer===L+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(e,i,i?m[i.id]:void 0),this.renderLayer(this,i,e,R(e,i)),!this.terrain&&T&&this.currentLayer===D){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const e=u[this.currentLayer];if(Ba[e.type]){const t=this.style.getLayerSourceCache(e);Ba[e.type](this,t,e,R(e,t));}}this.currentLayer=e;}if(T.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=u[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?g[i.id]:void 0);}this.currentLayer=e,this.renderPass="translucent";}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=u[this.currentLayer],o=t.getLayerSourceCache(i),r=o?g[o.id]:void 0;this.terrain||this._renderTileClippingMasks(i,o,o?m[o.id]:void 0),this.renderLayer(this,o,i,r);}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[];}++this.currentLayer;}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;u.forEach(e=>{const o=t.getLayerSourceCache(e);o&&!e.isHidden(this.transform.zoom)&&o.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom<o.getSource().maxzoom)&&(i=o);}),i&&this.options.showTileBoundaries&&Ns(this,i,i.getVisibleCoordinates(),e.aq.red,!1,this.options.showParseStatus);}this.terrain&&this._debugParams.showTerrainProxyTiles&&Ns(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new e.aq(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(e){const t=e.transform.padding;Vs(e,e.transform.height-(t.top||0),3,Ms),Vs(e,t.bottom||0,3,zs),js(e,t.left||0,3,Fs),js(e,e.transform.width-(t.right||0),3,Bs);const i=e.transform.centerPoint;!function(e,t,i,o){Gs(e,t-1,i-10,2,20,o),Gs(e,t-10,i-1,20,2,o);}(e,i.x,e.transform.height-i.y,ks);}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),_||(this.conflationActive=!1);}prepareLayer(e){this.gpuTimingStart(e);const{unsupportedLayers:t}=this.transform.projection,i=!t||!t.includes(e.type);if(za[e.type]&&(i||this.terrain&&"custom"===e.type)){const t=this.style.getLayerSourceCache(e);za[e.type](e,t,this);}this.gpuTimingEnd();}renderLayer(e,t,i,o){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||"model"===i.type||"raster"===i.type||"raster-particle"===i.type||o&&o.length)&&(this.id=i.id,this.gpuTimingStart(i),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(i.type)&&(!e.terrain||"custom"!==i.type)||"clip"===i.type||Ma[i.type](e,t,i,o,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd());}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery,i=this.context.gl;let o=this.gpuTimers[e.id];o||(o=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:i.createQuery()}),o.calls++,i.beginQuery(t.TIME_ELAPSED_EXT,o.query);}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=this.context.gl,i=t.createQuery();this.deferredRenderGpuTimeQueries.push(i),t.beginQuery(e.TIME_ELAPSED_EXT,i);}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT);}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT);}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const o=e[i],r=this.context.extTimerQuery,n=r.getQueryParameter(o.query,this.context.gl.QUERY_RESULT)/1e6;r.deleteQueryEXT(o.query),t[i]=n;}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.gl;let i=0;for(const o of e)i+=t.getQueryParameter(o,t.QUERY_RESULT)/1e6,t.deleteQuery(o);return i}translatePosMatrix(t,i,o,r,n){if(!o[0]&&!o[1])return t;const s=n?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(s){const e=Math.sin(s),t=Math.cos(s);o=[o[0]*t-o[1]*e,o[0]*e+o[1]*t];}const a=[n?o[0]:e.aA(i,o[0],this.transform.zoom),n?o[1]:e.aA(i,o[1],this.transform.zoom),0],l=new Float32Array(16);return e.bx(l,t,a),l}saveTileTexture(e){if(e.context!==this.context)return;const t=e.size[0],i=this._tileTextures[t];i?i.push(e):this._tileTextures[t]=[e];}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const o=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,r=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(r.push("LIGHTING_3D_MODE"),r.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):o||r.push("LIGHTING_3D_MODE")),this.terrainRenderModeElevated()&&(r.push("TERRAIN"),this.linearFloatFilteringSupported()&&r.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&r.push("GLOBE"),!this._fogVisible||o||void 0!==t&&!t||r.push("FOG"),o&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],o=t&&t.config,r=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),n=dn.cacheKey(tr[e],e,r,o);return this.cache[n]||(this.cache[n]=new dn(this.context,e,tr[e],o,Yn[e],r)),this.cache[n]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy();}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const o=this.style.directionalLight,r=this.style.ambientLight;if(o&&r){const n=((t,i,o)=>{const r=t.properties.get("direction"),n="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toNonPremultipliedRenderColor(n?null:o.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toNonPremultipliedRenderColor(l?null:o.getLut(i.scope)).toArray01(),h=i.properties.get("intensity"),d=[r.x,r.y,r.z],_=e.dD(c,h),u=e.dD(s,a);return {u_lighting_ambient_color:_,u_lighting_directional_dir:d,u_lighting_directional_color:u,u_ground_radiance:ln(d,u,_)}})(o,r,this.style);i.setLightsUniformValues(t,n);}}}uploadCommonUniforms(t,i,o,r,n){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const n=s.getOpacity(this.transform.pitch),a=((t,i,o,r,n,s,a,l,c,h,d,_)=>{const u=t.transform,p="none"===i.properties.get("color-use-theme"),f=i.properties.get("color").toNonPremultipliedRenderColor(p?null:t.style.getLut(i.scope)).toArray01();f[3]=r;const m=t.frameCounter/1e3%1,[g,v]=i.properties.get("vertical-range");return {u_fog_matrix:o?u.calculateFogTileMatrix(o):_||t.identityMat,u_fog_range:i.getFovAdjustedRange(u._fov),u_fog_color:f,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,v),v],u_fog_temporal_offset:m,u_frustum_tl:n,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_globe_transition:e.al(u.zoom),u_is_globe:+("globe"===u.projection.name)}})(this,s,o,n,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.o.devicePixelRatio,this.transform.height*e.o.devicePixelRatio],r);i.setFogUniformValues(t,a);}n&&i.setCutoffUniformValues(t,n.uniformValues);}setTileLoadedFlag(e){this.tileLoaded=e;}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1);}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return {canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return !1;const e=this.style&&this.style.fog;return !!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,i=this._backgroundTiles={},o=this.transform.coveringTiles({tileSize:512});for(const r of o)i[r.key]=t[r.key]||new e.b0(r,512,this.transform.tileZoom,this,void 0,this.worldview);return i}clearBackgroundTiles(){this._backgroundTiles={};}isSourceForClippingOrConflation(e,t){return !(!e.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==e.type&&"building"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer&&"procedural_buildings"!==e.sourceLayer)&&(!t||"batched-model"!==t.type)))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return !1;if("globe"===this.transform.projection.name)return !0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=Ke||t[1]>=Ke}setupDepthForOcclusion(e,t,i){const o=this.context,r=o.gl,n=!!i;var s;i||(i={u_dem:2,u_dem_prev:4,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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),o.activeTexture.set(r.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((s=this.depthRangeFor3D)[1]-s[0]),-1-2*s[0]/(s[1]-s[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),o.activeTexture.set(r.TEXTURE0),n||t.setTerrainUniformValues(o,i);}updateEmissiveMode(){if(this._forceEmissiveMode)return;const e=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=e?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant";}}function Na(e,t){let i=!1,o=null;const r=()=>{o=null,i&&(e(),o=setTimeout(r,t),i=!1);};return ()=>(i=!0,o||r(),o)}class Ua{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aZ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Na(this._updateHashUnthrottled.bind(this),300);}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return "";const t=Va(e);if(this._hashName){const e=this._hashName;let i=!1;const o=location.hash.slice(1).split("&").map(o=>{const r=o.split("=")[0];return r===e?(i=!0,`${r}=${t}`):o}).filter(e=>e);return i||o.push(`${e}=${t}`),`#${o.join("&")}`}return `#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(t=e);}),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return !1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(Number(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return !1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()));}}function Va(e,t){const i=e.getCenter(),o=Math.round(100*e.getZoom())/100,r=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),s=Math.round(i.lng*n)/n,a=Math.round(i.lat*n)/n,l=e.getBearing(),c=e.getPitch();let h=t?`/${s}/${a}/${o}`:`${o}/${a}/${s}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const ja={linearity:.3,easing:e.eN(0,0,.3,1)},Ga=Object.assign({deceleration:2500,maxSpeed:1400},ja),Za=Object.assign({deceleration:20,maxSpeed:1400},ja),qa=Object.assign({deceleration:1e3,maxSpeed:360},ja),Ha=Object.assign({deceleration:1e3,maxSpeed:90},ja);class Wa{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.o.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.o.now();for(;t.length>0&&i-t[0].time>160;)t.shift();}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const e=Xa(i.pan.mag(),o,Object.assign({},Ga,t||{}));r.offset=i.pan.mult(e.amount/i.pan.mag()),r.center=this._map.transform.center,$a(r,e);}if(i.zoom){const e=Xa(i.zoom,o,Za);r.zoom=this._map.transform.zoom+e.amount,$a(r,e);}if(i.bearing){const t=Xa(i.bearing,o,qa);r.bearing=this._map.transform.bearing+e.aC(t.amount,-179,179),$a(r,t);}if(i.pitch){const e=Xa(i.pitch,o,Ha);r.pitch=this._map.transform.pitch+e.amount,$a(r,e);}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),r.noMoveStart=!0,r}}function $a(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing);}function Xa(t,i,o){const{maxSpeed:r,linearity:n,deceleration:s}=o,a=e.aC(t*n/(i/1e3),-r,r),l=Math.abs(a)/(s*n);return {easing:o.easing,duration:1e3*l,amount:a*(l/2)}}class Ya extends e.C{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,o={}){const r=g(t.getCanvasContainer(),i),n=t.unproject(r);super(e,Object.assign({point:r,lngLat:n,originalEvent:i},o)),this._defaultPrevented=!1,this.target=t;}}class Ka extends e.C{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,o){const r="touchend"===t?o.changedTouches:o.touches,n=v(i.getCanvasContainer(),r),s=n.map(e=>i.unproject(e)),a=n.reduce((e,t,i,o)=>e.add(t.div(o.length)),new e.P(0,0));super(t,{points:n,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:o}),this._defaultPrevented=!1;}}class Ja extends e.C{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1;}}class Qa{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new Ja(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Ya(e.type,this._map,e))}mouseup(e){this._map.fire(new Ya(e.type,this._map,e));}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new Ya(t.type,this._map,t));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Ya(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new Ya(e.type,this._map,e))}mouseover(e){this._map.fire(new Ya(e.type,this._map,e));}mouseout(e){this._map.fire(new Ya(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Ka(e.type,this._map,e))}touchmove(e){this._map.fire(new Ka(e.type,this._map,e));}touchend(e){this._map.fire(new Ka(e.type,this._map,e));}touchcancel(e){this._map.fire(new Ka(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class el{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new Ya(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ya("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Ya(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class tl{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(u(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,o=this._startPos,r=this._lastPos;if(!o||!r||r.equals(i)||!this._box&&i.dist(o)<this._clickTolerance)return;this._lastPos=i,this._box||(this._box=l("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const n=Math.min(o.x,i.x),s=Math.max(o.x,i.x),a=Math.min(o.y,i.y),c=Math.max(o.y,i.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${n}px,${a}px)`,this._box.style.width=s-n+"px",this._box.style.height=c-a+"px");});}mouseupWindow(t,i){if(!this._active)return;const o=this._startPos,r=i;if(o&&0===t.button){if(this.reset(),m(),o.x!==r.x||o.y!==r.y)return this._map.fire(new e.C("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(o,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t);}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}blur(){this.reset();}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),p(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.C(t,{originalEvent:i}))}}function il(e,t){const i={};for(let o=0;o<e.length;o++)i[e[o].identifier]=t[o];return i}class ol{constructor(e){this.reset(),this.numTouches=e.numTouches;}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1;}touchstart(t,i,o){(this.centroid||o.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),o.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=il(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=il(i,t);for(const e in this.touches){const t=o[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class rl{constructor(e){this.singleTap=new ol(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const o=this.singleTap.touchend(e,t,i);if(o){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(o)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class nl{constructor(){this._zoomIn=new rl({numTouches:1,numTaps:2}),this._zoomOut=new rl({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const o=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(o)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}const sl=0,al=2,ll={[sl]:1,[al]:2},cl={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class hl{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1;}blur(){this.reset();}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0;}_correctButton(e,t){return !1}_move(e,t){return {}}mousedown(e,t){if(this._lastPoint)return;const i=y(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i);}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=ll[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&y(e)===this._eventButton&&(this._moved&&m(),this.reset());}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class dl extends hl{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0);}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return {around:t,panDelta:t.sub(e)}}}class _l extends hl{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?cl[e.pitchRotateKey]:void 0;}_correctButton(e,t){return this._pitchRotateKey?0===t&&e[this._pitchRotateKey]:0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){this._pitchRotateKey||e.preventDefault();}}class ul extends hl{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?cl[e.pitchRotateKey]:void 0;}_correctButton(e,t){return this._pitchRotateKey?0===t&&e[this._pitchRotateKey]:0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){this._pitchRotateKey||e.preventDefault();}}class pl{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),e.aZ(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this);}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0);}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(t,i,o){if(this._active&&!(o.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===o.length&&!e.eO())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,i,o)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset();}touchcancel(){this.reset();}_calculateTransform(t,i,o){o.length>0&&(this._active=!0);const r=il(o,i),n=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(n._add(t),s._add(t.sub(i)),a++,r[e]=t);}if(this._touches=r,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(a),panDelta:l}}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=l("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role");},500);}}class fl{constructor(){this.reset();}reset(){this._active=!1,this._firstTwoTouches=void 0;}_start(e){}_move(e,t,i){return {}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]));}touchmove(e,t,i){const o=this._firstTwoTouches;if(!o)return;e.preventDefault();const[r,n]=o,s=ml(i,t,r),a=ml(i,t,n);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,r]=this._firstTwoTouches,n=ml(i,t,o),s=ml(i,t,r);n&&s||(this._active&&m(),this.reset());}touchcancel(){this.reset();}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}function ml(e,t,i){for(let o=0;o<e.length;o++)if(e[o].identifier===i)return t[o]}function gl(e,t){return Math.log2(e/t)}class vl extends fl{reset(){super.reset(),this._distance=0,this._startDistance=0;}_start(e){this._startDistance=this._distance=e[0].dist(e[1]);}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(gl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:gl(this._distance,i),pinchAround:t}}}function yl(e,t){return 180*e.angleWith(t)/Math.PI}class xl extends fl{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0;}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1]);}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),i&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:yl(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=this._startVector;if(!i)return !1;const o=yl(e,i);return Math.abs(o)<t}}function bl(e){return Math.abs(e.y)>Math.abs(e.x)}class wl extends fl{constructor(e){super(),this._map=e;}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0;}_start(e){this._lastPoints=e,bl(e[0].sub(e[1]))&&(this._valid=!1);}_move(t,i,o){const r=this._lastPoints;if(!r)return;const n=t[0].sub(r[0]),s=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.eO()&&o.touches.length<3||(this._valid=this.gestureBeginsVertically(n,s,o.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const o=e.mag()>=2,r=t.mag()>=2;if(!o&&!r)return;if(!o||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=e.y>0==t.y>0;return bl(e)&&bl(t)&&n}}const Tl={panStep:100,bearingStep:15,pitchStep:10};class El{constructor(){const e=Tl;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1;}blur(){this.reset();}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,o=0,r=0,n=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,o=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Sl,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+o*this._pitchStep,offset:[-r*this._panStep,-n*this._panStep],center:s.getCenter()},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function Sl(e){return e*(2-e)}const Cl=4.000244140625,Il=1/450;class Rl{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Il,e.aZ(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this);}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker());}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()));}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.eO()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const o=e.o.now(),r=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==i&&i%Cl===0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault();}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=g(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Cl?this._wheelZoomRate:this._defaultZoomRate;let o=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==o&&(o=1/o);const r=i(),n=Math.pow(2,r),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):n;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*o))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const o="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,n=this._easing;let s,a=!1;if("wheel"===this._type&&r&&n){const t=Math.min((e.o.now()-this._lastWheelEventTime)/200,1),i=n(t);s=e.am(r,o,i),t<1?this._frameId||(this._frameId=!0):a=!0;}else s=o,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;},200));let l=s-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.eP;if(this._prevEase){const t=this._prevEase,o=(e.o.now()-t.start)/t.duration,r=t.easing(o+.01)-t.easing(o),n=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-n*n);i=e.eN(n,s,.25,1);}return this._prevEase={start:e.o.now(),duration:t,easing:i},i}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role");},200);}}class Dl{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}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 Al{constructor(){this.reset();}reset(){this._active=!1;}blur(){this.reset();}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Ll{constructor(){this._tap=new rl({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset();}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i));}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const o=t[0],r=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp);}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Pl{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},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 Ol{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i;}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 Ml{constructor(e,t,i,o){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("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 zl=e=>e.zoom||e.drag||e.pitch||e.rotate;class Fl extends e.C{}class Bl{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const o=e.ax([],i,t);this.radius=e.ai(o[2]<0?e.eR([],o,this.constants):[o[0],o[1],0]);}projectRay(t){e.eR(t,t,this.constants),e.ay(t,t),e.eS(t,t,this.constants);const i=e.bJ([],t,this.radius);if(i[2]>0){const t=e.bJ([],[0,0,1],e.bi(i,[0,0,1])),o=e.bJ([],e.ay([],[i[0],i[1],0]),this.radius),r=e.cT([],i,e.bJ([],e.ax([],e.cT([],o,t),i),2));i[0]=r[0],i[1]=r[1];}return i}}function kl(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Nl{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wa(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Bl,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aZ(["handleEvent","handleWindowEvent"],this);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,o,i);}}destroy(){for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,o,i);}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Qa(t,e));const o=t.boxZoom=new tl(t,e);this._add("boxZoom",o);const r=new nl,n=new Al;t.doubleClickZoom=new Dl(n,r),this._add("tapZoom",r),this._add("clickZoom",n);const s=new Ll;this._add("tapDragZoom",s);const a=t.touchPitch=new wl(t);this._add("touchPitch",a);const l=new _l(e),c=new ul(e);t.dragRotate=new Ol(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new dl(e),d=new pl(t,e);t.dragPan=new Pl(i,h,d),this._add("mousePan",h),this._add("touchPan",d,["touchZoom","touchRotate"]);const _=new xl,u=new vl;t.touchZoomRotate=new Ml(i,u,_,s),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",u,["touchPan","touchRotate"]),this._add("blockableMapEvent",new el(t));const p=t.scrollZoom=new Rl(t,this);this._add("scrollZoom",p,["mousePan"]);const f=t.keyboard=new El;this._add("keyboard",f);for(const i of ["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i]);}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0;}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return !!zl(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const o in e)if(o!==i&&(!t||t.indexOf(o)<0))return !0;return !1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`);}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,o=i?void 0:e,r={needsRenderFrame:!1},n={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?v(this._el,a):i?void 0:g(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let d;this._blockedByActive(s,h,i)?c.reset():c[t||e.type]&&(d=c[t||e.type](e,l,a),this.mergeHandlerResult(r,n,d,i,o),d&&d.needsRenderFrame&&this._triggerRenderFrame()),(d||c.isActive())&&(s[i]=c);}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=o);this._previousActiveHandlers=s,(Object.keys(c).length||kl(r))&&(this._changes.push([r,n,c]),this._triggerRenderFrame()),(Object.keys(s).length||kl(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(e,t,i,o,r){if(!i)return;Object.assign(e,i);const n={handlerName:o,originalEvent:i.originalEvent||r};void 0!==i.zoomDelta&&(t.zoom=n),void 0!==i.panDelta&&(t.drag=n),void 0!==i.pitchDelta&&(t.pitch=n),void 0!==i.bearingDelta&&(t.rotate=n);}_applyChanges(){const t={},i={},o={};for(const[r,n,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),Object.assign(i,n),Object.assign(o,s);this._updateMapTransform(t,i,o),this._changes=[];}_updateMapTransform(t,i,o){const r=this._map,n=r.transform,s=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!kl(t)){const e=n.zoom;n.cameraElevationReference="sea",null!=this._originalZoom&&n._orthographicProjectionAtLowPitch&&"globe"!==n.projection.name&&0===n.pitch?(n.cameraElevationReference="ground",n.zoom=this._originalZoom):(n.recenterOnTerrain(),n.cameraElevationReference="ground"),e!==n.zoom&&this._map._update(!0);}if(n._isCameraConstrained&&r._stop(!0),!kl(t))return void this._fireEvents(i,o,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:d,aroundCoord:_,pinchAround:u}=t;n._isCameraConstrained&&(l>0&&(l=0),n._isCameraConstrained=!1),void 0!==u&&(d=u),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&d&&(this._dragOrigin=s(n.pointCoordinate3D(d)),this._originalZoom=n.zoom,this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),d=d||r.transform.centerPoint,c&&(n.bearing+=c),h&&(n.pitch+=h),n._updateCameraState();const p=[0,0,0];if(a)if("mercator"===n.projection.name){const e=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(d).dir),t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(d.sub(a)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1];}else {const t=n.pointCoordinate(d);if("globe"===n.projection.name){a=a.rotate(-n.angle);const i=n._pixelsPerMercatorPixel/n.worldSize;p[0]=-a.x*e.eQ(e.bV(t.y))*i,p[1]=-a.y*e.eQ(n.center.lat)*i;}else {const e=n.pointCoordinate(d.sub(a));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y);}}const f=n.zoom,m=[0,0,0];if(l){const t=s(_||n.pointCoordinate3D(d)),i={dir:e.ay([],e.ax([],t,n._camera.position))};if(i.dir[2]<0){const o=n.zoomDeltaToMovement(t,l);e.bJ(m,i.dir,o);}}const g=e.cT(p,p,m);n._translateCameraConstrained(g),l&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,o,!0);}_fireEvents(t,i,o){const r=zl(this._eventsInProgress),n=zl(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in s)this._fireEvent(e,s[e]);n&&this._fireEvent("move",n.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:o}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||o,a[`${e}end`]=l);}for(const e in a)this._fireEvent(e,a[e]);const c=zl(this._eventsInProgress);if(o&&(r||n)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.C("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1;}}_fireEvent(t,i){this._map.fire(new e.C(t,i?{originalEvent:i}:{}));}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{this._frameId=void 0,this.handleEvent(new Fl("renderFrame",{timeStamp:e})),this._applyChanges();})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const Ul="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Vl extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.aZ(["_renderFrameCallback"],this);}getCenter(){return new e.aU(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,o){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},i),o)}panTo(e,t,i){return this.easeTo(Object.assign({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(Object.assign({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(Object.assign({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Object.assign({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(t,i){t=e.aK.convert(t);const o=i&&i.bearing||0,r=i&&i.pitch||0,n=t.getNorthWest(),s=t.getSouthEast();return this._cameraForBounds(this.transform,n,s,o,r,i)}_extendPadding(e){const t={top:0,right:0,bottom:0,left:0};return null==e?Object.assign({},t,this.transform.padding):"number"==typeof e?{top:e,bottom:e,right:e,left:e}:Object.assign({},t,e)}_extendCameraOptions(e){return (e=Object.assign({offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding=this._extendPadding(e.padding),e}_minimumAABBFrustumDistance(e,t){const i=t.max[0]-t.min[0],o=t.max[1]-t.min[1];return i/o>e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):o/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,o,r,n,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=n;const c=e.aU.convert(i),h=e.aU.convert(o),d=.5*(c.lat+h.lat),_=.5*(c.lng+h.lng),u=e.eT(d,_),p=e.ay([],u),f=e.ay([],e.bh([],p,[0,1,0])),m=e.bh([],f,p),g=[f[0],f[1],f[2],0,m[0],m[1],m[2],0,p[0],p[1],p[2],0,0,0,0,1],v=[u,e.eT(c.lat,c.lng),e.eT(h.lat,c.lng),e.eT(h.lat,h.lng),e.eT(c.lat,h.lng),e.eT(d,c.lng),e.eT(d,h.lng),e.eT(c.lat,_),e.eT(h.lat,_)];let y=e.cU.fromPoints(v.map(t=>[e.bi(f,t),e.bi(m,t),e.bi(p,t)]));const x=e.ah([],y.center,g);0===e.eU(x)&&e.eV(x,0,0,1),e.ay(x,x),e.bJ(x,x,e.aF),a.center=e.eW(x);const b=a.getWorldToCameraMatrix(),w=e.b7(new Float64Array(16),b);y=e.cU.applyTransform(y,e.aD([],b,g));const T=this._extendAABB(y,a,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=T,e.ah(x,x,b);const E=.5*(y.max[2]-y.min[2]),S=this._minimumAABBFrustumDistance(a,y),C=e.bJ([],[0,0,1],E),I=e.cT(C,x,C),R=S+(0===a.pitch?0:e.bf(x,I)),D=a.globeCenterInViewSpace,A=e.ax([],x,[D[0],D[1],D[2]]);e.ay(A,A),e.bJ(A,A,R);const L=e.cT([],x,A);e.ah(L,L,w);const P=e.eD/e.aF,O=e.ai(L),M=e.bU(Math.max(O*P-e.eD,Number.EPSILON),0),z=Math.min(a.zoomFromMercatorZAdjusted(M),l.maxZoom);return z>.5*(e.cJ+e.cv)?(a.setProjection({name:"mercator"}),a.zoom=z,this._cameraForBounds(a,i,o,r,n,s)):{center:a.center,zoom:z,bearing:r,pitch:n}}_extendAABB(t,i,o,r){const n=.5*((o.padding.left||0)+(o.padding.right||0)),s=.5*((o.padding.top||0)+(o.padding.bottom||0)),a=s,l=n,c=n,h=s,d=i.width-(l+c),_=i.height-(a+h),u=e.ax([],t.max,t.min),p=Math.min(d/u[0],_/u[1]),f=Math.min(i.scaleZoom(i.scale*p),o.maxZoom);if(isNaN(f))return null;const m=i.scale/i.zoomScale(f),g=new e.cU([t.min[0]-l*m,t.min[1]-h*m,t.min[2]],[t.max[0]+c*m,t.max[1]+a*m,t.max[2]]),v=("number"==typeof o.offset.x&&"number"==typeof o.offset.y?new e.P(o.offset.x,o.offset.y):e.P.convert(o.offset)).rotate(-e.ap(r));return g.center[0]-=v.x*m,g.center[1]+=v.y*m,g}queryTerrainElevation(t,i){const o=this.transform.elevation;return o?(i=Object.assign({},{exaggerated:!0},i),o.getAtPoint(e.ag.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,o,r,n,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,o,r,n,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=n;const c=e.aU.convert(i),h=e.aU.convert(o),d=new e.aU(c.lng,h.lat),_=new e.aU(h.lng,c.lat),u=a.project(c),p=a.project(h),f=this.queryTerrainElevation(c),m=this.queryTerrainElevation(h),g=this.queryTerrainElevation(d),v=this.queryTerrainElevation(_),y=[[u.x,u.y,Math.min(f||0,m||0,g||0,v||0)],[p.x,p.y,Math.max(f||0,m||0,g||0,v||0)]];let x=e.cU.fromPoints(y);const b=a.getWorldToCameraMatrix(),w=e.b7(new Float64Array(16),b);x=e.cU.applyTransform(x,b);const T=this._extendAABB(x,a,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T;const E=.5*e.ax([],x.max,x.min)[2],S=this._minimumAABBFrustumDistance(a,x),C=[0,0,1,0];e.aE(C,C,b),e.eX(C,C);const I=e.bJ([],C,S+E),R=e.cT([],x.center,I);e.ah(x.center,x.center,w),e.ah(R,R,w);const D=a.unproject(new e.P(x.center[0],x.center[1])),A=e.eY(a.projection,D),L=Math.pow(2,A),P=Math.min(a._zoomFromMercatorZ(R[2]*a.pixelsPerMeter*L/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&P<.5*(e.cJ+e.cv)?(a.setProjection({name:"globe"}),a.zoom=P,this._cameraForBounds(a,i,o,r,n,s)):{center:D,zoom:P,bearing:r,pitch:n}}fitBounds(e,t,i){const o=this.cameraForBounds(e,t);return this._fitInternal(o,t,i)}fitScreenCoordinates(t,i,o,r,n){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const h=this.transform.pointLocation3D(l),d=this.transform.pointLocation3D(c),_=this.transform.pointLocation3D(new e.P(l.x,c.y)),u=this.transform.pointLocation3D(new e.P(c.x,l.y)),p=[Math.min(h.lng,d.lng,_.lng,u.lng),Math.min(h.lat,d.lat,_.lat,u.lat)],f=[Math.max(h.lng,d.lng,_.lng,u.lng),Math.max(h.lat,d.lat,_.lat,u.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,p,f,o,m,r);return this._fitInternal(g,r,n)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(t,i){this.stop();const o=t.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,s=!1;"zoom"in t&&o.zoom!==+t.zoom&&(r=!0,o.zoom=+t.zoom),void 0!==t.center&&(o.center=e.aU.convert(t.center)),"bearing"in t&&o.bearing!==+t.bearing&&(n=!0,o.bearing=+t.bearing),"pitch"in t&&o.pitch!==+t.pitch&&(s=!0,o.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!o.isPaddingEqual(a))if(!1===t.retainPadding){const e=o.clone();e.padding=a,o.setLocationAtPoint(o.center,e.centerPoint);}else o.padding=a;return t.preloadOnly?(this._preloadTiles(o),this):(this.fire(new e.C("movestart",i)).fire(new e.C("move",i)),r&&this.fire(new e.C("zoomstart",i)).fire(new e.C("zoom",i)).fire(new e.C("zoomend",i)),n&&this.fire(new e.C("rotatestart",i)).fire(new e.C("rotate",i)).fire(new e.C("rotateend",i)),s&&this.fire(new e.C("pitchstart",i)).fire(new e.C("pitch",i)).fire(new e.C("pitchend",i)),this.fire(new e.C("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Ul),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const o=this.transform;if(!o.projection.supportsFreeCamera)return e.w(Ul),this;this.stop();const r=o.zoom,n=o.pitch,s=o.bearing;o.setFreeCameraOptions(t);const a=r!==o.zoom,l=n!==o.pitch,c=s!==o.bearing;return this.fire(new e.C("movestart",i)).fire(new e.C("move",i)),a&&this.fire(new e.C("zoomstart",i)).fire(new e.C("zoom",i)).fire(new e.C("zoomend",i)),c&&this.fire(new e.C("rotatestart",i)).fire(new e.C("rotate",i)).fire(new e.C("rotateend",i)),l&&this.fire(new e.C("pitchstart",i)).fire(new e.C("pitch",i)).fire(new e.C("pitchend",i)),this.fire(new e.C("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=Object.assign({offset:[0,0],duration:500,easing:e.eP},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const o=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,d=this._extendPadding(t.padding),_=e.P.convert(t.offset);let u,p,f;if("globe"===o.projection.name){const i=e.ag.fromLngLat(o.center),r=_.rotate(-o.angle);i.x+=r.x/o.worldSize,i.y+=r.y/o.worldSize;const n=i.toLngLat(),s=e.aU.convert(t.center||n);this._normalizeCenter(s),u=o.centerPoint.add(r),p=new e.P(i.x,i.y).mult(o.worldSize),f=new e.P(e.aH(s.lng),e.aL(s.lat)).mult(o.worldSize).sub(p);}else {u=o.centerPoint.add(_);const i=o.pointLocation(u),r=e.aU.convert(t.center||i);this._normalizeCenter(r),p=o.project(i),f=o.project(r).sub(p);}const m=o.zoomScale(l-r);let g,v;t.around&&(g=e.aU.convert(t.around),v=o.locationPoint(g));const y=this._zooming||l!==r,x=this._rotating||n!==c,b=this._pitching||h!==s,w=!o.isPaddingEqual(d),T=!1===t.retainPadding?o.clone():o,E=o=>E=>{if(y&&(o.zoom=e.am(r,l,E)),x&&(o.bearing=e.am(n,c,E)),b&&(o.pitch=e.am(s,h,E)),w&&(T.interpolatePadding(a,d,E),u=T.centerPoint.add(_)),g)o.setLocationAtPoint(g,v);else {const e=o.zoomScale(o.zoom-r),t=l>r?Math.min(2,m):Math.max(.5,m),i=Math.pow(t,1-E),n=o.unproject(p.add(f.mult(E*i)).mult(e));o.setLocationAtPoint(o.renderWorldCopies?n.wrap():n,u);}return t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(E,t.duration,o);return this._preloadTiles(e),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,S),this._ease(E(o),e=>{"sea"===o.cameraElevationReference&&o.recenterOnTerrain(),this._afterEase(i,e);},t),this}_prepareEase(t,i,o={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||o.moving||this.fire(new e.C("movestart",t)),this._zooming&&!o.zooming&&this.fire(new e.C("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new e.C("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new e.C("pitchstart",t));}_fireMoveEvents(t){this.fire(new e.C("move",t)),this._zooming&&this.fire(new e.C("zoom",t)),this._rotating&&this.fire(new e.C("rotate",t)),this._pitching&&this.fire(new e.C("pitch",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const o=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new e.C("zoomend",t)),r&&this.fire(new e.C("rotateend",t)),n&&this.fire(new e.C("pitchend",t)),this.fire(new e.C("moveend",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const o=e.aJ(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(o,i)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.eP},t);const o=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.aC(+t.zoom,o.minZoom,o.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,d=this._extendPadding(t.padding),_=o.zoomScale(l-r),u=e.P.convert(t.offset);let p=o.centerPoint.add(u);const f=o.pointLocation(p),m=e.aU.convert(t.center||f);this._normalizeCenter(m);const g=o.project(f),v=o.project(m).sub(g);let y=t.curve;const x=Math.max(o.width,o.height),b=x/_,w=v.mag();if("minZoom"in t){const i=e.aC(Math.min(t.minZoom,r,l),o.minZoom,o.maxZoom),n=x/o.zoomScale(i-r);y=Math.sqrt(n/w*2);}const T=y*y;function E(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return (Math.exp(e)-Math.exp(-e))/2}function C(e){return (Math.exp(e)+Math.exp(-e))/2}const I=E(0);let R=function(e){return C(I)/C(I+y*e)},D=function(e){return x*((C(I)*(S(t=I+y*e)/C(t))-S(I))/T)/w;var t;},A=(E(1)-I)/y;if(Math.abs(w)<1e-6||!isFinite(A)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,i);const e=b<x?-1:1;A=Math.abs(Math.log(b/x))/y,D=function(){return 0},R=function(t){return Math.exp(e*y*t)};}t.duration="duration"in t?+t.duration:1e3*A/("screenSpeed"in t?+t.screenSpeed/y:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const L=n!==c,P=h!==s,O=!o.isPaddingEqual(d),M=!1===t.retainPadding?o.clone():o,z=o=>_=>{const f=_*A,y=1/R(f);o.zoom=1===_?l:r+o.scaleZoom(y),L&&(o.bearing=e.am(n,c,_)),P&&(o.pitch=e.am(s,h,_)),O&&(M.interpolatePadding(a,d,_),p=M.centerPoint.add(u));const x=1===_?m:o.unproject(g.add(v.mult(D(f))).mult(y));return o.setLocationAtPoint(o.renderWorldCopies?x.wrap():x,p),o._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(z,t.duration,o);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=P,this._padding=O,this._prepareEase(i,!1),this._ease(z(o),()=>this._afterEase(i),t),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t);}if(!e){const e=this.handlers;e&&e.stop(!1);}return this}_ease(t,i,o){!1===o.animate||0===o.duration?(t(1),i()):(this._easeStart=e.o.now(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.o.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();}_normalizeBearing(t,i){t=e.bs(t,-180,180);const o=Math.abs(t-i);return Math.abs(t-360-i)<o&&(t-=360),Math.abs(t+360-i)<o&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(t.maxBounds)return;if("globe"!==t.projection.name&&!t.renderWorldCopies)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const o=Math.ceil(15*t/1e3),r=[],n=e(i.clone());for(let e=0;e<=o;e++){const t=n(e/o);r.push(t.clone());}return r}_preloadTiles(e,t){}}class jl{constructor(t={}){this.options=t,e.aZ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this);}getDefaultPosition(){return "bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const o=l("span","mapboxgl-ctrl-icon",this._compactButton);return o.setAttribute("aria-hidden","true"),o.setAttribute("title",i),this._innerContainer=l("div","mapboxgl-ctrl-attrib-inner",this._container),t&&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===t&&(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;}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"));}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.g.ACCESS_TOKEN}];if(t){const o=i.reduce((e,t,o)=>(t.value&&(e+=`${t.key}=${t.value}${o<i.length-1?"&":""}`),e),"?");t.href=`${e.g.FEEDBACK_URL}/${o}#${Va(this._map,!0)}`,t.rel="noopener nofollow";}}_updateData(e){!e||("source"!==e.dataType||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType)&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink());}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style._mergedSourceCaches;for(const i in t){const o=t[i];if(o.used){const t=o.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let o=i+1;o<e.length;o++)if(e[o].indexOf(t)>=0)return !1;return !0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.map(e=>function(e){const t=(new DOMParser).parseFromString(e,"text/html");return Array.from(t.body.querySelectorAll("*")).reverse().forEach(e=>{const i=e.textContent||"";if("A"!==e.tagName)return void e.replaceWith(...e.childNodes);const o=e.getAttribute("href");if(!o||!/^(https?:|mailto:)/i.test(o))return void e.replaceWith(t.createTextNode(i));const r=t.createElement("a");r.href=o,r.textContent=i,r.rel="noopener nofollow";const n=e.getAttribute("class");n&&(r.className=n),e.replaceWith(r);}),t.body.innerHTML}(e)).join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,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 Gl{constructor(){e.aZ(["_updateLogo","_updateCompact"],this);}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none");}_logoRequired(){if(!this._map.style)return !0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return !0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return !1}return !0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact");}}}class Zl{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}class ql{constructor(e){this.jumpTo(e);}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.dn((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e;}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i;}}const Hl={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class Wl extends e.C{constructor(e,t,i,o){const{point:r,lngLat:n,originalEvent:s,target:a}=e;super(e.type,{point:r,lngLat:n,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault();},this.id=t,this.interaction=i,this.feature=o;}}class $l{constructor(e){this.map=e,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map;}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const o=i.filter;let r=i.type;o&&this.filters.set(t,e.dg(o)),"mouseover"===r&&(r="mouseenter"),"mouseout"===r&&(r="mouseleave");const n=this.interactionsByType.get(r)||new Map;"mouseenter"===r||"mouseleave"===r?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===n.size&&this.map.on(r,this.handleType),0===n.size&&this.interactionsByType.set(r,n),n.set(t,i),this.typeById.set(t,r);}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);i&&(i.delete(e),"mouseenter"===t||"mouseleave"===t?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===i.size&&this.map.off(t,this.handleType));}queryTargets(e,t){const i=[];for(const[e,o]of t)o.target&&i.push({targetId:e,target:o.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const t=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());t.length&&(e.type="mouseenter",this.handleType(e,t));const i=new Map;for(const[e,{feature:t}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||i.set(t.id,t);i.size&&(e.type="mouseleave",this.handleType(e,Array.from(i.values())));}handleOut(e){const t=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);t.length&&(e.type="mouseleave",this.handleType(e,t)),this.hoveredFeatures.clear();}handleType(t,i){const o="mouseenter"===t.type;if(o&&!this.interactionsByType.has(t.type))return void e.w("mouseenter interaction required for mouseleave to work.");const r=Array.from(this.interactionsByType.get(t.type)).reverse(),n=!!i;i=i||this.queryTargets(t.point,r);let s=!1;const a=new Set;for(const l of i){for(const[i,c]of r){if(!c.target)continue;const r=l.variants?l.variants[i]:null;if(r){for(const h of r){if(Rt(h,l,a,i))continue;const r=new e.di(l,h),d=It(h,l,i);n&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const _=o?this.prevHoveredFeatures.get(d):null,u=new Wl(t,i,c,r),p=_?_.stop:c.handler(u);if(o&&this.hoveredFeatures.set(d,{feature:l,stop:p}),!1!==p){s=!0;break}}if(s)break}}if(s)break}if(!s)for(const[e,i]of r){const{handler:o,target:r}=i;if(!r&&!1!==o(new Wl(t,e,i,null)))break}}}function Xl(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),o=new Set(i);return e.size===o.size&&t.every(e=>o.has(e))}return e.b6(t,i)}const Yl={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,useServerFontComposition:!0,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},Kl={showCompass:!0,showZoom:!0,visualizePitch:!1};class Jl{constructor(t,i,o=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new _l({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,o&&(this.mousePitch=new ul({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aZ(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset);}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),u();}move(e,t){const i=this.map,o=this.mouseRotate.mousemoveWindow(e,t),r=o&&o.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const o=this.mousePitch.mousemoveWindow(e,t),r=o&&o.pitchDelta;r&&i.setPitch(i.getPitch()+r);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){p(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup);}mousedown(e){this.down(Object.assign({},e,{button:e.button,type:e.type,ctrlKey:!0,preventDefault:()=>e.preventDefault()}),g(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,g(this.element,e));}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp();}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=v(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos));}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=v(this.element,e.targetTouches)[0],this.move({buttons:1,preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.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();}}function Ql(t,i,o){if(t=new e.aU(t.lng,t.lat),i){const r=new e.aU(t.lng-360,t.lat),n=new e.aU(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-o.center.lng)/360),a=o.locationPoint3D(t).distSqr(i),l=i.x<0||i.y<0||i.x>o.width||i.y>o.height;o.locationPoint3D(r).distSqr(i)<a&&(l||Math.abs(r.lng-o.center.lng)<s)?t=r:o.locationPoint3D(n).distSqr(i)<a&&(l||Math.abs(n.lng-o.center.lng)<s)&&(t=n);}for(;Math.abs(t.lng-o.center.lng)>180;){const e=o.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=o.width&&e.y<=o.height)break;t.lng>o.center.lng?t.lng-=360:t.lng+=360;}return t}const ec={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%)"},tc={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class ic extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t=Object.assign({element:t},i)),e.aZ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:o="center",color:r="#3FB1CE",scale:n=1,draggable:s=!1,clickTolerance:a=0,rotation:l=tc.rotation,rotationAlignment:c=tc.rotationAlignment,pitchAlignment:h=tc.pitchAlignment,occludedOpacity:d=tc.occludedOpacity,altitude:_=tc.altitude}=t||{};this._anchor=o,this._color=r,this._scale=n,this._draggable=s,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=h,this._occludedOpacity=d,this._altitude=_,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=e.P.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault();}),this._element.addEventListener("mousedown",e=>{e.preventDefault();});const u=this._element.classList;for(const e in ec)u.remove(`mapboxgl-marker-anchor-${e}`);u.add(`mapboxgl-marker-anchor-${this._anchor}`);const p=t&&t.className?t.className.trim().split(/\s+/):[];u.add(...p),this._popup=null;}_createDefaultMarker(){const e=l("div"),t=c("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);if(0===this._altitude){const e=c("radialGradient",{id:"shadowGradient"},c("defs",{},t));c("stop",{offset:"10%","stop-opacity":.4},e),c("stop",{offset:"100%","stop-opacity":.05},e),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},t);}return c("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"},t),c("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"},t),c("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},t),e}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.aU.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){return e===this._altitude||(this._defaultMarker&&(0===this._altitude&&0!==e||0!==this._altitude&&0===e)&&(this._element=this._createDefaultMarker()),this._altitude=e||tc.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,o=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[o,-1*(t-i+o)],"bottom-right":[-o,-1*(t-i+o)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,e._altitude=this._altitude,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(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return !1;const i=e.unproject(t,this._altitude),o=e.getFreeCameraOptions();if(!o.position)return !1;const r=o.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const o=t.unproject(i,this._altitude);let r;t._showingGlobe()&&e.e$(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(o),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null;}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null);}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n            translate(${e.x}px,${e.y}px)\n            ${ec[this._anchor]}\n            ${this._calculateXYTransform()} ${this._calculateZTransform()}\n            translate(${t.x}px,${t.y}px)\n        `;}_calculateXYTransform(){const t=this._pos,i=this._map,o=this.getPitchAlignment();if(!i||!t||"map"!==o)return "";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.cH(e.f0(i.transform,this._lngLat)),n=t.sub(e.f1(i.transform)),s=Math.abs(n.x)+Math.abs(n.y);if(0===s)return "";const a=r/s;return `rotateX(${-n.y*a}deg) rotateY(${n.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return "";let o=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.aU(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=i.project(new e.aU(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);o=e.cH(Math.atan2(r.y,r.x))-90;}else o=-i.getBearing();else if("horizon"===r){const r=e.aj(4,6,i.getZoom()),n=e.f1(i.transform);n.y+=r*i.transform.height;const s=t.sub(n),a=e.cH(Math.atan2(s.y,s.x));o=(a>90?a-270:a+90)*(1-r);}return o+=this._rotation,o?`rotateZ(${o}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Ql(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat,this._altitude),!0===e?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM());}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)));}));}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const o=this._pointerdownPos,r=this._positionDelta;if(o&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(o)<e)return;this._isDragging=!0;}this._pos=t.point.sub(r),this._lngLat=i.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.C("dragstart"))),this.fire(new e.C("drag"));}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.C("dragend")),this._state="inactive";}_addDragHandler(e){const t=this._map,i=this._pos;t&&i&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(i),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp));}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||tc.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||tc.rotationAlignment,this._update(),this}getRotationAlignment(){return "auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||tc.pitchAlignment,this._update(),this}getPitchAlignment(){return "auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||tc.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const oc={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},rc={maxWidth:100,unit:"metric"},nc={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},sc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},ac=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function lc(t=new e.P(0,0),i="bottom"){if("number"==typeof t){const o=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case "top":return new e.P(0,t);case "top-left":return new e.P(o,o);case "top-right":return new e.P(-o,o);case "bottom":return new e.P(0,-t);case "bottom-left":return new e.P(o,-o);case "bottom-right":return new e.P(-o,-o);case "left":return new e.P(t,0);case "right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[i]||[0,0])}const cc={version:t,supported:a.supported,setRTLTextPlugin:e.f3,getRTLTextPluginStatus:e.f2,addTileProvider:function(t,i){if(!t||!i)throw new Error("TileProvider name and URL are required");e.g.TILE_PROVIDER_URLS[t]=e.o.resolveURL(i);},Map:class extends Vl{constructor(t){o.mark(i.create);const r=t;if(null!=(t=Object.assign({},Yl,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");t.antialias&&e.eZ(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new ao(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Zl,this._domRenderTaskQueue=new Zl,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.r(),this._locale=Object.assign({},Hl,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ql(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new T(t.transformRequest,t.accessToken,t.testMode);const n=R(t.accessToken||e.g.ACCESS_TOKEN);if(n&&"atlas"in n&&"number"==typeof n.atlas&&(this._tokenExpiration=n.atlas),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?Object.assign({},t.contextCreateOptions):{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e;}else {if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container;}if(this._container.childNodes.length>0&&e.w("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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._spriteFormat="auto",e.aZ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Nl(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,this._useServerFontComposition=t.useServerFontComposition,(t.style||!t.testMode)&&this.setStyle(t.style||e.g.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,useServerFontComposition:this._useServerFontComposition}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Ua("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const e=t.bounds;e&&(this.resize(),this.fitBounds(e,Object.assign({},t.fitBoundsOptions,{duration:0})));}this.resize(),t.attributionControl&&this.addControl(new jl({customAttribution:t.customAttribution})),this._logoControl=new Gl,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent();}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.C(`${t.dataType}data`,t));}),this.on("dataloading",t=>{this.fire(new e.C(`${t.dataType}dataloading`,t));}),this._interactions=new $l(this);}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.B(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return -1!==i.indexOf("bottom")?r.insertBefore(o,r.firstChild):r.appendChild(o),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.B(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 i=!this._moving;return i&&this.fire(new e.C("movestart",t)).fire(new e.C("move",t)),this.fire(new e.C("resize",t)),i&&this.fire(new e.C("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.aK.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.C("zoomstart")).fire(new e.C("zoom")).fire(new e.C("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=t??22)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.C("zoomstart")).fire(new e.C("zoom")).fire(new e.C("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new e.C("pitchstart")).fire(new e.C("pitch")).fire(new e.C("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=t??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.C("pitchstart")).fire(new e.C("pitch")).fire(new e.C("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(e=>"symbol"===e.type),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return "auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?navigator.language:e):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this._styleDirty=!0,this.style.setWorldview(e),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return "globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let o;"globe"===i&&t.zoom>=e.cv?(t.setMercatorFromTransition(),o=!0):"mercator"===i&&t.zoom<e.cv&&(t.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0));}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(t){let i;const o=this.transform.mercatorFromTransition;i="globe"===t.name&&this.transform.zoom>=e.cv?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&o!==this.transform.mercatorFromTransition;return (i||r)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.aU.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(e.P.convert(t),i)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){const o=e=>{let i=[];if(Array.isArray(t)){const o=t.filter(e=>this.getLayer(e));i=o.length?this.queryRenderedFeatures(e,{layers:o}):[];}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let r=!1;const n=t=>{const n=o(t.point);n.length?r||(r=!0,i.call(this,new Ya(e,this,t.originalEvent,{features:n}))):r=!1;};return {listener:i,targets:t,delegates:{mousemove:n,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=t=>{o(t.point).length?r=!0:r&&(r=!1,i.call(this,new Ya(e,this,t.originalEvent)));},s=t=>{r&&(r=!1,i.call(this,new Ya(e,this,t.originalEvent)));};return {listener:i,targets:t,delegates:{mousemove:n,mouseout:s}}}{const r=e=>{const t=o(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features);};return {listener:i,targets:t,delegates:{[e]:r}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(o);for(const e in o.delegates)this.on(e,o.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._createDelegatedListener(e,t,i);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._delegatedListeners?this._delegatedListeners[e]:void 0;return o&&(e=>{for(let o=0;o<e.length;o++){const r=e[o];if(r.listener===i&&Xl(r.targets,t)){for(const e in r.delegates)this.off(e,r.delegates[e]);return e.splice(o,1),this}}})(o),this}queryRenderedFeatures(t,i){if(!this.style)return [];if(void 0===t||t instanceof e.P||Array.isArray(t)||void 0!==i||(i=t,t=void 0),t=t||[[0,0],[this.transform.width,this.transform.height]],!i){const e=this.style.queryRenderedFeatures(t,void 0,this.transform),i=this.style.queryRenderedFeatureset(t,void 0,this.transform);return e.concat(i)}let o=!0;if(i.target&&(o=this._isTargetValid(i.target),o&&!i.layers))return this.style.queryRenderedFeatureset(t,i,this.transform);let r=!0;if(i.layers&&Array.isArray(i.layers)){for(const e of i.layers)if(!this._isValidId(e)){r=!1;break}if(r&&!i.target)return this.style.queryRenderedFeatures(t,i,this.transform)}let n=[];return r&&(n=n.concat(this.style.queryRenderedFeatures(t,i,this.transform))),o&&(n=n.concat(this.style.queryRenderedFeatureset(t,i,this.transform))),n}querySourceFeatures(e,t){return !e||"string"==typeof e&&!this._isValidId(e)?[]:this.style.querySourceFeatures(e,t)}queryRasterValue(e,t,i){return this._isValidId(e)?this.style.queryRasterValue(e,t,i):Promise.resolve(null)}isPointOnSurface(t){const{name:i}=this.transform.projection;return "globe"!==i&&"mercator"!==i&&e.w(`${i} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(e.P.convert(t))}addInteraction(e,t){return this._interactions.add(e,t),this}removeInteraction(e){return this._interactions.remove(e),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(e){return this._cooperativeGestures=e,this}setStyle(t,i){return i=Object.assign({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,useServerFontComposition:this._useServerFontComposition},i),this.style&&t&&!1!==i.diff&&i.localFontFamily===this._localFontFamily&&i.localIdeographFontFamily===this._localIdeographFontFamily&&!i.config?(this.style._diffStyle(t,(o,r)=>{if(o){const r="string"==typeof o?o:o instanceof Error?o.message:o.error;e.w(`Unable to perform style diff: ${r}. Rebuilding the style from scratch.`),this._updateStyle(t,i);}else r&&this._update(!0);},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){const i=Object.assign({},t);t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new Po(this,i).load(e),this.style.setEventedParent(this,{style:this.style});}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Po(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.B(new Error("IDs can't be empty."))),!1):!e.db(t)||(this.fire(new e.B(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isTargetValid(e){return "featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return !1;return !0}return this._isTargetValid(e)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return !!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i);}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:o=1,sdf:r=!1,stretchX:n,stretchY:s,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:h}=e.o.getImageData(i);this.style.addImage(l,{data:new e.q({width:t,height:c},h),pixelRatio:o,stretchX:n,stretchY:s,content:a,sdf:r,version:0,usvg:!1});}else if(void 0===i.width||void 0===i.height)this.fire(new e.B(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else {const{width:c,height:h}=i,d=i;this.style.addImage(l,{data:new e.q({width:c,height:h},new Uint8Array(d.data)),pixelRatio:o,stretchX:n,stretchY:s,content:a,sdf:r,usvg:!1,version:0,userImage:d}),d.onAdd&&d.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const o=e.I.from(t),r=this.style.getImage(o);if(!r)return void this.fire(new e.B(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.o.getImageData(i):i,{width:s,height:a,data:l}=n;if(void 0===s||void 0===a)return void this.fire(new e.B(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(s!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||a!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new e.B(new Error(`The width and height of the updated image (${s}, ${a})\n                must be that same as the previous version of the image\n                (${r.data.width}, ${r.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let h=!1;r.usvg?(r.data=new e.q({width:s,height:a},new Uint8Array(l)),r.usvg=!1,r.icon=void 0,h=!0):r.data.replace(l,c),this.style.updateImage(o,r,h);}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.B(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t));}loadImage(t,i){e.n(this._requestManager.transformRequest(t,e.R.Image),(e,t)=>{i(e,t);});}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.B(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e);}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(t,i){return this.style.addImport(t,i).catch(t=>this.fire(new e.B(new Error("Failed to add import",t)))),this}updateImport(e,t){return "string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){if(!this._isValidId(e))return null;const t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,o),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,o),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setLayerProperty(e,t,i,o={}){return this._isValidId(e)?("appearances"===t&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(e,t,i,o),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat");}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(e){const t=this.transform.nearClipOffset!==e;return this.transform.nearClipOffset=e,this._update(t)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.aU.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_selectIndoorFloor(e){this.style.indoorManager.selectFloor(e);}_setIndoorActiveFloorsVisibility(e){this.style.indoorManager.setActiveFloorsVisibility(e);}getIndoorTileOptions(e,t){return this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(e,t):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,o,r,n=this._container;for(;n&&(!o||!r);){const e=window.getComputedStyle(n).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(o=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),n=n.parentElement;}this._containerWidth=o?Math.abs(e/o):e,this._containerHeight=r?Math.abs(t/r):t;}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._canvas=l("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=l("div","mapboxgl-control-container",e),o=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{o[e]=l("div",`mapboxgl-ctrl-${e}`,i);}),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(t,i){const o=e.o.devicePixelRatio||1;this._canvas.width=o*Math.ceil(t),this._canvas.height=o*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`;}_addMarker(e){this._markers.push(e);}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1);}_addPopup(e){this._popups.push(e);}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1);}_setupPainter(){const t=Object.assign({},a.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(W(i,!0),this.painter=new ka(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",e=>{if("source"===e.dataType){const t=this.transform.elevation?this.transform.elevation._source():null;t&&e.sourceCacheId===t.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0);}}),e.k.testSupport(i)):this.fire(new e.B(new Error("Failed to initialize WebGL")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.C("webglcontextlost",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.C("webglcontextrestored",{originalEvent:t}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return !this.isMoving()&&this.loaded()}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e);}_render(t){let r;this.fire(new e.C("renderstart")),++this._frameId;const n=this.painter.context.extTimerQuery,s=e.o.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=a.createQuery(),a.beginQuery(n.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,o=e.o.now(),r=new e.ae(t,{now:o,fadeDuration:l,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(r);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(s),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(s),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.C("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.mark(i.load),this.fire(new e.C("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.o.now()-s;a.endQuery(n.TIME_ELAPSED_EXT),setTimeout(()=>{const i=a.getQueryParameter(r,a.QUERY_RESULT)/1e6;a.deleteQuery(r),this.fire(new e.C("gpu-timing-frame",{cpuTime:t,gpuTime:i}));},50);}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.C("gpu-timing-layer",{layerTimes:i}));},50);}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.C("gpu-timing-deferred-render",{gpuTime:i}));},50);}const h=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(h||this._repaint)this.triggerRepaint();else {const t=this.idle();if(t&&(c=this._updateAverageElevation(s,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.C("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.C("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1;}}!this._loaded||this._fullyLoaded||h||(this._fullyLoaded=!0,o.mark(i.fullLoad),this._performanceMetricsCollection&&G(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate());}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update();}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const o=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(o||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const n=Math.abs(t-r);if(n>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300);}else if(n>1e-4)return this._averageElevation.jumpTo(r),i(r)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_isTokenExpired(){return null!=this._tokenExpiration&&Date.now()>this._tokenExpiration}_revokeAuth(){const t=this.painter.context.gl;W(t,!1),this._logoControl instanceof Gl&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.B(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")));}_authenticate(){q(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,e=>{e&&(e.message!==w&&401!==e.status||this._revokeAuth());}),this._isTokenExpired()&&this._revokeAuth(),z(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{});}_postStyleLoadEvent(){this.style.globalId&&B(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()});}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&N(this._requestManager._customAccessToken);}_postAddingAppearancesToStyleEvent(){V(this._requestManager._customAccessToken);}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e);}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,o=i.createFramebuffer();function r(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,o),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let o=i[1]-i[0];const r=e.length/4;for(let n=0;n<t.length;n++){const s=t[n];let a=0;for(let t=0;t<s.length;t+=4)s[t]===e[t]&&s[t+1]===e[t+1]&&s[t+2]===e[t+2]&&s[t+3]===e[t+3]&&(a+=1);o+=(i[n+2]-i[n+1])*(1-a/r);}return o}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),H.delete(this.painter.context.gl),Z.remove(),M.remove(),this._removed=!0,this.fire(new e.C("remove"));}triggerRepaint(){this._triggerFrame(!0);}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.o.frame(e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e);}));}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.t(i,(e,i)=>e._preloadTiles(t,i),()=>{this.triggerRepaint();}),this}_onWindowOnline(){this._update();}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update();}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++;}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showParseStatus(){return !!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._update());}get speedIndexTiming(){return !!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this.style&&e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update());}_setCacheLimits(t,i){e.e_(t,i);}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=Object.assign({},Kl,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.aZ(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e});}),l("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e});}),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aZ(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}));}),this._compassIcon=l("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),o=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString());}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t);});}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Jl(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0);}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}},GeolocateControl:class extends e.E{constructor(t={}){super();const i=navigator.geolocation;this.options=Object.assign({geolocation:i},oc,t),e.aZ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Na(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1;}_checkGeolocationSupport(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t);};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t();}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return !!t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case "ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case "BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");}}_onSuccess(t){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.C("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));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(t),this.options.followUserLocation&&(!this.options.trackUserLocation||"ACTIVE_LOCK"===this._watchState)&&this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.C("geolocate",Object.assign({coords:t.coords,timestamp:t.timestamp},t.toJSON?{toJSON:t.toJSON.bind(t)}:{}))),this._finish();}}_updateCamera(t){const i=new e.aU(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,r=this._map.getBearing(),n=Object.assign({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),n,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.aU(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();}_updateCircleRadius(){const t=this._map.transform,i=e.bU(1,t._center.lat)*t.worldSize,o=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0));}_onError(t){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(1===t.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===t.code&&this._noTimeout)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.C("error",{code:t.code,message:t.message,PERMISSION_DENIED:t.PERMISSION_DENIED,POSITION_UNAVAILABLE:t.POSITION_UNAVAILABLE,TIMEOUT:t.TIMEOUT})),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_startRequestTimeout(){this._clearRequestTimeout();const e=this.options.positionOptions.timeout;e&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"});},e));}_clearRequestTimeout(){void 0!==this._requestTimeoutId&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0);}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new ic({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ic({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.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.C("trackuserlocationend")));});}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled());}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.C("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.C("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 e.C("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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return !0}setFollowUserLocation(t){return this.options.followUserLocation=null!=t?t:oc.followUserLocation,this.options.trackUserLocation&&"OFF"!==this._watchState&&(this.options.followUserLocation?"BACKGROUND"!==this._watchState&&"BACKGROUND_ERROR"!==this._watchState||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.C("trackuserlocationstart"))):"ACTIVE_LOCK"!==this._watchState&&"ACTIVE_ERROR"!==this._watchState||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new e.C("trackuserlocationend")))),this}_addDeviceOrientationListener(){const e=()=>{const e="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(e,this._onDeviceOrientation);};"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e();}).catch(console.error):e();}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},AttributionControl:jl,ScaleControl:class{constructor(t={}){this.options=Object.assign({},rc,t),e.aZ(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,o=t._containerWidth/2-e/2,r=t.unproject([o,i]),n=t.unproject([o+e,i]),s=r.distanceTo(n);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter");}_setScale(e,t,i){this._map._requestDomTask(()=>{const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),r=o/t;this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(o):`${o}&nbsp;${nc[i]}`,this._container.style.width=e*r+"px";});}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0;}_setLanguage(e){this._language=e,this._update();}setUnit(e){this.options.unit=e,this._update();}},FullscreenControl:class{constructor(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.aZ(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange");}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon);}_checkFullscreenSupport(){return !(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e);}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||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()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen();}},IndoorControl:class{constructor(){e.aZ(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null;}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection();}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const e=this._map.style.indoorManager;e.off("selector-update",this._onIndoorUpdate),e.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(e.getControlState());}}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){e.setAttribute("aria-label",t),e.textContent=t;}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null);}getDefaultPosition(){return "top-right"}_onIndoorUpdate(e){if(!e||!e.floors||0===e.floors.length)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block";const i=!t||t.floors.length!==e.floors.length||t.floors.some((t,i)=>t.id!==e.floors[i].id);if(i&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),e.selectedFloorId){if(e.selectedFloorId!==this._lastSelectedFloorId||i){const t=e.floors.findIndex(t=>t.id===e.selectedFloorId);if(-1!==t){const i=e.floors.length;let o,r;i<=5?(o=0,r=i-1):0===this._visibleFloorStart?(o=0,r=3):this._visibleFloorStart>=i-3?(o=i-3-1,r=i-1):(o=this._visibleFloorStart,r=this._visibleFloorStart+3-1),t<o?this._visibleFloorStart=t:t>r&&(this._visibleFloorStart=t-2);}}this._lastSelectedFloorId=e.selectedFloorId;}this._render();}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const e=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(e);const t=this._model.floors,i=t.length;if(i<=5)return void t.forEach(e=>this._createFloorButton(e));const o=0===this._visibleFloorStart,r=this._visibleFloorStart>=i-3;if(o)this._createFloorButton(t[0]);else {const e=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}let n=[];if(n=o?t.slice(1,4):r?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),n.forEach(e=>this._createFloorButton(e)),r)this._createFloorButton(t[i-1]);else {const e=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}}_createFloorButton(e){const t=this._createButton("mapboxgl-ctrl-level-button",()=>{const t=e.id;this._model&&this._model.selectedFloorId===t&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(t));}),i=(e.name||"").trim(),o=e.zIndex.toString(),r=i?Array.from(i).slice(0,3).join(""):o;this._setButtonTitle(t,r),this._model&&this._model.activeFloorsVisible&&e.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t);}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1);}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,1===this._visibleFloorStart&&(this._visibleFloorStart=0);const e=this._model&&this._model.floors||[];if(e.length>3){const t=e.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2);}this._render();}}_scrollDown(){if(this._model&&this._model.floors){const e=this._model.floors.length-3;this._visibleFloorStart<e&&(this._visibleFloorStart++,1===this._visibleFloorStart&&(this._visibleFloorStart=2),this._visibleFloorStart===e-1&&(this._visibleFloorStart=e),this._visibleFloorStart>e&&(this._visibleFloorStart=e),this._render());}}},Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(sc),t),this._altitude=this.options.altitude,e.aZ(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[]);}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.C("open")),this}isOpen(){return !!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.C("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aU.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(e){return this._altitude=e,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let o;for(i.innerHTML=e;o=i.firstChild,o;)t.appendChild(o);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='<span aria-hidden="true">&#215;</span>',e.addEventListener("click",this._onClose);}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point);}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,o=this._pos;if(!t||!i||!o)return "bottom";const r=i.offsetWidth,n=i.offsetHeight,s=o.x<r/2,a=o.x>t.transform.width-r/2;if(o.y+e<n)return s?"top-left":a?"top-right":"top";if(o.y>t.transform.height-n){if(s)return "bottom-left";if(a)return "bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ");}_update(t){const i=this._map,o=this._content;if(!i||!this._lngLat&&!this._trackPointer||!o)return;let r=this._container;if(r||(r=this._container=l("div","mapboxgl-popup",i.getContainer()),this._tip=l("div","mapboxgl-popup-tip",r),r.appendChild(o)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ql(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const o=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),r=lc(this.options.offset),n=this._anchor=this._getAnchor(r.y),s=lc(this.options.offset,n),a=o.add(s).round();i._requestDomTask(()=>{this._container&&n&&(this._container.style.transform=`${ec[n]} translate(${a.x}px,${a.y}px)`);});}if(!this._marker&&i._showingGlobe()){const t=e.e$(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(ac);e&&e.focus();}_onClose(){this.remove();}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none");}},Marker:ic,Style:Po,LngLat:e.aU,LngLatBounds:e.aK,Point:e.P,MercatorCoordinate:e.ag,FreeCameraOptions:io,Evented:e.E,config:e.g,prewarm:function(){oe().acquire(J);},clearPrewarmedResources:function(){const e=te;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(J),te=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 e.g.ACCESS_TOKEN},set accessToken(t){e.g.ACCESS_TOKEN=t;},get baseApiUrl(){return e.g.API_URL},set baseApiUrl(t){e.g.API_URL=t;},get workerCount(){return Q.workerCount},set workerCount(e){Q.workerCount=e;},get maxParallelImageRequests(){return e.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.g.MAX_PARALLEL_IMAGE_REQUESTS=t;},clearStorage(t){e.f7(t);},get workerUrl(){return Y.workerUrl},set workerUrl(e){Y.workerUrl=e;},get workerClass(){return Y.workerClass},set workerClass(e){Y.workerClass=e;},get workerParams(){return Y.workerParams},set workerParams(e){Y.workerParams=e;},get dracoUrl(){return e.f6()},set dracoUrl(t){e.g.DRACO_URL=e.o.resolveURL(t);},get meshoptUrl(){return e.f5()},set meshoptUrl(t){const i=e.o.resolveURL(t);e.g.MESHOPT_URL=i,e.g.MESHOPT_SIMD_URL=i;},get buildingGenUrl(){return e.f4()},set buildingGenUrl(t){e.g.BUILDING_GEN_URL=e.o.resolveURL(t);},setNow:e.o.setNow,restoreNow:e.o.restoreNow};return cc});

var mapboxgl$1 = mapboxgl;

return mapboxgl$1;

}));
//# sourceMappingURL=mapbox-gl.js.map
