11 lines
1.5 MiB
11 lines
1.5 MiB
var e,t;e=this,t=function(){var e=1e-6,t="undefined"!=typeof Float32Array?Float32Array:Array;function i(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*o-n*r;return s?(e[0]=o*(s=1/s),e[1]=-r*s,e[2]=-n*s,e[3]=i*s,e):null}function r(){var e=new t(9);return t!=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 n(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}function o(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=s*u-a*c,e[1]=n*c-r*u,e[2]=r*a-n*s,e[3]=a*l-o*u,e[4]=i*u-n*l,e[5]=n*o-i*a,e[6]=o*c-s*l,e[7]=r*l-i*c,e[8]=i*s-r*o,e}function s(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=d*r+p*s+f*c,e[1]=d*n+p*a+f*u,e[2]=d*o+p*l+f*h,e[3]=m*r+_*s+g*c,e[4]=m*n+_*a+g*u,e[5]=m*o+_*l+g*h,e[6]=y*r+x*s+v*c,e[7]=y*n+x*a+v*u,e[8]=y*o+x*l+v*h,e}function a(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function l(){var e=new t(16);return t!=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 c(e){var i=new t(16);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i}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 h(e,t){if(e===t){var i=t[1],r=t[2],n=t[3],o=t[6],s=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=n,e[13]=s,e[14]=a}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}function d(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,E=u*m-h*f,S=u*_-d*f,A=u*g-p*f,I=h*_-d*m,C=h*g-p*m,M=d*g-p*_,D=y*M-x*C+v*I+b*A-w*S+T*E;return D?(e[0]=(a*M-l*C+c*I)*(D=1/D),e[1]=(n*C-r*M-o*I)*D,e[2]=(m*T-_*w+g*b)*D,e[3]=(d*w-h*T-p*b)*D,e[4]=(l*A-s*M-c*S)*D,e[5]=(i*M-n*A+o*S)*D,e[6]=(_*v-f*T-g*x)*D,e[7]=(u*T-d*v+p*x)*D,e[8]=(s*C-a*A+c*E)*D,e[9]=(r*A-i*C-o*E)*D,e[10]=(f*w-m*v+g*y)*D,e[11]=(h*v-u*w-p*y)*D,e[12]=(a*S-s*I-l*E)*D,e[13]=(i*I-r*S+n*E)*D,e[14]=(m*x-f*b-_*y)*D,e[15]=(u*b-h*x+d*y)*D,e):null}function p(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*h+w*m,e[1]=x*n+v*l+b*d+w*_,e[2]=x*o+v*c+b*p+w*g,e[3]=x*s+v*u+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*h+(w=i[7])*m,e[5]=x*n+v*l+b*d+w*_,e[6]=x*o+v*c+b*p+w*g,e[7]=x*s+v*u+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*h+(w=i[11])*m,e[9]=x*n+v*l+b*d+w*_,e[10]=x*o+v*c+b*p+w*g,e[11]=x*s+v*u+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*h+(w=i[15])*m,e[13]=x*n+v*l+b*d+w*_,e[14]=x*o+v*c+b*p+w*g,e[15]=x*s+v*u+b*f+w*y,e}function f(e,t,i){var r,n,o,s,a,l,c,u,h,d,p,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*_+h*g+t[12],e[13]=n*m+l*_+d*g+t[13],e[14]=o*m+c*_+p*g+t[14],e[15]=s*m+u*_+f*g+t[15]),e}function m(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function _(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=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]=o*n+c*r,e[5]=s*n+u*r,e[6]=a*n+h*r,e[7]=l*n+d*r,e[8]=c*n-o*r,e[9]=u*n-s*r,e[10]=h*n-a*r,e[11]=d*n-l*r,e}function g(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=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]=o*n-c*r,e[1]=s*n-u*r,e[2]=a*n-h*r,e[3]=l*n-d*r,e[8]=o*r+c*n,e[9]=s*r+u*n,e[10]=a*r+h*n,e[11]=l*r+d*n,e}function y(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=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]=o*n+c*r,e[1]=s*n+u*r,e[2]=a*n+h*r,e[3]=l*n+d*r,e[4]=c*n-o*r,e[5]=u*n-s*r,e[6]=h*n-a*r,e[7]=d*n-l*r,e}function x(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 v(t,i,r){var n,o,s,a=r[0],l=r[1],c=r[2],u=Math.sqrt(a*a+l*l+c*c);return u<e?null:(a*=u=1/u,l*=u,c*=u,n=Math.sin(i),o=Math.cos(i),t[0]=a*a*(s=1-o)+o,t[1]=l*a*s+c*n,t[2]=c*a*s-l*n,t[3]=0,t[4]=a*l*s-c*n,t[5]=l*l*s+o,t[6]=c*l*s+a*n,t[7]=0,t[8]=a*c*s+l*n,t[9]=l*c*s-a*n,t[10]=c*c*s+o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function b(e,t){var i=t[0],r=t[1],n=t[2],o=t[4],s=t[5],a=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(i*i+r*r+n*n),e[1]=Math.sqrt(o*o+s*s+a*a),e[2]=Math.sqrt(l*l+c*c+u*u),e}function w(e,i){var r=new t(3);b(r,i);var n=1/r[0],o=1/r[1],s=1/r[2],a=i[0]*n,l=i[1]*o,c=i[2]*s,u=i[4]*n,h=i[5]*o,d=i[6]*s,p=i[8]*n,f=i[9]*o,m=i[10]*s,_=a+h+m,g=0;return _>0?(g=2*Math.sqrt(_+1),e[3]=.25*g,e[0]=(d-f)/g,e[1]=(p-c)/g,e[2]=(l-u)/g):a>h&&a>m?(g=2*Math.sqrt(1+a-h-m),e[3]=(d-f)/g,e[0]=.25*g,e[1]=(l+u)/g,e[2]=(p+c)/g):h>m?(g=2*Math.sqrt(1+h-a-m),e[3]=(p-c)/g,e[0]=(l+u)/g,e[1]=.25*g,e[2]=(d+f)/g):(g=2*Math.sqrt(1+m-a-h),e[3]=(l-u)/g,e[0]=(p+c)/g,e[1]=(d+f)/g,e[2]=.25*g),e}function T(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,u=r*s,h=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-h-f,e[1]=u+g,e[2]=d-_,e[3]=0,e[4]=u-g,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+_,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}var E=function(e,t,i,r,n){var o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,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!=n&&n!==1/0){var s=1/(r-n);e[10]=(n+r)*s,e[14]=2*n*r*s}else e[10]=-1,e[14]=-2*r;return e},S=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,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*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e},A=p;function I(){var e=new t(3);return t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function C(e){var i=new t(3);return i[0]=e[0],i[1]=e[1],i[2]=e[2],i}function M(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function D(e,i,r){var n=new t(3);return n[0]=e,n[1]=i,n[2]=r,n}function P(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e}function L(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function R(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function z(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function F(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e}function O(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e}function B(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function k(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function U(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(i*i+r*r+n*n)}function V(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}function N(e){var t=e[0],i=e[1],r=e[2];return t*t+i*i+r*r}function j(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function G(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function H(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function q(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e}function $(e,t,i,r){var n=t[0],o=t[1],s=t[2];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e}function Z(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e}function W(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e}function X(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=n*c-o*l,h=o*a-r*c,d=r*l-n*a;return e[0]=a+s*(u+=u)+n*(d+=d)-o*(h+=h),e[1]=l+s*h+o*u-r*d,e[2]=c+s*d+r*h-n*u,e}function Y(e){return e[0]=0,e[1]=0,e[2]=0,e}function K(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var J=R,Q=z,ee=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e},te=M;function ie(){var e=new t(4);return t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function re(e,i,r,n){var o=new t(4);return o[0]=e,o[1]=i,o[2]=r,o[3]=n,o}function ne(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function oe(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e}function se(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e}function ae(){var e=new t(4);return t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function le(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ce(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e}function ue(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a,e}function he(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e}I(),ie();var de,pe,fe,me=oe,_e=(de=I(),pe=D(1,0,0),fe=D(0,1,0),function(e,t,i){var r=H(t,i);return r<-.999999?(q(de,pe,t),te(de)<1e-6&&q(de,fe,t),G(de,de),function(e,t,i){i*=.5;var r=Math.sin(i);e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i)}(e,de,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(q(de,t,i),e[0]=de[0],e[1]=de[1],e[2]=de[2],e[3]=1+r,me(e,e))});function ge(){var e=new t(2);return t!=Float32Array&&(e[0]=0,e[1]=0),e}function ye(e,i){var r=new t(2);return r[0]=e,r[1]=i,r}function xe(e,t,i){return e[0]=t,e[1]=i,e}function ve(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e}function be(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function we(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function Te(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function Ee(e,t){var i=t[0],r=t[1],n=i*i+r*r;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e}function Se(e,t){return e[0]*t[0]+e[1]*t[1]}ae(),ae(),r();var Ae,Ie,Ce=be;function Me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}ge();var De=function(){if(Ie)return Ae;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return Ie=1,Ae=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 i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)<t)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o}var s=0,a=1;for(i=e,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-e)<t));r++)e>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},Ae}(),Pe=Me(De);function Le(e,t){this.x=e,this.y=t}function Re(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Re(e[i],t[i]))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 i in e)if(!Re(e[i],t[i]))return!1;return!0}return e===t}Le.prototype={clone(){return new Le(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,i=e.y-this.y;return t*t+i*i},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),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround(e,t){const i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Le},Le.convert=function(e){if(e instanceof Le)return e;if(Array.isArray(e))return new Le(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Le(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const ze=Math.PI/180,Fe=180/Math.PI;function Oe(e){return e*ze}function Be(e){return e*Fe}const ke=[[0,0],[1,0],[1,1],[0,1]];function Ue(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function Ve(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return{min:new Le(t,i),max:new Le(r,n)}}function Ne(e,t,i=0,r=!0){const n=new Le(i,i),o=e.sub(n),s=t.add(n),a=[o,new Le(s.x,o.y),s,new Le(o.x,s.y)];return r&&a.push(o.clone()),a}function je(e,t,i,r){const n=new Pe(e,t,i,r);return function(e){return n.solve(e)}}const Ge=je(.25,.1,.25,1);function He(e,t,i){return Math.min(i,Math.max(t,e))}function qe(e,t,i){return(i=He((i-e)/(t-e),0,1))*i*(3-2*i)}function $e(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function Ze(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),n[s]=t,0==--r&&i(o,n)}))}))}function We(e,t){const i={};for(let r=0;r<t.length;r++){const n=t[r];n in e&&(i[n]=e[n])}return i}let Xe=1;function Ye(){return Xe++}function Ke(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function Je(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log2(e)))}function Qe(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)}function et(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function tt(e,t,i){const r={};for(const i in e)r[i]=t.call(this,e[i],i,e);return r}function it(e,t,i){const r={};for(const i in e)t.call(this,e[i],i,e)&&(r[i]=e[i]);return r}function rt(e){return Array.isArray(e)?e.map(rt):"object"==typeof e&&e?tt(e,rt):e}function nt(e,t){for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>=0)return!0;return!1}const ot={};function st(e){ot[e]||("undefined"!=typeof console&&console.warn(e),ot[e]=!0)}function at(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function lt(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}function ct([e,t,i]){const r=Oe(t+90),n=Oe(i);return{x:e*Math.cos(r)*Math.sin(n),y:e*Math.sin(r)*Math.sin(n),z:e*Math.cos(n),azimuthal:t,polar:i}}function ut(e,t,i){const r=Math.sqrt(e*e+t*t+i*i),n=r>0?Math.acos(i/r)*Fe:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Fe+90:0;return o<0&&(o+=360),[r,o,n]}function ht(e){return("undefined"!=typeof self||void 0!==e)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==e?e:self)instanceof WorkerGlobalScope}function dt(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}function pt(e){return e?{cacheControl:e.get("Cache-Control"),expires:e.get("Expires")}:{cacheControl:void 0,expires:void 0}}let ft=null;function mt(){return!!document.fullscreenElement||!!document.webkitFullscreenElement}function _t(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function gt(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function yt(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]}function xt(e,t){return[Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]}function vt(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]}function bt(e,t,i,r){for(;t<i;){const n=t+i>>1;e[n]<r?t=n+1:i=n}return t}function wt(e,t,i,r){for(;t<i;){const n=t+i>>1;e[n]<=r?t=n+1:i=n}return t}function Tt(e){return e>0?1/(1.001-e):1+e}function Et(e){return e>0?1-1/(1.001-e):-e}function St(e,t,i){return(e-t.min)*(i.max-i.min)/(t.max-t.min)+i.min}function It(e){return e*e*e*e*e}var Ct="3.17.0";const Mt={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(!Mt.API_URL)return null;try{const e=new URL(Mt.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:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function Dt(e){return Mt.API_URL_REGEX.test(e)}function Pt(e){return 0===e.indexOf("mapbox:")}function Lt(e){return Mt.API_CDN_URL_REGEX.test(e)}function Rt(e){return Mt.API_SPRITE_REGEX.test(e)}function zt(e){return Mt.API_STYLE_REGEX.test(e)&&!Rt(e)}const Ft={create:"create",load:"load",fullLoad:"fullLoad"},Ot={mark(e){performance.mark(e)},measure(e,t,i){performance.measure(e,t,i)}};function Bt(e){const t=e.name.split("?")[0];return Lt(t)&&t.includes("mapbox-gl.js")?"javascript":Lt(t)&&t.includes("mapbox-gl.css")?"css":function(e){return Mt.API_FONTS_REGEX.test(e)}(t)?"fontRange":Rt(t)?"sprite":zt(t)?"style":function(e){return Mt.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}var kt,Ut={},Vt=function(){if(kt)return Ut;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"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(r),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[r=t&&t.failIfMajorPerformanceCaveat]&&(i[r]=function(t){var i,r=function(t){var i=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",r)}(t);if(!r)return!1;try{i=r.createShader(r.VERTEX_SHADER)}catch(e){return!1}return!(!i||r.isContextLost())&&(r.shaderSource(i,"void main() {}"),r.compileShader(i),!0===r.getShaderParameter(i,r.COMPILE_STATUS))}(r)),i[r]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var r}kt=1,Ut.supported=e,Ut.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},Ut}();let Nt,jt,Gt,Ht,qt,$t;function Zt(){return null==Nt&&(Nt=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Nt}const Wt={now:()=>void 0!==Ht?Ht:performance.now(),setNow(e){Ht=e},restoreNow(){Ht=void 0},frame(e){const t=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:r}=e;qt||(qt=document.createElement("canvas"));const n=qt.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return(i>qt.width||r>qt.height)&&(qt.width=i,qt.height=r),n.clearRect(-t,-t,i+2*t,r+2*t),n.drawImage(e,0,0,i,r),n.getImageData(-t,-t,i+2*t,r+2*t)},resolveURL:e=>(jt||(jt=document.createElement("a")),jt.href=e,jt.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==Gt&&(Gt=window.matchMedia("(prefers-reduced-motion: reduce)")),Gt.matches)},hasCanvasFingerprintNoise(){if(void 0!==$t)return $t;if(!Zt())return $t=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let i=0;for(let r=0;r<e.width;++r)t.fillStyle=`rgba(${i++},${i++},${i++}, 255)`,t.fillRect(r,0,1,1);const r=t.getImageData(0,0,e.width,e.height);i=0;for(let e=0;e<r.data.length;++e)if(e%4!=3&&i++!==r.data[e])return $t=!0,!0;return $t=!1,!1}};function Xt(e,t,i){const r=document.createElement(e);return null!=t&&(r.className=t),i&&i.appendChild(r),r}function Yt(e,t,i){const r=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))r.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(r),r}const Kt="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,Jt=Kt&&void 0!==Kt.userSelect?"userSelect":"WebkitUserSelect";let Qt;function ei(){Kt&&Jt&&(Qt=Kt[Jt],Kt[Jt]="none")}function ti(){Kt&&Jt&&(Kt[Jt]=Qt)}function ii(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",ii,!0)}function ri(){window.addEventListener("click",ii,!0),window.setTimeout((()=>{window.removeEventListener("click",ii,!0)}),0)}function ni(e,t){const i=e.getBoundingClientRect();return ai(e,i,t)}function oi(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n<t.length;n++)r.push(ai(e,i,t[n]));return r}function si(e){return/firefox/i.test(navigator.userAgent)&&/macintosh/i.test(navigator.userAgent)&&2===e.button&&e.ctrlKey?0:e.button}function ai(e,t,i){const r=e.offsetWidth===t.width?1:e.offsetWidth/t.width;return new Le((i.clientX-t.left)*r,(i.clientY-t.top)*r)}function li(e,t){const i=e.indexOf("?");if(i<0)return`${e}?${new URLSearchParams(t).toString()}`;const r=new URLSearchParams(e.slice(i));for(const e in t)r.set(e,t[e]);return`${e.slice(0,i)}?${r.toString()}`}function ci(e,t={persistentParams:[]}){const i=e.indexOf("?");if(i<0)return e;const r=new URLSearchParams,n=new URLSearchParams(e.slice(i));for(const e of t.persistentParams){const t=n.get(e);t&&r.set(e,t)}const o=r.toString();return`${e.slice(0,i)}${o.length>0?`?${o}`:""}`}const ui="mapbox-tiles";let hi=500,di=50;const pi=["language","worldview","jobid"];let fi,mi;function _i(){try{return caches}catch(e){}}function gi(){const e=_i();e&&null==fi&&(fi=e.open(ui))}let yi=1/0;function xi(e){yi++,yi>di&&(e.getActor().send("enforceCacheSizeLimit",hi),yi=0)}const vi={supported:!1,testSupport:function(e){!Ti&&wi&&(Ei?Ai(e):bi=e)}};let bi,wi,Ti=!1,Ei=!1;const Si="undefined"!=typeof self?self:{};function Ai(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,wi),e.isContextLost())return;vi.supported=!0}catch(e){}e.deleteTexture(t),Ti=!0}Si.document&&(wi=Si.document.createElement("img"),wi.onload=function(){bi&&Ai(bi),bi=null,Ei=!0},wi.onerror=function(){Ti=!0,bi=null},wi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ii={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Ii);class AJAXError extends Error{constructor(e,t,i){401===t&&Dt(i)&&(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=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ci=ht()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href;const Mi=function(e,t){if(!(/^file:/.test(i=e.url)||/^file:/.test(Ci())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(e,t){const i=new AbortController,r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Ci(),referrerPolicy:e.referrerPolicy,signal:i.signal});let n=!1,o=!1;const s=(a=r.url).indexOf("sku=")>0&&Dt(a);var a;"json"===e.type&&r.headers.set("Accept","application/json");const l=(i,n,a)=>{if(o)return;if(i&&"SecurityError"!==i.message&&st(i.toString()),n&&a)return c(n);const l=Date.now();fetch(r).then((i=>{if(i.ok){const e=s?i.clone():null;return c(i,e,l)}return t(new AJAXError(i.statusText,i.status,e.url))})).catch((i=>{"AbortError"!==i.name&&t(new Error(`${i.message} ${e.url}`))}))},c=(i,s,a)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then((e=>{o||(s&&a&&function(e,t,i){if(gi(),null==fi)return;const r=dt(t.headers.get("Cache-Control")||"");if(r["no-store"])return;const n={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach(((e,t)=>n.headers.set(t,e))),r["max-age"]&&n.headers.set("Expires",new Date(i+1e3*r["max-age"]).toUTCString());const o=n.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i<42e4)return;let s=ci(e.url,{persistentParams:pi});if(206===t.status){const t=e.headers.get("Range");if(!t)return;n.status=200,s=li(s,{range:t})}!function(e,t){if(void 0===mi)try{new Response(new ReadableStream),mi=!0}catch(e){mi=!1}mi?t(e.body):e.blob().then(t).catch((e=>st(e.message)))}(t,(e=>{const i=new Response(200!==(r=t.status)&&404!==r&&[101,103,204,205,304].includes(r)?null:e,n);var r;gi(),null!=fi&&fi.then((e=>e.put(s,i))).catch((e=>st(e.message)))}))}(r,s,a),n=!0,t(null,e,i.headers))})).catch((e=>{o||t(new Error(e.message))}))};return s?function(e,t){if(gi(),null==fi)return t(null);fi.then((i=>{let r=ci(e.url,{persistentParams:pi});const n=e.headers.get("Range");n&&(r=li(r,{range:n})),i.match(r).then((e=>{const n=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=dt(e.headers.get("Cache-Control")||"");return Number(t)>Date.now()&&!i["no-cache"]}(e);i.delete(r).catch(t),n&&i.put(r,e.clone()).catch(t),t(null,e,n)})).catch(t)})).catch(t)}(r,l):l(null,null),{cancel:()=>{o=!0,n||i.abort()}}}(e,t);if(ht(self)&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var i;return function(e,t){const i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{t(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===e.type)try{r=JSON.parse(i.response)}catch(e){return t(e)}const n=new Headers;i.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach((e=>{const t=e.split(": "),i=t.shift(),r=t.join(": ");n.append(i,r)})),t(null,r,n)}else t(new AJAXError(i.statusText,i.status,e.url))},i.send(e.body),{cancel:()=>i.abort()}}(e,t)},Di=function(e,t){return Mi(Object.assign(e,{type:"json"}),t)},Pi=function(e,t){return Mi(Object.assign(e,{type:"arrayBuffer"}),t)};function Li(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}const Ri="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let zi,Fi;zi=[],Fi=0;const Oi=function(e,t){if(vi.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Fi>=Mt.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return zi.push(i),i}Fi++;let i=!1;const r=()=>{if(!i)for(i=!0,Fi--;zi.length&&Fi<Mt.MAX_PARALLEL_IMAGE_REQUESTS;){const e=zi.shift(),{requestParameters:t,callback:i,cancelled:r}=e;r||(e.cancel=Oi(t,i).cancel)}},n=Pi(e,((e,i,n)=>{r(),e?t(e):i&&(self.createImageBitmap?function(e,t){const i=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(i).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.`))}))}(i,((e,i)=>t(e,i,n))):function(e,t){const i=new Image;i.onload=()=>{t(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame((()=>{i.src=Ri}))},i.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const r=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?URL.createObjectURL(r):Ri}(i,((e,i)=>t(e,i,n))))}));return{cancel:()=>{n.cancel(),r()}}},Bi="01",ki="NO_ACCESS_TOKEN";class RequestManager{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",Bi,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(e,t){if(!Pt(e))return e;const i=Vi(e);return i.params.push(`sdk=js-${Ct}`),i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!Pt(e))return e;const i=Vi(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeModelURL(e,t){if(!Pt(e))return e;const i=Vi(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,r){if(!Pt(e))return e;const n=Vi(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeIconsetURL(e,t){const i=Vi(e);return Pt(e)?(i.path=`/styles/v1${i.path}/iconset.pbf`,this._makeAPIURL(i,this._customAccessToken||t)):Ni(i)}normalizeSpriteURL(e,t,i,r){const n=Vi(e);return Pt(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,Ni(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!Pt(e))return e;const r=Vi(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==r.authority&&512===i?"@2x":""}${vi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${Mt.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${Mt.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${Mt.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${Mt.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)||Mt.ACCESS_TOKEN;return Mt.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(e,t){const i=Vi(e);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${Mt.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${Mt.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${Mt.TILE_URL_VERSION}/`,"")}`;let n=i.params;return t&&(n=n.filter((e=>!e.match(/^access_token=/)))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(e,t){const i=!!t&&Pt(t),r=[];for(const t of e.tiles||[])Dt(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=Vi(Mt.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!Mt.REQUIRE_ACCESS_TOKEN)return Ni(e);if(t=t||Mt.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),Ni(e)}}const Ui=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Vi(e){const t=e.match(Ui);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 Ni(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const ji="mapbox.eventData";function Gi(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(atob(t[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class TelemetryEvent{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=Gi(Mt.ACCESS_TOKEN);let i="";return i=t&&t.u?btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):Mt.ACCESS_TOKEN||"",e?`${ji}.${e}:${i}`:`${ji}:${i}`}fetchEventData(){const e=_t("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp");if(e)try{const e=localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const n=localStorage.getItem(i);n&&(this.anonId=n);const o=localStorage.getItem(r);o&&(this.anonIdTimestamp=Number(o));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<s)&&this.refreshUUID()}catch(e){st("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=Ke(),this.anonIdTimestamp=Date.now()}saveEventData(){const e=_t("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp"),n=this.anonId,o=this.anonIdTimestamp;if(e&&n)try{localStorage.setItem(i,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(t,JSON.stringify(this.eventData)),o&&localStorage.setItem(r,o.toString())}catch(e){st("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,r){if(!Mt.EVENTS_URL)return;const n=Vi(Mt.EVENTS_URL);n.params.push(`access_token=${r||Mt.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(e).toISOString()},s=t?Object.assign(o,t):o,a={url:Ni(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=function(e,t){return Mi(Object.assign(e,{method:"POST"}),t)}(a,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}class MetricsEvent extends TelemetryEvent{constructor(e){super("metrics"),e&&(this.data=e)}postMetricsEvent(e){if(!Mt.EVENTS_URL||!e&&!Mt.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),Qe(this.anonId)||this.refreshUUID();const t=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,(()=>{}),e)}}const Hi=new class TurnstileEvent extends TelemetryEvent{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){Mt.EVENTS_URL&&Mt.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>Pt(e)||Dt(e)))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Gi(Mt.ACCESS_TOKEN),i=t?t.u:Mt.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;Qe(this.anonId)||(this.refreshUUID(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||e.getDate()!==t.getDate()}else r=!0;r?this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Ct,skuId:Bi,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)}),e):this.processRequests()}},qi=Hi.postTurnstileEvent.bind(Hi),$i=new class MapLoadEvent extends TelemetryEvent{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,r){this.skuToken=t,this.errorCb=r,Mt.EVENTS_URL&&(i||Mt.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(ki)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),Qe(this.anonId)||this.refreshUUID(),this.postEvent(i,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Ct,skuId:Bi,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e))}remove(){this.errorCb=null}},Zi=$i.postMapLoadEvent.bind($i),Wi=new class StyleLoadEvent extends TelemetryEvent{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(e){let t=this.mapInstanceIdMap.get(e);return t||(t=Ke(),this.mapInstanceIdMap.set(e,t)),t}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:r,importedStyles:n}=t;if(!Mt.EVENTS_URL||!e&&!Mt.ACCESS_TOKEN)return;const o=this.getMapInstanceId(i),s={mapInstanceId:o,eventId:this.getEventId(o),style:r};n.length&&(s.importedStyles=n),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)}},Xi=Wi.postStyleLoadEvent.bind(Wi),Yi=new MetricsEvent({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Ki=Yi.postMetricsEvent.bind(Yi),Ji=new MetricsEvent({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Qi=Ji.postMetricsEvent.bind(Ji),er=new class PerformanceEvent extends TelemetryEvent{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){Mt.EVENTS_URL&&(e||Mt.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,performanceData:i}=this.queue.shift(),r=function(e){const t=performance.getEntriesByType("resource"),i=performance.getEntriesByType("mark"),r=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const r of e[i]){const e=`${i}ResolveRangeMin`,n=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,r.startTime),t[n]=Math.max(t[n]||-1/0,r.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&a(s),a(o)}return t}(function(e,t){const i={};if(e)for(const r of e){const e=t(r);void 0===i[e]&&(i[e]=[]),i[e].push(r)}return i}(t,Bt)),n=window.devicePixelRatio,o=navigator.connection||navigator.mozConnection||navigator.webkitConnection,s=o?o.effectiveType:void 0,a={counters:[],metadata:[],attributes:[]},l=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in r)l(a.counters,e,r[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(l(a.counters,"interactionRangeMin",e.interactionRange[0]),l(a.counters,"interactionRangeMax",e.interactionRange[1])),i)for(const e of Object.values(Ft)){const t=i.find((t=>t.name===e));t&&l(a.counters,e,t.startTime)}return l(a.counters,"visibilityHidden",e.visibilityHidden),l(a.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(zt(e)){const t=e.split("/").slice(-2);if(2===t.length)return`mapbox://styles/${t[0]}/${t[1]}`}}}(t)),l(a.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),l(a.attributes,"fogEnabled",e.fogEnabled?"true":"false"),l(a.attributes,"projection",e.projection),l(a.attributes,"zoom",e.zoom),l(a.metadata,"devicePixelRatio",n),l(a.metadata,"connectionEffectiveType",s),l(a.metadata,"navigatorUserAgent",navigator.userAgent),l(a.metadata,"screenWidth",window.screen.width),l(a.metadata,"screenHeight",window.screen.height),l(a.metadata,"windowWidth",window.innerWidth),l(a.metadata,"windowHeight",window.innerHeight),l(a.metadata,"mapWidth",e.width/n),l(a.metadata,"mapHeight",e.height/n),l(a.metadata,"webglRenderer",e.renderer),l(a.metadata,"webglVendor",e.vendor),l(a.metadata,"sdkVersion",Ct),l(a.metadata,"sdkIdentifier","mapbox-gl-js"),a}(i);for(const e of r.metadata);for(const e of r.counters);for(const e of r.attributes);this.postEvent(t,r,(()=>{}),e)}},tr=er.postPerformanceEvent.bind(er),ir=new class MapSessionAPI extends TelemetryEvent{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,r){if(!Mt.API_URL||!Mt.SESSION_PATH)return;const n=Vi(Mt.API_URL+Mt.SESSION_PATH);n.params.push(`sku=${t||""}`),n.params.push(`access_token=${r||Mt.ACCESS_TOKEN||""}`);const o={url:Ni(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return Mi(Object.assign(e,{method:"GET"}),t)}(o,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(e,t,i,r){this.skuToken=t,this.errorCb=r,Mt.SESSION_PATH&&Mt.API_URL&&(i||Mt.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(ki)))}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}},rr=ir.getSessionAPI.bind(ir),nr=new Set;function or(e,t){t?nr.add(e):nr.delete(e)}var sr,ar,lr,cr={exports:{}},ur={exports:{}},hr={exports:{}},dr=function(){if(lr)return cr.exports;lr=1;var e=(sr||(sr=1,function(e){e.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}}(ur)),ur.exports),t=(ar||(ar=1,function(e){e.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}}(hr)),hr.exports);return cr.exports=e,cr.exports.murmur3=e,cr.exports.murmur2=t,cr.exports}(),pr=Me(dr);class Event{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e}}class ErrorEvent extends Event{constructor(e,t={}){super("error",Object.assign({error:e},t))}}function fr(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function mr(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class Evented{on(e,t){return this._listeners=this._listeners||{},fr(e,t,this._listeners),this}off(e,t){return mr(e,t,this._listeners),mr(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},fr(e,t,this._oneTimeListeners),this):new Promise((t=>{this.once(e,t)}))}fire(e,t){const i="string"==typeof e?new Event(e,t):e,r=i.type;if(this.listens(r)){i.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const t of e)t.call(this,i);const t=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of t)mr(r,e,this._oneTimeListeners),e.call(this,i);const n=this._eventedParent;if(n){const e="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(i,e),n.fire(i)}}else i instanceof ErrorEvent&&console.error(i.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 ImageId{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new ImageId(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,i]=e.split("");return new ImageId({name:t,iconsetId:i})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return ImageId.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}class StyleChanges{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(e,t){this._updatedImages[t]=this._updatedImages[t]||new Set,this._updatedImages[t].add(ImageId.toString(e)),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={}}}var _r,gr={},yr=function(){if(_r)return gr;_r=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 i(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function r(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function n(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{gr.parseCSSColor=function(o){var s,a=o.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(s=parseInt(a.substr(1),16))>=0&&s<=4095?[(3840&s)>>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)<<4,1]:null:7===a.length&&(s=parseInt(a.substr(1),16))>=0&&s<=16777215?[(16711680&s)>>16,(65280&s)>>8,255&s,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),d=1;switch(u){case"rgba":if(4!==h.length)return null;d=r(h.pop());case"rgb":return 3!==h.length?null:[i(h[0]),i(h[1]),i(h[2]),d];case"hsla":if(4!==h.length)return null;d=r(h.pop());case"hsl":if(3!==h.length)return null;var p=(parseFloat(h[0])%360+360)%360/360,f=r(h[1]),m=r(h[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[t(255*n(g,_,p+1/3)),t(255*n(g,_,p)),t(255*n(g,_,p-1/3)),d];default:return null}}return null}}catch(e){}return gr}();class Color{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(e){if(!e)return;if(e instanceof Color)return e;if("string"!=typeof e)return;const t=yr.parseCSSColor(e);return t?new Color(t[0]/255,t[1]/255,t[2]/255,t[3]):void 0}toString(){const[e,t,i,r]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*i)},${r})`}toNonPremultipliedRenderColor(e){const{r:t,g:i,b:r,a:n}=this;return new NonPremultipliedRenderColor(e,t,i,r,n)}toPremultipliedRenderColor(e){const{r:t,g:i,b:r,a:n}=this;return new PremultipliedRenderColor(e,t*n,i*n,r*n,n)}clone(){return new Color(this.r,this.g,this.b,this.a)}}class RenderColor{constructor(e,t,i,r,n,o=!1){if(this.premultiplied=!1,this.premultiplied=o,e){const o=e.image.height,s=o*o;this.premultiplied?(t=0===n?0:t/n*(o-1),i=0===n?0:i/n*(o-1),r=0===n?0:r/n*(o-1)):(t*=o-1,i*=o-1,r*=o-1);const a=Math.floor(t),l=Math.floor(i),c=Math.floor(r),u=Math.ceil(t),h=Math.ceil(i),d=Math.ceil(r),p=t-a,f=i-l,m=r-c,_=e.image.data,g=4*(a+l*s+c*o),y=4*(a+l*s+d*o),x=4*(a+h*s+c*o),v=4*(a+h*s+d*o),b=4*(u+l*s+c*o),w=4*(u+l*s+d*o),T=4*(u+h*s+c*o),E=4*(u+h*s+d*o);if(g<0||E>=_.length)throw new Error("out of range");this.r=xr(xr(xr(_[g],_[y],m),xr(_[x],_[v],m),f),xr(xr(_[b],_[w],m),xr(_[T],_[E],m),f),p)/255*(this.premultiplied?n:1),this.g=xr(xr(xr(_[g+1],_[y+1],m),xr(_[x+1],_[v+1],m),f),xr(xr(_[b+1],_[w+1],m),xr(_[T+1],_[E+1],m),f),p)/255*(this.premultiplied?n:1),this.b=xr(xr(xr(_[g+2],_[y+2],m),xr(_[x+2],_[v+2],m),f),xr(xr(_[b+2],_[w+2],m),xr(_[T+2],_[E+2],m),f),p)/255*(this.premultiplied?n:1),this.a=n}else this.r=t,this.g=i,this.b=r,this.a=n}toArray(){const{r:e,g:t,b:i,a:r}=this;return[255*e,255*t,255*i,r]}toHslaArray(){let{r:e,g:t,b:i,a:r}=this;if(this.premultiplied){if(0===r)return[0,0,0,0];const n=1/r;e*=n,t*=n,i*=n}const n=Math.min(Math.max(e,0),1),o=Math.min(Math.max(t,0),1),s=Math.min(Math.max(i,0),1),a=Math.min(n,o,s),l=Math.max(n,o,s),c=l-a,u=.5*(a+l);if(0===c)return[0,0,100*u,r];const h=u>.5?c/(2-l-a):c/(l+a);let d;switch(l){case n:d=60*((o-s)/c+(o<s?6:0));break;case o:d=60*((s-n)/c+2);break;default:d=60*((n-o)/c+4)}return[d,100*h,100*u,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return[e,t,i,r]}toArray01Scaled(e){const{r:t,g:i,b:r}=this;return[t*e,i*e,r*e]}toArray01Linear(){const{r:e,g:t,b:i,a:r}=this;return[Math.pow(e,2.2),Math.pow(t,2.2),Math.pow(i,2.2),r]}}class NonPremultipliedRenderColor extends RenderColor{constructor(e,t,i,r,n){super(e,t,i,r,n,!1)}}class PremultipliedRenderColor extends RenderColor{constructor(e,t,i,r,n){super(e,t,i,r,n,!0)}}function xr(e,t,i){return e*(1-i)+t*i}function vr(e,t,i){return e.map(((e,r)=>xr(e,t[r],i)))}Color.black=new Color(0,0,0,1),Color.white=new Color(1,1,1,1),Color.transparent=new Color(0,0,0,0),Color.red=new Color(1,0,0,1),Color.blue=new Color(0,0,1,1);var br=Object.freeze({__proto__:null,array:vr,color:function(e,t,i){return new Color(xr(e.r,t.r,i),xr(e.g,t.g,i),xr(e.b,t.b,i),xr(e.a,t.a,i))},number:xr});class ParsingError extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Scope{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Scope(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"},Tr={kind:"number"},Er={kind:"string"},Sr={kind:"boolean"},Ar={kind:"color"},Ir={kind:"object"},Cr={kind:"value"},Mr={kind:"collator"},Dr={kind:"formatted"},Pr={kind:"resolvedImage"};function Lr(e,t){return{kind:"array",itemType:e,N:t}}function Rr(e){if("array"===e.kind){const t=Rr(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const zr=[wr,Tr,Er,Sr,Ar,Dr,Ir,Lr(Cr),Pr];function Fr(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Fr(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 zr)if(!Fr(e,t))return null}return`Expected ${Rr(e)} but found ${Rr(t)} instead.`}function Or(e,t){return t.some((t=>t.kind===e.kind))}function Br(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 kr(e,t){return"array"===e.kind&&"array"===t.kind?e.N===t.N&&kr(e.itemType,t.itemType):e.kind===t.kind}class Collator{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,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 FormattedSection{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class Formatted{constructor(e){this.sections=e}static fromString(e){return new Formatted([new FormattedSection(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 Formatted?e:Formatted.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 i=t.image.getPrimary().id.toString();e.push(["image",i]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(i)}return e}}class ImageVariant{constructor(e,t={}){this.id=ImageId.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,i,r,n;try{({id:t,params:i,sx:r,sy:n}=JSON.parse(e)||{})}catch(e){return null}return t?new ImageVariant(t,{params:i,sx:r,sy:n}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class ResolvedImage{constructor(e,t,i,r,n=!1){this.primaryId=ImageId.from(e),this.primaryOptions=t,i&&(this.secondaryId=ImageId.from(i)),this.secondaryOptions=r,this.available=n}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new ImageVariant(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new ImageVariant(this.secondaryId,this.secondaryOptions):null}static from(e){return"string"==typeof e?ResolvedImage.build({name:e}):e}static build(e,t,i,r){return!e||"object"==typeof e&&!("name"in e)?null:new ResolvedImage(e,i,t,r)}}function Ur(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Vr(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 Color)return!0;if(e instanceof Collator)return!0;if(e instanceof Formatted)return!0;if(e instanceof ResolvedImage)return!0;if(Array.isArray(e)){for(const t of e)if(!Vr(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Vr(e[t]))return!1;return!0}return!1}function Nr(e){if(null===e)return wr;if("string"==typeof e)return Er;if("boolean"==typeof e)return Sr;if("number"==typeof e)return Tr;if(e instanceof Color)return Ar;if(e instanceof Collator)return Mr;if(e instanceof Formatted)return Dr;if(e instanceof ResolvedImage)return Pr;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Nr(t);if(i){if(i===e)continue;i=Cr;break}i=e}return Lr(i||Cr,t)}return Ir}function jr(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Formatted||e instanceof ResolvedImage||e instanceof Color?e.toString():JSON.stringify(e)}class Literal{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(!Vr(e[1]))return t.error("invalid value");const i=e[1];let r=Nr(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Literal(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Color?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Formatted?this.value.serialize():this.value}}class RuntimeError{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Gr={string:Er,number:Tr,boolean:Sr,object:Ir};class Assertion{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 i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Gr)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=Gr[i],r++}else n=Cr;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);o=e[2],r++}i=Lr(n,o)}else i=Gr[n];const o=[];for(;r<e.length;r++){const i=t.parse(e[r],r,Cr);if(!i)return null;o.push(i)}return new Assertion(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!Fr(this.type,Nr(i)))return i;if(t===this.args.length-1)throw new RuntimeError(`The expression ${JSON.stringify(this.args[t].serialize())} evaluated to ${Rr(Nr(i))} but was expected to be of type ${Rr(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 i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map((e=>e.serialize())))}}class FormatExpression{constructor(e){this.type=Dr,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parseObjectValue(o["font-scale"],i,"font-scale",Tr),!e))return null;let s=null;if(o["text-font"]&&(s=t.parseObjectValue(o["text-font"],i,"text-font",Lr(Er)),!s))return null;let a=null;if(o["text-color"]&&(a=t.parseObjectValue(o["text-color"],i,"text-color",Ar),!a))return null;const l=r[r.length-1];l.scale=e,l.font=s,l.textColor=a}else{const o=t.parse(e[i],i,Cr);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new FormatExpression(r)}evaluate(e){return new Formatted(this.sections.map((t=>{const i=t.content.evaluate(e);return kr(Nr(i),Pr)?new FormattedSection("",i,null,null,null):new FormattedSection(jr(i),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 i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class ImageExpression{constructor(e,t,i,r){this._imageWarnHistory={},this.type=Pr,this.namePrimary=e,this.nameSecondary=t,i&&(this.paramsPrimary=i.params,this.iconsetIdPrimary=i.iconset?i.iconset.id:void 0),r&&(this.paramsSecondary=r.params,this.iconsetIdSecondary=r.iconset?r.iconset.id:void 0)}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let i=1;const r=[];function n(){if(i<e.length){const n=t.parse(e[i],i++,Er);return n?(r.push({image:n,options:{}}),!0):(t.error(r.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function o(){if(i<e.length){const o=e[i];if(null===(n=o)||"object"!=typeof n||Array.isArray(n))return!0;const s=o.params,a=o.iconset,l=t.concat(i);if(!s&&!a)return i++,!0;if(s){if("object"!=typeof s||s.constructor!==Object)return l.error('Image options "params" should be an object'),!1;const e={},t=l.concat(void 0,"params");for(const i in s){if(!i)return t.error("Image parameter name should be non-empty"),!1;const r=t.concat(void 0,i).parse(s[i],void 0,Ar,void 0,{typeAnnotation:"coerce"});if(!r)return!1;e[i]=r}r[r.length-1].options.params=e}if(a){if("object"!=typeof a||a.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!a.id)return l.error('Image options "iconset" should have an "id" property'),!1;r[r.length-1].options.iconset=a}return i++,!0}var n;return!0}for(let e=0;e<2;e++)if(!n()||!o())return;return new ImageExpression(r[0].image,r[1]?r[1].image:void 0,r[0].options,r[1]?r[1].options:void 0)}evaluateParams(e,t){const i={};if(t){for(const r in t)if(t[r])try{i[r]=t[r].evaluate(e)}catch(e){continue}if(0!==Object.keys(i).length)return{params:i}}}evaluate(e){const t={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},i=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,r=ResolvedImage.build(t,i,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(r&&e.availableImages){const t=r.getPrimary().id;if(r.available=e.availableImages.some((e=>ImageId.isEqual(e,t))),r.available){const t=r.getSecondary()?r.getSecondary().id:null;t&&(r.available=e.availableImages.some((e=>ImageId.isEqual(e,t))))}}return r}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 i={};if(t&&(i.iconset={id:t}),e){i.params={};for(const t in e)e[t]&&(i.params[t]=e[t].serialize())}return Object.keys(i).length>0?i: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 Hr(e){return $r(e)?"string":Zr(e)?"number":Wr(e)?"boolean":Array.isArray(e)?"array":null===e?"null":qr(e)?"object":typeof e}function qr(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function $r(e){return"string"==typeof e||e instanceof String}function Zr(e){return"number"==typeof e||e instanceof Number}function Wr(e){return"boolean"==typeof e||e instanceof Boolean}const Xr={"to-boolean":Sr,"to-color":Ar,"to-number":Tr,"to-string":Er};class Coercion{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 i=e[0],r=[];let n=wr;if("to-array"===i){if(!Array.isArray(e[1]))return null;const i=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);n=Lr(t.expectedType.itemType,i)}else{if(!(i>0&&Vr(e[1][0])))return null;n=Lr(Nr(e[1][0]),i)}for(let o=0;o<i;o++){const i=e[1][o];let s;if(Array.isArray(i))s=t.parse(i,void 0,n.itemType);else{const e=Hr(i);if(e!==n.itemType.kind)return t.error(`Expected ${n.itemType.kind} but found ${e}.`);s=t.registry.literal.parse(["literal",void 0===i?null:i],t)}if(!s)return null;r.push(s)}}else{if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");n=Xr[i];for(let i=1;i<e.length;i++){const n=t.parse(e[i],i,Cr);if(!n)return null;r.push(n)}}return new Coercion(n,r)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const r of this.args){if(t=r.evaluate(e),i=null,t instanceof Color)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ur(t[0],t[1],t[2],t[3]),!i))return new Color(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new RuntimeError(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new RuntimeError(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Formatted.fromString(jr(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?ResolvedImage.build(jr(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((t=>t.evaluate(e))):jr(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 FormatExpression([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ImageExpression(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}const Yr=["Unknown","Point","LineString","Polygon"];class EvaluationContext{constructor(e,t,i){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=i}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Yr[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:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Color.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class CompoundExpression{constructor(e,t,i,r,n){this.name=e,this.type=t,this._evaluate=i,this.args=r,this._overloadIndex=n}evaluate(e){if(!this._evaluate){const e=CompoundExpression.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 i=e[0],r=CompoundExpression.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=[];let a=null,l=-1;for(const[r,c]of o){if(Array.isArray(r)&&r.length!==e.length-1)continue;s.push(r),l++,a=new ParsingContext(t.registry,t.path,null,t.scope,void 0,t._scope,t.options,t.iconImageUseTheme);const o=[];let u=!1;for(let t=1;t<e.length;t++){const i=e[t],n=Array.isArray(r)?r[t-1]:r.type,s=a.parse(i,1+o.length,n);if(!s){u=!0;break}o.push(s)}if(!u)if(Array.isArray(r)&&r.length!==o.length)a.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let e=0;e<o.length;e++){const t=Array.isArray(r)?r[e]:r.type,i=o[e];a.concat(e+1).checkSubtype(t,i.type)}if(0===a.errors.length)return new CompoundExpression(i,n,c,o,l)}}if(1===s.length)t.errors.push(...a.errors);else{const i=(s.length?s:o.map((([e])=>e))).map(Kr).join(" | "),r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],1+r.length);if(!n)return null;r.push(Rr(n.type))}t.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(e,t){CompoundExpression.definitions=t;for(const i in t)e[i]=CompoundExpression}}function Kr(e){return Array.isArray(e)?`(${e.map(Rr).join(", ")})`:`(${Rr(e.type)}...)`}class CollatorExpression{constructor(e,t,i){this.type=Mr,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=void 0===i["case-sensitive"]?t.parse(!1,1,Sr):t.parseObjectValue(i["case-sensitive"],1,"case-sensitive",Sr);if(!r)return null;const n=void 0===i["diacritic-sensitive"]?t.parse(!1,1,Sr):t.parseObjectValue(i["diacritic-sensitive"],1,"diacritic-sensitive",Sr);if(!n)return null;let o=null;return i.locale&&(o=t.parseObjectValue(i.locale,1,"locale",Er),!o)?null:new CollatorExpression(r,n,o)}evaluate(e){return new Collator(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 Jr(e,t,i=0,r=e.length-1,n=en){for(;r>i;){if(r-i>600){const o=r-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Jr(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(r,Math.floor(t+(o-s)*l/o+c)),n)}const o=e[t];let s=i,a=r;for(Qr(e,i,t),n(e[r],o)>0&&Qr(e,i,r);s<a;){for(Qr(e,s,a),s++,a--;n(e[s],o)<0;)s++;for(;n(e[a],o)>0;)a--}0===n(e[i],o)?Qr(e,i,a):(a++,Qr(e,a,r)),a<=t&&(i=a+1),t<=a&&(r=a-1)}}function Qr(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function en(e,t){return e<t?-1:e>t?1:0}function tn(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}function rn(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 nn(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function on(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function sn(e,t,i=!1){let r=!1;for(let a=0,l=t.length;a<l;a++){const l=t[a];for(let t=0,a=l.length,c=a-1;t<a;c=t++){const a=l[c],u=l[t];if(on(e,a,u))return i;(o=a)[1]>(n=e)[1]!=(s=u)[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}}var n,o,s;return r}function an(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function ln(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!an(e,t,i,r)||!an(i,r,e,t));var n,o}function cn(e){const t=new Le(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new Le(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const r of e[0])t.x>r.x&&(t.x=r.x),t.y>r.y&&(t.y=r.y),i.x<r.x&&(i.x=r.x),i.y<r.y&&(i.y=r.y);return{min:t,max:i}}const un=8192;function hn(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(i*n*un),Math.round(r*n*un)]}function dn(e,t){for(let i=0;i<t.length;i++)if(sn(e,t[i]))return!0;return!1}function pn(e,t,i){for(const r of i)for(let i=0,n=r.length,o=n-1;i<n;o=i++)if(ln(e,t,r[o],r[i]))return!0;return!1}function fn(e,t){for(let i=0;i<e.length;++i)if(!sn(e[i],t))return!1;for(let i=0;i<e.length-1;++i)if(pn(e[i],e[i+1],t))return!1;return!0}function mn(e,t){for(let i=0;i<t.length;i++)if(fn(e,t[i]))return!0;return!1}function _n(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=[];for(let r=0;r<e[n].length;r++){const s=hn(e[n][r],i);rn(t,s),o.push(s)}r.push(o)}return r}function gn(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=_n(e[n],t,i);r.push(o)}return r}function yn(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}rn(t,e)}function xn(e,t,i,r){const n=Math.pow(2,r.z)*un,o=[r.x*un,r.y*un],s=[];if(!e)return s;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];yn(r,t,i,n),s.push(r)}return s}function vn(e,t,i,r){const n=Math.pow(2,r.z)*un,o=[r.x*un,r.y*un],s=[];if(!e)return s;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];rn(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)yn(r,t,i,n)}var a;return s}class Within{constructor(e,t){this.type=Sr,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(Vr(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Within(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Within(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Within(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 i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=_n(t.coordinates,r,n),s=xn(e.geometry(),i,r,n);if(!nn(i,r))return!1;for(const e of s)if(!sn(e,o))return!1}if("MultiPolygon"===t.type){const o=gn(t.coordinates,r,n),s=xn(e.geometry(),i,r,n);if(!nn(i,r))return!1;for(const e of s)if(!dn(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=_n(t.coordinates,r,n),s=vn(e.geometry(),i,r,n);if(!nn(i,r))return!1;for(const e of s)if(!fn(e,o))return!1}if("MultiPolygon"===t.type){const o=gn(t.coordinates,r,n),s=vn(e.geometry(),i,r,n);if(!nn(i,r))return!1;for(const e of s)if(!mn(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}const bn={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},wn=1/298.257223563,Tn=wn*(2-wn),En=Math.PI/180;class CheapRuler{static fromTile(e,t,i){const r=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),n=Math.atan(.5*(Math.exp(r)-Math.exp(-r)))/En;return new CheapRuler(n,i)}static get units(){return bn}constructor(e,t){if(void 0===e)throw new Error("No latitude given.");if(t&&!bn[t])throw new Error(`Unknown unit ${t}. Use one of: ${Object.keys(bn).join(", ")}`);const i=6378.137*En*(t?bn[t]:1),r=Math.cos(e*En),n=1/(1-Tn*(1-r*r)),o=Math.sqrt(n);this.kx=i*o*r,this.ky=i*o*n*(1-Tn)}distance(e,t){const i=Cn(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)}bearing(e,t){const i=Cn(t[0]-e[0])*this.kx;return Math.atan2(i,(t[1]-e[1])*this.ky)/En}destination(e,t,i){const r=i*En;return this.offset(e,Math.sin(r)*t,Math.cos(r)*t)}offset(e,t,i){return[e[0]+t/this.kx,e[1]+i/this.ky]}lineDistance(e){let t=0;for(let i=0;i<e.length-1;i++)t+=this.distance(e[i],e[i+1]);return t}area(e){let t=0;for(let i=0;i<e.length;i++){const r=e[i];for(let e=0,n=r.length,o=n-1;e<n;o=e++)t+=Cn(r[e][0]-r[o][0])*(r[e][1]+r[o][1])*(i?-1:1)}return Math.abs(t)/2*this.kx*this.ky}along(e,t){let i=0;if(t<=0)return e[0];for(let r=0;r<e.length-1;r++){const n=e[r],o=e[r+1],s=this.distance(n,o);if(i+=s,i>t)return An(n,o,(t-(i-s))/s)}return e[e.length-1]}pointToSegmentDistance(e,t,i){let[r,n]=t,o=Cn(i[0]-r)*this.kx,s=(i[1]-n)*this.ky;if(0!==o||0!==s){const t=(Cn(e[0]-r)*this.kx*o+(e[1]-n)*this.ky*s)/(o*o+s*s);t>1?(r=i[0],n=i[1]):t>0&&(r+=o/this.kx*t,n+=s/this.ky*t)}return o=Cn(e[0]-r)*this.kx,s=(e[1]-n)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(e,t){let i=1/0,r=e[0][0],n=e[0][1],o=0,s=0;for(let a=0;a<e.length-1;a++){let l=e[a][0],c=e[a][1],u=Cn(e[a+1][0]-l)*this.kx,h=(e[a+1][1]-c)*this.ky,d=0;0===u&&0===h||(d=(Cn(t[0]-l)*this.kx*u+(t[1]-c)*this.ky*h)/(u*u+h*h),d>1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=Cn(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p<i&&(i=p,r=l,n=c,o=a,s=d)}return{point:[r,n],index:o,t:Math.max(0,Math.min(1,s))}}lineSlice(e,t,i){let r=this.pointOnLine(i,e),n=this.pointOnLine(i,t);if(r.index>n.index||r.index===n.index&&r.t>n.t){const e=r;r=n,n=e}const o=[r.point],s=r.index+1,a=n.index;!Sn(i[s],o[0])&&s<=a&&o.push(i[s]);for(let e=s+1;e<=a;e++)o.push(i[e]);return Sn(i[a],n.point)||o.push(n.point),o}lineSliceAlong(e,t,i){let r=0;const n=[];for(let o=0;o<i.length-1;o++){const s=i[o],a=i[o+1],l=this.distance(s,a);if(r+=l,r>e&&0===n.length&&n.push(An(s,a,(e-(r-l))/l)),r>=t)return n.push(An(s,a,(t-(r-l))/l)),n;r>e&&n.push(a)}return n}bufferPoint(e,t){const i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[0]+r,e[1]+i]}bufferBBox(e,t){const i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[2]+r,e[3]+i]}insideBBox(e,t){return Cn(e[0]-t[0])>=0&&Cn(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function Sn(e,t){return e[0]===t[0]&&e[1]===t[1]}function An(e,t,i){const r=Cn(t[0]-e[0]);return[e[0]+r*i,e[1]+(t[1]-e[1])*i]}function Cn(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class TinyQueue{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:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e<r;){let r=1+(e<<1);const o=r+1;if(o<this.length&&i(t[o],t[r])<0&&(r=o),i(t[r],n)>=0)break;t[e]=t[r],e=r}t[e]=n}}var Mn=8192;function Dn(e,t){return t.dist-e.dist}const Pn=100,Ln=50;function Rn(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function zn(e){return e[1]-e[0]+1}function Fn(e,t){const i=e[1]>=e[0]&&e[1]<t;return i||console.warn("Distance Expression: Index is out of range"),i}function On(e,t){if(e[0]>e[1])return[null,null];const i=zn(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===i)return[e,null];const t=Math.floor(i/2)-1;return[[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function Bn(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!Fn(t,e.length))return i;for(let r=t[0];r<=t[1];++r)rn(i,e[r]);return i}function kn(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;i<e.length;++i)for(let r=0;r<e[i].length;++r)rn(t,e[i][r]);return t}function Un(e,t,i){if(Rn(e)||Rn(t))return NaN;let r=0,n=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]<t[1]&&(n=t[1]-e[3]),i.distance([0,0],[r,n])}function Vn(e){return 360*e-180}function Nn(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function jn(e,t){const i=Math.pow(2,t.z),r=(e.y/Mn+t.y)/i;return[Vn((e.x/Mn+t.x)/i),Nn(r)]}function Gn(e,t){const i=[];for(let r=0;r<e.length;++r)i.push(jn(e[r],t));return i}function Hn(e,t,i){const r=i.pointOnLine(t,e).point;return i.distance(e,r)}function qn(e,t,i,r,n){const o=i.slice(r[0],r[1]+1);let s=1/0;for(let i=t[0];i<=t[1];++i)if(0===(s=Math.min(s,Hn(e[i],o,n))))return 0;return s}function $n(e,t,i,r,n){const o=Math.min(n.pointToSegmentDistance(e,i,r),n.pointToSegmentDistance(t,i,r)),s=Math.min(n.pointToSegmentDistance(i,e,t),n.pointToSegmentDistance(r,e,t));return Math.min(o,s)}function Zn(e,t,i,r,n){if(!Fn(t,e.length)||!Fn(r,i.length))return NaN;let o=1/0;for(let s=t[0];s<t[1];++s)for(let t=r[0];t<r[1];++t){if(ln(e[s],e[s+1],i[t],i[t+1]))return 0;o=Math.min(o,$n(e[s],e[s+1],i[t],i[t+1],n))}return o}function Wn(e,t,i,r,n){if(!Fn(t,e.length)||!Fn(r,i.length))return NaN;let o=1/0;for(let s=t[0];s<=t[1];++s)for(let t=r[0];t<=r[1];++t)if(0===(o=Math.min(o,n.distance(e[s],i[t]))))return o;return o}function Xn(e,t,i){if(sn(e,t,!0))return 0;let r=1/0;for(const n of t){const t=n.length;if(t<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(n[0]!==n[t-1]&&0===(r=Math.min(r,i.pointToSegmentDistance(e,n[t-1],n[0]))))return r;if(0===(r=Math.min(r,Hn(e,n,i))))return r}return r}function Yn(e,t,i,r){if(!Fn(t,e.length))return NaN;for(let r=t[0];r<=t[1];++r)if(sn(e[r],i,!0))return 0;let n=1/0;for(let o=t[0];o<t[1];++o)for(const t of i)for(let i=0,s=t.length,a=s-1;i<s;a=i++){if(ln(e[o],e[o+1],t[a],t[i]))return 0;n=Math.min(n,$n(e[o],e[o+1],t[a],t[i],r))}return n}function Kn(e,t){for(const i of e)for(let e=0;e<=i.length-1;++e)if(sn(i[e],t,!0))return!0;return!1}function Jn(e,t,i,r=1/0){const n=kn(e),o=kn(t);if(r!==1/0&&Un(n,o,i)>=r)return r;if(nn(n,o)){if(Kn(e,t))return 0}else if(Kn(t,e))return 0;let s=r;for(const r of e)for(let e=0,n=r.length,o=n-1;e<n;o=e++)for(const n of t)for(let t=0,a=n.length,l=a-1;t<a;l=t++){if(ln(r[o],r[e],n[l],n[t]))return 0;s=Math.min(s,$n(r[o],r[e],n[l],n[t],i))}return s}function Qn(e,t,i,r,n,o,s){if(null===o||null===s)return;const a=Un(Bn(r,o),Bn(n,s),i);a<t&&e.push({dist:a,range1:o,range2:s})}function eo(e,t,i,r,n=1/0){let o=Math.min(r.distance(e[0],i[0][0]),n);if(0===o)return o;const s=new TinyQueue([{dist:0,range1:[0,e.length-1],range2:[0,0]}],Dn),a=t?Ln:Pn,l=kn(i);for(;s.length;){const n=s.pop();if(n.dist>=o)continue;const c=n.range1;if(zn(c)<=a){if(!Fn(c,e.length))return NaN;if(t){const t=Yn(e,c,i,r);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const n=Xn(e[t],i,r);if(0===(o=Math.min(o,n)))return o}}else{const i=On(c,t);if(null!==i[0]){const t=Un(Bn(e,i[0]),l,r);t<o&&s.push({dist:t,range1:i[0],range2:[0,0]})}if(null!==i[1]){const t=Un(Bn(e,i[1]),l,r);t<o&&s.push({dist:t,range1:i[1],range2:[0,0]})}}}return o}function to(e,t,i,r,n,o=1/0){let s=Math.min(o,n.distance(e[0],i[0]));if(0===s)return s;const a=new TinyQueue([{dist:0,range1:[0,e.length-1],range2:[0,i.length-1]}],Dn),l=t?Ln:Pn,c=r?Ln:Pn;for(;a.length;){const o=a.pop();if(o.dist>=s)continue;const u=o.range1,h=o.range2;if(zn(u)<=l&&zn(h)<=c){if(!Fn(u,e.length)||!Fn(h,i.length))return NaN;if(t&&r?s=Math.min(s,Zn(e,u,i,h,n)):t||r?t&&!r?s=Math.min(s,qn(i,h,e,u,n)):!t&&r&&(s=Math.min(s,qn(e,u,i,h,n))):s=Math.min(s,Wn(e,u,i,h,n)),0===s)return s}else{const o=On(u,t),l=On(h,r);Qn(a,s,n,e,i,o[0],l[0]),Qn(a,s,n,e,i,o[0],l[1]),Qn(a,s,n,e,i,o[1],l[0]),Qn(a,s,n,e,i,o[1],l[1])}}return s}function io(e,t,i,r,n=1/0){let o=n;const s=Bn(e,[0,e.length-1]);for(const n of i)if(!(o!==1/0&&Un(s,Bn(n,[0,n.length-1]),r)>=o)&&(o=Math.min(o,to(e,t,n,!0,r,o)),0===o))return o;return o}function ro(e,t,i,r,n=1/0){let o=n;const s=Bn(e,[0,e.length-1]);for(const n of i){if(o!==1/0&&Un(s,kn(n),r)>=o)continue;const i=eo(e,t,n,r,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function no(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class Distance{constructor(e,t){this.type=Tr,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(Vr(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e<t.features.length;++e)if(no(t.features[e].geometry.type))return new Distance(t,t.features[e].geometry)}else if("Feature"===t.type){if(no(t.geometry.type))return new Distance(t,t.geometry)}else if(no(t.type))return new Distance(t,t)}return t.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const t=e.geometry(),i=e.canonicalID();if(null!=t&&null!=i){if("Point"===e.geometryType())return function(e,t,i){const r=[];for(const i of e)for(const e of i)r.push(jn(e,t));const n=new CheapRuler(r[0][1],"meters");return"Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type?to(r,!1,"Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,n):"MultiLineString"===i.type?io(r,!1,i.coordinates,n):"Polygon"===i.type||"MultiPolygon"===i.type?ro(r,!1,"Polygon"===i.type?[i.coordinates]:i.coordinates,n):null}(t,i,this.geometries);if("LineString"===e.geometryType())return function(e,t,i){const r=[];for(const i of e){const e=[];for(const r of i)e.push(jn(r,t));r.push(e)}const n=new CheapRuler(r[0][0][1],"meters");if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return io("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,r,n);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const o=io(i.coordinates[t],!0,r,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}if("Polygon"===i.type||"MultiPolygon"===i.type){let e=1/0;for(let t=0;t<r.length;t++){const o=ro(r[t],!0,"Polygon"===i.type?[i.coordinates]:i.coordinates,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}return null}(t,i,this.geometries);if("Polygon"===e.geometryType())return function(e,t,i){const r=[];for(const i of function(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t<i;t++){const i=tn(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[e[t]]):n.push(e[t]))}return n&&r.push(n),r}(e)){const e=[];for(let r=0;r<i.length;++r)e.push(Gn(i[r],t));r.push(e)}const n=new CheapRuler(r[0][0][0][1],"meters");if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return ro("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,r,n);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const o=ro(i.coordinates[t],!0,r,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}return"Polygon"===i.type||"MultiPolygon"===i.type?function(e,t,i){let r=1/0;for(const n of e)for(const e of t){const t=Jn(n,e,i,r);if(isNaN(t))return t;if(0===(r=Math.min(r,t)))return r}return r}("Polygon"===i.type?[i.coordinates]:i.coordinates,r,n):null}(t,i,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requirs valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function oo(e){if(e instanceof CompoundExpression){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 Within)return!1;if(e instanceof Distance)return!1;if(e instanceof Config)return e.featureConstant;let t=!0;return e.eachChild((e=>{t&&!oo(e)&&(t=!1)})),t}function so(e){if(e instanceof CompoundExpression&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!so(e)&&(t=!1)})),t}function ao(e,t){if(e instanceof CompoundExpression&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild((e=>{i&&!ao(e,t)&&(i=!1)})),i}function lo(e,t,i){return[e,t,i].filter(Boolean).join("")}function co(e,t){switch(e){case"string":return jr(t);case"number":return+t;case"boolean":return!!t;case"color":return Color.parse(t);case"formatted":return Formatted.fromString(jr(t));case"resolvedImage":return ResolvedImage.build(jr(t))}return t}function uo(e,t,i,r){return void 0!==r&&(e=r*Math.round(e/r)),void 0!==t&&e<t&&(e=t),void 0!==i&&e>i&&(e=i),e}class Config{constructor(e,t,i,r=!1){this.type=e,this.key=t,this.scope=i,this.featureConstant=r}static parse(e,t){let i=t.expectedType;if(null==i&&(i=Cr),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const r=t.parse(e[1],1);if(!(r instanceof Literal))return t.error("Key name of 'config' expression must be a string literal.");let n,o=!0;const s=jr(r.value);if(e.length>=3){const i=t.parse(e[2],2);if(!(i instanceof Literal))return t.error("Scope of 'config' expression must be a string literal.");n=jr(i.value)}if(t.options){const e=lo(s,n,t._scope),i=t.options.get(e);i&&(o=oo(i.value||i.default))}return new Config(i,s,n,o)}evaluate(e){const t=lo(this.key,this.scope,e.scope),i=e.getConfig(t);if(!i)return null;const{type:r,value:n,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(e);let u=c;if(n){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),u=n.evaluate(e),e.scope=t}return r&&(u=co(r,u)),void 0===u||void 0===s&&void 0===a&&void 0===l||("number"==typeof u?u=uo(u,s,a,l):Array.isArray(u)&&(u=u.map((e=>"number"==typeof e?uo(e,s,a,l):e)))),void 0!==n&&void 0!==u&&o&&!o.includes(u)&&(u=c,r&&(u=co(r,u))),(r&&r!==this.type||void 0!==u&&!kr(Nr(u),this.type))&&(u=co(this.type.kind,u)),u}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Var{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 i=e[1];return t.scope.has(i)?new Var(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" 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 ParsingContext{constructor(e,t=[],i,r=new Scope,n=[],o,s,a){this.registry=e,this.path=t,this.key=t.map((e=>"string"==typeof e?`['${e}']`:`[${e}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i,this._scope=o,this.options=s,this.iconImageUseTheme=a}parse(e,t,i,r,n={}){return t||i?this.concat(t,null,i,r)._parse(e,n):this._parse(e,n)}parseObjectValue(e,t,i,r,n,o={}){return this.concat(t,i,r,n)._parse(e,o)}_parse(e,t){function i(e,t,i){return"assert"===i?new Assertion(t,[e]):"coerce"===i?new Coercion(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 r="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof Literal)&&"resolvedImage"!==n.type.kind&&ho(n)){const e=new EvaluationContext(this._scope,this.options,this.iconImageUseTheme);try{n=new Literal(n.type,n.evaluate(e))}catch(e){return this.error(e.message),null}}return n}return Coercion.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,i,r){let n="number"==typeof e?this.path.concat(e):this.path;n="string"==typeof t?n.concat(t):n;const o=r?this.scope.concat(r):this.scope;return new ParsingContext(this.registry,n,i||null,o,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new ParsingError(i,e))}checkSubtype(e,t){const i=Fr(e,t);return i&&this.error(i),i}}function ho(e){if(e instanceof Var)return ho(e.boundExpression);if(e instanceof CompoundExpression&&"error"===e.name)return!1;if(e instanceof CollatorExpression)return!1;if(e instanceof Within)return!1;if(e instanceof Distance)return!1;if(e instanceof Config)return!1;const t=e instanceof Coercion||e instanceof Assertion;let i=!0;return e.eachChild((e=>{i=t?i&&ho(e):i&&e instanceof Literal})),!!i&&oo(e)&&ao(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"])}function po(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||t<n)return a;o=a+1}else{if(!(r>t))throw new RuntimeError("Input is not a number.");s=a-1}return 0}class Step{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)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 i=t.parse(e[1],1,Tr);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],s=e[i+1],a=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Step(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[po(t,r)].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 fo=.95047,mo=1.08883,_o=4/29,go=6/29,yo=3*go*go,xo=go*go*go,vo=Math.PI/180,bo=180/Math.PI;function wo(e){return e>xo?Math.pow(e,1/3):e/yo+_o}function To(e){return e>go?e*e*e:yo*(e-_o)}function Eo(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function So(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ao(e){const t=So(e.r),i=So(e.g),r=So(e.b),n=wo((.4124564*t+.3575761*i+.1804375*r)/fo),o=wo((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-wo((.0193339*t+.119192*i+.9503041*r)/mo)),alpha:e.a}}function Io(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*To(t),i=fo*To(i),r=mo*To(r),new Color(Eo(3.2404542*i-1.5371385*t-.4985314*r),Eo(-.969266*i+1.8760108*t+.041556*r),Eo(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function Co(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Mo={forward:Ao,reverse:Io,interpolate:function(e,t,i){return{l:xr(e.l,t.l,i),a:xr(e.a,t.a,i),b:xr(e.b,t.b,i),alpha:xr(e.alpha,t.alpha,i)}}},Do={forward:function(e){const{l:t,a:i,b:r}=Ao(e),n=Math.atan2(r,i)*bo;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*vo,i=e.c;return Io({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:Co(e.h,t.h,i),c:xr(e.c,t.c,i),l:xr(e.l,t.l,i),alpha:xr(e.alpha,t.alpha,i)}}};var Po=Object.freeze({__proto__:null,hcl:Do,lab:Mo});class Interpolate{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=Lo(t,e.base,i,r);else if("linear"===e.name)n=Lo(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new Pe(o[0],o[1],o[2],o[3]).solve(Lo(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.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);r={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(n=t.parse(n,2,Tr),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Ar:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e<o.length;e+=2){const i=o[e],r=o[e+1],n=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Interpolate(a,i,r,n,s):t.error(`Type ${Rr(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=po(t,r),s=Interpolate.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?br[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Do.reverse(Do.interpolate(Do.forward(a),Do.forward(l),s)):Mo.reverse(Mo.interpolate(Mo.forward(a),Mo.forward(l),s))}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 Lo(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}class Coalesce{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.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}const o=r&&n.some((e=>Fr(r,e.type)));return new Coalesce(o?Cr:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof ResolvedImage&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}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 Let{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 i=[];for(let r=1;r<e.length-1;r+=2){const n=e[r];if("string"!=typeof n)return t.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return t.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=t.parse(e[r+1],r+1);if(!o)return null;i.push([n,o])}const r=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return r?new Let(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}class At{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Tr),r=t.parse(e[2],2,Lr(t.expectedType||Cr));return i&&r?new At(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new RuntimeError("Array index out of bounds: negative index");if(t>=i.length)throw new RuntimeError("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new RuntimeError("Array index must be an integer. Use at-interpolated for fractional indices");return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class AtInterpolated{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Tr),r=t.parse(e[2],2,Lr(t.expectedType||Cr));return i&&r?new AtInterpolated(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new RuntimeError(`Array index out of bounds: ${t} < 0.`);if(t>i.length-1)throw new RuntimeError(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t===Math.floor(t))return i[t];const r=Math.floor(t),n=Math.ceil(t),o=i[r],s=i[n];if("number"!=typeof o||"number"!=typeof s)throw new RuntimeError(`Cannot interpolate between non-number values at index ${t}.`);const a=t-r;return o*(1-a)+s*a}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class In{constructor(e,t){this.type=Sr,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.`);const i=t.parse(e[1],1,Cr),r=t.parse(e[2],2,Cr);return i&&r?Or(i.type,[Sr,Er,Tr,wr,Cr])?new In(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Rr(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!Br(t,["boolean","string","number","null"]))throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${Rr(Nr(t))} instead.`);if(!Br(i,["string","array"]))throw new RuntimeError(`Expected second argument to be of type array or string, but found ${Rr(Nr(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class IndexOf{constructor(e,t,i){this.type=Tr,this.needle=e,this.haystack=t,this.fromIndex=i}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.`);const i=t.parse(e[1],1,Cr),r=t.parse(e[2],2,Cr);if(!i||!r)return null;if(!Or(i.type,[Sr,Er,Tr,wr,Cr]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Rr(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Tr);return n?new IndexOf(i,r,n):null}return new IndexOf(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Br(t,["boolean","string","number","null"]))throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${Rr(Nr(t))} instead.`);if(!Br(i,["string","array"]))throw new RuntimeError(`Expected second argument to be of type array or string, but found ${Rr(Nr(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.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 Match{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}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 i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;s<e.length-1;s+=2){let a=e[s];const l=e[s+1];Array.isArray(a)||(a=[a]);const c=t.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Nr(e)))return null}else i=Nr(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const u=t.parse(l,s,r);if(!u)return null;r=r||u.type,o.push(u)}const s=t.parse(e[1],1,Cr);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new Match(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(kr(Nr(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(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class Case{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;n<e.length-1;n+=2){const o=t.parse(e[n],n,Sr);if(!o)return null;const s=t.parse(e[n+1],n+1,i);if(!s)return null;r.push([o,s]),i=i||s.type}const n=t.parse(e[e.length-1],e.length-1,i);return n?new Case(i,r,n):null}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);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 Slice{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=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.`);const i=t.parse(e[1],1,Cr),r=t.parse(e[2],2,Tr);if(!i||!r)return null;if(!Or(i.type,[Lr(Cr),Er,Cr]))return t.error(`Expected first argument to be of type array or string, but found ${Rr(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Tr);return n?new Slice(i.type,i,r,n):null}return new Slice(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Br(t,["string","array"]))throw new RuntimeError(`Expected first argument to be of type array or string, but found ${Rr(Nr(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}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 Split{constructor(e,t){this.type=Lr(Er),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 i=t.parse(e[1],1,Er),r=t.parse(e[2],2,Er);return i&&r?new Split(i,r):void 0}evaluate(e){const t=this.str.evaluate(e),i=this.delimiter.evaluate(e);return t.split(i)}eachChild(e){e(this.str),e(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function Ro(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 zo(e,t,i,r){return 0===r.compare(t,i)}function Fo(e,t,i){const r="=="!==e&&"!="!==e;return class Comparison{constructor(e,t,i){this.type=Sr,this.lhs=e,this.rhs=t,this.collator=i,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 i=e[0];let n=t.parse(e[1],1,Cr);if(!n)return null;if(!Ro(i,n.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Rr(n.type)}'.`);let o=t.parse(e[2],2,Cr);if(!o)return null;if(!Ro(i,o.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Rr(o.type)}'.`);if(n.type.kind!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${Rr(n.type)}' and '${Rr(o.type)}'.`);r&&("value"===n.type.kind&&"value"!==o.type.kind?n=new Assertion(o.type,[n]):"value"!==n.type.kind&&"value"===o.type.kind&&(o=new Assertion(n.type,[o])));let s=null;if(4===e.length){if("string"!==n.type.kind&&"string"!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,Mr),!s)return null}return new Comparison(n,o,s)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=Nr(o),i=Nr(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new RuntimeError(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Nr(o),i=Nr(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}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 Oo=Fo("==",(function(e,t,i){return t===i}),zo),Bo=Fo("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return!zo(0,t,i,r)})),ko=Fo("<",(function(e,t,i){return t<i}),(function(e,t,i,r){return r.compare(t,i)<0})),Uo=Fo(">",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),Vo=Fo("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),No=Fo(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class NumberFormat{constructor(e,t,i,r,n,o){this.type=Er,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Tr);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parseObjectValue(r.locale,2,"locale",Er),!n))return null;let o=null;if(r.currency&&(o=t.parseObjectValue(r.currency,2,"currency",Er),!o))return null;let s=null;if(r.unit&&(s=t.parseObjectValue(r.unit,2,"unit",Er),!s))return null;let a=null;if(r["min-fraction-digits"]&&(a=t.parseObjectValue(r["min-fraction-digits"],2,"min-fraction-digits",Tr),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parseObjectValue(r["max-fraction-digits"],2,"max-fraction-digits",Tr),!l)?null:new NumberFormat(i,n,o,s,a,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 Length{constructor(e){this.type=Tr,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Rr(i.type)} instead.`):new Length(i):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 RuntimeError(`Expected value to be of type string or array, but found ${Rr(Nr(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}function jo(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 Go={"==":Oo,"!=":Bo,">":Uo,"<":ko,">=":No,"<=":Vo,array:Assertion,at:At,"at-interpolated":AtInterpolated,boolean:Assertion,case:Case,coalesce:Coalesce,collator:CollatorExpression,format:FormatExpression,image:ImageExpression,in:In,"index-of":IndexOf,interpolate:Interpolate,"interpolate-hcl":Interpolate,"interpolate-lab":Interpolate,length:Length,let:Let,literal:Literal,match:Match,number:Assertion,"number-format":NumberFormat,object:Assertion,slice:Slice,step:Step,string:Assertion,"to-boolean":Coercion,"to-color":Coercion,"to-number":Coercion,"to-string":Coercion,var:Var,within:Within,distance:Distance,config:Config,split:Split};function Ho(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=Ur(t,i,r,o);if(s)throw new RuntimeError(s);return new Color(t/255,i/255,r/255,o)}function qo(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=function(e,t,i,r){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid hsla value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`}(t,i,r,o);if(s)throw new RuntimeError(s);const a=`hsla(${t}, ${i}%, ${r}%, ${o})`,l=Color.parse(a);if(!l)throw new RuntimeError(`Failed to parse HSLA color: ${a}`);return l}function $o(e,t){return e in t}function Zo(e,t){const i=t[e];return void 0===i?null:i}function Wo(e){return{type:e}}function Xo(e){if(e instanceof Config)return new Set([e.key]);let t=new Set;return e.eachChild((e=>{t=new Set([...t,...Xo(e)])})),t}function Yo(e){if(e instanceof CompoundExpression&&"is-active-floor"===e.name)return!0;let t=!1;return e.eachChild((e=>{!t&&Yo(e)&&(t=!0)})),t}function Ko(e){return{result:"success",value:e}}function Jo(e){return{result:"error",value:e}}function Qo(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function es(e){return"data-driven"===e["property-type"]}function ts(e){return Qo(e.expression,"measure-light")}function is(e){return Qo(e.expression,"zoom")}function rs(e){return!!e.expression&&e.expression.interpolated}function ns(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function os(e){return e}function ss(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||(rs(t)?"exponential":"interval");if(i&&((e=Object.assign({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],Color.parse(e[1])]))),e.default=Color.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Po[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=us;else if("interval"===o)s=cs;else if("categorical"===o){s=ls,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=hs}if(r){const i={},r=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const e of r)n.push([i[e].zoom,ss(i[e],t)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:Interpolate.interpolationFactor.bind(void 0,o),zoomStops:n.map((e=>e[0])),evaluate:({zoom:i},r)=>us({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Interpolate.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?as(e.default,t.default):s(e,t,n,a,l)}}}function as(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function ls(e,t,i,r,n){return as(typeof i===n?r[i]:void 0,e.default,t.default)}function cs(e,t,i){if(!Zr(i))return as(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=po(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function us(e,t,i){const r=void 0!==e.base?e.base:1;if(!Zr(i))return as(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=po(e.stops.map((e=>e[0])),i),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=br[t.type]||os;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Po[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function hs(e,t,i){return"color"===t.type?i=Color.parse(i):"formatted"===t.type?i=Formatted.fromString(i.toString()):"resolvedImage"===t.type?i=ResolvedImage.build(i.toString()):Hr(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),as(i,e.default,t.default)}CompoundExpression.register(Go,{error:[{kind:"error"},[Er],(e,[t])=>{throw new RuntimeError(t.evaluate(e))}],typeof:[Er,[Cr],(e,[t])=>Rr(Nr(t.evaluate(e)))],"to-rgba":[Lr(Tr,4),[Ar],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Lr(Tr,4),[Ar],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Ar,[Tr,Tr,Tr],Ho],rgba:[Ar,[Tr,Tr,Tr,Tr],Ho],hsl:[Ar,[Tr,Tr,Tr],qo],hsla:[Ar,[Tr,Tr,Tr,Tr],qo],has:{type:Sr,overloads:[[[Er],(e,[t])=>$o(t.evaluate(e),e.properties())],[[Er,Ir],(e,[t,i])=>$o(t.evaluate(e),i.evaluate(e))]]},get:{type:Cr,overloads:[[[Er],(e,[t])=>Zo(t.evaluate(e),e.properties())],[[Er,Ir],(e,[t,i])=>Zo(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Cr,[Er],(e,[t])=>Zo(t.evaluate(e),e.featureState||{})],properties:[Ir,[],e=>e.properties()],"geometry-type":[Er,[],e=>e.geometryType()],worldview:[Er,[],e=>e.globals.worldview||""],"is-active-floor":[Sr,Wo(Er),(e,t)=>{if(!(e.globals.activeFloors&&e.globals.activeFloors.size>0))return!1;const i=e.globals.activeFloors;return t.some((t=>{const r=t.evaluate(e);return i.has(r)}))}],id:[Cr,[],e=>e.id()],zoom:[Tr,[],e=>e.globals.zoom],pitch:[Tr,[],e=>e.globals.pitch||0],"distance-from-center":[Tr,[],e=>e.distanceFromCenter()],"measure-light":[Tr,[Er],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Tr,[],e=>e.globals.heatmapDensity||0],"line-progress":[Tr,[],e=>e.globals.lineProgress||0],"raster-value":[Tr,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Tr,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Tr,[],e=>e.globals.skyRadialProgress||0],accumulated:[Cr,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Tr,Wo(Tr),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Tr,Wo(Tr),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Tr,overloads:[[[Tr,Tr],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Tr],(e,[t])=>-t.evaluate(e)]]},"/":[Tr,[Tr,Tr],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Tr,[Tr,Tr],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Tr,[],()=>Math.LN2],pi:[Tr,[],()=>Math.PI],e:[Tr,[],()=>Math.E],"^":[Tr,[Tr,Tr],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Tr,[Tr],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Tr,[Tr],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Tr,[Tr],(e,[t])=>Math.log(t.evaluate(e))],log2:[Tr,[Tr],(e,[t])=>Math.log2(t.evaluate(e))],sin:[Tr,[Tr],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Tr,[Tr],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Tr,[Tr],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Tr,[Tr],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Tr,[Tr],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Tr,[Tr],(e,[t])=>Math.atan(t.evaluate(e))],min:[Tr,Wo(Tr),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Tr,Wo(Tr),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Tr,[Tr],(e,[t])=>Math.abs(t.evaluate(e))],round:[Tr,[Tr],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Tr,[Tr],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Tr,[Tr],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Sr,[Er,Cr],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Sr,[Cr],(e,[t])=>e.id()===t.value],"filter-type-==":[Sr,[Er],(e,[t])=>e.geometryType()===t.value],"filter-<":[Sr,[Er,Cr],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Sr,[Cr],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[Sr,[Er,Cr],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Sr,[Cr],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[Sr,[Er,Cr],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Sr,[Cr],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[Sr,[Er,Cr],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Sr,[Cr],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[Sr,[Cr],(e,[t])=>t.value in e.properties()],"filter-has-id":[Sr,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Sr,[Lr(Er)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Sr,[Lr(Cr)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Sr,[Er,Lr(Cr)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Sr,[Er,Lr(Cr)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Sr,overloads:[[[Sr,Sr],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Wo(Sr),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Sr,overloads:[[[Sr,Sr],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Wo(Sr),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Sr,[Sr],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Sr,[Er],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Er,[Er],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Er,[Er],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Er,Wo(Cr),(e,t)=>t.map((t=>jr(t.evaluate(e)))).join("")],"resolved-locale":[Er,[Mr],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Tr,[Tr,Tr,Cr],(e,t)=>{const[i,r,n]=t.map((t=>t.evaluate(e)));if(i>r)return i;if(i===r)return i;let o;if("string"==typeof n)o=function(e){let t=0;if(0===e.length)return t;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return t}(n);else{if("number"!=typeof n)throw new RuntimeError(`Invalid seed input: ${n}`);o=n}return i+jo(o)()*(r-i)}]});class StyleExpression{constructor(e,t,i,r,n){this.expression=e,this._warningHistory={},this._scope=i,this._options=r,this._iconImageUseTheme=n,this._evaluator=new EvaluationContext(i,r,n),this._defaultValue=t?function(e){return"color"===e.type&&(ns(e.default)||Array.isArray(e.default))?new Color(0,0,0,0):"color"===e.type?Color.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this.configDependencies=Xo(e),this.isIndoorDependent=Yo(e)}evaluateWithoutErrorHandling(e,t,i,r,n,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o,s,a,l){this._evaluator||(this._evaluator=new EvaluationContext(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||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 RuntimeError(`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 ds(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Go}function ps(e,t,i,r,n){const o=new ParsingContext(Go,[],t?function(e){const t={color:Ar,string:Er,number:Tr,enum:Er,boolean:Sr,formatted:Dr,resolvedImage:Pr};return"array"===e.type?Lr(t[e.value]||Cr,e.length):t[e.type]}(t):void 0,void 0,void 0,i,r,n),s=o.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return s?Ko(new StyleExpression(s,t,i,r,n)):Jo(o.errors)}class ZoomConstantExpression{constructor(e,t,i,r){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isLineProgressConstant=r,this.isStateDependent="constant"!==e&&!so(t.expression),this.configDependencies=Xo(t.expression),this.isIndoorDependent=Yo(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o,s){return this._styleExpression.evaluate(e,t,i,r,n,o,void 0,void 0,s)}}class ZoomDependentExpression{constructor(e,t,i,r,n,o){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!so(t.expression),this.isIndoorDependent=Yo(t.expression),this.isLightConstant=n,this.isLineProgressConstant=o,this.configDependencies=Xo(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?Interpolate.interpolationFactor(this.interpolationType,e,t,i):0}}function fs(e,t,i,r,n){if("error"===(e=ps(e,t,i,r,n)).result)return e;const o=e.value.expression,s=oo(o);if(!s&&!es(t))return Jo([new ParsingError("","data expressions not supported")]);const a=ao(o,["zoom","pitch","distance-from-center"]);if(!a&&!is(t))return Jo([new ParsingError("","zoom expressions not supported")]);const l=ao(o,["measure-light"]);if(!l&&!ts(t))return Jo([new ParsingError("","measure-light expression not supported")]);const c=ao(o,["line-progress"]);if(!c&&!function(e){return Qo(e.expression,"line-progress")}(t))return Jo([new ParsingError("","line-progress expression not supported")]);const u=t.expression&&t.expression.relaxZoomRestriction,h=ms(o);return h||a||u?h instanceof ParsingError?Jo([h]):h instanceof Interpolate&&!rs(t)?Jo([new ParsingError("",'"interpolate" expressions cannot be used with this property')]):Ko(h?new ZoomDependentExpression(s&&c?"camera":"composite",e.value,h.labels,h instanceof Interpolate?h.interpolation:void 0,l,c):new ZoomConstantExpression(s&&c?"constant":"source",e.value,l,c)):Jo([new ParsingError("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class StylePropertyFunction{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,ss(this._parameters,this._specification))}static deserialize(e){return new StylePropertyFunction(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ms(e){let t=null;if(e instanceof Let)t=ms(e.result);else if(e instanceof Coalesce){for(const i of e.args)if(t=ms(i),t)break}else(e instanceof Step||e instanceof Interpolate)&&e.input instanceof CompoundExpression&&"zoom"===e.input.name&&(t=e);return t instanceof ParsingError||e.eachChild((e=>{const i=ms(e);i instanceof ParsingError?t=i:t&&i&&t!==i&&(t=new ParsingError("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}var _s,gs,ys=function(){if(gs)return _s;gs=1,_s=t;var e=3;function t(t,i,r){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var o=new Int32Array(this.arrayBuffer);t=o[0],this.d=(i=o[1])+2*(r=o[2]);for(var s=0;s<this.d*this.d;s++){var a=o[e+s],l=o[e+s+1];n.push(a===l?null:o.subarray(a,l))}var c=o[e+n.length+1];this.keys=o.subarray(o[e+n.length],c),this.bboxes=o.subarray(c),this.insert=this._insertReadonly}else{this.d=i+2*r;for(var u=0;u<this.d*this.d;u++)n.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=r,this.scale=i/t,this.uid=0;var h=r/i*t;this.min=-h,this.max=t+h}return t.prototype.insert=function(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},t.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},t.prototype._insertCell=function(e,t,i,r,n,o){this.cells[n].push(o)},t.prototype.query=function(e,t,i,r,n){var o=this.min,s=this.max;if(e<=o&&t<=o&&s<=i&&s<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(e,t,i,r,this._queryCell,a,{},n),a},t.prototype._queryCell=function(e,t,i,r,n,o,s,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var d=l[h];if(void 0===s[d]){var p=4*d;(a?a(u[p+0],u[p+1],u[p+2],u[p+3]):e<=u[p+2]&&t<=u[p+3]&&i>=u[p+0]&&r>=u[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},t.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),d=l;d<=u;d++)for(var p=c;p<=h;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,e,t,i,r,f,o,s,a))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,i=e+this.cells.length+1+1,r=0,n=0;n<this.cells.length;n++)r+=this.cells[n].length;var o=new Int32Array(i+r+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;for(var s=i,a=0;a<t.length;a++){var l=t[a];o[e+a]=s,o.set(l,s),s+=l.length}return o[e+t.length]=s,o.set(this.keys,s),o[e+t.length+1]=s+=this.keys.length,o.set(this.bboxes,s),s+=this.bboxes.length,o.buffer},_s}(),xs=Me(ys);const vs={};function bs(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),vs[t]={klass:e,omit:i.omit||[]}}bs(Object,"Object"),xs.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.add(i),{buffer:i}},xs.deserialize=function(e){return new xs(e.buffer)},Object.defineProperty(xs,"name",{value:"Grid"}),bs(xs,"Grid"),delete Le.prototype.constructor,bs(Color,"Color"),bs(Error,"Error"),bs(Formatted,"Formatted"),bs(FormattedSection,"FormattedSection"),bs(AJAXError,"AJAXError"),bs(ResolvedImage,"ResolvedImage"),bs(StylePropertyFunction,"StylePropertyFunction"),bs(StyleExpression,"StyleExpression",{omit:["_evaluator"]}),bs(ImageId,"ImageId"),bs(ImageVariant,"ImageVariant"),bs(ZoomDependentExpression,"ZoomDependentExpression"),bs(ZoomConstantExpression,"ZoomConstantExpression"),bs(CompoundExpression,"CompoundExpression",{omit:["_evaluate"]});for(const e in Go)vs[Go[e]._classRegistryKey]||bs(Go[e],`Expression${e}`);function ws(e){return e&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function Ts(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(ws(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 i=[];for(const r of e)i.push(Ts(r,t));return i}if(e instanceof Map){const i={$name:"Map",entries:[]};for(const[r,n]of e.entries())i.entries.push(Ts(r),Ts(n,t));return i}if(e instanceof Set){const t={$name:"Set"};let i=0;for(const r of e.values())t[++i]=Ts(r);return t}if("bigint"==typeof e)return{$name:"BigInt",value:e.toString()};if("object"==typeof e){const i=e.constructor,r=i._classRegistryKey;if(!r)throw new Error(`Can't serialize object of unregistered class "${i.name}".`);const n=i.serialize?i.serialize(e,t):{};if(!i.serialize){for(const i in e)e.hasOwnProperty(i)&&(vs[r].omit.indexOf(i)>=0||(n[i]=Ts(e[i],t)));e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof e)}function Es(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||ws(e)||e instanceof ImageBitmap||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(Es);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=e.entries||[],i=new Map;for(let e=0;e<t.length;e+=2)i.set(Es(t[e]),Es(t[e+1]));return i}if("Set"===t){const t=new Set;for(const i of Object.keys(e))"$name"!==i&&t.add(Es(e[i]));return t}if("BigInt"===t)return BigInt(e.value);const{klass:i}=vs[t];if(!i)throw new Error(`Can't deserialize unregistered class "${t}".`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=Es(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const Ss={"Latin-1 Supplement":e=>e>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519,Osage:e=>e>=66736&&e<=66815,"CJK Unified Ideographs Extension B":e=>e>=131072&&e<=173791};function As(e){for(const t of e)if(Is(t.charCodeAt(0)))return!0;return!1}function Is(e){return!(746!==e&&747!==e&&(e<4352||!(Ss["Bopomofo Extended"](e)||Ss.Bopomofo(e)||Ss["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||Ss["CJK Compatibility Ideographs"](e)||Ss["CJK Compatibility"](e)||Ss["CJK Radicals Supplement"](e)||Ss["CJK Strokes"](e)||!(!Ss["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Ss["CJK Unified Ideographs Extension A"](e)||Ss["CJK Unified Ideographs"](e)||Ss["Enclosed CJK Letters and Months"](e)||Ss["Hangul Compatibility Jamo"](e)||Ss["Hangul Jamo Extended-A"](e)||Ss["Hangul Jamo Extended-B"](e)||Ss["Hangul Jamo"](e)||Ss["Hangul Syllables"](e)||Ss.Hiragana(e)||Ss["Ideographic Description Characters"](e)||Ss.Kanbun(e)||Ss["Kangxi Radicals"](e)||Ss["Katakana Phonetic Extensions"](e)||Ss.Katakana(e)&&12540!==e||!(!Ss["Halfwidth and Fullwidth Forms"](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)||!(!Ss["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||Ss["Unified Canadian Aboriginal Syllabics"](e)||Ss["Unified Canadian Aboriginal Syllabics Extended"](e)||Ss["Vertical Forms"](e)||Ss["Yijing Hexagram Symbols"](e)||Ss["Yi Syllables"](e)||Ss["Yi Radicals"](e))))}function Cs(e){return e>=1424&&e<=2303||Ss["Arabic Presentation Forms-A"](e)||Ss["Arabic Presentation Forms-B"](e)}function Ms(e,t){return!(!t&&Cs(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Ss.Khmer(e))}function Ds(e){for(const t of e)if(Cs(t.charCodeAt(0)))return!0;return!1}const Ps="deferred",Ls="loading",Rs="loaded";let zs=null,Fs="unavailable",Os=null;const Bs=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Fs="error"),zs&&zs(e)};function ks(){Us.fire(new Event("pluginStateChange",{pluginStatus:Fs,pluginURL:Os}))}const Us=new Evented,Vs=function(){return Fs},Ns=function(){if(Fs!==Ps||!Os)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fs=Ls,ks(),Os&&Pi({url:Os},(e=>{e?Bs(e):(Fs=Rs,ks())}))},js={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fs===Rs||null!=js.applyArabicShaping,isLoading:()=>Fs===Ls,setState(e){Fs=e.pluginStatus,Os=e.pluginURL},isParsing:()=>"parsing"===Fs,isParsed:()=>"parsed"===Fs,getPluginURL:()=>Os};class EvaluationParameters{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 i of e)if(!Ms(i.charCodeAt(0),t))return!1;return!0}(e,js.isLoaded())}}class PropertyValue{constructor(e,t,i,r,n){this.property=e,this.value=t,this.expression=function(e,t,i,r,n){if(ns(e))return new StylePropertyFunction(e,t);if(ds(e)||Array.isArray(e)&&e.length>0){const o=fs(e,t,i,r,n);if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return o.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=Color.parse(e)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i,r,n)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i,r){return this.property.possiblyEvaluate(this,e,t,i,r)}}class TransitionablePropertyValue{constructor(e,t,i,r){this.property=e,this.value=new PropertyValue(e,void 0,t,i,r)}transitioned(e,t){return new TransitioningPropertyValue(this.property,this.value,t,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new TransitioningPropertyValue(this.property,this.value,null,{},0)}}class Transitionable{constructor(e,t,i,r){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=i,this._iconImageUseTheme=r,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return rt(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new TransitionablePropertyValue(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new PropertyValue(this._values[e].property,null===t?void 0:rt(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 i=this._properties.properties;if(e)for(const t in e){const r=e[t];if(t.endsWith("-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,r)}else i.hasOwnProperty(t)&&this.setValue(t,r)}}getTransition(e){return rt(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new TransitionablePropertyValue(this._values[e].property)),this._values[e].transition=rt(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Transitioning(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Transitioning(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class TransitioningPropertyValue{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(e,t,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),n,Ue(s))}}return n}}class Transitioning{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const r=new PossiblyEvaluated(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Layout{constructor(e,t,i,r){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=t,this._options=i,this._iconImageUseTheme=r,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return rt(this._values[e].value)}setValue(e,t){this._values[e]=new PropertyValue(this._values[e].property,null===t?void 0:rt(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 i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i,r){const n=new PossiblyEvaluated(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].possiblyEvaluate(e,t,i,r);return n}isIndoorDependent(){return this._isIndoorDependent}}class PossiblyEvaluatedPropertyValue{constructor(e,t,i,r){this.property=e,this.value=t,this.parameters=i,this.iconImageUseTheme=r}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r,this.iconImageUseTheme)}}class PossiblyEvaluated{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class DataConstantProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const r=br[this.specification.type];return r?r(e,t,i):e}}class DataDrivenProperty{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,r,n){return"constant"===e.expression.kind||"camera"===e.expression.kind?new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,r,void 0,n)},t):new PossiblyEvaluatedPropertyValue(this,e.expression,t,n)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:void 0},e.parameters);const r=br[this.specification.type];return r?new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:r(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,r,n,o,s){return"constant"===e.kind?e.value:e.evaluate(t,i,r,n,o,void 0,s)}}class ColorRampProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class DirectionProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const i=ct([1,e,t]);return{x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:xr(e.x,t.x,i),y:xr(e.y,t.y,i),z:xr(e.z,t.z,i)}}}class PositionProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t){return ct(e.expression.evaluate(t))}interpolate(e,t,i){return{x:xr(e.x,t.x,i),y:xr(e.y,t.y,i),z:xr(e.z,t.z,i),azimuthal:xr(e.azimuthal,t.azimuthal,i),polar:xr(e.polar,t.polar,i)}}}class Properties{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new EvaluationParameters(0,{});for(const i in e){const r=e[i];r.specification.overridable&&this.overridableProperties.push(i);const n=this.defaultPropertyValues[i]=new PropertyValue(r,void 0),o=this.defaultTransitionablePropertyValues[i]=new TransitionablePropertyValue(r);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=n.possiblyEvaluate(t)}}}bs(DataDrivenProperty,"DataDrivenProperty"),bs(DataConstantProperty,"DataConstantProperty"),bs(ColorRampProperty,"ColorRampProperty");var Gs=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}},"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}},"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"]}}},"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":{}}},"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":{}}},"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"]}}},"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-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-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}},"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"]},"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"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"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"]},"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"]},"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"]},"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"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":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"]},"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"]},"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"]},"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"]},"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"]},"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"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":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,"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"]}}},"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":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function Hs(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function qs(e){if(Array.isArray(e))return e.map(qs);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=qs(e[i]);return t}return Hs(e)}function $s(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(!$s(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Zs(e,t="",i=null,r="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};$s(e)||(e=ea(e));const n=e;let o=!0;try{o=function(e){if(!Ys(e))return e;let t=qs(e);return Xs(t),t=Ws(t),t}(n)}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(n,null,2)}\n `)}let s=null,a=null;if("background"!==r&&"sky"!==r&&"slot"!==r){a=Gs[`filter_${r}`];const e=ps(o,a,t,i);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(t,i,r)=>e.value.evaluate(t,i,{},r)}let l=null,c=null;if(o!==n){const e=ps(n,a,t,i);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));l=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),c=!oo(e.value.expression)}return{filter:s,dynamicFilter:l||void 0,needGeometry:Qs(o),needFeature:!!c}}function Ws(e){if(!Array.isArray(e))return e;const t=function(e){if(Ks.has(e[0]))for(let t=1;t<e.length;t++)if(Ys(e[t]))return!0;return e}(e);return!0===t?t:t.map((e=>Ws(e)))}function Xs(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r<e.length-1;r+=2)t=t||Ys(e[r]),i.push(e[r+1]);i.push(e[e.length-1])}else if("match"===e[0]){t=t||Ys(e[1]);for(let t=2;t<e.length-1;t+=2)i.push(e[t+1]);i.push(e[e.length-1])}else if("step"===e[0]){t=t||Ys(e[1]);for(let t=1;t<e.length-1;t+=2)i.push(e[t+1])}t&&(e.length=0,e.push("any",...i));for(let t=1;t<e.length;t++)Xs(e[t])}function Ys(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(Ys(e[t]))return!0;return!1}const Ks=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Js(e,t){return e<t?-1:e>t?1:0}function Qs(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(Qs(e[t]))return!0;return!1}function ea(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?ta(e[1],e[2],"=="):"!="===t?na(ta(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?ta(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(ea))):"all"===t?["all"].concat(e.slice(1).map(ea)):"none"===t?["all"].concat(e.slice(1).map(ea).map(na)):"in"===t?ia(e[1],e.slice(2)):"!in"===t?na(ia(e[1],e.slice(2))):"has"===t?ra(e[1]):"!has"!==t||na(ra(e[1]));var i}function ta(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function ia(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(Js)]]:["filter-in-small",e,["literal",t]]}}function ra(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function na(e){return["!",e]}const oa="";function sa(e){return e.indexOf(oa)>=0}function aa(e,t){return t?`${e}${oa}${t}`:e}function la(e){const t=e.indexOf(oa);return t>=0?e.slice(0,t):e}function ca(e){const t=e.indexOf(oa);return t>=0?e.slice(t+1):""}let ua;const ha=()=>ua||(ua=new Properties({"icon-size":new DataDrivenProperty(Gs.layout_symbol["icon-size"]),"icon-image":new DataDrivenProperty(Gs.layout_symbol["icon-image"]),"icon-rotate":new DataDrivenProperty(Gs.layout_symbol["icon-rotate"]),"icon-offset":new DataDrivenProperty(Gs.layout_symbol["icon-offset"]),"text-size":new DataDrivenProperty(Gs.layout_symbol["text-size"]),"text-rotate":new DataDrivenProperty(Gs.layout_symbol["text-rotate"]),"text-offset":new DataDrivenProperty(Gs.layout_symbol["text-offset"])}));class SymbolAppearance{constructor(e,t,i,r,n,o){const s=ps(e,Gs.appearance.condition);if("success"===s.result&&(this.condition=s.value),this.name=t,i){this.properties=new PossiblyEvaluated(ha()),this.unevaluatedLayout=new Layout(ha(),r,n,o);for(const e in i)this.unevaluatedLayout.setValue(e,i[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}getProperty(e){return this.properties.get(e)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(e){return this.unevaluatedLayout._values[e]}recalculate(e,t,i){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,i))}serialize(){const e={};return e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name),this.unevaluatedLayout&&(e.properties=this.unevaluatedLayout.serialize()),e}hasIconProperties(){const e=this.hasProperty("icon-image"),t=this.hasProperty("icon-size"),i=this.hasProperty("icon-offset"),r=this.hasProperty("icon-rotate");return e||t||i||r}hasTextProperties(){const e=this.hasProperty("text-size"),t=this.hasProperty("text-offset"),i=this.hasProperty("text-rotate");return e||t||i}hasProperty(e){return void 0!==this.getUnevaluatedProperty(e).value}}const da="-transition",pa=new Set(["fill","line","background","hillshade","raster"]);class StyleLayer extends Evented{constructor(e,t,i,r,n,o){if(super(),this.id=e.id,this.fqid=aa(this.id,i),this.type=e.type,this.scope=i,this.lut=r,this.options=n,this.iconImageUseTheme=o,this.appearances=new Array,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=ps(this.filter,Gs[`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 Layout(t.layout,this.scope,n,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 Transitionable(t.paint,this.scope,n);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 PossiblyEvaluated(t.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&pa.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 i=this._unevaluatedLayout;i._properties.properties[e]&&(i.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...i.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||i.isIndoorDependent(),"visibility"===e&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach((e=>{this.appearances.push(new SymbolAppearance(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme))}))}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(da)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return!!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const i=this._transitionablePaint,r=i._properties.properties;if(e.endsWith(da)){const n=e.slice(0,-11);return r[n]&&i.setTransition(n,t||void 0),!1}if(!r[e])return!1;const n=i._values[e],o=n.value.isDataDriven(),s=n.value;i.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...i.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||i.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);const a=i._values[e].value,l=a.isDataDriven(),c=e.endsWith("pattern")||"line-dasharray"===e;return l||o||c||this._handleOverridablePaintPropertyUpdate(e,s,a)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,i){return null}_handleOverridablePaintPropertyUpdate(e,t,i){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()))),it(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 PossiblyEvaluatedPropertyValue&&es(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}for(const e of this.appearances)if(!so(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=Zs(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}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,i){return{}}queryRadius(e){}queryIntersectsFeature(e,t,i,r,n,o,s,a,l){}}const fa={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Struct{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 ma=new ArrayBuffer(0);class StructArray{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=ma),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 _a(e,t=1){let i=0,r=0;return{members:e.map((e=>{const n=fa[e.type].BYTES_PER_ELEMENT,o=i=ga(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}})),size:ga(i,Math.max(r,t)),alignment:t}}function ga(e,t){return Math.ceil(e/t)*t}class StructArrayLayout2i4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}StructArrayLayout2i4.prototype.bytesPerElement=4,bs(StructArrayLayout2i4,"StructArrayLayout2i4");class StructArrayLayout3i6 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}StructArrayLayout3i6.prototype.bytesPerElement=6,bs(StructArrayLayout3i6,"StructArrayLayout3i6");class StructArrayLayout4i8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}StructArrayLayout4i8.prototype.bytesPerElement=8,bs(StructArrayLayout4i8,"StructArrayLayout4i8");class StructArrayLayout1f4 extends StructArray{_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}}StructArrayLayout1f4.prototype.bytesPerElement=4,bs(StructArrayLayout1f4,"StructArrayLayout1f4");class StructArrayLayout2i1f8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=4*e,o=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.float32[o+1]=r,e}}StructArrayLayout2i1f8.prototype.bytesPerElement=8,bs(StructArrayLayout2i1f8,"StructArrayLayout2i1f8");class StructArrayLayout3i8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=4*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}StructArrayLayout3i8.prototype.bytesPerElement=8,bs(StructArrayLayout3i8,"StructArrayLayout3i8");class StructArrayLayout5i10 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,e}}StructArrayLayout5i10.prototype.bytesPerElement=10,bs(StructArrayLayout5i10,"StructArrayLayout5i10");class StructArrayLayout2i4ub1f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,e}}StructArrayLayout2i4ub1f12.prototype.bytesPerElement=12,bs(StructArrayLayout2i4ub1f12,"StructArrayLayout2i4ub1f12");class StructArrayLayout3f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}StructArrayLayout3f12.prototype.bytesPerElement=12,bs(StructArrayLayout3f12,"StructArrayLayout3f12");class StructArrayLayout4ui1f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=6*e,a=3*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=r,this.uint16[s+3]=n,this.float32[a+2]=o,e}}StructArrayLayout4ui1f12.prototype.bytesPerElement=12,bs(StructArrayLayout4ui1f12,"StructArrayLayout4ui1f12");class StructArrayLayout4ui8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=r,this.uint16[o+3]=n,e}}StructArrayLayout4ui8.prototype.bytesPerElement=8,bs(StructArrayLayout4ui8,"StructArrayLayout4ui8");class StructArrayLayout6i12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}StructArrayLayout6i12.prototype.bytesPerElement=12,bs(StructArrayLayout6i12,"StructArrayLayout6i12");class StructArrayLayout4i4ui4i24 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,u,h)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}StructArrayLayout4i4ui4i24.prototype.bytesPerElement=24,bs(StructArrayLayout4i4ui4i24,"StructArrayLayout4i4ui4i24");class StructArrayLayout3i3f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}StructArrayLayout3i3f20.prototype.bytesPerElement=20,bs(StructArrayLayout3i3f20,"StructArrayLayout3i3f20");class StructArrayLayout4f16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}StructArrayLayout4f16.prototype.bytesPerElement=16,bs(StructArrayLayout4f16,"StructArrayLayout4f16");class StructArrayLayout1ul4 extends StructArray{_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}}StructArrayLayout1ul4.prototype.bytesPerElement=4,bs(StructArrayLayout1ul4,"StructArrayLayout1ul4");class StructArrayLayout2ui4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}StructArrayLayout2ui4.prototype.bytesPerElement=4,bs(StructArrayLayout2ui4,"StructArrayLayout2ui4");class StructArrayLayout5i4f1i1ul2ui40 extends StructArray{_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,i,r,n,o,s,a,l,c,u,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,u,h,d)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}StructArrayLayout5i4f1i1ul2ui40.prototype.bytesPerElement=40,bs(StructArrayLayout5i4f1i1ul2ui40,"StructArrayLayout5i4f1i1ul2ui40");class StructArrayLayout3i2i2i16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}StructArrayLayout3i2i2i16.prototype.bytesPerElement=16,bs(StructArrayLayout3i2i2i16,"StructArrayLayout3i2i2i16");class StructArrayLayout2f1f2i16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}StructArrayLayout2f1f2i16.prototype.bytesPerElement=16,bs(StructArrayLayout2f1f2i16,"StructArrayLayout2f1f2i16");class StructArrayLayout2ub4f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=20*e,l=5*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}StructArrayLayout2ub4f20.prototype.bytesPerElement=20,bs(StructArrayLayout2ub4f20,"StructArrayLayout2ub4f20");class StructArrayLayout3ui6 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}StructArrayLayout3ui6.prototype.bytesPerElement=6,bs(StructArrayLayout3ui6,"StructArrayLayout3ui6");class StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60 extends StructArray{_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,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60.prototype.bytesPerElement=60,bs(StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class StructArrayLayout2f9i15ui1ul4f1ub1ui80 extends StructArray{_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,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b,w,T,E,S,A,I,C,M,D,P,L){const R=this.length;return this.resize(R+1),this.emplace(R,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b,w,T,E,S,A,I,C,M,D,P,L)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b,w,T,E,S,A,I,C,M,D,P,L,R){const z=20*e,F=40*e,O=80*e;return this.float32[z+0]=t,this.float32[z+1]=i,this.int16[F+4]=r,this.int16[F+5]=n,this.int16[F+6]=o,this.int16[F+7]=s,this.int16[F+8]=a,this.int16[F+9]=l,this.int16[F+10]=c,this.int16[F+11]=u,this.int16[F+12]=h,this.uint16[F+13]=d,this.uint16[F+14]=p,this.uint16[F+15]=f,this.uint16[F+16]=m,this.uint16[F+17]=_,this.uint16[F+18]=g,this.uint16[F+19]=y,this.uint16[F+20]=x,this.uint16[F+21]=v,this.uint16[F+22]=b,this.uint16[F+23]=w,this.uint16[F+24]=T,this.uint16[F+25]=E,this.uint16[F+26]=S,this.uint16[F+27]=A,this.uint32[z+14]=I,this.float32[z+15]=C,this.float32[z+16]=M,this.float32[z+17]=D,this.float32[z+18]=P,this.uint8[O+76]=L,this.uint16[F+39]=R,e}}StructArrayLayout2f9i15ui1ul4f1ub1ui80.prototype.bytesPerElement=80,bs(StructArrayLayout2f9i15ui1ul4f1ub1ui80,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class StructArrayLayout6f24 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,this.float32[a+3]=n,this.float32[a+4]=o,this.float32[a+5]=s,e}}StructArrayLayout6f24.prototype.bytesPerElement=24,bs(StructArrayLayout6f24,"StructArrayLayout6f24");class StructArrayLayout5f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,e}}StructArrayLayout5f20.prototype.bytesPerElement=20,bs(StructArrayLayout5f20,"StructArrayLayout5f20");class StructArrayLayout7f28 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}StructArrayLayout7f28.prototype.bytesPerElement=28,bs(StructArrayLayout7f28,"StructArrayLayout7f28");class StructArrayLayout11f44 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,n,o,s,a,l,c,u)}emplace(e,t,i,r,n,o,s,a,l,c,u,h){const d=11*e;return this.float32[d+0]=t,this.float32[d+1]=i,this.float32[d+2]=r,this.float32[d+3]=n,this.float32[d+4]=o,this.float32[d+5]=s,this.float32[d+6]=a,this.float32[d+7]=l,this.float32[d+8]=c,this.float32[d+9]=u,this.float32[d+10]=h,e}}StructArrayLayout11f44.prototype.bytesPerElement=44,bs(StructArrayLayout11f44,"StructArrayLayout11f44");class StructArrayLayout9f36 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,r,n,o,s,a,l)}emplace(e,t,i,r,n,o,s,a,l,c){const u=9*e;return this.float32[u+0]=t,this.float32[u+1]=i,this.float32[u+2]=r,this.float32[u+3]=n,this.float32[u+4]=o,this.float32[u+5]=s,this.float32[u+6]=a,this.float32[u+7]=l,this.float32[u+8]=c,e}}StructArrayLayout9f36.prototype.bytesPerElement=36,bs(StructArrayLayout9f36,"StructArrayLayout9f36");class StructArrayLayout2f8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}StructArrayLayout2f8.prototype.bytesPerElement=8,bs(StructArrayLayout2f8,"StructArrayLayout2f8");class StructArrayLayout1ul3ui12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}StructArrayLayout1ul3ui12.prototype.bytesPerElement=12,bs(StructArrayLayout1ul3ui12,"StructArrayLayout1ul3ui12");class StructArrayLayout1ui2 extends StructArray{_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}}StructArrayLayout1ui2.prototype.bytesPerElement=2,bs(StructArrayLayout1ui2,"StructArrayLayout1ui2");class StructArrayLayout16f64 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=i,this.float32[g+2]=r,this.float32[g+3]=n,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=u,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]=_,e}}StructArrayLayout16f64.prototype.bytesPerElement=64,bs(StructArrayLayout16f64,"StructArrayLayout16f64");class StructArrayLayout4ui3f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=r,this.uint16[l+3]=n,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,e}}StructArrayLayout4ui3f20.prototype.bytesPerElement=20,bs(StructArrayLayout4ui3f20,"StructArrayLayout4ui3f20");class StructArrayLayout1i2 extends StructArray{_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}}StructArrayLayout1i2.prototype.bytesPerElement=2,bs(StructArrayLayout1i2,"StructArrayLayout1i2");class StructArrayLayout1ub1 extends StructArray{_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}}StructArrayLayout1ub1.prototype.bytesPerElement=1,bs(StructArrayLayout1ub1,"StructArrayLayout1ub1");class CollisionBoxStruct extends Struct{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]}}CollisionBoxStruct.prototype.size=40;class CollisionBoxArray extends StructArrayLayout5i4f1i1ul2ui40{get(e){return new CollisionBoxStruct(this,e)}}bs(CollisionBoxArray,"CollisionBoxArray");class PlacedSymbolStruct extends Struct{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}}PlacedSymbolStruct.prototype.size=60;class PlacedSymbolArray extends StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60{get(e){return new PlacedSymbolStruct(this,e)}}bs(PlacedSymbolArray,"PlacedSymbolArray");class SymbolInstanceStruct extends Struct{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]}}SymbolInstanceStruct.prototype.size=80;class SymbolInstanceArray extends StructArrayLayout2f9i15ui1ul4f1ub1ui80{get(e){return new SymbolInstanceStruct(this,e)}}bs(SymbolInstanceArray,"SymbolInstanceArray");class GlyphOffsetArray extends StructArrayLayout1f4{getoffsetX(e){return this.float32[1*e+0]}}bs(GlyphOffsetArray,"GlyphOffsetArray");class SymbolLineVertexArray extends StructArrayLayout2i4{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}bs(SymbolLineVertexArray,"SymbolLineVertexArray");class FeatureIndexStruct extends Struct{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]}}FeatureIndexStruct.prototype.size=12;class FeatureIndexArray extends StructArrayLayout1ul3ui12{get(e){return new FeatureIndexStruct(this,e)}}bs(FeatureIndexArray,"FeatureIndexArray");class FillExtrusionCentroidArray extends StructArrayLayout2ui4{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}bs(FillExtrusionCentroidArray,"FillExtrusionCentroidArray");class FillExtrusionWallStruct extends Struct{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]}}FillExtrusionWallStruct.prototype.size=6;class FillExtrusionWallArray extends StructArrayLayout3i6{get(e){return new FillExtrusionWallStruct(this,e)}}bs(FillExtrusionWallArray,"FillExtrusionWallArray");const ya=_a([{name:"a_pos",components:2,type:"Int16"}],4),xa=_a([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),va=_a([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class SegmentVector{constructor(e=[]){this.segments=e}_prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>SegmentVector.MAX_VERTEX_ARRAY_LENGTH&&st(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>SegmentVector.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}prepareSegment(e,t,i,r){return this._prepareSegment(e,t.length,i.length,r)}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,i,r){return new SegmentVector([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function ba(e,t){return 256*(e=He(Math.floor(e),0,255))+He(Math.floor(t),0,255)}SegmentVector.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,bs(SegmentVector,"SegmentVector");const wa=_a([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ta=_a([{name:"a_pattern_b",components:4,type:"Uint16"}]),Ea=_a([{name:"a_dash",components:4,type:"Uint16"}]);class FeaturePositionMap{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(Sa(e)),this.positions.push(t,i,r)}eachPosition(e,t){const i=Sa(e);let r=0,n=this.ids.length-1;for(;r<n;){const e=r+n>>1;this.ids[e]>=i?n=e:r=e+1}for(;this.ids[r]===i;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Aa(i,r,0,i.length-1),t&&(t.add(i.buffer),t.add(r.buffer)),{ids:i,positions:r}}static deserialize(e){const t=new FeaturePositionMap;let i;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==i&&t.uniqueIds.push(e),i=e;return t.indexed=!0,t}}function Sa(e){const t=+e;return Number.isSafeInteger(t)?t:pr(String(e))}function Aa(e,t,i,r){for(;i<r;){const n=e[i+r>>1];let o=i-1,s=r+1;for(;;){do{o++}while(e[o]<n);do{s--}while(e[s]>n);if(o>=s)break;Ia(e,o,s),Ia(t,3*o,3*s),Ia(t,3*o+1,3*s+1),Ia(t,3*o+2,3*s+2)}s-i<r-s?(Aa(e,t,i,s),i=s+1):(Aa(e,t,s+1,r),r=s)}}function Ia(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}bs(FeaturePositionMap,"FeaturePositionMap");class Uniform{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,i){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class Uniform1i extends Uniform{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}}class Uniform1f extends Uniform{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i))}}class Uniform2f extends Uniform{constructor(e){super(e),this.current=[0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}}class Uniform3f extends Uniform{constructor(e){super(e),this.current=[0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}}class Uniform4f extends Uniform{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])))}}class UniformColor extends Uniform{constructor(e){super(e),this.current=Color.transparent.toPremultipliedRenderColor(null)}set(e,t,i){this.fetchUniformLocation(e,t)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)))}}const Ca=new Float32Array(16);class UniformMatrix4f extends Uniform{constructor(e){super(e),this.current=Ca}set(e,t,i){if(this.fetchUniformLocation(e,t)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}}const Ma=new Float32Array(9);class UniformMatrix3f extends Uniform{constructor(e){super(e),this.current=Ma}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}const Da=new Float32Array(4);class UniformMatrix2f extends Uniform{constructor(e){super(e),this.current=Da}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}function Pa(e){return[ba(255*e.r,255*e.g),ba(255*e.b,255*e.a)]}function La(e,t,i,r,n,o,s,a){return!!e&&("composite"===e.kind||"source"===e.kind?"none"===e.evaluate(new EvaluationParameters(0,{brightness:o,worldview:a}),t,i,n,r,s):"none"===e.value)}class ConstantBinder{constructor(e,t,i,r){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=i,this.context=r}setUniform(e,t,i,r,n){const o=r.constantOr(this.value);t.set(e,n,o instanceof Color?o.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):o)}getBinding(e,t){return"color"===this.type?new UniformColor(e):new Uniform1f(e)}}class PatternConstantBinder{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,i,r,n){let o=null;"u_pattern"!==n&&"u_dash"!==n||(o=this.pattern),"u_pattern_b"===n&&(o=this.patternTransition),"u_pixel_ratio"===n&&(o=this.pixelRatio),o&&t.set(e,n,o)}getBinding(e,t){return"u_pattern"===t||"u_pattern_b"===t||"u_dash"===t?new Uniform4f(e):new Uniform1f(e)}}class SourceExpressionBinder{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o,s,a){const l=this.paintVertexArray.length,c="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new EvaluationParameters(0,{brightness:o,worldview:a}),t,{},n,r,s):"constant"===this.expression.kind&&this.expression.value,u=La(this.lutExpression,t,{},r,n,o,s,a);this.paintVertexArray.resize(e),this._setPaintValue(l,e,c,u?null:this.context.lut)}updatePaintArray(e,t,i,r,n,o,s,a){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:s,worldview:a},i,r,void 0,n):"constant"===this.expression.kind&&this.expression.value,c=La(this.lutExpression,i,r,n,void 0,s,void 0,a);this._setPaintValue(e,t,l,c?null:this.context.lut)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Pa(i.toPremultipliedRenderColor(r));for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}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 CompositeExpressionBinder{constructor(e,t,i,r,n,o){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.context=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o,s,a){const l=this.expression.evaluate(new EvaluationParameters(this.context.zoom,{brightness:o,worldview:a}),t,{},n,r,s),c=this.expression.evaluate(new EvaluationParameters(this.context.zoom+1,{brightness:o,worldview:a}),t,{},n,r,s),u=La(this.lutExpression,t,{},r,n,o,s,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,c,u?null:this.context.lut)}updatePaintArray(e,t,i,r,n,o,s,a){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:s,worldview:a},i,r,void 0,n),c=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s,worldview:a},i,r,void 0,n),u=La(this.lutExpression,i,r,n,void 0,s,void 0,a);this._setPaintValue(e,t,l,c,u?null:this.context.lut)}_setPaintValue(e,t,i,r,n){if("color"===this.type){const r=Pa(i.toPremultipliedRenderColor(n)),o=Pa(i.toPremultipliedRenderColor(n));for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1],o[0],o[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),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.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t,i,r,n){const o=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,s=He(this.expression.interpolationFactor(o,this.context.zoom,this.context.zoom+1),0,1);t.set(e,n,s)}getBinding(e,t){return new Uniform1f(e)}}class PatternCompositeBinder{constructor(e,t,i,r,n){this.expression=e,this.layerId=n,this.paintVertexAttributes=("array"===i?Ea:wa).members;for(let e=0;e<t.length;++e);this.paintVertexArray=new r,this.paintTransitionVertexArray=new StructArrayLayout4ui8}populatePaintArray(e,t,i,r){const n=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(n,e,t.patterns&&t.patterns[this.layerId],i)}updatePaintArray(e,t,i,r,n,o,s){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o)}_setPaintValues(e,t,i,r){if(!r||!i)return;const n=r[i[0]],o=r[i[1]];if(n){if(n){const{tl:i,br:r,pixelRatio:o}=n;for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i[0],i[1],r[0],r[1],o)}if(o){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);const{tl:i,br:r}=o;for(let n=e;n<t;n++)this.paintTransitionVertexArray.emplace(n,i[0],i[1],r[0],r[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,Ta.members,t))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class ProgramConfiguration{constructor(e,t,i=(()=>!0)){this.binders={},this._buffers=[],this.context=t;const r=[];for(const n in e.paint._values){const o=e.paint.get(n);if(n.endsWith("-use-theme"))continue;if(!i(n))continue;if(!(o instanceof PossiblyEvaluatedPropertyValue&&es(o.property.specification)))continue;const s=za(n,e.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,u="line-dasharray"===n||n.endsWith("pattern"),h=e.paint.get(`${n}-use-theme`),d="line-dasharray"===n&&"constant"!==e.layout.get("line-cap").value.kind||h&&"constant"!==h.value.kind;if("constant"!==a.kind||d)if("source"===a.kind||d||u){const t=Ba(n,l,"source");this.binders[n]=u?new PatternCompositeBinder(a,s,l,t,e.id):new SourceExpressionBinder(a,s,l,t),r.push(`/a_${n}`)}else{const e=Ba(n,l,"composite");this.binders[n]=new CompositeExpressionBinder(a,s,l,c,t,e),r.push(`/z_${n}`)}else this.binders[n]=u?new PatternConstantBinder(a.value,s):new ConstantBinder(a.value,s,l,t),r.push(`/u_${n}`);h&&(this.binders[n].lutExpression=h.value)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof SourceExpressionBinder||t instanceof CompositeExpressionBinder?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];c.context=this.context,(c instanceof SourceExpressionBinder||c instanceof CompositeExpressionBinder||c instanceof PatternCompositeBinder)&&c.populatePaintArray(e,t,i,r,n,o,s,a)}}setConstantPatternPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof PatternConstantBinder&&r.setConstantPatternPositions(e,t)}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof PatternCompositeBinder?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,i,r,n,o,s,a,l,c){let u=!1;const h=Object.keys(e),d=0!==h.length&&!a,p=d?h:t.uniqueIds;this.context.lut=n.lut;for(const a in this.binders){const h=this.binders[a];if(h.context=this.context,(h instanceof SourceExpressionBinder||h instanceof CompositeExpressionBinder||h instanceof PatternCompositeBinder)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=n.paint.get(a);h.expression=f.value;for(const i of p){const n=e[i.toString()];t.eachPosition(i,((e,t,i)=>{const a=r.feature(e);h.updatePaintArray(t,i,a,n,o,s,l,c)}))}if(!d)for(const t of i.uniqueIds){const n=e[t.toString()];i.eachPosition(t,((e,t,i)=>{const a=r.feature(e);h.updatePaintArray(t,i,a,n,o,s,l,c)}))}u=!0}}return u}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof ConstantBinder||i instanceof PatternConstantBinder)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const i in this.binders){const r=this.binders[i];if(r instanceof ConstantBinder||r instanceof PatternConstantBinder||r instanceof CompositeExpressionBinder)for(const n of r.uniformNames)t.push({name:n,property:i,binding:r.getBinding(e,n)})}return t}setUniforms(e,t,i,r,n){for(const{name:t,property:o,binding:s}of i)this.binders[o].setUniform(e,s,n,r.get(o),t)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof SourceExpressionBinder||t instanceof CompositeExpressionBinder||t instanceof PatternCompositeBinder)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof PatternCompositeBinder&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof SourceExpressionBinder||i instanceof CompositeExpressionBinder||i instanceof PatternCompositeBinder)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof SourceExpressionBinder||t instanceof CompositeExpressionBinder||t instanceof PatternCompositeBinder)&&t.destroy()}}}class ProgramConfigurationSet{constructor(e,t,i=(()=>!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new ProgramConfiguration(r,t,i);this.needsUpload=!1,this._featureMap=new FeaturePositionMap,this._featureMapWithoutIds=new FeaturePositionMap,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,i,r,n,o,s,a,l){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s,a,l);void 0!==t.id?this._featureMap.add(t.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r,n,o,s,a){for(const l of i)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,r,n,o,s||0,a)||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 Ra={"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 za(e,t){return Ra[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Fa={"line-pattern":{source:StructArrayLayout4ui1f12,composite:StructArrayLayout4ui1f12},"fill-pattern":{source:StructArrayLayout4ui1f12,composite:StructArrayLayout4ui1f12},"fill-extrusion-pattern":{source:StructArrayLayout4ui1f12,composite:StructArrayLayout4ui1f12},"line-dasharray":{source:StructArrayLayout4ui8,composite:StructArrayLayout4ui8}},Oa={color:{source:StructArrayLayout2f8,composite:StructArrayLayout4f16},number:{source:StructArrayLayout1f4,composite:StructArrayLayout2f8}};function Ba(e,t,i){const r=Fa[e];return r&&r[i]||Oa[t][i]}bs(ConstantBinder,"ConstantBinder"),bs(PatternConstantBinder,"PatternConstantBinder"),bs(SourceExpressionBinder,"SourceExpressionBinder"),bs(PatternCompositeBinder,"PatternCompositeBinder"),bs(CompositeExpressionBinder,"CompositeExpressionBinder"),bs(ProgramConfiguration,"ProgramConfiguration",{omit:["_buffers"]}),bs(ProgramConfigurationSet,"ProgramConfigurationSet");const ka=Mn/Math.PI/2,Ua=5,Va=6,Na=16383,ja=64,Ga=[ja,32,16],Ha=-ka,qa=ka;function $a(e,t,i,r=ka){return i=Oe(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function Za(e,t,i){return $a(Math.cos(Oe(e)),Math.sin(Oe(e)),t,i)}const Wa=6371008.8,Xa=2*Math.PI*Wa;class LngLat{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 LngLat($e(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,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return Wa*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new LngLatBounds({lng:this.lng-i,lat:this.lat-t},{lng:this.lng+i,lat:this.lat+t})}toEcef(e){return Za(this.lat,this.lng,ka+e*ka/Wa)}static convert(e){if(e instanceof LngLat)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new LngLat(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new LngLat(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 LngLatBounds{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 LngLat?new LngLat(e.lng,e.lat):LngLat.convert(e),this}setSouthWest(e){return this._sw=e instanceof LngLat?new LngLat(e.lng,e.lat):LngLat.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof LngLat)r=e,n=e;else{if(!(e instanceof LngLatBounds))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(LngLatBounds.convert(e)):this.extend(LngLat.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(LngLat.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new LngLat(r.lng,r.lat),this._ne=new LngLat(n.lng,n.lat)),this}getCenter(){return new LngLat((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 LngLat(this.getWest(),this.getNorth())}getSouthEast(){return new LngLat(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:i}=LngLat.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){if(e)return e instanceof LngLatBounds?e:new LngLatBounds(e)}}const Ya=0,Ka=25.5;function Ja(e){return Xa*Math.cos(e*Math.PI/180)}function Qa(e){return(180+e)/360}function el(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function tl(e,t){return e/Ja(t)}function il(e){return 360*e-180}function rl(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function nl(e,t){return e*Ja(rl(t))}const ol=85.051129;function sl(e){return Math.cos(Oe(He(e,-ol,ol)))}function al(e,t){const i=He(t,Ya,Ka),r=Math.pow(2,i);return sl(e)*Xa/(512*r)}function ll(e){return 1/Math.cos(e*Math.PI/180)}function cl(e,t=0){const i=Math.exp(Math.PI*(1-(e.y+t/Mn)/(1<<e.z)*2));return 80150034*i/(i*i+1)/Mn/(1<<e.z)}class MercatorCoordinate{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=LngLat.convert(e);return new MercatorCoordinate(Qa(i.lng),el(i.lat),tl(t,i.lat))}toLngLat(){return new LngLat(il(this.x),rl(this.y))}toAltitude(){return nl(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Xa*ll(rl(this.y))}}function ul(e,t,i,r,n,o,s,a,l){const c=(t+r)/2,u=(i+n)/2,h=new Le(c,u);a(h),function(e,t,i,r,n,o){const s=i-n,a=r-o;return Math.abs((r-t)*s-(i-e)*a)/Math.hypot(s,a)}(h.x,h.y,o.x,o.y,s.x,s.y)>=l?(ul(e,t,i,c,u,o,h,a,l),ul(e,c,u,r,n,h,s,a,l)):e.push(s)}function hl(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const s=[r];for(let a=1;a<e.length;a++){const l=e[a],{x:c,y:u}=l;t(l),ul(s,n,o,c,u,r,l,t,i),n=c,o=u,r=l}return s}function dl(e,t,i,r){if(r(t,i)){const n=t.add(i)._mult(.5);dl(e,t,n,r),dl(e,n,i,r)}else e.push(i)}function pl(e,t){let i=e[0];const r=[i];for(let n=1;n<e.length;n++){const o=e[n];dl(r,i,o,t),i=o}return r}const fl=Math.pow(2,14)-1,ml=-fl-1;function _l(e,t){const i=Math.round(e.x*t),r=Math.round(e.y*t);return e.x=He(i,ml,fl),e.y=He(r,ml,fl),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&st("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function gl(e,t,i){const r=e.loadGeometry(),n=e.extent,o=Mn/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:s,x:a,y:l,projection:c}=i,u=e=>{const i=il((t.x+e.x/n)/o),r=rl((t.y+e.y/n)/o),u=c.project(i,r);e.x=(u.x*s-a)*n,e.y=(u.y*s-l)*n};for(let t=0;t<r.length;t++)if(1!==e.type)r[t]=hl(r[t],u,1);else{const e=[];for(const i of r[t])i.x<0||i.x>=n||i.y<0||i.y>=n||(u(i),e.push(i));r[t]=e}}for(const e of r)for(const t of e)_l(t,o);return r}function yl(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?gl(e):[]}}class VectorTileFeature{constructor(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(xl,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,i=[];let r,n=1,o=0,s=0,a=0;for(;e.pos<t;){if(o<=0){const t=e.readVarint();n=7&t,o=t>>3}if(o--,1===n||2===n)s+=e.readSVarint(),a+=e.readSVarint(),1===n&&(r&&i.push(r),r=[]),r&&r.push(new Le(s,a));else{if(7!==n)throw new Error(`unknown command ${n}`);r&&r.push(r[0].clone())}}return r&&i.push(r),i}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos<t;){if(r<=0){const t=e.readVarint();i=7&t,r=t>>3}if(r--,1===i||2===i)n+=e.readSVarint(),o+=e.readSVarint(),n<s&&(s=n),n>a&&(a=n),o<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const r=this.extent*Math.pow(2,i),n=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+n)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/r)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=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 i=[];let r,n;for(let o=0;o<t;o++){const t=vl(e[o]);0!==t&&(void 0===n&&(n=t<0),n===t<0?(r&&i.push(r),r=[e[o]]):r&&r.push(e[o]))}return r&&i.push(r),i}(s),t=[];for(const i of e)t.push(i.map(l));c=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}}const u={type:"Feature",geometry:c,properties:this.properties};return null!=this.id&&(u.id=this.id),u}}function xl(e,t,i){1===e?t.id=i.readVarint():2===e?function(e,t){const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[i]=r}}(i,t):3===e?t.type=i.readVarint():4===e&&(t._geometry=i.pos)}function vl(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}VectorTileFeature.types=["Unknown","Point","LineString","Polygon"];class VectorTileLayer{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(bl,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 VectorTileFeature(this._pbf,t,this.extent,this._keys,this._values)}}function bl(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=e.readVarint()>>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class VectorTile{constructor(e,t){this.layers=e.readFields(wl,{},t)}}function wl(e,t,i){if(3===e){const e=new VectorTileLayer(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Tl="3d_elevation_id",El="level";class PropertyParser{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,i){return this.get(e,!0,t,i)}optional(e,t,i){return this.get(e,!1,t,i)}success(){return this._valid}get(e,t,i,r){const n=this.feature.properties.hasOwnProperty(e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==n&&!Number.isNaN(n)?i(r?r(n):n):t&&(this._valid=!1),this}}class VersionSchema{constructor(e,t){this.featureFunc=e,this.vertexFunc=t}parseFeature(e,t,i){return this.featureFunc(e,t,i)}parseVertex(e,t,i){return this.vertexFunc(e,t,i)}}const Sl=new VersionSchema(((e,t,i)=>e.reset(t).require(Tl,(e=>{i.id=e})).optional("fixed_height_relative",(e=>{i.constantHeight=e}),ElevationFeatureParser.decodeRelativeHeight).geometry((e=>{i.bounds=e}),cn).success()),((e,t,i)=>e.reset(t).require(Tl,(e=>{i.id=e})).require("elevation_idx",(e=>{i.idx=e})).require("extent",(e=>{i.extent=e})).require("height_relative",(e=>{i.height=e}),ElevationFeatureParser.decodeRelativeHeight).geometry((e=>{i.position=e}),ElevationFeatureParser.getPoint).success())),Al=new VersionSchema(((e,t,i)=>e.reset(t).require(Tl,(e=>{i.id=e})).optional("fixed_height",(e=>{i.constantHeight=e}),ElevationFeatureParser.decodeMetricHeight).geometry((e=>{i.bounds=e}),cn).success()),((e,t,i)=>e.reset(t).require(Tl,(e=>{i.id=e})).require("elevation_idx",(e=>{i.idx=e})).require("extent",(e=>{i.extent=e})).require("height",(e=>{i.height=e}),ElevationFeatureParser.decodeMetricHeight).geometry((e=>{i.position=e}),ElevationFeatureParser.getPoint).success()));class ElevationFeatureParser{static getPoint(e){return ye(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?Al:void 0:Sl}static parse(e){const t=[],i=[],r=e.length,n=new PropertyParser;for(let o=0;o<r;o++){const r=e.feature(o),s=r.properties.version,a=ElevationFeatureParser.getVersionSchema(s);if(void 0===a){st(`Unknown elevation feature version number ${s||"(unknown)"}`);continue}const l=r.properties.type;if(!l)continue;const c=VectorTileFeature.types[r.type];if("Point"===c&&"curve_point"===l){const e={};a.parseVertex(n,r,e)&&t.push(e)}else if("Polygon"===c&&"curve_meta"===l){const e={};a.parseFeature(n,r,e)&&i.push(e)}}return{vertices:t,features:i}}}class Ray2D{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const r=Se(t,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,!0}}class Ray{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const r=H(t,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,i[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(t,i,r){if(function(t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return Math.abs(r-s)<=e*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=e*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-l)<=e*Math.max(1,Math.abs(o),Math.abs(l))}(this.pos,t)||0===i)return r[0]=r[1]=r[2]=0,!1;const[n,o,s]=this.dir,a=this.pos[0]-t[0],l=this.pos[1]-t[1],c=this.pos[2]-t[2],u=n*n+o*o+s*s,h=2*(a*n+l*o+c*s),d=h*h-4*u*(a*a+l*l+c*c-i*i);if(d<0){const e=Math.max(-h/2,0),t=a+n*e,u=l+o*e,d=c+s*e,p=Math.hypot(t,u,d);return r[0]=t*i/p,r[1]=u*i/p,r[2]=d*i/p,!1}{const e=(-h-Math.sqrt(d))/(2*u);if(e<0){const e=Math.hypot(a,l,c);return r[0]=a*i/e,r[1]=l*i/e,r[2]=c*i/e,!1}return r[0]=a+n*e,r[1]=l+o*e,r[2]=c+s*e,!0}}}class FrustumCorners{constructor(e,t,i,r,n){this.TL=e,this.TR=t,this.BR=i,this.BL=r,this.horizon=n}static fromInvProjectionMatrix(e,t,i){const r=[-1,1,1],n=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Z(r,r,e),l=Z(n,n,e),c=Z(o,o,e),u=Z(s,s,e);return new FrustumCorners(a,l,c,u,t/i)}}function Il(e,t,i){let r=1/0,n=-1/0;const o=[];for(const s of e){J(o,s,t);const e=H(o,i);r=Math.min(r,e),n=Math.max(n,e)}return[r,n]}function Cl(e,t){let i=!0;for(let r=0;r<e.planes.length;r++){const n=e.planes[r];let o=0;for(let e=0;e<t.length;e++)o+=+(H(n,t[e])+n[3]>=0);if(0===o)return 0;o!==t.length&&(i=!1)}return i?2:1}function Ml(e,t){for(const i of e.projections){const r=Il(t,e.points[0],i.axis);if(i.projection[1]<r[0]||i.projection[0]>r[1])return 0}return 1}function Dl(e,t){let i=0;const r=[0,0,0,0];for(let s=0;s<e.length;s++)r[0]=e[s][0],r[1]=e[s][1],r[2]=e[s][2],r[3]=1,(n=r)[0]*(o=t)[0]+n[1]*o[1]+n[2]*o[2]+n[3]*o[3]>=0&&i++;var n,o;return i}class Frustum{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=Aabb.fromPoints(this.points),this.projections=[],this.frustumEdges=[J([],this.points[2],this.points[3]),J([],this.points[0],this.points[3]),J([],this.points[4],this.points[0]),J([],this.points[5],this.points[1]),J([],this.points[6],this.points[2]),J([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],i=[e[2],0,-e[0]];this.projections.push({axis:t,projection:Il(this.points,this.points[0],t)}),this.projections.push({axis:i,projection:Il(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(e,t,i,r){const n=Math.pow(2,i),o=[[-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((i=>{const o=se([],i,e),s=1/o[3]/t*n;return(a=o)[0]=(l=o)[0]*(c=[s,s,r?1/o[3]:s,s])[0],a[1]=l[1]*c[1],a[2]=l[2]*c[2],a[3]=l[3]*c[3],a;var a,l,c})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=G([],q([],J([],o[e[0]],o[e[1]]),J([],o[e[2]],o[e[1]]))),i=-H(t,o[e[1]]);return t.concat(i)})),a=[];for(let e=0;e<o.length;e++)a.push([o[e][0],o[e][1],o[e][2]]);return new Frustum(a,s)}intersectsPrecise(e,t,i){for(let i=0;i<t.length;i++)if(!Dl(e,t[i]))return 0;for(let t=0;t<this.planes.length;t++)if(!Dl(e,this.planes[t]))return 0;for(const t of i)for(const i of this.frustumEdges){const r=q([],t,i),n=M(r);if(0===n)continue;B(r,r,1/n);const o=Il(this.points,this.points[0],r),s=Il(e,this.points[0],r);if(o[0]>s[1]||s[0]>o[1])return 0}return 1}containsPoint(e){for(const t of this.planes){const i=t[3];if(H([t[0],t[1],t[2]],e)+i<0)return!1}return!0}}class Aabb{static fromPoints(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const r of e)F(t,t,r),O(i,i,r);return new Aabb(t,i)}static fromTileIdAndHeight(e,t,i){const r=1<<e.canonical.z,n=e.canonical.x,o=e.canonical.y;return new Aabb([n/r,o/r,t],[(n+1)/r,(o+1)/r,i])}static applyTransform(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)Z(i[e],i[e],t);return Aabb.fromPoints(i)}static applyTransformFast(e,t){const i=[t[12],t[13],t[14]],r=[...i];for(let n=0;n<3;n++)for(let o=0;o<3;o++){const s=t[4*o+n],a=s*e.min[o],l=s*e.max[o];i[n]+=Math.min(a,l),r[n]+=Math.max(a,l)}return new Aabb(i,r)}static projectAabbCorners(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)Z(i[e],i[e],t);return i}constructor(e,t){this.min=e,this.max=t,this.center=B([],L([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=C(this.min),r=C(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],r[e]=t[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new Aabb(i,r)}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)?Cl(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?Cl(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)?Ml(e,this.getCorners()):0}intersectsPreciseFlat(e,t){return t||this.intersectsFlat(e)?Ml(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])]}}bs(Aabb,"Aabb");class EdgeIterator{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,i=t[1],r=-t[0],n=(e.extent+1)*this.metersToTile;return[new Le(Math.trunc(e.position[0]+i*n),Math.trunc(e.position[1]+r*n)),new Le(Math.trunc(e.position[0]-i*n),Math.trunc(e.position[1]-r*n))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class ElevationFeature{constructor(e,t,i,r,n,o){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this._tmpVec2=[ge(),ge(),ge(),ge(),ge(),ge(),ge()],this.id=e,this.heightRange={min:i,max:i},this.safeArea=t,this.constantHeight=i,null==this.constantHeight&&(null!=this.constantHeight||0!==r.length)){this.vertices=r,this.edges=n,this.edges=this.edges.filter((e=>{return e.a<this.vertices.length&&e.b<this.vertices.length&&!((t=this.vertices[e.a].position)[0]===(i=this.vertices[e.b].position)[0]&&t[1]===i[1]);var t,i})),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(const e of this.vertices)this.vertexProps.push({dir:ye(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,i=this.vertices[e.b].position,r=be(ge(),i,t),n=Te(r),o=we(ge(),r,1/n);this.edgeProps.push({vec:r,dir:o,len:n});const s=this.vertexProps[e.a].dir,a=this.vertexProps[e.b].dir;ve(s,s,o),ve(a,a,o)}for(const e of this.vertexProps)0===e.dir[0]&&0===e.dir[1]||Ee(e.dir,e.dir);this.tessellate(o)}}pointElevation(e){if(null!=this.constantHeight)return this.constantHeight;const t=this.getClosestEdge(e);if(null==t)return 0;const[i,r]=t;return xr(this.vertices[this.edges[i].a].height,this.vertices[this.edges[i].b].height,r)}computeSlopeNormal(e,t){const i=this.getClosestEdge(e);if(!i)return D(0,0,1);const r=i[0],n=this.edges[r],o=this.edgeProps[r].vec,s=D(o[0],o[1],(this.vertices[n.b].height-this.vertices[n.a].height)*t),a=D(s[1],-s[0],0);q(a,a,s);const l=M(a);return l>0?B(a,a,1/l):P(a,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(0===this.edges.length)return;let t=0,i=Number.POSITIVE_INFINITY,r=0;const[n,o,s,a,l,c,u]=this._tmpVec2;xe(u,e.x,e.y);const h=new Ray2D(u,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,_=h.intersectsPlane(f,this.vertexProps[d.a].dir,n),g=h.intersectsPlane(m,this.vertexProps[d.b].dir,o);if(!_||!g)continue;be(s,o,n),be(a,u,n);const y=Se(s,s),x=y>0?Se(a,s)/y:0,v=He(x,0,1),b=Math.abs((x-v)*this.edgeProps[e].len);be(l,u,f),xe(c,p[1],-p[0]);const w=b+Math.abs(Se(l,c));w<i&&(t=e,i=w,r=v)}return[t,r]}tessellate(e){const t=I(),i=I(),r=I(),n=I();for(let o=this.edges.length-1;o>=0;--o){const s=this.edges[o].a,a=this.edges[o].b,{position:l,height:c,extent:u}=this.vertices[s],{position:h,height:d,extent:p}=this.vertices[a],f=this.vertexProps[s].dir,m=this.vertexProps[a].dir;if(P(t,l[0]/e,l[1]/e,c),P(i,h[0]/e,h[1]/e,d),P(r,f[1],-f[0],0),B(r,r,u),P(n,m[1],-m[0],0),B(n,n,p),this.distSqLines(D(t[0]+.5*r[0],t[1]+.5*r[1],t[2]+.5*r[2]),D(i[0]-.5*n[0],i[1]-.5*n[1],i[2]-.5*n[2]),D(t[0]-.5*r[0],t[1]-.5*r[1],t[2]-.5*r[2]),D(i[0]+.5*n[0],i[1]+.5*n[1],i[2]+.5*n[2]))<=.0025000000000000005)continue;const _=this.vertices.length,g=ve(ge(),l,h);this.vertices.push({position:we(g,g,.5),height:.5*(c+d),extent:.5*(u+p)});const y=ve(ge(),f,m);this.vertexProps.push({dir:Ee(y,y)}),this.edges.splice(o,1),this.edgeProps.splice(o,1),this.edges.push({a:s,b:_}),this.edges.push({a:_,b:a});const x=be(ge(),this.vertices[_].position,l),v=Te(x),b={vec:x,dir:we(ge(),x,1/v),len:v};this.edgeProps.push(b),this.edgeProps.push(b)}}distSqLines(e,t,i,r){const n=R(I(),t,e),o=R(I(),r,i),s=R(I(),e,i),a=H(n,n),l=H(n,o),c=H(n,s),u=H(o,o),h=H(o,s),d=a*u-l*l;if(0===d)return V($(n,i,r,H(s,o)/H(o,o)),e);const p=(a*h-l*c)/d;return V($(n,e,t,(l*h-c*u)/d),$(o,i,r,p))}}class ElevationFeatures{static parseFrom(e,t){const i=ElevationFeatureParser.parse(e);if(!i)return[];let{vertices:r,features:n}=i;const o=1/cl(t);n.sort(((e,t)=>e.id-t.id)),r.sort(((e,t)=>e.id-t.id||e.idx-t.idx)),r=r.filter(((e,t,i)=>t===i.findIndex((t=>t.id===e.id&&t.idx===e.idx))));const s=new Array;let a=0;const l=r.length;for(const e of n){if(e.constantHeight){s.push(new ElevationFeature(e.id,e.bounds,e.constantHeight));continue}for(;a!==l&&r[a].id<e.id;)a++;if(a===l||r[a].id!==e.id)continue;const t=new Array,i=new Array,n=a;for(;a!==l&&r[a].id===e.id;){const e=r[a];if(t.push({position:e.position,height:e.height,extent:e.extent}),a!==n&&r[a-1].idx===e.idx-1){const e=a-n;i.push({a:e-1,b:e})}a++}s.push(new ElevationFeature(e.id,e.bounds,void 0,t,i,o))}return s}static getElevationFeature(e,t){if(!t)return;const i=+e.properties[Tl];return Number.isNaN(i)?void 0:t.find((e=>e.id===i))}}class ElevationFeatureSampler{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)*Mn,this.yOffset=(e.y*this.zScale-t.y)*Mn)}constantElevation(e,t){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,i){const r=this.constantElevation(t,i);return null!=r?r:(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),i))}computeBiasedHeight(e,t){return t<=0?e:e+t*qe(0,t,e>=0?e:Math.abs(.5*e))}}bs(ElevationFeature,"ElevationFeature");class CircleBucket{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 StructArrayLayout2i4,this.indexArray=new StructArrayLayout3ui6,this.segments=new SegmentVector,this.programConfigurations=new ProgramConfigurationSet(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 StructArrayLayout1f4),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,r){}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:n,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=yl(n,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=s?s.evaluate(u,{},i):void 0,d={id:a,properties:n.properties,type:n.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:gl(n,i,r),patterns:{},sortKey:h};o.push(d)}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new StructArrayLayout6i12,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,a,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,n,o,s,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,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,ya.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,va.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,xa.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,i,r,n,o,s,a){let l;"none"!==this.elevationMode&&(l=ElevationFeatures.getElevationFeature(e,a));for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=Mn||r<0||r>=Mn)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r);this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;if(this.addCircleVertex(i,r,-1,-1),this.addCircleVertex(i,r,1,-1),this.addCircleVertex(i,r,1,1),this.addCircleVertex(i,r,-1,1),"none"!==this.elevationMode){const e=l?l.pointElevation(new Le(i,r)):0;this.hasElevation=this.hasElevation||0!==e;for(let t=0;t<4;t++)this.elevatedLayoutVertexArray.emplaceBack(e)}this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n,s,void 0,this.worldview)}addCircleVertex(e,t,i,r){this.layoutVertexArray.emplaceBack(2*e+(i+1)/2,2*t+(r+1)/2)}addGlobeExtVertex(e,t){const i=16384;this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*i,t[1]*i,t[2]*i)}}function Pl(e,t){for(let i=0;i<e.length;i++)if(jl(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(jl(e,t[i]))return!0;return!!Fl(e,t)}function Ll(e,t,i){return!!jl(e,t)||!!Ul(t,e,i)}function Rl(e,t){if(1===e.length)return Nl(t,e[0]);for(let i=0;i<t.length;i++){const r=t[i];for(let t=0;t<r.length;t++)if(jl(e,r[t]))return!0}for(let i=0;i<e.length;i++)if(Nl(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Fl(e,t[i]))return!0;return!1}function zl(e,t,i){if(e.length>1){if(Fl(e,t))return!0;for(let r=0;r<t.length;r++)if(Ul(t[r],e,i))return!0}for(let r=0;r<e.length;r++)if(Ul(e[r],t,i))return!0;return!1}function Fl(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)if(Ol(r,n,t[e],t[e+1]))return!0}return!1}function Ol(e,t,i,r){return at(e,i,r)!==at(t,i,r)&&at(e,t,i)!==at(e,t,r)}function Bl(e,t,i){return(e.x-i.x)*(t.y-i.y)-(e.y-i.y)*(t.x-i.x)}function kl(e,t,i,r){const n=Bl(e,t,r),o=Bl(e,t,i);if(Math.sign(n)===Math.sign(o))return;const s=Bl(i,r,e),a=s+o-n;return Math.sign(s)!==Math.sign(a)?[s/(s-a),o/(o-n)]:void 0}function Ul(e,t,i){const r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let i=1;i<t.length;i++)if(Vl(e,t[i-1],t[i])<r)return!0;return!1}function Vl(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return e.distSqr(n<0?t:n>1?i:i.sub(t)._mult(n)._add(t))}function Nl(e,t){let i,r,n,o=!1;for(let s=0;s<e.length;s++){i=e[s];for(let e=0,s=i.length-1;e<i.length;s=e++)r=i[e],n=i[s],r.y>t.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function jl(e,t){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const o=e[r],s=e[n];o.y>t.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function Gl(e,t,i,r,n){for(const o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const o=[new Le(t,i),new Le(t,n),new Le(r,n),new Le(r,i)];if(e.length>2)for(const t of o)if(jl(e,t))return!0;for(let t=0;t<e.length-1;t++)if(Hl(e[t],e[t+1],o))return!0;return!1}function Hl(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return!1;const o=at(e,t,i[0]);return o!==at(e,t,i[1])||o!==at(e,t,i[2])||o!==at(e,t,i[3])}function ql(e,t,i,r,n,o){let s=t.y-e.y,a=e.x-t.x;if(o=o||0){const e=s*s+a*a;if(0===e)return!0;const t=Math.sqrt(e);s/=t,a/=t}return!((i.x-e.x)*s+(i.y-e.y)*a-o<0||(r.x-e.x)*s+(r.y-e.y)*a-o<0||(n.x-e.x)*s+(n.y-e.y)*a-o<0)}function $l(e,t,i,r,n,o,s){return!(ql(e,t,r,n,o,s)||ql(t,i,r,n,o,s)||ql(i,e,r,n,o,s)||ql(r,n,e,t,i,s)||ql(n,o,e,t,i,s)||ql(o,r,e,t,i,s))}function Zl(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Wl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Xl(e,t,i,r,n){if(!t[0]&&!t[1])return e;const o=Le.convert(t)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let t=0;t<e.length;t++)s.push(e[t].sub(o));return s}function Yl(e,t,i,r){const n=Le.convert(e)._mult(r);return"viewport"===t&&n._rotate(-i),n}let Kl,Jl;function Ql(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}bs(CircleBucket,"CircleBucket",{omit:["layers"]});class CanonicalTileID{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=ec(0,e,e,t,i)}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 i=function(e,t,i){var r=Ql(256*e,256*(t=Math.pow(2,i)-t-1),i),n=Ql(256*(e+1),256*(t+1),i);return r[0]+","+r[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),r=function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<<o-1,n+=(t&r?1:0)+(i&r?2:0);return n}(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}",r).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class UnwrappedTileID{constructor(e,t){this.wrap=e,this.canonical=t,this.key=ec(e,t.z,t.z,t.x,t.y)}}class OverscaledTileID{constructor(e,t,i,r,n){this.overscaledZ=e,this.wrap=t,this.canonical=new CanonicalTileID(i,+r,+n),this.key=0===t&&e===i?this.canonical.key:ec(t,e,i,r,n)}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 OverscaledTileID(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new OverscaledTileID(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 ec(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return ec(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}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 OverscaledTileID(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new OverscaledTileID(t,this.wrap,t,i,r),new OverscaledTileID(t,this.wrap,t,i+1,r),new OverscaledTileID(t,this.wrap,t,i,r+1),new OverscaledTileID(t,this.wrap,t,i+1,r+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 OverscaledTileID(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new OverscaledTileID(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 UnwrappedTileID(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function ec(e,t,i,r,n){const o=1<<Math.min(i,22);let s=o*(n%o)+r%o;return e&&i<22&&(s+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))),16*(32*s+i)+(t-i)}const tc=[e=>{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,i--),new OverscaledTileID(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,i=e.wrap;return t===1<<e.canonical.z&&(t=0,i++),new OverscaledTileID(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>new OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)];bs(CanonicalTileID,"CanonicalTileID"),bs(OverscaledTileID,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const ic=_a([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:rc}=ic,nc=_a([{name:"a_pos_3",components:3,type:"Int16"}]);var oc=_a([{name:"a_pos",type:"Int16",components:2}]);function sc(e){return e*ka/Wa}const ac=[new Aabb([Ha,Ha,Ha],[qa,qa,qa]),new Aabb([Ha,Ha,Ha],[0,0,qa]),new Aabb([0,Ha,Ha],[qa,0,qa]),new Aabb([Ha,0,Ha],[0,qa,qa]),new Aabb([0,0,Ha],[qa,qa,qa])];function lc(e,t,i,r=!0){const n=B([],e._camera.position,e.worldSize),o=[t,i,1,1];se(o,o,e.pixelMatrixInverse),ne(o,o,1/o[3]);const s=G([],J([],o,n)),a=e.globeMatrix,l=[a[12],a[13],a[14]],c=J([],l,n),u=M(c),h=G([],c),d=e.worldSize/(2*Math.PI),p=H(h,s),f=Math.asin(d/u);if(f<Math.acos(p)){if(!r)return null;const e=[],t=[];B(e,s,u/p),G(t,J(t,e,c)),G(s,L(s,c,B(s,t,Math.tan(f)*u)))}const m=[];new Ray(n,s).closestPointOnSphere(l,d,m);const _=G([],gt(a,0)),g=G([],gt(a,1)),y=G([],gt(a,2)),x=H(_,m),v=H(g,m),b=H(y,m),w=Be(Math.asin(-v/d));let T=Be(Math.atan2(x,b));T=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,T);const E=Qa(T),S=He(el(w),0,1);return new MercatorCoordinate(E,S)}class Arc{constructor(e,t,i){this.a=J([],e,i),this.b=J([],t,i),this.center=i;const r=G([],this.a),n=G([],this.b);this.angle=Math.acos(H(r,n))}}function cc(e,t){if(0===e.angle)return null;let i;return i=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)),i<0||i>1?null:function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)}(e.a[t],e.b[t],e.angle,He(i,0,1))+e.center[t]}function uc(e){if(e.z<=1)return ac[e.z+2*e.y+e.x];const t=_c(mc(e));return Aabb.fromPoints(t)}function hc(e,t,i){return B(e,e,1-i),k(e,e,t,i)}function dc(e,t){const i=Ac(t.zoom);if(0===i)return uc(e);const r=mc(e),n=_c(r),o=Qa(r.getWest())*t.worldSize,s=Qa(r.getEast())*t.worldSize,a=el(r.getNorth())*t.worldSize,l=el(r.getSouth())*t.worldSize,c=[o,a,0],u=[s,a,0],h=[o,l,0],p=[s,l,0],f=d([],t.globeMatrix);return Z(c,c,f),Z(u,u,f),Z(h,h,f),Z(p,p,f),n[0]=hc(n[0],h,i),n[1]=hc(n[1],p,i),n[2]=hc(n[2],u,i),n[3]=hc(n[3],c,i),Aabb.fromPoints(n)}function pc(e,t,i){for(const r of e)Z(r,r,t),B(r,r,i)}function fc(e,t,i,r){const n=t/e.worldSize,o=e.globeMatrix;if(i.z<=1){const e=uc(i).getCorners();return pc(e,o,n),Aabb.fromPoints(e)}const s=mc(i,r),a=_c(s,ka+sc(e._tileCoverLift));pc(a,o,n);const l=Number.MAX_VALUE,c=[-l,-l,-l],u=[l,l,l];if(s.contains(e.center)){for(const e of a)F(u,u,e),O(c,c,e);c[2]=0;const t=e.point,i=[t.x*n,t.y*n,0];return F(u,u,i),O(c,c,i),new Aabb(u,c)}if(e._tileCoverLift>0){for(const e of a)F(u,u,e),O(c,c,e);return new Aabb(u,c)}const h=[o[12]*n,o[13]*n,o[14]*n],d=s.getCenter(),p=He(e.center.lat,-ol,ol),f=He(d.lat,-ol,ol),m=Qa(e.center.lng),_=el(p);let g=m-Qa(d.lng);const y=_-el(f);g>.5?g-=1:g<-.5&&(g+=1);let x=0;Math.abs(g)>Math.abs(y)?x=g>=0?1:3:(x=y>=0?0:2,k(h,h,[o[4]*n,o[5]*n,o[6]*n],-Math.sin(Oe(y>=0?s.getSouth():s.getNorth()))*ka));const v=a[x],b=a[(x+1)%4],w=new Arc(v,b,h),T=[cc(w,0)||v[0],cc(w,1)||v[1],cc(w,2)||v[2]],E=Ac(e.zoom);if(E>0){const r=function({x:e,y:t,z:i},r,n,o,s){const a=1/(1<<i);let l=e*a,c=l+a,u=t*a,h=u+a,d=0;const p=(l+c)/2-o;return p>.5?d=-1:p<-.5&&(d=1),l=((l+d)*r-(o*=r))*n+o,c=((c+d)*r-o)*n+o,u=(u*r-(s*=r))*n+s,h=(h*r-s)*n+s,[[l,h,0],[c,h,0],[c,u,0],[l,u,0]]}(i,t,e._pixelsPerMercatorPixel,m,_);for(let e=0;e<a.length;e++)hc(a[e],r[e],E);const n=L([],r[x],r[(x+1)%4]);B(n,n,.5),hc(T,n,E)}for(const e of a)F(u,u,e),O(c,c,e);return u[2]=Math.min(v[2],b[2]),F(u,u,T),O(c,c,T),new Aabb(u,c)}function mc({x:e,y:t,z:i},r=!1){const n=1/(1<<i),o=new LngLat(il(e*n),t===(1<<i)-1&&r?-90:rl((t+1)*n)),s=new LngLat(il((e+1)*n),0===t&&r?90:rl(t*n));return new LngLatBounds(o,s)}function _c(e,t=ka){const i=Oe(e.getNorth()),r=Oe(e.getSouth()),n=Math.cos(i),o=Math.cos(r),s=Math.sin(i),a=Math.sin(r),l=e.getWest(),c=e.getEast();return[$a(o,a,l,t),$a(o,a,c,t),$a(n,s,c,t),$a(n,s,l,t)]}function gc(e,t,i,r){const n=1<<i.z,o=(e/Mn+i.x)/n;return Za(rl((t/Mn+i.y)/n),il(o),r)}function yc({min:e,max:t}){return Na/Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])}const xc=new Float64Array(16);function vc(e){const t=yc(e),i=x(xc,[t,t,t]);return f(i,i,j([],e.min))}function bc(e){const t=(r=e.min,(i=xc)[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i);var i,r;const n=1/yc(e);return m(t,t,[n,n,n])}function wc(e){const t=Mn/(2*Math.PI);return e/(2*Math.PI)/t}function Tc(e,t){return Mn/(512*Math.pow(2,e))*yc(uc(t))}function Ec(e,t,i,r,n){const o=wc(i),s=[e,t,-i/(2*Math.PI)],a=u(new Float64Array(16));return f(a,a,s),m(a,a,[o,o,o]),_(a,a,Oe(-n)),g(a,a,Oe(-r)),a}function Sc(e){const t=e.pixelsPerMeter,i=t/tl(1,e.center.lat),r=u(new Float64Array(16));return f(r,r,[e.point.x,e.point.y,0]),m(r,r,[i,i,t]),Float32Array.from(r)}function Ac(e){return qe(Ua,Va,e)}function Ic(e,t,i){const r=u(new Float64Array(16)),n=(t/(1<<e)-.5)*Math.PI*2;return g(r,i.globeMatrix,n),Float32Array.from(r)}function Cc(e,t,i){const r=Ac(i.zoom),n=e.style.map._antialias,o=e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!o}function Mc(e,t,i,r){const n=t.getNorth(),o=t.getSouth(),a=t.getWest(),l=t.getEast(),c=1<<e.z,u=l-a,h=n-o,d=u/ja,p=-h/Ga[i],f=[0,d,0,p,0,0,n,a,0];if(e.z>0){const e=180/r;s(f,f,[e/u+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f}function Dc(e){const t=ol-5;e=He(e,-t,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Oe(e))),3);return Math.round(i*(Ga.length-1))}function Pc(e){const t=[0,0,0],i=u(new Float64Array(16));return p(i,e.pixelMatrix,e.globeMatrix),Z(t,t,i),new Le(t[0],t[1])}function Lc(e,t){const i=Za(t.lat,t.lng),r=function(e){const t=Za(e._center.lat,e._center.lng);let i=q([],D(0,1,0),t);const r=v([],-e.angle,t);i=Z(i,i,r),v(r,-e._pitch,i);const n=G([],t);return B(n,n,sc(e.cameraToCenterDistance/e.pixelsPerMeter)),Z(n,n,r),L([],t,n)}(e);return s=(n=R([],r,i))[0],a=n[1],l=n[2],c=(o=i)[0],u=o[1],h=o[2],p=(d=Math.sqrt((s*s+a*a+l*l)*(c*c+u*u+h*h)))&&H(n,o)/d,Math.acos(Math.min(Math.max(p,-1),1));var n,o,s,a,l,c,u,h,d,p}function Rc(e,t){return Lc(e,t)>Math.PI/2*1.01}const zc=Oe(85),Fc=Math.cos(zc),Oc=Math.sin(zc);class GlobeSharedBuffers{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 i=new StructArrayLayout2i4,r=new StructArrayLayout3ui6,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=i?24575:0,[r,t]};for(let e=0;e<o;++e)i.emplaceBack(...l(e,0,!0));for(let e=0;e<s;++e)for(let t=0;t<o;++t)i.emplaceBack(...l(t,e,(0===t||t===o-1)&&!0));for(let e=0;e<t.length;++e){const r=t[e];for(let e=0;e<o;++e)i.emplaceBack(...l(e,r,!0))}for(let e=0;e<t.length;++e){const s=r.length,l=t[e]+1+2,c=new StructArrayLayout3ui6;for(let i=0;i<l-1;i++){const n=i===l-2,s=n?o*(a-t.length+e-i):o;for(let e=0;e<o-1;e++){const t=i*o+e;0===i||n||0===e||e===o-2?(c.emplaceBack(t+1,t,t+s),c.emplaceBack(t+s,t+s+1,t+1)):(r.emplaceBack(t+1,t,t+s),r.emplaceBack(t+s,t+s+1,t+1))}}const u=SegmentVector.simpleSegment(0,s,i.length,r.length-s);for(let e=0;e<c.uint16.length;e+=3)r.emplaceBack(c.uint16[e],c.uint16[e+1],c.uint16[e+2]);const h=SegmentVector.simpleSegment(0,s,i.length,r.length-s);n.push({withoutSkirts:u,withSkirts:h})}return{vertices:i,indices:r,segments:n}}_createGrid(e){const t=this._fillGridMeshWithLods(ja,Ga);this._gridSegments=t.segments,this._gridBuffer=e.createVertexBuffer(t.vertices,oc.members),this._gridIndexBuffer=e.createIndexBuffer(t.indices,!0)}_createPoles(e){const t=new StructArrayLayout3ui6;for(let e=0;e<=ja;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const i=new StructArrayLayout5f20,r=new StructArrayLayout5f20,n=new StructArrayLayout5f20,o=new StructArrayLayout5f20;this._poleSegments=[];for(let e=0,t=0;e<Ua;e++){const s=360/(1<<e);i.emplaceBack(0,-ka,0,.5,0),r.emplaceBack(0,-ka,0,.5,1),n.emplaceBack(0,-ka,0,.5,.5),o.emplaceBack(0,-ka,0,.5,.5);for(let e=0;e<=ja;e++){let t=e/ja,a=0;const l=xr(0,s,t),[c,u,h]=$a(Fc,Oc,l,ka);i.emplaceBack(c,u,h,t,a),r.emplaceBack(c,u,h,t,1-a);const d=Oe(l);t=.5+.5*Math.sin(d),a=.5+.5*Math.cos(d),n.emplaceBack(c,u,h,t,a),o.emplaceBack(c,u,h,t,1-a)}this._poleSegments.push(SegmentVector.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(i,rc,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(r,rc,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(n,rc,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(o,rc,!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]]}}const Bc=l(),kc=(e,t,i,r,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Tc(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Wt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Bc,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=Ac(s.zoom);const e=n[0]*Mn,i=n[1]*Mn;c.u_up_dir=s.projection.upVector(new CanonicalTileID(0,0,0),e,i)}return c},Uc=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 Vc(e,t,i,r,n,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(a),d=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(h.x,h.y,!0):0,p=i.projection.projectTilePoint(h.x,h.y,c);if(d>0){const e=i.projection.upVector(c,h.x,h.y);p.x+=e[0]*u*d,p.y+=e[1]*u*d,p.z+=e[2]*u*d}const f=o?h:Nc(p.x,p.y,p.z,r),m=o?e.tilespaceRays.map((e=>Hc(e,d))):e.queryGeometry.screenGeometry,_=se([],[p.x,p.y,p.z,1],r);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const e=rl((t.y/Mn+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(e,1)/tl(1,e)}if(Ll(m,f,l))return!0}return!1}function Nc(e,t,i,r){const n=se([],[e,t,i,1],r);return new Le(n[0]/n[3],n[1]/n[3])}const jc=D(0,0,0),Gc=D(0,0,1);function Hc(e,t){const i=I();return jc[2]=t,e.intersectsPlane(jc,Gc,i),new Le(i[0],i[1])}class HeatmapBucket extends CircleBucket{}let qc,$c,Zc,Wc;function Xc(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function Yc(e,t,i){const{width:r,height:n}=t;r===e.width&&n===e.height||(Kc(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,n)},i,null),e.width=r,e.height=n,e.data=t.data)}function Kc(e,t,i,r,n,o,s,a){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,c=t.data,u=4===o&&a;for(let a=0;a<n.height;a++){const h=((i.y+a)*e.width+i.x)*o,d=((r.y+a)*t.width+r.x)*o;if(u)for(let e=0;e<n.width;e++){const t=h+e*o+3,i=d+e*o;c[i+0]=255,c[i+1]=255,c[i+2]=255,c[i+3]=l[t]}else if(s)for(let e=0;e<n.width;e++){const t=h+e*o,i=d+e*o,r=new Color(l[t+0]/255,l[t+1]/255,l[t+2]/255,l[t+3]).toNonPremultipliedRenderColor(s).toArray();c[i+0]=r[0],c[i+1]=r[1],c[i+2]=r[2],c[i+3]=r[3]}else for(let e=0;e<n.width*o;e++)c[d+e]=l[h+e]}return t}bs(HeatmapBucket,"HeatmapBucket",{omit:["layers"]});class AlphaImage{constructor(e,t){Xc(this,e,1,t)}resize(e){Yc(this,new AlphaImage(e),1)}clone(){return new AlphaImage({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){Kc(e,t,i,r,n,1,null)}}class RGBAImage{constructor(e,t){Xc(this,e,4,t)}resize(e){Yc(this,new RGBAImage(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new RGBAImage({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n,o,s){Kc(e,t,i,r,n,4,o,s)}}class Float32Image{constructor(e,t){this.width=e.width,this.height=e.height,this.data=t instanceof Uint8Array?new Float32Array(t.buffer):t}}function Jc(e){const t={},i=e.resolution||256,r=e.clips?e.clips.length:1,n=e.image||new RGBAImage({width:i,height:r}),o=(i,r,o)=>{t[e.evaluationKey]=o;const s=e.expression.evaluate(t),a=s?s.toNonPremultipliedRenderColor(null):null;a&&(n.data[i+r+0]=Math.floor(255*a.r),n.data[i+r+1]=Math.floor(255*a.g),n.data[i+r+2]=Math.floor(255*a.b),n.data[i+r+3]=Math.floor(255*a.a))};if(e.clips)for(let t=0,n=0;t<r;++t,n+=4*i)for(let r=0,s=0;r<i;r++,s+=4){const a=r/(i-1),{start:l,end:c}=e.clips[t];o(n,s,l*(1-a)+c*a)}else for(let e=0,t=0;e<i;e++,t+=4)o(0,t,e/(i-1));return n}bs(AlphaImage,"AlphaImage"),bs(RGBAImage,"RGBAImage");const Qc=_a([{name:"a_pos",components:2,type:"Int16"}],4),eu=_a([{name:"a_road_z_offset",components:1,type:"Float32"}],4),tu=_a([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),iu=_a([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);function ru(e,t,i=2){const r=t&&t.length,n=r?t[0]*i:e.length;let o=nu(e,0,n,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c;if(r&&(o=function(e,t,i,r){const n=[];for(let i=0,o=t.length;i<o;i++){const s=nu(e,t[i]*r,i<o-1?t[i+1]*r:e.length,r,!1);s===s.next&&(s.steiner=!0),n.push(mu(s))}n.sort(hu);for(let e=0;e<n.length;e++)i=du(n[e],i);return i}(e,t,o,i)),e.length>80*i){a=e[0],l=e[1];let t=a,r=l;for(let o=i;o<n;o+=i){const i=e[o],n=e[o+1];i<a&&(a=i),n<l&&(l=n),i>t&&(t=i),n>r&&(r=n)}c=Math.max(t-a,r-l),c=0!==c?32767/c:0}return su(o,s,i,a,l,c,0),s}function nu(e,t,i,r,n){let o;if(n===function(e,t,i,r){let n=0;for(let o=t,s=i-r;o<i;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}(e,t,i,r)>0)for(let n=t;n<i;n+=r)o=Au(n/r|0,e[n],e[n+1],o);else for(let n=i-r;n>=t;n-=r)o=Au(n/r|0,e[n],e[n+1],o);return o&&vu(o,o.next)&&(Iu(o),o=o.next),o}function ou(e,t){if(!e)return e;t||(t=e);let i,r=e;do{if(i=!1,r.steiner||!vu(r,r.next)&&0!==xu(r.prev,r,r.next))r=r.next;else{if(Iu(r),r=t=r.prev,r===r.next)break;i=!0}}while(i||r!==t);return t}function su(e,t,i,r,n,o,s){if(!e)return;!s&&o&&function(e,t,i,r){let n=e;do{0===n.z&&(n.z=fu(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){let t,i=1;do{let r,n=e;e=null;let o=null;for(t=0;n;){t++;let s=n,a=0;for(let e=0;e<i&&(a++,s=s.nextZ,s);e++);let l=i;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||n.z<=s.z)?(r=n,n=n.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=s}o.nextZ=null,i*=2}while(t>1)}(n)}(e,r,n,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?lu(e,r,n,o):au(e))t.push(l.i,e.i,c.i),Iu(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?su(e=cu(ou(e),t),t,i,r,n,o,2):2===s&&uu(e,t,i,r,n,o):su(ou(e),t,i,r,n,o,1);break}}}function au(e){const t=e.prev,i=e,r=e.next;if(xu(t,i,r)>=0)return!1;const n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,u=Math.min(n,o,s),h=Math.min(a,l,c),d=Math.max(n,o,s),p=Math.max(a,l,c);let f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&gu(n,a,o,l,s,c,f.x,f.y)&&xu(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function lu(e,t,i,r){const n=e.prev,o=e,s=e.next;if(xu(n,o,s)>=0)return!1;const a=n.x,l=o.x,c=s.x,u=n.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),_=Math.max(u,h,d),g=fu(p,f,t,i,r),y=fu(m,_,t,i,r);let x=e.prevZ,v=e.nextZ;for(;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&gu(a,u,l,h,c,d,x.x,x.y)&&xu(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&gu(a,u,l,h,c,d,v.x,v.y)&&xu(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&gu(a,u,l,h,c,d,x.x,x.y)&&xu(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&gu(a,u,l,h,c,d,v.x,v.y)&&xu(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function cu(e,t){let i=e;do{const r=i.prev,n=i.next.next;!vu(r,n)&&bu(r,i,i.next,n)&&Eu(r,n)&&Eu(n,r)&&(t.push(r.i,i.i,n.i),Iu(i),Iu(i.next),i=e=n),i=i.next}while(i!==e);return ou(i)}function uu(e,t,i,r,n,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&yu(s,e)){let a=Su(s,e);return s=ou(s,s.next),a=ou(a,a.next),su(s,t,i,r,n,o,0),void su(a,t,i,r,n,o,0)}e=e.next}s=s.next}while(s!==e)}function hu(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function du(e,t){const i=function(e,t){let i=t;const r=e.x,n=e.y;let o,s=-1/0;if(vu(e,i))return i;do{if(vu(e,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const e=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,o=i.x<i.next.x?i:i.next,e===r))return o}i=i.next}while(i!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let u=1/0;i=o;do{if(r>=i.x&&i.x>=l&&r!==i.x&&_u(n<c?r:s,n,l,c,n<c?s:r,n,i.x,i.y)){const t=Math.abs(n-i.y)/(r-i.x);Eu(i,e)&&(t<u||t===u&&(i.x>o.x||i.x===o.x&&pu(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const r=Su(i,e);return ou(r,r.next),ou(i,i.next)}function pu(e,t){return xu(e.prev,e,t.prev)<0&&xu(t.next,e,e.next)<0}function fu(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function mu(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function _u(e,t,i,r,n,o,s,a){return(n-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function gu(e,t,i,r,n,o,s,a){return!(e===s&&t===a)&&_u(e,t,i,r,n,o,s,a)}function yu(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&bu(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Eu(e,t)&&Eu(t,e)&&function(e,t){let i=e,r=!1;const n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(xu(e.prev,e,t.prev)||xu(e,t.prev,t))||vu(e,t)&&xu(e.prev,e,e.next)>0&&xu(t.prev,t,t.next)>0)}function xu(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function vu(e,t){return e.x===t.x&&e.y===t.y}function bu(e,t,i,r){const n=Tu(xu(e,t,i)),o=Tu(xu(e,t,r)),s=Tu(xu(i,r,e)),a=Tu(xu(i,r,t));return n!==o&&s!==a||!(0!==n||!wu(e,i,t))||!(0!==o||!wu(e,r,t))||!(0!==s||!wu(i,e,r))||!(0!==a||!wu(i,t,r))}function wu(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Tu(e){return e>0?1:e<0?-1:0}function Eu(e,t){return xu(e.prev,e,e.next)<0?xu(e,t,e.next)>=0&&xu(e,e.prev,t)>=0:xu(e,t,e.prev)<0||xu(e,e.next,t)<0}function Su(e,t){const i=Cu(e.i,e.x,e.y),r=Cu(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Au(e,t,i,r){const n=Cu(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Iu(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 Cu(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Mu(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t<i;t++){const i=lt(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[e[t]]):n.push(e[t]))}if(n&&r.push(n),t>1)for(let e=0;e<r.length;e++)r[e].length<=t||(Jr(r[e],t,1,r[e].length-1,Du),r[e]=r[e].slice(0,t));return r}function Du(e,t){return t.area-e.area}function Pu(e,t,i=1){if(!e)return null;const r="string"==typeof e?ResolvedImage.from(e).getPrimary():e.getPrimary(),n="string"==typeof e?null:e.getSecondary();for(const e of[r,n]){if(!e)continue;const r=e.id.toString();t.has(r)||t.set(r,[]),e.scaleSelf(i),t.get(r).push(e)}return{primary:r.toString(),secondary:n?n.toString():null}}function Lu(e,t,i,r){const n=r.patternDependencies;let o=!1;for(const r of t){const t=r.paint.get(`${e}-pattern`);t.isConstant()||(o=!0),Pu(t.constantOr(null),n,i)&&(o=!0)}return o}function Ru(e,t,i,r,n,o){const s=o.patternDependencies;for(const a of t){const t=a.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:r},i,{},o.availableImages);e=e&&e.name?e.name:e;const l=Pu(e,s,n);if(!l)continue;const{primary:c,secondary:u}=l;c&&(i.patterns[a.id]=[c,u].filter(Boolean))}}return i}class ElevationPolygons{constructor(){this.polygons=new Map}add(e,...t){const i=this.polygons.get(e);i?i.push(...t):this.polygons.set(e,t)}merge(e){for(const[t,i]of e.polygons)this.add(t,...i)}}class ElevationPortalGraph{constructor(){this.portals=[]}static isOnBorder(e,t){return e<=0&&t<=0||e>=Mn&&t>=Mn}static evaluate(e){if(0===e.length)return new ElevationPortalGraph;let t=[];for(const i of e)t.push(...i.portals);if(0===t.length)return new ElevationPortalGraph;for(const e of t){const t=e.va,i=e.vb;(ElevationPortalGraph.isOnBorder(t.x,i.x)||ElevationPortalGraph.isOnBorder(t.y,i.y))&&(e.type="border")}const i=t.filter((e=>"unevaluated"!==e.type)),r=t.filter((e=>"unevaluated"===e.type));if(0===r.length)return new ElevationPortalGraph;r.sort(((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hash<t.hash?1:-1)),t=i.concat(r);let n=i.length,o=n,s=n;do{if(o++,o===t.length||t[n].hash!==t[o].hash){if(o-n==2){s<n&&(t[s]=t[n],t[n]=null);const e=t[s],i=t[o-1];e.type=e.isTunnel!==i.isTunnel?"tunnel":"polygon",e.connection={a:e.connection.a,b:i.connection.a},s++}n=o}}while(n!==t.length);return t.splice(s),t.sort(((e,t)=>e.hash<t.hash?1:-1)),{portals:t}}}bs(ElevationPortalGraph,"ElevationPortalGraph"),bs(ElevationPolygons,"ElevationPolygons");class MeshBuilder{constructor(e,t,i){this.outPositions=e,this.outNormals=t,this.outIndices=i,this.vertexLookup=new Map}addVertex(e,t,i){let r=e[2];null!=i&&(r*=i);const n=`${e[0]},${e[1]},${e[2]},${t[0]},${t[1]},${t[2]}`,o=this.vertexLookup.get(n);if(null!=o)return o;const s=this.outPositions.length;this.vertexLookup.set(n,s);const a=Math.trunc(16384*t[0]),l=Math.trunc(16384*t[1]),c=Math.trunc(16384*t[2]);return this.outPositions.emplaceBack(e[0],e[1],r),this.outNormals.emplaceBack(a,l,c),s}addTriangle(e,t,i){this.outIndices.emplaceBack(e,t,i)}addTriangles(e,t,i){if(0===e.length)return;const r=1===i.length,n=I(),o=I();for(let s=0;s<e.length;s+=3){const a=t[e[s+0]],l=t[e[s+1]],c=t[e[s+2]],u=r?i[0]:i[e[s+1]],h=r?i[0]:i[e[s+2]];P(n,a.x,a.y,r?i[0]:i[e[s+0]]);const d=this.addVertex(n,o);P(n,l.x,l.y,u);const p=this.addVertex(n,o);P(n,c.x,c.y,h);const f=this.addVertex(n,o);this.outIndices.emplaceBack(d,p,f)}}addQuad(e,t,i,r,n,o){const s=this.addVertex(e,n,o),a=this.addVertex(t,n,o),l=this.addVertex(i,n,o),c=this.addVertex(r,n,o);this.addTriangle(s,a,l),this.addTriangle(l,c,s)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class ElevatedStructures{constructor(e,t,i,r){this.unevaluatedPortals=new ElevationPortalGraph,this.portalPolygons=new ElevationPolygons,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new StructArrayLayout2i1f8,this.vertexNormals=new StructArrayLayout3i8,this.indexArray=new StructArrayLayout3ui6,this.tileToMeters=cl(e),this.bridgeProgramConfigurations=new ProgramConfigurationSet(t,{zoom:i,lut:r},(e=>"fill-tunnel-structure-color"!==e)),this.tunnelProgramConfigurations=new ProgramConfigurationSet(t,{zoom:i,lut:r},(e=>"fill-bridge-guard-rail-color"!==e))}addVertices(e,t){const i=this.unevalVertices.length;for(let i=0;i<e.length;i++)this.unevalVertices.push(e[i]),this.unevalHeights.push(t[i]);return i}addTriangles(e,t,i){const r=i?this.unevalTunnelTriangles:this.unevalTriangles;for(const i of e)r.push(i+t)}addRenderableRing(e,t,i,r,n,o){const s=[new Le(n.min.x,n.min.y),new Le(n.max.x,n.min.y),new Le(n.max.x,n.max.y),new Le(n.min.x,n.max.y)];for(let a=0;a<i-1;a++){const i=t+a,l=i+1,c=this.unevalVertices[i],u=this.unevalVertices[l];if(!(c.x>=n.min.x&&c.x<=n.max.x&&c.y>=n.min.y&&c.y<=n.max.y||u.x>=n.min.x&&u.x<=n.max.x&&u.y>=n.min.y&&u.y<=n.max.y||Hl(c,u,s)))continue;if(this.isOnBorder(c.x,u.x)||this.isOnBorder(c.y,u.y))continue;const h=ElevatedStructures.computeEdgeHash(this.unevalVertices[i],this.unevalVertices[l]);let d,p=this.vertexHashLookup.get(ElevatedStructures.computePosHash(c));null!=p?d=p.next:(p=this.vertexHashLookup.get(ElevatedStructures.computePosHash(u)),d=null!=p?p.prev:h),this.unevalEdges.push({polygonIdx:e,a:i,b:l,hash:h,portalHash:d,isTunnel:r,type:"unevaluated",featureInfo:o})}}addPortalCandidates(e,t,i,r,n){if(0===t.length)return;this.portalPolygons.add(e,{geometry:t,zLevel:n});const o=t[0];this.vertexHashLookup.clear();let s=ElevatedStructures.computeEdgeHash(o[o.length-2],o[o.length-1]);for(let t=0;t<o.length-1;t++){const n=o[t+0],a=o[t+1],l=ye(a.x-n.x,a.y-n.y),c=Te(l);if(0===c)continue;let u="unevaluated";const h=r.pointElevation(n),d=r.pointElevation(a);Math.abs(h)<.01&&Math.abs(d)<.01?u="entrance":(this.isOnBorder(n.x,a.x)||this.isOnBorder(n.y,a.y))&&(u="border");const p=ElevatedStructures.computeEdgeHash(n,a);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:n,vb:a,vab:l,length:c,hash:p,isTunnel:i,type:u});const f=ElevatedStructures.computePosHash(n);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}),i=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset},r=new MeshBuilder(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const n=t(),o=t(),s=t(),a=(e,t)=>{e.sort(((e,i)=>e.type===t&&i.type!==t?-1:e.type!==t&&i.type===t?1:0));const i=e.findIndex((e=>e.type!==t));return i>=0?i:e.length};let l=0;this.unevalEdges.length>0&&(l=a(this.unevalEdges,"none"),this.constructBridgeStructures(r,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),i(s);const c=t(),u=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=a(e,"tunnel")+l;this.unevalEdges.push(...e),this.constructTunnelStructures(r,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:t})}i(c),r.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),i(u),r.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),i(o),r.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),i(n),this.maskSegments=SegmentVector.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.depthSegments=SegmentVector.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableBridgeSegments=SegmentVector.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableTunnelSegments=SegmentVector.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.shadowCasterSegments=SegmentVector.simpleSegment(0,n.primitiveOffset,0,n.primitiveLength)}update(e,t,i,r,n,o,s,a){this.bridgeProgramConfigurations.updatePaintArrays(e,t,n,i,r,o,s,a),this.tunnelProgramConfigurations.updatePaintArrays(e,t,n,i,r,o,s,a)}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,tu.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,iu.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,i,r,n){const o=(o,s)=>{for(let a=0;a<s.length-1;a++){const l=s[a].featureIndex,c=s[a+1].vertexStart,u=e.feature(l);o.populatePaintArrays(c,u,l,{},i,t,r,void 0,n)}};o(this.bridgeProgramConfigurations,this.bridgeFeatureSections),o(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(e,t,i,r,n){const o=new Map;for(let s=r;s<n;s++){const r=i[s],n=r.a,a=r.b,l=ElevatedStructures.computePosHash(e[n]),c=ElevatedStructures.computePosHash(e[a]);let u=o.get(l);u||(u={},o.set(l,u));let h=o.get(c);h||(h={},o.set(c,h)),t[n]<=0&&t[a]<=0||(u.to=a,h.from=n)}return o}isTerminalVertex(e,t){const i=ElevatedStructures.computePosHash(this.unevalVertices[e]),r=t.get(i);return!r||!r.from||!r.to}constructBridgeStructures(e,t,i,r,n,o){e.clearVertexLookup();const s=this.computeVertexConnections(t,i,r,n.min,n.max),a=1/o,l=.5*a,c=(e,r)=>P(e,t[r].x,t[r].y,i[r]*a),u=I(),h=I(),d=I(),p=I(),f=I(),m=(e,i)=>{const r=s.get(ElevatedStructures.computePosHash(t[i])),n=r.from,o=r.to;if(!n||!o)return;c(u,n),c(h,i),c(d,o),Y(p),K(u,h)||(J(f,h,u),G(p,f)),K(d,h)||(J(f,d,h),L(p,p,G(f,f)));const a=te(p);return a>0?B(e,p,1/a):void 0};let _=Number.POSITIVE_INFINITY;this.sortSubarray(r,n.min,n.max,((e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex));const g=I(),y=I(),x=I(),v=I(),b=I(),w=I(),T=I(),E=I(),S=I(),A=[I(),I(),I(),I()],C=[I(),I(),I(),I()],M=[{coord:new Le(0,0),height:0},{coord:new Le(0,0),height:0}],D=(e,t)=>e>t;for(let c=n.min;c<n.max;c++){const n=r[c];if(!n.featureInfo.guardRailEnabled)continue;if(!this.prepareEdgePoints(M,t,i,n,D))continue;const[u,h]=M;if(P(g,u.coord.x,u.coord.y,a*u.height),P(y,h.coord.x,h.coord.y,a*h.height),K(g,y))continue;J(x,y,g),G(x,x);const d=m(E,n.a)||x,p=m(S,n.b)||x;P(v,d[1],-d[0],0),G(v,v),P(b,p[1],-p[0],0),G(b,b),q(E,v,d),G(w,E),q(E,b,p),G(T,E),L(A[0],g,B(E,J(E,v,w),l)),L(A[1],g,B(E,L(E,v,w),l)),L(A[2],g,B(E,w,l)),A[3]=g,L(C[0],y,B(E,J(E,b,T),l)),L(C[1],y,B(E,L(E,b,T),l)),L(C[2],y,B(E,T,l)),C[3]=y,_=this.addFeatureSection(n.featureInfo.featureIndex,_,this.bridgeFeatureSections,e);const f=e.addVertex(A[0],v,o),I=e.addVertex(A[1],v,o),R=e.addVertex(C[0],b,o),z=e.addVertex(C[1],b,o);e.addTriangle(f,I,R),e.addTriangle(I,z,R);const F=e.addVertex(A[1],w,o),O=e.addVertex(A[2],w,o),k=e.addVertex(C[1],T,o),U=e.addVertex(C[2],T,o);e.addTriangle(F,O,k),e.addTriangle(O,U,k),j(v,v),j(b,b);const V=e.addVertex(A[2],v,o),N=e.addVertex(A[3],v,o),H=e.addVertex(C[2],b,o),$=e.addVertex(C[3],b,o);e.addTriangle(V,N,H),e.addTriangle(N,$,H);const Z=this.isTerminalVertex(n.a,s),W=this.isTerminalVertex(n.b,s);u.height<.01&&Z&&e.addQuad(A[3],A[2],A[1],A[0],j(d,d),o),h.height<.01&&W&&e.addQuad(C[0],C[1],C[2],C[3],p,o)}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}constructTunnelStructures(e,t,i,r,n,o){e.clearVertexLookup();let s=Number.POSITIVE_INFINITY;const a=(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(r,n.min,n.max,a),this.sortSubarray(r,o.min,o.max,a);const l=e=>G(e,e),c=[{coord:new Le(0,0),height:0},{coord:new Le(0,0),height:0}],u=(e,t)=>e<t,h=I(),d=I(),p=I(),f=I(),m=I();for(let o=n.min;o<n.max;o++){if(!this.prepareEdgePoints(c,t,i,r[o],u))continue;const[n,a]=c,_=l(P(m,-(a.coord.y-n.coord.y),a.coord.x-n.coord.x,0));s=this.addFeatureSection(r[o].featureInfo.featureIndex,s,this.tunnelFeatureSections,e),e.addQuad(P(h,n.coord.x,n.coord.y,n.height),P(d,a.coord.x,a.coord.y,a.height),P(p,a.coord.x,a.coord.y,r[o].isTunnel?-.1:0),P(f,n.coord.x,n.coord.y,r[o].isTunnel?-.1:0),_)}for(let n=o.min;n<o.max;n++){const o=r[n];o.isTunnel&&([o.a,o.b]=[o.b,o.a]);const a=t[o.a],c=t[o.b],u=l(P(m,-(c.y-a.y),c.x-a.x,0));s=this.addFeatureSection(o.featureInfo.featureIndex,s,this.tunnelFeatureSections,e),e.addQuad(P(h,c.x,c.y,0),P(d,a.x,a.y,0),P(p,a.x,a.y,i[o.a]+4),P(f,c.x,c.y,i[o.b]+4),u),e.addQuad(P(h,a.x,a.y,0),P(d,c.x,c.y,0),P(p,c.x,c.y,i[o.b]+4),P(f,a.x,a.y,i[o.a]+4),u)}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}setElevatedPoint(e,t,i,r){e.coord.x=t,e.coord.y=i,e.height=r}prepareEdgePoints(e,t,i,r,n){let o=t[r.a].x,s=t[r.a].y,a=t[r.b].x,l=t[r.b].y,c=i[r.a],u=i[r.b];const h=n(c,0),d=n(u,0);if(h&&d)return this.setElevatedPoint(e[0],o,s,c),this.setElevatedPoint(e[1],a,l,u),!0;if(!h&&!d)return!1;if(h){if(!d){const e=u/(u-c);a=xr(a,o,e),l=xr(l,s,e),u=xr(u,c,e)}}else{const e=c/(c-u);o=xr(o,a,e),s=xr(s,l,e),c=xr(c,u,e)}return this.setElevatedPoint(e[0],o,s,c),this.setElevatedPoint(e[1],a,l,u),!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 i=0,r=0,n=0,o=t[i].polygonIdx;do{r++,(r===t.length||t[i].hash!==t[r].hash)&&((1==r-i||t[r-1].polygonIdx!==o)&&(n<i&&(t[n]=t[i],t[i]=null),t[n].type="none",n++),i=r,i!==t.length&&(o=t[i].polygonIdx))}while(i!==t.length);if(t.splice(n),0!==t.length&&0!==e.length){t.sort(((e,t)=>e.portalHash<t.portalHash?1:-1));let i=0,r=0;for(;i!==t.length&&r!==e.length;){const n=t[i],o=e[r];n.portalHash>o.hash?i++:o.hash>n.portalHash?r++:(n.type=o.type,i++)}}}isOnBorder(e,t){return e<=0&&t<=0||e>=Mn&&t>=Mn}addFeatureSection(e,t,i,r){return e!==t&&(t=e,i.push({featureIndex:e,vertexStart:r.getVertexCount()}),r.clearVertexLookup()),t}sortSubarray(e,t,i,r){const n=e.slice(t,i);n.sort(r),e.splice(t,n.length,...n)}static computeEdgeHash(e,t){return(e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(ElevatedStructures.computePosHash(e))<<32n|BigInt(ElevatedStructures.computePosHash(t))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}var zu,Fu={exports:{}},Ou=(zu||(zu=1,function(e){function t(e,t){return e>t?1:e<t?-1:0}var i=function(e,i){void 0===e&&(e=t),void 0===i&&(i=!1),this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!i},r={size:{configurable:!0}};function n(e,t,i,r,o){var s=o-r;if(s>0){var a=r+Math.floor(s/2),l={key:t[a],data:i[a],parent:e};return l.left=n(l,t,i,r,a),l.right=n(l,t,i,a+1,o),l}return null}function o(e,t,i,r,n){if(!(i>=r)){for(var s=e[i+r>>1],a=i-1,l=r+1;;){do{a++}while(n(e[a],s)<0);do{l--}while(n(e[l],s)>0);if(a>=l)break;var c=e[a];e[a]=e[l],e[l]=c,c=t[a],t[a]=t[l],t[l]=c}o(e,t,i,l,n),o(e,t,l+1,r,n)}}i.prototype.rotateLeft=function(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},i.prototype.rotateRight=function(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},i.prototype._splay=function(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)}},i.prototype.splay=function(e){for(var t,i,r,n,o;e.parent;)(i=(t=e.parent).parent)&&i.parent?((r=i.parent).left===i?r.left=e:r.right=e,e.parent=r):(e.parent=null,this._root=e),n=e.left,o=e.right,e===t.left?(i&&(i.left===t?(t.right?(i.left=t.right,i.left.parent=i):i.left=null,t.right=i,i.parent=t):(n?(i.right=n,n.parent=i):i.right=null,e.left=i,i.parent=e)),o?(t.left=o,o.parent=t):t.left=null,e.right=t,t.parent=e):(i&&(i.right===t?(t.left?(i.right=t.left,i.right.parent=i):i.right=null,t.left=i,i.parent=t):(o?(i.left=o,o.parent=i):i.left=null,e.right=i,i.parent=e)),n?(t.right=n,n.parent=t):t.right=null,e.left=t,t.parent=e)},i.prototype.replace=function(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.parent=e.parent)},i.prototype.minNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.left;)e=e.left;return e},i.prototype.maxNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.right;)e=e.right;return e},i.prototype.insert=function(e,t){var i=this._root,r=null,n=this._compare;if(this._noDuplicates)for(;i;){if(r=i,0===n(i.key,e))return;i=n(i.key,e)<0?i.right:i.left}else for(;i;)r=i,i=n(i.key,e)<0?i.right:i.left;return i={key:e,data:t,left:null,right:null,parent:r},r?n(r.key,i.key)<0?r.right=i:r.left=i:this._root=i,this.splay(i),this._size++,i},i.prototype.find=function(e){for(var t=this._root,i=this._compare;t;){var r=i(t.key,e);if(r<0)t=t.right;else{if(!(r>0))return t;t=t.left}}return null},i.prototype.contains=function(e){for(var t=this._root,i=this._compare;t;){var r=i(e,t.key);if(0===r)return!0;t=r<0?t.left:t.right}return!1},i.prototype.remove=function(e){var t=this.find(e);if(!t)return!1;if(this.splay(t),t.left)if(t.right){var i=this.minNode(t.right);i.parent!==t&&(this.replace(i,i.right),i.right=t.right,i.right.parent=i),this.replace(t,i),i.left=t.left,i.left.parent=i}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0},i.prototype.removeNode=function(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},i.prototype.erase=function(e){var t=this.find(e);if(t){this.splay(t);var i=t.left,r=t.right,n=null;i&&(i.parent=null,n=this.maxNode(i),this.splay(n),this._root=n),r&&(i?n.right=r:this._root=r,r.parent=n),this._size--}},i.prototype.pop=function(){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},i.prototype.next=function(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},i.prototype.prev=function(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},i.prototype.forEach=function(e){for(var t=this._root,i=[],r=!1,n=0;!r;)t?(i.push(t),t=t.left):i.length>0?(e(t=i.pop(),n++),t=t.right):r=!0;return this},i.prototype.range=function(e,t,i,r){for(var n=[],o=this._compare,s=this._root;0!==n.length||s;)if(s)n.push(s),s=s.left;else{if(o((s=n.pop()).key,t)>0)break;if(o(s.key,e)>=0&&i.call(r,s))return this;s=s.right}return this},i.prototype.keys=function(){for(var e=this._root,t=[],i=[],r=!1;!r;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.key),e=e.right):r=!0;return i},i.prototype.values=function(){for(var e=this._root,t=[],i=[],r=!1;!r;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.data),e=e.right):r=!0;return i},i.prototype.at=function(e){for(var t=this._root,i=[],r=!1,n=0;!r;)if(t)i.push(t),t=t.left;else if(i.length>0){if(t=i.pop(),n===e)return t;n++,t=t.right}else r=!0;return null},i.prototype.load=function(e,t,i){if(void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=!1),0!==this._size)throw new Error("bulk-load: tree is not empty");var r=e.length;return i&&o(e,t,0,r-1,this._compare),this._root=n(null,e,t,0,r),this._size=r,this},i.prototype.min=function(){var e=this.minNode(this._root);return e?e.key:null},i.prototype.max=function(){var e=this.maxNode(this._root);return e?e.key:null},i.prototype.isEmpty=function(){return null===this._root},r.size.get=function(){return this._size},i.createTree=function(e,t,r,n,o){return new i(r,o).load(e,t,n)},Object.defineProperties(i.prototype,r);var s=0,a=1,l=2,c=3,u=0,h=1,d=2,p=3;function f(e,t,i){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=!m(t,i)||t.isVertical()?t.prevInResult:t));var r=m(e,i);e.resultTransition=r?function(e,t){var i,r=!e.inOut,n=!e.otherInOut;switch(t){case u:i=r&&n;break;case h:i=r||n;break;case p:i=r^n;break;case d:i=e.isSubject?r&&!n:n&&!r}return i?1:-1}(e,i):0}function m(e,t){switch(e.type){case s:switch(t){case u:return!e.otherInOut;case h:return e.otherInOut;case d:return e.isSubject&&e.otherInOut||!e.isSubject&&!e.otherInOut;case p:return!0}break;case l:return t===u||t===h;case c:return t===d;case a:return!1}return!1}var _=function(e,t,i,r,n){this.left=t,this.point=e,this.otherEvent=i,this.isSubject=r,this.type=n||s,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},g={inResult:{configurable:!0}};function y(e,t){return e[0]===t[0]&&e[1]===t[1]}_.prototype.isBelow=function(e){var t=this.point,i=this.otherEvent.point;return this.left?(t[0]-e[0])*(i[1]-e[1])-(i[0]-e[0])*(t[1]-e[1])>0:(i[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(i[1]-e[1])>0},_.prototype.isAbove=function(e){return!this.isBelow(e)},_.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},g.inResult.get=function(){return 0!==this.resultTransition},_.prototype.clone=function(){var e=new _(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},Object.defineProperties(_.prototype,g);var x=11102230246251565e-32,v=134217729,b=(3+8*x)*x;function w(e,t,i,r,n){var o,s,a,l,c=t[0],u=r[0],h=0,d=0;u>c==u>-c?(o=c,c=t[++h]):(o=u,u=r[++d]);var p=0;if(h<e&&d<i)for(u>c==u>-c?(a=o-((s=c+o)-c),c=t[++h]):(a=o-((s=u+o)-u),u=r[++d]),o=s,0!==a&&(n[p++]=a);h<e&&d<i;)u>c==u>-c?(a=o-((s=o+c)-(l=s-o))+(c-l),c=t[++h]):(a=o-((s=o+u)-(l=s-o))+(u-l),u=r[++d]),o=s,0!==a&&(n[p++]=a);for(;h<e;)a=o-((s=o+c)-(l=s-o))+(c-l),c=t[++h],o=s,0!==a&&(n[p++]=a);for(;d<i;)a=o-((s=o+u)-(l=s-o))+(u-l),u=r[++d],o=s,0!==a&&(n[p++]=a);return 0===o&&0!==p||(n[p++]=o),p}function T(e){return new Float64Array(e)}var E=33306690738754716e-32,S=22204460492503146e-32,A=11093356479670487e-47,I=T(4),C=T(8),M=T(12),D=T(16),P=T(4);function L(e,t,i){var r=function(e,t,i,r,n,o){var s=(t-o)*(i-n),a=(e-n)*(r-o),l=s-a;if(0===s||0===a||s>0!=a>0)return l;var c=Math.abs(s+a);return Math.abs(l)>=E*c?l:-function(e,t,i,r,n,o,s){var a,l,c,u,h,d,p,f,m,_,g,y,x,T,E,L,R,z,F=e-n,O=i-n,B=t-o,k=r-o;I[0]=(E=(f=F-(p=(d=v*F)-(d-F)))*(_=k-(m=(d=v*k)-(d-k)))-((T=F*k)-p*m-f*m-p*_))-((g=E-(R=(f=B-(p=(d=v*B)-(d-B)))*(_=O-(m=(d=v*O)-(d-O)))-((L=B*O)-p*m-f*m-p*_)))+(h=E-g))+(h-R),I[1]=(x=T-((y=T+g)-(h=y-T))+(g-h))-((g=x-L)+(h=x-g))+(h-L),I[2]=y-((z=y+g)-(h=z-y))+(g-h),I[3]=z;var U=function(e,t){for(var i=t[0],r=1;r<4;r++)i+=t[r];return i}(0,I),V=S*s;if(U>=V||-U>=V)return U;if(a=e-(F+(h=e-F))+(h-n),c=i-(O+(h=i-O))+(h-n),l=t-(B+(h=t-B))+(h-o),u=r-(k+(h=r-k))+(h-o),0===a&&0===l&&0===c&&0===u)return U;if(V=A*s+b*Math.abs(U),(U+=F*u+k*a-(B*c+O*l))>=V||-U>=V)return U;P[0]=(E=(f=a-(p=(d=v*a)-(d-a)))*(_=k-(m=(d=v*k)-(d-k)))-((T=a*k)-p*m-f*m-p*_))-((g=E-(R=(f=l-(p=(d=v*l)-(d-l)))*(_=O-(m=(d=v*O)-(d-O)))-((L=l*O)-p*m-f*m-p*_)))+(h=E-g))+(h-R),P[1]=(x=T-((y=T+g)-(h=y-T))+(g-h))-((g=x-L)+(h=x-g))+(h-L),P[2]=y-((z=y+g)-(h=z-y))+(g-h),P[3]=z;var N=w(4,I,4,P,C);P[0]=(E=(f=F-(p=(d=v*F)-(d-F)))*(_=u-(m=(d=v*u)-(d-u)))-((T=F*u)-p*m-f*m-p*_))-((g=E-(R=(f=B-(p=(d=v*B)-(d-B)))*(_=c-(m=(d=v*c)-(d-c)))-((L=B*c)-p*m-f*m-p*_)))+(h=E-g))+(h-R),P[1]=(x=T-((y=T+g)-(h=y-T))+(g-h))-((g=x-L)+(h=x-g))+(h-L),P[2]=y-((z=y+g)-(h=z-y))+(g-h),P[3]=z;var j=w(N,C,4,P,M);P[0]=(E=(f=a-(p=(d=v*a)-(d-a)))*(_=u-(m=(d=v*u)-(d-u)))-((T=a*u)-p*m-f*m-p*_))-((g=E-(R=(f=l-(p=(d=v*l)-(d-l)))*(_=c-(m=(d=v*c)-(d-c)))-((L=l*c)-p*m-f*m-p*_)))+(h=E-g))+(h-R),P[1]=(x=T-((y=T+g)-(h=y-T))+(g-h))-((g=x-L)+(h=x-g))+(h-L),P[2]=y-((z=y+g)-(h=z-y))+(g-h),P[3]=z;var G=w(j,M,4,P,D);return D[G-1]}(e,t,i,r,n,o,c)}(e[0],e[1],t[0],t[1],i[0],i[1]);return r>0?-1:r<0?1:0}function R(e,t){var i=e.point,r=t.point;return i[0]>r[0]?1:i[0]<r[0]?-1:i[1]!==r[1]?i[1]>r[1]?1:-1:function(e,t,i,r){return e.left!==t.left?e.left?1:-1:0!==L(i,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,i)}function z(e,t,i){var r=new _(t,!1,e,e.isSubject),n=new _(t,!0,e.otherEvent,e.isSubject);return y(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),r.contourId=n.contourId=e.contourId,R(n,e.otherEvent)>0&&(e.otherEvent.left=!0,n.left=!1),e.otherEvent.otherEvent=n,e.otherEvent=r,i.push(n),i.push(r),i}function F(e,t){return e[0]*t[1]-e[1]*t[0]}function O(e,t){return e[0]*t[0]+e[1]*t[1]}function B(e,t,i){var r=function(e,t,i,r,n){var o=[t[0]-e[0],t[1]-e[1]],s=[r[0]-i[0],r[1]-i[1]];function a(e,t,i){return[e[0]+t*i[0],e[1]+t*i[1]]}var l=[i[0]-e[0],i[1]-e[1]],c=F(o,s),u=c*c,h=O(o,o);if(u>0){var d=F(l,s)/c;if(d<0||d>1)return null;var p=F(l,o)/c;return p<0||p>1?null:0===d||1===d?[a(e,d,o)]:0===p||1===p?[a(i,p,s)]:[a(e,d,o)]}if((u=(c=F(l,o))*c)>0)return null;var f=O(o,l)/h,m=f+O(o,s)/h,_=Math.min(f,m),g=Math.max(f,m);return _<=1&&g>=0?1===_?[a(e,_>0?_:0,o)]:0===g?[a(e,g<1?g:1,o)]:[a(e,_>0?_:0,o),a(e,g<1?g:1,o)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),n=r?r.length:0;if(0===n)return 0;if(1===n&&(y(e.point,t.point)||y(e.otherEvent.point,t.otherEvent.point)))return 0;if(2===n&&e.isSubject===t.isSubject)return 0;if(1===n)return y(e.point,r[0])||y(e.otherEvent.point,r[0])||z(e,r[0],i),y(t.point,r[0])||y(t.otherEvent.point,r[0])||z(t,r[0],i),1;var o=[],s=!1,u=!1;return y(e.point,t.point)?s=!0:1===R(e,t)?o.push(t,e):o.push(e,t),y(e.otherEvent.point,t.otherEvent.point)?u=!0:1===R(e.otherEvent,t.otherEvent)?o.push(t.otherEvent,e.otherEvent):o.push(e.otherEvent,t.otherEvent),s&&u||s?(t.type=a,e.type=t.inOut===e.inOut?l:c,s&&!u&&z(o[1].otherEvent,o[0].point,i),2):u?(z(o[0],o[1].point,i),3):o[0]!==o[3].otherEvent?(z(o[0],o[1].point,i),z(o[1],o[2].point,i),3):(z(o[0],o[1].point,i),z(o[3].otherEvent,o[2].point,i),3)}function k(e,t){if(e===t)return 0;if(0!==L(e.point,e.otherEvent.point,t.point)||0!==L(e.point,e.otherEvent.point,t.otherEvent.point))return y(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===R(e,t)?t.isAbove(e.point)?-1:1:e.isBelow(t.point)?-1:1;if(e.isSubject!==t.isSubject)return e.isSubject?-1:1;var i=e.point,r=t.point;return i[0]===r[0]&&i[1]===r[1]?(i=e.otherEvent.point)[0]===(r=t.otherEvent.point)[0]&&i[1]===r[1]?0:e.contourId>t.contourId?1:-1:1===R(e,t)?1:-1}var U=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function V(e,t,i,r){var n,o=e+1,s=t[e].point,a=t.length;for(o<a&&(n=t[o].point);o<a&&n[0]===s[0]&&n[1]===s[1];){if(!i[o])return o;++o<a&&(n=t[o].point)}for(o=e-1;i[o]&&o>r;)o--;return o}U.prototype.isExterior=function(){return null==this.holeOf};var N=G,j=G;function G(e,t){if(!(this instanceof G))return new G(e,t);if(this.data=e||[],this.length=this.data.length,this.compare=t||H,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}function H(e,t){return e<t?-1:e>t?1:0}G.prototype={push:function(e){this.data.push(e),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var e=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),e}},peek:function(){return this.data[0]},_up:function(e){for(var t=this.data,i=this.compare,r=t[e];e>0;){var n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r},_down:function(e){for(var t=this.data,i=this.compare,r=this.length>>1,n=t[e];e<r;){var o=1+(e<<1),s=o+1,a=t[o];if(s<this.length&&i(t[s],a)<0&&(o=s,a=t[s]),i(a,n)>=0)break;t[e]=a,e=o}t[e]=n}},N.default=j;var q=Math.max,$=Math.min,Z=0;function W(e,t,i,r,n,o){var s,a,l,c,u,h;for(s=0,a=e.length-1;s<a;s++)if(c=e[s+1],u=new _(l=e[s],!1,void 0,t),h=new _(c,!1,u,t),u.otherEvent=h,l[0]!==c[0]||l[1]!==c[1]){u.contourId=h.contourId=i,o||(u.isExteriorRing=!1,h.isExteriorRing=!1),R(u,h)>0?h.left=!0:u.left=!0;var d=l[0],p=l[1];n[0]=$(n[0],d),n[1]=$(n[1],p),n[2]=q(n[2],d),n[3]=q(n[3],p),r.push(u),r.push(h)}}var X=[];function Y(e,t,r){"number"==typeof e[0][0][0]&&(e=[e]),"number"==typeof t[0][0][0]&&(t=[t]);var n=function(e,t,i){var r=null;return e.length*t.length==0&&(i===u?r=X:i===d?r=e:i!==h&&i!==p||(r=0===e.length?t:e)),r}(e,t,r);if(n)return n===X?null:n;var o=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],a=function(e,t,i,r,n){var o,s,a,l,c,u,h=new N(null,R);for(a=0,l=e.length;a<l;a++)for(c=0,u=(o=e[a]).length;c<u;c++)(s=0===c)&&Z++,W(o[c],!0,Z,h,i,s);for(a=0,l=t.length;a<l;a++)for(c=0,u=(o=t[a]).length;c<u;c++)s=0===c,n===d&&(s=!1),s&&Z++,W(o[c],!1,Z,h,r,s);return h}(e,t,o,s,r);if(n=function(e,t,i,r,n){var o=null;return(i[0]>r[2]||r[0]>i[2]||i[1]>r[3]||r[1]>i[3])&&(n===u?o=X:n===d?o=e:n!==h&&n!==p||(o=e.concat(t))),o}(e,t,o,s,r))return n===X?null:n;for(var l=function(e){var t,i,r=function(e){var t,i,r,n,o=[];for(i=0,r=e.length;i<r;i++)((t=e[i]).left&&t.inResult||!t.left&&t.otherEvent.inResult)&&o.push(t);for(var s=!1;!s;)for(s=!0,i=0,r=o.length;i<r;i++)i+1<r&&1===R(o[i],o[i+1])&&(n=o[i],o[i]=o[i+1],o[i+1]=n,s=!1);for(i=0,r=o.length;i<r;i++)(t=o[i]).otherPos=i;for(i=0,r=o.length;i<r;i++)(t=o[i]).left||(n=t.otherPos,t.otherPos=t.otherEvent.otherPos,t.otherEvent.otherPos=n);return o}(e),n={},o=[],s=function(){if(!n[t]){var e=o.length,i=function(e,t,i){var r=new U;if(null!=e.prevInResult){var n=e.prevInResult,o=n.outputContourId;if(n.resultTransition>0){var s=t[o];if(null!=s.holeOf){var a=s.holeOf;t[a].holeIds.push(i),r.holeOf=a,r.depth=t[o].depth}else t[o].holeIds.push(i),r.holeOf=o,r.depth=t[o].depth+1}else r.holeOf=null,r.depth=t[o].depth}else r.holeOf=null,r.depth=0;return r}(r[t],o,e),s=function(t){n[t]=!0,t<r.length&&r[t]&&(r[t].outputContourId=e)},a=t,l=t;for(i.points.push(r[t].point);s(a),s(a=r[a].otherPos),i.points.push(r[a].point),!((a=V(a,r,n,l))==l||a>=r.length)&&r[a];);o.push(i)}};for(t=0,i=r.length;t<i;t++)s();return o}(function(e,t,r,n,o,s){for(var a,l,c,h=new i(k),p=[],m=Math.min(n[2],o[2]);0!==e.length;){var _=e.pop();if(p.push(_),s===u&&_.point[0]>m||s===d&&_.point[0]>n[2])break;if(_.left){l=a=h.insert(_),a=a!==(c=h.minNode())?h.prev(a):null,l=h.next(l);var g=a?a.key:null;if(f(_,g,s),l&&2===B(_,l.key,e)&&(f(_,g,s),f(l.key,_,s)),a&&2===B(a.key,_,e)){var y=a;f(g,(y=y!==c?h.prev(y):null)?y.key:null,s),f(_,g,s)}}else l=a=h.find(_=_.otherEvent),a&&l&&(a=a!==c?h.prev(a):null,l=h.next(l),h.remove(_),l&&a&&B(a.key,l.key,e))}return p}(a,0,0,o,s,r)),c=[],m=0;m<l.length;m++){var _=l[m];if(_.isExterior()){for(var g=[_.points],y=0;y<_.holeIds.length;y++)g.push(l[_.holeIds[y]].points);c.push(g)}}return c}var K={UNION:h,DIFFERENCE:d,INTERSECTION:u,XOR:p};e.diff=function(e,t){return Y(e,t,d)},e.intersection=function(e,t){return Y(e,t,u)},e.operations=K,e.union=function(e,t){return Y(e,t,h)},e.xor=function(e,t){return Y(e,t,p)},Object.defineProperty(e,"__esModule",{value:!0})}(Fu.exports)),Fu.exports);
|
||
/**
|
||
* martinez v0.7.4
|
||
* Martinez polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor
|
||
*
|
||
* @author Alex Milevski <info@w8r.name>
|
||
* @license MIT
|
||
* @preserve
|
||
*/function Bu(e,t,i,r){const n=[],o=0===r?(e,t,i,r,n,o)=>{e.push(new Le(o,i+(o-t)/(r-t)*(n-i)))}:(e,t,i,r,n,o)=>{e.push(new Le(t+(o-i)/(n-i)*(r-t),o))};for(const s of e){const e=[];for(const n of s){if(n.length<=2)continue;const s=[];for(let e=0;e<n.length-1;e++){const a=n[e].x,l=n[e].y,c=n[e+1].x,u=n[e+1].y,h=0===r?a:l,d=0===r?c:u;h<t?d>t&&o(s,a,l,c,u,t):h>i?d<i&&o(s,a,l,c,u,i):s.push(n[e]),d<t&&h>=t&&o(s,a,l,c,u,t),d>i&&h<=i&&o(s,a,l,c,u,i)}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=t&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),e.push(s))}e.length&&n.push(e)}return n}function ku(e,t){const i=Vu(e),r=Vu([t]),n=Ou.intersection(i,r);return null==n?[]:Nu(n)}function Uu(e,t){const i=65536;let r=Vu(e,i);const n=[];for(;t.valid();t.next()){const[e,r]=t.get(),o=e.x*i,s=e.y*i,a=r.x*i,l=r.y*i,c=a-o,u=l-s,h=Math.hypot(c,u);if(0===h)continue;const d=Math.trunc(u/h*3),p=-Math.trunc(c/h*3);n.push([[[o,s],[a,l],[a+d,l+p],[o+d,s+p],[o,s]]])}return n.length>0&&(r=Ou.diff(r,n)),Nu(r,1/i)}function Vu(e,t=1){return[e.map((e=>e.map((e=>[e.x*t,e.y*t]))))]}function Nu(e,t=1){return e.map((e=>e.map(((e,i)=>{const r=e.map((e=>new Le(e[0]*t,e[1]*t).round()));return i>0&&r.reverse(),r}))))}class FillBufferData{constructor(e,t){this.layoutVertexArray=new StructArrayLayout2i4,this.indexArray=new StructArrayLayout3ui6,this.lineIndexArray=new StructArrayLayout2ui4,this.triangleSegments=new SegmentVector,this.lineSegments=new SegmentVector,this.programConfigurations=new ProgramConfigurationSet(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new StructArrayLayout1f4)}update(e,t,i,r,n,o,s,a){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,a)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Qc.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,eu.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,i,r,n,o,s){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,i,r,n,o,void 0,s)}}class FillBucket{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 FillBufferData(e,!1),this.elevationBufferData=new FillBufferData(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,i,r){}populate(e,t,i,r){this.hasPattern=Lu("fill",this.layers,this.pixelRatio,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=yl(s,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=n?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:gl(s,i,r),patterns:{},sortKey:h};o.push(d)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const e=Ru("fill",this.layers,r,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i,r,n,o,s){this.bufferData.update(e,t,i,r,n,o,s,this.worldview),this.elevationBufferData.update(e,t,i,r,n,o,s,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,i,r,n,o,s,this.worldview)}addFeatures(e,t,i,r,n,o){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,r,o,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,i,r,n,o=[],s,a){const l=Mu(t,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,l,r,i,a):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(e,i,n,o,r,s,this.worldview),this.elevationBufferData.populatePaintArrays(e,i,n,o,r,s,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(e,t,i,r,n){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,i,r,n,this.worldview))}addElevatedRoadFeature(e,t,i,r,n){const o=new Array,s=ElevationFeatures.getElevationFeature(e,n);if(!s)return void this.addGeometry(t,this.bufferData);{const e=this.clipPolygonsToTile(t,1);e.length>0&&o.push({polygons:e,elevationFeature:s,elevationTileID:i})}const a={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},i),featureIndex:r};for(const t of o)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new ElevatedStructures(t.elevationTileID,this.layers,this.zoom,this.lut));const i=t.elevationFeature.isTunnel();let r=0;e.properties.hasOwnProperty(El)&&(r=+e.properties[El]);for(const e of t.polygons)this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,e,i,t.elevationFeature,r)}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const n=new ElevationFeatureSampler(i,t.elevationTileID);this.addElevatedGeometry(t.polygons,n,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,r,a)}}addElevatedGeometry(e,t,i,r,n,o){const s={elevation:i,elevationSampler:t,bias:r,index:n,featureInfo:o},[a,l]=this.addGeometry(e,this.elevationBufferData,s);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:a,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,a),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l))}addGeometry(e,t,i){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=null;i&&(o=i.elevationSampler.constantElevation(i.elevation,i.bias),null!=o&&(r=o,n=o));const s=(e,s,a)=>{if(null!=i)if(s.push(e),null!=o)t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o);else{const o=i.elevationSampler.pointElevation(e,i.elevation,i.bias);t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o),r=Math.min(r,o),n=Math.max(n,o)}};for(const r of e){let e=0;for(const t of r)e+=t.length;const n=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),o=n.vertexLength,a=[],l=[],c=[],u=[],h=[],d=t.layoutVertexArray.length;for(const e of r){if(0===e.length)continue;e!==r[0]&&l.push(a.length/2);const n=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),o=n.vertexLength;i&&h.push(t.layoutVertexArray.length-d),s(e[0],c,u),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(o+e.length-1,o),a.push(e[0].x),a.push(e[0].y);for(let i=1;i<e.length;i++)s(e[i],c,u),t.layoutVertexArray.emplaceBack(e[i].x,e[i].y),t.lineIndexArray.emplaceBack(o+i-1,o+i),a.push(e[i].x),a.push(e[i].y);n.vertexLength+=e.length,n.primitiveLength+=e.length}const p=ru(a,l);for(let e=0;e<p.length;e+=3)t.indexArray.emplaceBack(o+p[e],o+p[e+1],o+p[e+2]);if(p.length>0&&i&&"hd-road-base"===this.elevationMode){const e=i.elevation.isTunnel(),t=i.elevation.safeArea,r=this.elevatedStructures.addVertices(c,u);this.elevatedStructures.addTriangles(p,r,e);const n=h.length;if(n>0){for(let o=0;o<n-1;o++)this.elevatedStructures.addRenderableRing(i.index,h[o]+r,h[o+1]-h[o],e,t,i.featureInfo);this.elevatedStructures.addRenderableRing(i.index,h[n-1]+r,c.length-h[n-1],e,t,i.featureInfo)}}n.vertexLength+=e,n.primitiveLength+=p.length/3}return[r,n]}prepareElevatedPolygons(e,t,i){const r=1/cl(i),n=[];for(const i of e){const e=Uu(i,new EdgeIterator(t,r));n.push(...e)}return n}clipPolygonsToTile(e,t){const i=-t,r=-t,n=Mn+t,o=Mn+t;let s=0;const a=[],l=[];for(;s<e.length;s++){const t=e[s],c=cn(t);(c.min.x>=i&&c.max.x<=n&&c.min.y>=r&&c.max.y<=o?a:l).push(t)}if(a.length===e.length)return e;const c=[new Le(i,r),new Le(n,r),new Le(n,o),new Le(i,o),new Le(i,r)],u=a;for(const e of l)u.push(...ku(e,c));return u}}let ju,Gu,Hu,qu;bs(FillBucket,"FillBucket",{omit:["layers","patternFeatures"]}),bs(FillBufferData,"FillBufferData"),bs(ElevatedStructures,"ElevatedStructures");class TriangleGridIndex{constructor(e,t,i,r){if(this.triangleCount=t.length/3,this.min=new Le(0,0),this.max=new Le(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[n,o]=[e[0].clone(),e[0].clone()];for(let t=1;t<e.length;++t){const i=e[t];n.x=Math.min(n.x,i.x),n.y=Math.min(n.y,i.y),o.x=Math.max(o.x,i.x),o.y=Math.max(o.y,i.y)}if(r){const e=Math.ceil(Math.max(o.x-n.x,o.y-n.y)/r);i=Math.max(i,e)}if(0===i)return;this.min=n,this.max=o;const s=this.max.sub(this.min);s.x=Math.max(s.x,1),s.y=Math.max(s.y,1);const a=Math.max(s.x,s.y)/i;this.cellsX=Math.max(1,Math.ceil(s.x/a)),this.cellsY=Math.max(1,Math.ceil(s.y/a)),this.xScale=1/a,this.yScale=1/a;const l=[];for(let i=0;i<this.triangleCount;i++){const r=e[t[3*i+0]].sub(this.min),n=e[t[3*i+1]].sub(this.min),o=e[t[3*i+2]].sub(this.min),s=$u(Math.floor(Math.min(r.x,n.x,o.x)),this.xScale,this.cellsX),c=$u(Math.floor(Math.max(r.x,n.x,o.x)),this.xScale,this.cellsX),u=$u(Math.floor(Math.min(r.y,n.y,o.y)),this.yScale,this.cellsY),h=$u(Math.floor(Math.max(r.y,n.y,o.y)),this.yScale,this.cellsY),d=new Le(0,0),p=new Le(0,0),f=new Le(0,0),m=new Le(0,0);for(let e=u;e<=h;++e){d.y=p.y=e*a,f.y=m.y=(e+1)*a;for(let t=s;t<=c;++t)d.x=f.x=t*a,p.x=m.x=(t+1)*a,($l(r,n,o,d,p,m)||$l(r,n,o,d,m,f))&&l.push({cellIdx:e*this.cellsX+t,triIdx:i})}}if(0===l.length)return;l.sort(((e,t)=>e.cellIdx-t.cellIdx||e.triIdx-t.triIdx));let c=0;for(;c<l.length;){const e=l[c].cellIdx,t={start:this.payload.length,len:0};for(;c<l.length&&l[c].cellIdx===e;)++t.len,this.payload.push(l[c++].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 i=$u(e.x-this.min.x,this.xScale,this.cellsX),r=$u(e.y-this.min.y,this.yScale,this.cellsY),n=this.cells[r*this.cellsX+i];if(n){this._lazyInitLookup();for(let e=0;e<n.len;e++){const i=this.payload[n.start+e],r=Math.floor(i/8),o=1<<i%8;if(!(this.lookup[r]&o)&&(this.lookup[r]|=o,t.push(i),t.length===this.triangleCount))return}}}query(e,t,i){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 r=$u(e.x-this.min.x,this.xScale,this.cellsX),n=$u(t.x-this.min.x,this.xScale,this.cellsX),o=$u(e.y-this.min.y,this.yScale,this.cellsY),s=$u(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let t=r;t<=n;t++){const r=this.cells[e*this.cellsX+t];if(r)for(let e=0;e<r.len;e++){const t=this.payload[r.start+e],n=Math.floor(t/8),o=1<<t%8;if(!(this.lookup[n]&o)&&(this.lookup[n]|=o,i.push(t),i.length===this.triangleCount))return}}}}function $u(e,t,i){return Math.max(0,Math.min(i-1,Math.floor(e*t)))}bs(TriangleGridIndex,"TriangleGridIndex");class ClipBucket{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 i of this.footprints)t.push({footprint:i,id:e})}updateAppearances(e,t,i,r){}populate(e,t,i,r){const n=[];for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=yl(o,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:gl(o,i,r),patterns:{}};n.push(u)}for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r;this.addFeature(r,n,o,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,t,i,r,n,o,s){}destroy(){}addFeature(e,t,i,r,n,o=[],s){for(const e of Mu(t,2)){const t=[],i=[],r=[],n=new Le(1/0,1/0),o=new Le(-1/0,-1/0);for(const s of e)if(0!==s.length){s!==e[0]&&r.push(i.length/2);for(let e=0;e<s.length;e++)i.push(s[e].x),i.push(s[e].y),t.push(s[e]),n.x=Math.min(n.x,s[e].x),n.y=Math.min(n.y,s[e].y),o.x=Math.max(o.x,s[e].x),o.y=Math.max(o.y,s[e].y)}const s=ru(i,r),a=new TriangleGridIndex(t,s,8,256);this.footprints.push({vertices:t,indices:s,grid:a,min:n,max:o})}}}bs(ClipBucket,"ClipBucket",{omit:["layers"]});const Zu=_a([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Wu=_a([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Xu=_a([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),Yu=_a([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Ku=_a([{name:"a_join_normal_inside",components:3,type:"Int16"}]),Ju=_a([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Qu=_a([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:eh}=Zu,th=Number.MAX_SAFE_INTEGER,ih=th-1;function rh(e,t,i,r){return e.order<t||e.order===th||!(e.clipMask&i)||function(e,t){return 0!==t.length&&void 0===t.find((t=>t===e))}(r,e.clipScope)}class ReplacementSource{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Le(1/0,1/0),max:new Le(-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 i=lh(new Le(0,0),new Le(Mn,Mn),e),r=[];if(t&&!sh(i,this._globalClipBounds))return r;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!sh(i,t))continue;const n=ch(t.min,t.max,e);r.push({min:n.min,max:n.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope})}return r}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(i).buckets[e.layer];r&&r.updateFootprints(i.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 i=e.getOrder(),r=e.getClipMask(),n=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=lh(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:i,clipMask:r,clipScope:n})}this._sourceIds.push(e.getSourceId())}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||nh(e.min,t.min)||nh(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const i=(e,t)=>e+t;return e.length-t.length||e.reduce(i,"").localeCompare(t.reduce(i,""))}(e.clipScope,t.clipScope)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],r=this._prevRegions[t];e=i.priority!==r.priority||!oh(i,r)||i.order!==r.order||i.clipMask!==r.clipMask||!Re(i.clipScope,r.clipScope),this._activeRegions[t].hiddenByOverlap=r.hiddenByOverlap,++t}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==th&&(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 i=t[e].priority;for(;e<t.length&&t[e].priority===i;)++e;return e};if(this._sourceIds.length>1){let t=0,i=e(t);for(;t!==i;){let r=t;const n=t;for(;r!==i;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t<n;t++){const i=this._activeRegions[t];if(!i.hiddenByOverlap&&e.order===th&&sh(e,i)&&(e.hiddenByOverlap=hh(e.footprint,e.tileId,i.footprint,i.tileId),e.hiddenByOverlap))break}++r}t=i,i=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()}}function nh(e,t){return e.x-t.x||e.y-t.y}function oh(e,t){return 0===nh(e.min,t.min)&&0===nh(e.max,t.max)}function sh(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 ah(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i].sourceId!==t[i].sourceId||!oh(e[i],t[i])||e[i].order!==t[i].order||e[i].clipMask!==t[i].clipMask||!Re(e[i].clipScope,t[i].clipScope))return!1;return!0}function lh(e,t,i){const r=1/Mn,n=1/(1<<i.canonical.z),o=(t.x*r+i.canonical.x)*n+i.wrap,s=(t.y*r+i.canonical.y)*n;return{min:new Le((e.x*r+i.canonical.x)*n+i.wrap,(e.y*r+i.canonical.y)*n),max:new Le(o,s)}}function ch(e,t,i){const r=1<<i.canonical.z,n=((t.x-i.wrap)*r-i.canonical.x)*Mn,o=(t.y*r-i.canonical.y)*Mn;return{min:new Le(((e.x-i.wrap)*r-i.canonical.x)*Mn,(e.y*r-i.canonical.y)*Mn),max:new Le(n,o)}}function uh(e,t,i,r,n,o,s){const a=e.indices,l=e.vertices,c=[];for(let u=r;u<r+n;u+=3){const r=t[i[u+0]+o],n=t[i[u+1]+o],h=t[i[u+2]+o],d=Math.min(r.x,n.x,h.x),p=Math.max(r.x,n.x,h.x),f=Math.min(r.y,n.y,h.y),m=Math.max(r.y,n.y,h.y);c.length=0,e.grid.query(new Le(d,f),new Le(p,m),c);for(let e=0;e<c.length;e++){const t=c[e];if($l(l[a[3*t+0]],l[a[3*t+1]],l[a[3*t+2]],r,n,h,s))return!0}}return!1}function hh(e,t,i,r){if(!e||!i)return!1;let n=e.vertices;if(!t.canonical.equals(r.canonical)||t.wrap!==r.wrap){if(i.vertices.length<e.vertices.length)return hh(i,r,e,t);const o=t.canonical,s=r.canonical,a=Math.pow(2,s.z-o.z);n=e.vertices.map((e=>new Le((e.x+o.x*Mn)*a-s.x*Mn,(e.y+o.y*Mn)*a-s.y*Mn)))}return uh(i,n,e.indices,0,e.indices.length,0,0)}function dh(e,t,i,r){const n=Math.pow(2,r.z-i.z);return new Le((e+i.x*Mn)*n-r.x*Mn,(t+i.y*Mn)*n-r.y*Mn)}function ph(e,t){const i=[];t.grid.queryPoint(e,i);const r=t.indices,n=t.vertices;for(let t=0;t<i.length;t++){const o=i[t];if(jl([n[r[3*o+0]],n[r[3*o+1]],n[r[3*o+2]]],e))return!0}return!1}const fh=[new Le(0,0),new Le(Mn,0),new Le(Mn,Mn),new Le(0,Mn)];function mh(e,t){const i=[];let r=[];if(!t||e.length<2)return[e];if(2===e.length)return Hl(e[0],e[1],fh)?[e]:[];for(let t=0;t<e.length+2;t++){const n=e[t%e.length],o=e[(t+1)%e.length],s=Hl(0===t?e[e.length-1]:e[(t-1)%e.length],n,fh),a=Hl(n,o,fh),l=s||a;l&&r.push(n),l&&a||r.length>0&&(r.length>1&&i.push(r),r=[])}return r.length>1&&i.push(r),i}const _h=VectorTileFeature.types,gh=["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"],yh=["fill-extrusion-flood-light-ground-radius"],xh=Math.pow(2,13),vh=Math.pow(2,15)-1,bh=new Le(0,1),wh=2147483648,Th=7,Eh=450;function Sh(e,t,i,r,n,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(r*xh)<<1)+n,Math.round(a))}function Ah(e,t,i){e.emplaceBack(t.x*Mn,t.y*Mn,i?1:0)}function Ih(e,t,i,r,n,o){e.emplaceBack(t.x,t.y,(i.x<<1)+r,(i.y<<1)+n,o)}function Ch(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class FootprintSegment{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class PartData{constructor(){this.centroidXY=new Le(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 Le(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Le(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new Le(this.max.x-this.min.x,this.max.y-this.min.y)}}class BorderCentroidData{constructor(){this.acc=new Le(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,i){this.accCount++,this.acc._add(t);let r=!!this.borders;t.x<e.min.x?(e.min.x=t.x,r=!0):t.x>e.max.x&&(e.max.x=t.x,r=!0),t.y<e.min.y?(e.min.y=t.y,r=!0):t.y>e.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===Mn)&&t.x===i.x)!=((0===t.y||t.y===Mn)&&t.y===i.y)&&this.processBorderOverlap(t,i),r&&this.checkBorderIntersection(t,i)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,xr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Mn!=e.x>Mn&&this.addBorderIntersection(1,xr(t.y,e.y,(Mn-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,xr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Mn!=e.y>Mn&&this.addBorderIntersection(3,xr(t.x,e.x,(Mn-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 i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){return 0===this.accCount?new Le(0,0):new Le(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 Mh(e,t){const i=e.add(t)._unit(),r=He(e.x*i.x+e.y*i.y,-1,1);var n,o,s;return n=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(n)))/4*vh*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const Dh=[e=>e.x<0,e=>e.x>Mn,e=>e.y<0,e=>e.y>Mn];function Ph(e,t,i,r){const n=[4];if(0===r)return n;i._mult(r);const o=e.sub(i),s=t.sub(i),a=[e,t,o,s];for(let e=0;e<4;e++)for(const t of a)if(Dh[e](t)){n.push(e);break}return n}class GroundEffect{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new StructArrayLayout5i10,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(e.layers,{zoom:e.zoom,lut:e.lut},(e=>yh.includes(e))),this._segments=new SegmentVector,this.hiddenByLandmarkVertexArray=new StructArrayLayout1ub1,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new SegmentVector}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,r=!1){const n=e.length;if(n>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],i=e[1];a=Mh(t.sub(e[n-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;l<n;l++){const c=l===n-1?0:l+1,u=e[l],h=e[c],d=e[c===n-1?0:c+1],p=h.sub(u)._perp()._unit(),f=Mh(p,d.sub(h)._perp()._unit()),m=a,_=f;if(Fh(u,h,t)||r&&Oh(u,t)&&Oh(h,t)){a=f;continue}const g=s.vertexLength;Ih(this.vertexArray,u,h,1,1,m),Ih(this.vertexArray,u,h,1,0,m),Ih(this.vertexArray,u,h,0,1,_),Ih(this.vertexArray,u,h,0,0,_),s.vertexLength+=4;const y=Ph(u,h,p,i);for(const e of y)this._segmentToGroundQuads[o].push({id:g,region:e}),this._segmentToRegionTriCounts[o][e]+=2,s.primitiveLength+=2;a=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 i=0;i<t;i++){const t=this._segmentToGroundQuads[i],r=e[i],n=this._segmentToRegionTriCounts[i];n.reduce(((e,t)=>e+t),0);let o=0;for(let e=0;e<=4;e++){const t=n[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new SegmentVector);const n={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};i.get().push(n)}o+=t}for(let e=0;e<t.length;e++){const i=t[e].id;this.indexArray.emplaceBack(i,i+1,i+3),this.indexArray.emplaceBack(i,i+3,i+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,t,i,r,n,o,s){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,t,i,r,n,o,void 0,s)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Wu.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),null!=this.groundRadiusArray&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,Xu.members)))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,t,i,r,n,o,s,a){this.hasData()&&this.programConfigurations.updatePaintArrays(e,t,i,r,n,o,s,a)}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&wh))}updateHiddenByLandmarkRange(e,t,i){if(!this.hasData())return;const r=t+e;if(0!==t){for(let t=e;t<r;++t)this.hiddenByLandmarkVertexArray.emplace(t,i?1:0);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Ju.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 FillExtrusionBucket{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 StructArrayLayout3ui6,this.footprintVertices=new StructArrayLayout2i4,this.footprintSegments=[],this.layoutVertexArray=new StructArrayLayout4i8,this.centroidVertexArray=new FillExtrusionCentroidArray,this.wallVertexArray=new FillExtrusionWallArray,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(e.layers,{zoom:e.zoom,lut:e.lut},(e=>gh.includes(e))),this.segments=new SegmentVector,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.groundEffect=new GroundEffect(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,r){}populate(e,t,i,r){this.features=[],this.hasPattern=Lu("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=cl(i),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:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=yl(n,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:gl(n,i,r),properties:n.properties,type:n.type,patterns:{}},u=this.layoutVertexArray.length,h="Polygon"===_h[c.type];if(this.hasPattern)this.features.push({featureId:n.id,feature:Ru("fill-extrusion",this.layers,c,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of c.geometry)for(const o of mh(e,h))this.addFeature(n.id,c,[o],s,i,{},t.availableImages,r,t.brightness);else this.addFeature(n.id,c,c.geometry,s,i,{},t.availableImages,r,t.brightness);t.featureIndex.insert(n,c.geometry,s,a,this.index,u)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,i,r,n,o){for(const{featureId:e,feature:s}of this.features){const a="Polygon"===_h[s.type],{geometry:l}=s;if(this.wallMode)for(const c of l)for(const l of mh(c,a))this.addFeature(e,s,[l],s.index,t,i,r,n,o);else this.addFeature(e,s,l,s.index,t,i,r,n,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,this.worldview),this.groundEffect.update(e,t,n,i,r,o,s,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,eh),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Qu.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,Yu.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,i,r,n,o,s,a,l){const c=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new Le(0,0),new Le(Mn,Mn)],h=a.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===_h[t.type],f=new BorderCentroidData;f.centroidDataIndex=this.centroidData.length;const m=new PartData;m.buildingId=e,t.properties&&t.properties.hasOwnProperty("building_id")&&(m.buildingId=t.properties.building_id);const _=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},n);let y;if(m.height=g,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new StructArrayLayout6i12),this.wallMode){if(d)return void st("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==i.length)return;y=function(e){const t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,i=function(e){let t=0;const i=e.length;for(let r=0;r<i;r++)t+=(e[(r+1)%i].x-e[r].x)*(e[(r+1)%i].y+e[r].y);return t>=0}(e);i||(e=e.reverse());const r={geometry:[],joinNormals:[],indices:[]},n=[],o=[],s=[];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;if(a<(t?3:2))return r;let l,c,u,h,d,p=0;for(;p<a-1&&e[p].equals(e[p+1]);)p++;t&&(l=e[a-2],d=e[p].sub(l)._unit()._perp());for(let i=p;i<a;i++){if(u=i===a-1?t?e[p+1]:void 0:e[i+1],u&&e[i].equals(u))continue;d&&(h=d),l&&(c=l),l=e[i],d=u?u.sub(l)._unit()._perp():h,h=h||d;let r=h.add(d);0===r.x&&0===r.y||r._unit();const f=r.x*d.x+r.y*d.y,m=0!==f?1/f:1/0,_=h.x*d.y-h.y*d.x>0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m<y&&(g="miter"));const x=(e,t,i,r)=>{const a=new Le(e.x,e.y),l=new Le(e.x,e.y);a.x+=t.x*r,a.y+=t.y*r,l.x-=t.x*Math.max(i,1),l.y-=t.y*Math.max(i,1),s.push(t),n.push(a),o.push(l)};if("miter"===g)r._mult(m),x(l,r,0,0);else if("flipbevel"===g)r=d.mult(-1),x(l,r,0,0),x(l,r.mult(-1),0,0);else{const e=-Math.sqrt(m*m-1),t=_?e:0,i=_?0:e;c&&x(l,h,t,i),u&&x(l,d,t,i)}}r.geometry=[...n,...o.reverse(),n[0]],r.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=r.geometry.length-1;for(let e=0;e<f/2;e++)if(e+1<f/2){let t=e,i=e+1,n=f-1-e,o=f-2-e;t=0===t?f-1:t-1,i=0===i?f-1:i-1,n=0===n?f-1:n-1,o=0===o?f-1:o-1,r.indices.push(n),r.indices.push(i),r.indices.push(t),r.indices.push(n),r.indices.push(o),r.indices.push(i)}return r}(i[0]),i=[y.geometry]}const x=(e,t)=>e<(t.length-1)/2||e===t.length-1,v=this.wallMode?[i]:Mu(i,500);for(let e=v.length-1;e>=0;e--){const t=v[e];(0===t.length||(b=t[0]).every((e=>e.x<=0))||b.every((e=>e.x>=Mn))||b.every((e=>e.y<=0))||b.every((e=>e.y>=Mn)))&&v.splice(e,1)}var b;let w;if(d)w=Vh(v,u,n);else{w=[];for(const e of v)w.push({polygon:e,bounds:u})}const T=p?this.edgeRadius:0,E=T>0&&this.zoom<17,S=(e,t)=>{if(0===e.length)return!1;const i=e[e.length-1];return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of w){let i=0,r=0;for(const t of e)p&&!t[0].equals(t[t.length-1])&&t.push(t[0]),r+=p?t.length-1:t.length;const o=this.segments.prepareSegment((p?5:4)*r,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new FootprintSegment;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],p){const r=[],s=[];i=o.vertexLength;for(let i=0;i<e.length;i++){const l=e[i];l.length&&0!==i&&s.push(r.length/2);const u=[];let p,f;p=l[1].sub(l[0])._perp()._unit(),a.ringIndices.push(l.length-1);for(let e=1;e<l.length;e++){const t=l[e],i=l[e===l.length-1?1:e+1],s=t.clone();if(T){f=i.sub(t)._perp()._unit();const e=p.add(f)._unit(),r=T*Math.min(4,1/(p.x*e.x+p.y*e.y));s.x+=r*e.x,s.y+=r*e.y,s.x=Math.round(s.x),s.y=Math.round(s.y),p=f}if(!_||0!==T&&!E||S(u,s)||u.push(s),Sh(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),this.wallMode){const t=x(e,l);Ah(this.wallVertexArray,y.joinNormals[e],!t)}o.vertexLength++,this.footprintVertices.emplaceBack(t.x,t.y),r.push(t.x,t.y),d&&Ch(this.layoutVertexExtArray,h.projectTilePoint(s.x,s.y,n),h.upVector(n,s.x,s.y))}_&&(0===T||E)&&(0!==u.length&&S(u,u[0])&&u.pop(),this.groundEffect.addData(u,t,c))}const l=this.wallMode?y.indices:ru(r,s);for(let e=0;e<l.length;e+=3)this.footprintIndices.emplaceBack(a.vertexOffset+l[e+0],a.vertexOffset+l[e+1],a.vertexOffset+l[e+2]),this.indexArray.emplaceBack(i+l[e],i+l[e+2],i+l[e+1]),o.primitiveLength++;a.indexCount+=l.length,a.vertexCount+=this.footprintVertices.length-a.vertexOffset}for(let r=0;r<e.length;r++){const s=e[r];f.startRing(m,s[0]);let a=s.length>4&&Bh(s[s.length-2],s[0],s[1]),l=T?Rh(s[s.length-2],s[0],s[1],T):0;const u=[];let g,v,b;v=s[1].sub(s[0])._perp()._unit();let w=!0;for(let e=1,r=0;e<s.length;e++){let c=s[e-1],p=s[e];const E=s[e===s.length-1?1:e+1];if(f.appendEdge(m,p,c),Fh(p,c,t)){T&&(v=E.sub(p)._perp()._unit(),w=!w);continue}const A=p.sub(c)._perp(),I=A.x/(Math.abs(A.x)+Math.abs(A.y)),C=A.y>0?1:0,M=c.dist(p);if(r+M>32768&&(r=0),T){b=E.sub(p)._perp()._unit();let e=zh(c,p,E,Lh(v,b),T);isNaN(e)&&(e=0);const t=p.sub(c)._unit();c=c.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,v=b,_&&this.zoom>=17&&(S(u,c)||u.push(c),S(u,p)||u.push(p))}const D=o.vertexLength,P=s.length>4&&Bh(c,p,E);let L=kh(r,a,w);if(Sh(this.layoutVertexArray,c.x,c.y,I,C,0,0,L),Sh(this.layoutVertexArray,c.x,c.y,I,C,0,1,L),this.wallMode){const t=x(e-1,s),i=y.joinNormals[e-1];Ah(this.wallVertexArray,i,t),Ah(this.wallVertexArray,i,t)}if(r+=M,L=kh(r,P,!w),a=P,Sh(this.layoutVertexArray,p.x,p.y,I,C,0,0,L),Sh(this.layoutVertexArray,p.x,p.y,I,C,0,1,L),this.wallMode){const t=x(e,s),i=y.joinNormals[e];Ah(this.wallVertexArray,i,t),Ah(this.wallVertexArray,i,t)}if(o.vertexLength+=4,this.indexArray.emplaceBack(D+0,D+1,D+2),this.indexArray.emplaceBack(D+1,D+3,D+2),o.primitiveLength+=2,T){const r=i+(1===e?s.length-2:e-2),n=1===e?i:r+1;if(this.indexArray.emplaceBack(D+1,r,D+3),this.indexArray.emplaceBack(r,n,D+3),o.primitiveLength+=2,void 0===g&&(g=D),!Fh(E,s[e],t)){const t=e===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(D+2,D+3,t),this.indexArray.emplaceBack(D+3,t+1,t),this.indexArray.emplaceBack(D+3,n,t+1),o.primitiveLength+=3}w=!w}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(c.x,c.y,n),i=h.projectTilePoint(p.x,p.y,n),r=h.upVector(n,c.x,c.y),o=h.upVector(n,p.x,p.y);Ch(e,t,r),Ch(e,t,r),Ch(e,i,o),Ch(e,i,o)}}p&&(i+=s.length-1),_&&T&&this.zoom>=17&&(0!==u.length&&S(u,u[0])&&u.pop(),this.groundEffect.addData(u,t,c,T>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++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?bh:this.encodeCentroid(f,m),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,r,o,s,n,l,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(t,r,o,s,n,l,this.worldview),this.maxHeight=Math.max(this.maxHeight,g)}}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort(((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]))}splitToSubtiles(){const e=[];for(let t=0;t<this.centroidData.length;t++){const i=this.centroidData[t],r=+(i.min.y+i.max.y>Mn),n=2*r+(+(i.min.x+i.max.x>Mn)^r);for(let r=0;r<i.polygonSegLen;r++){const o=i.polygonSegIdx+r;e.push({centroidIdx:t,subtile:n,polygonSegmentIdx:o,triangleSegmentIdx:this.polygonSegments[o].triangleSegIdx})}}const t=new StructArrayLayout3ui6;e.sort(((e,t)=>e.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx));let i=0,r=0,n=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;n++}const o=e.length;for(;r!==e.length;){i=e[r].triangleSegmentIdx;let s=0,a=r,l=r;for(let t=a;t<n&&e[t].subtile===s;t++)l++;for(;a!==n;){const r=e[a];s=r.subtile;const o=this.centroidData[r.centroidIdx].min.clone(),c=this.centroidData[r.centroidIdx].max.clone(),u={vertexOffset:this.segments.segments[i].vertexOffset,primitiveOffset:t.length,vertexLength:this.segments.segments[i].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let i=a;i<l;i++){const r=e[i],n=this.polygonSegments[r.polygonSegmentIdx],s=this.centroidData[r.centroidIdx].min,a=this.centroidData[r.centroidIdx].max,l=this.indexArray.uint16;for(let e=n.triangleArrayOffset;e<n.triangleArrayOffset+n.triangleCount;e++)t.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);u.primitiveLength+=n.triangleCount,o.x=Math.min(o.x,s.x),o.y=Math.min(o.y,s.y),c.x=Math.max(c.x,a.x),c.y=Math.max(c.y,a.y)}u.primitiveLength>0&&this.triangleSubSegments.push({segment:u,min:o,max:c}),a=l;for(let t=a;t<n&&e[t].subtile===e[a].subtile;t++)l++}r=n;for(let t=r;t<o&&e[t].triangleSegmentIdx===e[r].triangleSegmentIdx;t++)n++}t._trim(),this.indexArray=t}getVisibleSegments(e,t,i){const r=new SegmentVector;if(this.wallMode){for(const e of this.triangleSubSegments)r.segments.push(e.segment);return r}let n=0,o=0;const s=1<<e.canonical.z;if(t){const i=t.getMinMaxForTile(e);i&&(n=i.min,o=i.max)}o+=this.maxHeight;const a=e.toUnwrapped();let l;const c=[a.canonical.x/s+a.wrap,a.canonical.y/s],u=[(a.canonical.x+1)/s+a.wrap,(a.canonical.y+1)/s],h=(e,t,i)=>[e[0]*(1-i[0])+t[0]*i[0],e[1]*(1-i[1])+t[1]*i[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/Mn,d[1]=e.min.y/Mn,p[0]=e.max.x/Mn,p[1]=e.max.y/Mn;const t=h(c,u,d),s=h(c,u,p);if(0===new Aabb([t[0],t[1],n],[s[0],s[1],o]).intersectsPrecise(i)){l&&(r.segments.push(l),l=void 0);continue}const a=e.segment;l&&l.vertexOffset!==a.vertexOffset&&(r.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&r.segments.push(l),r}encodeCentroid(e,t){const i=e.centroid(),r=t.span(),n=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new Le(He(i.x,1,Mn-1)<<3|n,He(i.y,1,Mn-1)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new Le(0,0);const t=e.borders,i=Number.MAX_VALUE;if(t[0][0]!==i||t[1][0]!==i){const e=t[0][0]!==i?0:1;return new Le(6|(t[0][0]!==i?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==i?2:3;return new Le((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=2147483647,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,r=e.flags&wh?bh:e.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||n!==r.x){for(let e=t;e<i;++e)this.centroidVertexArray.emplace(e,r.x,r.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,i){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped());if(ah(this.activeReplacements,r))return;if(this.activeReplacements=r,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const e of this.centroidData)e.flags&=2147483647;const n=[];for(const t of this.activeReplacements){if(t.order<i)continue;const r=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&wh||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|=wh);else for(const i of this.centroidData)if(!(i.flags&wh||t.min.x>i.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;o<i.footprintSegLen;o++){const s=this.footprintSegments[i.footprintSegIdx+o];if(n.length=0,Nh(this.footprintVertices,s.vertexOffset,s.vertexCount,t.footprintTileId.canonical,e.canonical,n),uh(t.footprint,n,this.footprintIndices.uint16,s.indexOffset,s.indexCount,-s.vertexOffset,-r)){i.flags|=wh;break}}}for(const e of this.centroidData)this.writeCentroidToBuffer(e);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,t,i){let r=!1;for(let n=0;n<i.footprintSegLen;n++){const o=this.footprintSegments[i.footprintSegIdx+n];let s=0;for(const i of o.ringIndices){for(let n=s,a=i+s-1;n<i+s;a=n++){const i=this.footprintVertices.int16[2*(n+o.vertexOffset)+0],s=this.footprintVertices.int16[2*(n+o.vertexOffset)+1],l=this.footprintVertices.int16[2*(a+o.vertexOffset)+1];s>t!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(r=!r)}s=i}}return r}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,r=!0;const n=4*(e+Mn)*Mn+(t+Mn);if(this.partLookup.hasOwnProperty(n)){const e=this.partLookup[n];return e?{height:e.height,hidden:!!(e.flags&wh)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||o.height<=i||this.footprintContainsPoint(e,t,o)&&(i=o.height,this.partLookup[n]=o,r=!!(o.flags&wh));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:r};this.partLookup[n]=void 0}}function Lh(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function Rh(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return zh(e,t,i,Lh(n,o),r)}function zh(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function Fh(e,t,i){return e.x<i[0].x&&t.x<i[0].x||e.x>i[1].x&&t.x>i[1].x||e.y<i[0].y&&t.y<i[0].y||e.y>i[1].y&&t.y>i[1].y}function Oh(e,t){return e.x<t[0].x||e.x>t[1].x||e.y<t[0].y||e.y>t[1].y}function Bh(e,t,i){if(e.x<0||e.x>=Mn||t.x<0||t.x>=Mn||i.x<0||i.x>=Mn)return!1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function kh(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function Uh(){const e=Math.PI/32,t=Math.tan(e),i=Wa;return i*Math.sqrt(1+2*t*t)-i}function Vh(e,t,i){const r=1<<i.z,n=il(i.x/r),o=il((i.x+1)/r),s=rl(i.y/r),a=rl((i.y+1)/r);return function(e,t,i,r,n=0,o){const s=[];if(!e.length||!i||!r)return s;const a=(e,t)=>{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(r)),u=l-c,h=[];for(let e=0;e<Math.abs(u);e++)h.push(u>0?0:1);for(let e=0;e<Math.min(l,c);e++)h.push(0),h.push(1);let d=e;if(d=Bu(d,t[0].y-n,t[1].y+n,1),d=Bu(d,t[0].x-n,t[1].x+n,0),!d.length)return s;const p=[];for(h.length?p.push({polygons:d,bounds:t,depth:0}):a(d,t);p.length;){const e=p.pop(),t=e.depth,i=h[t],r=e.bounds[0],s=e.bounds[1],l=0===i?r.x:r.y,c=0===i?s.x:s.y,u=o?o(i,l,c):.5*(l+c),d=Bu(e.polygons,l-n,u+n,i),f=Bu(e.polygons,u-n,c+n,i);if(d.length){const e=[r,new Le(0===i?u:s.x,1===i?u:s.y)];h.length>t+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new Le(0===i?u:r.x,1===i?u:r.y),s];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s}(e,t,Math.ceil((o-n)/11.25),Math.ceil((s-a)/11.25),1,((e,t,n)=>{if(0===e)return.5*(t+n);{const e=rl((i.y+t/Mn)/r);return(el(.5*(rl((i.y+n/Mn)/r)+e))*r-i.y)*Mn}}))}function Nh(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a<i;a++){let i=e.int16[2*(a+t)+0],l=e.int16[2*(a+t)+1];i=(i+n.x*Mn)*s-r.x*Mn,l=(l+n.y*Mn)*s-r.y*Mn,o.push(new Le(i,l))}}let jh,Gh;bs(FillExtrusionBucket,"FillExtrusionBucket",{omit:["layers","features"]}),bs(PartData,"PartData"),bs(FootprintSegment,"FootprintSegment"),bs(BorderCentroidData,"BorderCentroidData"),bs(GroundEffect,"GroundEffect");class Point3D extends Le{constructor(e,t,i){super(e,t),this.z=i}}class Point4D extends Point3D{constructor(e,t,i,r){super(e,t,i),this.w=r}}function Hh(e,t,i,r){const n="x"===i?"y":"x",o=(r-e[i])/(t[i]-e[i]);e[n]=Math.round(e[n]+(t[n]-e[n])*o),e[i]=r,e.hasOwnProperty("z")&&(e.z=xr(e.z,t.z,o)),e.hasOwnProperty("w")&&(e.w=xr(e.w,t.w,o))}function qh(e,t,i,r){const n=i,o=r;for(const i of["x","y"]){let r=e,s=t;r[i]>=s[i]&&(r=t,s=e),r[i]<n&&s[i]>n&&Hh(r,s,i,n),r[i]<o&&s[i]>o&&Hh(s,r,i,o)}}function $h(e,t,i,r,n,o){const s=[];for(let a=0;a<e.length;a++){const l=e[a];let c;const u=s.length;let h=0;for(let e=0;e<l.length-1;e++){let u=l[e],d=l[e+1],p=0;const f=h;let m,_;o&&(p=Math.hypot(d.x-u.x,d.y-u.y),h+=p,m=u,_=d),u.x<t&&d.x<t||(u.x<t?u=new Le(t,u.y+(t-u.x)/(d.x-u.x)*(d.y-u.y))._round():d.x<t&&(d=new Le(t,u.y+(t-u.x)/(d.x-u.x)*(d.y-u.y))._round()),u.y<i&&d.y<i||(u.y<i?u=new Le(u.x+(i-u.y)/(d.y-u.y)*(d.x-u.x),i)._round():d.y<i&&(d=new Le(u.x+(i-u.y)/(d.y-u.y)*(d.x-u.x),i)._round()),u.x>=r&&d.x>=r||(u.x>=r?u=new Le(r,u.y+(r-u.x)/(d.x-u.x)*(d.y-u.y))._round():d.x>=r&&(d=new Le(r,u.y+(r-u.x)/(d.x-u.x)*(d.y-u.y))._round()),u.y>=n&&d.y>=n||(u.y>=n?u=new Le(u.x+(n-u.y)/(d.y-u.y)*(d.x-u.x),n)._round():d.y>=n&&(d=new Le(u.x+(n-u.y)/(d.y-u.y)*(d.x-u.x),n)._round()),c&&u.equals(c[c.length-1])||(c=[u],s.push(c),o&&o.push({progress:{min:f+Wh(m,_,u)*p,max:1},parentIndex:a,prevPoint:m,nextPoint:_})),c.push(d),o&&(o[o.length-1].progress.max=f+Wh(m,_,d)*p,o[o.length-1].nextPoint=_)))))}if(o&&h>0)for(let e=u;e<s.length;e++)o[e].progress.min/=h,o[e].progress.max/=h}return s}function Zh(e,t,i,r,n){if(e.length<2)return void r.push(e);const o=[];for(;t.valid();){const[i,r]=t.get();for(let t=0;t<e.length-1;t++){const n=e[t],s=e[t+1],a=kl(n,s,i,r);if(a){const[e]=a,i=new Le(xr(n.x,s.x,e),xr(n.y,s.y,e));o.push({t:t+e,distance:0,point:i})}}t.next()}if(0===o.length)return void r.push(e);o.sort(((e,t)=>e.t-t.t));let s=0,a=0,l=[];for(r.push(l);s!==e.length;){if(a===o.length){for(;s!==e.length;)0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++;break}o[a].t<=s?(0!==l.length&&l[l.length-1].equals(o[a].point)||l.push(o[a].point),Math.trunc(o[a].t),a++):(0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++)}}function Wh(e,t,i){return e.x!==t.x?(i.x-e.x)/(t.x-e.x):e.y!==t.y?(i.y-e.y)/(t.y-e.y):0}function Xh(e,t){return e.x*t.x+e.y*t.y}function Yh(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(n=t[i++],!n)return 1/0;for(;i<t.length;i++){const o=t[i],s=e[0],a=n.sub(r),l=o.sub(r),c=s.sub(r),u=Xh(a,a),h=Xh(a,l),d=Xh(l,l),p=Xh(c,a),f=Xh(c,l),m=u*d-h*h,_=(d*p-h*f)/m,g=(u*f-h*p)/m,y=r.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}function Kh(e,t,i){let r=1/0;Rl(i,t)&&(r=Yh(i,t[0]));for(let n=0;n<t.length;n++){const o=t[n],s=e[n];for(let e=0;e<o.length-1;e++){const t=o[e],n=[t,o[e+1],s[e+1],s[e],t];Pl(i,n)&&(r=Math.min(r,Yh(i,n)))}}return r!==1/0&&r}function Jh(e,t,i,r,n,o,s,a,l,c,u){return"globe"===e.projection.name?function(e,t,i,r,n,o,s,a,l,c,u){const h=[],d=[],p=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1},g=Uh();i>0&&(i+=g),r+=g;for(const g of t){const t=[],y=[];for(const h of g){const d=h.x+n.x,g=h.y+n.y,x=e.projection.projectTilePoint(d,g,u),v=e.projection.upVector(u,h.x,h.y);let b=i,w=r;if(s){const e=Qh(d,g,i,r,s,a,l,c);b+=e.base,w+=e.top}0!==i?_(f,x.x+v[0]*p*b,x.y+v[1]*p*b,x.z+v[2]*p*b):_(f,x.x,x.y,x.z),_(m,x.x+v[0]*p*w,x.y+v[1]*p*w,x.z+v[2]*p*w),Z(f,f,o),Z(m,m,o),t.push(new Point3D(f[0],f[1],f[2])),y.push(new Point3D(m[0],m[1],m[2]))}h.push(t),d.push(y)}return[h,d]}(e,t,i,r,n,o,s,a,l,c,u):s?function(e,t,i,r,n,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const u=c.x+r.x,d=c.y+r.y,f=Qh(u,d,t,i,o,s,a,l);h[0]=u,h[1]=d,h[2]=f.base,h[3]=1,se(h,h,n),h[3]=Math.max(h[3],1e-5);const m=new Point3D(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=d,h[2]=f.top,h[3]=1,se(h,h,n),h[3]=Math.max(h[3],1e-5);const _=new Point3D(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(_)}c.push(e),u.push(p)}return[c,u]}(t,i,r,n,o,s,a,l,c):function(e,t,i,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,u=n[11]*t,h=n[8]*i,d=n[9]*i,p=n[10]*i,f=n[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+r.x,s=o.y+r.y,m=n[0]*t+n[4]*s+n[12],_=n[1]*t+n[5]*s+n[13],g=n[2]*t+n[6]*s+n[14],y=n[3]*t+n[7]*s+n[15],x=m+a,v=_+l,b=g+c,w=Math.max(y+u,1e-5),T=m+h,E=_+d,S=g+p,A=Math.max(y+f,1e-5);e.push(new Point3D(x/w,v/w,b/w)),i.push(new Point3D(T/A,E/A,S/A))}o.push(e),s.push(i)}return[o,s]}(t,i,r,n,o)}function Qh(e,t,i,r,n,o,s,a){const l=s*n.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/Th-Eh):s*function(e,t,i){const r=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*r),s=10*(t[1]-8*n),a=e.getElevationAt(r,n,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=e.tileCoordToPixel(r,n),d=2*c+1,p=2*u+1,f=function(e,t,i,r,n){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+n,i,!0),e.getElevationAtPixel(t,i+n,!0),e.getElevationAtPixel(t+r,i+n,!0)]}(e,h.x-c,h.y-u,d,p),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/d),x=Math.min(.25,.5*l*g/p);return a+Math.max(y*o,x*s)}(n,o,a):l;return{base:l+(0===i?-1:i),top:c?Math.max(u+r,l+i+2):l+r}}class ThrottledInvoker{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 Scheduler{constructor(){this.tasks={},this.taskQueue=[],et(["process"],this),this.invoker=new ThrottledInvoker(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}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 i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<t&&(t=r.priority,e=i)}if(null===e)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}var ed={workerUrl:"",workerClass:null,workerParams:void 0};const td="mapboxgl_preloaded_worker_pool";class WorkerPool{constructor(e){this.active={},this.name=e}acquire(e,t=WorkerPool.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<t;){const t=(i=`${this.name||""}WorkerPool: ${e}-${this.workers.length}`,null!=ed.workerClass?new ed.workerClass:new self.Worker(ed.workerUrl,Object.assign({name:i},ed.workerParams)));this.workers.push(t)}var i;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[td]}numActive(){return Object.keys(this.active).length}}WorkerPool.workerCount=2;class Dispatcher{constructor(e,t,i="Worker",r=WorkerPool.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Ye();const n=this.workerPool.acquire(this.id,r);for(let e=0;e<n.length;e++){const r=new Dispatcher.Actor(n[e],t,this.id);r.name=`${i} ${e}`,this.actors.push(r)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(e,t,i){Ze(this.actors,((i,r)=>{i.send(e,t,r)}),i=i||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 id,rd;function nd(){return id||(id=new WorkerPool),id}Dispatcher.Actor=class Actor{constructor(e,t,i){this.target=e,this.parent=t,this.mapId=i,this.callbacks={},this.cancelCallbacks={},et(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new Scheduler}send(e,t,i,r,n=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=new Set;return this.target.postMessage({id:s,type:e,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Ts(t,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data;if(!t)return;const i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||ht(self)){const e=this.callbacks[i],r=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"});r&&(this.cancelCallbacks[i]=r)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],"<response>"===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(Es(t.error)):i(null,Es(t.data)))}else{const i=new Set,r=t.hasCallback?(t,r)=>{this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?Ts(t):null,data:Ts(r,i)},i)}:()=>{},n=Es(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:i,scope:o}=n;this.parent.getWorkerSource(t.sourceMapId,e[0],i,o)[e[1]](n,r)}else r(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}};const od=4096;class BuildingGen{constructor(e){this.module=e,this.memoryStack=this.module.malloc(od),this.memoryStackNextFree=this.memoryStack}createIntArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>od?-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>od?-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,i){this.module.setFauxFacadeOptions(e?1:0,t?1:0,i)}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e)}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const t of e){const e=this.createIntArray(t.ringIndices),i=this.createFloatArray(t.coordinates);if(-1===e||-1===i)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,i,e,t.ringIndices.length-1)}for(const e of t){let t;t=e.entrances?JSON.parse(e.entrances):[];const i=this.createFloatArray(t),r=this.createFloatArray(e.coordinates);if(-1===i||-1===r)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(e.sourceId,e.crossPerc,e.distanceToRoad,i,t.length,r,e.coordinates.length)}if(!this.module.generateMesh()){const e=this.module.getLastError();return this.readStringBuffer(e)}const i=this.module.getMeshCount(),r=new Array(i);for(let e=0;e<i;e++){const t=this.module.getPositionsPtr(e),i=this.module.getPositionsLength(e),n=new Float32Array(this.module.heapF32.buffer,t,i),o=this.module.getNormalsPtr(e),s=this.module.getNormalsLength(e),a=new Float32Array(this.module.heapF32.buffer,o,s),l=this.module.getAOPtr(e),c=this.module.getAOLength(e),u=new Float32Array(this.module.heapF32.buffer,l,c),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),_=new Uint8Array(this.module.heapU8.buffer,f,m),g=this.module.getIndicesPtr(e),y=this.module.getIndicesLength(e),x=new Int16Array(this.module.heap16.buffer,g,y),v=this.module.getBuildingPart(e);r[e]={positions:n,normals:a,ao:u,uv:p,isFauxFacade:_,indices:x,buildingPart:v}}const n=this.module.getRingCount(),o=[];for(let e=0;e<n;e++){const t=this.module.getRingPtr(e),i=this.module.getRingLength(e),r=new Float32Array(this.module.heapF32.buffer,t,i);o.push(r)}return{meshes:r,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:o}}}let sd,ad,ld,cd,ud,hd=null,dd=null,pd=null,fd=null;function md(){return ht(self)&&self.worker.dracoUrl?self.worker.dracoUrl:ad||Mt.DRACO_URL}function _d(){if(ht(self)&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(cd)return cd;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]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return cd=WebAssembly.validate(e)?Mt.MESHOPT_SIMD_URL:Mt.MESHOPT_URL,cd}function gd(){return fd}const yd={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},xd={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function bd(e,t,i){const r=i.json.bufferViews.length,n=i.buffers.length;t.bufferView=r,i.json.bufferViews[r]={buffer:n,byteLength:e.byteLength},i.buffers[n]=e}const wd="KHR_draco_mesh_compression";function Td(e,t){const i=e.extensions&&e.extensions[wd];if(!i)return;const r=new ld.Decoder,n=Dd(t,i.bufferView),o=new ld.Mesh;if(!r.DecodeArrayToMesh(n,n.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=t.json.accessors[e.indices],a=yd[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=ld._malloc(l);a===Uint16Array?r.GetTrianglesUInt16Array(o,l,c):r.GetTrianglesUInt32Array(o,l,c),bd(ld.memory.buffer.slice(c,c+l),s,t),ld._free(c);for(const n of Object.keys(i.attributes)){const s=r.GetAttributeByUniqueId(o,i.attributes[n]),a=t.json.accessors[e.attributes[n]],l=xd[a.componentType],c=a.count*vd[a.type]*yd[a.componentType].BYTES_PER_ELEMENT,u=ld._malloc(c);r.GetAttributeDataArrayForAllPoints(o,s,ld[l],c,u),bd(ld.memory.buffer.slice(u,u+c),a,t),ld._free(u)}r.destroy(),o.destroy(),delete e.extensions[wd]}const Ed="EXT_meshopt_compression";function Sd(e,t){if(!e.extensions||!e.extensions[Ed])return;const i=e.extensions[Ed],r=new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),n=new Uint8Array(i.count*i.byteStride);ud.decodeGltfBuffer(n,i.count,i.byteStride,r,i.mode,i.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=n.buffer,delete e.extensions[Ed]}const Ad=1179937895,Id=new TextDecoder("utf8");function Cd(e,t){return new URL(e,t).href}function Md(e,t,i,r){return fetch(Cd(e.uri,r)).then((e=>e.arrayBuffer())).then((e=>{t.buffers[i]=e}))}function Dd(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Pd(e,t,i,r){if(e.uri){const n=Cd(e.uri,r);return fetch(n).then((e=>e.blob())).then((e=>createImageBitmap(e))).then((e=>{t.images[i]=e}))}if(void 0!==e.bufferView){const r=Dd(t,e.bufferView),n=new Blob([r],{type:e.mimeType});return createImageBitmap(n).then((e=>{t.images[i]=e}))}}function Ld(e){return fetch(e).then((e=>e.arrayBuffer())).then((t=>function(e,t=0,i){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===Ad){const i=new Uint32Array(e,t);let n=2;const o=(i[n++]>>2)-3,s=i[n++]>>2;if(n++,r.json=JSON.parse(Id.decode(i.subarray(n,n+s))),n+=s,n<o){const o=i[n++];n++;const s=t+(n<<2);r.buffers[0]=e.slice(s,s+o)}}else r.json=JSON.parse(Id.decode(new Uint8Array(e,t)));const{buffers:n,images:o,meshes:s,extensionsUsed:a,bufferViews:l}=r.json;let c=Promise.resolve();if(n){const e=[];for(let t=0;t<n.length;t++){const o=n[t];o.uri?e.push(Md(o,r,t,i)):r.buffers[t]||(r.buffers[t]=null)}c=Promise.all(e)}return c.then((()=>{const e=[],t=a&&a.includes(wd),n=a&&a.includes(Ed);if(t&&e.push(function(){if(!ld)return null!=sd?sd:(sd=function(e){let t,i=null;function r(){t=new Uint8Array(i.buffer)}function n(){throw new Error("Unexpected Draco error.")}const o={a:{a:n,d:function(e,i,r){return t.copyWithin(e,i,i+r)},c:function(e){const n=t.length,o=Math.max(e>>>0,Math.ceil(1.2*n)),s=Math.ceil((o-n)/65536);try{return i.grow(s),r(),!0}catch(e){return!1}},b:n}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,o)))).then((e=>{const{Rb:n,Qb:o,P:s,T:a,X:l,Ja:c,La:u,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:x,Ab:v,Bb:b,Db:w,Gb:T}=e.instance.exports;i=g;const E=(()=>{let e=0,i=0,r=0,s=0;return a=>{r&&(n(s),n(e),i+=r,r=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(r=l,c=s=o(l));for(let e=0;e<a.length;e++)t[c+e]=a[e];return c}})();return r(),_(),{memory:g,_free:n,_malloc:o,Mesh:class Mesh{constructor(){this.ptr=s()}destroy(){a(this.ptr)}},Decoder:class Decoder{constructor(){this.ptr=c()}destroy(){m(this.ptr)}DecodeArrayToMesh(e,t,i){const r=E(e),n=u(this.ptr,r,t,i.ptr);return!!l(n)}GetAttributeByUniqueId(e,t){return{ptr:h(this.ptr,e.ptr,t)}}GetTrianglesUInt16Array(e,t,i){d(this.ptr,e.ptr,t,i)}GetTrianglesUInt32Array(e,t,i){p(this.ptr,e.ptr,t,i)}GetAttributeDataArrayForAllPoints(e,t,i,r,n){f(this.ptr,e.ptr,t.ptr,i,r,n)}},DT_INT8:y(),DT_UINT8:x(),DT_INT16:v(),DT_UINT16:b(),DT_UINT32:w(),DT_FLOAT32:T()}}))}(fetch(md())),sd.then((e=>{ld=e,sd=void 0})))}()),n&&e.push(function(){if(ud)return;const e=function(e){let t;const i=WebAssembly.instantiateStreaming(e,{}).then((e=>{t=e.instance,t.exports.__wasm_call_ctors()})),r={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},n={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(e,i,o,s,a,l){!function(e,t,i,r,n,o,s){const a=e.exports.sbrk,l=r+3&-4,c=a(l*n),u=a(o.length),h=new Uint8Array(e.exports.memory.buffer);h.set(o,u);const d=t(c,r,n,u,o.length);if(0===d&&s&&s(c,l,n),i.set(h.subarray(c,c+r*n)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(t,t.exports[n[a]],e,i,o,s,t.exports[r[l]])}}}(fetch(_d()));return e.ready.then((()=>{ud=e}))}()),o)for(let t=0;t<o.length;t++)e.push(Pd(o[t],r,t,i));return(e.length?Promise.all(e):Promise.resolve()).then((()=>{if(t&&s)for(const{primitives:e}of s)for(const t of e)Td(t,r);if(n&&s&&l)for(const e of l)Sd(e,r);return r}))}))}(t,0,e)))}function Rd(e){switch(e){case WebGL2RenderingContext.RGBA8: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 zd(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;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 Texture{constructor(e,t,i,r){this.context=e,this.format=i,this.useMipmap=r&&r.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:r&&r.premultiply})}update(e,t){const i=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,r=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:n}=this,{gl:o}=n,{x:s,y:a}=t&&t.position?t.position:{x:0,y:0},l=s+i,c=a+r;!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!t||!1!==t.premultiply));const u=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,e,this.format,l,c),this.size=[l,c]}this.size&&(u?o.texSubImage2D(o.TEXTURE_2D,0,s,a,Rd(this.format),zd(this.format),e):"data"in e&&e.data&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,r,Rd(this.format),zd(this.format),e.data)),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(e,t,i=!1){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,this.useMipmap&&!i?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR: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)}bindExtraParam(e,t,i,r,n){const{context:o}=this,{gl:s}=o;s.bindTexture(s.TEXTURE_2D,this.texture),t!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?e===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),this.wrapS=i),r!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,r),this.wrapT=r),n!==this.compareMode&&(n?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,n)):s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE),this.compareMode=n)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Texture3D{constructor(e,t,i,r){this.context=e,this.format=r,this.size=i,this.texture=e.gl.createTexture();const[n,o,s]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&a.texImage3D(a.TEXTURE_3D,0,this.format,n,o,s,0,Rd(this.format),zd(this.format),t.data)}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_3D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class UserManagedTexture{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}}const Fd=_a([{name:"a_pos_3f",components:3,type:"Float32"}]),Od=_a([{name:"a_color_3f",components:3,type:"Float32"}]),Bd=_a([{name:"a_color_4f",components:4,type:"Float32"}]),kd=_a([{name:"a_uv_2f",components:2,type:"Float32"}]),Ud=_a([{name:"a_normal_3f",components:3,type:"Float32"}]),Vd=_a([{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"}]),Nd=_a([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function jd(e,t){const i=Hd(e.projection,e.zoom,e.width,e.height),r=function(e,t,i,r,n){const o=new LngLat(i.lng-180*qd,i.lat),s=new LngLat(i.lng+180*qd,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),h=MercatorCoordinate.fromLngLat(i);h.y=He(h.y,-1+qd,1-qd);const d=h.toLngLat(),f=e.project(d.lng,d.lat),_=MercatorCoordinate.fromLngLat(d);_.x+=qd;const g=_.toLngLat(),x=e.project(g.lng,g.lat),v=Zd(x.x-f.x,x.y-f.y,c),b=MercatorCoordinate.fromLngLat(d);b.y+=qd;const w=b.toLngLat(),T=e.project(w.lng,w.lat),E=Zd(T.x-f.x,T.y-f.y,c),S=Math.abs(v.x)/Math.abs(E.y),A=u([]);y(A,A,-c*(1-(n?0:r)));const I=u([]);return m(I,I,[1,1-(1-S)*r,1]),I[4]=-E.x/E.y*r,y(I,I,c),p(I,A,I),I}(e.projection,0,e.center,i,t),n=Gd(e);return m(r,r,[n,n,1]),r}function Gd(e){const t=e.projection,i=Hd(e.projection,e.zoom,e.width,e.height),r=$d(t,e.center),n=$d(t,LngLat.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function Hd(e,t,i,r,n=1/0){const o=e.range;if(!o)return 0;const s=Math.min(n,Math.max(i,r)),a=Math.log2(s/1024);return qe(o[0]+a,o[1]+a,t)}const qd=1/4e4;function $d(e,t){const i=He(t.lat,-ol,ol),r=new LngLat(t.lng-180*qd,i),n=new LngLat(t.lng+180*qd,i),o=e.project(r.lng,i),s=e.project(n.lng,i),a=MercatorCoordinate.fromLngLat(r),l=MercatorCoordinate.fromLngLat(n),c=s.x-o.x,u=s.y-o.y,h=l.x-a.x,d=l.y-a.y,p=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log2(p)}function Zd(e,t,i){const r=Math.cos(i),n=Math.sin(i);return{x:e*r-t*n,y:e*n+t*r}}function Wd(e,t,i){u(e),y(e,e,Oe(t[2])),_(e,e,Oe(t[0])),g(e,e,Oe(t[1])),m(e,e,i),p(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function Xd(e,t,i,r,n,o,s,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[r[0]-t[0],r[1]-t[1],0];if(M(l)<1e-12||M(c)<1e-12)return le(e);const u=q([],l,c);G(u,u),R(c,r,t),l[2]=(o-n)*a,c[2]=(s-n)*a;const h=l;return q(h,l,c),G(h,h),_e(e,u,h)}function Yd(e,t,i=!1){const r=Ac(t.zoom),n=function(e,t,i){const r=t.worldSize,n=[e[12],e[13],e[14]],o=rl(n[1]/r),s=il(n[0]/r),a=u([]),l=tl(1,o)*r,c=tl(1,0)*r*al(o,t.zoom),h=1/wc(r);let d=c*h;if(i){const e=Hd(t.projection,t.zoom,t.width,t.height,1024);d=h*t.projection.pixelSpaceConversion(t.center.lat,r,e)}const _=Za(o,s);L(_,_,B([],G([],_),l*d*n[2]));const g=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const r=q([],i,t);return q(i,t,r),0===N(i)&&(i=[0,1,0],q(r,t,i)),G(r,r),G(i,i),G(t,t),[r[0],r[1],r[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(_);m(a,a,[d,d,d*l]),f(a,a,[-n[0],-n[1],-n[2]]);const y=p([],t.globeMatrix,g);return p(y,y,a),p(y,y,e),y}(e,t,i);if(r>0){const i=function(e,t){const i=t.worldSize,r=tl(1,0)*i*al(t.center.lat,t.zoom)/wc(i),n=tl(1,t.center.lat)*i,o=u([]);g(o,o,Oe(t.center.lng)),_(o,o,Oe(t.center.lat)),f(o,o,[0,0,ka]),m(o,o,[r,r,r*n]);const s=t.point;return f(o,o,[-s.x,-s.y,0]),p(o,o,e),p(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const r=(e,t,i)=>{const r=M(e),n=M(t),o=hc(e,t,i);return B(o,o,1/M(o)*xr(r,n,i))},n=r([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),o=r([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),s=r([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=hc([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return[n[0],n[1],n[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(n,i,r)}return n}function Kd(e,t,i,r){const n=Aabb.projectAabbCorners(r,i);let o=Number.MAX_VALUE;for(let e=0;e<n.length;++e){const i=n[e];i[0]=(.5*i[0]+.5)*t.width,i[1]=(.5-.5*i[1])*t.height,i[2]<o&&(o=i[2])}const s=function(e){const t=[];let i=0;for(let t=1;t<e.length;t++)(e[t][0]<e[i][0]||e[t][0]===e[i][0]&&e[t][1]<e[i][1])&&(i=t);let r,n=i;const o=new Uint8Array(e.length);do{if(o[n])break;t.push(new Le(e[n][0],e[n][1])),o[n]=1,r=(n+1)%e.length;for(let t=0;t<e.length;t++){if(e[t][0]===e[r][0]&&e[t][1]===e[r][1]||e[t][0]===e[n][0]&&e[t][1]===e[n][1])continue;const i=[e[t][0]-e[n][0],e[t][1]-e[n][1]],o=[e[r][0]-e[n][0],e[r][1]-e[n][1]],s=i[0]*o[1]-i[1]*o[0];(s>0||0===s&&i[0]*o[0]+i[1]*o[1]>=0&&i[0]*i[0]+i[1]*i[1]>o[0]*o[0]+o[1]*o[1])&&(r=t)}n=r}while(n!==i);return t.length>0&&t.push(t[0]),t}(n);if(Pl(e,s))return o}const Jd=[1,1,1];function Qd(e,t,i,r,n,o,s,a,l,c=!1){const h=i.zoom,d=i.project(r),_=al(r.lat,h),g=1/_;u(e),f(e,e,[d.x+s[0]*g,d.y+s[1]*g,s[2]]);let y=1,x=1;const v=i.worldSize;if(c){if("mercator"===i.projection.name){let e=0;i.elevation&&(e=i.elevation.getAtPointOrZero(new MercatorCoordinate(d.x/v,d.y/v),0));const t=se([],[d.x,d.y,e,1],i.projMatrix)[3]/i.cameraToCenterDistance;y=t,x=t*al(i.center.lat,h)}else if("globe"===i.projection.name){const t=Yd(e,i),n=[0,0,0,1];se(n,n,p([],i.projMatrix,t));const o=n[3]/i.cameraToCenterDistance,s=Ac(h),a=i.projection.pixelsPerMeter(r.lat,v)*al(r.lat,h),l=i.projection.pixelsPerMeter(i.center.lat,v)*al(i.center.lat,h);y=o/xr(a,sl(i.center.lat),s),x=o*_/a,y*=l,x*=l}}else y=g;m(e,e,[y,y,x]);const b=[...e],w=t.orientation,E=[];if(Wd(E,[w[0]+(n?n[0]:0),w[1]+(n?n[1]:0),w[2]+(n?n[2]:0)],o),p(e,b,E),a&&i.elevation){let n=0;const o=[];if(l&&i.elevation){n=function(e,t,i,r,n){const o=t.elevation;if(!o)return 0;const s=Aabb.projectAabbCorners(i,r),a=tl(1,n.lat)*t.worldSize,l=function(e,t){const i=[0,0,1],r=[{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 n of r){const r=e[n.corners[0]],o=e[n.corners[1]],s=e[n.corners[2]],a=[o[0]-r[0],o[1]-r[1],t*(o[2]-r[2])],l=q(a,a,[s[0]-r[0],s[1]-r[1],t*(s[2]-r[2])]);G(l,l),n.dotProductWithUp=H(l,i)}return r.sort(((e,t)=>e.dotProductWithUp-t.dotProductWithUp)),r[0].corners}(s,a),c=s[l[0]],u=s[l[1]],h=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new MercatorCoordinate(c[0]/t.worldSize,c[1]/t.worldSize),0),f=o.getAtPointOrZero(new MercatorCoordinate(u[0]/t.worldSize,u[1]/t.worldSize),0),m=o.getAtPointOrZero(new MercatorCoordinate(h[0]/t.worldSize,h[1]/t.worldSize),0),_=o.getAtPointOrZero(new MercatorCoordinate(d[0]/t.worldSize,d[1]/t.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f<m?Xd(e,u,d,c,f,_,p,a):Xd(e,h,c,d,m,p,_,a):p<_?Xd(e,c,u,h,p,f,m,a):Xd(e,d,h,u,_,m,f,a),Math.max(g,y)}(o,i,t.aabb,e,r);const s=p([],T([],o),E);p(e,b,s)}else n=i.elevation.getAtPointOrZero(new MercatorCoordinate(d.x/v,d.y/v),0);0!==n&&(e[14]+=n)}}class Model{constructor(e,t,i,r,n){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=t,this.position=null!=i?new LngLat(i[0],i[1]):new LngLat(0,0),this.orientation=null!=r?r:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,t){p(e.globalMatrix,t,e.localMatrix);const i=this.nodeOverrides.get(e.name);if(void 0!==i){const t=[];n=i.orientation,u(r=t),g(r,r,Oe(n[1])),y(r,r,Oe(n[2])),_(r,r,Oe(n[0])),p(e.globalMatrix,e.globalMatrix,t)}var r,n;if(e.meshes)for(const t of e.meshes){const i=Aabb.applyTransformFast(t.aabb,e.globalMatrix);this.aabb.encapsulate(i)}if(e.children)for(const t of e.children)this._applyTransformations(t,e.globalMatrix)}computeBoundsAndApplyParent(){const e=u([]);this.aabb=new Aabb([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,i,r,n,o,s=!1){Qd(this.matrix,this,e.transform,this.position,t,i,r,n,o,s)}upload(e){if(!this.uploaded){for(const t of this.nodes)ip(t,e);for(const e of this.nodes)rp(e);this.uploaded=!0}}destroy(){for(const e of this.nodes)np(e)}}function ep(e,t,i=!1){e.uploaded||(e.gfxTexture=new Texture(t,e.image,i?t.gl.R8:t.gl.RGBA8,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function tp(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Fd.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Ud.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,kd.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Od:Bd).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Nd.members,!0)),e.segments=SegmentVector.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&ep(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&ep(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&ep(r.normalTexture,t),r.occlusionTexture&&ep(r.occlusionTexture,t,i),r.emissionTexture&&ep(r.emissionTexture,t)}function ip(e,t,i){if(e.meshes)for(const r of e.meshes)tp(r,t,i);if(e.children)for(const r of e.children)ip(r,t,i)}function rp(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)rp(t)}function np(e){if(e.meshes)for(const i of e.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((t=i.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const t of e.children)np(t)}function op(e,t){const i=e.json.bufferViews[t.bufferView],r=yd[t.componentType];return new r(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==vd[t.type]*r.BYTES_PER_ELEMENT?i.byteStride/r.BYTES_PER_ELEMENT:vd[t.type]))}function sp(e,t,i,r){const n=yd[t.componentType],o=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}}(n),s=e.json.bufferViews[t.bufferView],a=s.byteStride?s.byteStride/n.BYTES_PER_ELEMENT:vd[t.type],l=i.float32,c=l.length/i.capacity;for(let e=0,i=0;e<t.count*a;e+=a,i+=c)for(let t=0;t<c;t++)l[i+t]=r[e+t]*o;i._trim()}function ap(e,t,i){const r=e.indices,n=e.attributes,o={};o.indexArray=new StructArrayLayout3ui6;const s=t.json.accessors[r],a=s.count/3;o.indexArray.reserve(a);const l=op(t,s);for(let e=0;e<a;e++)o.indexArray.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);o.indexArray._trim(),o.vertexArray=new StructArrayLayout3f12;const c=t.json.accessors[n.POSITION];o.vertexArray.reserve(c.count);const u=op(t,c);for(let e=0;e<c.count;e++)o.vertexArray.emplaceBack(u[3*e],u[3*e+1],u[3*e+2]);if(o.vertexArray._trim(),o.aabb=new Aabb(c.min,c.max),o.centroid=function(e,t){const i=[0,0,0],r=e.length;if(r>0){for(let n=0;n<r;n++){const r=3*e[n];i[0]+=t[r],i[1]+=t[r+1],i[2]+=t[r+2]}i[0]/=r,i[1]/=r,i[2]/=r}return i}(l,u),void 0!==n.COLOR_0){const e=t.json.accessors[n.COLOR_0],i=vd[e.type],r=op(t,e);o.colorArray=3===i?new StructArrayLayout3f12:new StructArrayLayout4f16,o.colorArray.resize(e.count),sp(t,e,o.colorArray,r)}if(void 0!==n.NORMAL){o.normalArray=new StructArrayLayout3f12;const e=t.json.accessors[n.NORMAL];o.normalArray.resize(e.count);const i=op(t,e);sp(t,e,o.normalArray,i)}if(void 0!==n.TEXCOORD_0&&i.length>0){o.texcoordArray=new StructArrayLayout2f8;const e=t.json.accessors[n.TEXCOORD_0];o.texcoordArray.resize(e.count);const i=op(t,e);sp(t,e,o.texcoordArray,i)}if(void 0!==n._FEATURE_ID_RGBA4444){const e=t.json.accessors[n._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=op(t,e))}void 0!==n._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(op(t,t.json.accessors[n._FEATURE_RGBA4444]).buffer));const h=e.material;return o.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:r="OPAQUE",alphaCutoff:n=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l,name:c}=e,{baseColorFactor:u=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=s?t[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&m){const e=s.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{name:c,pbrMetallicRoughness:{baseColorFactor:new Color(...u),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new Color(...i),alphaMode:r,alphaCutoff:n,normalTexture:o?t[o.index]:void 0,occlusionTexture:m,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},i),o}function lp(e,t,i){const{matrix:r,rotation:n,translation:o,scale:s,mesh:a,extras:l,children:u,name:h}=e,d={};if(d.name=h,d.localMatrix=r||function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3],l=n+n,c=o+o,u=s+s,h=n*l,d=n*c,p=n*u,f=o*c,m=o*u,_=s*u,g=a*l,y=a*c,x=a*u,v=r[0],b=r[1],w=r[2];return e[0]=(1-(f+_))*v,e[1]=(d+x)*v,e[2]=(p-y)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(h+_))*b,e[6]=(m+g)*b,e[7]=0,e[8]=(p+y)*w,e[9]=(m-g)*w,e[10]=(1-(h+f))*w,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}([],n||[0,0,0,1],o||[0,0,0],s||[1,1,1]),d.globalMatrix=c(d.localMatrix),void 0!==a){d.meshes=i[a];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:i,max:r}=t.aabb;e[0]+=i[0]+r[0],e[1]+=i[1]+r[1]}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2)}if(l&&(l.id&&(d.id=l.id),l.lights&&(d.lights=function(e){if(!e.length)return[];const t=function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.codePointAt(e);return i}(e),i=[],r=t.length/24,n=new Uint16Array(t.buffer),o=new Float32Array(t.buffer);for(let e=0;e<r;e++){const t=n[2*e*6]/30,r=n[2*e*6+1]/30,s=n[2*e*6+10]/100,a=o[6*e+1],l=o[6*e+2],c=o[6*e+3],u=o[6*e+4],h=c-a,d=u-l,p=Math.hypot(h,d);i.push({pos:[a+.5*h,l+.5*d,r],normal:[d/p,-h/p,0],width:p,height:t,depth:s,points:[a,l,c,u]})}return i}(l.lights)),l.MAPBOX_geometry_bloom&&(d.isGeometryBloom=l.MAPBOX_geometry_bloom)),u){const e=[];for(const r of u)e.push(lp(t.json.nodes[r],t,i));d.children=e}return d}function cp(e){if(0===e.vertices.length||0===e.indices.length)return null;const t=new TriangleGridIndex(e.vertices,e.indices,8,256),[i,r]=[t.min.clone(),t.max.clone()];return{vertices:e.vertices,indices:e.indices,grid:t,min:i,max:r}}function up(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 i=t[0];if(!i||!Array.isArray(i)||0===i.length)return null;const r=[];for(const e of i){if(!Array.isArray(e)||2!==e.length)continue;const t=e[0],i=e[1];"number"==typeof t&&"number"==typeof i&&r.push(new Le(t,i))}if(r.length<3)return null;r.length>1&&r[r.length-1].equals(r[0])&&r.pop();let n=0;for(let e=0;e<r.length;e++){const t=r[e],i=r[(e+1)%r.length],o=r[(e+2)%r.length];n+=(t.x-i.x)*(o.y-i.y)-(o.x-i.x)*(t.y-i.y)}n>0&&r.reverse();const o=ru(r.flatMap((e=>[e.x,e.y])),[]);return 0===o.length?null:{vertices:r,indices:o}}function hp(e,t){const i=[],r=[];let n=0;const o=[];for(const s of e){n=i.length;const e=s.vertexArray.float32,a=s.indexArray.uint16;for(let r=0;r<s.vertexArray.length;r++)o[0]=e[3*r+0],o[1]=e[3*r+1],o[2]=e[3*r+2],Z(o,o,t),i.push(new Le(o[0],o[1]));for(let e=0;e<3*s.indexArray.length;e++)r.push(a[e]+n)}if(r.length%3!=0)return null;for(let e=0;e<r.length;e+=3){const t=i[r[e+0]],n=i[r[e+1]],o=i[r[e+2]];(t.x-n.x)*(o.y-n.y)-(o.x-n.x)*(t.y-n.y)>0&&([r[e+1],r[e+2]]=[r[e+2],r[e+1]])}return{vertices:i,indices:r}}function dp(e){const t=function(e,t){const i=[],r=WebGL2RenderingContext;if(e.json.textures)for(const n of e.json.textures){const o={magFilter:r.LINEAR,minFilter:r.NEAREST,wrapS:r.REPEAT,wrapT:r.REPEAT};void 0!==n.sampler&&Object.assign(o,e.json.samplers[n.sampler]),i.push({image:t[n.source],sampler:o,uploaded:!1})}return i}(e,e.images),i=function(e,t){const i=[];for(const r of e.json.meshes){const n=[];for(const i of r.primitives)n.push(ap(i,e,t));i.push(n)}return i}(e,t),{scenes:r,scene:n,nodes:o}=e.json,s=r?r[n||0].nodes:[...o.keys()],a=[];for(const t of s)a.push(lp(o[t],e,i));return function(e,t,i){const r={},n=new Set;for(let o=0;o<e.length;o++){const e=i[t[o]];if(!e.extras)continue;const s=e.extras["mapbox:footprint:version"],a=e.extras["mapbox:footprint:id"];(s||a)&&n.add(o),"1.0.0"===s&&a&&(r[a]=o)}for(let o=0;o<e.length;o++){if(n.has(o))continue;const s=e[o],a=i[t[o]];if(!a.extras)continue;let l=null;s.id in r&&(l=hp(e[r[s.id]].meshes,s.localMatrix)),l||(l=up(a)),l&&(s.footprint=cp(l))}if(n.size>0){const t=Array.from(n.values()).sort(((e,t)=>e-t));for(let i=t.length-1;i>=0;i--)e.splice(t[i],1)}}(a,s,e.json.nodes),a}function pp(e,t,i,r,n){i.reserve(i.length+4*e.length),r.reserve(r.length+10*e.length),n.reserve(n.length+10*e.length);let o=r.length;for(const s of e){const e=Math.min(10,Math.max(4,1.3*s.height))*t,a=[-s.normal[1],s.normal[0],0],l=Math.min(.29,.1*s.width/s.depth),c=s.width-2*s.depth*t*(l+.01),u=k([],s.pos,a,c/2),h=k([],s.pos,a,-c/2),d=[u[0],u[1],u[2]+s.height],p=[h[0],h[1],h[2]+s.height],f=k([],s.normal,a,l);B(f,f,e);const m=k([],s.normal,a,-l);B(m,m,e),L(f,u,f),L(m,h,m),u[2]+=.1,h[2]+=.1,r.emplaceBack(f[0],f[1],f[2]),r.emplaceBack(m[0],m[1],m[2]),r.emplaceBack(u[0],u[1],u[2]),r.emplaceBack(h[0],h[1],h[2]),r.emplaceBack(d[0],d[1],d[2]),r.emplaceBack(p[0],p[1],p[2]),r.emplaceBack(u[0],u[1],u[2]),r.emplaceBack(h[0],h[1],h[2]),r.emplaceBack(f[0],f[1],f[2]),r.emplaceBack(m[0],m[1],m[2]);const _=c/e/2;n.emplaceBack(-_-l,-1,_,.8),n.emplaceBack(_+l,-1,_,.8),n.emplaceBack(-_,0,_,1.3),n.emplaceBack(_,0,_,1.3),n.emplaceBack(_+l,-.8,_,.7),n.emplaceBack(_+l,-.8,_,.7),n.emplaceBack(0,0,_,1.3),n.emplaceBack(0,0,_,1.3),n.emplaceBack(_+l,-1.2,_,.8),n.emplaceBack(_+l,-1.2,_,.8),i.emplaceBack(6+o,4+o,8+o),i.emplaceBack(7+o,9+o,5+o),i.emplaceBack(0+o,1+o,2+o),i.emplaceBack(1+o,3+o,2+o),o+=10}}const fp=_a([{name:"a_pos_3f",components:3,type:"Float32"}]),mp=_a([{name:"a_normal_3",components:3,type:"Int16"}]),_p=_a([{name:"a_centroid_3",components:3,type:"Int16"}]),gp=_a([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),yp=_a([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),xp=_a([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),vp=_a([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),bp=_a([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),wp=_a([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),Tp=VectorTileFeature.types,Ep=32767;function Sp(e,t){const i=Mn+t;for(const r of e)for(const e of r)if(e.x<-t||e.x>i||e.y<-t||e.y>i)return!1;return!0}function Ap(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 BuildingBloomGeometry{constructor(){this.layoutVertexArray=new StructArrayLayout3f12,this.layoutAttenuationArray=new StructArrayLayout4f16,this.layoutColorArray=new StructArrayLayout2ui4,this.indexArray=new StructArrayLayout3ui6,this.indexArrayForConflation=new StructArrayLayout3ui6,this.segmentsBucket=new SegmentVector}}class BuildingGeometry{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new SegmentVector,this.entranceBloom=new BuildingBloomGeometry;const t=66560;this.layoutVertexArray=new StructArrayLayout3f12,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new StructArrayLayout3i6,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new StructArrayLayout3i6,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new StructArrayLayout2ui4,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new StructArrayLayout1ui2,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new StructArrayLayout1ub1,this.layoutAOArray.reserve(t),this.indexArray=new StructArrayLayout3ui6,this.indexArray.reserve(66560),this.indexArrayForConflation=new StructArrayLayout3ui6,this.segmentsBucket=new SegmentVector,this.entranceBloom=new BuildingBloomGeometry,e&&(this.layoutFacadePaintArray=new StructArrayLayout2ui4,this.layoutFacadeDataArray=new StructArrayLayout4ui8,this.layoutFacadeVerticalRangeArray=new StructArrayLayout2ui4)}reserve(e,t,i){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),i&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e))}}class BuildingBucket{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new StructArrayLayout2f8,this.footprintsIndices=new StructArrayLayout1ui2,this.footprintsMin=new Le(1/0,1/0),this.footprintsMax=new Le(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new BuildingGeometry(!1),this.buildingWithFacade=new BuildingGeometry(!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 ProgramConfigurationSet(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 GroundEffect(e),this.groundEffect.groundRadiusArray=new StructArrayLayout1f4,this.hasAppearances=null}updateFootprints(e,t){const i=new TriangleGridIndex([],[],1),r={vertices:[],indices:new Uint32Array(0),grid:i,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:r,id:e})}updateAppearances(e,t,i,r){}prepare(){return function(){if(null!=fd||null!=pd)return null;if(null!=dd)return dd;const e=fetch(Mt.BUILDING_GEN_URL);return dd=function(e){let t,i,r,n,o;function s(){t=new Uint8Array(o.buffer),i=new Int16Array(o.buffer),r=new Int32Array(o.buffer),n=new Float32Array(o.buffer)}function a(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},c={a:{a,f:function(e){const i=t.length,r=Math.max(e>>>0,Math.ceil(1.2*i)),n=Math.ceil((r-i)/65536);try{return o.grow(n),s(),!0}catch(e){return!1}},g:a,b:l,c:l,d:l,e:l}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,c):e.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,c)))).then((e=>{const a=e.instance.exports;return(0,a.g)(),o=a.f,s(),new BuildingGen({setStyle:a.h,setAOOptions:a.i,setMetricOptions:a.j,setStructuralOptions:a.k,setFacadeOptions:a.l,setFauxFacadeOptions:a.m,setFacadeClassifierOptions:a.n,addFeature:a.o,addFacade:a.p,generateMesh:a.q,getLastError:a.r,getOuterRingLength:a.s,getMeshCount:a.t,getPositionsPtr:a.u,getPositionsLength:a.v,getNormalsPtr:a.w,getNormalsLength:a.x,getAOPtr:a.y,getAOLength:a.z,getUVPtr:a.A,getUVLength:a.B,getFauxFacadePtr:a.C,getFauxFacadeLength:a.D,getIndicesPtr:a.E,getIndicesLength:a.F,getBuildingPart:a.G,getRingCount:a.H,getRingPtr:a.I,getRingLength:a.J,malloc:a.K,free:a.L,heapU8:t,heap16:i,heap32:r,heapF32:n})}))}(e).then((e=>(dd=null,fd=e,fd))).catch((e=>{st("Could not load building-gen"),dd=null,pd=e})),dd}()}populate(e,t,i,r){const n=gd();if(!n)return;const o=cl(i);this.tileToMeter=o,this.brightness=t.brightness,n.setStyle({normalScale:[1,-1,o],tileToMeters:o}),n.setAOOptions(!1,.3),n.setMetricOptions(!1,16),n.setStructuralOptions(!0),n.setFacadeClassifierOptions(3);const s=new Map,a=new Map;let l=0;for(const{feature:t}of e){if("LineString"!==Tp[t.type]){s.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),t,i))continue;const n=yl(t,e);if(!e&&!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),n,i))continue;const o=e?n.geometry:gl(t,i,r),c=[];for(const e of o)for(const t of e)c.push(t.x),c.push(t.y);const u={coordinates:c,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},h=t.properties.source_id;let d=a.get(h);d||(d=[],a.set(h,d)),d.push(u),++l}this.maxHeight=0;const c=new Array,u=new Set,h=e=>{null!=e&&u.add(e)},d=(e,t)=>{null!=e&&c.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:c,index:p,sourceLayerIndex:f}of e){if("LineString"===Tp[l.type])continue;const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),l,i))continue;let m=null;if(l.properties&&l.properties.hasOwnProperty("building_id")&&(m=l.properties.building_id,u.has(m)))continue;const _=yl(l,e);if(!e&&!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),_,i))continue;const g=e?_.geometry:gl(l,i,r),y=Mu(g,500);let x=!1;for(const e of y)if(1!==e.length){x=!0;break}if(x){h(m);continue}if(!Sp(g,163)){h(m);continue}const v=this.layers[0],b=Ap(v.layout.get("building-roof-shape").evaluate(l,{},i)),w=v.layout.get("building-base").evaluate(l,{},i),T=v.layout.get("building-height").evaluate(l,{},i),E=v.layout.get("building-flood-light-ground-radius").evaluate(l,{},i),S=v.paint.get("building-ambient-occlusion-intensity"),A=E/this.tileToMeter;l.properties["building-part"]="roof";const I=v.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),C=v.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="wall";const M=v.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),D=v.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="window";const P=v.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),L=v.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="door";const R=v.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),z=v.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);let F=v.layout.get("building-flood-light-wall-radius").evaluate(l,{},i);F=He(F,0,2048);const O=F/2048*Ep,B=s.get(c),k=a.get(B)||[],U=0!==k.length&&v.layout.get("building-facade").evaluate(l,{},i);n.setFacadeOptions(4,!0),n.setFauxFacadeOptions(U,!1,1);let V=0,N=0,j=0,G=0,H=0,q=0,$=0,Z=0,W=0,X=0,Y=0;if(U){let e=Math.round(v.layout.get("building-facade-floors").evaluate(l,{},i));if(0===w){e=Math.max(1,e-(k.length>0?1:0));let t=4;if(T>100){const e=[10,13,15];t=e[l.id?l.id%e.length:0]}else T<=10&&(t=3);n.setFacadeOptions(t,!0),H=(T<15?1.3:1.61803)*t/o}else H=w/o;q=T/o,H=Math.min(H,q),j=v.layout.get("building-facade-unit-width").evaluate(l,{},i)/o,G=(q-H)/e,n.setFauxFacadeOptions(!0,!0,j);const t=v.layout.get("building-facade-window").evaluate(l,{},i);V=t[0],N=t[1],$=Math.floor(65535*Math.min(1,H/Mn)),Z=Math.floor(65535*Math.min(1,q/Mn)),W=Math.floor(255*V)<<8|Math.floor(255*N),X=Math.floor(65535*Math.min(1,j/Mn)),Y=Math.floor(65535*Math.min(1,G/Mn))}const K=Array(y.length),J={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<y.length;e++){const t=y[e];if(t.length>0){const i=[],r=Array(t.length+1);r[0]=0;for(let e=0;e<t.length;e++){const n=t[e];for(let e=0;e<n.length;e++){const t=n[n.length-e-1];J.x=Math.min(J.x,t.x),J.y=Math.min(J.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++,i.push(t.x),i.push(t.y)}r[e+1]=i.length}K[e]={id:l.id?l.id:0,height:T,minHeight:w,sourceId:0,roofType:b,coordinates:i,ringIndices:r}}}ee.x/=te||1,ee.y/=te||1;const ie=n.generateMesh(K,k);if("string"==typeof ie){st(`Unable to generate building ${l.id}: ${ie}`),h(m);continue}if(0===ie.meshes.length||0===ie.modifiedPolygonRings.length){h(m);continue}const re=U?this.buildingWithFacade:this.buildingWithoutFacade;let ne=0;for(const e of ie.meshes)ne+=e.positions.length/3;const oe=re.segmentsBucket.prepareSegment(ne,re.layoutVertexArray,re.indexArray),se=[];let ae=null,le=0,ce=-1;const ue=re.layoutVertexArray.length,he=ue+ne;re.layoutVertexArray.resize(he),re.layoutCentroidArray.resize(he),re.layoutNormalArray.resize(he),re.layoutAOArray.resize(he),re.layoutColorArray.resize(he),re.layoutFloodLightDataArray.resize(he),U&&(re.layoutFacadePaintArray.resize(he),re.layoutFacadeDataArray.resize(he),re.layoutFacadeVerticalRangeArray.resize(he));const de=re.indexArray.length;let pe=0,fe=ue;for(const e of ie.meshes){let t,i;if(1===e.buildingPart)t=I,i=C;else if(0===e.buildingPart)t=M,i=D;else if(2===e.buildingPart)t=P,i=L;else{if(3!==e.buildingPart)continue;t=R,i=z}if(i=He(i,0,1),3===e.buildingPart){const t=new Array;for(let i=0;i<e.positions.length;i+=12){const r=e.positions[i+0],n=e.positions[i+1],o=e.positions[i+3],s=e.positions[i+4],a=e.positions[i+2],l=e.positions[i+8]-a,c=1,u=o-r,h=s-n,d=Math.hypot(u,h);t.push({pos:[r+.5*u,n+.5*h,a],normal:[h/d,-u/d,0],width:d,height:l,depth:c,points:[r,n,o,s]})}const i=re.entranceBloom.segmentsBucket.prepareSegment(10*t.length,re.entranceBloom.layoutVertexArray,re.entranceBloom.indexArray),r=re.entranceBloom.layoutVertexArray.length;le=re.entranceBloom.indexArray.length,pp(t,.5/this.tileToMeter,re.entranceBloom.indexArray,re.entranceBloom.layoutVertexArray,re.entranceBloom.layoutAttenuationArray);const n=re.entranceBloom.layoutVertexArray.length-r;ce=re.entranceBloom.indexArray.length-le;for(let e=0;e<n;e++)re.entranceBloom.layoutColorArray.emplaceBack(255*R.r<<8|255*R.g,255*R.b<<8|51*z);i.vertexLength+=n,i.primitiveLength+=ce,ae={part:e.buildingPart,vertexOffset:r,vertexLength:n}}re.layoutVertexArray.float32.set(e.positions,3*fe);const r=e.positions.length/3;for(let n=0;n<r;++n){const r=3*n;pe=Math.max(pe,e.positions[r+2]);const o=e.normals[r+1]*Ep,s=e.normals[r+2]*Ep,a=3*(fe+n);re.layoutNormalArray.int16[a]=e.normals[r]*Ep,re.layoutNormalArray.int16[a+1]=o,re.layoutNormalArray.int16[a+2]=s;const l=e.ao[n];re.layoutAOArray.uint8[fe+n]=255*l;const c=1+(l-1)*S,u=255*t.b*c<<8|255*i;re.layoutColorArray.uint16[2*(fe+n)]=255*t.r*c<<8|255*t.g*c,re.layoutColorArray.uint16[2*(fe+n)+1]=u}const n=Math.floor(ee.x),o=Math.floor(ee.y),s=Math.floor(T);for(let e=0;e<r;++e){const t=3*(fe+e);re.layoutCentroidArray.int16[t]=n,re.layoutCentroidArray.int16[t+1]=o,re.layoutCentroidArray.int16[t+2]=s}if(re.layoutFloodLightDataArray.uint16.fill(0===e.buildingPart?O:0,fe,fe+r),U){const t=255*P.r<<8|255*P.g,i=255*P.b<<8|255*L;for(let e=0;e<r;++e){const r=2*(fe+e);re.layoutFacadePaintArray.uint16[r]=t,re.layoutFacadePaintArray.uint16[r+1]=i}for(let t=0;t<r;++t)if(e.isFauxFacade[t]){const i=Math.min(65535,Math.floor(e.uv[2*t]*ie.outerRingLength));re.layoutFacadeDataArray.emplace(fe+t,1|i,W,X,Y),re.layoutFacadeVerticalRangeArray.emplace(fe+t,$,Z)}else re.layoutFacadeDataArray.emplace(fe+t,0,0,0,0),re.layoutFacadeVerticalRangeArray.emplace(fe+t,0,0)}const a=oe.vertexLength,l=e.indices.length/3,c=re.indexArray.length;re.indexArray.resize(c+l);for(let t=0;t<l;++t){const i=3*t,r=3*c+i;re.indexArray.uint16[r]=a+e.indices[i],re.indexArray.uint16[r+1]=a+e.indices[i+1],re.indexArray.uint16[r+2]=a+e.indices[i+2]}1!==e.buildingPart&&0!==e.buildingPart&&2!==e.buildingPart&&3!==e.buildingPart||se.push({part:e.buildingPart,vertexOffset:fe,vertexLength:e.positions.length/3}),fe+=r,oe.vertexLength+=r,oe.primitiveLength+=e.indices.length/3}this.maxHeight=Math.max(this.maxHeight,pe);const me=re.indexArray.length-de,_e=this.footprintsIndices.length,ge=this.footprintsVertices.length,ye=[],xe=new Le(1/0,1/0),ve=new Le(-1/0,-1/0),be=this.groundEffect.vertexArray.length;for(const e of ie.modifiedPolygonRings){const t=[],i=new Le(1/0,1/0),r=new Le(-1/0,-1/0);for(let n=0;n<e.length;n+=2){const o=e.length-n-2;i.x=Math.min(i.x,e[o]),i.y=Math.min(i.y,e[o+1]),r.x=Math.max(r.x,e[o]),r.y=Math.max(r.y,e[o+1]);const s=new Le(e[o],e[o+1]);t.push(s),ye.push(s.x,s.y),this.footprintsVertices.emplaceBack(s.x,s.y)}xe.x=Math.min(xe.x,i.x),xe.y=Math.min(xe.y,i.y),ve.x=Math.max(ve.x,r.x),ve.y=Math.max(ve.y,r.y),this.groundEffect.addData(t,[i,r],A)}const we=this.groundEffect.vertexArray.length-be;this.groundEffect.groundRadiusArray.reserveForAdditional(we);for(let e=0;e<we;e++)this.groundEffect.groundRadiusArray.emplaceBack(E);(J.x<0||Q.x>Mn||J.y<0||Q.y>Mn)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{const e=ru(ye,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+e.length),this.footprintsIndices.uint16.set(e,_e),this.buildingIds.add(null!=m?m:l.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,xe.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,xe.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,ve.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,ve.y);const t={footprintVertexOffset:ge,footprintVertexLength:this.footprintsVertices.length-ge,footprintIndexOffset:_e,footprintIndexLength:this.footprintsIndices.length-_e,min:xe,max:ve,hiddenFlags:0,indicesOffset:de,indicesLength:me,bloomIndicesOffset:le,bloomIndicesLength:ce,groundEffectVertexOffset:be,groundEffectVertexLength:we,hasFauxFacade:U,height:pe,promoteId:c,feature:_,parts:se,buildingBloom:ae},i=this.footprints.length;void 0!==l.id&&this.featureFootprintLookup.set(l.id,i),d(m,i),this.footprints.push(t)}this.programConfigurations.populatePaintArrays(re.layoutVertexArray.length,l,p,{},t.availableImages,i,t.brightness),this.groundEffect.addPaintPropertiesData(l,p,{},t.availableImages,i,t.brightness),t.featureIndex.insert(l,g,p,f,this.index,ue)}c.forEach((({buildingId:e,footprintIndex:t})=>{u.has(e)&&(this.footprints[t].hiddenFlags|=4)}));const m=new Set;this.buildingIds.forEach(((e,t,i)=>{u.has(e)||m.add(e)})),this.buildingIds=m,this.groundEffect.prepareBorderSegments()}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s),this.groundEffect.update(e,t,n,i,r,o,s),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,fp.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,mp.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,_p.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,wp.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,xp.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,vp.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,fp.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,bp.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,i=!0){let r=!1;const n=i?t:0,o=0|(i?-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],i=e.hiddenFlags&o|n;e.hiddenFlags!==i&&(e.hiddenFlags=i,r=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags))}return r&&(this.indexArrayForConflationUploaded=!1),r}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,i=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let r=e.indicesOffset;r<i;r++)t.indexArrayForConflation.uint16[3*r+0]=0,t.indexArrayForConflation.uint16[3*r+1]=0,t.indexArrayForConflation.uint16[3*r+2]=0;const r=e.bloomIndicesOffset+e.bloomIndicesLength;for(let i=e.bloomIndicesOffset;i<r;i++)t.entranceBloom.indexArrayForConflation.uint16[3*i+0]=0,t.entranceBloom.indexArrayForConflation.uint16[3*i+1]=0,t.entranceBloom.indexArrayForConflation.uint16[3*i+2]=0}}const i=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))};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,gp.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,yp.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,gp.members,!0)};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,t){const i=e.paint.get("building-ambient-occlusion-intensity");for(const r of this.footprints){if(4&r.hiddenFlags)continue;const n=t[r.promoteId],o=r.feature;o.properties["building-part"]="roof";const s=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),a=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),c=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="window";const u=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical),f=r.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of r.parts){let t,n=s;1===e.part?(n=s,t=a):0===e.part?(n=l,t=c):2===e.part?(n=u,t=h):3===e.part&&(n=d,t=p),t=He(t,0,1);for(let o=0;o<e.vertexLength;o++){const s=e.vertexOffset+o,a=1+(f.layoutAOArray.uint8[s]/255-1)*i;f.layoutColorArray.emplace(s,n.r*a*255<<8|n.g*a*255,n.b*a*255<<8|255*t),r.hasFauxFacade&&f.layoutFacadePaintArray.emplace(s,255*u.r<<8|255*u.g,255*u.b<<8|255*h)}}const m=r.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,i){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped());if(ah(this.activeReplacements,r))return;this.activeReplacements=r;for(const e of this.footprints)e.hiddenFlags&=-2;const n=[];for(const t of this.activeReplacements){if(t.order<=ih)continue;const i=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||(n.length=0,Cp(this.footprintsVertices,r.footprintVertexOffset,r.footprintVertexLength,t.footprintTileId.canonical,e.canonical,n),uh(t.footprint,n,this.footprintsIndices.uint16,r.footprintIndexOffset,r.footprintIndexLength,0,-i)&&(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 i=Number.NEGATIVE_INFINITY,r=!0;const n=4*(e+Mn)*Mn+(t+Mn);if(this.footprintLookup.hasOwnProperty(n)){const e=this.footprintLookup[n];return e?{height:e.height,hidden:0!==e.hiddenFlags}:void 0}const o=new Le(e,t);for(const s of this.footprints)e>s.max.x||s.min.x>e||t>s.max.y||s.min.y>t||s.height<=i||Ip(o,this.footprintsVertices.float32.subarray(2*s.footprintVertexOffset,2*(s.footprintVertexOffset+s.footprintVertexLength)),this.footprintsIndices.uint16.subarray(s.footprintIndexOffset,s.footprintIndexOffset+s.footprintIndexLength))&&(i=s.height,this.footprintLookup[n]=s,r=0!==s.hiddenFlags);if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:r};this.footprintLookup[n]=void 0}}function Ip(e,t,i){for(let r=0;r<i.length;r+=3){const n=i[r],o=i[r+1],s=i[r+2],a=t[2*n+0],l=t[2*n+1],c=t[2*o+0],u=t[2*o+1],h=t[2*s+0],d=t[2*s+1],p=(a-h)*(e.y-d)-(l-d)*(e.x-h),f=(c-a)*(e.y-l)-(u-l)*(e.x-a);if(p<0!=f<0&&0!==p&&0!==f)continue;const m=(h-c)*(e.y-u)-(d-u)*(e.x-c);if(0===m||m<0==p+f<=0)return!0}return!1}function Cp(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a<i;a++){let i=e.float32[2*(a+t)+0],l=e.float32[2*(a+t)+1];i=(i+n.x*Mn)*s-r.x*Mn,l=(l+n.y*Mn)*s-r.y*Mn,o.push(new Le(i,l))}}let Mp,Dp;bs(BuildingBucket,"BuildingBucket",{omit:["layers"]}),bs(BuildingGeometry,"BuildingGeometry"),bs(BuildingBloomGeometry,"BuildingBloomGeometry");const Pp=_a([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),Lp=_a([{name:"a_z_offset_width",components:3,type:"Float32"}],4),{members:Rp}=Pp,zp=_a([{name:"a_packed",components:3,type:"Float32"}]),{members:Fp}=zp,Op=_a([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:Bp}=Op;bs(class LineAtlas{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new AlphaImage({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=Je(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const r=[];let n=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];n=a*i,a+=l,o=a*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l})}return r}addRoundDash(e,t,i){const r=t/2;for(let t=-i;t<=i;t++){const n=this.width*(this.nextRow+i+t);let o=0,s=e[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=r-Math.sqrt(u*u+d*d);this.image.data[n+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i<this.width;i++){i/s.right>1&&(s=e[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return st("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;t<e.length;t++)e[t]<0&&(st("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),s+=e[t];if(0!==s){const i=this.width/s,o=this.getDashRanges(e,this.width,i);r?this.addRoundDash(o,i,n):this.addRegularDash(o,"square"===t?.5*i:0)}const a=this.nextRow+n;this.nextRow+=o;const l={tl:[a,n],br:[s,0]};return this.positions[i]=l,l}},"LineAtlas");const kp=VectorTileFeature.types,Up=Math.cos(Math.PI/180*37.5),Vp=Math.cos(Math.PI/180*5);class LineBucket{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",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 StructArrayLayout2i4ub1f12,this.layoutVertexArray2=new StructArrayLayout3f12,this.patternVertexArray=new StructArrayLayout3f12,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new SegmentVector,this.maxLineLength=0,this.zOffsetVertexArray=new StructArrayLayout3f12,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.tessellationStep=e.tessellationStep?e.tessellationStep:Mn/64,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,r){}populate(e,t,i,r){this.hasPattern=Lu("line",this.layers,this.pixelRatio,t);const n=this.layers[0].layout.get("line-sort-key");this.tileToMeter=cl(i);const o=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===o)this.elevationType="road";else{const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==o&&"ground"!==o&&t?"none":"offset","offset"===this.elevationType&&"none"===o&&st(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==s;const a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=yl(o,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=n?n.evaluate(u,{},i):void 0,d={id:s,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:gl(o,i,r),patterns:{},sortKey:h};a.push(d)}n&&a.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:l,featureIndex:c}=t,u=this.addConstantDashes(l);for(const r of a){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(u&&this.addFeatureDashes(r,l),this.hasPattern){const e=Ru("line",this.layers,r,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,l.positions,t.availableImages,t.brightness,t.elevationFeatures);c.insert(e[o].feature,n,o,s,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,i=r.value;if(!i)continue;e.addDash(i,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a;if("constant"===n.kind){if(s=n.value,!s)continue}else s=n.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[r.id]=[t.getKey(s,a)]}}update(e,t,i,r,n,o,s,a){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,a)}addFeatures(e,t,i,r,n,o){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,r,o,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,Fp)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Bp)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Lp.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rp),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,t){let i,r;if(t&&t>0?(i=`mapbox_clip_start_${t}`,r=`mapbox_clip_end_${t}`):(i="mapbox_clip_start",r="mapbox_clip_end"),e.properties&&e.properties.hasOwnProperty(i)&&e.properties.hasOwnProperty(r))return{start:+e.properties[i],end:+e.properties[r]}}addFeature(e,t,i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(e,{}),u=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),"road"===this.elevationType){const i=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,r,a,c,u,h,d)){const[n,o]=this.clipRuntimeLinesToTile(t,1);for(let t=0;t<n.length;t++){const i=n[t],s=o[t],a={progress:{min:s.progress.min,max:s.progress.max},nextDir:this.computeSegNextDir(s,i),prevDir:this.computeSegPrevDir(s,i)};this.addLine(i,e,r,c,u,h,d,a,p&&s.parentIndex>0?s.parentIndex:null)}this.fillNonElevatedRoadSegment(i)}}else for(let i=0;i<t.length;i++)this.addLine(t[i],e,r,c,u,h,d,void 0,p&&i>0?i:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s,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 $h(e,-t,-t,Mn+t,Mn+t)}clipRuntimeLinesToTile(e,t){const i=[];return[$h(e,-t,-t,Mn+t,Mn+t,i),i]}addElevatedRoadFeature(e,t,i,r,n,o,s,a){const l=[],c=ElevationFeatures.getElevationFeature(e,r);if(c){const e=this.clipLinesToTile(t,1),r=this.prepareElevatedLines(e,c,i);for(const e of r)l.push({geometry:e,elevation:c,elevationTileID:i,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(0===l.length)return!1;for(const t of l){const r=this.layoutVertexArray.length;this.addLine(t.geometry,e,i,n,o,s,a);const l=new ElevationFeatureSampler(i,t.elevationTileID);if(t.elevation)for(let e=r;e<this.layoutVertexArray.length;e++){const i=new Le(this.layoutVertexArray.int16[6*e]>>1,this.layoutVertexArray.int16[6*e+1]>>1),r=l.pointElevation(i,t.elevation,.05);this.updateHeightRange(r),this.zOffsetVertexArray.emplaceBack(r,0,0)}else this.fillNonElevatedRoadSegment(r)}return!0}prepareElevatedLines(e,t,i){if(null!=t.constantHeight)return e;const r=[],n=1/cl(i);for(const i of e)Zh(i,new EdgeIterator(t,n),0,r);return r}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,i,r,n,o,s,a,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 c="none"===r;this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];const u=a&&a.progress.min>0,h=a&&a.progress.max<1;if(this.lineClips){let i={min:this.lineClips.start,max:this.lineClips.end},r=1;if(a){const e=this.lineClips.end-this.lineClips.start;i=function(e,t,i){return{min:St(e.min,t,i),max:St(e.max,t,i)}}(a.progress,{min:0,max:1},i),e>0&&(r=(i.max-i.min)/e)}const n=+t.properties.mapbox_clip_feature_len,o=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(n)||Number.isNaN(o)){for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);const t=this.totalDistance/(i.max-i.min);this.totalFeatureLength=Number.isFinite(t)?t:0,this.lineClips.start=i.min,this.lineClips.end=i.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=n,this.distance=o*r,this.lineClips.start=i.min,this.lineClips.end=i.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}const d="Polygon"===kp[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"===r&&(o=1.05);const m=this.segments.prepareSegment(10*p,this.layoutVertexArray,this.indexArray);let _,g,y,x,v,b,w,T;a&&a.prevDir&&(b=a.prevDir.perp()),a&&a.nextDir&&(w=a.nextDir.perp()),this.e1=this.e2=-1,d&&(_=e[p-2],v=e[f].sub(_)._unit()._perp());for(let t=f;t<p;t++){if(y=t===p-1?d?e[f+1]:void 0:e[t+1],y&&e[t].equals(y))continue;v&&(x=v),_&&(g=_),_=e[t],T=this.evaluateLineProgressFeatures(g?g.dist(_):0),v=y?y.sub(_)._unit()._perp():x,x=x||v;const i=g&&y;let a=i?r:d||c?"butt":n;const l=x.x*v.x+x.y*v.y;if(c){const e=function(e){if(e.patternJoinNone){const t=e.segmentPoints.length/2,i=e.lineSoFar-e.segmentStart;for(let r=0;r<t;++r){const t=e.segmentPoints[2*r+1],n=Math.round(e.segmentPoints[2*r])+.5+.25*t;e.patternVertexArray.emplaceBack(n,i,e.segmentStart),e.patternVertexArray.emplaceBack(n,i,e.segmentStart)}e.segmentPoints.length=0}e.e1=e.e2=-1};if(i&&l<Vp){this.updateDistance(g,_),this.addCurrentVertex(_,x,1,1,m,T),e(this),this.addCurrentVertex(_,v,-1,-1,m,T);continue}if(g){if(!y){this.updateDistance(g,_),this.addCurrentVertex(_,x,1,1,m,T),e(this);continue}a="miter"}}let E=x.add(v);0===E.x&&0===E.y||E._unit();const S=E.x*v.x+E.y*v.y,A=0!==S?1/S:1/0,I=2*Math.sqrt(2-2*S),C=S<Up&&g&&y,M=x.x*v.y-x.y*v.x>0,D=this.overscaling<=16?15*Mn/(512*this.overscaling):0;if(i&&"round"===a)if(A<s)a="miter";else if(A<=2){const e=Np(_,-10,Mn+10);a="offset"===this.elevationType&&(e||this.hasCrossSlope)?"miter":"fakeround"}if("miter"===a&&A>o&&(a="bevel"),"bevel"===a&&(A>2&&(a="flipbevel"),A<o&&(a="miter")),g&&!("miter"===a&&C)&&this.updateDistance(g,_),"miter"===a)if(C){const e=_.dist(g);if(e>2*D){const t=_.sub(_.sub(g)._mult(D/e)._round());this.updateDistance(g,t),this.addCurrentVertex(t,x,0,0,m,T),g=t}this.updateDistance(g,_),E._mult(A),this.addCurrentVertex(_,E,0,0,m,T);const t=_.dist(y);if(t>2*D){const e=_.add(y.sub(_)._mult(D/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,v,0,0,m,T),_=e}}else E._mult(A),this.addCurrentVertex(_,E,0,0,m,T);else if("flipbevel"===a){if(A>100)E=v.mult(-1);else{const e=A*x.add(v).mag()/x.sub(v).mag();E._perp()._mult(e*(M?-1:1))}this.addCurrentVertex(_,E,0,0,m,T),this.addCurrentVertex(_,E.mult(-1),0,0,m,T)}else if("bevel"===a||"fakeround"===a){null!=T&&g&&this.addCurrentVertex(_,w||x,-1,-1,m,T);const e=_.dist(g)<=2*D&&"bevel"!==a,t=E.mult(M?1:-1);t._mult(A);const i=v.mult(M?-1:1),r=x.mult(M?-1:1),n=this.evaluateLineProgressFeatures(this.distance);if(null==T&&(this.addHalfVertex(_,t.x,t.y,!1,!M,0,m,n),e||this.addHalfVertex(_,t.x+2*r.x,t.y+2*r.y,!1,M,0,m,n)),"fakeround"===a){const e=Math.round(180*I/Math.PI/20);this.addHalfVertex(_,r.x,r.y,!1,M,0,m,n);for(let t=0;t<e;t++){let o=t/e;if(.5!==o){const e=o-.5;o+=o*e*(o-1)*((1.0904+l*(l*(3.55645-1.43519*l)-3.2452))*e*e+(.848013+l*(.215638*l-1.06021)))}const s=i.sub(r)._mult(o)._add(r)._unit();this.addHalfVertex(_,s.x,s.y,!1,M,0,m,n)}this.addHalfVertex(_,i.x,i.y,!1,M,0,m,n)}e||null!=T||this.addHalfVertex(_,t.x+2*i.x,t.y+2*i.y,!1,M,0,m,n),null!=T&&y&&this.addCurrentVertex(_,b||v,1,1,m,T)}else if("butt"===a)this.addCurrentVertex(_,E,0,0,m,T);else if("square"===a){if(!g){const e=u?0:-1;this.addCurrentVertex(_,E,e,e,m,T)}if(this.addCurrentVertex(_,E,0,0,m,T),g){const e=h?0:1;this.addCurrentVertex(_,E,e,e,m,T)}}else if("round"===a){if(g){const e=!i&&w?w:x;this.addCurrentVertex(_,e,0,0,m,T),!i&&h||this.addCurrentVertex(_,e,1,1,m,T,!0)}if(y){const e=!i&&b?b:v;!i&&u||this.addCurrentVertex(_,e,-1,-1,m,T,!0),this.addCurrentVertex(_,e,0,0,m,T)}}}}addVerticesTo(e,t,i,r,n,o,s,a,l,c){const u=(t.w-e.w)/this.tessellationStep|0;let h=0;const d=this.scaledDistance;if(u>1){this.lineSoFar=e.w;const d=(t.x-e.x)/u,p=(t.y-e.y)/u,f=(t.z-e.z)/u,m=(t.w-e.w)/u;for(let t=1;t<u;++t){e.x+=d,e.y+=p,e.z+=f,this.lineSoFar+=m,h+=m;const t=this.evaluateLineProgressFeatures(this.prevDistance+h);this.scaledDistance=(this.prevDistance+h)/this.totalDistance,this.addHalfVertex(e,i,r,c,!1,s,l,t),this.addHalfVertex(e,n,o,c,!0,-a,l,t)}}this.lineSoFar=t.w,this.scaledDistance=d;const p=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(t,i,r,c,!1,s,l,p),this.addHalfVertex(t,n,o,c,!0,-a,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):st(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let t=0;return this.variableWidthValue&&"constant"!==this.variableWidthValue.kind&&(t=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0),"offset"!==this.elevationType?{zOffset:0,variableWidth:t}:"constant"===this.zOffsetValue.kind?{zOffset:this.zOffsetValue.value,variableWidth:t}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:t}}addCurrentVertex(e,t,i,r,n,o,s=!1){const a=t.x+t.y*i,l=t.y-t.x*i,c=t.y*r-t.x,u=-t.y-t.x*r;if(null!=o){const t="offset"===this.elevationType,h=-10,d=Mn+10,p=o.zOffset,f=new Point4D(e.x,e.y,p,this.lineSoFar),m=!!t&&Np(e,h,d),_=this.lineSoFar,g=this.distance;if(this.currentVertex)if(m){const t=this.currentVertexIsOutside,o=this.currentVertex,m=new Point4D(e.x,e.y,p,this.lineSoFar);if(qh(o,m,h,d),!Np(m,h,d)){if(t){this.e1=this.e2=-1,this.distance-=o.dist(f),this.lineSoFar=o.w;const e=this.evaluateLineProgressFeatures(o.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(o,a,l,s,!1,i,n,e),this.addHalfVertex(o,c,u,s,!0,-r,n,e),this.prevDistance=this.distance}this.distance=this.prevDistance+o.dist(m),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(o,m,a,l,c,u,i,r,n,s),this.distance=g,this.scaledDistance=this.distance/this.totalDistance}}else{const e=this.currentVertex;if(this.currentVertexIsOutside){qh(e,f,h,d),this.e1=this.e2=-1,this.distance-=e.dist(f),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,a,l,s,!1,i,n,t),this.addHalfVertex(e,c,u,s,!0,-r,n,t),this.prevDistance=this.distance,this.distance=g,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(e,f,a,l,c,u,i,r,n,s)}else m||(this.addHalfVertex(e,a,l,s,!1,i,n,o),this.addHalfVertex(e,c,u,s,!0,-r,n,o));this.currentVertex=f,this.currentVertexIsOutside=m,this.lineSoFar=_}else this.addHalfVertex(e,a,l,s,!1,i,n,o),this.addHalfVertex(e,c,u,s,!0,-r,n,o)}addHalfVertex({x:e,y:t},i,r,n,o,s,a,l){if(this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),o||this.segmentPoints.push(this.lineSoFar-this.segmentStart,s)),this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){const e=xr(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,e)}const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth)}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 Np(e,t,i){return e.x<t||e.x>i||e.y<t||e.y>i}let jp,Gp;function Hp(e,t,i){return t*(Mn/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}bs(LineBucket,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const qp=(e,t,i)=>(1-i)*e+i*t,$p=(e,t,i,r,n,o,s,a,l,c)=>{const u=e.transform,h=u.calculatePixelsToTileUnitsMatrix(t),d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default"),p=u.pitch<15?qp(.07,.7,He((14-u.zoom)/5,0,1)):.07;return{u_matrix:Xp(e,t,i,r),u_pixels_to_tile_units:h,u_device_pixel_ratio:o,u_width_scale:s,u_floor_width_scale:a,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:Kp(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Wp(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_zbias_factor:p,u_tile_to_meter:cl(t.tileID.canonical,0),u_ground_shadow_factor:c}},Zp=(e,t,i,r,n,o,s,a,l,c)=>{const u=e.transform,h=u.pitch<15?qp(.07,.7,He((14-u.zoom)/5,0,1)):.07,d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default");return{u_matrix:Xp(e,t,i,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:u.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_width_scale:o,u_floor_width_scale:s,u_image:0,u_tile_units_to_pixels:Wp(t,u),u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_zbias_factor:h,u_tile_to_meter:cl(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:c}};function Wp(e,t){return 1/Hp(e,1,t.tileZoom)}function Xp(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Yp=e=>{const t=[];Kp(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const r="none"===e.layout.get("line-join").constantOr("miter"),n=!!e.paint.get("line-pattern").constantOr(1);return r&&n&&t.push("LINE_JOIN_NONE"),t};function Kp(e){const t=e.paint.get("line-dasharray").value;return"constant"!==t.kind||t.value}let Jp;const Qp=()=>Jp||(Jp={layout:jp||(jp=new Properties({"line-cap":new DataDrivenProperty(Gs.layout_line["line-cap"]),"line-join":new DataDrivenProperty(Gs.layout_line["line-join"]),"line-miter-limit":new DataConstantProperty(Gs.layout_line["line-miter-limit"]),"line-round-limit":new DataConstantProperty(Gs.layout_line["line-round-limit"]),"line-sort-key":new DataDrivenProperty(Gs.layout_line["line-sort-key"]),"line-z-offset":new DataDrivenProperty(Gs.layout_line["line-z-offset"]),"line-elevation-reference":new DataConstantProperty(Gs.layout_line["line-elevation-reference"]),"line-cross-slope":new DataConstantProperty(Gs.layout_line["line-cross-slope"]),visibility:new DataConstantProperty(Gs.layout_line.visibility),"line-width-unit":new DataConstantProperty(Gs.layout_line["line-width-unit"])})),paint:Gp||(Gp=new Properties({"line-opacity":new DataDrivenProperty(Gs.paint_line["line-opacity"]),"line-color":new DataDrivenProperty(Gs.paint_line["line-color"]),"line-translate":new DataConstantProperty(Gs.paint_line["line-translate"]),"line-translate-anchor":new DataConstantProperty(Gs.paint_line["line-translate-anchor"]),"line-width":new DataDrivenProperty(Gs.paint_line["line-width"]),"line-gap-width":new DataDrivenProperty(Gs.paint_line["line-gap-width"]),"line-offset":new DataDrivenProperty(Gs.paint_line["line-offset"]),"line-blur":new DataDrivenProperty(Gs.paint_line["line-blur"]),"line-dasharray":new DataDrivenProperty(Gs.paint_line["line-dasharray"]),"line-pattern":new DataDrivenProperty(Gs.paint_line["line-pattern"]),"line-pattern-cross-fade":new DataConstantProperty(Gs.paint_line["line-pattern-cross-fade"]),"line-gradient":new ColorRampProperty(Gs.paint_line["line-gradient"]),"line-trim-offset":new DataConstantProperty(Gs.paint_line["line-trim-offset"]),"line-trim-fade-range":new DataConstantProperty(Gs.paint_line["line-trim-fade-range"]),"line-trim-color":new DataConstantProperty(Gs.paint_line["line-trim-color"]),"line-emissive-strength":new DataDrivenProperty(Gs.paint_line["line-emissive-strength"]),"line-border-width":new DataDrivenProperty(Gs.paint_line["line-border-width"]),"line-border-color":new DataDrivenProperty(Gs.paint_line["line-border-color"]),"line-occlusion-opacity":new DataConstantProperty(Gs.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},Jp);class LineFloorwidthProperty extends DataDrivenProperty{possiblyEvaluate(e,t){return t=new EvaluationParameters(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}let ef;function tf(e,t){return t>0?t+2*e:e}const rf=_a([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),nf=_a([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),of=_a([{name:"a_projected_pos",components:4,type:"Float32"}],4);_a([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const sf=_a([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),af=_a([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),lf=_a([{name:"a_texb",components:2,type:"Uint16"}]),cf=_a([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),uf=_a([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);_a([{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 hf=_a([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),df=_a([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function pf(e,t,i){return e.sections.forEach((e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),e}(e.text,t,i)})),e}_a([{name:"triangle",components:3,type:"Uint16"}]),_a([{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"}]),_a([{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"}]),_a([{type:"Float32",name:"offsetX"}]),_a([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const ff={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"},mf=4294967296,_f=1/mf,gf="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let yf=class Pbf{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,i=this.length){for(;this.pos<i;){const i=this.readVarint(),r=i>>3,n=this.pos;this.type=7&i,e(r,t,this),this.pos===n&&this.skip(i)}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)*mf;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*mf;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 i,r;return r=t[this.pos++],i=127&r,r<128?i:(r=t[this.pos++],i|=(127&r)<<7,r<128?i:(r=t[this.pos++],i|=(127&r)<<14,r<128?i:(r=t[this.pos++],i|=(127&r)<<21,r<128?i:(r=t[this.pos],i|=(15&r)<<28,function(e,t,i){const r=i.buf;let n,o;if(o=r[i.pos++],n=(112&o)>>4,o<128)return xf(e,n,t);if(o=r[i.pos++],n|=(127&o)<<3,o<128)return xf(e,n,t);if(o=r[i.pos++],n|=(127&o)<<10,o<128)return xf(e,n,t);if(o=r[i.pos++],n|=(127&o)<<17,o<128)return xf(e,n,t);if(o=r[i.pos++],n|=(127&o)<<24,o<128)return xf(e,n,t);if(o=r[i.pos++],n|=(1&o)<<31,o<128)return xf(e,n,t);throw new Error("Expected varint not more than 10 bytes")}(i,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&&gf?gf.decode(this.buf.subarray(t,e)):function(e,t,i){let r="",n=t;for(;n<i;){const t=e[n];let o,s,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(n+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[n+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(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 i=this.readPackedEnd();for(;this.pos<i;)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*_f),!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*_f),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(i=~(-e%4294967296),r=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){const i=(7&e)<<4;t.buf[t.pos++]|=i|((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)))))}(r,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,i){for(let r,n,o=0;o<t.length;o++){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&vf(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}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 i=0;i<t;i++)this.buf[this.pos++]=e[i]}writeRawMessage(e,t){this.pos++;const i=this.pos;e(t,this);const r=this.pos-i;r>=128&&vf(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,bf,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,wf,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Sf,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Tf,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Ef,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Af,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,If,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Cf,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Mf,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 xf(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function vf(e,t,i){const r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(let t=i.pos-1;t>=e;t--)i.buf[t+r]=i.buf[t]}function bf(e,t){for(let i=0;i<e.length;i++)t.writeVarint(e[i])}function wf(e,t){for(let i=0;i<e.length;i++)t.writeSVarint(e[i])}function Tf(e,t){for(let i=0;i<e.length;i++)t.writeFloat(e[i])}function Ef(e,t){for(let i=0;i<e.length;i++)t.writeDouble(e[i])}function Sf(e,t){for(let i=0;i<e.length;i++)t.writeBoolean(e[i])}function Af(e,t){for(let i=0;i<e.length;i++)t.writeFixed32(e[i])}function If(e,t){for(let i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Cf(e,t){for(let i=0;i<e.length;i++)t.writeFixed64(e[i])}function Mf(e,t){for(let i=0;i<e.length;i++)t.writeSFixed64(e[i])}const Df=3;function Pf(e,t,i){t.glyphs=[],1===e&&i.readMessage(Lf,t)}function Lf(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Rf,{});t.glyphs.push({id:e,bitmap:new AlphaImage({width:n+2*Df,height:o+2*Df},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function Rf(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}const zf={horizontal:1,vertical:2,horizontalOnly:3};function Ff(e){let t=.5,i=.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":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function Of(e,t,i,r){const{horizontalAlign:n,verticalAlign:o}=Ff(r),s=i[0]-e.displaySize[0]*n,a=i[1]-e.displaySize[1]*o;return{imagePrimary:e,imageSecondary:t,top:a,bottom:a+e.displaySize[1],left:s,right:s+e.displaySize[0]}}function Bf(e,t,i,r,n,o){const s=e.imagePrimary;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}const l=t.left*o,c=t.right*o;let u,h,d,p;"width"===i||"both"===i?(p=n[0]+l-r[3],h=n[0]+c+r[1]):(p=n[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=n[1]+f-r[0],d=n[1]+m+r[2]):(u=n[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{imagePrimary:s,imageSecondary:void 0,top:u,right:h,bottom:d,left:p,collisionPadding:a}}const kf=128;function Uf(e,t,i){const{expression:r}=t;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new EvaluationParameters(e+1,{worldview:i}))};if("source"===r.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=r;let o=0;for(;o<t.length&&t[o]<=e;)o++;o=Math.max(0,o-1);let s=o;for(;s<t.length&&t[s]<e+1;)s++;s=Math.min(t.length-1,s);const a=t[o],l=t[s];return"composite"===r.kind?{kind:"composite",minZoom:a,maxZoom:l,interpolationType:n}:{kind:"camera",minZoom:a,maxZoom:l,minSize:r.evaluate(new EvaluationParameters(a,{worldview:i})),maxSize:r.evaluate(new EvaluationParameters(l,{worldview:i})),interpolationType:n}}}function Vf(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/kf:"composite"===e.kind?xr(r/kf,n/kf,i):t}function Nf(e,t,i=1){let r=0,n=0;if("constant"===e.kind)n=e.layoutSize*i;else if("source"!==e.kind){const{interpolationType:o,minZoom:s,maxZoom:a}=e,l=o?He(Interpolate.interpolationFactor(o,t,s,a),0,1):0;"camera"===e.kind?n=xr(e.minSize,e.maxSize,l)*i:r=l*i}return{uSizeT:r,uSize:n}}class Anchor extends Le{constructor(e,t,i,r,n){super(e,t),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new Anchor(this.x,this.y,this.z,this.angle,this.segment)}}function jf(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();t&&e<r.length&&(r[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(r.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:n,h:o,fill:t/(n*o)||0}}bs(Anchor,"Anchor");class ImagePosition{static getImagePositionScale(e,t,i){if(t&&e){const{sx:t,sy:i}=e;return{x:t,y:i}}return{x:i,y:i}}constructor(e,t,i,r){this.paddedRect=e;const{pixelRatio:n,version:o,stretchX:s,stretchY:a,content:l,sdf:c,usvg:u}=t;this.pixelRatio=n,this.stretchX=s,this.stretchY=a,this.content=l,this.version=o,this.padding=i,this.sdf=c,this.usvg=u,this.scale=ImagePosition.getImagePositionScale(r,u,n)}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 Gf(e,t,i){const r=ImageVariant.parse(e),n=function(e,t,i=[1,1]){return{x:0,y:0,w:(e.data?e.data.width:e.width*i[0])+2*t,h:(e.data?e.data.height:e.height*i[1])+2*t}}(t,i,[r.sx,r.sy]);return{bin:n,imagePosition:new ImagePosition(n,t,i,r),imageVariant:r}}bs(ImagePosition,"ImagePosition"),bs(class ImageAtlas{constructor(e,t,i){const r=new Map,n=new Map;this.haveRenderCallbacks=[];const o=[];this.addImages(e,r,1,o),this.addImages(t,n,2,o);const{w:s,h:a}=jf(o),l=new RGBAImage({width:s||1,height:a||1});for(const[t,i]of e.entries()){const e=r.get(t).paddedRect;RGBAImage.copy(i.data,l,{x:0,y:0},{x:e.x+1,y:e.y+1},i.data,null,i.sdf)}for(const[e,r]of t.entries()){const t=n.get(e),o=t.paddedRect;let s=t.padding;const a=o.x+s,c=o.y+s,u=r.data.width,h=r.data.height;s=s>1?s-1:s,RGBAImage.copy(r.data,l,{x:0,y:0},{x:a,y:c},r.data,i),RGBAImage.copy(r.data,l,{x:0,y:h-s},{x:a,y:c-s},{width:u,height:s},i),RGBAImage.copy(r.data,l,{x:0,y:0},{x:a,y:c+h},{width:u,height:s},i),RGBAImage.copy(r.data,l,{x:u-s,y:0},{x:a-s,y:c},{width:s,height:h},i),RGBAImage.copy(r.data,l,{x:0,y:0},{x:a+u,y:c},{width:s,height:h},i),RGBAImage.copy(r.data,l,{x:u-s,y:h-s},{x:a-s,y:c-s},{width:s,height:s},i),RGBAImage.copy(r.data,l,{x:0,y:h-s},{x:a+u,y:c-s},{width:s,height:s},i),RGBAImage.copy(r.data,l,{x:0,y:0},{x:a+u,y:c+h},{width:s,height:s},i),RGBAImage.copy(r.data,l,{x:u-s,y:0},{x:a-s,y:c+h},{width:s,height:s},i)}this.lut=i,this.image=l,this.iconPositions=r,this.patternPositions=n}addImages(e,t,i,r){for(const[n,o]of e.entries()){const{bin:e,imagePosition:s,imageVariant:a}=Gf(n,o,i);t.set(n,s),r.push(e),o.hasRenderCallback&&this.haveRenderCallbacks.push(a.id)}}patchUpdatedImages(e,t,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((t=>e.hasImage(t,i))),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const r of e.getUpdatedImages(i)){for(const n of this.iconPositions.keys()){const o=ImageVariant.parse(n);if(ImageId.isEqual(o.id,r)){const o=e.getImage(r,i);this.patchUpdatedImage(this.iconPositions.get(n),o,t,null)}}for(const n of this.patternPositions.keys()){const o=ImageVariant.parse(n);if(ImageId.isEqual(o.id,r)){const o=e.getImage(r,i);this.patchUpdatedImage(this.patternPositions.get(n),o,t,this.lut)}}}}patchUpdatedImage(e,t,i,r=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[n,o]=e.tl,s=e.sdf;if(this.lut||s){const e={width:t.data.width,height:t.data.height},a=new RGBAImage(e);RGBAImage.copy(t.data,a,{x:0,y:0},{x:0,y:0},e,r,s),i.update(a,{position:{x:n,y:o}})}else i.update(t.data,{position:{x:n,y:o}})}},"ImageAtlas");const Hf=1e20;function qf(e,t,i,r,n,o,s,a,l){for(let c=t;c<t+r;c++)$f(e,i*o+c,o,n,s,a,l);for(let c=i;c<i+n;c++)$f(e,c*o+t,1,r,s,a,l)}function $f(e,t,i,r,n,o,s){o[0]=0,s[0]=-Hf,s[1]=Hf,n[0]=e[t];for(let a=1,l=0,c=0;a<r;a++){n[a]=e[t+a*i];const r=a*a;do{const e=o[l];c=(n[a]-n[e]+r-e*e)/(a-e)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=Hf}for(let a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;const r=o[l],c=a-r;e[t+a*i]=n[r]+c*c}}class GlyphManager{constructor(e,t,i){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,t){const i=[],r=this.url||Mt.GLYPHS_URL;for(const t in e)for(const r of e[t])i.push({stack:t,id:r});Ze(i,(({stack:e,id:t},i)=>{let n=this.entries[e];n||(n=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[t];if(void 0!==o)return void i(null,{stack:e,id:t,glyph:o});if(o=this._tinySDF(n,e,t),o)return n.glyphs[t]=o,void i(null,{stack:e,id:t,glyph:o});const s=Math.floor(t/256);if(256*s>65535)return st("glyphs > 65535 not supported"),void i(null,{stack:e,id:t,glyph:o});if(n.ranges[s])return void i(null,{stack:e,id:t,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],GlyphManager.loadGlyphRange(e,s,r,this.requestManager,((e,t)=>{if(t){n.ascender=t.ascender,n.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=t.glyphs[+e]);n.ranges[s]=!0}for(const i of a)i(e,t);delete n.requests[s]}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null})}))}),((e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:r,glyph:n}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}}))}_doesCharSupportLocalGlyph(e){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&(Ss["CJK Unified Ideographs"](e)||Ss["Hangul Syllables"](e)||Ss.Hiragana(e)||Ss.Katakana(e)||Ss["CJK Symbols and Punctuation"](e)||Ss["CJK Unified Ideographs Extension A"](e)||Ss["CJK Unified Ideographs Extension B"](e)||Ss.Osage(e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new GlyphManager.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),n.fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:d,glyphAdvance:p}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new AlphaImage({width:a,height:l},s),metrics:{width:c/2,height:u/2,left:h/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}GlyphManager.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),Ii.Glyphs);Pi(a,((e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new yf(e).readFields(Pf,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}}))},GlyphManager.TinySDF=class TinySDF{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=r,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${n}`,u.textBaseline="alphabetic",u.textAlign="left",u.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:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(Hf,0,h),_.fill(0,0,h);for(let e=0;e<l;e++)for(let t=0;t<a;t++){const i=y.data[4*(e*a+t)+3]/255;if(0===i)continue;const r=(e+m)*c+t+m;if(1===i)g[r]=0,_[r]=Hf;else{const e=.5-i;g[r]=e>0?e*e:0,_[r]=e<0?e*e:0}}qf(g,0,0,c,u,c,this.f,this.v,this.z),qf(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e<h;e++){const t=Math.sqrt(g[e])-Math.sqrt(_[e]);d[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return p}};const Zf=1;function Wf(e,t){return e+t[1]-t[0]}function Xf(e,t,i,r,n=1){const o=[],s=e.imagePrimary,a=s.pixelRatio,l=s.paddedRect.w-2*Zf,c=s.paddedRect.h-2*Zf,u=(e.right-e.left)*n,h=(e.bottom-e.top)*n,d=s.stretchX||[[0,l]],p=s.stretchY||[[0,c]],f=d.reduce(Wf,0),m=p.reduce(Wf,0),_=l-f,g=c-m;let y=0,x=f,v=0,b=m,w=0,T=_,E=0,S=g;if(s.content&&r){const e=s.content;y=Yf(d,0,e[0]),v=Yf(p,0,e[1]),x=Yf(d,e[0],e[2]),b=Yf(p,e[1],e[3]),w=e[0]-y,E=e[1]-v,T=e[2]-e[0]-x,S=e[3]-e[1]-b}const A=(r,o,l,c)=>{const d=Jf(r.stretch-y,x,u,e.left*n),p=Qf(r.fixed-w,T,r.stretch,f),_=Jf(o.stretch-v,b,h,e.top*n),g=Qf(o.fixed-E,S,o.stretch,m),A=Jf(l.stretch-y,x,u,e.left*n),I=Qf(l.fixed-w,T,l.stretch,f),C=Jf(c.stretch-v,b,h,e.top*n),M=Qf(c.fixed-E,S,c.stretch,m),D=new Le(d,_),P=new Le(A,_),L=new Le(A,C),R=new Le(d,C),z=new Le(p/a,g/a),F=new Le(I/a,M/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];D._matMult(i),P._matMult(i),R._matMult(i),L._matMult(i)}const B=r.stretch+r.fixed,k=l.stretch+l.fixed,U=o.stretch+o.fixed,V=c.stretch+c.fixed,N=e.imageSecondary;return{tl:D,tr:P,bl:R,br:L,texPrimary:{x:s.paddedRect.x+Zf+B,y:s.paddedRect.y+Zf+U,w:k-B,h:V-U},texSecondary:N?{x:N.paddedRect.x+Zf+B,y:N.paddedRect.y+Zf+U,w:k-B,h:V-U}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:z,pixelOffsetBR:F,minFontScaleX:T/a/u,minFontScaleY:S/a/h,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){const e=Kf(d,_,f),t=Kf(p,g,m);for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)o.push(A(r,t[e],n,t[e+1]))}}else o.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return o}function Yf(e,t,i){let r=0;for(const n of e)r+=Math.max(t,Math.min(i,n[1]))-Math.max(t,Math.min(i,n[0]));return r}function Kf(e,t,i){const r=[{fixed:-Zf,stretch:0}];for(const[t,i]of e){const e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)})}return r.push({fixed:t+Zf,stretch:i}),r}function Jf(e,t,i,r){return e/t*i+r}function Qf(e,t,i,r){return e-t*i/r}const em=7,tm=Number.POSITIVE_INFINITY,im=Math.sqrt(2);function rm(e,[t,i]){let r=0,n=0;if(i===tm){t<0&&(t=0);const i=t/im;switch(e){case"top-right":case"top-left":n=i-em;break;case"bottom-right":case"bottom-left":n=-i+em;break;case"bottom":n=-t+em;break;case"top":n=t-em}switch(e){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=t;break;case"right":r=-t}}else{switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-em;break;case"bottom-right":case"bottom-left":case"bottom":n=-i+em}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}}return[r,n]}function nm(e,t,i,r,n,o,s,a,l){if(!e)return;const c=function(e,t,i,r,n,o){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const r=t.possiblyEvaluate(new EvaluationParameters(e.maxZoom,{worldview:o}),i).evaluate(n,{},i),s=t.possiblyEvaluate(new EvaluationParameters(e.minZoom,{worldview:o}),i).evaluate(n,{},i);return Math.max(r,s)}return t.possiblyEvaluate(new EvaluationParameters(r,{worldview:o})).evaluate(n,{},i)}(t,i,r,n,o,l);return e.scaleSelf(c*a*s)}function om(e,t,i,r,n,o,s,a,l){return{iconPrimary:nm(e.getPrimary(),t,i,r,n,o,s,a,l),iconSecondary:nm(e.getSecondary(),t,i,r,n,o,s,a,l)}}const sm=255*kf;function am(e,t){const i=e.fovAboveCenter,r=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,n=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),o=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01));let s=Math.sin(e._pitch)*o+n;const a=n*(1/e._horizonShift);if(!e.elevation||0===e.elevation.exaggeration()){let t=Math.max(e.zoom-17,0);e.isOrthographic&&(t/=10),s*=1+t}return Math.min(1.01*s,a)}function lm(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 i=Math.pow(2,-e.z),r=e.x*i,n=(e.x+1)*i,o=e.y*i,s=(e.y+1)*i,a=il(r),l=il(n),c=rl(o),u=rl(s),h=t.project(a,c),d=t.project(l,c),p=t.project(l,u),f=t.project(a,u);let m=Math.min(h.x,d.x,p.x,f.x),_=Math.min(h.y,d.y,p.y,f.y),g=Math.max(h.x,d.x,p.x,f.x),y=Math.max(h.y,d.y,p.y,f.y);const x=i/16;function v(e,i,r,n,o,s){const a=(r+o)/2,l=(n+s)/2,c=t.project(il(a),rl(l)),u=Math.max(0,m-c.x,_-c.y,c.x-g,c.y-y);m=Math.min(m,c.x),g=Math.max(g,c.x),_=Math.min(_,c.y),y=Math.max(y,c.y),u>x&&(v(e,c,r,n,a,l),v(c,i,a,l,o,s))}v(h,d,r,o,n,o),v(d,p,n,o,n,s),v(p,f,n,s,r,s),v(f,h,r,s,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}function cm(e,t,i,r,n,o,s,a,l){if("globe"===l.name)return fc(e,t,new CanonicalTileID(i,r,n),!1);const c=lm({z:i,x:r,y:n},l);return new Aabb([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])}function um(e,{x:t,y:i},r=0){return new Le(((t-r)*e.scale-e.x)*Mn,(i*e.scale-e.y)*Mn)}function hm(e,t,i=0){return D(((t.x-i)*e.scale-e.x)*Mn,(t.y*e.scale-e.y)*Mn,nl(t.z,t.y))}const dm=u(new Float32Array(16));class Projection{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 LngLat(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i,r=!0){return e._coordinatePoint(e.locationCoordinate(t,i),r)}pixelsPerMeter(e,t){return tl(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return am(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,r){const n=e.horizonLineFromTop(!1),o=new Le(t,Math.max(n,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,i){const r=new Le(t,i);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.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 i=e.horizonLineFromTop();return t.y<i}createInversionMatrix(e,t){return dm}createTileMatrix(e,t,i){let r,n,o;const s=i.canonical,a=u(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=lm(s,this);r=1,n=l.x+i.wrap*l.scale,o=l.y,m(a,a,[r/l.scale,r/l.scale,e.pixelsPerMeter/t])}else r=t/e.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return f(a,a,[n,o,0]),m(a,a,[r/Mn,r/Mn,1]),a}upVector(e,t,i){return[0,0,1]}upVectorScale(e,t,i){return{metersToTile:1}}}class Albers extends Projection{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,i]=this.parallels=e.parallels||[29.5,45.5],r=Math.sin(Oe(t));this.n=(r+Math.sin(Oe(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:i,c:r,r0:n}=this,o=Oe(e-this.center[0]),s=Oe(t),a=Math.sqrt(r-2*i*Math.sin(s))/i;return{x:a*Math.sin(o*i),y:a*Math.cos(o*i)-n,z:0}}unproject(e,t){const{n:i,c:r,r0:n}=this,o=n+t;let s=Math.atan2(e,Math.abs(o))*Math.sign(o);o*i<0&&(s-=Math.PI*Math.sign(e)*Math.sign(o));const a=Oe(this.center[0])*i;s=$e(s,-Math.PI-a,Math.PI-a);const l=He(Be(s/i)+this.center[0],-180,180),c=Math.asin(He((r-(e*e+o*o)*i*i)/(2*i),-1,1)),u=He(Be(c),-ol,ol);return new LngLat(l,u)}}const pm=1.340264,fm=-.081106,mm=893e-6,_m=.003796,gm=Math.sqrt(3)/2;class EqualEarth extends Projection{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(gm*Math.sin(t)),r=i*i,n=r*r*r;return{x:.5*(e*Math.cos(i)/(gm*(pm+3*fm*r+n*(7*mm+9*_m*r)))/Math.PI+.5),y:1-.5*(i*(pm+fm*r+n*(mm+_m*r))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=i*i,n=r*r*r;for(let e,o,s,a=0;a<12&&(o=i*(pm+fm*r+n*(mm+_m*r))-t,s=pm+3*fm*r+n*(7*mm+9*_m*r),e=o/s,i=He(i-e,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(e)<1e-12));++a);const o=gm*e*(pm+3*fm*r+n*(7*mm+9*_m*r))/Math.cos(i),s=Math.asin(Math.sin(i)/gm),a=He(180*o/Math.PI,-180,180),l=He(180*s/Math.PI,-ol,ol);return new LngLat(a,l)}}class Equirectangular extends Projection{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 i=360*(e-.5),r=He(360*(.5-t),-ol,ol);return new LngLat(i,r)}}const ym=Math.PI/2;function xm(e){return Math.tan((ym+e)/2)}class LambertConformalConic extends Projection{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30];let r=Oe(t),n=Oe(i);this.southernCenter=r+n<0,this.southernCenter&&(r=-r,n=-n);const o=Math.cos(r),s=xm(r);this.n=r===n?Math.sin(r):Math.log(o/Math.cos(n))/Math.log(xm(n)/s),this.f=o*Math.pow(xm(r),this.n)/this.n}project(e,t){t=Oe(t),this.southernCenter&&(t=-t),e=Oe(e-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?t<-ym+i&&(t=-ym+i):t>ym-i&&(t=ym-i);const o=n/Math.pow(xm(t),r);let s=o*Math.sin(r*e),a=n-o*Math.cos(r*e);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:r}=this,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=He(Be(a/i)+this.center[0],-180,180),c=He(Be(2*Math.atan(Math.pow(r/s,1/i))-ym),-ol,ol);return new LngLat(l,this.southernCenter?-c:c)}}class Mercator extends Projection{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:Qa(e),y:el(t),z:0}}unproject(e,t){const i=il(e),r=rl(t);return new LngLat(i,r)}}const vm=Oe(ol);class NaturalEarth extends Projection{project(e,t){const i=(t=Oe(t))*t,r=i*i;return{x:.5*((e=Oe(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=He(i-n,-vm,vm)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=He(Be(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Be(i);return new LngLat(s,a)}}const bm=Oe(ol);class WinkelTripel extends Projection{project(e,t){t=Oe(t),e=Oe(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,u=n*n,h=Math.cos(i/2),d=Math.sin(i/2),p=2*h*d,f=d*d,m=1-u*h*h,_=m?1/m:0,g=m?Math.acos(n*h)*Math.sqrt(1/m):0,y=.5*(2*g*n*d+2*i/Math.PI)-e,x=.5*(g*o+r)-t,v=.5*_*(u*f+g*n*h*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*u*p),T=.5*_*(c*h+g*f*n)+.5,E=b*w-T*v;s=(x*b-y*T)/E,a=(y*w-x*v)/E,i=He(i-s,-Math.PI,Math.PI),r=He(r-a,-bm,bm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new LngLat(Be(i),Be(r))}}class CylindricalEqualArea extends Projection{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Oe(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:i,cosPhi:r}=this;return{x:Oe(e)*r*i+.5,y:-Math.sin(Oe(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=He(Be((e-.5)/i)/r,-180,180),s=Math.asin(He(n*r,-1,1)),a=He(Be(s),-ol,ol);return new LngLat(o,a)}}class Globe extends Mercator{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,i){const r=gc(e,t,i);return Z(r,r,vc(uc(i))),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t,i){const r=Za(t.lat,t.lng),n=G([],r),o=i?e._centerAltitude+i:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;k(r,r,n,tl(1,0)*Mn*o);const s=u(new Float64Array(16));return p(s,e.pixelMatrix,e.globeMatrix),Z(r,r,s),new Le(r[0],r[1])}pixelsPerMeter(e,t){return tl(1,0)*t}pixelSpaceConversion(e,t,i){const r=tl(1,e)*t,n=xr(tl(1,45)*t,r,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(e,t,i){const r=bc(uc(i.canonical));return p(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:i}=e,r=vc(uc(t));return g(r,r,Oe(i.lng)),_(r,r,Oe(i.lat)),m(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,i,r){return lc(e,t,i,!0)||new MercatorCoordinate(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!lc(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),s=L([],B([],o,-i),[0,0,r]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=B([],n.up(),u),d=B([],n.right(),u*c),p=G([],L([],L([],o,h),d)),f=[];let m;if(new Ray(s,p).closestPointOnSphere(l,a,f)){const t=L([],f,l),i=J([],t,s);m=Math.cos(e.fovAboveCenter)*M(i)}else{const e=J([],s,l),t=J([],l,s);G(t,t);const i=M(e)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(H(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=Ac(e.zoom);if(i>0){const r=am(e,tl(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return xr(t,r+n*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return gc(t,i,e,1)}upVectorScale(e){return{metersToTile:sc(yc(uc(e)))}}}function wm(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new Mercator(e);case"equirectangular":return new Equirectangular(e);case"naturalEarth":return new NaturalEarth(e);case"equalEarth":return new EqualEarth(e);case"winkelTripel":return new WinkelTripel(e);case"albers":return i?new CylindricalEqualArea(e):new Albers(e);case"lambertConformalConic":return i?new CylindricalEqualArea(e):new LambertConformalConic(e);case"globe":return new Globe(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Tm=VectorTileFeature.types,Em=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Sm(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=a?Math.min(sm,Math.round(a[0])):0,f=a?Math.min(sm,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),0+(f<<1),16*c,16*u,256*h,256*d)}function Am(e,t,i){e.emplaceBack(t,i)}function Im(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,s)}function Cm(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n}const Mm=(e,t,i,r)=>{for(let n=0;n<t;n++)e.emplaceBack(i[0],i[1],i[2],r[0],r[1],r[2])};function Dm(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n)}function Pm(e){for(const t of e.sections)if(Ds(t.text))return!0;return!1}class SymbolBuffers{constructor(e){this.layoutVertexArray=new StructArrayLayout4i4ui4i24,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=e,this.segments=new SegmentVector,this.dynamicLayoutVertexArray=new StructArrayLayout4f16,this.opacityVertexArray=new StructArrayLayout1ul4,this.placedSymbolArray=new PlacedSymbolArray,this.iconTransitioningVertexArray=new StructArrayLayout2ui4,this.globeExtVertexArray=new StructArrayLayout3i3f20,this.zOffsetVertexArray=new StructArrayLayout1f4,this.orientationVertexArray=new StructArrayLayout6f24,this.symbolInstanceIndices=[]}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}getIconVertexData(e,t){const i=[],r=this.layoutVertexArray.uint16;for(let n=0;n<t;++n){const t=12*(e+n);i.push(...r.slice(t,t+12))}return i}updateIconVertexData(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=this.layoutVertexArray.uint16,f=12*e;p[f]=t,p[f+1]=i,p[f+2]=r,p[f+3]=n,p[f+4]=o,p[f+5]=s,p[f+6]=a,p[f+7]=l,p[f+8]=c,p[f+9]=u,p[f+10]=h,p[f+11]=d}upload(e,t,i,r,n,o){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,rf.members,!!o),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,of.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Em,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,lf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,nf.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,sf.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,af.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}bs(SymbolBuffers,"SymbolBuffers");class CollisionBuffers{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new SegmentVector,this.collisionVertexArray=new StructArrayLayout2ub4f20,this.collisionVertexArrayExt=new StructArrayLayout4f16}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,cf.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,uf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}bs(CollisionBuffers,"CollisionBuffers");class SymbolBucket{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.textSizeData=Uf(this.zoom,t["text-size"],this.worldview),this.iconSizeData=Uf(this.zoom,t["icon-size"],this.worldview);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.lut=e.lut,this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((e=>zf[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.lastActiveApperance=null,this.featureToAppearanceIndex={}}hasAnyAppearanceProperty(e){const t=this.layers[0].getAppearances();return!(!t||0===t.length)&&t.some((t=>null!=t.getProperty(e)))}createArrays(){this.text=new SymbolBuffers(new ProgramConfigurationSet(this.layers,{zoom:this.zoom,lut:this.lut},(e=>e.startsWith("text")||e.startsWith("symbol")))),this.icon=new SymbolBuffers(new ProgramConfigurationSet(this.layers,{zoom:this.zoom,lut:this.lut},(e=>e.startsWith("icon")||e.startsWith("symbol")))),this.glyphOffsetArray=new GlyphOffsetArray,this.lineVertexArray=new SymbolLineVertexArray,this.symbolInstances=new SymbolInstanceArray}calculateGlyphDependencies(e,t,i,r,n){for(const i of e){const e=i.codePointAt(0);if(void 0===e)break;if(t[e]=!0,r&&n&&e<=65535){const e=ff[i];e&&(t[e.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,t,i,r,n,o){let s=1;const a=e.getUnevaluatedProperties()._values["icon-size"],l=Uf(this.zoom,a,this.worldview),c=Nf(l,t);if("constant"!==l.kind&&"camera"!==l.kind||(s=c.uSize),"composite"===l.kind){const{minZoom:e,maxZoom:t}=l,o=a.possiblyEvaluate(new EvaluationParameters(e,{worldview:this.worldview}),r),u=a.possiblyEvaluate(new EvaluationParameters(t,{worldview:this.worldview}),r),h=o.evaluate(i,{},r,n);s=h+(u.evaluate(i,{},r,n)-h)*c.uSizeT}return"source"===l.kind&&(s=a.possiblyEvaluate(new EvaluationParameters(this.zoom,{worldview:this.worldview}),r).evaluate(i,{},r,n)),s*o}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!ah(this.activeReplacements,i)&&(this.activeReplacements=i,!0)}getResolvedImageFromTokens(e){return"string"==typeof e?ResolvedImage.build(e):e}populate(e,t,i,r){const n=this.layers[0],o=n.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),[u,h]=o.get("icon-size-scale-range"),d=He(t.scaleFactor||1,u,h),p=("constant"!==l.value.kind||l.value.value instanceof Formatted&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),f="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,m=this.hasAnyAppearanceProperty("icon-image"),_=o.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!p&&!f&&!m)return;const g=t.iconDependencies,y=t.glyphDependencies,x=t.availableImages,v=new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),b=e=>{const t=e.id.toString();g.has(t)?g.get(t).push(e):g.set(t,[e])};for(const t of e){const{feature:e,id:l,index:c,sourceLayerIndex:u}=t,h=n._featureFilter.needGeometry,w=yl(e,h);if(!n._featureFilter.filter(v,w,i))continue;if(h||(w.geometry=gl(e,i,r)),s&&1!==e.type&&i.z<=5){const e=w.geometry,t=.98078528056,r=(e,r)=>H(gc(e.x,e.y,i,1),gc(r.x,r.y,i,1))<t;for(let t=0;t<e.length;t++)e[t]=pl(e[t],r)}let T,E;if(p){const e=n.getValueAndResolveTokens("text-field",w,i,x),t=Formatted.factory(e);Pm(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Vs()||this.hasRTLText&&js.isParsed())&&(T=pf(t,n,w))}if(f){const e=n.getValueAndResolveTokens("icon-image",w,i,x);E=this.getResolvedImageFromTokens(e)}const S=this.layers[0];let A=!1;if(!E&&m){const e=S.getAppearances();for(const t of e)if(t.getProperty("icon-image")){const e=S.getAppearanceValueAndResolveTokens(t,"icon-image",w,i,x);if(e){E=this.getResolvedImageFromTokens(e),A=!0;break}}}if(!T&&!E)continue;const I=this.sortFeaturesByKey?_.evaluate(w,{},i):void 0,C={id:l,text:T,icon:E,index:c,sourceLayerIndex:u,geometry:w.geometry,properties:e.properties,type:Tm[e.type],sortKey:I};if(this.features.push(C),this.featureToAppearanceIndex[c]=this.appearanceFeatureData.length,this.appearanceFeatureData.push({id:l,properties:e.properties,usesAppearanceIconAsPlaceholder:A,isUsingAppearanceVertexData:!1,layoutBasedVertexData:[],activeAppearance:null}),E){const e=S._unevaluatedLayout._values,{iconPrimary:t,iconSecondary:r}=om(E,this.iconSizeData,e["icon-size"],i,this.zoom,C,this.pixelRatio,d,this.worldview);b(t),r&&(this.hasAnySecondaryIcon=!0,b(r))}const M=S.getAppearances();if(0!==M.length&&M.forEach((e=>{if(!e.getProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,S,w,i,x,C,d);t&&b(t)})),T){const e=a.evaluate(w,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(zf.vertical)>=0;for(const i of T.sections)if(i.image){const e=i.image.getPrimary().scaleSelf(this.pixelRatio),t=e.id.toString(),r=g.get(t)||[];r.push(e),g.set(t,r)}else{const r=As(T.toString()),n=i.fontStack||e,o=y[n]=y[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r)}}}if("line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;c<e.length;c++){const u=e[c],h=u.geometry,d=u.text?u.text.toString():null;if(!d){o(c);continue}const p=l(d,h),f=l(d,h,!0);if(p in i&&f in t&&i[p]!==t[f]){const e=a(p,f,h),n=s(p,f,r[e].geometry);delete t[p],delete i[f],i[l(d,r[n].geometry,!0)]=n,r[e].geometry=null}else p in i?s(p,f,h):f in t?a(p,f,h):(o(c),t[p]=n-1,i[f]=n-1)}return r.filter((e=>e.geometry))}(this.features)),"hd-road-markup"===o.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 o.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,i,r,n,o,s){let a,l;const c=e.getUnevaluatedProperties();if(void 0!==c._values["icon-image"].value){const o=t.getAppearanceValueAndResolveTokens(e,"icon-image",i,r,n);a=this.getResolvedImageFromTokens(o)}else{const e=t.getValueAndResolveTokens("icon-image",i,r,n);a=this.getResolvedImageFromTokens(e)}if(a){const e=c._values["icon-size"]||t._unevaluatedLayout._values["icon-size"];l=om(a,Uf(this.zoom,e,this.worldview),e,r,this.zoom,o,this.pixelRatio,s,this.worldview).iconPrimary}return l}updateAppearanceBasedIconTextures(e,t,i,r){if(!this.appearanceFeatureData)return!1;if(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)return!1;const n=this.layers[0];let o=!1,s=0;const a=n.layout,[l,c]=a.get("icon-size-scale-range"),u=He(1,l,c);for(let a=0;a<this.symbolInstances.length;a++){const l=this.symbolInstances.get(a),c=this.featureToAppearanceIndex[l.featureIndex],h=void 0!==c?this.appearanceFeatureData[c]:void 0;if(h&&l.placedIconSymbolIndex>=0){const a=h.id,c=t&&void 0!==a?t[String(a)]:void 0,d={type:"Point",id:h.id,properties:h.properties,geometry:[]},p=this.layers[0].appearances&&this.layers[0].appearances.find((t=>t.isActive({globals:r,feature:d,canonical:e,featureState:c})));if(h.activeAppearance===p){s+=l.numIconVertices;continue}if(p){h.activeAppearance=p;const t=this.getCombinedIconPrimary(p,n,d,e,i,{sortKey:void 0,text:void 0,icon:null,index:l.featureIndex,sourceLayerIndex:l.featureIndex,geometry:[],properties:h.properties,type:"Point",id:h.id},u);if(!t)continue;const a=t.toString(),c=this.iconAtlasPositions&&this.iconAtlasPositions.get(a);if(c){const t=n.getAppearanceValueAndResolveTokens(p,"icon-offset",d,e,i),a=t&&Array.isArray(t)?t:[0,0];let f=Of(c,void 0,a,n.layout.get("icon-anchor").evaluate(d,{},e));const m=n.getAppearanceValueAndResolveTokens(p,"icon-rotate",d,e,i),_="number"==typeof m?m:0,g=c.sdf,y=n.layout.get("icon-text-fit").constantOr("none");"none"!==y&&h.textShaping&&h.iconTextFitPadding&&h.fontScale&&(f=Bf(f,h.textShaping,y,h.iconTextFitPadding,a,h.fontScale));const x=this.calculateEffectiveAppearanceIconSize(p,r.zoom,d,e,i,u),v=0,b=1+(Math.min(sm,Math.round(x*kf))<<1),w=Xf(f,_,g,"none"!==y,u);h.isUsingAppearanceVertexData||(h.isUsingAppearanceVertexData=!0,h.layoutBasedVertexData=this.icon.getIconVertexData(s,l.numIconVertices));for(let e=0;e<w.length;++e){const t=w[e],i=h.layoutBasedVertexData[0]||l.tileAnchorX,r=h.layoutBasedVertexData[1]||l.tileAnchorY,n=16*t.pixelOffsetTL.x,o=16*t.pixelOffsetTL.y,a=16*t.pixelOffsetBR.x,c=16*t.pixelOffsetBR.y,u=16*t.minFontScaleX,d=16*t.minFontScaleY;this.icon.updateIconVertexData(s,i,r,Math.round(32*t.tl.x),Math.round(32*t.tl.y),t.texPrimary.x,t.texPrimary.y,v,b,n,o,u,d),this.icon.updateIconVertexData(s+1,i,r,Math.round(32*t.tr.x),Math.round(32*t.tr.y),t.texPrimary.x+t.texPrimary.w,t.texPrimary.y,v,b,a,o,u,d),this.icon.updateIconVertexData(s+2,i,r,Math.round(32*t.bl.x),Math.round(32*t.bl.y),t.texPrimary.x,t.texPrimary.y+t.texPrimary.h,v,b,n,c,u,d),this.icon.updateIconVertexData(s+3,i,r,Math.round(32*t.br.x),Math.round(32*t.br.y),t.texPrimary.x+t.texPrimary.w,t.texPrimary.y+t.texPrimary.h,v,b,a,c,u,d),s+=4}const T=l.numIconVertices-4*w.length;for(let e=0;e<T;++e)this.icon.updateIconVertexData(s+e,0,0,0,0,0,0,0,0,0,0,0,0);o=!0}else s+=l.numIconVertices}else if(h.usesAppearanceIconAsPlaceholder)this.layers[0].appearances&&this.layers[0].appearances.length>0&&(this.icon.updateIconVertexData(s,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+3,0,0,0,0,0,0,0,0,0,0,0,0),o=!0),s+=l.numIconVertices,h.activeAppearance=null;else if(h.isUsingAppearanceVertexData){const e=12,t=h.layoutBasedVertexData.length/e;for(let i=0;i<t;++i){const t=i*e;this.icon.updateIconVertexData(s+i,h.layoutBasedVertexData[t+0],h.layoutBasedVertexData[t+1],h.layoutBasedVertexData[t+2],h.layoutBasedVertexData[t+3],h.layoutBasedVertexData[t+4],h.layoutBasedVertexData[t+5],h.layoutBasedVertexData[t+6],h.layoutBasedVertexData[t+7],h.layoutBasedVertexData[t+8],h.layoutBasedVertexData[t+9],h.layoutBasedVertexData[t+10],h.layoutBasedVertexData[t+11])}s+=t,h.isUsingAppearanceVertexData=!1,h.activeAppearance=null,o=!0}else s+=l.numIconVertices,h.activeAppearance=null}}return o}update(e,t,i,r,n,o,s){this.text.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,this.worldview),this.icon.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,this.worldview)}updateRoadElevation(e){if("road"!==this.elevationType||!this.elevationFeatures)return;if(this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let t=!1;const i=cl(e),r=1/i;let n=!1,o=!1;for(let e=0;e<this.symbolInstances.length;e++){const s=this.symbolInstances.get(e),a=D(1,0,0),l=D(0,1,0),{numHorizontalGlyphVertices:c,numVerticalGlyphVertices:u,numIconVertices:h,numVerticalIconVertices:d}=s,p=c>0||u>0,f=h>0,m=this.elevationFeatures[s.elevationFeatureIndex];if(m){const e=new Le(s.tileAnchorX,s.tileAnchorY),c=.075+m.pointElevation(e);s.zOffset!==c&&(t=!0,s.zOffset=c),0!==c&&(this.hasAnyZOffset=!0);const u=m.computeSlopeNormal(e,r),h=_e(ae(),D(0,0,1),u);X(a,a,h),X(l,l,h),a[2]*=i,l[2]*=i,1===a[0]&&0===a[1]&&0===a[2]&&0===l[0]&&1===l[1]&&0===l[2]||(n=n||p,o=o||f)}if(p&&(Mm(this.text.orientationVertexArray,c,a,l),Mm(this.text.orientationVertexArray,u,a,l)),f){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:t}=s;e>=0&&Mm(this.icon.orientationVertexArray,h,a,l),t>=0&&Mm(this.icon.orientationVertexArray,d,a,l)}}n||(this.text.orientationVertexArray=void 0),o||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const e=(e,t,r)=>{i+=t,i>e.length&&e.resize(i);for(let n=-t;n<0;n++)e.emplace(n+i,r)},t=(e,t,i)=>{r+=t,r>e.length&&e.resize(r);for(let n=-t;n<0;n++)e.emplace(n+r,i)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,r=0;for(let i=0;i<this.symbolInstances.length;i++){const r=this.symbolInstances.get(i),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:o,numIconVertices:s}=r,a=r.zOffset,l=s>0;if((n>0||o>0)&&(e(this.text.zOffsetVertexArray,n,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=r;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,a)}}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,i,r,n){!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,!1),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,i,r){return!!(e&&t&&i)&&!(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(e,t,i,r)&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=wm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:i}of t)this.lineVertexArray.emplaceBack(e,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g){const y=e.indexArray,x=e.layoutVertexArray,v=e.globeExtVertexArray,b=e.segments.prepareSegment(4*g,x,y,this.canOverlap?o.sortKey:void 0),w=this.glyphOffsetArray.length,T=b.vertexLength,E=this.allowVerticalPlacement&&s===zf.vertical?Math.PI/2:0,S=o.text&&o.text.sections;for(let r=0;r<t.length;r++){const{tl:n,tr:s,bl:c,br:u,texPrimary:h,texSecondary:_,pixelOffsetTL:g,pixelOffsetBR:w,minFontScaleX:T,minFontScaleY:A,glyphOffset:I,isSDF:C,sectionIndex:M}=t[r],D=b.vertexLength,P=I[1];if(Sm(x,l.x,l.y,n.x,P+n.y,h.x,h.y,i,C,g.x,g.y,T,A),Sm(x,l.x,l.y,s.x,P+s.y,h.x+h.w,h.y,i,C,w.x,g.y,T,A),Sm(x,l.x,l.y,c.x,P+c.y,h.x,h.y+h.h,i,C,g.x,w.y,T,A),Sm(x,l.x,l.y,u.x,P+u.y,h.x+h.w,h.y+h.h,i,C,w.x,w.y,T,A),a){const{x:t,y:i,z:r}=a.anchor,[n,o,s]=a.up;Im(v,t,i,r,n,o,s),Im(v,t,i,r,n,o,s),Im(v,t,i,r,n,o,s),Im(v,t,i,r,n,o,s),Dm(e.dynamicLayoutVertexArray,t,i,r,E)}else Dm(e.dynamicLayoutVertexArray,l.x,l.y,l.z,E);if(m){const t=_||h;Am(e.iconTransitioningVertexArray,t.x,t.y),Am(e.iconTransitioningVertexArray,t.x+t.w,t.y),Am(e.iconTransitioningVertexArray,t.x,t.y+t.h),Am(e.iconTransitioningVertexArray,t.x+t.w,t.y+t.h)}y.emplaceBack(D,D+1,D+2),y.emplaceBack(D+1,D+2,D+3),b.vertexLength+=4,b.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(I[0]),r!==t.length-1&&M===t[r+1].sectionIndex||e.programConfigurations.populatePaintArrays(x.length,o,o.index,{},d,p,f,S&&S[M],this.worldview)}const A=g-t.length;0!==A&&this._addNullVertices(A,x,i,a,v,e,m,b,y);const I=a?a.anchor:l;e.placedSymbolArray.emplaceBack(I.x,I.y,I.z,l.x,l.y,w,this.glyphOffsetArray.length-w,T,c,u,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,0,0,h,0),e.symbolInstanceIndices.push(_)}_addNullVertices(e,t,i,r,n,o,s,a,l){for(let c=0;c<e;c++){for(let e=0;e<4;e++)Sm(t,0,0,0,0,0,0,i,!1,0,0,0,0),r?(Im(n,0,0,0,0,0,0),Dm(o.dynamicLayoutVertexArray,0,0,0,0)):Dm(o.dynamicLayoutVertexArray,0,0,0,0),s&&Am(o.iconTransitioningVertexArray,0,0);const e=a.vertexLength;l.emplaceBack(e,e+1,e+2),l.emplaceBack(e+1,e+2,e+3),a.vertexLength+=4,a.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(e,t,i,r,n,o,s){const a=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),l=a.vertexLength,c=s.tileAnchorX,u=s.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(i.collisionVertexArrayExt,t,e.padding,s.zOffset),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,u,new Le(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,u,new Le(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,u,new Le(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,u,new Le(e.x1,e.y2)),a.vertexLength+=4;const h=i.indexArray;h.emplaceBack(l,l+1),h.emplaceBack(l+1,l+2),h.emplaceBack(l+2,l+3),h.emplaceBack(l+3,l),a.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(e,t,o.placedIconSymbolIndex);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}generateCollisionDebugBuffers(e,t,i){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new CollisionBuffers(StructArrayLayout3i2i2i16,hf.members,StructArrayLayout2ui4),this.iconCollisionBox=new CollisionBuffers(StructArrayLayout3i2i2i16,hf.members,StructArrayLayout2ui4);const r=Nf(this.iconSizeData,e),n=Nf(this.textSizeData,e,i);for(let i=0;i<this.symbolInstances.length;i++){const o=this.symbolInstances.get(i);this._addTextDebugCollisionBoxes(n,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(n,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(r,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(r,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,t,i,r){const n=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=Vf(this.textSizeData,e,n)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=Vf(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i,r){e.emplaceBack(t,-i,-i,r),e.emplaceBack(t,i,-i,r),e.emplaceBack(t,i,i,r),e.emplaceBack(t,-i,i,r)}_updateTextDebugCollisionBoxes(e,t,i,r,n,o,s){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding,o.zOffset)}}_updateIconDebugCollisionBoxes(e,t,i,r,n,o,s){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(e,t,o.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding,o.zOffset)}}updateCollisionDebugBuffers(e,t,i,r){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const n=Nf(this.iconSizeData,e,r),o=Nf(this.textSizeData,e,i);for(let s=0;s<this.symbolInstances.length;s++){const a=this.symbolInstances.get(s);this._updateTextDebugCollisionBoxes(o,e,t,a.textBoxStartIndex,a.textBoxEndIndex,a,i),this._updateTextDebugCollisionBoxes(o,e,t,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a,i),this._updateIconDebugCollisionBoxes(n,e,t,a.iconBoxStartIndex,a.iconBoxEndIndex,a,r),this._updateIconDebugCollisionBoxes(n,e,t,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex,a,r)}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,i,r,n,o,s,a,l){const c={};if(t<i){const{x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(t);c.textBox={x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.textFeatureIndex=p}if(r<n){const{x1:t,y1:i,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(r);c.verticalTextBox={x1:t,y1:i,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.verticalTextFeatureIndex=p}if(o<s){const{x1:t,y1:i,x2:r,y2:n,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(o);c.iconBox={x1:t,y1:i,x2:r,y2:n,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.iconFeatureIndex=p}if(a<l){const{x1:t,y1:i,x2:r,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d,featureIndex:p}=e.get(a);c.verticalIconBox={x1:t,y1:i,x2:r,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:u,tileAnchorX:h,tileAnchorY:d},c.verticalIconFeatureIndex=p}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.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 i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<r;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),i=Math.cos(e),r=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);r.push(0|Math.round(t*s.tileAnchorX+i*s.tileAnchorY)),n.push(s.featureIndex)}return o.sort(((e,t)=>r[e]-r[t]||n[t]-n[e])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),r>=0&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}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 i;return this.elevationFeatures&&t<this.elevationFeatures.length&&(i=this.elevationFeatures[t]),i}}function Lm(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))}let Rm,zm,Fm;bs(SymbolBucket,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),SymbolBucket.addDynamicAttributes=Dm;class FormatSectionOverride{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}}bs(FormatSectionOverride,"FormatSectionOverride",{omit:["defaultValue"]});const Om=()=>Fm||(Fm={layout:Rm||(Rm=new Properties({"symbol-placement":new DataConstantProperty(Gs.layout_symbol["symbol-placement"]),"symbol-spacing":new DataConstantProperty(Gs.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new DataConstantProperty(Gs.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new DataDrivenProperty(Gs.layout_symbol["symbol-sort-key"]),"symbol-z-order":new DataConstantProperty(Gs.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new DataConstantProperty(Gs.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new DataConstantProperty(Gs.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new DataConstantProperty(Gs.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new DataConstantProperty(Gs.layout_symbol["icon-ignore-placement"]),"icon-optional":new DataConstantProperty(Gs.layout_symbol["icon-optional"]),"icon-rotation-alignment":new DataConstantProperty(Gs.layout_symbol["icon-rotation-alignment"]),"icon-size":new DataDrivenProperty(Gs.layout_symbol["icon-size"]),"icon-size-scale-range":new DataConstantProperty(Gs.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new DataDrivenProperty(Gs.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new DataDrivenProperty(Gs.layout_symbol["icon-text-fit-padding"]),"icon-image":new DataDrivenProperty(Gs.layout_symbol["icon-image"]),"icon-image-use-theme":new DataConstantProperty({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new DataDrivenProperty(Gs.layout_symbol["icon-rotate"]),"icon-padding":new DataConstantProperty(Gs.layout_symbol["icon-padding"]),"icon-keep-upright":new DataConstantProperty(Gs.layout_symbol["icon-keep-upright"]),"icon-offset":new DataDrivenProperty(Gs.layout_symbol["icon-offset"]),"icon-anchor":new DataDrivenProperty(Gs.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new DataConstantProperty(Gs.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new DataConstantProperty(Gs.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new DataConstantProperty(Gs.layout_symbol["text-rotation-alignment"]),"text-field":new DataDrivenProperty(Gs.layout_symbol["text-field"]),"text-font":new DataDrivenProperty(Gs.layout_symbol["text-font"]),"text-size":new DataDrivenProperty(Gs.layout_symbol["text-size"]),"text-size-scale-range":new DataConstantProperty(Gs.layout_symbol["text-size-scale-range"]),"text-max-width":new DataDrivenProperty(Gs.layout_symbol["text-max-width"]),"text-line-height":new DataDrivenProperty(Gs.layout_symbol["text-line-height"]),"text-letter-spacing":new DataDrivenProperty(Gs.layout_symbol["text-letter-spacing"]),"text-justify":new DataDrivenProperty(Gs.layout_symbol["text-justify"]),"text-radial-offset":new DataDrivenProperty(Gs.layout_symbol["text-radial-offset"]),"text-variable-anchor":new DataConstantProperty(Gs.layout_symbol["text-variable-anchor"]),"text-anchor":new DataDrivenProperty(Gs.layout_symbol["text-anchor"]),"text-max-angle":new DataConstantProperty(Gs.layout_symbol["text-max-angle"]),"text-writing-mode":new DataConstantProperty(Gs.layout_symbol["text-writing-mode"]),"text-rotate":new DataDrivenProperty(Gs.layout_symbol["text-rotate"]),"text-padding":new DataConstantProperty(Gs.layout_symbol["text-padding"]),"text-keep-upright":new DataConstantProperty(Gs.layout_symbol["text-keep-upright"]),"text-transform":new DataDrivenProperty(Gs.layout_symbol["text-transform"]),"text-offset":new DataDrivenProperty(Gs.layout_symbol["text-offset"]),"text-allow-overlap":new DataConstantProperty(Gs.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new DataConstantProperty(Gs.layout_symbol["text-ignore-placement"]),"text-optional":new DataConstantProperty(Gs.layout_symbol["text-optional"]),visibility:new DataConstantProperty(Gs.layout_symbol.visibility)})),paint:zm||(zm=new Properties({"icon-opacity":new DataDrivenProperty(Gs.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new DataDrivenProperty(Gs.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new DataDrivenProperty(Gs.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new DataDrivenProperty(Gs.paint_symbol["text-emissive-strength"]),"icon-color":new DataDrivenProperty(Gs.paint_symbol["icon-color"]),"icon-halo-color":new DataDrivenProperty(Gs.paint_symbol["icon-halo-color"]),"icon-halo-width":new DataDrivenProperty(Gs.paint_symbol["icon-halo-width"]),"icon-halo-blur":new DataDrivenProperty(Gs.paint_symbol["icon-halo-blur"]),"icon-translate":new DataConstantProperty(Gs.paint_symbol["icon-translate"]),"icon-translate-anchor":new DataConstantProperty(Gs.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new DataConstantProperty(Gs.paint_symbol["icon-image-cross-fade"]),"text-opacity":new DataDrivenProperty(Gs.paint_symbol["text-opacity"]),"text-occlusion-opacity":new DataDrivenProperty(Gs.paint_symbol["text-occlusion-opacity"]),"text-color":new DataDrivenProperty(Gs.paint_symbol["text-color"],{runtimeType:Ar,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new DataDrivenProperty(Gs.paint_symbol["text-halo-color"]),"text-halo-width":new DataDrivenProperty(Gs.paint_symbol["text-halo-width"]),"text-halo-blur":new DataDrivenProperty(Gs.paint_symbol["text-halo-blur"]),"text-translate":new DataConstantProperty(Gs.paint_symbol["text-translate"]),"text-translate-anchor":new DataConstantProperty(Gs.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new DataConstantProperty(Gs.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new DataConstantProperty(Gs.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new DataConstantProperty(Gs.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new DataConstantProperty(Gs.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new DataDrivenProperty(Gs.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},Fm);class SymbolStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,Om(),t,i,r,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((i=>{i.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 i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)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,i,r){return this._saturation===e&&this._contrast===t&&this._brightnessMin===i&&this._brightnessMax===r||(this._colorAdjustmentMatrix=function(e,t,i,r){e=Et(e),t=Tt(t);const n=l(),o=e/3,s=1-2*o,a=[s,o,o,0,o,s,o,0,o,o,s,0,0,0,0,1],c=.5-.5*t,u=r-i;return p(n,[u,0,0,0,0,u,0,0,0,0,u,0,i,i,i,1],[t,0,0,0,0,t,0,0,0,0,t,0,c,c,c,1]),p(n,n,a),n}(e,t,i,r),this._saturation=e,this._contrast=t,this._brightnessMin=i,this._brightnessMax=r),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||ds(o.value)||!n?n:Lm(t.properties,n)}getAppearanceValueAndResolveTokens(e,t,i,r,n){const o=e.getProperty(t);if(!o)return;const s=o.evaluate(i,{},r,n),a=e.getUnevaluatedProperties()._values[t];return a.isDataDriven()||ds(a.value)||!s||"string"!=typeof s?s:Lm(i.properties,s)}createBucket(e){return new SymbolBucket(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Om().paint.overridableProperties){if(!SymbolStyleLayer.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new FormatSectionOverride(t),r=new StyleExpression(i,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new ZoomConstantExpression("source",r):new ZoomDependentExpression("composite",r,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new PossiblyEvaluatedPropertyValue(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&SymbolStyleLayer.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=Om().paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Formatted)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof Literal&&Nr(t.value)===Dr?o(t.value.sections):t instanceof FormatExpression?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,t,i){return{config:new ProgramConfiguration(this,{zoom:t,lut:i}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let Bm,km,Um,Vm;var Nm=_a([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function jm(e,t,i,r,n,a,l,c){const u=[e,t,1,i,r,1,n,a,1],h=[l,c,1],d=o([],u),[p,f,m]=W(h,h,d);return s(u,u,[p,0,0,0,f,0,0,0,m])}function Gm(e,t,i,r,n,a,l,c){const u=function(e,t,i,r,n,a,l,c){const u=jm(0,0,1,0,1,1,0,1),h=jm(e,t,i,r,n,a,l,c);return s(h,h,o([],u))}(e,t,i,r,n,a,l,c);return[u[2]/u[8]/Mn,u[5]/u[8]/Mn]}function Hm(e){return[e[0],Math.min(Math.max(e[1],-ol),ol)]}class ImageSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,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(r),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Event("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Oi(this.map._requestManager.transformRequest(this.url,Ii.Image),((t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new ErrorEvent(t)):i&&(this.image=i instanceof HTMLImageElement?Wt.getImageData(i):i,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 UserManagedTexture(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 Event("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 UserManagedTexture||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],i=e[0][1];for(const r of e)r[1]>i&&(i=r[1]),r[1]<t&&(t=r[1]);const r=(i+t)/2;if(r>ol?this.onNorthPole=!0:r<-ol&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(MercatorCoordinate.fromLngLat);this.tileID=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),s=Math.max(0,Math.floor(-Math.log2(o))),a=Math.pow(2,s);let l=Math.floor((t+r)/2*a);return l>1&&(l-=1),new CanonicalTileID(s,l,Math.floor((i+n)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof UserManagedTexture||(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=lm(new CanonicalTileID(0,0,0),this.map.transform.projection),i=[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,i=e[1].y-e[0].y,r=e[2].x-e[1].x,n=e[2].y-e[1].y,o=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*n-r*i,u=r*s-o*n,h=o*l-a*s,d=a*i-t*l;return c>0&&u>0&&h>0&&d>0||c<0&&u<0&&h<0&&d<0}(i))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const r=lm(this.tileID,this.map.transform.projection),[n,a,l,c]=this.coordinates.map((e=>{const t=r.projection.project(e[0],e[1]);return um(r,t)._round()}));this.perspectiveTransform=Gm(n.x,n.y,a.x,a.y,l.x,l.y,c.x,c.y);const u=this._boundsArray=new StructArrayLayout4i8;u.emplaceBack(n.x,n.y,0,0),u.emplaceBack(a.x,a.y,Mn,0),u.emplaceBack(c.x,c.y,0,Mn),u.emplaceBack(l.x,l.y,Mn,Mn),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,Nm.members),this.boundsSegments=SegmentVector.simpleSegment(0,0,4,2);const h=ja,d=[],p=function(e){return[Hm(e[0]),Hm(e[1]),Hm(e[2]),Hm(e[3])]}(this.coordinates),[f,m,_,g]=function(e){let t=e[0][0],i=t,r=e[0][1],n=r;for(let o=1;o<e.length;o++)e[o][0]<t?t=e[o][0]:e[o][0]>i&&(i=e[o][0]),e[o][1]<r?r=e[o][1]:e[o][1]>n&&(n=e[o][1]);return[t,r,i-t,n-r]}(p);{const r=new StructArrayLayout4i8,[n,a,l,c]=function(e){let t=e[0].x,i=t,r=e[0].y,n=r;for(let o=1;o<e.length;o++)e[o].x<t?t=e[o].x:e[o].x>i&&(i=e[o].x),e[o].y<r?r=e[o].y:e[o].y>n&&(n=e[o].y);return[t,r,i-t,n-r]}(i),u=e=>[(e.x-n)/l,(e.y-a)/c],[p,y,x,v]=i.map(u),b=function(e,t,i,r,n,a,l,c){const u=jm(0,0,1,0,1,1,0,1);return s(u,u,o([],jm(e,t,i,r,n,a,l,c)))}(p[0],p[1],y[0],y[1],x[0],x[1],v[0],v[1]);this.elevatedGlobePerspectiveTransform=Gm(p[0],p[1],y[0],y[1],x[0],x[1],v[0],v[1]);const w=(e,t)=>{d.push(e.lng);const i=Math.round((e.lng-f)/_*Mn),n=Math.round((e.lat-m)/g*Mn),o=u(t),s=W([],[o[0],o[1],1],b),a=Math.round(s[0]/s[2]*Mn),l=Math.round(s[1]/s[2]*Mn);r.emplaceBack(i,n,a,l)},T=i[3].x-i[0].x,E=i[3].y-i[0].y,S=i[2].x-i[1].x,A=i[2].y-i[1].y;for(let e=0;e<65;e++){const r=e/h,n=[i[0].x+r*T,i[0].y+r*E],o=[i[1].x+r*S,i[1].y+r*A],s=o[0]-n[0],a=o[1]-n[1];for(let e=0;e<65;e++){const i=e/h,r={x:n[0]+s*i,y:n[1]+a*i};w(t.projection.unproject(r.x,r.y),r)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(r,Nm.members)}{this.maxLongitudeTriangleSize=0;let t=[],i=new StructArrayLayout3ui6;const r=(e,r,n)=>{i.emplaceBack(e,r,n);const o=d[e],s=d[r],a=d[n],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let e=0;e<h;e++)for(let t=0;t<h;t++){const i=65*e+t,n=i+1,o=i+65,s=o+1;r(i,o,n),r(n,o,s)}[t,i]=function(e,t){const i=Array.from({length:e.length},((e,t)=>t));i.sort(((t,i)=>e[t]-e[i]));const r=[],n=new StructArrayLayout3ui6;for(let o=0;o<i.length;o++){const s=i[o];r.push(e[s]);const a=3*s,l=a+1;n.emplaceBack(t.uint16[a],t.uint16[l],t.uint16[l+1])}return[r,n]}(t,i),this.elevatedGlobeTrianglesCenterLongitudes=t,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(i)}this.elevatedGlobeSegments=SegmentVector.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,_/Mn,0,g/Mn,0,0,m,f,0])}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const t=this.map.painter.context,i=t.gl;!this._dirty||this.texture instanceof UserManagedTexture||(this.texture?this.texture.update(this.image):(this.texture=new Texture(t,this.image,i.RGBA8),this.texture.bind(i.LINEAR,i.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 i=this.elevatedGlobeTrianglesCenterLongitudes;let r=(n=e+180)+360*Math.round((i[0]-n)/360);var n;const o=new SegmentVector,s=(e,i)=>{o.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-r)<=a){const e=wt(i,0,i.length,r+a);return e===i.length||s(e,bt(i,e+1,i.length,r+360-a)-e),o}r<i[0]&&(r+=360);const l=bt(i,0,i.length,r-a);if(l===i.length)return s(0,i.length),o;s(0,l-0);const c=wt(i,l+1,i.length,r+a);return c!==i.length&&s(c,i.length-c),o}}const qm=256,$m=(Math.pow(qm,2)-1)/16907520;class RasterStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Um||(Um=new Properties({visibility:new DataConstantProperty(Gs.layout_raster.visibility)})),paint:Vm||(Vm=new Properties({"raster-opacity":new DataConstantProperty(Gs.paint_raster["raster-opacity"]),"raster-color":new ColorRampProperty(Gs.paint_raster["raster-color"]),"raster-color-mix":new DataConstantProperty(Gs.paint_raster["raster-color-mix"]),"raster-color-range":new DataConstantProperty(Gs.paint_raster["raster-color-range"]),"raster-hue-rotate":new DataConstantProperty(Gs.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new DataConstantProperty(Gs.paint_raster["raster-brightness-min"]),"raster-brightness-max":new DataConstantProperty(Gs.paint_raster["raster-brightness-max"]),"raster-saturation":new DataConstantProperty(Gs.paint_raster["raster-saturation"]),"raster-contrast":new DataConstantProperty(Gs.paint_raster["raster-contrast"]),"raster-resampling":new DataConstantProperty(Gs.paint_raster["raster-resampling"]),"raster-fade-duration":new DataConstantProperty(Gs.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new DataConstantProperty(Gs.paint_raster["raster-emissive-strength"]),"raster-array-band":new DataConstantProperty(Gs.paint_raster["raster-array-band"]),"raster-elevation":new DataConstantProperty(Gs.paint_raster["raster-elevation"]),"raster-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),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 ImageSource&&(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,[i,r]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(i)&&isNaN(r)||i===this._curRampRange[0]&&r===this._curRampRange[1]||(this.colorRamp=Jc({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:i,end:r}],resolution:qm}),this.colorRampTexture=null,this._curRampRange=[i,r])}}let Zm,Wm,Xm,Ym,Km,Jm,Qm;class RasterParticleStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Zm||(Zm=new Properties({visibility:new DataConstantProperty(Gs["layout_raster-particle"].visibility)})),paint:Wm||(Wm=new Properties({"raster-particle-array-band":new DataConstantProperty(Gs["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new DataConstantProperty(Gs["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new ColorRampProperty(Gs["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new DataConstantProperty(Gs["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new DataConstantProperty(Gs["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new DataConstantProperty(Gs["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new DataConstantProperty(Gs["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new DataConstantProperty(Gs["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),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=Jc({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 CustomStyleLayer extends StyleLayer{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 e_(e,t,i){const r=[0,0,1],n=le([]);return ue(n,n,i?-Oe(e)+Math.PI:Oe(e)),ce(n,n,-Oe(t)),X(r,r,n),G(r,r)}class ValidationError{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}class ValidationWarning extends ValidationError{}function t_(e,t){const i=-1===e.indexOf("://");try{return new URL(e,i&&t?"http://example.com":void 0),!0}catch(e){return!1}}function i_(e){const t=e.value;return t?$r(t)?t_(t,!0)?[]:[new ValidationError(e.key,t,`invalid url "${t}"`)]:[new ValidationError(e.key,t,`string expected, "${Hr(t)}" found`)]:[]}class ModelFeature{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 PerModelAttributes{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new StructArrayLayout16f64,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(e){const t=16*e,i=this.instancedDataArray.float32;let r=Math.floor(i[t+2]);const n=1.05*(i[t+2]-r);return r/=100,[i[t]%1*1.05,i[t+1]%1*1.05,n,r]}tileCoordinatesForInstance(e){const t=16*e,i=this.instancedDataArray.float32;let r=i[t+0];return r=r>Mn?r-Mn:r,new Le(Math.trunc(r),Math.trunc(i[t+1]))}translationForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+4],i[t+5],i[t+6]]}rotationScaleForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+7],i[t+8],i[t+9],i[t+10],i[t+11],i[t+12],i[t+13],i[t+14],i[t+15]]}transformForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+7],i[t+8],i[t+9],i[t+4],i[t+10],i[t+11],i[t+12],i[t+5],i[t+13],i[t+14],i[t+15],i[t+6],0,0,0,1]}}class ModelBucket{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,i,r){}populate(e,t,i,r){this.tileToMeter=cl(i);const n=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=yl(o,n);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:e,sourceLayerIndex:l,index:a,geometry:n?c.geometry:gl(o,i,r),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(u,u.geometry,c);h&&t.featureIndex.insert(o,u.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length,Mn/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let i=0;for(const r of this.modelUris){const n=e.getModel(r,t);if(!n)continue;const o=this.instancesPerModel[r];if(o){const e=.5*U(n.aabb.max,n.aabb.min)*o.maxScale+o.maxXYTranslationDistance,t=Math.min(Mn,Math.max(e/this.tileToMeter,Mn/32));i=Math.max(t,i)}}return i}update(e,t,i,r){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)i.idToFeaturesIndex.hasOwnProperty(t)&&(this.evaluate(i.features[i.idToFeaturesIndex[t]],e[t],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t of i.features){const r=this.layers[0],n=t.feature,o=this.canonical,s=r.paint.get("model-rotation").evaluate(n,{},o),a=r.paint.get("model-scale").evaluate(n,{},o),l=r.paint.get("model-translation").evaluate(n,{},o);K(t.rotation,s)&&K(t.scale,a)&&K(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0)}}return e}updateReplacement(e,t,i,r){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(ah(this.activeReplacements,n))return!1;this.activeReplacements=n;let o=!1;for(const t in this.instancesPerModel){const n=this.instancesPerModel[t],s=n.instancedDataArray;for(const t of n.features){const n=t.instancedDataOffset,a=t.instancedDataCount;for(let t=0;t<a;t++){const a=16*(t+n);let l=s.float32[a+0];const c=l>Mn;l=c?l-Mn:l;const u=Math.floor(l),h=Math.floor(s.float32[a+1]);let d=!1;for(const t of this.activeReplacements)if(!rh(t,i,1,r)&&!(t.min.x>u||u>t.max.x||t.min.y>h||h>t.max.y)&&(d=ph(dh(u,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;s.float32[a]=d?l+Mn:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[t];i.instancedDataArray.length<0||0===i.instancedDataArray.length||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,Vd.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,i){const r=this.layers[0],n=r.layout.get("model-id").evaluate(i,{},this.canonical);if(!n)return st(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),n;(t_(n,!1)||void 0!==this.styleDefinedModelURLs[n])&&(this.modelUris.includes(n)||this.modelUris.push(n)),this.instancesPerModel[n]||(this.instancesPerModel[n]=new PerModelAttributes);const o=this.instancesPerModel[n],s=o.instancedDataArray,a=new ModelFeature(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=Mn||t.y<0||t.y>=Mn)continue;if(0!==this.lookupDim){const e=(this.lookupDim-1)/Mn,i=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}}this.instanceCount++;const e=s.length;s.resize(e+1),o.instancesEvaluatedElevation.push(0),s.float32[16*e]=t.x,s.float32[16*e+1]=t.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),n}getModelUris(){return this.modelUris}evaluate(e,t,i,r){const n=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=n.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=n.paint.get("model-scale").evaluate(o,t,s),c=e.translation=n.paint.get("model-translation").evaluate(o,t,s),u=Object.assign({},n.paint.get("model-color").evaluate(o,t,s));u.a=n.paint.get("model-color-mix-intensity").evaluate(o,t,s);const h=[];this.maxVerticalOffset<c[2]&&(this.maxVerticalOffset=c[2]);const d=c[0]*c[0]+c[1]*c[1],p=d>0?Math.sqrt(d):0;i.maxScale=Math.max(Math.max(i.maxScale,l[0]),Math.max(l[1],l[2])),i.maxXYTranslationDistance=Math.max(i.maxXYTranslationDistance,p),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Wd(h,a,l);const f=Math.round(100*u.a)+u.b/1.05;for(let t=0;t<e.instancedDataCount;++t){const n=e.instancedDataOffset+t,o=16*n,a=i.instancedDataArray.float32;let l=0;r&&(l=a[o+6]-i.instancesEvaluatedElevation[n]);const d=0|a[o+1];a[o]=(0|a[o])+u.r/1.05,a[o+1]=d+u.g/1.05,a[o+2]=f,a[o+3]=1/(s.z>10?this.tileToMeter:cl(s,d)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=h[0],a[o+8]=h[1],a[o+9]=h[2],a[o+10]=h[4],a[o+11]=h[5],a[o+12]=h[6],a[o+13]=h[8],a[o+14]=h[9],a[o+15]=h[10],i.instancesEvaluatedElevation[n]=c[2]}}}bs(ModelBucket,"ModelBucket",{omit:["layers"]}),bs(PerModelAttributes,"PerModelAttributes"),bs(ModelFeature,"ModelFeature");class Elevation{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,r=1<<i,n=Math.floor(e.x),o=Math.floor((e.x-n)*r),s=Math.floor(e.y*r),a=this.findDEMTileFor(new OverscaledTileID(i,n,i,o,s));return!(!a||!a.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){if(this.isUsingMockSource())return null;null==t&&(t=null);const r=this._source();if(!r)return t;if(e.y<0||e.y>1)return t;const n=r.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),a=e.x-s,l=new OverscaledTileID(n,s,n,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const u=c.dem,h=1<<c.tileID.canonical.z,d=(a*h-c.tileID.canonical.x)*u.dim,p=(e.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(d),m=Math.floor(p);return(i?this.exaggeration():1)*xr(xr(u.get(f,m),u.get(f,m+1),p-m),xr(u.get(f+1,m),u.get(f+1,m+1),p-m),d-f)}static getAtTileOffset(e,t,i,r){const n=1<<e.canonical.z;return r?r.pointElevation(t):i?i.getAtPointOrZero(new MercatorCoordinate(e.wrap+(e.canonical.x+t.x/Mn)/n,(e.canonical.y+t.y/Mn)/n)):0}static getAtTileOffsetFunc(e,t,i,r){return(n,o,s)=>{const a=this.getAtTileOffset(e,n,o,s),l=r.upVector(e.canonical,n.x,n.y);return B(l,l,a*r.upVectorScale(e.canonical,t,i).metersToTile),l}}getForTilePoints(e,t,i,r){if(this.isUsingMockSource())return!1;const n=DEMSampler.create(this,e,r);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<<e.canonical.z-r.canonical.z;let o=e.canonical.x/n-r.canonical.x,s=e.canonical.y/n-r.canonical.y,a=0;for(let t=0;t<e.canonical.z-r.canonical.z&&!i.leaves[a];t++){o*=2,s*=2;const e=2*Math.floor(s)+Math.floor(o);a=i.childOffsets[a]+e,o%=1,s%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){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,i=Number.MAX_VALUE,r=Number.MIN_VALUE;for(const n of e){const e=this.getMinMaxForTile(n.tileID);e&&(i=Math.min(i,e.min),r=Math.max(r,e.max),t=!0)}return t?{min:i,max:r}:null}}class DEMSampler{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const r=i||e.findDEMTileFor(t);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,s=1<<t.canonical.z-o.canonical.z;return new DEMSampler(r,n.dim/Mn/s,[(t.canonical.x/s-o.canonical.x)*n.dim,(t.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1];return new Le(Math.floor(e*this._scale+this._offset[0]),Math.floor(i))}getElevationAt(e,t,i,r){const n=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],s=Math.floor(n),a=Math.floor(o),l=this._dem;return r=!!r,i?xr(xr(l.get(s,a,r),l.get(s,a+1,r),o-a),xr(l.get(s+1,a,r),l.get(s+1,a+1,r),o-a),n-s):l.get(s,a,r)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*tl(1,e)*this._dem.stride}}const r_=new Float32Array(262144),n_=new Uint8Array(262144);function o_(e){let t=0;if(e.meshes)for(const i of e.meshes)t=Math.max(t,i.aabb.max[2]);if(e.children)for(const i of e.children)t=Math.max(t,o_(i));return t}function s_(e,t,i){if(e.meshes)for(const r of e.meshes){if(r.aabb.min[0]===1/0)continue;const n=Aabb.applyTransform(r.aabb,e.globalMatrix);i.insert(t,n.min[0],n.min[1],n.max[0],n.max[1])}if(e.children)for(const r of e.children)s_(r,t,i)}const a_=["","wall","door","roof","window","lamp","logo"];class Tiled3dModelFeature{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:o_(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==e&&(i.transformedAabb=Aabb.applyTransformFast(i.aabb,this.node.globalMatrix),t.encapsulate(i.transformedAabb)),e++;this.aabb=t}return this.aabb}}class Tiled3dModelBucket{constructor(e,t,i,r,n,o,s,a){this.id=i,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|=1,this.uploaded=!1,this.hasPattern=!1,r&&(this.modelTraits|=4),n&&(this.modelTraits|=8),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=a,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Tiled3dModelFeature(e)),s_(e,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,t){for(const i of this.getNodesInfo()){const r=i.node;r.footprint&&t.push({footprint:r.footprint,id:e})}}updateAppearances(e,t,i,r){}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const i=t?this.stateDependentLayers:this.layers;if(!Re(e,this.states))for(const t of i)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 i of t){const t=i.node;this.uploaded?this.updatePbrBuffer(t):ip(t,e,!0)}for(const e of t)rp(e.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);return t}needsReEvaluation(e,t,i){const r=e.transform.projectionOptions,n=e.style.getBrightness(),o=this.brightness!==n;if(!this.uploaded||this.dirty||r.name!==this.projection.name||l_(i.paint.get("model-color").value,o)||l_(i.paint.get("model-color-mix-intensity").value,o)||l_(i.paint.get("model-roughness").value,o)||l_(i.paint.get("model-emissive-strength").value,o)||l_(i.paint.get("model-height-based-emissive-strength-multiplier").value,o)){this.projection=r,this.brightness=n;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 i=this.getNodesInfo(),r=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(i,{},r),e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},r)}}evaluate(e,t){const i=this.getNodesInfo();for(const r of i){if(!r.node.meshes)continue;const i=r.feature,n=t&&t[i.id];if(Re(n,r.state))continue;r.state=structuredClone(n);const o=r.node.meshes&&r.node.meshes[0].featureData,s=r.evaluatedColor[2],a=r.evaluatedRMEA[2],l=this.id.canonical;if(r.hasTranslucentParts=!1,o){for(let t=0;t<a_.length;t++){const o=a_[t];o.length&&(i.properties.part=o);const s=e.paint.get("model-color").evaluate(i,n,l).toPremultipliedRenderColor(null),a=e.paint.get("model-color-mix-intensity").evaluate(i,n,l);r.evaluatedColor[t]=[s.r,s.g,s.b,a],r.evaluatedRMEA[t][0]=e.paint.get("model-roughness").evaluate(i,n,l),r.evaluatedRMEA[t][2]=e.paint.get("model-emissive-strength").evaluate(i,n,l),r.evaluatedRMEA[t][3]=s.a,r.emissionHeightBasedParams[t]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(i,n,l),!r.hasTranslucentParts&&s.a<1&&(r.hasTranslucentParts=!0)}delete i.properties.part,u_(r,s!==r.evaluatedColor[2]||a!==r.evaluatedRMEA[2],this.modelTraits)}else r.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(i,n,l);r.evaluatedTranslation=e.paint.get("model-translation").evaluate(i,n,l),r.evaluatedScale=e.paint.get("model-scale").evaluate(i,n,l),this.updatePbrBuffer(r.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,t,i,r){const n=e.findDEMTileFor(i);if(n&&(n.tileID.canonical!==this.terrainTile||t!==this.terrainExaggeration)){if(n.dem&&n.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=n.tileID.overscaledZ;const t=DEMSampler.create(e,i,n);if(!t)return;4&this.modelTraits&&this.updateDEM(e,t,i,r);for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.vertices||!i.footprint.vertices.length)continue;const r=i.footprint.vertices;let n=t.getElevationAt(r[0].x,r[0].y,!0,!0);for(let e=1;e<r.length;e++)n=Math.min(n,t.getElevationAt(r[e].x,r[e].y,!0,!0));i.elevation=n}}this.terrainTile=n.tileID.canonical,this.terrainExaggeration=t}}updateDEM(e,t,i,r){let n=t._dem._modifiedForSources[r];if(void 0===n&&(t._dem._modifiedForSources[r]=[],n=t._dem._modifiedForSources[r]),n.includes(i.canonical))return;const o=t._dem.dim;n.push(i.canonical);let s=!1;for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.grid)continue;const r=i.footprint.grid,n=t.tileCoordToPixel(r.min.x,r.min.y),a=t.tileCoordToPixel(r.max.x,r.max.y),l=Math.min(Math.min(o-a.y,n.x),Math.min(n.y,o-a.x));if(l<0)continue;const c=He(l,2,5);let u=Math.max(0,n.x-c),h=Math.max(0,n.y-c),d=Math.min(a.x+c,o-1),p=Math.min(a.y+c,o-1);for(let e=h;e<=p;++e)for(let t=u;t<=d;++t)n_[e*o+t]=255;let f=0,m=0;for(let e=0;e<r.cellsY;++e)for(let i=0;i<r.cellsX;++i){if(!r.cells[e*r.cellsX+i])continue;const n=t.tileCoordToPixel(r.min.x+i/r.xScale,r.min.y+e/r.yScale),s=t.tileCoordToPixel(r.min.x+(i+1)/r.xScale,r.min.y+(e+1)/r.yScale);for(let e=n.y;e<=Math.min(s.y+1,o-1);++e)for(let i=n.x;i<=Math.min(s.x+1,o-1);++i)255===n_[e*o+i]&&(n_[e*o+i]=0,f+=t.getElevationAtPixel(i,e),m++)}const _=f/m;u=Math.max(1,n.x-c),h=Math.max(1,n.y-c),d=Math.min(a.x+c,o-2),p=Math.min(a.y+c,o-2),s=!0;for(let e=h;e<=p;++e)for(let i=u;i<=d;++i)0===n_[e*o+i]&&(r_[e*o+i]=t._dem.set(i,e,_));for(let e=1;e<c;++e){u=Math.max(1,n.x-e),h=Math.max(1,n.y-e),d=Math.min(a.x+e,o-2),p=Math.min(a.y+e,o-2);for(let i=h;i<=p;++i)for(let r=u;r<=d;++r){const n=i*o+r;if(255===n_[n]){let s=0,a=0,l=-1,u=-1;for(let t=-1;t<=1;++t)for(let n=-1;n<=1;++n){const c=(i+t)*o+r+n;if(n_[c]>=e)continue;const h=r_[c],d=Math.abs(h);d>a&&(s=h,a=d,l=n,u=t)}if(a>.1){const o=1-(e+.5*Math.abs(l*u))/c;let a=t._dem.get(r,i)+s*o;const h=t._dem.get(r+l,i+u),d=t._dem.get(r-l,i-u,!0);(a-h)*(a-d)>0&&(a=(h+d)/2),r_[n]=t._dem.set(r,i,a),n_[n]=e}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=Wt.now())}setFilter(e){this.filter=e?Zs(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter((e=>this.filter.filter(new EvaluationParameters(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical))):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)rp(t.node),np(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!i.find((e=>e.footprint===t))}}getHeightAtTileCoord(e,t){const i=[],r=[0,0,0],n=u([]);for(const o of this.getNodesInfo()){const s=o.node.meshes[0],a=s.transformedAabb;if(e<a.min[0]||t<a.min[1]||e>a.max[0]||t>a.max[1])continue;if(!0===o.node.hidden)return{height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};d(n,o.node.globalMatrix),r[0]=e,r[1]=t,Z(r,r,n);const l=(r[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*64|0,c=64*Math.min(63,(r[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*64|0)+Math.min(63,l),u=s.heightmap[c];if(!(u<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:u,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new Le(e,t),new Le(e,t),i),i.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function l_(e,t){return e instanceof ZoomConstantExpression&&!e.isLightConstant&&t}function c_(e,t,i,r,n,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,u=240&t|(240&t)>>4;i[3]>0&&(l=xr(l,255*i[0],i[3]),c=xr(c,255*i[1],i[3]),u=xr(u,255*i[2],i[3]));const h=l<<8|c,d=u<<8|Math.floor(255*r[3]),p=function(e){const t=He(e,0,2);return Math.min(Math.round(.5*t*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],f=He(n[0],0,1),m=He(n[1],0,1),_=He(n[2],0,1),g=He(n[3],0,1);let y,x,v,b;if(f!==m&&s!==o&&m!==f){const e=s-o;x=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=He(n[4],-1,1);b=Math.pow(10,t),y=255*_<<8|255*g}else y=65535,x=0,v=1,b=1;if(e.emplaceBack(h,d,p,y,x,v,b),a){const e=a.length;a.clear();for(let t=0;t<e;t++)a.emplaceBack(h,d,p,y,x,v,b)}}function u_(e,t,i){const r=e.node;let n=0;const o=8&i;for(const i of r.meshes){if(r.lights&&r.lightMeshIndex===n)continue;if(!i.featureData)continue;i.featureArray=new StructArrayLayout4ui3f20,i.featureArray.reserve(i.featureData.length);let s=t;for(const t of i.featureData){const n=o?65535&t:t>>16&65535,a=o?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],u=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(s&&2===l&&r.lights&&(d=new StructArrayLayout4ui3f20,d.resize(10*r.lights.length)),c_(i.featureArray,n,u,c,h,i.aabb.min[2],i.aabb.max[2],d),d&&s){s=!1;const e=r.meshes[r.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),n++}}bs(Tiled3dModelBucket,"Tiled3dModelBucket",{omit:["layers"]}),bs(Tiled3dModelFeature,"Tiled3dModelFeature");const h_=["id","tile","layer","source","sourceLayer","state"];class Feature{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e?e.properties:{},this.id=n}clone(){const e=new Feature(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 h_)void 0!==this[t]&&(e[t]=this[t]);return e}}class TargetFeature extends Feature{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}}class ModelSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t,this._modelsInfo=new Map}load(){const e=[];for(const t in this._options.models){const i=this._options.models[t],r=this._modelsInfo.get(t);if(r){const e=r.model;e.position=null!=i.position?new LngLat(i.position[0],i.position[1]):new LngLat(0,0),e.orientation=null!=i.orientation?i.orientation:[0,0,0],r.modelSpec=i,ModelSource.applyModelSpecification(e,i),e.computeBoundsAndApplyParent(),this.models.push(e)}else{const r=Ld(this.map._requestManager.transformRequest(i.uri,Ii.Model).url).then((e=>{if(!e)return;const r=dp(e),n=new Model(t,i.uri,i.position,i.orientation,r);ModelSource.applyModelSpecification(n,i),n.computeBoundsAndApplyParent(),this.models.push(n),this._modelsInfo.set(t,{modelSpec:i,model:n})})).catch((e=>{this.fire(new ErrorEvent(new Error(`Could not load model ${t} from ${i.uri}: ${e.message}`)))}));e.push(r)}}Promise.allSettled(e).then((()=>{this._loaded=!0,this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((e=>{this._loaded=!0,this.fire(new ErrorEvent(new Error(`Could not load models: ${e.message}`)))}))}static applyModelSpecification(e,t){t.nodeOverrides&&ModelSource.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&ModelSource.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 i of t)e.nodeOverrideNames.push(i)}else Object.entries(t).forEach((([t,i])=>{const r={orientation:[0,0,0]};if(i.hasOwnProperty("orientation")){const e=i.orientation;e&&(r.orientation=e)}e.nodeOverrides.set(t,r)}))}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every((e=>"string"==typeof e))){e.materialOverrideNames=[];for(const i of t)e.materialOverrideNames.push(i)}else Object.entries(t).forEach((([t,i])=>{const r={color:new Color(1,1,1),colorMix:0,emissionStrength:0,opacity:1},n=i["model-color"];void 0!==n&&(r.color.r=n[0],r.color.g=n[1],r.color.b=n[2]);const o=i["model-color-mix-intensity"];void 0!==o&&(r.colorMix=o);const s=i["model-emissive-strength"];void 0!==s&&(r.emissionStrength=s);const a=i["model-opacity"];void 0!==a&&(r.opacity=a),e.materialOverrides.set(t,r)}))}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return!1}reload(){const e=aa(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(e){this.models=[];const t=new Map;for(const i in e){const r=e[i];if(this._modelsInfo.has(i)){const e=this._modelsInfo.get(i);e&&e.modelSpec.uri===r.uri&&t.set(i,e)}}this._modelsInfo=t,this._options.models=e,this._loaded=!1,this.load()}}function d_(e,t,i,r){const n=1<<e.z;t.lat=rl((r/Mn+e.y)/n),t.lng=il((i/Mn+e.x)/n)}function p_(e,t,i,r){const n=e.getNodesInfo()[t];if(!n||n.hiddenByReplacement||!n.node.meshes)return;let o=Number.MAX_VALUE;const s=n.node,a=i.tile,l=r.calculatePosMatrix(a.tileID.toUnwrapped(),r.worldSize),c=n.evaluatedScale;let u=0;r.elevation&&s.elevation&&(u=s.elevation*r.elevation.exaggeration()),f(l,l,[(s.anchor?s.anchor[0]:0)*(c[0]-1),(s.anchor?s.anchor[1]:0)*(c[1]-1),u]),m(l,l,c);const h=i.queryGeometry,d=h.isPointQuery()?h.screenBounds:h.screenGeometry,_=function(e){const t=p([],l,e.globalMatrix);p(t,r.expandedFarZProjMatrix,t);for(let i=0;i<e.meshes.length;++i){const n=e.meshes[i];if(i===e.lightMeshIndex)continue;const s=Kd(d,r,t,n.aabb);null!=s&&(o=Math.min(s,o))}if(e.children)for(const t of e.children)_(t)};if(_(s),o===Number.MAX_VALUE)return;const g=new LngLat(0,0);return d_(a.tileID.canonical,g,n.node.anchor[0],n.node.anchor[1]),{intersectionZ:o,position:g,feature:n.feature}}const f_={circle:class CircleStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Kl||(Kl=new Properties({"circle-sort-key":new DataDrivenProperty(Gs.layout_circle["circle-sort-key"]),"circle-elevation-reference":new DataConstantProperty(Gs.layout_circle["circle-elevation-reference"]),visibility:new DataConstantProperty(Gs.layout_circle.visibility)})),paint:Jl||(Jl=new Properties({"circle-radius":new DataDrivenProperty(Gs.paint_circle["circle-radius"]),"circle-color":new DataDrivenProperty(Gs.paint_circle["circle-color"]),"circle-blur":new DataDrivenProperty(Gs.paint_circle["circle-blur"]),"circle-opacity":new DataDrivenProperty(Gs.paint_circle["circle-opacity"]),"circle-translate":new DataConstantProperty(Gs.paint_circle["circle-translate"]),"circle-translate-anchor":new DataConstantProperty(Gs.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new DataConstantProperty(Gs.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new DataConstantProperty(Gs.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new DataDrivenProperty(Gs.paint_circle["circle-stroke-width"]),"circle-stroke-color":new DataDrivenProperty(Gs.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new DataDrivenProperty(Gs.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new DataConstantProperty(Gs.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r)}createBucket(e){return new CircleBucket(e)}queryRadius(e){const t=e;return Zl("circle-radius",this,t)+Zl("circle-stroke-width",this,t)+Wl(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=Yl(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return Vc(e,r,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getDefaultProgramParams(e,t,i){const r=Uc(this);return{config:new ProgramConfiguration(this,{zoom:t,lut:i}),defines:r,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 HeatmapStyleLayer extends StyleLayer{createBucket(e){return new HeatmapBucket(e)}constructor(e,t,i,r){super(e,{layout:qc||(qc=new Properties({visibility:new DataConstantProperty(Gs.layout_heatmap.visibility)})),paint:$c||($c=new Properties({"heatmap-radius":new DataDrivenProperty(Gs.paint_heatmap["heatmap-radius"]),"heatmap-weight":new DataDrivenProperty(Gs.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new DataConstantProperty(Gs.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ColorRampProperty(Gs.paint_heatmap["heatmap-color"]),"heatmap-opacity":new DataConstantProperty(Gs.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Jc({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 Zl("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=this.paint.get("heatmap-radius").evaluate(t,i);return Vc(e,r,o,s,a,!0,!0,new Le(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t,i){return"heatmap"===e?{config:new ProgramConfiguration(this,{zoom:t,lut:i}),overrideFog:!1}:{}}},hillshade:class HillshadeStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Zc||(Zc=new Properties({visibility:new DataConstantProperty(Gs.layout_hillshade.visibility)})),paint:Wc||(Wc=new Properties({"hillshade-illumination-direction":new DataConstantProperty(Gs.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new DataConstantProperty(Gs.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new DataConstantProperty(Gs.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new DataConstantProperty(Gs.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new DataConstantProperty(Gs.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new DataConstantProperty(Gs.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new DataConstantProperty(Gs.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r)}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,i){return{overrideFog:!1}}},fill:class FillStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:ju||(ju=new Properties({"fill-sort-key":new DataDrivenProperty(Gs.layout_fill["fill-sort-key"]),visibility:new DataConstantProperty(Gs.layout_fill.visibility),"fill-elevation-reference":new DataConstantProperty(Gs.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new DataDrivenProperty(Gs.layout_fill["fill-construct-bridge-guard-rail"])})),paint:Gu||(Gu=new Properties({"fill-antialias":new DataConstantProperty(Gs.paint_fill["fill-antialias"]),"fill-opacity":new DataDrivenProperty(Gs.paint_fill["fill-opacity"]),"fill-color":new DataDrivenProperty(Gs.paint_fill["fill-color"]),"fill-outline-color":new DataDrivenProperty(Gs.paint_fill["fill-outline-color"]),"fill-translate":new DataConstantProperty(Gs.paint_fill["fill-translate"]),"fill-translate-anchor":new DataConstantProperty(Gs.paint_fill["fill-translate-anchor"]),"fill-pattern":new DataDrivenProperty(Gs.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new DataConstantProperty(Gs.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new DataConstantProperty(Gs.paint_fill["fill-emissive-strength"]),"fill-z-offset":new DataDrivenProperty(Gs.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new DataDrivenProperty(Gs.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new DataDrivenProperty(Gs.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(e,t,i){return{config:new ProgramConfiguration(this,{zoom:t,lut:i}),overrideFog:!1}}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new FillBucket(e)}queryRadius(){return Wl(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,r,n,o){return!e.queryGeometry.isAboveHorizon&&Rl(Xl(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}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 FillExtrusionStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:jh||(jh=new Properties({visibility:new DataConstantProperty(Gs["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new DataConstantProperty(Gs["layout_fill-extrusion"]["fill-extrusion-edge-radius"])})),paint:Gh||(Gh=new Properties({"fill-extrusion-opacity":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new DataDrivenProperty(Gs["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new DataDrivenProperty(Gs["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new DataDrivenProperty(Gs["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new DataDrivenProperty(Gs["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new DataDrivenProperty(Gs["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new DataDrivenProperty(Gs["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new DataDrivenProperty(Gs["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new DataDrivenProperty(Gs["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new DataConstantProperty(Gs["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new FillExtrusionBucket(e)}queryRadius(){return Wl(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,i,r,n,o,s,a,l){const c=Yl(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(t,i),h=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],p=a&&o.elevation,f=o.elevation?o.elevation.exaggeration():1,m=e.tile.getBucket(this);if(p&&m instanceof FillExtrusionBucket){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"===o.projection.name&&(r=Vh([r],[new Le(0,0),new Le(Mn,Mn)],e.tileID.canonical).map((e=>e.polygon)).flat());const _=p?a:null,[g,y]=Jh(o,r,h,u,c,s,_,d,f,o.center.lat,e.tileID.canonical),x=e.queryGeometry;return Kh(g,y,x.isPointQuery()?x.screenBounds:x.screenGeometry)}},building:class BuildingStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Mp||(Mp=new Properties({visibility:new DataConstantProperty(Gs.layout_building.visibility),"building-facade":new DataDrivenProperty(Gs.layout_building["building-facade"]),"building-facade-floors":new DataDrivenProperty(Gs.layout_building["building-facade-floors"]),"building-facade-unit-width":new DataDrivenProperty(Gs.layout_building["building-facade-unit-width"]),"building-facade-window":new DataDrivenProperty(Gs.layout_building["building-facade-window"]),"building-roof-shape":new DataDrivenProperty(Gs.layout_building["building-roof-shape"]),"building-height":new DataDrivenProperty(Gs.layout_building["building-height"]),"building-base":new DataDrivenProperty(Gs.layout_building["building-base"]),"building-flood-light-wall-radius":new DataDrivenProperty(Gs.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new DataDrivenProperty(Gs.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new DataDrivenProperty(Gs.layout_building["building-flip-roof-orientation"])})),paint:Dp||(Dp=new Properties({"building-opacity":new DataConstantProperty(Gs.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new DataConstantProperty(Gs.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new DataConstantProperty(Gs.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new DataConstantProperty(Gs.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new DataConstantProperty(Gs.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new DataConstantProperty(Gs.paint_building["building-vertical-scale"]),"building-cast-shadows":new DataConstantProperty(Gs.paint_building["building-cast-shadows"]),"building-color":new DataDrivenProperty(Gs.paint_building["building-color"]),"building-emissive-strength":new DataDrivenProperty(Gs.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new DataConstantProperty(Gs.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new DataConstantProperty(Gs.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new DataConstantProperty(Gs.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new DataConstantProperty(Gs.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new DataConstantProperty(Gs.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new BuildingBucket(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,i,r,n,o,s,a,l){let c=this.layout.get("building-height").evaluate(t,i);const u=this.layout.get("building-base").evaluate(t,i),h=e.tile.getBucket(this).getFootprint(t);if(h){if(0!==h.hiddenFlags)return!1;c=h.height}const[d,p]=Jh(o,r,u,c,new Le(0,0),s,null,[0,0],1,o.center.lat,e.tileID.canonical),f=e.queryGeometry;return Kh(d,p,f.isPointQuery()?f.screenBounds:f.screenGeometry)}},line:class LineStyleLayer extends StyleLayer{constructor(e,t,i,r){const n=Qp();super(e,n,t,i,r),n.layout&&(this.layout=new PossiblyEvaluated(n.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 Step,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(ef)return ef;const e=Qp();return ef=new LineFloorwidthProperty(e.paint.properties["line-width"].specification),ef.useIntegerZoom=!0,ef})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new LineBucket(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,t,i){const r=Yp(this);return{config:new ProgramConfiguration(this,{zoom:t,lut:i}),defines:r,overrideFog:!1}}queryRadius(e){const t=e,i=tf(Zl("line-width",this,t),Zl("line-gap-width",this,t)),r=Zl("line-offset",this,t);return i/2+Math.abs(r)+Wl(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,r,n,o){if(e.queryGeometry.isAboveHorizon)return!1;const s=Xl(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*tf(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=function(e,t){const i=[],r=new Le(0,0);for(let n=0;n<e.length;n++){const o=e[n],s=[];for(let e=0;e<o.length;e++){const i=o[e],n=o[e+1],a=0===e?r:i.sub(o[e-1])._unit()._perp(),l=e===o.length-1?r:n.sub(i)._unit()._perp(),c=a._add(l)._unit();c._mult(1/(c.x*l.x+c.y*l.y)),s.push(c._mult(t)._add(i))}i.push(s)}return i}(r,l*e.pixelToTileUnitsFactor)),function(e,t,i){for(let r=0;r<t.length;r++){const n=t[r];if(e.length>=3)for(let t=0;t<n.length;t++)if(jl(e,n[t]))return!0;if(zl(e,n,i))return!0}return!1}(s,r,a)}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")}},symbol:SymbolStyleLayer,background:class BackgroundStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Bm||(Bm=new Properties({visibility:new DataConstantProperty(Gs.layout_background.visibility)})),paint:km||(km=new Properties({"background-pitch-alignment":new DataConstantProperty(Gs.paint_background["background-pitch-alignment"]),"background-color":new DataConstantProperty(Gs.paint_background["background-color"]),"background-pattern":new DataConstantProperty(Gs.paint_background["background-pattern"]),"background-opacity":new DataConstantProperty(Gs.paint_background["background-opacity"]),"background-emissive-strength":new DataConstantProperty(Gs.paint_background["background-emissive-strength"]),"background-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,t,i){return{overrideFog:!1}}is3D(e){return"viewport"===this.paint.get("background-pitch-alignment")}},raster:RasterStyleLayer,"raster-particle":RasterParticleStyleLayer,sky:class SkyLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Xm||(Xm=new Properties({visibility:new DataConstantProperty(Gs.layout_sky.visibility)})),paint:Ym||(Ym=new Properties({"sky-type":new DataConstantProperty(Gs.paint_sky["sky-type"]),"sky-atmosphere-sun":new DataConstantProperty(Gs.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new DataConstantProperty(Gs.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new DataConstantProperty(Gs.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new DataConstantProperty(Gs.paint_sky["sky-gradient-radius"]),"sky-gradient":new ColorRampProperty(Gs.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new DataConstantProperty(Gs.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new DataConstantProperty(Gs.paint_sky["sky-atmosphere-color"]),"sky-opacity":new DataConstantProperty(Gs.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),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=Jc({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 i=this.paint.get("sky-atmosphere-sun"),r=!i,n=e.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&st("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?e_(o.azimuthal,90-o.polar,t):e_(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return e_(i[0],90-i[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 SlotStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{paint:Km||(Km=new Properties({}))},t,null)}},model:class ModelStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Jm||(Jm=new Properties({visibility:new DataConstantProperty(Gs.layout_model.visibility),"model-id":new DataDrivenProperty(Gs.layout_model["model-id"])})),paint:Qm||(Qm=new Properties({"model-opacity":new DataDrivenProperty(Gs.paint_model["model-opacity"]),"model-rotation":new DataDrivenProperty(Gs.paint_model["model-rotation"]),"model-scale":new DataDrivenProperty(Gs.paint_model["model-scale"]),"model-translation":new DataDrivenProperty(Gs.paint_model["model-translation"]),"model-color":new DataDrivenProperty(Gs.paint_model["model-color"]),"model-color-mix-intensity":new DataDrivenProperty(Gs.paint_model["model-color-mix-intensity"]),"model-type":new DataConstantProperty(Gs.paint_model["model-type"]),"model-cast-shadows":new DataConstantProperty(Gs.paint_model["model-cast-shadows"]),"model-receive-shadows":new DataConstantProperty(Gs.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new DataConstantProperty(Gs.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new DataDrivenProperty(Gs.paint_model["model-emissive-strength"]),"model-roughness":new DataDrivenProperty(Gs.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new DataDrivenProperty(Gs.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new DataConstantProperty(Gs.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new DataConstantProperty(Gs.paint_model["model-front-cutoff"]),"model-elevation-reference":new DataConstantProperty(Gs.paint_model["model-elevation-reference"]),"model-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this.layer=e,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new ModelBucket(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 Tiled3dModelBucket?Mn-1:0}queryRenderedFeatures(e,t,i){const r=t.getSource();if(!(r&&r instanceof ModelSource))return{};const n=r,o={};o[this.id]=[];const s=o[this.id];let a=0;for(const r of n.models){const n=t.getFeatureState(this.sourceLayer,r.id),o={type:"Unknown",id:r.id,properties:r.featureProperties},l=this.paint.get("model-rotation").evaluate(o,n),c=this.paint.get("model-scale").evaluate(o,n),u=this.paint.get("model-translation").evaluate(o,n),h=this.paint.get("model-elevation-reference");let d=[];Qd(d,r,i,r.position,l,c,u,"ground"===h,"ground"===h,!1),"globe"===i.projection.name&&(d=Yd(d,i));const f=p([],i.projMatrix,d),m=Kd(e.isPointQuery()?e.screenBounds:e.screenGeometry,i,f,r.aabb);if(null!=m){const e=new Feature(void 0,0,0,0,r.id);e.layer=this.layer,e.properties=structuredClone(r.featureProperties),e.properties.layer=this.id,e.properties.uri=r.uri,e.properties.orientation=r.orientation,e.sourceLayer=this.sourceLayer,e.geometry={type:"Point",coordinates:[r.position.lng,r.position.lat]},e.state=n,e.source=this.source,s.push({featureIndex:a,feature:e,intersectionZ:m})}++a}return o}queryIntersectsFeature(e,t,i,r,n,o){if(!this.modelManager)return!1;const s=this.modelManager,a=e.tile.getBucket(this);if(!(a&&a instanceof ModelBucket))return!1;for(const i in a.instancesPerModel){const r=a.instancesPerModel[i],n=void 0!==t.id?t.id:t.properties&&t.properties.hasOwnProperty("id")?t.properties.id:void 0;if(r.idToFeaturesIndex.hasOwnProperty(n)){const t=r.features[r.idToFeaturesIndex[n]],l=s.getModel(i,this.scope);if(!l)return!1;let c=[];const u=new LngLat(0,0),h=a.canonical;let d=Number.MAX_VALUE;for(let i=0;i<t.instancedDataCount;++i){const n=16*(t.instancedDataOffset+i),s=r.instancedDataArray.float32,a=[s[n+4],s[n+5],s[n+6]];d_(h,u,Math.floor(s[n]),Math.floor(s[n+1])),Qd(c,l,o,u,t.rotation,t.scale,a,!1,!1,!1),"globe"===o.projection.name&&(c=Yd(c,o));const f=p([],o.projMatrix,c),m=e.queryGeometry,_=Kd(m.isPointQuery()?m.screenBounds:m.screenGeometry,o,f,l.aabb);null!=_&&(d=Math.min(_,d))}return d!==Number.MAX_VALUE&&d}}return!1}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.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 ZoomDependentExpression}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class ClipStyleLayer extends StyleLayer{constructor(e,t,i,r){super(e,{layout:Hu||(Hu=new Properties({"clip-layer-types":new DataConstantProperty(Gs.layout_clip["clip-layer-types"]),"clip-layer-scope":new DataConstantProperty(Gs.layout_clip["clip-layer-scope"])})),paint:qu||(qu=new Properties({}))},t,i,r)}recalculate(e,t){super.recalculate(e,t)}createBucket(e){return new ClipBucket(e)}is3D(e){return!0}}};function m_(e,t,i,r){return"custom"===e.type?new CustomStyleLayer(e,t):new f_[e.type](e,t,i,r)}function __(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}const g_=new Color(0,0,0),y_={PATH_RULE_NON_ZERO:1,PATH_RULE_EVEN_ODD:2},x_={LINE_CAP_BUTT:1,LINE_CAP_ROUND:2,LINE_CAP_SQUARE:3},v_={LINE_JOIN_MITER:1,LINE_JOIN_MITER_CLIP:2,LINE_JOIN_ROUND:3,LINE_JOIN_BEVEL:4},b_={PAINT_ORDER_FILL_AND_STROKE:1},w_={PATH_COMMAND_MOVE:1,PATH_COMMAND_LINE:2,PATH_COMMAND_QUAD:3,PATH_COMMAND_CUBIC:4,PATH_COMMAND_CLOSE:5},T_={MASK_TYPE_LUMINANCE:1};function E_(e,t,i){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:i}=t;null==i.left&&(i.left=0),null==i.top&&(i.top=i.left),null==i.width&&(i.width=e.usvg_tree.width),null==i.height&&(i.height=i.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&&S_(t,"x"),t.stretch_y&&t.stretch_y.length&&S_(t,"y"),e}(e.readFields(A_,{name:void 0},t))}(i,i.readVarint()+i.pos))}function S_(e,t){const i=[],r=e[`stretch_${t}`];let n=null;for(let e=0;e<r.length;e++)null===n?n=0===i.length?r[0]:i[i.length-1][1]+r[e]:(i.push([n,n+r[e]]),n=null);e[`stretch_${t}_areas`]=i}function A_(e,t,i){1===e?t.name=i.readString():2===e?t.metadata=function(e,t){return e.readFields(I_,{stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]},t)}(i,i.readVarint()+i.pos):3===e&&(t.usvg_tree=function(e,t){return e.readFields(P_,{width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[]},t)}(i,i.readVarint()+i.pos),t.data="usvg_tree")}function I_(e,t,i){1===e?t.stretch_x=i.readPackedVarint():2===e?t.stretch_y=i.readPackedVarint():3===e?t.content_area=C_(i,i.readVarint()+i.pos):4===e?t.variables.push(function(e,t){return e.readFields(D_,{name:void 0},t)}(i,i.readVarint()+i.pos)):5===e&&(t.text_placeholder=C_(i,i.readVarint()+i.pos))}function C_(e,t){return e.readFields(M_,{},t)}function M_(e,t,i){1===e?t.left=i.readVarint():2===e?t.width=i.readVarint():3===e?t.top=i.readVarint():4===e&&(t.height=i.readVarint())}function D_(e,t,i){1===e?t.name=i.readString():2===e&&(t.rgb_color=U_(i.readVarint()),t.value="rgb_color")}function P_(e,t,i){1===e?t.width=t.height=i.readVarint():2===e?t.height=i.readVarint():3===e?t.children.push(L_(i,i.readVarint()+i.pos)):4===e?t.linear_gradients.push(function(e,t){return e.readFields(N_,{spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0},t)}(i,i.readVarint()+i.pos)):5===e?t.radial_gradients.push(function(e,t){return e.readFields(H_,{spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0},t)}(i,i.readVarint()+i.pos)):7===e?t.clip_paths.push(function(e,t){return e.readFields(q_,{children:[]},t)}(i,i.readVarint()+i.pos)):8===e&&t.masks.push(function(e,t){const i=e.readFields($_,{left:0,width:20,mask_type:T_.MASK_TYPE_LUMINANCE,children:[]},t);return null==i.height&&(i.height=i.width),null==i.top&&(i.top=i.left),i}(i,i.readVarint()+i.pos))}function L_(e,t){return e.readFields(R_,{},t)}function R_(e,t,i){1===e?(t.group=function(e,t){return e.readFields(z_,{opacity:255,children:[]},t)}(i,i.readVarint()+i.pos),t.node="group"):2===e&&(t.path=function(e,t){return e.readFields(B_,{paint_order:1,commands:[],step:1,diffs:[],rule:y_.PATH_RULE_NON_ZERO},t)}(i,i.readVarint()+i.pos),t.node="path")}function z_(e,t,i){1===e?t.transform=F_(i,i.readVarint()+i.pos):2===e?t.opacity=i.readVarint():5===e?t.clip_path_idx=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(L_(i,i.readVarint()+i.pos))}function F_(e,t){return e.readFields(O_,{sx:1,ky:0,kx:0,sy:1,tx:0,ty:0},t)}function O_(e,t,i){1===e?t.sx=i.readFloat():2===e?t.ky=i.readFloat():3===e?t.kx=i.readFloat():4===e?t.sy=i.readFloat():5===e?t.tx=i.readFloat():6===e&&(t.ty=i.readFloat())}function B_(e,t,i){1===e?t.fill=function(e,t){return e.readFields(k_,{rgb_color:g_,paint:"rgb_color",opacity:255},t)}(i,i.readVarint()+i.pos):2===e?t.stroke=function(e,t){return e.readFields(V_,{rgb_color:g_,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1},t)}(i,i.readVarint()+i.pos):3===e?t.paint_order=i.readVarint():5===e?i.readPackedVarint(t.commands):6===e?t.step=i.readFloat():7===e?i.readPackedSVarint(t.diffs):8===e&&(t.rule=i.readVarint())}function k_(e,t,i){1===e?(t.rgb_color=U_(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e&&(t.opacity=i.readVarint())}function U_(e){return new Color((e>>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function V_(e,t,i){1===e?(t.rgb_color=U_(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e?i.readPackedFloat(t.dasharray):6===e?t.dashoffset=i.readFloat():7===e?t.miterlimit=i.readFloat():8===e?t.opacity=i.readVarint():9===e?t.width=i.readFloat():10===e?t.linecap=i.readVarint():11===e&&(t.linejoin=i.readVarint())}function N_(e,t,i){1===e?t.transform=F_(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(j_(i,i.readVarint()+i.pos)):4===e?t.x1=i.readFloat():5===e?t.y1=i.readFloat():6===e?t.x2=i.readFloat():7===e&&(t.y2=i.readFloat())}function j_(e,t){return e.readFields(G_,{offset:0,opacity:255,rgb_color:g_},t)}function G_(e,t,i){1===e?t.offset=i.readFloat():2===e?t.opacity=i.readVarint():3===e&&(t.rgb_color=U_(i.readVarint()))}function H_(e,t,i){1===e?t.transform=F_(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(j_(i,i.readVarint()+i.pos)):4===e?t.cx=i.readFloat():5===e?t.cy=i.readFloat():6===e?t.r=i.readFloat():7===e?t.fx=i.readFloat():8===e?t.fy=i.readFloat():9===e&&(t.fr=i.readFloat())}function q_(e,t,i){1===e?t.transform=F_(i,i.readVarint()+i.pos):2===e?t.clip_path_idx=i.readVarint():3===e&&t.children.push(L_(i,i.readVarint()+i.pos))}function $_(e,t,i){1===e?t.left=t.top=i.readFloat():2===e?t.width=t.height=i.readFloat():3===e?t.top=i.readFloat():4===e?t.height=i.readFloat():5===e?t.mask_type=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(L_(i,i.readVarint()+i.pos))}class ColorReplacements{static calculate(e={},t=[]){const i=new Map,r=new Map;if(0===Object.keys(e).length)return i;t.forEach((e=>{r.set(e.name,e.rgb_color||new Color(0,0,0))}));for(const[t,n]of Object.entries(e))r.has(t)?i.set(r.get(t).toString(),n):console.warn(`Ignoring unknown image variable "${t}"`);return i}}function Z_(e,t=255,i){const r=t/255,n=e.toString(),o=i.has(n)?i.get(n).clone():e.clone();return o.a*=r,o.toString()}function W_(e,t){if(!Zt()){const i=document.createElement("canvas");return i.width=e,i.height=t,i}return new OffscreenCanvas(e,t)}let X_,Y_=null;function K_(e,t,i,r,n){for(const o of r.children)J_(e,t,i,o,n)}function J_(e,t,i,r,n){r.group?(e.save(),function(e,t,i,r,n){const o=null!=r.mask_idx?i.masks[r.mask_idx]:null,s=null!=r.clip_path_idx?i.clip_paths[r.clip_path_idx]:null;if(r.transform&&(t=ag(r.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(r,null!=s,null!=o))return void K_(e,t,i,r,n);const a=W_(e.canvas.width,e.canvas.height),l=a.getContext("2d");K_(l,t,i,r,n),s&&og(l,t,i,s),o&&sg(l,t,i,o,n),e.globalAlpha=r.opacity/255,e.drawImage(a,0,0)}(e,t,i,r.group,n),e.restore()):r.path&&(e.save(),function(e,t,i,r,n){e.setTransform(t),r.paint_order===b_.PAINT_ORDER_FILL_AND_STROKE?(Q_(e,i,r,n),tg(e,i,r,n)):(tg(e,i,r,n),Q_(e,i,r,n))}(e,t,i,r.path,n),e.restore())}function Q_(e,t,i,r){const n=i.fill;if(!n)return;const o=n.opacity/255;switch(e.save(),e.beginPath(),lg(i,e),n.paint){case"rgb_color":e.fillStyle=Z_(n.rgb_color,n.opacity,r);break;case"linear_gradient_idx":{const i=t.linear_gradients[n.linear_gradient_idx];i.transform&&e.setTransform(ag(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=ig(e,i,o,r);break}case"radial_gradient_idx":{const i=t.radial_gradients[n.radial_gradient_idx];i.transform&&e.setTransform(ag(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=rg(e,i,o,r)}}e.fill(eg(i)),e.restore()}function eg(e){return e.rule===y_.PATH_RULE_NON_ZERO?"nonzero":e.rule===y_.PATH_RULE_EVEN_ODD?"evenodd":void 0}function tg(e,t,i,r){const n=i.stroke;if(!n)return;const o=cg(i);e.lineWidth=n.width,e.miterLimit=n.miterlimit,e.setLineDash(n.dasharray),e.lineDashOffset=n.dashoffset;const s=n.opacity/255;switch(n.paint){case"rgb_color":e.strokeStyle=Z_(n.rgb_color,n.opacity,r);break;case"linear_gradient_idx":e.strokeStyle=ig(e,t.linear_gradients[n.linear_gradient_idx],s,r,!0);break;case"radial_gradient_idx":e.strokeStyle=rg(e,t.radial_gradients[n.radial_gradient_idx],s,r,!0)}switch(n.linejoin){case v_.LINE_JOIN_MITER_CLIP:case v_.LINE_JOIN_MITER:e.lineJoin="miter";break;case v_.LINE_JOIN_ROUND:e.lineJoin="round";break;case v_.LINE_JOIN_BEVEL:e.lineJoin="bevel"}switch(n.linecap){case x_.LINE_CAP_BUTT:e.lineCap="butt";break;case x_.LINE_CAP_ROUND:e.lineCap="round";break;case x_.LINE_CAP_SQUARE:e.lineCap="square"}e.stroke(o)}function ig(e,t,i,r,n=!1){if(1===t.stops.length){const e=t.stops[0];return Z_(e.rgb_color,e.opacity*i,r)}const{x1:o,y1:s,x2:a,y2:l}=t;let c=new DOMPoint(o,s),u=new DOMPoint(a,l);if(n){const e=ag(t.transform);c=e.transformPoint(c),u=e.transformPoint(u)}const h=e.createLinearGradient(c.x,c.y,u.x,u.y);for(const e of t.stops)h.addColorStop(e.offset,Z_(e.rgb_color,e.opacity*i,r));return h}function rg(e,t,i,r,n=!1){if(1===t.stops.length){const e=t.stops[0];return Z_(e.rgb_color,e.opacity*i,r)}const o=ag(t.transform),{fx:s,fy:a,fr:l,cx:c,cy:u,r:h}=t;let d=new DOMPoint(s,a),p=new DOMPoint(c,u),f=l,m=h;if(n){d=o.transformPoint(d),p=o.transformPoint(p);const e=(o.a+o.d)/2;f=l*e,m=t.r*e}const _=e.createRadialGradient(d.x,d.y,f,p.x,p.y,m);for(const e of t.stops)_.addColorStop(e.offset,Z_(e.rgb_color,e.opacity*i,r));return _}function ng(e,t,i,r){const n=r.transform?ag(r.transform).preMultiplySelf(t):t,o=W_(e.canvas.width,e.canvas.height),s=o.getContext("2d");for(const e of r.children)if(e.group)ng(s,n,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(cg(t),n),s.fill(i,eg(t))}const a=null!=r.clip_path_idx?i.clip_paths[r.clip_path_idx]:null;a&&og(s,n,i,a),e.globalCompositeOperation="source-over",e.drawImage(o,0,0)}function og(e,t,i,r){const n=W_(e.canvas.width,e.canvas.height);ng(n.getContext("2d"),t,i,r),e.globalCompositeOperation="destination-in",e.drawImage(n,0,0)}function sg(e,t,i,r,n){if(0===r.children.length)return;const o=null!=r.mask_idx?i.masks[r.mask_idx]:null;o&&sg(e,t,i,o,n);const s=e.canvas.width,a=e.canvas.height,l=W_(s,a),c=l.getContext("2d"),u=r.width,h=r.height,d=r.left,p=r.top,f=new Path2D,m=new Path2D;m.rect(d,p,u,h),f.addPath(m,t),c.clip(f);for(const e of r.children)J_(c,t,i,e,n);const _=c.getImageData(0,0,s,a),g=_.data;if(r.mask_type===T_.MASK_TYPE_LUMINANCE)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]);c.putImageData(_,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l,0,0)}function ag(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function lg(e,t){const i=e.step;let r=e.diffs[0]*i,n=e.diffs[1]*i;t.moveTo(r,n);for(let o=0,s=2;o<e.commands.length;o++)switch(e.commands[o]){case w_.PATH_COMMAND_MOVE:r+=e.diffs[s++]*i,n+=e.diffs[s++]*i,t.moveTo(r,n);break;case w_.PATH_COMMAND_LINE:r+=e.diffs[s++]*i,n+=e.diffs[s++]*i,t.lineTo(r,n);break;case w_.PATH_COMMAND_QUAD:{const o=r+e.diffs[s++]*i,a=n+e.diffs[s++]*i;r=o+e.diffs[s++]*i,n=a+e.diffs[s++]*i,t.quadraticCurveTo(o,a,r,n);break}case w_.PATH_COMMAND_CUBIC:{const o=r+e.diffs[s++]*i,a=n+e.diffs[s++]*i,l=o+e.diffs[s++]*i,c=a+e.diffs[s++]*i;r=l+e.diffs[s++]*i,n=c+e.diffs[s++]*i,t.bezierCurveTo(o,a,l,c,r,n);break}case w_.PATH_COMMAND_CLOSE:t.closePath()}return t}function cg(e){return lg(e,new Path2D)}class LRUCache{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)}}bs(LRUCache,"LRUCache");class ImageRasterizer{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(e){return new RGBAImage(e,e.data)}getFromCache(e,t,i){return this.cacheMap.has(i)||this.cacheMap.set(i,new LRUCache(150)),this.cacheMap.get(i).get(aa(e.toString(),t))}setInCache(e,t,i,r){this.cacheDependenciesMap.has(r)||this.cacheDependenciesMap.set(r,new Map),this.cacheMap.has(r)||this.cacheMap.set(r,new LRUCache(150));const n=this.cacheDependenciesMap.get(r),o=aa(e.id.toString(),i);n.get(o)||n.set(o,new Set);const s=this.cacheMap.get(r),a=e.toString();n.get(o).add(a),s.put(aa(e.toString(),i),t)}removeImagesFromCacheByIds(e,t,i=0){if(!this.cacheMap.has(i)||!this.cacheDependenciesMap.has(i))return;const r=this.cacheMap.get(i),n=this.cacheDependenciesMap.get(i);for(const i of e){const e=aa(i.toString(),t);if(n.has(e)){for(const t of n.get(e))r.delete(t);n.delete(e)}}}rasterize(e,t,i,r){const n=this.getFromCache(e,i,r);if(n)return n.clone();const o=function(e,t){const i=ColorReplacements.calculate(t.params,e.metadata?e.metadata.variables:[]),r=e.usvg_tree,n=r.width,o=r.height,s=Math.max(1,Math.round(n*t.sx)),a=Math.max(1,Math.round(o*t.sy)),l=new DOMMatrix([s/n,0,0,a/o,0,0]);return null===Y_&&(Y_=W_(10,10),X_=Y_.getContext("2d",{willReadFrequently:!0})),Y_.width=s,Y_.height=a,K_(X_,l,r,r,i),X_.getImageData(0,0,s,a)}(t.icon,e),s=ImageRasterizer._getImage(o);return this.setInCache(e,s,i,r),s.clone()}}class ImageManager extends Evented{constructor(e){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=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.dirty=!0,this.spriteFormat=e,"raster"!==e&&Zt()&&(this.imageRasterizerDispatcher=new Dispatcher((rd||(rd=new WorkerPool("ImageRasterizer")),rd),this,"Image Rasterizer Worker",1))}addScope(e){this.loaded.set(e,!1),this.imageProviders.set(e,new Map),this.images.set(e,new Map),this.updatedImages.set(e,new Set),this.callbackDispatchedThisFrame.set(e,new Set),this.patterns.set(e,new Map),this.atlasImage.set(e,new RGBAImage({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.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 ImageRasterizer),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){this._validate(e,i)&&this.images.get(t).set(e.toString(),i)}_validate(e,t){let i=!0;return this._validateStretch(t.stretchX,t.data&&t.data.width)||(this.fire(new ErrorEvent(new Error(`Image "${e.name}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,t.data&&t.data.height)||(this.fire(new ErrorEvent(new Error(`Image "${e.name}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new ErrorEvent(new Error(`Image "${e.name}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[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 r=this.images.get(t).get(e.toString());i.version=r.version+1,this.images.get(t).set(e.toString(),i),this.updatedImages.get(t).add(e),this.removeFromImageRasterizerCache(e,t)}clearUpdatedImages(e){this.updatedImages.get(e).clear()}removeFromImageRasterizerCache(e,t){"raster"!==this.spriteFormat&&(Zt()?this.imageRasterizerDispatcher.getActor().send("removeRasterizedImages",{imageIds:[e],scope:t}):this.imageRasterizer.removeImagesFromCacheByIds([e],t))}removeImage(e,t){const i=this.images.get(t),r=i.get(e.toString());i.delete(e.toString()),this.patterns.get(t).delete(e.toString()),this.removeFromImageRasterizerCache(e,t),r.userImage&&r.userImage.onRemove&&r.userImage.onRemove()}listImages(e){return Array.from(this.images.get(e).keys()).map((e=>ImageId.from(e)))}getImages(e,t,i){const r=[],n=[],o=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){r.push(i);continue}const e=o.get(i.iconsetId);e&&(this.getImage(i,t)?n.push(i):e.addPendingRequest(i))}if(0===r.length)return void this._notify(n,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of r)l.has(e.toString())||(s=!1);a||s?this._notify(r,t,i):this.requestors.push({ids:r,scope:t,callback:i})}rasterizeImages(e,t){const i=new Map,{tasks:r,scope:n}=e;for(const[e,t]of r.entries()){const r=this.getImage(t.id,n);r&&i.set(e,{image:r,imageVariant:t})}this._rasterizeImages(n,i,t)}_rasterizeImages(e,t,i){if(Zt())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:t,scope:e},i);else{const r=new Map;for(const[i,{image:n,imageVariant:o}]of t.entries())r.set(i,this.imageRasterizer.rasterize(o,n,e,0));i(void 0,r)}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(e,t,i){const r=this.images.get(t),n=new Map;for(const t of e){if(!r.get(t.toString())){if(t.iconsetId)continue;this.fire(new Event("styleimagemissing",{id:t.name}))}const e=r.get(t.toString());if(!e){st(`Image "${t.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 i={data:e.usvg?null:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,usvg:e.usvg,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)};e.usvg&&Object.assign(i,{width:e.icon.usvg_tree.width,height:e.icon.usvg_tree.height}),n.set(ImageId.toString(t),i)}i(null,n)}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return{width:t,height:i}}getPattern(e,t,i){const r=e.toString(),n=this.patterns.get(t),o=n.get(r),s=this.getImage(e,t);if(!s)return null;if(o){if(o.position.version===s.version)return o.position;o.position.version=s.version}else{if(s.usvg&&!s.data){const n=this.getPatternInFlightId(r,t);if(this.patternsInFlight.has(n))return null;this.patternsInFlight.add(n);const o=new ImageVariant(e).scaleSelf(Wt.devicePixelRatio),a=new Map([[o.toString(),{image:s,imageVariant:o}]]);return this._rasterizeImages(t,a,((e,r)=>this.storePatternImage(o,t,s,i,r))),null}this.storePattern(e,t,s)}return this._updatePatternAtlas(t,i),n.get(r).position}getPatternInFlightId(e,t){return aa(e,t)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,r,n){const o=e.toString(),s=n?n.get(o):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,r),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)))}storePattern(e,t,i){const r={w:i.data.width+4,h:i.data.height+4,x:0,y:0},n=new ImagePosition(r,i,2);this.patterns.get(t).set(e.toString(),{bin:r,position:n})}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear()}bind(e,t){const i=e.gl;let r=this.atlasTexture.get(t);r?this.dirty&&(r.update(this.atlasImage.get(t)),this.dirty=!1):(r=new Texture(e,this.atlasImage.get(t),i.RGBA8),this.atlasTexture.set(t,r)),r.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(e,t){const i=this.patterns.get(e),r=Array.from(i.values()).map((({bin:e})=>e)),{w:n,h:o}=jf(r),s=this.atlasImage.get(e);s.resize({width:n||1,height:o||1});const a=this.images.get(e);for(const[e,{bin:r,position:n}]of i.entries()){let i=n.padding;const o=r.x+i,l=r.y+i,c=a.get(e).data,u=c.width,h=c.height;i=i>1?i-1:i,RGBAImage.copy(c,s,{x:0,y:0},{x:o,y:l},{width:u,height:h},t),RGBAImage.copy(c,s,{x:0,y:h-i},{x:o,y:l-i},{width:u,height:i},t),RGBAImage.copy(c,s,{x:0,y:0},{x:o,y:l+h},{width:u,height:i},t),RGBAImage.copy(c,s,{x:u-i,y:0},{x:o-i,y:l},{width:i,height:h},t),RGBAImage.copy(c,s,{x:0,y:0},{x:o+u,y:l},{width:i,height:h},t),RGBAImage.copy(c,s,{x:u-i,y:h-i},{x:o-i,y:l-i},{width:i,height:i},t),RGBAImage.copy(c,s,{x:0,y:h-i},{x:o+u,y:l-i},{width:i,height:i},t),RGBAImage.copy(c,s,{x:0,y:0},{x:o+u,y:l+h},{width:i,height:i},t),RGBAImage.copy(c,s,{x:u-i,y:0},{x:o-i,y:l+h},{width:i,height:i},t)}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 r of e){if(this.callbackDispatchedThisFrame.get(t).has(r.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(r.toString());const e=i.get(r.toString());__(e)&&this.updateImage(r,t,e)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function ug(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||Lg;if(!Array.isArray(t))return[new ValidationError(o,t,`array expected, ${Hr(t)} found`)];if(i.length&&t.length!==i.length)return[new ValidationError(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new ValidationError(o,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};n.$version<7&&(a.function=i.function),qr(i.value)&&(a=i.value);let l=[];for(let e=0;e<t.length;e++)l=l.concat(s({array:t,arrayIndex:e,value:t[e],valueSpec:a,style:r,styleSpec:n,key:`${o}[${e}]`},!0));return l}function hg(e){const t=e.key,i=e.value,r=e.valueSpec;if(!Zr(i))return[new ValidationError(t,i,`number expected, ${Hr(i)} found`)];if(i!=i)return[new ValidationError(t,i,"number expected, NaN found")];if("minimum"in r){let n=r.minimum;if(Array.isArray(r.minimum)&&(n=r.minimum[e.arrayIndex]),i<n)return[new ValidationError(t,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if(Array.isArray(r.maximum)&&(n=r.maximum[e.arrayIndex]),i>n)return[new ValidationError(t,i,`${i} is greater than the maximum value ${n}`)]}return[]}function dg(e){const t=e.key,i=e.value;if(!qr(i))return[new ValidationError(t,i,`object expected, ${Hr(i)} found`)];const r=e.valueSpec,n=Hs(i.type);let o,s,a,l={};const c="categorical"!==n&&void 0===i.property,u=!c,h=function(e){const t=e.stops;return Array.isArray(t)&&Array.isArray(t[0])&&qr(t[0][0])}(i),d=Rg({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return[new ValidationError(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const i=e.value;return t=t.concat(ug({key:e.key,value:i,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:p})),Array.isArray(i)&&0===i.length&&t.push(new ValidationError(e.key,i,"array must have at least one stop")),t},default:function(e){return Lg({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&c&&d.push(new ValidationError(e.key,e.value,'missing required property "property"')),"identity"===n||i.stops||d.push(new ValidationError(e.key,e.value,'missing required property "stops"')),"exponential"===n&&r.expression&&!rs(r)&&d.push(new ValidationError(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(u&&!es(r)?d.push(new ValidationError(e.key,e.value,"property functions not supported")):c&&!is(r)&&d.push(new ValidationError(e.key,e.value,"zoom functions not supported"))),"categorical"!==n&&!h||void 0!==i.property||d.push(new ValidationError(e.key,e.value,'"property" property is required')),d;function p(e){let t=[];const i=e.value,n=e.key;if(!Array.isArray(i))return[new ValidationError(n,i,`array expected, ${Hr(i)} found`)];if(2!==i.length)return[new ValidationError(n,i,`array length 2 expected, length ${i.length} found`)];if(h){if(!qr(i[0]))return[new ValidationError(n,i,`object expected, ${Hr(i[0])} found`)];const r=i[0];if(void 0===r.zoom)return[new ValidationError(n,i,"object stop key must have zoom")];if(void 0===r.value)return[new ValidationError(n,i,"object stop key must have value")];const o=Hs(r.zoom);if("number"!=typeof o)return[new ValidationError(n,r.zoom,"stop zoom values must be numbers")];if(a&&a>o)return[new ValidationError(n,r.zoom,"stop zoom values must appear in ascending order")];o!==a&&(a=o,s=void 0,l={}),t=t.concat(Rg({key:`${n}[0]`,value:i[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:hg,value:f}}))}else t=t.concat(f({key:`${n}[0]`,value:i[0],style:e.style,styleSpec:e.styleSpec},i));return ds(qs(i[1]))?t.concat([new ValidationError(`${n}[1]`,i[1],"expressions are not allowed in function stops.")]):t.concat(Lg({key:`${n}[1]`,value:i[1],valueSpec:r,style:e.style,styleSpec:e.styleSpec}))}function f(e,t){const i=Hr(e.value),a=Hs(e.value),c=null!==e.value?e.value:t;if(o){if(i!==o)return[new ValidationError(e.key,c,`${i} stop domain type must match previous stop domain type ${o}`)]}else o=i;if("number"!==i&&"string"!==i&&"boolean"!==i&&"number"!=typeof a&&"string"!=typeof a&&"boolean"!=typeof a)return[new ValidationError(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==i&&"categorical"!==n){let t=`number expected, ${i} found`;return es(r)&&void 0===n&&(t+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ValidationError(e.key,c,t)]}return"categorical"!==n||"number"!==i||"number"==typeof a&&isFinite(a)&&Math.floor(a)===a?"categorical"!==n&&"number"===i&&"number"==typeof a&&"number"==typeof s&&void 0!==s&&a<s?[new ValidationError(e.key,c,"stop domain values must appear in ascending order")]:(s=a,"categorical"===n&&a in l?[new ValidationError(e.key,c,"stop domain values must be unique")]:(l[a]=!0,[])):[new ValidationError(e.key,c,`integer expected, found ${String(a)}`)]}}function pg(e){const t=("property"===e.expressionContext?fs:ps)(qs(e.value),e.valueSpec);if("error"===t.result)return t.value.map((t=>new ValidationError(`${e.key}${t.key}`,e.value,t.message)));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new ValidationError(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!so(i))return[new ValidationError(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return fg(i,e);if("appearance"===e.expressionContext)return mg(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!ao(i,["zoom","feature-state"]))return[new ValidationError(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!oo(i))return[new ValidationError(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function fg(e,t){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return[];const r=[];return e instanceof CompoundExpression&&i.has(e.name)?[new ValidationError(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild((e=>{r.push(...fg(e,t))})),r)}function mg(e,t){const i=new Set;if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.add(e);if(0===i.size)return[];const r=[];return e instanceof CompoundExpression&&!i.has(e.name)?[new ValidationError(t.key,t.value,`["${e.name}"] is not an allowed parameter`)]:(e.eachChild((e=>{r.push(...mg(e,t))})),r)}function _g(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Hs(i))&&n.push(new ValidationError(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Hs(i))&&n.push(new ValidationError(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function gg(e){return $s(qs(e.value))?pg(Object.assign({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):yg(e)}function yg(e){const t=e.value,i=e.key;if(!Array.isArray(t))return[new ValidationError(i,t,`array expected, ${Hr(t)} found`)];if(t.length<1)return[new ValidationError(i,t,"filter array must have at least 1 element")];const r=e.styleSpec;let n=_g({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator});const o=()=>{t.length>=2&&($r(t[1])||n.push(new ValidationError(`${i}[1]`,t[1],`string expected, ${Hr(t[1])} found`)));for(let e=2;e<t.length;e++)"$type"===Hs(t[1])?n=n.concat(_g({key:`${i}[${e}]`,value:t[e],valueSpec:r.geometry_type})):$r(t[e])||Zr(t[e])||Wr(t[e])||n.push(new ValidationError(`${i}[${e}]`,t[e],`string, number, or boolean expected, ${Hr(t[e])} found.`))};switch(Hs(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===Hs(t[1])&&n.push(new ValidationError(i,t,`"$type" cannot be use with operator "${t[0]}"`)),3!==t.length&&n.push(new ValidationError(i,t,`filter array for operator "${t[0]}" must have 3 elements`)),o();break;case"==":case"!=":3!==t.length&&n.push(new ValidationError(i,t,`filter array for operator "${t[0]}" must have 3 elements`)),o();break;case"in":case"!in":o();break;case"any":case"all":case"none":for(let r=1;r<t.length;r++)n=n.concat(yg({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":2!==t.length?n.push(new ValidationError(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):$r(t[1])||n.push(new ValidationError(`${i}[1]`,t[1],`string expected, ${Hr(t[1])} found`))}return n}function xg(e,t){const i=e.key,r=e.style,n=e.layer,o=e.styleSpec,s=e.value,a=e.objectKey,l=o[`${t}_${e.layerType}`];if(!l)return[];const c=a.match(/^(.*)-use-theme$/);if(c&&l[c[1]])return ds(qs(s))?[].concat(Lg({key:i,value:s,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:r,styleSpec:o,expressionContext:"property",propertyType:t,propertyKey:a})):Lg({key:i,value:s,valueSpec:{type:"string"},style:r,styleSpec:o});const u=a.match(/^(.*)-transition$/);if("paint"===t&&u&&l[u[1]]&&l[u[1]].transition)return Lg({key:i,value:s,valueSpec:o.transition,style:r,styleSpec:o});const h=e.valueSpec||l[a];if(!h)return[new ValidationWarning(i,s,`unknown property "${a}"`)];let d;if($r(s)&&es(h)&&!h.tokens&&(d=/^{([^}]+)}$/.exec(s))){const e=`\`{ "type": "identity", "property": ${d?JSON.stringify(d[1]):'"_"'} }\``;return[new ValidationError(i,s,`"${a}" does not support interpolation syntax\nUse an identity property function instead: ${e}.`)]}const p=[];if("symbol"===e.layerType)"text-field"!==a||!r||r.glyphs||r.imports||p.push(new ValidationError(i,s,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&ns(qs(s))&&"identity"===Hs(s.type)&&p.push(new ValidationError(i,s,'"text-font" does not support identity functions'));else if("model"===e.layerType&&"paint"===t&&n&&n.layout&&n.layout.hasOwnProperty("model-id")&&es(h)&&(ts(h)||is(h))){const e=fs(qs(s),h).value,t="expression"in e&&e.expression||"_styleExpression"in e&&e._styleExpression&&e._styleExpression.expression;t&&!ao(t,["measure-light"])&&("model-emissive-strength"===a&&oo(t)&&so(t)||p.push(new ValidationError(i,s,`${a} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return p.concat(Lg({key:e.key,value:s,valueSpec:h,style:r,styleSpec:o,expressionContext:"property",propertyType:t,propertyKey:a}))}function vg(e){return xg(e,"paint")}function bg(e){return xg(e,"layout")}function wg(e){let t=[];const i=e.value,r=e.key,n=e.style,o=e.styleSpec;if(!qr(i))return[new ValidationError(r,i,"object expected")];i.type||i.ref||t.push(new ValidationError(r,i,'either "type" or "ref" is required'));let s=Hs(i.type);const a=Hs(i.ref);if(i.id){const o=Hs(i.id);for(let s=0;s<e.arrayIndex;s++){const e=n.layers[s];Hs(e.id)===o&&t.push(new ValidationError(r,i.id,`duplicate layer id "${o}", previously used at line ${e.id.__line__}`))}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach((e=>{e in i&&t.push(new ValidationError(r,i[e],`"${e}" is prohibited for ref layers`))})),n.layers.forEach((t=>{Hs(t.id)===a&&(e=t)})),e?e.ref?t.push(new ValidationError(r,i.ref,"ref cannot reference another ref layer")):s=Hs(e.type):"string"==typeof a&&t.push(new ValidationError(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s&&"slot"!==s)if(i.source)if($r(i.source)){const e=n.sources&&n.sources[i.source],o=e&&Hs(e.type);e?"vector"===o&&"raster"===s?t.push(new ValidationError(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?t.push(new ValidationError(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?t.push(new ValidationError(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==o||["raster","raster-particle"].includes(s)?"line"===s&&i.paint&&(i.paint["line-gradient"]||i.paint["line-trim-offset"])&&"geojson"===o&&!e.lineMetrics?t.push(new ValidationError(r,i,`layer "${i.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===s&&"raster-array"!==o&&t.push(new ValidationError(r,i.source,`layer "${i.id}" requires a 'raster-array' source.`)):t.push(new ValidationError(r,i.source,"raster-array source can only be used with layer type 'raster'.")):t.push(new ValidationError(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new ValidationError(r,i.source,`source "${i.source}" not found`))}else t.push(new ValidationError(`${r}.source`,i.source,'"source" must be a string'));else t.push(new ValidationError(r,i,'missing required property "source"'));return t=t.concat(Rg({key:r,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Lg({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>gg(Object.assign({layerType:s},e)),layout:e=>Rg({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>bg(Object.assign({layerType:s},e))}}),paint:e=>Rg({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>vg(Object.assign({layerType:s,layer:i},e))}}),appearances(e){const t=ug({key:e.key,value:e.value,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:e=>function(e){const{key:t,layer:i,layerType:r}=e,n=Hs(e.value),o=Hs(n.name),s=Hs(n.condition),a=Rg({key:t,value:n,valueSpec:e.styleSpec.appearance,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{condition:e=>function(e){const t=[];return t.push(...pg({key:e.key,value:e.object.condition,valueSpec:Gs.appearance.condition,expressionContext:"appearance"})),t}(Object.assign({layer:i,layerType:r},e)),properties:e=>function(e){const t=[],{styleSpec:i,layer:r,layerType:n}=e,o=i[`paint_${n}`],s=i[`layout_${n}`],a=e.object[e.objectKey];for(const i in a){const l=i in o?"paint":i in s?"layout":void 0;if(!l){t.push(new ValidationError(e.key,i,`unknown property "${i}" for layer type "${n}"`));continue}const c=Object.assign({},e,{key:`${e.key}.${i}`,object:a,objectKey:i,layer:r,layerType:n,value:a[i],valueSpec:"paint"===l?o[i]:s[i]});t.push(...xg(c,l))}return t}(Object.assign({layer:i,layerType:r},e))}});return"hidden"!==o&&void 0===s&&a.push(new ValidationError(e.key,"name",'Appearance with name different than "hidden" must have a condition')),a}(Object.assign({layerType:s,layer:i},e))}),r=Array.isArray(e.value)?e.value:[],n=new Set;return r.forEach(((r,o)=>{const s=Hs(r.name);if(s)if(n.has(s)){const r=Hs(i.id);t.push(new ValidationError(e.key,s,`Duplicated appearance name "${s}" for layer "${r}"`))}else n.add(s)})),t}}})),t}function Tg({key:e,value:t}){return $r(t)?[]:[new ValidationError(e,t,`string expected, ${Hr(t)} found`)]}const Eg={promoteId:function e({key:t,value:i}){if($r(i))return Tg({key:t,value:i});if(Array.isArray(i)){const e=[],r=ps(qs(i));return"error"===r.result&&r.value.forEach((i=>{e.push(new ValidationError(`${t}${i.key}`,null,`${i.message}`))})),ao(r.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"])||e.push(new ValidationError(`${t}`,null,"promoteId expression should be only feature dependent")),e}if(!qr(i))return[new ValidationError(t,i,`string, expression or object expected, "${Hr(i)}" found`)];const r=[];for(const n in i)r.push(...e({key:`${t}.${n}`,value:i[n]}));return r}};function Sg(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style;if(!qr(t))return[new ValidationError(i,t,`object expected, ${Hr(t)} found`)];if(!("type"in t))return[new ValidationError(i,t,'"type" is required')];const o=Hs(t.type);let s=[];switch(["vector","raster","raster-dem","raster-array"].includes(o)&&("url"in t||"tiles"in t||s.push(new ValidationWarning(i,t,'Either "url" or "tiles" is required.'))),o){case"vector":case"raster":case"raster-dem":case"raster-array":return s=s.concat(Rg({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Eg})),s;case"geojson":if(s=Rg({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:Eg}),"cluster"in t&&"clusterProperties"in t){if(!qr(t.clusterProperties))return[new ValidationError(`${i}.clusterProperties`,t,`object expected, ${Hr(t)} found`)];for(const e in t.clusterProperties){const r=t.clusterProperties[e];if(!Array.isArray(r))return[new ValidationError(`${i}.clusterProperties.${e}`,r,"array expected")];const[n,o]=r,a="string"==typeof n?[n,["accumulated"],["get",e]]:n;s.push(...pg({key:`${i}.${e}.map`,value:o,expressionContext:"cluster-map"})),s.push(...pg({key:`${i}.${e}.reduce`,value:a,expressionContext:"cluster-reduce"}))}}return s;case"video":return Rg({key:i,value:t,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Rg({key:i,value:t,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new ValidationError(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return _g({key:`${i}.type`,value:t.type,valueSpec:{values:Ag(r)}})}}function Ag(e){return e.source.reduce(((t,i)=>{const r=e[i];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values||{}))),t}),[])}function Ig(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;if(void 0===t)return[];if(!qr(t))return[new ValidationError("light",t,`object expected, ${Hr(t)} found`)];let o=[];for(const e in t){const s=e.match(/^(.*)-transition$/),a=e.match(/^(.*)-use-theme$/);o=o.concat(a&&r[a[1]]?Lg({key:e,value:t[e],valueSpec:{type:"string"},style:n,styleSpec:i}):s&&r[s[1]]&&r[s[1]].transition?Lg({key:e,value:t[e],valueSpec:i.transition,style:n,styleSpec:i}):r[e]?Lg({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}):[new ValidationError(e,t[e],`unknown property "${e}"`)])}return o}function Cg(e){const t=e.value;if(!t)return[];const i=e.key;if(!qr(t))return[new ValidationError(i,t,`object expected, ${Hr(t)} found`)];let r=[];const n=e.styleSpec,o=n["light-3d"],s=e.style,a=e.style.lights;for(const e of["type","id"])if(!(e in t))return r=r.concat([new ValidationError(i,t,`missing property "${e}"`)]),r;if(!$r(t.type))return r=r.concat([new ValidationError(`${i}.type`,t.type,"string expected")]),r;if(a)for(let n=0;n<e.arrayIndex;n++){const e=Hs(t.type),o=a[n];Hs(o.type)===e&&r.push(new ValidationError(i,t.id,`duplicate light type "${t.type}", previously defined at line ${o.id.__line__}`))}const l=`properties_light_${t.type}`;if(!(l in n))return r=r.concat([new ValidationError(`${i}.type`,t,`Invalid light type ${t.type}`)]),r;const c=n[l];for(const i in t)if("properties"===i){const o=t[i];if(!qr(o))return r=r.concat([new ValidationError("properties",o,`object expected, ${Hr(o)} found`)]),r;for(const a in o){const l=a.match(/^(.*)-transition$/),u=a.match(/^(.*)-use-theme$/);r=r.concat(u&&c[u[1]]?Lg({key:i,value:o[a],valueSpec:{type:"string"},style:s,styleSpec:n}):l&&c[l[1]]&&c[l[1]].transition?Lg({key:i,value:t[i],valueSpec:n.transition,style:s,styleSpec:n}):c[a]?Lg({key:a,value:o[a],valueSpec:c[a],style:s,styleSpec:n}):[new ValidationWarning(e.key,o[a],`unknown property "${a}"`)])}}else r=r.concat(o[i]?Lg({key:i,value:t[i],valueSpec:o[i],style:s,styleSpec:n}):[new ValidationWarning(i,t[i],`unknown property "${i}"`)]);return r}function Mg(e){const t=e.value,i=e.key,r=e.style,n=e.styleSpec,o=n.terrain;if(null==t)return[];if(!qr(t))return[new ValidationError("terrain",t,`object expected, ${Hr(t)} found`)];let s=[];for(const e in t){const i=e.match(/^(.*)-transition$/),a=e.match(/^(.*)-use-theme$/);s=s.concat(a&&o[a[1]]?Lg({key:e,value:t[e],valueSpec:{type:"string"},style:r,styleSpec:n}):i&&o[i[1]]&&o[i[1]].transition?Lg({key:e,value:t[e],valueSpec:n.transition,style:r,styleSpec:n}):o[e]?Lg({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:n}):[new ValidationWarning(e,t[e],`unknown property "${e}"`)])}if(t.source)if($r(t.source)){const e=r.sources&&r.sources[t.source],n=e&&Hs(e.type);e?"raster-dem"!==n&&s.push(new ValidationError(`${i}.source`,t.source,`terrain cannot be used with a source of type ${n}, it only be used with a "raster-dem" source type`)):s.push(new ValidationError(`${i}.source`,t.source,`source "${t.source}" not found`))}else s.push(new ValidationError(`${i}.source`,t.source,"source must be a string"));else s.push(new ValidationError(i,t,'terrain is missing required property "source"'));return s}function Dg(e){const t=e.value,i=e.style,r=e.styleSpec,n=r.fog;if(void 0===t)return[];if(!qr(t))return[new ValidationError("fog",t,`object expected, ${Hr(t)} found`)];let o=[];for(const e in t){const s=e.match(/^(.*)-transition$/),a=e.match(/^(.*)-use-theme$/);o=o.concat(a&&n[a[1]]?Lg({key:e,value:t[e],valueSpec:{type:"string"},style:i,styleSpec:r}):s&&n[s[1]]&&n[s[1]].transition?Lg({key:e,value:t[e],valueSpec:r.transition,style:i,styleSpec:r}):n[e]?Lg({key:e,value:t[e],valueSpec:n[e],style:i,styleSpec:r}):[new ValidationWarning(e,t[e],`unknown property "${e}"`)])}return o}const Pg={"*":()=>[],array:ug,boolean:function(e){const t=e.value,i=e.key;return Wr(t)?[]:[new ValidationError(i,t,`boolean expected, ${Hr(t)} found`)]},number:hg,color:function({key:e,value:t}){return $r(t)?null===yr.parseCSSColor(t)?[new ValidationError(e,t,`color expected, "${t}" found`)]:[]:[new ValidationError(e,t,`color expected, ${Hr(t)} found`)]},enum:_g,filter:gg,function:dg,layer:wg,object:Rg,source:Sg,model:i_,light:Ig,"light-3d":Cg,terrain:Mg,fog:Dg,string:Tg,formatted:function(e){return 0===Tg(e).length?[]:pg(e)},resolvedImage:function(e){return 0===Tg(e).length?[]:pg(e)},projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style;if(qr(t)){let e=[];for(const o in t)e=e.concat(Lg({key:o,value:t[o],valueSpec:r[o],style:n,styleSpec:i}));return e}return $r(t)?[]:[new ValidationError("projection",t,`object or string expected, ${Hr(t)} found`)]},import:function(e){const t=e.key,{value:i,styleSpec:r}=e;if(!qr(i))return[new ValidationError(t,i,"import must be an object")];const{data:n,...o}=i;Object.defineProperty(o,"__line__",{value:i.__line__,enumerable:!1});let s=Rg(Object.assign({},e,{value:o,valueSpec:r.import}));return""===Hs(o.id)&&s.push(new ValidationError(`${e.key}.id`,o,"import id can't be an empty string")),n&&(s=s.concat(Fg(n,r,{key:`${e.key}.data`}))),s},iconset:function(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style;if(!qr(t))return[new ValidationError(i,t,"object expected")];if(!t.type)return[new ValidationError(i,t,'"type" is required')];const o=Hs(t.type);let s=[];if(s=s.concat(Rg({key:i,value:t,valueSpec:r[`iconset_${o}`],style:n,styleSpec:r})),function(e,t){return!("source"!==e||!t.source)}(o,t)){const e=n.sources&&n.sources[t.source],r=e&&Hs(e.type);e?"raster-array"!==r&&s.push(new ValidationError(i,t.source,`iconset cannot be used with a source of type ${String(r)}, it only be used with a "raster-array" source type`)):s.push(new ValidationError(i,t.source,`source "${t.source}" not found`))}return s}};function Lg(e,t=!1){const i=e.value,r=e.valueSpec,n=e.styleSpec;if(r.expression){if(ns(Hs(i)))return dg(e);if(ds(qs(i)))return pg(e)}if(r.type&&Pg[r.type]){const i=Pg[r.type](e);return!0===t&&i.length>0&&Array.isArray(e.value)?pg(e):i}return Rg(Object.assign({},e,{valueSpec:r.type?n[r.type]:r}))}function Rg(e){const t=e.key,i=e.value,r=e.valueSpec||{},n=e.objectElementValidators||{},o=e.style,s=e.styleSpec;if(!qr(i))return[new ValidationError(t,i,`object expected, ${Hr(i)} found`)];let a=[];for(const e in i){const l=e.split(".")[0];let c;n[l]?c=n[l]:r[l]?c=Lg:n["*"]?c=n["*"]:r["*"]&&(c=Lg),c?a=a.concat(c({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:r[l]||r["*"],style:o,styleSpec:s,object:i,objectKey:e},i)):a.push(new ValidationWarning(t,i[e],`unknown property "${e}"`))}for(const e in r){if(n[e])continue;const o=r[e];o.required&&void 0===o.default&&void 0===i[e]&&a.push(new ValidationError(t,i,`missing required property "${e}"`))}return a}function zg({key:e,value:t}){const i=Tg({key:e,value:t});if(i.length)return i;const r=t;return-1===r.indexOf("{fontstack}")&&i.push(new ValidationError(e,t,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&i.push(new ValidationError(e,t,'"glyphs" url must include a "{range}" token')),i}function Fg(e,t=Gs,i={}){return Rg({key:i.key||"",value:e,valueSpec:Object.assign(t.$root,{"*":{type:"*"}}),styleSpec:t,style:e,objectElementValidators:{glyphs:zg}})}function Og(e,t=Gs){return Xg(Fg(e,t))}const Bg=e=>Xg(Sg(e)),kg=e=>Xg(Ig(e)),Ug=e=>Xg(Cg(e)),Vg=e=>Xg(Mg(e)),Ng=e=>Xg(Dg(e)),jg=e=>Xg(function(e){const t=e.value,i=e.style,r=e.styleSpec,n=r.snow;if(void 0===t)return[];if(!qr(t))return[new ValidationError("snow",t,`object expected, ${Hr(t)} found`)];let o=[];for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?Lg({key:e,value:t[e],valueSpec:r.transition,style:i,styleSpec:r}):n[e]?Lg({key:e,value:t[e],valueSpec:n[e],style:i,styleSpec:r}):[new ValidationWarning(e,t[e],`unknown property "${e}"`)])}return o}(e)),Gg=e=>Xg(function(e){const t=e.value,i=e.style,r=e.styleSpec,n=r.rain;if(void 0===t)return[];if(!qr(t))return[new ValidationError("rain",t,`object expected, ${Hr(t)} found`)];let o=[];for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?Lg({key:e,value:t[e],valueSpec:r.transition,style:i,styleSpec:r}):n[e]?Lg({key:e,value:t[e],valueSpec:n[e],style:i,styleSpec:r}):[new ValidationWarning(e,t[e],`unknown property "${e}"`)])}return o}(e)),Hg=e=>Xg(wg(e)),qg=e=>Xg(gg(e)),$g=e=>Xg(vg(e)),Zg=e=>Xg(bg(e)),Wg=e=>Xg(i_(e));function Xg(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function Yg(e,t){let i=!1;if(t&&t.length)for(const r of t)r instanceof ValidationWarning?st(r.message):(e.fire(new ErrorEvent(new Error(r.message))),i=!0);return i}const Kg=Gs.light;let Jg;class Light extends Evented{constructor(e,t="flat"){super(),this._transitionable=new Transitionable(Jg||(Jg=new Properties({anchor:new DataConstantProperty(Kg.anchor),position:new PositionProperty(Kg.position),color:new DataConstantProperty(Kg.color),intensity:new DataConstantProperty(Kg.intensity)}))),this.setLight(e,t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(kg,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(e,t,i){return(!i||!1!==i.validate)&&Yg(this,e.call(Og,Object.assign({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Gs})))}}const Qg=Gs.terrain;let ey=class Terrain extends Evented{constructor(e,t,i,r,n){super(),this.scope=i,this._transitionable=new Transitionable(new Properties({source:new DataConstantProperty(Qg.source),exaggeration:new DataConstantProperty(Qg.exaggeration)}),i,r),this._transitionable.setTransitionOrValue(e,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t,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(e){return this._transitioning.possiblyEvaluate(new EvaluationParameters(e,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const e=this._transitionable._values.exaggeration;if(!e)return null;const t=e.value.expression;if(!t)return null;let i=-1,r=-1,n=1;for(const e of t.zoomStops)n=t.evaluate(new EvaluationParameters(e,{worldview:this.worldview})),n>.01?(i=e,r=-1):r=e;return n<.01&&i>0&&r>i?[i,r]:null}isZoomDependent(){const e=this._transitionable._values.exaggeration;return null!=e&&null!=e.value&&null!=e.value.expression&&e.value.expression instanceof ZoomDependentExpression}};const ty=45,iy=65,ry=.05;function ny(e,t,i,r){const n=qe(ty,iy,i),[o,s]=oy(e,r);let a=1-Math.min(1,Math.exp((t-o)/(s-o)*-6));return a*=a*a,a=Math.min(1,1.00747*a),a*n*e.alpha}function oy(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}function sy(e,t,i,r,n){return ny(e,M(Z([],[t,i,r],n.mercatorFogMatrix)),n.pitch,n._fov)}function ay(e,t,i,r,n,o,s){const a=[[i,r,0],[n,r,0],[n,o,0],[i,o,0]];let l=Number.MAX_VALUE,c=-Number.MAX_VALUE;for(const e of a){const i=M(Z([],e,t));l=Math.min(l,i),c=Math.max(c,i)}return[ny(e,l,s.pitch,s._fov),ny(e,c,s.pitch,s._fov)]}const ly=Gs.fog;class Fog extends Evented{constructor(e,t,i,r){super();const n=new Properties({range:new DataConstantProperty(ly.range),color:new DataConstantProperty(ly.color),"color-use-theme":new DataConstantProperty({type:"string","property-type":"data-constant",default:"default"}),"high-color":new DataConstantProperty(ly["high-color"]),"high-color-use-theme":new DataConstantProperty({type:"string","property-type":"data-constant",default:"default"}),"space-color":new DataConstantProperty(ly["space-color"]),"space-color-use-theme":new DataConstantProperty({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new DataConstantProperty(ly["horizon-blend"]),"star-intensity":new DataConstantProperty(ly["star-intensity"]),"vertical-range":new DataConstantProperty(ly["vertical-range"])});this._transitionable=new Transitionable(n,i,new Map(r)),this.set(e,r),this._transitioning=this._transitionable.untransitioned(),this._transform=t,this.properties=new PossiblyEvaluated(n),this.scope=i}get state(){const e=this._transform,t="globe"===e.projection.name,i=Ac(e.zoom),r=this.properties.get("range"),n=[.5,3];return{range:t?[xr(n[0],r[0],i),xr(n[1],r[1],i)]: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(Ng,e,i))return;const r=Object.assign({},e);for(const e of Object.keys(ly))void 0===r[e]&&(r[e]=ly[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,t)}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const t=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:qe(ty,iy,e))*t.a}getOpacityAtLatLng(e,t){return this._transform.projection.supportsFog?function(e,t,i){const r=MercatorCoordinate.fromLngLat(t),n=i.elevation?i.elevation.getAtPointOrZero(r):0;return sy(e,r.x,r.y,n,i)}(this.state,e,t):0}getOpacityForTile(e){if(!this._transform.projection.supportsFog)return[1,1];const t=this._transform.calculateFogTileMatrix(e.toUnwrapped());return ay(this.state,t,0,0,Mn,Mn,this._transform)}getOpacityForBounds(e,t,i,r,n){return this._transform.projection.supportsFog?ay(this.state,e,t,i,r,n,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?oy(this.state,e):[0,1]}isVisibleOnFrustum(e){if(!this._transform.projection.supportsFog)return!1;const t=[4,5,6,7];for(const i of t){const t=e.points[i];let r;if(t[2]>=0)r=t;else{const n=e.points[i-4];r=vr(n,t,n[2]/(n[2]-t[2]))}if(sy(this.state,r[0],r[1],0,this._transform)>=ry)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(e,t,i){return(!i||!1!==i.validate)&&Yg(this,e.call(Og,Object.assign({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Gs})))}}let cy,uy,hy,dy,py=class Snow extends Evented{constructor(e,t,i,r){super();const n=cy||(cy=new Properties({density:new DataConstantProperty(Gs.snow.density),intensity:new DataConstantProperty(Gs.snow.intensity),color:new DataConstantProperty(Gs.snow.color),opacity:new DataConstantProperty(Gs.snow.opacity),vignette:new DataConstantProperty(Gs.snow.vignette),"vignette-color":new DataConstantProperty(Gs.snow["vignette-color"]),"center-thinning":new DataConstantProperty(Gs.snow["center-thinning"]),direction:new DataConstantProperty(Gs.snow.direction),"flake-size":new DataConstantProperty(Gs.snow["flake-size"])}));this._transitionable=new Transitionable(n,i,new Map(r)),this.set(e,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new PossiblyEvaluated(n),this.scope=i}get state(){const e=this.properties.get("opacity"),t=this.properties.get("color"),i=this.properties.get("direction"),r=Oe(i[0]),n=-Math.max(Oe(i[1]),.01),o=[Math.cos(r)*Math.cos(n),Math.sin(r)*Math.cos(n),Math.sin(n)],s=this.properties.get("vignette"),a=this.properties.get("vignette-color");return a.a=s,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new Color(t.r,t.g,t.b,t.a*e),direction:o,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(jg,e,i))return;const r=Object.assign({},e),n=Gs.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,t)}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(e,t,i){return(!i||!1!==i.validate)&&Yg(this,e.call(Og,Object.assign({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Gs})))}},fy=class Rain extends Evented{constructor(e,t,i,r){super();const n=uy||(uy=new Properties({density:new DataConstantProperty(Gs.rain.density),intensity:new DataConstantProperty(Gs.rain.intensity),color:new DataConstantProperty(Gs.rain.color),opacity:new DataConstantProperty(Gs.rain.opacity),vignette:new DataConstantProperty(Gs.rain.vignette),"vignette-color":new DataConstantProperty(Gs.rain["vignette-color"]),"center-thinning":new DataConstantProperty(Gs.rain["center-thinning"]),direction:new DataConstantProperty(Gs.rain.direction),"droplet-size":new DataConstantProperty(Gs.rain["droplet-size"]),"distortion-strength":new DataConstantProperty(Gs.rain["distortion-strength"])}));this._transitionable=new Transitionable(n,i,new Map(r)),this.set(e,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new PossiblyEvaluated(n),this.scope=i}get state(){const e=this.properties.get("opacity"),t=this.properties.get("color"),i=this.properties.get("direction"),r=Oe(i[0]),n=-Math.max(Oe(i[1]),.01),o=[Math.cos(r)*Math.cos(n),Math.sin(r)*Math.cos(n),Math.sin(n)],s=this.properties.get("vignette-color");return s.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new Color(t.r,t.g,t.b,t.a*e),direction:o,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:s}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Gg,e,i))return;const r=Object.assign({},e),n=Gs.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,t)}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(e,t,i){return(!i||!1!==i.validate)&&Yg(this,e.call(Og,Object.assign({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Gs})))}};class Lights extends Evented{constructor(e,t,i,r){super(),this.scope=i,this._options=e,this.properties=new PossiblyEvaluated(t),this._transitionable=new Transitionable(t,i,new Map(r)),this._transitionable.setTransitionOrValue(e.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")}}class QueryGeometry{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(e,t){let i,r;if(e instanceof Le||"number"==typeof e[0]){const n=Le.convert(e);i=[n],r=t.isPointAboveHorizon(n)}else{const n=Le.convert(e[0]),o=Le.convert(e[1]),s=n.add(o)._div(2);i=[n,o],r=Ne(n,o).every((e=>t.isPointAboveHorizon(e)))&&t.isPointAboveHorizon(s)}return new QueryGeometry(i,r,t)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return Ne(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new Le(1,1)):this.screenBounds[1],r=Ne(t,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>t.x&&this.cameraPoint.x<i.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?r[2]=this.cameraPoint:this.cameraPoint.x<=t.x&&(r[3]=this.cameraPoint)),function(e,t){const i=[];for(let r=0;r<e.length;r++){const n=$e(r-1,-1,e.length-1),o=$e(r+1,-1,e.length-1),s=e[r],a=e[o],l=e[n].sub(s).unit(),c=a.sub(s).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*t/Math.sin(u/2));i.push(s.add(h))}return i}(r,e)}bufferedCameraGeometryGlobe(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new Le(1,1)):this.screenBounds[1],r=Ne(t,i,e),n=this.cameraPoint.clone();switch(3*((n.y>t.y)+(n.y>i.y))+((n.x>t.x)+(n.x>i.x))){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(e,t,i,r=0){const n=Math.max(e.queryPadding,e.evaluateQueryRenderedFeaturePadding())/t._pixelsPerMercatorPixel+1,o=i?this._bufferedCameraMercator(n,t):this._bufferedScreenMercator(n,t);let s=e.tileID.wrap+(o.unwrapped?r:0);const a=o.polygon.map((t=>um(e.tileTransform,t,s)));if(!Gl(a,0,0,Mn,Mn))return;s=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const l=this.screenGeometryMercator.polygon.map((t=>hm(e.tileTransform,t,s))),c=l.map((e=>new Le(e[0],e[1]))),u=t.getFreeCameraOptions().position||new MercatorCoordinate(0,0,0),h=hm(e.tileTransform,u,s),d=l.map((e=>{const t=J(e,e,h);return G(t,t),new Ray(h,t)})),p=Hp(e,1,t.zoom)*t._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:c,tilespaceRays:d,bufferedTilespaceGeometry:a,bufferedTilespaceBounds:(f=Ve(a),f.min.x=He(f.min.x,0,Mn),f.min.y=He(f.min.y,0,Mn),f.max.x=He(f.max.x,0,Mn),f.max.y=He(f.max.y,0,Mn),f),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:p};var f}_bufferedScreenMercator(e,t){const i=gy(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=gy(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(e,t){const i=function(e,t){const i=p([],t.pixelMatrix,t.globeMatrix),r=[0,-ka,0,1],n=[0,ka,0,1],o=[0,0,0,1];se(r,r,i),se(n,n,i),se(o,o,i);const s=new Le(r[0]/r[3],r[1]/r[3]),a=new Le(n[0]/n[3],n[1]/n[3]),l=jl(e,s)&&r[3]<o[3],c=jl(e,a)&&n[3]<o[3];if(!l&&!c)return null;const u=function(e,t,i){for(let r=1;r<e.length;r++){const n=_y(t.pointCoordinate3D(e[r-1]).x),o=_y(t.pointCoordinate3D(e[r]).x);if(i<0){if(n<o)return{idx:r,t:-n/(o-1-n)}}else if(o<n)return{idx:r,t:(1-n)/(o+1-n)}}return null}(e,t,l?-1:1);if(!u)return null;const{idx:h,t:d}=u;let f=h>1?my(e.slice(0,h),t):[],m=h<e.length?my(e.slice(h),t):[];f=f.map((e=>new Le(_y(e.x),e.y))),m=m.map((e=>new Le(_y(e.x),e.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=xr(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=l?[new Le(0,g),new Le(0,0),new Le(1,0),new Le(1,g)]:[new Le(1,g),new Le(1,1),new Le(0,1),new Le(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((e=>new MercatorCoordinate(e.x,e.y))),unwrapped:!1}}(e,t);if(i)return i;const r=function(e,t){let i=!1,r=-1/0,n=0;for(let t=0;t<e.length-1;t++)e[t].x>r&&(r=e[t].x,n=t);for(let t=0;t<e.length-1;t++){const r=(n+t)%(e.length-1),o=e[r],s=e[r+1];Math.abs(o.x-s.x)>.5&&(o.x<s.x?(o.x+=1,0===r&&(e[e.length-1].x+=1)):(s.x+=1,r+1===e.length-1&&(e[0].x+=1)),i=!0)}const o=Qa(t.center.lng);return i&&o<Math.abs(o-1)&&e.forEach((e=>{e.x-=1})),{polygon:e,unwrapped:i}}(my(e,t).map((e=>new Le(_y(e.x),e.y))),t);return{polygon:r.polygon.map((e=>new MercatorCoordinate(e.x,e.y))),unwrapped:r.unwrapped}}}function my(e,t){return hl(e,(e=>{const i=t.pointCoordinate3D(e);e.x=i.x,e.y=i.y}),1/256)}function _y(e){return e<0?1+e%1:e%1}function gy(e){return 100*e|0}function yy(e,t,i,r,n){const o=function(i,r){if(i)return n(i);if(r){if(e.url&&r.tiles&&e.tiles&&delete e.tiles,r.variants){if(!Array.isArray(r.variants))return n(new Error("variants must be an array"));for(const e of r.variants){if(null==e||"object"!=typeof e||e.constructor!==Object)return n(new Error("variant must be an object"));if(!Array.isArray(e.capabilities))return n(new Error("capabilities must be an array"));if(1===e.capabilities.length&&"meshopt"===e.capabilities[0]){r=Object.assign(r,e);break}}}const i=We(Object.assign({},r,e),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);i.tiles=t.canonicalizeTileset(i,e.url),n(null,i)}},s=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const r=Object.values(e.language||{});if(0===r.length)return null;const n=Object.values(e.worldview||{});if(0===n.length)return null;const o=r.every((e=>e===t)),s=n.every((e=>e===i));return o&&s?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(e.data,i,r);return s?Wt.frame((()=>o(null,s))):e.url?Di(t.transformRequest(t.normalizeSourceURL(e.url,null,i,r),Ii.Source),o):Wt.frame((()=>{const{data:t,...i}=e;o(null,i)}))}function xy(e,t){const i=Math.pow(2,t.z),r=Math.floor(Qa(e.getWest())*i),n=Math.floor(el(e.getNorth())*i),o=Math.ceil(Qa(e.getEast())*i),s=Math.ceil(el(e.getSouth())*i);return t.x>=r&&t.x<o&&t.y>=n&&t.y<s}class TileBounds{constructor(e,t,i){this.bounds=e?LngLatBounds.convert(this.validateBounds(e)):null,this.minzoom=t||0,this.maxzoom=i||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(e){if(e){this.extraBounds||(this.extraBounds=[]);for(const t of e)this.extraBounds.push(LngLatBounds.convert(this.validateBounds(t)))}}contains(e){if(e.z>this.maxzoom||e.z<this.minzoom)return!1;if(this.bounds&&!xy(this.bounds,e))return!1;if(!this.extraBounds)return!0;for(const t of this.extraBounds)if(xy(t,e))return!0;return!1}static fromTileJSON(e){if(!e.bounds&&!e.extra_bounds)return null;const t=new TileBounds(e.bounds,e.minzoom,e.maxzoom);return t.addExtraBounds(e.extra_bounds),t}}class DedupedRequest{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,r){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(e,i)}),t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,r)}),t):e(i,r);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==r)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}}function vy(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=Pi(e.request,((e,r,n)=>{e?t(e):r&&t(null,{rawData:r,vectorTile:i?void 0:new VectorTile(new yf(r)),responseHeaders:new Map(n.entries())})}));return()=>{r.cancel(),t()}}),t)}class VectorTileSource extends Evented{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,We(t,["url","scheme","tileSize","promoteId"])),this._options=Object.assign({type:"vector"},t),this._collectResourceTiming=!!t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new DedupedRequest}load(e){this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map.getWorldview();this._tileJSONRequest=yy(this._options,this.map._requestManager,t,i,((r,n)=>{if(this._tileJSONRequest=null,this._loaded=!0,r)t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),i&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new ErrorEvent(r));else if(n){if(Object.assign(this,n),this.hasWorldviews=!!n.worldview_options,n.worldview_default&&(this.worldviewDefault=n.worldview_default),n.vector_layers){this.vectorLayers=n.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const e of n.vector_layers)this.vectorLayerIds.push(e.id),n.worldview&&n.worldview[e.source]&&this.localizableLayerIds.add(e.id)}this.tileBounds=TileBounds.fromTileJSON(n),qi(n.tiles,this.map._requestManager._customAccessToken),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))}e&&e(r)}))}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 e=aa(this.id,this.scope);this.load((()=>this.map.style.clearSource(e)))}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(e,t){const i=e.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(i),n=this.map._requestManager.transformRequest(r,Ii.Tile),o=this.map.style?this.map.style.getLut(this.scope):null,s=o?{image:o.image.clone()}:null,a={request:n,data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,lut:s,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:Wt.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:e.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&Pt(i)&&(a.localizableLayerIds=this.localizableLayerIds),a.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=t:e.request=e.actor.send("reloadTile",a,l.bind(this));else if(e.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",a,l.bind(this),void 0,!0);else{const t=vy.call({deduped:this._deduped},a,((t,i)=>{if(t||!i)l.call(this,t);else{const t=pt(i.responseHeaders);a.data={rawData:i.rawData.slice(0),expires:t.expires,cacheControl:t.cacheControl},e.actor&&e.actor.send("loadTile",a,l.bind(this),void 0,!0)}}),!0);e.request={cancel:t}}function l(i,r){return delete e.request,e.aborted?t(null):i&&i instanceof AJAXError&&404!==i.status?t(i):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),xi(this.dispatcher),t(null,r),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.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 RasterTileSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,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"},t),Object.assign(this,We(t,["url","scheme","tileSize"]))}load(e){this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"}));const t=this.map.getWorldview();this._tileJSONRequest=yy(this._options,this.map._requestManager,null,t,((t,i)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new ErrorEvent(t)):i&&(Object.assign(this,i),i.raster_layers&&(this.rasterLayers=i.raster_layers,this.rasterLayerIds=this.rasterLayers.map((e=>e.id))),this.tileBounds=TileBounds.fromTileJSON(i),qi(i.tiles),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(t)}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=aa(this.id,this.scope);this.load((()=>this.map.style.clearSource(e)))}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(e,t){const i=Wt.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);e.request=Oi(this.map._requestManager.transformRequest(r,Ii.Tile),((i,r,n)=>{if(delete e.request,e.aborted)return e.state="unloaded",t(null);if(i)return e.state="errored",t(i);if(!r)return t(null);const o=pt(n);this.map._refreshExpiredTiles&&e.setExpiryData(o),e.setTexture(r,this.map.painter),e.state="loaded",xi(this.dispatcher),t(null)}))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}unloadTile(e,t){e.texture&&e.texture instanceof Texture?(e.destroy(!1),e.texture&&e.texture instanceof Texture&&this.map.painter.saveTileTexture(e.texture)):e.destroy(),t&&t()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class MipLevel{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const i=this.toIdx(e,t);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function by(e,t,i,r){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(r[s])<1e-15){if(i[s]<e[s]||i[s]>t[s])return null}else{const a=1/r[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function wy(e,t,i,r,n,o,s,a,l,c,u){const h=r-e,d=n-t,p=o-i,f=s-e,m=a-t,_=l-i,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,x=u[0]*m-u[1]*f,v=h*g+d*y+p*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const A=T*p-E*d,I=E*h-w*p,C=w*d-T*h,M=(u[0]*A+u[1]*I+u[2]*C)*b;return M<0||S+M>1?null:(f*A+m*I+_*C)*b}function Ty(e,t,i){return(e-t)/(i-t)}function Ey(e,t,i,r,n,o,s,a,l){const c=1<<i,u=o-r,h=s-n,d=(e+1)/c*u+r,p=(t+0)/c*h+n,f=(t+1)/c*h+n;a[0]=(e+0)/c*u+r,a[1]=p,l[0]=d,l[1]=f}class DemMinMaxQuadTree{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)),i=[];let r=Math.ceil(Math.pow(2,t));const n=1/r,o=(e,t,i,r,n)=>{const o=r?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=a,n[2]=s,n[3]=l};let s=new MipLevel(r);const a=[];for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),n,!1,a);const i=Ay(a[0],a[1],e),l=Ay(a[2],a[1],e),c=Ay(a[2],a[3],e),u=Ay(a[0],a[3],e);s.minimums.push(Math.min(i,l,c,u)),s.maximums.push(Math.max(i,l,c,u)),s.leaves.push(1)}for(i.push(s),r/=2;r>=1;r/=2){const e=i[i.length-1];s=new MipLevel(r);for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),2,!0,a);const i=e.getElevation(a[0],a[1]),n=e.getElevation(a[2],a[1]),l=e.getElevation(a[2],a[3]),c=e.getElevation(a[0],a[3]),u=e.isLeaf(a[0],a[1]),h=e.isLeaf(a[2],a[1]),d=e.isLeaf(a[2],a[3]),p=e.isLeaf(a[0],a[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=u&&h&&d&&p;s.maximums.push(m),s.minimums.push(f),s.leaves.push(m-f<=5&&_?1:0)}i.push(s)}return i}(this.dem),i=t.length-1,r=t[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(t,0,0,i,0)}raycastRoot(e,t,i,r,n,o,s=1){return by([e,t,-100],[i,r,this.maximums[0]*s],n,o)}raycast(e,t,i,r,n,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(e,t,i,r,n,o,s);if(null==a)return null;const l=[],c=[],u=[],h=[],d=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;d.length>0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){Ey(f,m,_,e,t,i,r,u,h);const a=1<<_,l=(f+0)/a,c=(f+1)/a,d=(m+0)/a,g=(m+1)/a,y=Ay(l,d,this.dem)*s,x=Ay(c,d,this.dem)*s,v=Ay(c,g,this.dem)*s,b=Ay(l,g,this.dem)*s,w=wy(u[0],u[1],y,h[0],u[1],x,h[0],h[1],v,n,o),T=wy(h[0],h[1],v,u[0],h[1],b,u[0],u[1],y,n,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const e=k([],n,o,p);if(Sy(y,x,b,v,Ty(e[0],u[0],h[0]),Ty(e[1],u[1],h[1]))>=e[2])return p}continue}let g=0;for(let d=0;d<this._siblingOffset.length;d++){Ey((f<<1)+this._siblingOffset[d][0],(m<<1)+this._siblingOffset[d][1],_+1,e,t,i,r,u,h),u[2]=-100,h[2]=this.maximums[this.childOffsets[a]+d]*s;const p=by(u,h,n,o);if(null!=p){const e=p;l[d]=e;let t=!1;for(let i=0;i<g&&!t;i++)e>=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[g]=d),g++}}for(let e=0;e<g;e++){const t=c[e];d.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:_+1})}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,r,n){if(1===e[r].isLeaf(t,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,s=e[o];let a=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const r=2*t+this._siblingOffset[e][0],n=2*i+this._siblingOffset[e][1],o=s.getElevation(r,n),c=s.isLeaf(r,n),u=this._addNode(o.min,o.max,c);c&&(a|=1<<e),l||(l=u)}for(let r=0;r<this._siblingOffset.length;r++)a&1<<r||this._construct(e,2*t+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],o,l+r)}}function Sy(e,t,i,r,n,o){return xr(xr(e,i,o),xr(t,r,o),n)}function Ay(e,t,i){const r=i.dim,n=He(e*r-.5,0,r-1),o=He(t*r-.5,0,r-1),s=Math.floor(n),a=Math.floor(o),l=Math.min(s+1,r-1),c=Math.min(a+1,r-1);return Sy(i.get(s,a),i.get(l,a),i.get(s,c),i.get(l,c),n-s,o-a)}const Iy={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function Cy(e,t,i){return(256*e*256+256*t+i)/10-1e4}function My(e,t,i){return 256*e+t+i/256-32768}class DEMData{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,r=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return void st(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const n=this.dim=t.height-2,o=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=r,this._modifiedForSources={},!r){for(let e=0;e<n;e++)o[this._idx(-1,e)]=o[this._idx(0,e)],o[this._idx(n,e)]=o[this._idx(n-1,e)],o[this._idx(e,-1)]=o[this._idx(e,0)],o[this._idx(e,n)]=o[this._idx(e,n-1)];o[this._idx(-1,-1)]=o[this._idx(0,0)],o[this._idx(n,-1)]=o[this._idx(n-1,0)],o[this._idx(-1,n)]=o[this._idx(0,n-1)],o[this._idx(n,n)]=o[this._idx(n-1,n-1)]}const s="terrarium"===i?My:Cy;for(let e=0;e<o.length;++e){const t=4*e;this.floatView[e]=s(this.pixels[t],this.pixels[t+1],this.pixels[t+2])}this._timestamp=Wt.now()}_buildQuadTree(){this._tree=new DemMinMaxQuadTree(this)}get(e,t,i=!1){i&&(e=He(e,-1,this.dim),t=He(t,-1,this.dim));const r=this._idx(e,t);return this.floatView[r]}set(e,t,i){const r=this._idx(e,t),n=this.floatView[r];return this.floatView[r]=i,i-n}static getUnpackVector(e){return Iy[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 i=[0,0,0,0],r=DEMData.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new Float32Image({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t<s;t++)for(let i=r;i<n;i++){const r=4*this._idx(i,t),n=4*this._idx(i+a,t+l);this.pixels[r+0]=e.pixels[n+0],this.pixels[r+1]=e.pixels[n+1],this.pixels[r+2]=e.pixels[n+2],this.pixels[r+3]=e.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function Dy(e,t,i){1===e?t.headerLength=i.readFixed32():2===e?t.x=i.readVarint():3===e?t.y=i.readVarint():4===e?t.z=i.readVarint():5===e&&t.layers.push(function(e,t){return e.readFields(Fy,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},t)}(i,i.readVarint()+i.pos))}function Py(e,t,i){1===e?(t.delta_filter=function(e,t){return e.readFields(Ly,{blockSize:0},t)}(i,i.readVarint()+i.pos),t.filter="delta_filter"):2===e?(i.readVarint(),t.filter="zigzag_filter"):3===e?(i.readVarint(),t.filter="bitshuffle_filter"):4===e&&(i.readVarint(),t.filter="byteshuffle_filter")}function Ly(e,t,i){1===e&&(t.blockSize=i.readVarint())}function Ry(e,t,i){1===e?(i.readVarint(),t.codec="gzip_data"):2===e?(i.readVarint(),t.codec="jpeg_image"):3===e?(i.readVarint(),t.codec="webp_image"):4===e&&(i.readVarint(),t.codec="png_image")}function zy(e,t,i){let r=0,n=0;1===e?t.firstByte=i.readFixed64():2===e?t.lastByte=i.readFixed64():3===e?t.filters.push(function(e,t){return e.readFields(Py,{},t)}(i,i.readVarint()+i.pos)):4===e?t.codec=function(e,t){return e.readFields(Ry,{},t)}(i,i.readVarint()+i.pos):5===e?n=i.readFloat():6===e?r=i.readFloat():7===e?t.bands.push(i.readString()):8===e?t.offset=i.readDouble():9===e&&(t.scale=i.readDouble()),0===t.offset&&(t.offset=n),0===t.scale&&(t.scale=r)}function Fy(e,t,i){1===e?t.version=i.readVarint():2===e?t.name=i.readString():3===e?t.units=i.readString():4===e?t.tileSize=i.readVarint():5===e?t.buffer=i.readVarint():6===e?t.pixelFormat=i.readVarint():7===e&&t.dataIndex.push(function(e,t){return e.readFields(zy,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},t)}(i,i.readVarint()+i.pos))}function Oy(e,t,i){if(2===e)!function(e,t,i){e.readFields(By,i,t)}(i,i.readVarint()+i.pos,t);else if(3===e)throw new Error("Not implemented")}function By(e,t,i){if(1===e){let e=0;const r=i.readVarint()+i.pos;for(;i.pos<r;)t[e++]=i.readVarint()}}function ky(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let i=t[3];for(let r=2;r>=1;r--){const n=1===r?1:0,o=2===r?1:0;for(let r=0;r<t[0];r++){const s=t[1]*r;for(let r=n;r<t[1];r++){const n=t[2]*(r+s);for(let r=o;r<t[2];r++){const o=t[3]*(r+n);for(let r=0;r<t[3];r++){const t=o+r;e[t]+=e[t-i]}}}}i*=t[r]}return e}function Uy(e){for(let t=0,i=e.length;t<i;t++)e[t]=e[t]>>>1^-(1&e[t]);return e}function Vy(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t<e.length;t+=2){const i=e[t],r=e[t+1];e[t]=(240&i)>>4|(61440&i)>>8|(240&r)<<4|61440&r,e[t+1]=15&i|(3840&i)>>4|(15&r)<<8|(3840&r)<<4}return e;case"uint8":for(let t=0;t<e.length;t+=4){const i=e[t],r=e[t+1],n=e[t+2],o=e[t+3];e[t+0]=(192&i)>>6|(192&r)>>4|(192&n)>>2|192&o,e[t+1]=(48&i)>>4|(48&r)>>2|48&n|(48&o)<<2,e[t+2]=(12&i)>>2|12&r|(12&n)<<2|(12&o)<<4,e[t+3]=3&i|(3&r)<<2|(3&n)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}bs(DEMData,"DEMData"),bs(DemMinMaxQuadTree,"DemMinMaxQuadTree",{omit:["dem"]});var Ny=Uint8Array,jy=Uint16Array,Gy=Int32Array,Hy=new Ny([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]),qy=new Ny([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]),$y=new Ny([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zy=function(e,t){for(var i=new jy(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new Gy(i[30]);for(r=1;r<30;++r)for(var o=i[r];o<i[r+1];++o)n[o]=o-i[r]<<5|r;return{b:i,r:n}},Wy=Zy(Hy,2),Xy=Wy.b,Yy=Wy.r;Xy[28]=258,Yy[258]=28;for(var Ky=Zy(qy,0).b,Jy=new jy(32768),Qy=0;Qy<32768;++Qy){var ex=(43690&Qy)>>1|(21845&Qy)<<1;Jy[Qy]=((65280&(ex=(61680&(ex=(52428&ex)>>2|(13107&ex)<<2))>>4|(3855&ex)<<4))>>8|(255&ex)<<8)>>1}var tx=function(e,t,i){for(var r=e.length,n=0,o=new jy(t);n<r;++n)e[n]&&++o[e[n]-1];var s,a=new jy(t);for(n=1;n<t;++n)a[n]=a[n-1]+o[n-1]<<1;s=new jy(1<<t);var l=15-t;for(n=0;n<r;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],h=a[e[n]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)s[Jy[h]>>l]=c;return s},ix=new Ny(288);for(Qy=0;Qy<144;++Qy)ix[Qy]=8;for(Qy=144;Qy<256;++Qy)ix[Qy]=9;for(Qy=256;Qy<280;++Qy)ix[Qy]=7;for(Qy=280;Qy<288;++Qy)ix[Qy]=8;var rx=new Ny(32);for(Qy=0;Qy<32;++Qy)rx[Qy]=5;var nx=tx(ix,9),ox=tx(rx,5),sx=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},ax=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&i},lx=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},cx=["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"],ux=function(e,t,i){var r=new Error(t||cx[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,ux),!i)throw r;return r},hx=new Ny(0),dx="undefined"!=typeof TextDecoder&&new TextDecoder;try{dx.decode(hx,{stream:!0})}catch(e){}const px={gzip_data:"gzip"};class MRTError extends Error{constructor(e){super(e),this.name="MRTError"}}const fx={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},mx={uint32:1,uint16:2,uint8:4},_x={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let gx;class MapboxRasterTile{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 MRTError(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new MRTError("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),i=this.getHeaderLength(e);if(t.length<i)throw new MRTError(`Expected header with length >= ${i} but got buffer of length ${t.length}`);const r=new gx(t.subarray(0,i)).readFields(Dy,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==r.x||this.y!==r.y||this.z!==r.z))throw new MRTError(`Invalid attempt to parse header ${r.z}/${r.x}/${r.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=r.x,this.y=r.y,this.z=r.z;for(const e of r.layers)this.layers[e.name]=new MapboxRasterLayer(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let r of e.blockIndices){const n=i.dataIndex[r],o=n.firstByte-e.firstByte,s=n.lastByte-e.firstByte;if(i._blocksInProgress.has(r))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:r,blockShape:[n.bands.length].concat(i.bandShape),buffer:i.buffer,codec:n.codec.codec,filters:n.filters.map((e=>e.filter))};i._blocksInProgress.add(r),t.push(a)}return new MRTDecodingBatch(t,(()=>{t.forEach((e=>i._blocksInProgress.delete(e.blockIndex)))}),((e,r)=>{if(t.forEach((e=>i._blocksInProgress.delete(e.blockIndex))),e)throw e;r.forEach((e=>{this.getLayer(e.layerName).processDecodedData(e)}))}))}}class MapboxRasterLayer{constructor({version:e,name:t,units:i,tileSize:r,pixelFormat:n,buffer:o,dataIndex:s},a){if(this.version=e,1!==this.version)throw new MRTError(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=r,this.buffer=o,this.pixelFormat=fx[n],this.dataIndex=s,this.bandShape=[r+2*o,r+2*o,mx[this.pixelFormat]],this._decodedBlocks=new LRUCache(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return mx[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[i,r]of this.dataIndex.entries()){for(const[n,o]of r.bands.entries())if(o===e)return{bandIndex:t+n,blockIndex:i,blockBandIndex:n};t+=r.bands.length}break;case"number":for(const[i,r]of this.dataIndex.entries()){if(e>=t&&e<t+r.bands.length)return{bandIndex:e,blockIndex:i,blockBandIndex:e-t};t+=r.bands.length}break;default:throw new MRTError(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let t=1/0,i=-1/0;const r=[],n=new Set;for(const o of e){const{blockIndex:e}=this.getBlockForBand(o);if(e<0)throw new MRTError(`Invalid band: ${JSON.stringify(o)}`);const s=this.dataIndex[e];r.includes(e)||r.push(e),n.add(e),t=Math.min(t,s.firstByte),i=Math.max(i,s.lastByte)}if(n.size>this.cacheSize)throw new MRTError(`Number of blocks to decode (${n.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:i,blockIndices:r}}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:i}=this.getBlockForBand(e);if(t<0)throw new MRTError(`Band not found: ${JSON.stringify(e)}`);const r=this._decodedBlocks.get(t.toString());if(!r)throw new MRTError(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const n=this.dataIndex[t],o=this.bandShape.reduce(((e,t)=>e*t),1),s=i*o,a=r.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:n.offset,scale:n.scale}}}MapboxRasterTile.setPbf=function(e){gx=e};class MRTDecodingBatch{constructor(e,t,i){this.tasks=e,this._onCancel=t,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}function yx([e,t],i,r,{scaled:n=!0}={}){const{tileSize:o,buffer:s}=r,{x:a,y:l,z:c}=i;if(!isFinite(a)||!isFinite(l)||!isFinite(c))throw new Error("Invalid MRT header");const u=2**c,h=u*Qa(e),d=u*el(t);return function([e,t],i,{scaled:r=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:n,tileSize:o,buffer:s,offset:a,scale:l,dimension:c}=i;if(e<-s||e>o+s||t<-s||t>o+s)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${o}, buffer=${s}`);const u=(t+s)*(o+2*s)+(e+s);if(4294967295===new Uint32Array(n.buffer)[u])return null;let h=[];h=r?[]:new(0,i.data.constructor)(c);for(let e=0;e<c;e++)h[e]=Math.round(1e12*(n[c*u+e]*l+a))/1e12;return h}([Math.min(Math.max(-s,Math.floor((h-a)*o)),o-1+s),Math.min(Math.max(-s,Math.floor((d-l)*o)),o-1+s)],r,{scaled:n})}MapboxRasterTile.performDecoding=function(e,t){const i=new Uint8Array(e);return Promise.all(t.tasks.map((e=>{const{layerName:t,firstByte:r,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,u=i.subarray(r,n+1),h=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new MRTError(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||ux(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[i++]);return i+(2&t)}(n=e))+8>n.length&&ux(6,"invalid gzip data"),function(e,t,i,r){var n=e.length;if(!n||t.f&&!t.l)return i||new Ny(0);var o=!i,s=o||2!=t.i,a=t.i;o&&(i=new Ny(3*n));var l,c,u=function(e){var t=i.length;if(e>t){var r=new Ny(Math.max(2*t,e));r.set(i),i=r}},h=t.f||0,d=t.p||0,p=t.b||0,f=t.l,m=t.d,_=t.m,g=t.n,y=8*n;do{if(!f){h=ax(e,d,1);var x=ax(e,d+1,3);if(d+=3,!x){var v=e[(P=4+((d+7)/8|0))-4]|e[P-3]<<8,b=P+v;if(b>n){a&&ux(0);break}s&&u(p+v),i.set(e.subarray(P,b),p),t.b=p+=v,t.p=d=8*b,t.f=h;continue}if(1==x)f=nx,m=ox,_=9,g=5;else if(2==x){var w=ax(e,d,31)+257,T=ax(e,d+10,15)+4,E=w+ax(e,d+5,31)+1;d+=14;for(var S=new Ny(E),A=new Ny(19),I=0;I<T;++I)A[$y[I]]=ax(e,d+3*I,7);d+=3*T;var C=sx(A),M=(1<<C)-1,D=tx(A,C);for(I=0;I<E;){var P,L=D[ax(e,d,M)];if(d+=15&L,(P=L>>4)<16)S[I++]=P;else{var R=0,z=0;for(16==P?(z=3+ax(e,d,3),d+=2,R=S[I-1]):17==P?(z=3+ax(e,d,7),d+=3):18==P&&(z=11+ax(e,d,127),d+=7);z--;)S[I++]=R}}var F=S.subarray(0,w),O=S.subarray(w);_=sx(F),g=sx(O),f=tx(F,_),m=tx(O,g)}else ux(1);if(d>y){a&&ux(0);break}}s&&u(p+131072);for(var B=(1<<_)-1,k=(1<<g)-1,U=d;;U=d){var V=(R=f[lx(e,d)&B])>>4;if((d+=15&R)>y){a&&ux(0);break}if(R||ux(2),V<256)i[p++]=V;else{if(256==V){U=d,f=null;break}var N=V-254;V>264&&(N=ax(e,d,(1<<(H=Hy[I=V-257]))-1)+Xy[I],d+=H);var j=m[lx(e,d)&k],G=j>>4;if(j||ux(3),d+=15&j,O=Ky[G],G>3){var H=qy[G];O+=lx(e,d)&(1<<H)-1,d+=H}if(d>y){a&&ux(0);break}s&&u(p+131072);var q=p+N;if(p<O){var $=0-O,Z=Math.min(O,q);for($+p<0&&ux(3);p<Z;++p)i[p]=(void 0)[$+p]}for(;p<q;++p)i[p]=i[p-O]}}t.l=f,t.p=U,t.b=p,t.f=h,f&&(h=1,t.m=_,t.d=m,t.n=g)}while(!h);return p!=i.length&&o?(l=i,(null==(c=p)||c>l.length)&&(c=l.length),new Ny(l.subarray(0,c))):i.subarray(0,p)}(n.subarray(o,-8),{i:2},new Ny(((i=n)[(r=i.length)-4]|i[r-3]<<8|i[r-2]<<16|i[r-1]<<24)>>>0))));var i,r,n,o;const s=px[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then((e=>new Uint8Array(e)))}(u,c).then((e=>(function(e,t){e.readFields(Oy,t)}(new gx(e),h),new(0,_x[o])(h.buffer)))),d.then((e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":ky(e,s);break;case"zigzag_filter":Uy(e);break;case"bitshuffle_filter":Vy(e,o);break;default:throw new MRTError(`Unhandled filter "${l[t]}"`)}return{layerName:t,blockIndex:a,data:e}})).catch((e=>{throw e}))})))},bs(MRTDecodingBatch,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),bs(MapboxRasterTile,"MapboxRasterTile"),bs(MapboxRasterLayer,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class RasterArrayTileSource extends RasterTileSource{constructor(e,t,i,r){super(e,t,i,r),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(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(i,Ii.Tile),n={request:r,uid:e.uid,tileID:e.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};e.source=this.id,e.scope=this.scope,e.requestParams=r,e.actor||(e.actor=this.dispatcher.getActor());const o=(i,r,n)=>{if(delete e.request,e.aborted)return e.state="unloaded",t(null);if(i){if("AbortError"===i.name)return;return e.state="errored",t(i)}if(this.map._refreshExpiredTiles&&r){const t=pt(n);e.setExpiryData(t)}if(this.partial&&"expired"!==e.state)e.state="empty";else if(!this.partial){if(!r)return t(null);e.state="loaded",e._isHeaderLoaded=!0,e._mrt=r}t(null)};e.request=this.partial?e.fetchHeader(void 0,o.bind(this)):e.actor.send("loadTile",n,o.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(e,t,i,r){e._isHeaderLoaded&&("empty"!==e.state&&(e.state="reloading"),e.fetchBandForRender(t,i,r,((t,r)=>{if(t)return e.state="errored",this.fire(new ErrorEvent(t)),void this.triggerRepaint(e);r&&(e._isHeaderLoaded=!0,e.setTexturePerLayer(i,r,this.map.painter),e.state="loaded",this.triggerRepaint(e))})))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find((({id:t})=>t===e)),i=t&&t.fields,r=i&&i.bands&&i.bands;return r?r[0]:0}getTextureDescriptor(e,t,i){if(!e)return;const r=t.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let n=null;t instanceof RasterStyleLayer?n=t.paint.get("raster-array-band"):t instanceof RasterParticleStyleLayer&&(n=t.paint.get("raster-particle-array-band"));const o=n||this.getInitialBand(r);if(null==o)return;if(!e.textureDescriptorPerLayer.get(t.id))return void this.prepareTile(e,r,t.id,o);if(e.updateNeeded(t.id,o)&&!i)return;const s=e.textureDescriptorPerLayer.get(t.id);return Object.assign({},s,{texture:e.texturePerLayer.get(t.id)})}getImages(e,t){const i=new Map;for(const r of e)for(const e of t){const[t,n]=e.split("/"),o=r.getLayer(t);if(!o)continue;if(!o.hasBand(n)||!o.hasDataForBand(n))continue;const{bytes:s,tileSize:a,buffer:l}=o.getBandView(n),c=a+2*l,u={data:new RGBAImage({width:c,height:c},s),pixelRatio:2,sdf:!1,usvg:!1,version:0};i.set(e,u)}return i}queryRasterArrayValueByBandId(e,t,i){const r=t._mrt;return new Promise((n=>{const o={},s=new Set;for(const[a,l]of Object.entries(r.layers)){if(i.layerName&&a!==i.layerName)continue;const c={};o[a]=c;for(const{bands:u}of l.dataIndex)for(const h of u)i.bands&&!i.bands.includes(h)||(s.add(aa(a,h)),t.fetchBand(a,null,h,(t=>{Wt.frame((()=>{c[h]=t?null:yx([e.lng,e.lat],r,l.getBandView(h)),s.delete(aa(a,h)),0===s.size&&n(o)}))}),!1))}0===s.size&&n(o)}))}_loadTileForQuery(e,t){if(this._loadTileLoaded[e.uid])return void t(null,e._mrt);if(this._loadTilePending[e.uid])return void this._loadTilePending[e.uid].push(t);this._loadTilePending[e.uid]=[t];const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(i,Ii.Tile);e.actor.send("loadTile",{request:r,uid:e.uid,tileID:e.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},((t,i,r)=>{if(t)return this._loadTilePending[e.uid].forEach((e=>e(t,null))),void delete this._loadTilePending[e.uid];if(!i)return this._loadTilePending[e.uid].forEach((e=>e(null,null))),void delete this._loadTilePending[e.uid];if(this.map._refreshExpiredTiles&&i){const t=pt(r);e.setExpiryData(t)}e._mrt=i,e._isHeaderLoaded=!0,e.state="loaded",this._loadTilePending[e.uid].forEach((e=>e(null,i))),this._loadTileLoaded[e.uid]=!0,delete this._loadTilePending[e.uid]}),void 0,!0)}queryRasterArrayValueByAllBands(e,t,i){return new Promise(((r,n)=>{this._loadTileForQuery(t,((o,s)=>{o?n(o):r(s?this.queryRasterArrayValueByBandId(e,t,i):null)}))}))}queryRasterArrayValue(e,t){const i=LngLat.convert(e),r=this.findLoadedParent(i);return r&&r._mrt?t.bands||!this.partial?this.queryRasterArrayValueByBandId(i,r,t):this.queryRasterArrayValueByAllBands(i,r,t):Promise.resolve(null)}findLoadedParent(e){const t=MercatorCoordinate.fromLngLat(e,this.map.transform.tileSize),i=this.maxzoom+1,r=1<<i,n=Math.floor(t.x),o=Math.floor((t.x-n)*r),s=Math.floor(t.y*r),a=this.map.style.getSourceCache(this.id),l=new OverscaledTileID(i,n,i,o,s);return a.findLoadedParent(l,this.minzoom)}}const xx={vector:VectorTileSource,raster:RasterTileSource,"raster-dem":class RasterDEMTileSource extends RasterTileSource{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=Object.assign({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(i,r){i&&(e.state="errored",t(i)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",t(null))}e.request=Oi(this.map._requestManager.transformRequest(i,Ii.Tile),function(i,n,o){if(delete e.request,e.aborted)e.state="unloaded",t(null);else if(i)e.state="errored",t(i);else if(n){const t=pt(o);this.map._refreshExpiredTiles&&e.setExpiryData(t);const i=ImageBitmap&&n instanceof ImageBitmap&&Zt(),a=1-(n.width-((s=n.width)<=1?1:Math.pow(2,Math.floor(Math.log2(s)))))/2;a<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const l=i?n:Wt.getImageData(n,a),c={uid:e.uid,tileID:e.tileID,source:this.id,type:this.type,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:a};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadTile",c,r.bind(this),void 0,!0))}var s}.bind(this))}_getNeighboringTiles(e){const t=e.canonical,i=Math.pow(2,t.z),r=(t.x-1+i)%i,n=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+i)%i,s=t.x+1===i?e.wrap+1:e.wrap,a={};return a[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y).key]={backfilled:!1},a[new OverscaledTileID(e.overscaledZ,s,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(a[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y-1).key]={backfilled:!1},a[new OverscaledTileID(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},a[new OverscaledTileID(e.overscaledZ,s,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1<i&&(a[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y+1).key]={backfilled:!1},a[new OverscaledTileID(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},a[new OverscaledTileID(e.overscaledZ,s,t.z,o,t.y+1).key]={backfilled:!1}),a}},"raster-array":RasterArrayTileSource,geojson:class GeoJSONSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(r),this._data=t.data,this._options=Object.assign({},t),this._collectResourceTiming=t.collectResourceTiming,void 0!==t.maxzoom&&(this.maxzoom=t.maxzoom),void 0!==t.minzoom&&(this.minzoom=t.minzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;const n=Mn/this.tileSize;this.workerOptions=Object.assign({source:this.id,scope:this.scope,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(void 0!==t.buffer?t.buffer:128)*n,tolerance:(void 0!==t.tolerance?t.tolerance:.375)*n,extent:Mn,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:void 0!==t.clusterMaxZoom?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:Mn,radius:(void 0!==t.clusterRadius?t.clusterRadius:50)*n,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter,dynamic:t.dynamic},t.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(e){if(!this._options.dynamic)return this.fire(new ErrorEvent(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if("string"!=typeof e&&("Feature"===e.type&&(e={type:"FeatureCollection",features:[e]}),"FeatureCollection"!==e.type))return this.fire(new ErrorEvent(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&"string"!=typeof e&&"string"!=typeof this._data&&"FeatureCollection"===this._data.type){const t=new Map;for(const e of this._data.features)t.set(e.id,e);for(const i of e.features)t.set(i.id,i);this._data.features=[...t.values()]}else this._data=e;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,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:i},r),this}_updateWorkerData(e=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new Event("dataloading",{dataType:"source"})),this._loaded=!1;const t=Object.assign({append:e},this.workerOptions);t.scope=this.scope;const i=this._data;"string"==typeof i?(t.request=this.map._requestManager.transformRequest(Wt.resolveURL(i),Ii.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(i),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,((t,i)=>{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.resourceTiming[this.id]),e&&(this._partialReload=!0),this.fire(new Event("data",t)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(e),this._coalesce=!1)}))}loaded(){return this._loaded}reload(){const e=aa(this.id,this.scope);this.map.style.clearSource(e),this._updateWorkerData()}loadTile(e,t){const i=e.actor?"reloadTile":"loadTile";e.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,n=r?{image:r.image.clone()}:null,o=this._partialReload,s={type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:n,scope:this.scope,pixelRatio:Wt.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:e.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:o,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};e.request=this.actor.send(i,s,((r,n)=>o&&!n?(e.state="loaded",t(null)):(delete e.request,e.destroy(!1),e.aborted?t(null):r?t(r):(e.loadVectorData(n,this.map.painter,"reloadTile"===i),t(null)))),void 0,"loadTile"===i)}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 VideoSource extends ImageSource{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,Ii.Source).url);!function(e,t){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t<e.length;t++){const r=document.createElement("source");Li(e[t])||(i.crossOrigin="Anonymous"),r.src=e[t],i.appendChild(r)}}(this.urls,((e,t)=>{this._loaded=!0,e?this.fire(new ErrorEvent(e)):t&&(this.video=t,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(e){if(this.video){const t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new ErrorEvent(new ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new Texture(e,this.video,t.RGBA8),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ImageSource,model:ModelSource,"batched-model":class Tiled3DModelSource extends Evented{constructor(e,t,i,r){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(r)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=aa(this.id,this.scope);this.load((()=>this.map.style.clearSource(e)))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(e){this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map.getWorldview();this._tileJSONRequest=yy(this._options,this.map._requestManager,t,i,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new ErrorEvent(r))):n&&(Object.assign(this,n),n.bounds&&(this.tileBounds=new TileBounds(n.bounds,this.minzoom,this.maxzoom)),qi(n.tiles,this.map._requestManager._customAccessToken),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)}))}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,Ii.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:Wt.devicePixelRatio,promoteId:this.promoteId};if(e.actor&&"expired"!==e.state)if("loading"===e.state)e.reloadCallback=t;else{if(e.buckets){const t=Object.values(e.buckets);for(const e of t)e.dirty=!0;return void(e.state="loaded")}e.request=e.actor.send("reloadTile",r,n.bind(this))}else e.actor=this.dispatcher.getActor(),e.request=e.actor.send("loadTile",r,n.bind(this),void 0,!0);function n(i,r){return e.aborted?t(null):i&&404!==i.status?t(i):(this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadModelData(r,this.map.painter),e.state="loaded",void t(null))}}serialize(){return Object.assign({},this._options)}},canvas:class CanvasSource extends ImageSource{constructor(e,t,i,r){super(e,t,i,r),t.coordinates?Array.isArray(t.coordinates)&&4===t.coordinates.length&&!t.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new ErrorEvent(new ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new ErrorEvent(new ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new ErrorEvent(new ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"==typeof t.canvas||t.canvas instanceof HTMLCanvasElement||this.fire(new ErrorEvent(new ValidationError(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new ErrorEvent(new ValidationError(`sources.${e}`,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.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 ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(e){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?!e&&!this._playing||this.texture instanceof UserManagedTexture||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Texture(t,this.canvas,t.gl.RGBA8,{premultiply:!0}),this._prepareData(t)}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 CustomSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=t,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 ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new TileBounds(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.clearTiles=this._clearTiles.bind(this),t.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,We(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return We(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this.map=e,this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:r,z:n}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:r,z:n},{signal:o.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))})),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this.map.painter)}unloadTile(e,t){if(e.texture&&e.texture instanceof Texture?(e.destroy(!1),e.texture&&e.texture instanceof Texture&&this.map.painter.saveTileTexture(e.texture)):e.destroy(),this._implementation.unloadTile){const{x:t,y:i,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:r})}t&&t()}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 e=aa(this.id,this.scope);this.map.style.clearSource(e)}_update(){this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))}}},vx=function(e,t,i,r){const n=new xx[t.type](e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return et(["load","abort","unload","serialize","prepare"],n),n};function bx(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 wx(e,t,i,r=""){if(e.uniqueFeatureID){const n=bx(e,t,r);if(i.has(n))return!0;i.add(n)}return!1}function Tx(e,t,i,r,n=!1){const o=t.sourceCache.transform,s=t.sourceCache.tilesIn(e,t.has3DLayers,n);s.sort(Ax);const a=[];for(const e of s){const s=e.tile.queryRenderedFeatures(t,e,i,r,o,n);Object.keys(s).length&&a.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:s})}for(const i in t.layers){const n=t.layers[i];if(n.styleLayer){const i=n.styleLayer.queryRenderedFeatures(e,t.sourceCache,r);Object.keys(i).length&&a.push({wrappedTileID:0,queryResults:i})}}return 0===a.length?{}:function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t}(a)}function Ex(e,t,i,r,n,o){const s={},a=r.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(n[e]);l.sort(Ax);for(const e of l){const r=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,o);for(const t in r){const i=s[t]=s[t]||[],n=r[t];n.sort(((t,i)=>{const r=e.featureSortOrder;if(r){const e=r.indexOf(t.featureIndex);return r.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex}));for(const e of n)i.push(e)}}return s}function Sx(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(let e=0;e<i.length;e++){const o=i[e],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(r,t))}return r}function Ax(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}class DictionaryCoder{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}function Ix(e,t,i,r,n){return tt(e,((e,o)=>{const s=t instanceof PossiblyEvaluated?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,void 0,n):s}))}function Cx(e,t){return t-e}function Mx(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.fqid]=r}}return i}bs(class FeatureIndex{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new xs(Mn,16,0),this.featureIndexArray=new FeatureIndexArray,this.promoteId=t,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,t,i,r,n,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const l=this.grid;for(let e=0;e<t.length;e++){const i=t[e],r=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];r[0]=Math.min(r[0],t.x),r[1]=Math.min(r[1],t.y),r[2]=Math.max(r[2],t.x),r[3]=Math.max(r[3],t.y)}0!==s&&(r[0]-=s,r[1]-=s,r[2]+=s,r[3]+=s),r[0]<Mn&&r[1]<Mn&&r[2]>=0&&r[3]>=0&&l.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new VectorTile(new yf(this.rawTileData)).layers,this.sourceLayerCoder=new DictionaryCoder(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:i,transform:r,tileTransform:n,pixelPosMatrix:o,availableImages:s,worldview:a}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,c=i.bufferedTilespaceBounds,u=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,((e,t,r,n)=>Gl(i.bufferedTilespaceGeometry,e-l,t-l,r+l,n+l)));u.sort(Cx);let h=null;r.elevation&&u.length>0&&(h=DEMSampler.create(r.elevation,this.tileID));const d={};let p;for(let t=0;t<u.length;t++){const l=u[t];if(l===p)continue;p=l;const c=this.featureIndexArray.get(l);let f=null;this.is3DTile?this.loadMatchingModelFeature(d,c,e,i,r,a):this.loadMatchingFeature(d,c,e,s,a,((e,t,s,a=0)=>(f||(f=gl(e,this.tileID.canonical,n)),t.queryIntersectsFeature(i,e,s,f,this.z,r,o,h,a))))}return d}loadMatchingFeature(e,t,i,r,n,o){const{featureIndex:s,bucketIndex:a,sourceLayerIndex:l,layoutVertexArrayOffset:c}=t,u=this.bucketLayerIDs[a],h=i.layers,d=Object.keys(h);if(d.length&&!nt(d,u))return;const p=i.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(s),_=this.getId(m,f);for(let t=0;t<u.length;t++){const i=u[t];if(!h[i])continue;const{styleLayer:a,targets:l}=h[i];let d={};void 0!==_&&(d=p.getFeatureState(a.sourceLayer,_));const f=!o||o(m,a,d,c);if(!f)continue;const g=new Feature(m,this.z,this.x,this.y,_);g.tile=this.tileID.canonical,g.state=d;let y=this.serializedLayersCache.get(i);y||(y=a.serialize(),y.id=i,this.serializedLayersCache.set(i,y)),g.source=y.source,g.sourceLayer=y["source-layer"],g.layer=Object.assign({},y),g.layer.paint=Ix(y.paint,a.paint,m,d,r),g.layer.layout=Ix(y.layout,a.layout,m,d,r);let x=!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=yl(m,!0);if(!t.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:n}),e,this.tileID.canonical))continue}else if(!t.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:n}),m))continue;x=!0,e.targetId&&this.addFeatureVariant(g,e)}x&&this.appendToResult(e,i,s,g,f)}}loadMatchingModelFeature(e,t,i,r,n,o){const{featureIndex:s,bucketIndex:a}=t,l=this.bucketLayerIDs[a],c=i.layers,u=Object.keys(c);if(!u.length||nt(u,l))for(let t=0;t<l.length;t++){const a=l[t],{styleLayer:u,targets:h}=c[a];if("model"!==u.type)continue;const d=r.tile,p=d.getBucket(u);if(!(p&&p instanceof Tiled3dModelBucket))continue;const f=p_(p,s,r,n);if(!f)continue;const{z:m,x:_,y:g}=d.tileID.canonical,{feature:y,intersectionZ:x,position:v}=f;let b={};void 0!==y.id&&(b=i.sourceCache.getFeatureState(u.sourceLayer,y.id));const w=new Feature({},m,_,g,y.id);w.tile=this.tileID.canonical,w.state=b,w.properties=y.properties,w.geometry={type:"Point",coordinates:[v.lng,v.lat]};let T=this.serializedLayersCache.get(a);T||(T=u.serialize(),T.id=a,this.serializedLayersCache.set(a,T)),w.source=T.source,w.sourceLayer=T["source-layer"],w.layer=Object.assign({},T);let E=!1;for(const e of h){this.updateFeatureProperties(w,e);const{filter:t}=e;if(t)if(y.properties=w.properties,t.needGeometry){if(!t.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:o}),y,this.tileID.canonical))continue}else if(!t.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:o}),y))continue;E=!0,e.targetId&&this.addFeatureVariant(w,e)}E&&this.appendToResult(e,a,s,w,x)}}updateFeatureProperties(e,t,i){if(t.properties){const r={};for(const n in t.properties){const o=t.properties[n].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,i);null!=o&&(r[n]=o)}e.properties=r}}addFeatureVariant(e,t,i){const r={target:t.target,namespace:t.namespace,uniqueFeatureID:t.uniqueFeatureID};t.properties&&(r.properties=e.properties),e.variants=e.variants||{},e.variants[t.targetId]=e.variants[t.targetId]||[],e.variants[t.targetId].push(r)}appendToResult(e,t,i,r,n){let o=e[t];void 0===o&&(o=e[t]=[]),o.push({featureIndex:i,feature:r,intersectionZ:n})}lookupSymbolFeatures(e,t,i,r,n,o){const s={};this.loadVTLayers();for(const a of e)this.loadMatchingFeature(s,{bucketIndex:t,sourceLayerIndex:i,featureIndex:a,layoutVertexArrayOffset:0},r,n,o);return s}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[t])return n[t];const o=this.vtLayers[r].feature(t);return n[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;if(this.promoteId){const r=Array.isArray(this.promoteId)||"object"!=typeof this.promoteId?this.promoteId:this.promoteId[t];if(null!=r)if(Array.isArray(r)){if(!this.promoteIdExpression){const e=ps(r);if("success"!==e.result){const t=e.value.map((e=>`${e.key}: ${e.message}`)).join(", ");return void st(`Failed to create expression for promoteId: ${t}`)}this.promoteIdExpression=e.value}i=this.promoteIdExpression.evaluate({zoom:0},e)}else i=e.properties[r];"boolean"==typeof i&&(i=Number(i))}return i}},"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Dx=32,Px=33,Lx=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=Dx:i=r=a=Dx;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=e,a=l}const l=4*e;Lx[l+0]=i,Lx[l+1]=r,Lx[l+2]=n,Lx[l+3]=o}const Rx=new Uint16Array(2178),zx=new Uint8Array(1089),Fx=new Uint16Array(1089);function Ox(e){return 0===e?-.03125:32===e?.03125:0}const Bx=(()=>({type:2,extent:Mn,loadGeometry:()=>[[new Le(0,0),new Le(Mn+1,0),new Le(Mn+1,Mn+1),new Le(0,Mn+1),new Le(0,0)]]}))();class Tile{constructor(e,t,i,r,n,o){this.tileID=e,this.uid=Ye(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=o,this._hasAppearances=null}registerFadeDuration(e){const t=e+this.timeAdded;t<Wt.now()||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=lm(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,i){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=Mx(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof SymbolBucket){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof SymbolBucket&&t.hasRTLText){this.hasRTLText=!0,js.isLoading()||js.isLoaded()||"deferred"!==Vs()||Ns();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e],r=t.style.getOwnLayer(e);if(!r)continue;const n=r.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,n)}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness}else this.collisionBoxArray=new CollisionBoxArray}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}loadModelData(e,t,i){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets=Object.assign({},this.buckets,Mx(e.buckets,t.style)),e.featureIndex&&(this.latestFeatureIndex=e.featureIndex))}getBucket(e){return this.buckets[e.fqid]}upload(e,t){for(const i in this.buckets){const r=this.buckets[i];if(r.uploadPending()){let i={},n=[],o={zoom:0,pitch:0,brightness:0,worldview:""};if(t){if(t.style){n=t.style.listImages();const e=r.layers[0],o=e.sourceLayer||"_geojsonTileLayer",s=t.style.getLayerSourceCache(e);s&&(i=s._state.getState(o,void 0))}o={zoom:t.transform.zoom||0,pitch:t.transform.pitch||0,brightness:t.style.getBrightness()||0,worldview:t.worldview||""}}r.upload(e,this.tileID.canonical,i,n,o)}}const i=e.gl,r=this.imageAtlas;r&&!r.uploaded&&(this.imageAtlasTexture=new Texture(e,r.image,i.RGBA8,{useMipmap:!!r.patternPositions.size}),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Texture(e,this.glyphAtlasImage,i.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Texture(e,this.lineAtlas.image,i.R8),this.lineAtlas.uploaded=!0)}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=t.style.getBrightness();null===this._hasAppearances&&(this._hasAppearances=this.hasAppearances(t)),(this._lastUpdatedBrightness||r||this._hasAppearances)&&(!this._hasAppearances&&this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this.updateBuckets(t,this._lastUpdatedBrightness!==r),this._lastUpdatedBrightness=r))}evaluateQueryRenderedFeaturePadding(){let e=0;for(const t in this.buckets){const i=this.buckets[t];i.evaluateQueryRenderedFeaturePadding&&(e=Math.max(e,i.evaluateQueryRenderedFeaturePadding()))}return e}queryRenderedFeatures(e,t,i,r,n,o){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const s=this.evaluateQueryRenderedFeaturePadding(),a=function(e,t){const i=x([],[.5*e.width,.5*-e.height,1]);return f(i,i,[1,-1,0]),p(i,i,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(i)}(n,this.tileID);return this.latestFeatureIndex.query(e,{tilespaceGeometry:t,pixelPosMatrix:a,transform:r,availableImages:i,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:s})}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const s=Zs(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let t=0;t<o.length;t++){const r=o.feature(t);if(s.needGeometry){const e=yl(r,!0);if(!s.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:this.worldview}),e,this.tileID.canonical))continue}else if(!s.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:this.worldview}),r))continue;const h=i.getId(r,n),d=new Feature(r,a,l,c,h);d.tile=u,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=dt(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 i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{const r=this.expirationTime-t;r?this.expirationTime=e+Math.max(r,3e4):i=!0}else i=!0;i?(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){this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)&&e&&this.updateBuckets(e)}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){if(!this.latestFeatureIndex)return;if(!e.style)return;const i=e.style.listImages(),r=e.style.getBrightness();for(const n in this.buckets){if(!e.style.hasLayer(n))continue;const o=this.buckets[n],s=o.layers[0],a=s.sourceLayer||"_geojsonTileLayer",l=e.style.getLayerSourceCache(s);let c={};l&&(c=l._state.getState(a,void 0));const u=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},h=Object.keys(c).length>0&&!t;o.hasAppearances=o.layers.some((e=>e.appearances&&e.appearances.length>0));const d=h?o.stateDependentLayers:o.layers;if(h&&0!==o.stateDependentLayers.length||t){const e=this.latestFeatureIndex.loadVTLayers();o.update(c,e[a],i,u,d,t,r)}if(h&&0!==o.stateDependentLayers.length||t||o.hasAppearances){const t={zoom:e.transform.zoom,pitch:e.transform.pitch,brightness:e.style.getBrightness()||0,worldview:e.worldview};o.updateAppearances(this.tileID.canonical,c,i,t)}(o instanceof LineBucket||o instanceof FillBucket)&&e._terrain&&e._terrain.enabled&&l&&o.uploadPending()&&e._terrain._clearRenderCacheForTile(l.id,this.tileID);const p=e&&e.style&&e.style.getOwnLayer(n);p&&(this.queryPadding=Math.max(this.queryPadding,p.queryRadius(o)))}}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 i=t.context,r=i.gl;this.texture=this.texture||t.getTileTexture(e.width),this.texture&&this.texture instanceof Texture?this.texture.update(e):(this.texture=new Texture(i,e,r.RGBA8,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE))}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const i=gl(Bx,this.tileID.canonical,this.tileTransform)[0],r=new StructArrayLayout2i4,n=new StructArrayLayout1ui2;for(let e=0;e<i.length;e++){const{x:t,y:o}=i[e];r.emplaceBack(t,o),n.emplaceBack(e)}n.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(n),this._tileDebugBuffer=e.createVertexBuffer(r,oc.members),this._tileDebugSegments=SegmentVector.simpleSegment(0,0,r.length,n.length)}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const i=gl(Bx,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const e=function(e,t){const i=lm(e,t),r=Math.pow(2,e.z);for(let n=0;n<Px;n++)for(let o=0;o<Px;o++){const s=il((e.x+(o+Ox(o))/Dx)/r),a=rl((e.y+(n+Ox(n))/Dx)/r),l=t.project(s,a),c=n*Px+o;Rx[2*c+0]=Math.round((l.x*i.scale-i.x)*Mn),Rx[2*c+1]=Math.round((l.y*i.scale-i.y)*Mn)}zx.fill(0),Fx.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=Lx[t+0],r=Lx[t+1],n=Lx[t+2],o=Lx[t+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,u=r*Px+i,h=o*Px+n,d=a*Px+s,p=Math.hypot((Rx[2*u+0]+Rx[2*h+0])/2-Rx[2*d+0],(Rx[2*u+1]+Rx[2*h+1])/2-Rx[2*d+1])>=16;zx[d]=zx[d]||(p?1:0),e<1022&&(zx[d]=zx[d]||zx[(r+c>>1)*Px+(i+l>>1)]||zx[(o+c>>1)*Px+(n+l>>1)])}const n=new StructArrayLayout4i8,o=new StructArrayLayout3ui6;let s=0;function a(e,t){const i=t*Px+e;return 0===Fx[i]&&(n.emplaceBack(Rx[2*i+0],Rx[2*i+1],e*Mn/Dx,t*Mn/Dx),Fx[i]=++s),Fx[i]-1}function l(e,t,i,r,n,s){const c=e+i>>1,u=t+r>>1;if(Math.abs(e-n)+Math.abs(t-s)>1&&zx[u*Px+c])l(n,s,e,t,c,u),l(i,r,n,s,c,u);else{const l=a(e,t),c=a(i,r),u=a(n,s);o.emplaceBack(l,c,u)}}return l(0,0,Dx,Dx,Dx,0),l(Dx,Dx,0,0,0,Dx),{vertices:n,indices:o}}(this.tileID.canonical,t);r=e.vertices,n=e.indices}else{r=new StructArrayLayout4i8,n=new StructArrayLayout3ui6;for(const{x:e,y:t}of i)r.emplaceBack(e,t,0,0);const e=ru(r.int16.subarray(0,4*r.length),void 0,4);for(let t=0;t<e.length;t+=3)n.emplaceBack(e[t],e[t+1],e[t+2])}this._tileBoundsBuffer=e.createVertexBuffer(r,Nm.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(n),this._tileBoundsSegments=SegmentVector.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugBuffers(e,t){const i=t.projection;if(!i||"globe"!==i.name||t.freezeTileCoverage)return;const r=this.tileID.canonical,n=vc(dc(r,t)),o=Ac(t.zoom);let s;o>0&&(s=d(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,t,n,s,o),this._makeGlobeTileDebugTextBuffer(e,r,t,n,s,o)}_globePoint(e,t,i,r,n,o,s){let a=gc(e,t,i);if(o){const n=1<<i.z,l=Qa(r.center.lng),c=el(r.center.lat),u=(i.x+.5)/n-l;let h=0;u>.5?h=-1:u<-.5&&(h=1);let d=(e/Mn+i.x)/n+h,p=(t/Mn+i.y)/n;d=(d-l)*r._pixelsPerMercatorPixel+l,p=(p-c)*r._pixelsPerMercatorPixel+c;const f=[d*r.worldSize,p*r.worldSize,0];Z(f,f,o),a=hc(a,f,s)}return Z(a,a,n)}_makeGlobeTileDebugBorderBuffer(e,t,i,r,n,o){const s=new StructArrayLayout2i4,a=new StructArrayLayout1ui2,l=new StructArrayLayout3i6,c=(e,c,u,h,d)=>{const p=(u-e)/(d-1),f=(h-c)/(d-1),m=s.length;for(let u=0;u<d;u++){const h=e+u*p,d=c+u*f;s.emplaceBack(h,d);const _=this._globePoint(h,d,t,i,r,n,o);l.emplaceBack(_[0],_[1],_[2]),a.emplaceBack(m+u)}},u=Mn;c(0,0,u,0,16),c(u,0,u,u,16),c(u,u,0,u,16),c(0,u,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(a),this._tileDebugBuffer=e.createVertexBuffer(s,oc.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(l,nc.members),this._tileDebugSegments=SegmentVector.simpleSegment(0,0,s.length,a.length)}_makeGlobeTileDebugTextBuffer(e,t,i,r,n,o){const s=Mn/4,a=new StructArrayLayout2i4,l=new StructArrayLayout3ui6,c=new StructArrayLayout3i6,u=25;l.reserve(32),a.reserve(u),c.reserve(u);const h=(e,t)=>u*e+t;for(let e=0;e<u;e++){const l=e*s;for(let e=0;e<u;e++){const u=e*s;a.emplaceBack(u,l);const h=this._globePoint(u,l,t,i,r,n,o);c.emplaceBack(h[0],h[1],h[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=h(e,t),r=h(e,t+1),n=h(e+1,t),o=h(e+1,t+1);l.emplaceBack(i,r,n),l.emplaceBack(n,r,o)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(l),this._tileDebugTextBuffer=e.createVertexBuffer(a,oc.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(c,nc.members),this._tileDebugTextSegments=SegmentVector.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&&(this.imageAtlasTexture.destroy(),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 Texture&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof Texture&&(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"}}MapboxRasterTile.setPbf(yf);class RasterArrayTile extends Tile{constructor(e,t,i,r,n){super(e,t,i,r,n),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(e,t,i){const r=i.context,n=r.gl;let o=this.texturePerLayer.get(e)||i.getTileTexture(t.width);o&&o instanceof Texture?o.update(t,{premultiply:!1}):o=new Texture(r,t,n.RGBA8,{premultiply:!1}),this.texturePerLayer.has(e)||this.texturePerLayer.set(e,o)}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(e=16384,t){const i=this._mrt=new MapboxRasterTile(30),r=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(e-1)}});return this.entireBuffer=null,this.request=Pi(r,((r,n,o)=>{if(r)t(r);else try{const r=i.getHeaderLength(n);if(r>e)return void(this.request=this.fetchHeader(r,t));i.parseHeader(n),this._isHeaderLoaded=!0;let s=0;for(const e of Object.values(i.layers))s=Math.max(s,e.dataIndex[e.dataIndex.length-1].lastByte);n.byteLength>=s&&(this.entireBuffer=n),t(null,this.entireBuffer||n,o)}catch(e){t(e)}})),this.request}fetchBandForRender(e,t,i,r){this.fetchBand(e,t,i,(n=>{if(n)return void r(n);this.updateTextureDescriptor(e,t,i);const o=this.textureDescriptorPerLayer.get(t);r(null,o?o.img:null)}))}fetchBand(e,t,i,r,n=!0){const o=this._mrt;if(!this._isHeaderLoaded||!o)return void r(new Error("Tile header is not ready"));const s=this.actor;if(!s)return void r(new Error("Can't fetch tile band without an actor"));let a;const l=aa(String(i),aa(this.tileID.key,e));let c=this._taskQueue.get(l);c?c.add(r):(c=new Set,c.add(r),this._taskQueue.set(l,c));const u=(e,t)=>{a.complete(e,t),e?r(e):(c.forEach((e=>e(null,t))),this._taskQueue.delete(l))},h=(e,i)=>{if(e)return r(e);const n=s.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:i,task:a},u,void 0,!0);if(null!==t){const e=this._workQueuePerLayer.get(t)||[];e.push((()=>{n&&n.cancel(),a.cancel()})),this._workQueuePerLayer.has(t)||this._workQueuePerLayer.set(t,e)}};let d;try{d=o.getLayer(e)}catch(e){if("reloading"===this.state)return;throw e}if(!d)return void r(new Error(`Unknown sourceLayer "${e}"`));if(d.hasDataForBand(i))return c.forEach((e=>e(null,null))),void this._taskQueue.delete(l);const p=d.getDataRange([i]);if(a=o.createDecodingTask(p),!a||a.tasks.length)if(null!==t&&this.flushQueues(t),this.entireBuffer)h(null,this.entireBuffer.slice(p.firstByte,p.lastByte+1));else{const e=Object.assign({},this.requestParams,{headers:{Range:`bytes=${p.firstByte}-${p.lastByte}`}}),i=Pi(e,h);if(null!==t){const e=this._fetchQueuePerLayer.get(t)||[];e.push((()=>{i.cancel(),a.cancel()})),this._fetchQueuePerLayer.has(t)||this._fetchQueuePerLayer.set(t,e)}}}updateNeeded(e,t){return(!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(e,t,i){if(!this._mrt)return;const r=this._mrt.getLayer(e);if(!r||!r.hasBand(i)||!r.hasDataForBand(i))return;const{bytes:n,tileSize:o,buffer:s,offset:a,scale:l}=r.getBandView(i),c=o+2*s,u=new RGBAImage({width:c,height:c},n),h=this.texturePerLayer.get(t);h&&h instanceof Texture&&h.update(u,{premultiply:!1}),this.textureDescriptorPerLayer.set(t,{layer:e,band:i,img:u,buffer:s,offset:a,tileSize:o,format:r.pixelFormat,mix:[l,256*l,65536*l,16777216*l]})}destroy(e=!1){if(super.destroy(e),delete this._mrt,!e)for(const e of this.texturePerLayer.values())e&&e instanceof Texture&&e.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 TileCache{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 r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),i)),this.data[r].push(n),this.order.push(r),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,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.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 r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class SourceFeatureState{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},Object.assign(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){const i=this.state[e]||{},r=this.stateChanges[e]||{},n=this.deletedStates[e];if(null===n)return{};if(void 0!==t){const e=String(t),o=Object.assign({},i[e],r[e]);if(n){const e=n[t];if(null===e)return{};for(const t in e)delete o[t]}return o}const o=Object.assign({},i,r);if(n)for(const e in n)delete o[e];return o}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 i in e)e[i].refreshFeatureState(t)}}class SourceCache extends Evented{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,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 TileCache(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 SourceFeatureState,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}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)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,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(kx).map((e=>e.key))}getRenderableIds(e,t){const i=[];for(const r in this._tiles)this._isIdRenderable(+r,e,t)&&i.push(this._tiles[r]);return e?i.sort(((e,t)=>{const i=e.tileID,r=t.tileID,n=new Le(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Le(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||o.y-n.y||o.x-n.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(kx).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(e,t,i,r,n){if(r){if(e.state="errored",404!==r.status)this._source.fire(new ErrorEvent(r,{tile:e}));else{if(this._source.fire(new Event("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:e})),!(e.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)}return}e.timeAdded=Wt.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null);let o=new Map;n&&n.responseHeaders&&(o=n.responseHeaders),this._source.fire(new Event("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id,responseHeaders:o}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r<t.length;r++){const n=t[r];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);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 r=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){r[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),r=this._getLoadedTile(t);if(r)return r}}_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,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;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 r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}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(e,t,i,r,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const o="batched-model"===this._source.type;let s,a=this._source.maxzoom;const l=this.map&&this.map.painter?this.map.painter._terrain:null;if(l&&l.sourceCache===this&&l.attenuationRange()){const e=l.attenuationRange()[0],t=Math.floor(e)-Math.log2(l.getDemUpscale());a>t&&(a=t)}if(this.used||this.usedForTerrain){if(this._source.tileID)s=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)));else if(0!==this.tileCoverLift){const r=e.clone();r.tileCoverLift=this.tileCoverLift,s=r.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:a,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:o}),this._source.minzoom<=1&&"globe"===e.projection.name&&(s.push(new OverscaledTileID(1,0,1,0,0)),s.push(new OverscaledTileID(1,0,1,1,0)),s.push(new OverscaledTileID(1,0,1,0,1)),s.push(new OverscaledTileID(1,0,1,1,1)))}else if(s=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:a,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:o}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);s=s.filter((t=>e(t)))}}else s=[];if(s.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Ux(this._source.type)){const a=e.coveringZoomLevel({tileSize:t||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),l=Math.min(a,this._source.maxzoom);if(o){const t=e.extendTileCover(s,l);for(const e of t)s.push(e)}else if(n){const t=e.extendTileCoverToNearPlane(s,this.transform.getFrustum(l),l);for(const e of t)s.push(e)}else if(this.castsShadows&&r){const t=e.extendTileCover(s,l,r,16);for(const e of t)this._shadowCasterTiles[e.key]=!0,s.push(e)}}const c=this._updateRetainedTiles(s);if(Ux(this._source.type)&&0!==s.length){const e={},t={},i=Object.keys(c);for(const r of i){const i=c[r],n=this._tiles[r];if(!n||n.fadeEndTime&&n.fadeEndTime<=Wt.now())continue;const o=this.findLoadedParent(i,Math.max(i.overscaledZ-SourceCache.maxOverzooming,this._source.minzoom));o&&(this._addTile(o.tileID),e[o.tileID.key]=o.tileID),t[r]=i}const r=s[s.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(c[e]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>r;){n=n.scaledTo(n.overscaledZ-1);const r=this._tiles[n.key];if(r&&r.hasData()&&t[n.key]){c[e]=i.tileID;break}}}for(const t in e)c[t]||(this._coveredTiles[t]=!0,c[t]=e[t])}for(const e in c)this._tiles[e].clearFadeHold();const u=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i}(this._tiles,c);for(const e of u){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-SourceCache.maxOverzooming,this._source.minzoom),s=Math.max(n+SourceCache.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,r,s,t);for(const r of e){let e=this._tiles[r.key];if(e.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(e){let t=this._tiles[e.key];if(t)return!0!==t.isExtraShadowCaster||!!this._shadowCasterTiles[e.key]||this._reloadTile(e.key,"reloading"),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null,r=this._source.tileSize*e.overscaleFactor();t="raster-array"===this._source.type?new RasterArrayTile(e,r,this.transform.tileZoom,i,this._isRaster):new Tile(e,r,this.transform.tileZoom,i,this._isRaster,this._source.worldview),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t.uses++,this._tiles[e.key]=t,i||this._source.fire(new Event("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t}_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(e,t,i){const r=[],n=this.transform;if(!n)return r;const o="globe"===n.projection.name,s=Qa(n.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(He(s,...Vx(e,-1))-s),Math.abs(He(s,...Vx(e,1))-s)];c=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(He(s,...Vx(e,-1))-s),Math.abs(He(s,...Vx(e,0))-s),Math.abs(He(s,...Vx(e,1))-s)];c=[t.indexOf(Math.min(...t))-1]}}else c=[0];for(const i of c){const o=e.containsTile(l,n,t,i);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)),r="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=r?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,r=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<<e.canonical.z);n[e.key]=((e.canonical.x+.5)*t+e.wrap-i[0])*r[0]+((e.canonical.y+.5)*t-i[1])*r[1]-i[2]*r[2]}return t.sort(((e,t)=>n[e.key]-n[t.key])),t}hasTransition(){if(this._source.hasTransition())return!0;if(Ux(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=Wt.now())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 r=this._tiles[e];r&&r.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(e,t){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(e,t))};return void this._source.on("data",i)}const i=new Map,r=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,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)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}Ze(Array.from(i.values()),((e,t)=>{const i=new Tile(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)}))}),t)}}function kx(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Ux(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Vx(e,t){const i=1<<e.z;return[e.x/i+t,(e.x+1)/i+t]}SourceCache.maxOverzooming=10,SourceCache.maxUnderzooming=3;class BuildingIndex{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 r=this.style._mergedLayers[i];if("fill-extrusion"===r.type||"building"===r.type)this.layers.push({layer:r,visible:e,visibilityChanged:t});else if("model"===r.type){const i=this.style.getLayerSource(r);i&&"batched-model"===i.type&&this.layers.push({layer:r,visible:e,visibilityChanged:t})}}}onNewFrame(e){this.layersGotHidden=!1;for(const t of this.layers){const i=t.layer;let r=!1;"fill-extrusion"===i.type?r=!i.isHidden(e)&&i.paint.get("fill-extrusion-opacity")>0:"building"===i.type?r=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(r=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!r&&t.visible,t.visible=r}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,r=this.style.getLayerSourceCache(i);let n=1;"fill-extrusion"===i.type?n=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(n=e.visible?i.paint.get("building-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r)for(const e in r._tiles){const i=r._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){o=i;break}}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:n})}e.hasAnyZOffset=!1;let i=!1;for(let r=0;r<e.symbolInstances.length;r++){const n=e.symbolInstances.get(r),o=n.zOffset,s=this._getHeightAtTileOffset(t,n.tileAnchorX,n.tileAnchorY);n.zOffset=s!==Number.NEGATIVE_INFINITY?s:o,i||o===n.zOffset||(i=!0),e.hasAnyZOffset||0===n.zOffset||(e.hasAnyZOffset=!0)}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(e,t,i,r){let n=t,o=i;if(e.canonical.z!==r.canonical.z){const s=r.canonical,a=1/(1<<e.canonical.z-s.z);n=(t+e.canonical.x*Mn)*a-s.x*Mn|0,o=(i+e.canonical.y*Mn)*a-s.y*Mn|0}return{tileX:n,tileY:o}}_getHeightAtTileOffset(e,t,i){let r,n;for(let o=0;o<this.layers.length;++o){const s=this.layers[o].layer;if("fill-extrusion"!==s.type&&"building"!==s.type)continue;const{bucket:a,tileID:l,verticalScale:c}=this.currentBuildingBuckets[o];if(!a)continue;const{tileX:u,tileY:h}=this._mapCoordToOverlappingTile(e,t,i,l),d=a.getHeightAtTileCoord(u,h);d&&void 0!==d.height&&(d.hidden?r=d.height:n=Math.max(d.height*c,n||0))}if(void 0!==n)return n;for(let n=0;n<this.layers.length;++n){const o=this.layers[n];if("model"!==o.layer.type||!o.visible)continue;const{bucket:s,tileID:a}=this.currentBuildingBuckets[n];if(!s)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,i,a),u=s.getHeightAtTileCoord(l,c);if(u&&!u.hidden)return void 0===u.height&&void 0!==r?Math.min(u.maxHeight,r)*u.verticalScale:u.height?u.height*u.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}var Nx=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function jx(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return Nx.forEach((e=>{e in t&&(i[e]=t[e])})),i}function Gx(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=jx(e[i],t[e[i].ref]));return e}const Hx={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 qx(e,t,i){i.push({command:Hx.addSource,args:[e,t[e]]})}function $x(e,t,i){t.push({command:Hx.removeSource,args:[e]}),i[e]=!0}function Zx(e,t,i,r){$x(e,i,r),qx(e,t,i)}function Wx(e,t,i){let r;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!Re(e[i][r],t[i][r]))return!1;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!Re(e[i][r],t[i][r]))return!1;return!0}function Xx(e,t,i,r,n,o){let s;for(s in t=t||{},e=e||{})e.hasOwnProperty(s)&&(Re(e[s],t[s])||i.push({command:o,args:[r,s,t[s],n]}));for(s in t)t.hasOwnProperty(s)&&!e.hasOwnProperty(s)&&(Re(e[s],t[s])||i.push({command:o,args:[r,s,t[s],n]}))}function Yx(e){return e.id}function Kx(e,t){return e[t.id]=t,e}function Jx(e,t,i){const r=t.createTileMatrix(e,e.worldSize,i.toUnwrapped());return p(new Float32Array(16),e.projMatrix,r)}function Qx(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const r=i.clone();return r.setProjection(t.projection),Jx(r,t.getProjection(),e)}function ev(e,t,i){return t.name===i.projection.name?e.projMatrix:Jx(i,t,e)}class PathInterpolator{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(e){if(1===this.points.length)return this.points[0];e=He(e,0,1);let t=1,i=this._distances[t];const r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];const n=t-1,o=this._distances[n],s=i-o,a=s>0?(r-o)/s:0;return this.points[n].mult(1-a).add(this.points[t].mult(a))}}class GridIndex{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),n.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,r,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,i,r,n,o){this.circleCells[n].push(o)}_query(e,t,i,r,n,o){if(i<0||e>this.width||r<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)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],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}return o?s.filter(o):s}return this._forEachCell(e,t,i,r,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[u],t=n[u+1],i=n[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)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 o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const e=this.circles;for(const t of h)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 o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,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,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,u=Math.abs(t-(n+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}const tv={unknown:0,flipRequired:1,flipNotRequired:2},iv=Math.tan(85*Math.PI/180);function rv(e,t,r,n,o,s,a){const c=l();if(r)if("globe"===s.name){const e=function(e,t){const{x:i,y:r}=e.point,n=Ec(i,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return p(n,n,bc(uc(t)))}(o,t);p(c,c,e)}else{const e=i([],a);c[0]=e[0],c[1]=e[1],c[4]=e[2],c[5]=e[3],n||y(c,c,o.angle)}else p(c,o.labelPlaneMatrix,e);return c}function nv(e,t,i,r,n,o,s){const a=rv(e,t,i,r,n,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ov(e,t,i,r,n,o,s){if(i){if("globe"===o.name){const a=rv(e,t,i,r,n,o,s);return d(a,a),p(a,e,a),a}{const t=c(e),i=u([]);return i[0]=s[0],i[1]=s[1],i[4]=s[2],i[5]=s[3],p(t,t,i),r||y(t,t,-n.angle),t}}return n.glCoordMatrix}function sv(e,t,i,r){const n=[e,t,i,1];i?se(n,n,r):gv(n,n,r);const o=n[3];return n[0]/=o,n[1]/=o,n[2]/=o,n}function av(e,t){return Math.min(.5+e/t*.5,1.5)}function lv(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function cv(e,t,i,r,n,o,s,a,l,c,u=1){const h=i.transform,d=r?e.textSizeData:e.iconSizeData,p=Nf(d,i.transform.zoom,u),f="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],_=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=r?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const y=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let b,w=!1;for(let r=0;r<x.length;r++){const u=x.get(r),{numGlyphs:f,writingMode:T}=u;if(T!==zf.vertical||w||b===zf.horizontal||(w=!0),b=T,(u.hidden||T===zf.vertical)&&!w){_v(f,_);continue}w=!1;const E=new Le(u.tileAnchorX,u.tileAnchorY),S="road"===e.elevationType,A=!!h.elevation||S;let{x:I,y:C,z:M}=h.projection.projectTilePoint(E.x,E.y,c.canonical),D=null;if(A){const t=S?e.getElevationFeatureForText(r):null;D={getElevation:l,elevation:h.elevation,elevationFeature:t};const[i,n,o]=l(E,h.elevation,t);I+=i,C+=n,M+=o}const P=[I,C,M,1];if(se(P,P,t),!lv(P,m)){_v(f,_);continue}const L=P[3],R=av(i.transform.getCameraToCenterDistance(h.projection),L),z=Vf(d,p,u),F=s?z/R:z*R,O=sv(I,C,M,n);if(O[3]<=0){_v(f,_);continue}let B={};const k=Oe(e.layers[0].layout.get("text-max-angle")),U=Math.cos(k),V=s?null:D,N=dv(u,F,!1,a,t,n,o,e.glyphOffsetArray,y,_,g,O,E,B,v,V,h.projection,c,s,U);w=N.useVertical,V&&N.needsFlipping&&(B={}),(N.notEnoughRoom||w||N.needsFlipping&&dv(u,F,!0,a,t,n,o,e.glyphOffsetArray,y,_,g,O,E,B,v,V,h.projection,c,s,U).notEnoughRoom)&&_v(f,_)}r?(e.text.dynamicLayoutVertexBuffer.updateData(_),g&&e.text.globeExtVertexBuffer&&e.text.globeExtVertexBuffer.updateData(g)):(e.icon.dynamicLayoutVertexBuffer.updateData(_),g&&e.icon.globeExtVertexBuffer&&e.icon.globeExtVertexBuffer.updateData(g))}function uv(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_){const{lineStartIndex:g,glyphStartIndex:y,segment:x}=a,v=y+a.numGlyphs,b=g+a.lineLength,w=t.getoffsetX(y),T=t.getoffsetX(v-1),E=mv(e*w,i,r,n,o,s,x,g,b,l,c,u,h,d,!0,p,f,m,_);if(!E)return null;const S=mv(e*T,i,r,n,o,s,x,g,b,l,c,u,h,d,!0,p,f,m,_);return S?{first:E,last:S}:null}function hv(e,t,i,r){return e===zf.horizontal&&Math.abs(r)>Math.abs(i)?{useVertical:!0}:e===zf.vertical?r>0?{needsFlipping:!0}:null:t!==tv.unknown&&function(e,t){return 0===e||Math.abs(t/e)>iv}(i,r)?t===tv.flipRequired?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function dv(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x){const v=t/24,b=e.lineOffsetX*v,w=e.lineOffsetY*v,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:S,segment:A,writingMode:I,flipState:C}=e,M=T+e.lineLength,D=e=>{if(u){const[t,i,r]=e.up,n=c.length;Cm(u,n+0,t,i,r),Cm(u,n+1,t,i,r),Cm(u,n+2,t,i,r),Cm(u,n+3,t,i,r)}const[t,i,r]=e.point;Dm(c,t,i,r,e.angle)};if(S>1){const t=uv(v,a,b,w,i,h,d,e,l,o,p,m,!1,_,g,y,x);if(!t)return{notEnoughRoom:!0};if(r&&!i){let[i,r,n]=t.first.point,[o,a,l]=t.last.point;[i,r]=sv(i,r,n,s),[o,a]=sv(o,a,l,s);const c=hv(I,C,(o-i)*f,a-r);if(e.flipState=c&&c.needsFlipping?tv.flipRequired:tv.flipNotRequired,c)return c}D(t.first);for(let e=E+1;e<E+S-1;e++){const t=mv(v*a.getoffsetX(e),b,w,i,h,d,A,T,M,l,o,p,m,!1,!1,_,g,y,x);if(!t)return c.length-=4*(e-E),{notEnoughRoom:!0};D(t)}D(t.last)}else{if(r&&!i){const t=sv(d.x,d.y,0,n),i=T+A+1,r=new Le(l.getx(i),l.gety(i)),o=sv(r.x,r.y,0,n),s=o[3]>0?o:fv(d,r,t,1,n,void 0,_,g.canonical),a=hv(I,C,(s[0]-t[0])*f,s[1]-t[1]);if(e.flipState=a&&a.needsFlipping?tv.flipRequired:tv.flipNotRequired,a)return a}const t=mv(v*a.getoffsetX(E),b,w,i,h,d,A,T,M,l,o,p,m,!1,!1,_,g,y,x);if(!t)return{notEnoughRoom:!0};D(t)}return{}}function pv(e,t,i,r,n){const{x:o,y:s,z:a}=r.projectTilePoint(e.x,e.y,t);if(!n)return sv(o,s,a,i);const[l,c,u]=n.getElevation(e,n.elevation,n.elevationFeature);return sv(o+l,s+c,a+u,i)}function fv(e,t,i,r,n,o,s,a){const l=pv(e.sub(t)._unit()._add(e),a,n,s,o);return J(l,i,l),G(l,l),k(l,i,l,r)}function mv(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y){const x=r?e-t:e+t;let v=x>0?1:-1,b=0;r&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=a+s+(v>0?0:1)|0,T=n,E=n,S=0,A=0;const I=Math.abs(x),C=[],M=[];let D=o,P=D,L=Y([]);const R=()=>fv(P,D,E,I-S+1,u,d,m,_.canonical);for(;S+A<=I;){if(w+=v,w<a||w>=l)return null;if(E=T,P=D,C.push(E),p&&M.push(P),D=new Le(c.getx(w),c.gety(w)),T=h[w],!T){const e=pv(D,_.canonical,u,m,d);T=e[3]>0?h[w]=e:R()}S+=A;const e=J([],T,E),t=U(E,T);if(i&&t>0&&A>0&&H(L,e)/(A*t)<y)return null;A=t,L=e}f&&d&&(h[w]&&(T=R(),A=U(E,T),L=J([],T,E)),h[w]=T);const z=(I-S)/A,F=D.sub(P)._mult(z)._add(P),O=k([],E,L,z);let B=[0,0,1],V=L[0],N=L[1];if(g&&(B=m.upVector(_.canonical,F.x,F.y),0!==B[0]||0!==B[1]||1!==B[2])){const e=[B[2],0,-B[0]],t=q([],B,e);G(e,e),G(t,t),V=H(L,e),N=H(L,t)}if(i){const e=q([],B,L);G(e,e),k(O,O,e,i*v)}const j=b+Math.atan2(N,V);return C.push(O),p&&M.push(F),{point:O,angle:j,path:C,tilePath:M,up:B}}function _v(e,t){const i=t.length,r=i+4*e;t.resize(r),t.float32.fill(-1/0,4*i,4*r)}function gv(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const yv=100;class CollisionIndex{constructor(e,t,i=new GridIndex(e.width+200,e.height+200,25),r=new GridIndex(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+yv,this.screenBottomBoundary=e.height+yv,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,i,r,n,o,s,a,l,c,u){let h=i.projectedAnchorX,d=i.projectedAnchorY,p=i.projectedAnchorZ;const f=i.tileAnchorX,m=i.tileAnchorY,_=i.elevation,g=i.tileID,y=e.getProjection();if(_&&g){const[e,t,r]=y.upVector(g.canonical,i.tileAnchorX,i.tileAnchorY),n=y.upVectorScale(g.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;h+=e*_*n,d+=t*_*n,p+=r*_*n}const x="globe"===e.projection.name,v="globe"===e.projection.name?Ac(this.transform.zoom):0;if(g&&x&&v<1&&!o){const e=1<<g.canonical.z,t=ye(f,m);we(t,t,1/Mn),ve(t,t,ye(g.canonical.x,g.canonical.y)),we(t,t,1/e),Ce(t,t,ye(r[0],r[1])),t[0]=$e(t[0],-.5,.5),we(t,t,Mn);const i=re(t[0],t[1],Mn/(2*Math.PI),1);se(i,i,n),h=xr(h,i[0],v),d=xr(d,i[1],v),p=xr(p,i[2],v)}const b=this.projectAndGetPerspectiveRatio(c,h,d,p,i.tileID,"globe"===y.name||!!_||this.transform.pitch>0,y),w=l*b.perspectiveRatio,T=(i.x1*t+s.x-i.padding)*w+b.point.x,E=(i.y1*t+s.y-i.padding)*w+b.point.y,S=(i.x2*t+s.x+i.padding)*w+b.point.x,A=(i.y2*t+s.y+i.padding)*w+b.point.y,I=b.perspectiveRatio<=.55||b.occluded;return!this.isInsideGrid(T,E,S,A)||!a&&this.grid.hitTest(T,E,S,A,u)||I?{box:[],offscreen:!1,occluded:b.occluded}:{box:[T,E,S,A],offscreen:this.isOffscreen(T,E,S,A),occluded:!1}}placeCollisionCircles(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const _=[],g=this.transform.elevation,y=e.getProjection(),x="road"===e.elevationType,v=!!g||x,b=Elevation.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y),w=new Le(i.tileAnchorX,i.tileAnchorY),T=new Le(i.tileAnchorX,i.tileAnchorY);let{x:E,y:S,z:A}=y.projectTilePoint(T.x,T.y,m.canonical),I=null;if(v){const t=x?e.getElevationFeatureForText(r):null;I={getElevation:b,elevation:g,elevationFeature:t};const[i,n,o]=b(w,g,t);E+=i,S+=n,A+=o}const C="globe"===y.name,M=this.projectAndGetPerspectiveRatio(a,E,S,A,m,C||!!g||this.transform.pitch>0,y),{perspectiveRatio:D}=M,P=(h?s/D:s*D)/24,L=sv(E,S,A,l),R=i.lineOffsetX*P,z=i.lineOffsetY*P,F=Oe(e.layers[0].layout.get("text-max-angle")),O=Math.cos(F),B=M.signedDistanceFromCamera>0?uv(P,o,R,z,x&&1===i.flipState,L,T,i,n,l,{},v&&!h?I:null,h&&v,y,m,h,O):null;let k=!1,U=!1,V=!0;if(B&&!M.occluded){const e=.5*p*D+f,i=new Le(-100,-100),r=new Le(this.screenRightBoundary,this.screenBottomBoundary),n=new PathInterpolator,{first:o,last:s}=B,a=o.path.length;let l=[];for(let e=a-1;e>=1;e--)l.push(o.path[e]);for(let e=1;e<s.path.length;e++)l.push(s.path[e]);const h=2.5*e;c&&(l=l.map((([e,t,i],r)=>(v&&!C&&(i=b(r<a-1?o.tilePath[a-1-r]:s.tilePath[r-a+2],g,I.elevationFeature)[2]),sv(e,t,i,c)))),l.some((e=>e[3]<=0))&&(l=[]));let m=[];if(l.length>0){let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const i of l)e=Math.min(e,i[0]),n=Math.min(n,i[1]),t=Math.max(t,i[0]),o=Math.max(o,i[1]);t>=i.x&&e<=r.x&&o>=i.y&&n<=r.y&&(m=[l.map((e=>new Le(e[0],e[1])))],(e<i.x||t>r.x||n<i.y||o>r.y)&&(m=$h(m,i.x,i.y,r.x,r.y)))}for(const i of m){n.reset(i,.25*e);let r=0;r=n.length<=.5*e?1:Math.ceil(n.paddedLength/h)+1;for(let i=0;i<r;i++){const o=i/Math.max(r-1,1),s=n.lerp(o),a=s.x+yv,l=s.y+yv;_.push(a,l,e,0);const c=a-e,h=l-e,p=a+e,f=l+e;if(V=V&&this.isOffscreen(c,h,p,f),U=U||this.isInsideGrid(c,h,p,f),!t&&this.grid.hitTestCircle(a,l,e,d)&&(k=!0,!u))return{circles:[],offscreen:!1,collisionDetected:k,occluded:!1}}}}return{circles:!u&&k||!U?[]:_,offscreen:V,collisionDetected:k,occluded:M.occluded}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const t=[];let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const s of e){const e=new Le(s.x+yv,s.y+yv);i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y),t.push(e)}const s=this.grid.query(i,r,n,o).concat(this.ignoredGrid.query(i,r,n,o)),a={},l={};for(const e of s){const i=e.key;void 0===a[i.bucketInstanceId]&&(a[i.bucketInstanceId]={}),a[i.bucketInstanceId][i.featureIndex]||Pl(t,[new Le(e.x1,e.y1),new Le(e.x2,e.y1),new Le(e.x2,e.y2),new Le(e.x1,e.y2)])&&(a[i.bucketInstanceId][i.featureIndex]=!0,void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]=[]),l[i.bucketInstanceId].push(i.featureIndex))}return l}insertCollisionBox(e,t,i,r,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,n){const o=t?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,t,i,r,n,o,s){const a=[t,i,r,1];let l=!1;if(r||this.transform.pitch>0){if(se(a,a,e),this.fogState&&n&&"globe"!==s.name){const e=function(e,t,i,r,n,o){const s=[t,i,r];return Z(s,s,o.calculateFogTileMatrix(n)),ny(e,M(s),o.pitch,o._fov)}(this.fogState,t,i,r,n.toUnwrapped(),this.transform);l=e>.9}}else gv(a,a,e);const c=a[3];return{point:new Le((a[0]/c+1)/2*this.transform.width+yv,(-a[1]/c+1)/2*this.transform.height+yv),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/c*.5,1.5),signedDistanceFromCamera:c,occluded:o&&a[2]>c||l}}isOffscreen(e,t,i,r){return i<yv||e>=this.screenRightBoundary||r<yv||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=u([]);return f(e,e,[-100,-100,0]),e}}class OpacityState{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class JointOpacityState{constructor(e,t,i,r,n,o=!1){this.text=new OpacityState(e?e.text:null,t,i,n),this.icon=new OpacityState(e?e.icon:null,t,r,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class JointPlacement{constructor(e,t,i,r=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=r}}class CollisionCircleArray{constructor(){this.invProjMatrix=l(),this.viewportMatrix=l(),this.circles=[]}}class RetainedQueryData{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class CollisionGroups{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 xv(e,t,i,r,n){const{horizontalAlign:o,verticalAlign:s}=Ff(e),a=-(o-.5)*t,l=-(s-.5)*i,c=rm(e,r);return new Le(a+c[0]*n,l+c[1]*n)}function vv(e,t,i,r,n){const o=new Le(e,t);return i&&o._rotate(r?n:-n),o}class Placement{constructor(e,t,i,r,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new CollisionIndex(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new CollisionGroups(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(e,t,i,r,n=1){const o=i.getBucket(t),s=i.latestFeatureIndex;if(!o||!s||t.fqid!==o.layerIds[0])return;const a=o.layers[0].layout,l=o.layers[0].paint,c=i.collisionBoxArray,u=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),h=i.tileSize/Mn,d=i.tileID.toUnwrapped();this.transform.setProjection(o.projection);const f=(m=i.tileID,_=o.getProjection(),g=this.transform,_.name===this.projection?g.calculateProjMatrix(m.toUnwrapped()):Jx(g,_,m));var m,_,g;const y="map"===a.get("text-pitch-alignment"),x="map"===a.get("text-rotation-alignment");t.compileFilter(t.options);const v=t.dynamicFilter(),b=t.dynamicFilterNeedsFeature(),w=this.transform.calculatePixelsToTileUnitsMatrix(i),T=nv(f,i.tileID.canonical,y,x,this.transform,o.getProjection(),w);let E=null;const S=o.getProjection().createInversionMatrix(this.transform,i.tileID.canonical);if(y){const e=ov(f,i.tileID.canonical,y,x,this.transform,o.getProjection(),w);E=p([],this.transform.labelPlaneMatrix,e)}let A=null;v&&i.latestFeatureIndex&&(A={unwrappedTileID:d,dynamicFilter:v,dynamicFilterNeedsFeature:b}),this.retainedQueryData[o.bucketInstanceId]=new RetainedQueryData(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,i.tileID);const[I,C]=o.layers[0].layout.get("text-size-scale-range"),M=He(n,I,C),[D,P]=a.get("icon-size-scale-range"),L=He(n,D,P),R={bucket:o,layout:a,paint:l,posMatrix:f,invMatrix:S,mercatorCenter:[Qa(this.transform.center.lng),el(this.transform.center.lat)],textLabelPlaneMatrix:T,labelToScreenMatrix:E,clippingData:A,scale:u,textPixelRatio:h,holdingForFade:i.holdingForFade(),collisionBoxArray:c,partiallyEvaluatedTextSize:Nf(o.textSizeData,this.transform.zoom,M),partiallyEvaluatedIconSize:Nf(o.iconSizeData,this.transform.zoom,L),collisionGroup:this.collisionGroups.get(o.sourceID),latestFeatureIndex:i.latestFeatureIndex};if(r)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:R})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:R})}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v){const{textOffset0:b,textOffset1:w,crossTileID:T}=f,E=[b,w],S=xv(e,o,s,E,a),A=this.collisionIndex.placeCollisionBox(_,a,t,i,r,n,vv(S.x,S.y,l,c,this.transform.angle),p,u,h,d.predicate);if(y){const e=_.getSymbolInstanceIconSize(v,this.transform.zoom,f.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(_,e,y,i,r,n,vv(S.x,S.y,l,c,this.transform.angle),p,u,h,d.predicate).box.length)return}if(A.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:o,height:s,anchor:e,textScale:a,prevAnchor:t},this.markUsedJustification(_,e,f,g),_.allowVerticalPlacement&&(this.markUsedOrientation(_,g,f),this.placedOrientations[T]=g),{shift:S,placedGlyphBoxes:A}}}placeLayerBucketPart(e,t,i,r,n=1){const{bucket:o,layout:s,paint:a,posMatrix:l,textLabelPlaneMatrix:c,labelToScreenMatrix:u,clippingData:h,textPixelRatio:p,mercatorCenter:f,invMatrix:m,holdingForFade:_,collisionBoxArray:g,partiallyEvaluatedTextSize:y,partiallyEvaluatedIconSize:x,collisionGroup:v,latestFeatureIndex:b}=e.parameters,w=s.get("text-optional"),T=s.get("icon-optional"),E=s.get("text-allow-overlap"),S=s.get("icon-allow-overlap"),A="map"===s.get("text-rotation-alignment"),I="map"===s.get("icon-rotation-alignment"),C="map"===s.get("text-pitch-alignment"),M=a.get("symbol-z-offset"),D="sea"===s.get("symbol-elevation-reference"),P=s.get("symbol-placement"),[L,R]=s.get("text-size-scale-range"),[z,F]=s.get("icon-size-scale-range"),O=He(n,L,R),B=He(n,z,F),k=s.get("text-variable-anchor"),U=A&&"point"!==P,V=I&&"point"!==P,N=k&&o.hasTextData(),j=o.hasIconTextFit()&&N&&o.hasIconData();this.transform.setProjection(o.projection);const G=N||U,H=V||j;let q=E&&(S||!o.hasIconData()||T),$=S&&(E||!o.hasTextData()||w);const Z=!M.isConstant();!o.collisionArrays&&g&&o.deserializeCollisionBoxes(g),i&&r&&o.updateCollisionDebugBuffers(this.transform.zoom,g,O,B);const W=(e,r,n)=>{const{crossTileID:a,numVerticalGlyphVertices:d}=e;let g=null;if(h&&h.dynamicFilterNeedsFeature||Z){const t=this.retainedQueryData[o.bucketInstanceId];g=b.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0});const i=g.properties?g.properties.worldview:null;if(o.localizable&&o.worldview&&"string"==typeof i)if("all"===i)g.properties.$localized=!0;else{if(!i.split(",").includes(o.worldview))return;g.properties.$localized=!0,g.properties.worldview=o.worldview}}if(h&&!(0,h.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:o.worldview},g,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new Le(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[a]=new JointPlacement(!1,!1,!1,!0),void t.add(a);const I=M.evaluate(g,{});if(t.has(a))return;if(_)return void(this.placements[a]=new JointPlacement(!1,!1,!1));let P=!1,L=!1,R=!0,z=!1,F=!1,O=null,B={box:null,offscreen:null,occluded:null},U={box:null},V=null,N=null,j=null,W=0,X=0,Y=0;n.textFeatureIndex?W=n.textFeatureIndex:e.useRuntimeCollisionCircles&&(W=e.featureIndex),n.verticalTextFeatureIndex&&(X=n.verticalTextFeatureIndex);const K=o.elevationFeatures?o.elevationFeatures[e.elevationFeatureIndex]:void 0,J=t=>{t.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const i=this.transform.elevation;t.elevation=D?I:I+Elevation.getAtTileOffset(t.tileID,new Le(t.tileAnchorX,t.tileAnchorY),i,K),t.elevation+=e.zOffset},Q=n.textBox;if(Q){J(Q);const t=t=>{let i=zf.horizontal;if(o.allowVerticalPlacement&&!t&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[a];t&&(this.placedOrientations[a]=t,i=t,this.markUsedOrientation(o,i,e))}return i},i=(e,t)=>{if(o.allowVerticalPlacement&&d>0&&n.verticalTextBox){for(const i of o.writingModes)if(i===zf.vertical?(B=t(),U=B):B=e(),B&&B.box&&B.box.length)break}else B=e()};if(k){let s=k;if(this.prevPlacement&&this.prevPlacement.variableOffsets[a]){const e=this.prevPlacement.variableOffsets[a];s.indexOf(e.anchor)>0&&(s=s.filter((t=>t!==e.anchor)),s.unshift(e.anchor))}const c=(t,i,n)=>{const a=o.getSymbolInstanceTextSize(y,e,this.transform.zoom,r),c=(t.x2-t.x1)*a+2*t.padding,u=(t.y2-t.y1)*a+2*t.padding,h=e.hasIconTextFit&&!S?i:null;h&&J(h);let d={box:[],offscreen:!1,occluded:!1};const _=E?2*s.length:s.length;for(let i=0;i<_;++i){const _=this.attemptAnchorPlacement(s[i%s.length],t,f,m,G,c,u,a,A,C,p,l,v,i>=s.length,e,r,o,n,h,y,x);if(_&&(d=_.placedGlyphBoxes,d&&d.box&&d.box.length)){P=!0,O=_.shift;break}}return d};i((()=>c(Q,n.iconBox,zf.horizontal)),(()=>{const e=n.verticalTextBox;return e&&J(e),o.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&d>0&&e?c(e,n.verticalIconBox,zf.vertical):{box:null,offscreen:null,occluded:null}})),B&&(P=B.box,R=B.offscreen,z=B.occluded);const u=t(!(!B||!B.box));if(!P&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[a];t&&(this.variableOffsets[a]=t,this.markUsedJustification(o,t.anchor,e,u))}}else{const s=(t,i)=>{const n=o.getSymbolInstanceTextSize(y,e,this.transform.zoom,r),s=this.collisionIndex.placeCollisionBox(o,n,t,f,m,G,new Le(0,0),E,p,l,v.predicate);return s&&s.box&&s.box.length&&(this.markUsedOrientation(o,i,e),this.placedOrientations[a]=i),s};i((()=>s(Q,zf.horizontal)),(()=>{const e=n.verticalTextBox;return o.allowVerticalPlacement&&d>0&&e?(J(e),s(e,zf.vertical)):{box:null,offscreen:null,occluded:null}})),t(!!(B&&B.box&&B.box.length))}}if(V=B,P=V&&V.box&&V.box.length>0,R=V&&V.offscreen,z=V&&V.occluded,e.useRuntimeCollisionCircles){const t=e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex,r=o.text.placedSymbolArray.get(t),n=Vf(o.textSizeData,y,r),a=s.get("text-padding");N=this.collisionIndex.placeCollisionCircles(o,E,r,t,o.lineVertexArray,o.glyphOffsetArray,n,l,c,u,i,C,v.predicate,e.collisionCircleDiameter*n/24,a,this.retainedQueryData[o.bucketInstanceId].tileID),P=E||N.circles.length>0&&!N.collisionDetected,R=R&&N.offscreen,z=N.occluded}if(n.iconFeatureIndex&&(Y=n.iconFeatureIndex),n.iconBox){const t=t=>{J(t);const i=e.hasIconTextFit&&O?vv(O.x,O.y,A,C,this.transform.angle):new Le(0,0),r=o.getSymbolInstanceIconSize(x,this.transform.zoom,e.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,r,t,f,m,H,i,S,p,l,v.predicate)};U&&U.box&&U.box.length&&n.verticalIconBox?(j=t(n.verticalIconBox),L=j.box.length>0):(j=t(n.iconBox),L=j.box.length>0),R=R&&j.offscreen,F=j.occluded}const ee=w||0===e.numHorizontalGlyphVertices&&0===d,te=T||0===e.numIconVertices;if(ee||te?te?ee||(L=L&&P):P=L&&P:L=P=L&&P,P&&V&&V.box&&this.collisionIndex.insertCollisionBox(V.box,s.get("text-ignore-placement"),o.bucketInstanceId,U&&U.box&&X?X:W,v.ID),L&&j&&this.collisionIndex.insertCollisionBox(j.box,s.get("icon-ignore-placement"),o.bucketInstanceId,Y,v.ID),N&&(P&&this.collisionIndex.insertCollisionCircles(N.circles,s.get("text-ignore-placement"),o.bucketInstanceId,W,v.ID),i)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new CollisionCircleArray);for(let e=0;e<N.circles.length;e+=4)t.circles.push(N.circles[e+0]),t.circles.push(N.circles[e+1]),t.circles.push(N.circles[e+2]),t.circles.push(N.collisionDetected?1:0)}const ie="globe"!==o.projection.name;q=q&&(ie||!z),$=$&&(ie||!F),this.placements[a]=new JointPlacement(P||q,L||$,R||o.justReloaded),t.add(a)},X=this.retainedQueryData[o.bucketInstanceId].tileID;if("offset"===o.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(o,X),"road"===o.elevationType&&o.updateRoadElevation(X.canonical),o.updateZOffset(),o.sortFeaturesByY){const e=o.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const i=e[t];W(o.symbolInstances.get(i),i,o.collisionArrays[i])}o.hasAnyZOffset&&st(`${o.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(o.hasAnyZOffset){const e=o.getSortedIndexesByZOffset();for(let t=0;t<e.length;++t){const i=e[t];W(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)W(o.symbolInstances.get(t),t,o.collisionArrays[t]);if(i&&o.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[o.bucketInstanceId];d(e.invProjMatrix,l),e.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(e,t,i,r){const{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:a,crossTileID:l}=i,c=function(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"}(t),u=r===zf.vertical?a:"left"===c?n:"center"===c?o:"right"===c?s:-1;n>=0&&(e.text.placedSymbolArray.get(n).crossTileID=u>=0&&n!==u?0:l),o>=0&&(e.text.placedSymbolArray.get(o).crossTileID=u>=0&&o!==u?0:l),s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=u>=0&&s!==u?0:l),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=u>=0&&a!==u?0:l)}markUsedOrientation(e,t,i){const r=t===zf.horizontal||t===zf.horizontalOnly?t:0,n=t===zf.vertical?t:0,{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l}=i,c=e.text.placedSymbolArray;o>=0&&(c.get(o).placedOrientation=r),s>=0&&(c.get(s).placedOrientation=r),a>=0&&(c.get(a).placedOrientation=r),l>=0&&(c.get(l).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 r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new JointOpacityState(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new JointOpacityState(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new JointOpacityState(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[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,r){r&&(this.lastReplacementSourceUpdateTime=r.updateTime);const n=new Set;for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,n,o,o.collisionBoxArray,i,r,o.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,o.tileID),"road"===t.elevationType&&t.updateRoadElevation(o.tileID.canonical),t.updateZOffset())}}updateBucketOpacities(e,t,i,r,n,o,s,a){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const l=e.layers[0].layout,c=e.layers[0].paint,u=!!e.layers[0].dynamicFilter(),h=new JointOpacityState(null,0,!1,!1,!0),d=l.get("text-allow-overlap"),p=l.get("icon-allow-overlap"),f=l.get("text-variable-anchor"),m="map"===l.get("text-rotation-alignment"),_="map"===l.get("text-pitch-alignment"),g=c.get("symbol-z-offset"),y="sea"===l.get("symbol-elevation-reference"),x=!g.isConstant(),v=new JointOpacityState(null,0,d&&(p||!e.hasIconData()||l.get("icon-optional")),p&&(d||!e.hasTextData()||l.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const b=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i)};let w=0;o&&e.updateReplacement(s,o);for(let r=0;r<e.symbolInstances.length;r++){const l=e.symbolInstances.get(r),{numHorizontalGlyphVertices:c,numVerticalGlyphVertices:d,crossTileID:p,numIconVertices:T,tileAnchorX:E,tileAnchorY:S}=l;let A=null;const I=this.retainedQueryData[e.bucketInstanceId];x&&l&&I&&(A=i.latestFeatureIndex.loadFeature({featureIndex:l.featureIndex,bucketIndex:I.bucketIndex,sourceLayerIndex:I.sourceLayerIndex,layoutVertexArrayOffset:0}));const C=g.evaluate(A,{}),M=t.has(p);let D=this.opacities[p];M?D=h:D||(D=v,this.opacities[p]=D),t.add(p);const P=c>0||d>0,L=T>0,R=this.placedOrientations[p],z=R===zf.vertical,F=R===zf.horizontal||R===zf.horizontalOnly;!P&&!L||D.isHidden()||w++;let O=!1;if((P||L)&&o)for(const t of e.activeReplacements)if(!rh(t,n,2,a)&&!(t.min.x>E||E>t.max.x||t.min.y>S||S>t.max.y)&&(O=ph(dh(E,S,s.canonical,t.footprintTileId.canonical),t.footprint),O))break;if(P){const t=O?Dv:Mv(D.text);b(e.text,c,z?Dv:t),b(e.text,d,F?Dv:t);const i=D.text.isHidden(),{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=l,a=e.text.placedSymbolArray,u=i||z?1:0;r>=0&&(a.get(r).hidden=u),n>=0&&(a.get(n).hidden=u),o>=0&&(a.get(o).hidden=u),s>=0&&(a.get(s).hidden=i||F?1:0);const h=this.variableOffsets[p];h&&this.markUsedJustification(e,h.anchor,l,R);const f=this.placedOrientations[p];f&&(this.markUsedJustification(e,"left",l,f),this.markUsedOrientation(e,f,l))}if(L){const t=O?Dv:Mv(D.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:r}=l,n=e.icon.placedSymbolArray,o=D.icon.isHidden()?1:0;i>=0&&(b(e.icon,T,z?Dv:t),n.get(i).hidden=o),r>=0&&(b(e.icon,l.numVerticalIconVertices,F?Dv:t),n.get(r).hidden=o)}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const t=e.collisionArrays[r];if(t){let i=new Le(0,0),r=!0;if(t.textBox||t.verticalTextBox){if(f){const e=this.variableOffsets[p];e?(i=xv(e.anchor,e.width,e.height,e.textOffset,e.textScale),m&&i._rotate(_?this.transform.angle:-this.transform.angle)):r=!1}u&&(r=!D.clipped),t.textBox&&bv(e.textCollisionBox.collisionVertexArray,D.text.placed,!r||z,C,y,i.x,i.y),t.verticalTextBox&&bv(e.textCollisionBox.collisionVertexArray,D.text.placed,!r||F,C,y,i.x,i.y)}const n=r&&Boolean(!F&&t.verticalIconBox);t.iconBox&&bv(e.iconCollisionBox.collisionVertexArray,D.icon.placed,n,C,y,l.hasIconTextFit?i.x:0,l.hasIconTextFit?i.y:0),t.verticalIconBox&&bv(e.iconCollisionBox.collisionVertexArray,D.icon.placed,!n,C,y,l.hasIconTextFit?i.x:0,l.hasIconTextFit?i.y:0)}}}if(e.fullyClipped=0===w,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.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 this.stale||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 bv(e,t,i,r,n,o,s){e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0)}const wv=Math.pow(2,25),Tv=Math.pow(2,24),Ev=Math.pow(2,17),Sv=Math.pow(2,16),Av=Math.pow(2,9),Iv=Math.pow(2,8),Cv=Math.pow(2,1);function Mv(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*wv+t*Tv+i*Ev+t*Sv+i*Av+t*Iv+i*Cv+t}const Dv=0;class LayerPlacement{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,r,n,o){const s=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(s,r,e[this._currentTileIndex],this._sortAcrossTiles,o),this._currentTileIndex++,n())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,o),this._currentPartIndex++,n())return!0}return!1}}class PauseablePlacement{constructor(e,t,i,r,n,o,s,a,l){this.placement=new Placement(e,n,o,s,a,l),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i,r,n){const o=Wt.now(),s=()=>{const e=Wt.now()-o;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const o=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===o.type&&"none"!==o.visibility&&(!o.minzoom||o.minzoom<=a)&&(!o.maxzoom||o.maxzoom>a)){const e=o,t=e.layout.get("symbol-z-elevate"),a=void 0!==e.layout.get("symbol-sort-key").constantOr(1),l=e.layout.get("symbol-z-order"),c="viewport-y"===l||"auto"===l&&!("viewport-y"!==l&&a),u=e.layout.get("text-allow-overlap")||e.layout.get("icon-allow-overlap")||e.layout.get("text-ignore-placement")||e.layout.get("icon-ignore-placement"),h=c&&u,d=this._inProgressLayer=this._inProgressLayer||new LayerPlacement(e),p=aa(o.source,o.scope);if(d.continuePlacement(t||h?r[p]:i[p],this.placement,this._showCollisionBoxes,o,s,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Pv=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class KDBush{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=Pv[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new KDBush(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){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=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=Pv.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Lv(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)Ov(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=h+u>>1,p=n[2*d],f=n[2*d+1];Ov(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function Lv(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;Rv(e,t,s,r,n,o),Lv(e,t,i,r,s-1,1-o),Lv(e,t,i,s+1,n,1-o)}function Rv(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);Rv(e,t,i,Math.max(r,Math.floor(i-a*c/s+u)),Math.min(n,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=r,l=n;for(zv(e,t,r,i),t[2*n+o]>s&&zv(e,t,r,n);a<l;){for(zv(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--}t[2*r+o]===s?zv(e,t,r,l):(l++,zv(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function zv(e,t,i,r){Fv(e,i,r),Fv(t,2*i,2*r),Fv(t,2*i+1,2*r+1)}function Fv(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function Ov(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}const Bv=512/Mn/2;class TileLayerIndex{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this.index=new KDBush(t.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=e.canonical.x*Mn,n=e.canonical.y*Mn;for(let e=0;e<t.length;e++){const{key:i,crossTileID:o,tileAnchorX:s,tileAnchorY:a}=t.get(e),l=Math.floor((r+s)*Bv),c=Math.floor((n+a)*Bv);this.index.add(l,c),this.keys.push(i),this.crossTileIDs.push(o)}this.index.finish()}findMatches(e,t,i){const r=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z),n=Bv/Math.pow(2,t.canonical.z-this.tileID.canonical.z),o=t.canonical.x*Mn,s=t.canonical.y*Mn;for(let t=0;t<e.length;t++){const a=e.get(t);if(a.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:u}=a,h=Math.floor((o+c)*n),d=Math.floor((s+u)*n),p=this.index.range(h-r,d-r,h+r,d+r).sort(((e,t)=>e-t));for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!i.has(t)){i.add(t),a.crossTileID=t;break}}}}}class CrossTileIDs{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class CrossTileSymbolLayerIndex{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],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}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 r=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=i.generate(),r.add(n.crossTileID))}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new TileLayerIndex(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 r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0)}return t}}class CrossTileSymbolIndex{constructor(){this.layerIndexes={},this.crossTileIDs=new CrossTileIDs,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i,r){let n=this.layerIndexes[e.fqid];void 0===n&&(n=this.layerIndexes[e.fqid]=new CrossTileSymbolLayerIndex);let o=!1;const s={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const kv=771;class ColorMode{constructor(e,t,i,r){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=r}}ColorMode.Replace=[1,0,1,0],ColorMode.disabled=new ColorMode(ColorMode.Replace,Color.transparent,[!1,!1,!1,!1]),ColorMode.unblended=new ColorMode(ColorMode.Replace,Color.transparent,[!0,!0,!0,!0]),ColorMode.alphaBlended=new ColorMode([1,kv,1,kv],Color.transparent,[!0,!0,!0,!0]),ColorMode.alphaBlendedNonPremultiplied=new ColorMode([770,kv,770,kv],Color.transparent,[!0,!0,!0,!0]),ColorMode.multiply=new ColorMode([774,0,774,0],Color.transparent,[!0,!0,!0,!0]),ColorMode.additive=new ColorMode([1,1,1,1],Color.transparent,[!0,!0,!0,!0]);class DepthMode{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}DepthMode.ReadOnly=!1,DepthMode.ReadWrite=!0,DepthMode.disabled=new DepthMode(519,DepthMode.ReadOnly,[0,1]);const Uv=7680;class StencilMode{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}StencilMode.disabled=new StencilMode({func:519,mask:0},0,0,Uv,Uv,Uv);const Vv=1029,Nv=2305;class CullFaceMode{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}function jv(e,t){const i=gt(e,3);T(e,t),yt(e,3,i)}function Gv(e,t){const i=le([]);return he(i,i,-t),ce(i,i,-e),i}function Hv(e,t){const i=[e[0],e[1],0],r=[t[0],t[1],0];if(M(i)>=1e-15){const e=G([],i);B(r,e,H(r,e)),t[0]=r[0],t[1]=r[1]}const n=q([],t,e);if(te(n)<1e-15)return null;const o=Math.atan2(-n[1],n[0]);return Gv(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}CullFaceMode.disabled=new CullFaceMode(!1,Vv,Nv),CullFaceMode.backCCW=new CullFaceMode(!0,Vv,Nv),CullFaceMode.backCW=new CullFaceMode(!0,Vv,2304),CullFaceMode.frontCW=new CullFaceMode(!0,1028,2304),CullFaceMode.frontCCW=new CullFaceMode(!0,1028,Nv);class FreeCameraOptions{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(e){if(e){const t=e instanceof MercatorCoordinate?e:new MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=$e(t.x,0,1)),this._position=t}else this._position=null}lookAtPoint(e,t,i){if(this.orientation=null,!this.position)return;const r=this.position,n=i||(this._elevation?this._elevation.getAtPointOrZero(MercatorCoordinate.fromLngLat(e)):0),o=MercatorCoordinate.fromLngLat(e,n),s=[o.x-r.x,o.y-r.y,o.z-r.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=Hv(s,t)}setPitchBearing(e,t){this.orientation=Gv(Oe(e),Oe(-t))}}class FreeCamera{constructor(e,t){this._transform=u([]),this.orientation=t,this.position=e}get mercatorPosition(){const e=this.position;return new MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=gt(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var t;e&&yt(this._transform,3,[(t=e)[0],t[1],t[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||le([]),e&&jv(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=Gv(e,t),jv(this._transform,this._orientation)}forward(){const e=gt(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=gt(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=gt(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,t){const i=new Float64Array(16);return d(i,this.getWorldToCamera(e,t)),i}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,t,i){const r=this.position;B(r,r,-e);const n=new Float64Array(16);return x(n,[i,i,i]),f(n,n,r),n[10]*=t,n}getWorldToCamera(e,t){const i=new Float64Array(16),r=new Float64Array(4),n=this.position;var o,s;return(o=r)[0]=-(s=this._orientation)[0],o[1]=-s[1],o[2]=-s[2],o[3]=s[3],B(n,n,-e),T(i,r),f(i,i,n),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=t,i[9]*=t,i[10]*=t,i[11]*=t,i}getCameraToClipPerspective(e,t,i,r){const n=new Float64Array(16);return E(n,e,t,i,r),n}getCameraToClipOrthographic(e,t,i,r,n,o){const s=new Float64Array(16);return S(s,e,t,i,r,n,o),s}getDistanceToElevation(e,t=!1){const i=0===e?0:tl(e,t?rl(this.position[1]):this.position[1]),r=this.forward();return(i-this.position[2])/r[2]}clone(){return new FreeCamera([...this.position],[...this.orientation])}}const qv={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class EdgeInsets{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<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=r}interpolate(e,t,i){return null!=t.top&&null!=e.top&&(this.top=xr(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=xr(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=xr(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=xr(e.right,t.right,i)),this}getCenter(e,t){return new Le(He((this.left+e-this.right)/2,0,e),He((this.top+t-this.bottom)/2,0,t))}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new EdgeInsets(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const $v=15;class Transform{constructor(e,t,i,r,n,o,s){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=i??0,this._maxPitch=r??60,this.setProjection(o),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new EdgeInsets,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new FreeCamera,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 Transform(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._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<$v}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),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 We(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=wm(this.projectionOptions);const i=!Re(t,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=wm({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}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 tl(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new Le(this.width,this.height)}get bearing(){return $e(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const i=-e*Math.PI/180;var r;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(r=new t(4),t!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=r*l+o*a,e[1]=n*l+s*a,e[2]=r*-a+o*l,e[3]=n*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=He(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=Oe(e),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 e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let r=0,n=0;for(let o=0;o<t.length;o++){const s=new Le(t[o][0]*this.width,i+t[o][1]*(this.height-i)),a=e.pointCoordinate(s);if(!a)continue;const l=1/Math.hypot(a[0]-this._camera.position[0],a[1]-this._camera.position[1]);r+=a[3]*l,n+=l}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,r=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(o))}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,r=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)&&!r}computeZoomRelativeTo(e){const t=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[t.x,t.y,t.z]:[e.x,e.y,e.z];const r=M(J([],this._camera.position,i));return He(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let t=!1;if(e.orientation&&!((i=e.orientation)[0]===(r=this._camera.orientation)[0]&&i[1]===r[1]&&i[2]===r[2]&&i[3]===r[3])&&(t=this._setCameraOrientation(e.orientation)),e.position){const i=[e.position.x,e.position.y,e.position.z];K(i,this._camera.position)||(this._setCameraPosition(i),t=!0)}var i,r;t&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,t=new FreeCameraOptions;return t.position=new MercatorCoordinate(e[0],e[1],e[2]),t.orientation=this._camera.orientation,t._elevation=this.elevation,t._renderWorldCopies=this.renderWorldCopies,t}_setCameraOrientation(e){if(!function(e){var t=e[0],i=e[1],r=e[2],n=e[3];return Math.sqrt(t*t+i*i+r*r+n*n)}(e))return!1;me(e,e);const t=X([],[0,0,-1],e),i=X([],[0,-1,0],e);if(i[2]<0)return!1;const r=Hv(t,i);return!!r&&(this._camera.orientation=r,!0)}_setCameraPosition(e){const t=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;e[2]=He(e[2],r/i,r/t),this._camera.position=e}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(e){const t=[new UnwrappedTileID(0,e)];if(this.renderWorldCopies){const i=this.pointCoordinate(new Le(0,0)),r=this.pointCoordinate(new Le(this.width,0)),n=this.pointCoordinate(new Le(this.width,this.height)),o=this.pointCoordinate(new Le(0,this.height)),s=Math.floor(Math.min(i.x,r.x,n.x,o.x)),a=Math.floor(Math.max(i.x,r.x,n.x,o.x)),l=1;for(let i=s-l;i<=a+l;i++)0!==i&&t.push(new UnwrappedTileID(i,e))}return t}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(e,t,i,r){let n=[];const o=null!=i,s=!o;if(s&&this.zoom<t)return n;if(o&&0===i[0]&&0===i[1])return n;const a=new Set,l=(e,t,i,r,o)=>{const s=ec(t,e,i,r,o);a.has(s)||(n.push(new OverscaledTileID(e,t,i,r,o)),a.add(s))};for(let n=0;n<e.length;n++){const a=e[n];if(s&&a.canonical.z!==t)continue;if(o&&void 0!==r&&r>a.canonical.z)continue;const c=a.canonical,u=a.overscaledZ,h=a.wrap,d=1<<c.z,p=c.x+1<d,f=c.x>0,m=c.y+1<d,_=c.y>0,g=a.wrap-(f?0:1),y=a.wrap+(p?0:1),x=f?c.x-1:d-1,v=p?c.x+1:0;if(o)i[0]<0?(l(u,y,c.z,v,c.y),i[1]<0&&m&&(l(u,h,c.z,c.x,c.y+1),l(u,y,c.z,v,c.y+1)),i[1]>0&&_&&(l(u,h,c.z,c.x,c.y-1),l(u,y,c.z,v,c.y-1))):i[0]>0?(l(u,g,c.z,x,c.y),i[1]<0&&m&&(l(u,h,c.z,c.x,c.y+1),l(u,g,c.z,x,c.y+1)),i[1]>0&&_&&(l(u,h,c.z,c.x,c.y-1),l(u,g,c.z,x,c.y-1))):i[1]<0&&m?l(u,h,c.z,c.x,c.y+1):_&&l(u,h,c.z,c.x,c.y-1);else{const e=a.visibleQuadrants;1&e&&(l(u,g,c.z,x,c.y),_&&(l(u,h,c.z,c.x,c.y-1),l(u,g,c.z,x,c.y-1))),2&e&&(l(u,y,c.z,v,c.y),_&&(l(u,h,c.z,c.x,c.y-1),l(u,y,c.z,v,c.y-1))),4&e&&(l(u,g,c.z,x,c.y),m&&(l(u,h,c.z,c.x,c.y+1),l(u,g,c.z,x,c.y+1))),8&e&&(l(u,y,c.z,v,c.y),m&&(l(u,h,c.z,c.x,c.y+1),l(u,y,c.z,v,c.y+1)))}}const c=[];for(const e of n)n.some((t=>e.isChildOf(t)))||c.push(e);if(n=c.filter((i=>!e.some((e=>!!(i.overscaledZ<t&&e.isChildOf(i))||i.equals(e)||i.isChildOf(e))))),s){const e=1<<t,i="globe"===this.projection.name?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),r=[e*i.x,e*i.y],o=4,s=o*o;n=n.filter((e=>{const t=e.canonical.x+.5-r[0],i=e.canonical.y+.5-r[1];return t*t+i*i<s}))}return n}extendTileCoverToNearPlane(e,t,i){const r=[],n=new Set;for(const t of e)n.add(t.key);const o=(e,t,i,o,s)=>{const a=ec(t,e,i,o,s);n.has(a)||(r.push(new OverscaledTileID(e,t,i,o,s)),n.add(a))},s=e.reduce(((e,t)=>Math.max(e,t.overscaledZ)),i),a=1<<i,l=[new Le(0,0),new Le(Mn,0),new Le(Mn,Mn),new Le(0,Mn)],c=new Le(0,0),u=new Le(0,0),h=(e,t)=>{const r=Math.floor(e[0]),n=Math.floor(e[1]),h=(e[0]-r)*Mn,d=(e[1]-n)*Mn,p=Math.floor(t[0]),f=Math.floor(t[1]),m=(t[0]-p)*Mn,_=(t[1]-f)*Mn;for(let e=-1;e<=1;e++){const t=r+e;if(!(t<0||t>=a)){c.x=h-e*Mn,u.x=m-(t-p)*Mn;for(let e=-1;e<=1;e++){const r=n+e;c.y=d-e*Mn,u.y=_-(r-f)*Mn,Hl(c,u,l)&&o(s,0,i,t,r)}}}},d=t.points,p=d[3],f=d[2],m=this._projectToGround(p,d[7]),_=this._projectToGround(f,d[6]);return h(p,m),h(f,_),r}_projectToGround(e,t){return $(I(),e,t,e[2]/(e[2]-t[2]))}coveringTiles(e){let t=this.coveringZoomLevel(e);const i=t,r=this.elevation&&this.elevation.exaggeration(),n=r&&!e.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==e.minzoom&&t<e.minzoom)return[];void 0!==e.maxzoom&&t>e.maxzoom&&(t=e.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<<t,c=[l*s.x,l*s.y,0],u="globe"===this.projection.name,h=!u,d=Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,h),p=u?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=l*tl(1,this.center.lat),m=this._camera.position[2]/tl(1,this.center.lat),_=[l*p.x,l*p.y,m*(h?1:f)],g=u||r,y=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),x=this.isLODDisabled(!0)?t:0;let v;if(this._elevation&&e.isTerrainDEM)v=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();v=e?e.max:this._centerAltitude}else v=this._centerAltitude;const b=e.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,w=this.projection.isReprojectedInTileSpace?Gd(this):1,T=e=>{const t=1/4e4,i=new MercatorCoordinate(e.x+t,e.y,e.z),r=new MercatorCoordinate(e.x,e.y+t,e.z),n=e.toLngLat(),o=i.toLngLat(),s=r.toLngLat(),a=this.locationCoordinate(n),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=Math.hypot(l.x-a.x,l.y-a.y),h=Math.hypot(c.x-a.x,c.y-a.y);return Math.sqrt(u*h)*w/t},E=e=>{const t=v,i=b;return{aabb:cm(this,l,0,0,0,e,i,t,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:t,wrap:e,fullyVisible:!1}},S=[];let A=[];const I=t,C=e.reparseOverscaled?i:t,M=(m-this._centerAltitude)*f,D=e=>{if(!this._elevation||!e.tileID||!o)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=L(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)},L=e=>{if(e.zoom<x)return!0;if(e.zoom===I)return!1;if(null!=e.shouldSplit)return e.shouldSplit;const t=e.aabb.distanceX(_),r=e.aabb.distanceY(_);let s=M,l=1;if(u){s=e.aabb.distanceZ(_);const t=Math.pow(2,e.zoom),i=rl((e.y+1)/t),r=rl(e.y/t),n=Math.min(Math.max(a,i),r),o=Ja(n)/Ja(a);if(l=n===a?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,o/this._mercatorScaleRatio),this.zoom<=Ua&&e.zoom===I-1&&o>=.9)return!0}else if(n&&(s=e.aabb.distanceZ(_)*f),this.projection.isReprojectedInTileSpace&&i<=5){const t=Math.pow(2,e.zoom),i=T(new MercatorCoordinate((e.x+.5)/t,(e.y+.5)/t));l=i>.85?1:i}if(!o&&!u){const i=Math.sqrt(t*t+r*r+s*s);let n=(1<<I-e.zoom)*y*l;return n*=P(Math.max(s,M),i),i<n}let h=Number.MAX_VALUE,d=0;const p=e.aabb.getCorners(),m=[];for(const e of p){J(m,e,_),u||(n?m[2]*=f:m[2]=M);const t=H(m,this._camera.forward());t<h&&(h=t,d=Math.abs(m[2]))}let g=(1<<I-e.zoom)*y*l;if(g*=P(Math.max(d,M),h),h<g)return!0;const v=e.aabb.closestPoint(c);return v[0]===c[0]&&v[1]===c[1]};if(this.renderWorldCopies)for(let e=1;e<=3;e++)S.push(E(-e)),S.push(E(e));for(S.push(E(0));S.length>0;){const i=S.pop(),r=i.x,s=i.y;let a=i.fullyVisible;const h=()=>"globe"===this.projection.name&&(0===i.y||i.y===(1<<i.zoom)-1);if(!a){let e=g?i.aabb.intersects(d):i.aabb.intersectsFlat(d);if(0===e&&h()){const t=new CanonicalTileID(i.zoom,r,s);e=fc(this,l,t,!0).intersects(d)}if(0===e)continue;a=2===e}if(i.zoom!==I&&L(i))for(let e=0;e<4;e++){const t=(r<<1)+e%2,c=(s<<1)+(e>>1),h={aabb:o?i.aabb.quadrant(e):cm(this,l,i.zoom+1,t,c,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:t,y:c,wrap:i.wrap,fullyVisible:a,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};n&&!u&&(h.tileID=new OverscaledTileID(i.zoom+1===I?C:i.zoom+1,i.wrap,i.zoom+1,t,c),D(h)),S.push(h)}else{const n=i.zoom===I?C:i.zoom;if(e.minzoom&&e.minzoom>n)continue;let o=0;if(!a){let t=g?i.aabb.intersectsPrecise(d):i.aabb.intersectsPreciseFlat(d);if(0===t&&h()){const e=new CanonicalTileID(i.zoom,r,s);t=fc(this,l,e,!0).intersectsPrecise(d)}if(0===t)continue;if(e.calculateQuadrantVisibility)if(d.containsPoint(i.aabb.center))o=15;else for(let e=0;e<4;e++)0!==i.aabb.quadrant(e).intersects(d)&&(o|=1<<e)}const u=c[0]-(.5+r+(i.wrap<<i.zoom))*(1<<t-i.zoom),p=c[1]-.5-s,f=i.tileID?i.tileID:new OverscaledTileID(n,i.wrap,i.zoom,r,s);e.calculateQuadrantVisibility&&(f.visibleQuadrants=o),A.push({tileID:f,distanceSq:u*u+p*p})}}if(this.fogCullDistSq){const t=this.fogCullDistSq,i=this.horizonLineFromTop();A=A.filter((r=>{const n=[0,0,0,1],o=[Mn,Mn,0,1],s=this.calculateFogTileMatrix(r.tileID.toUnwrapped());se(n,n,s),se(o,o,s);const a=(c=n,u=o,(l=[])[0]=Math.min(c[0],u[0]),l[1]=Math.min(c[1],u[1]),l[2]=Math.min(c[2],u[2]),l[3]=Math.min(c[3],u[3]),l);var l,c,u;const h=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e[3]=Math.max(t[3],i[3]),e}([],n,o),d=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]<n&&(r+=(n-t[i])*(n-t[i]))}return r}(a,h);if(0===d)return!0;let p=!1;const f=this._elevation;if(f&&d>t&&0!==i){const t=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;e.isTerrainDEM||(n=f.getMinMaxForTile(r.tileID)),n||(n={min:b,max:v});const o=function(e){const t=Math.round((e+45+360)%360/90)%4;return ke[t]}(this.rotation),s=[o[0]*Mn,o[1]*Mn,n.max];Z(s,s,t),p=(1-s[1])*this.height*.5<i}return d<t||p}))}return A.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(e){const t=He(e.lat,-ol,ol),i=this.projection.project(e.lng,t);return new Le(i.x*this.worldSize,i.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/tl(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,t){let i,r;const n=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(t.x-n.x)/e,r=(t.y-n.y)/e}else{const e=this.pointCoordinate(t),o=this.pointCoordinate(n);i=e.x-o.x,r=e.y-o.y}const o=this.locationCoordinate(e);this.setLocation(new MercatorCoordinate(o.x-i,o.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(e,t){const i=t?tl(t,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new MercatorCoordinate(r.x,r.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const i=null!=t?t:this._centerAltitude,r=[e.x,e.y,0,1],n=[e.x,e.y,1,1];se(r,r,this.pixelMatrixInverse),se(n,n,this.pixelMatrixInverse);const o=n[3];ne(r,r,1/r[3]),ne(n,n,1/o);const s=r[2],a=n[2];return{p0:r,p1:n,t:s===a?0:(i-s)/(a-s)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return se(t,t,this.pixelMatrixInverse),se(i,i,this.pixelMatrixInverse),ne(t,t,1/t[3]),ne(i,i,1/i[3]),t[2]=tl(t[2],this._center.lat)*this.worldSize,i[2]=tl(i[2],this._center.lat)*this.worldSize,ne(t,t,1/this.worldSize),ne(i,i,1/this.worldSize),new Ray([t[0],t[1],t[2]],G([],J([],i,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:i,t:r}=e,n=tl(t[2],this._center.lat),o=tl(i[2],this._center.lat);return new MercatorCoordinate(xr(t[0],i[0],r)/this.worldSize,xr(t[1],i[1],r)/this.worldSize,xr(n,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e,t){if(!this.elevation)return this.pointCoordinate(e,t);let i=this.projection.pointCoordinate3D(this,e.x,e.y);if(i)return new MercatorCoordinate(i[0],i[1],i[2]);let r=0,n=this.horizonLineFromTop();if(e.y>n)return this.pointCoordinate(e,t);const o=.02*n,s=e.clone();for(let e=0;e<10&&n-r>o;e++){s.y=xr(r,n,.66);const e=this.projection.pointCoordinate3D(this,s.x,s.y);e?(n=s.y,i=e):r=s.y}return i?new MercatorCoordinate(i[0],i[1],i[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return!1;if(this.elevation||this.zoom>=Va)return!this.isPointAboveHorizon(e);const t=this.pointCoordinate(e);return t.y>=0&&t.y<=1}_coordinatePoint(e,t){const i=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,r=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return se(r,r,this.pixelMatrix),r[3]>0?new Le(r[0]/r[3],r[1]/r[3]):new Le(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:t}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,n=this.pointLocation3D(new Le(t,e)),o=this.pointLocation3D(new Le(r,e)),s=this.pointLocation3D(new Le(r,i)),a=this.pointLocation3D(new Le(t,i));let l=Math.min(n.lng,o.lng,s.lng,a.lng),c=Math.max(n.lng,o.lng,s.lng,a.lng),h=Math.min(n.lat,o.lat,s.lat,a.lat),d=Math.max(n.lat,o.lat,s.lat,a.lat);const f=Math.pow(2,-this.zoom)/16*270,m="globe"===this.projection.name?1:4,_=(e,t,i,r,n)=>{const o=(e+i)/2,s=(t+r)/2,a=new Le(o,s),{lng:u,lat:p}=this.pointLocation3D(a),g=Math.max(0,l-u,h-p,u-c,p-d);l=Math.min(l,u),c=Math.max(c,u),h=Math.min(h,p),d=Math.max(d,p),(n<m||g>f)&&(_(e,t,o,s,n+1),_(o,s,i,r,n+1))};if(_(t,e,r,e,1),_(r,e,r,i,1),_(r,i,t,i,1),_(t,i,t,e,1),"globe"===this.projection.name){const[e,t]=function(e){const t=u(new Float64Array(16));p(t,e.pixelMatrix,e.globeMatrix);const i=[0,Ha,0],r=[0,qa,0];return Z(i,i,t),Z(r,r,t),[i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!Rc(e,new LngLat(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Rc(e,new LngLat(e.center.lat,-90))]}(this);e?(d=90,c=180,l=-180):t&&(h=-90,c=180,l=-180)}return new LngLatBounds(new LngLat(l,h),new LngLat(c,d))}_getBoundsRectangular(e,t){const{top:i,left:r}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,s=new Le(r,i),a=new Le(o,i),l=new Le(o,n),c=new Le(r,n);let u=this.pointCoordinate(s,e),h=this.pointCoordinate(a,e);const d=this.pointCoordinate(l,t),p=this.pointCoordinate(c,t),f=(e,t)=>(t.y-e.y)/(t.x-e.x);return u.y>1&&h.y>=0?u=new MercatorCoordinate((1-p.y)/f(p,u)+p.x,1):u.y<0&&h.y<=1&&(u=new MercatorCoordinate(-p.y/f(p,u)+p.x,0)),h.y>1&&u.y>=0?h=new MercatorCoordinate((1-d.y)/f(d,h)+d.x,1):h.y<0&&u.y<=1&&(h=new MercatorCoordinate(-d.y/f(d,h)+d.x,0)),(new LngLatBounds).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(d))}_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(e){this.maxBounds=e,this.minLat=-ol,this.maxLat=ol,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=Qa(this.minLng)*this.tileSize,this.worldMaxX=Qa(this.maxLng)*this.tileSize,this.worldMinY=el(this.maxLat)*this.tileSize,this.worldMaxY=el(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(e){const t=e.key,i=this._distanceTileDataCache;if(i[t])return i[t];const r=e.canonical,n=1/this.height,o=this.cameraWorldSize,s=o/this.zoomScale(r.z),a=(r.x+Math.pow(2,r.z)*e.wrap)*s,l=r.y*s,c=this.point;c.x*=o/this.worldSize,c.y*=o/this.worldSize;const u=this.angle,h=Math.sin(-u),d=-Math.cos(-u);return i[t]={bearing:[h,d],center:[(c.x-a)*n,(c.y-l)*n],scale:s/Mn*n},i[t]}calculateFogTileMatrix(e){const t=e.key,i=this._fogTileMatrixCache;if(i[t])return i[t];const r=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,e);return p(r,this.worldToFogMatrix,r),i[t]=new Float32Array(r),i[t]}calculateProjMatrix(e,t=!1,i=!1){const r=e.key;let n;if(n=i?this._expandedProjMatrixCache:t?this._alignedProjMatrixCache:this._projMatrixCache,n[r])return n[r];const o=this.calculatePosMatrix(e,this.worldSize);let s;return s=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.expandedFarZProjMatrix:t?this.alignedProjMatrix:this.projMatrix,p(o,s,o),n[r]=new Float32Array(o),n[r]}calculatePixelsToTileUnitsMatrix(e){const t=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[t])return i[t];const r=function(e,t){const{scale:i}=e.tileTransform,r=i*Mn/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,i){var r=t[1],n=t[2],o=t[3],s=i[0],a=i[1];return e[0]=t[0]*s,e[1]=r*s,e[2]=n*a,e[3]=o*a,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[r,r])}(e,this);return i[t]=r,i[t]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const e=1/this.worldSize,t=x([],[e,e,e]);return p(t,t,this.globeMatrix),t}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const e=this._elevation;this._updateCameraState();const t=tl(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),r=this._camera.forward(),n=tl(1,this._center.lat);i[2]/=n,r[2]/=n,G(r,r);const o=e.raycast(i,r,e.exaggeration());if(o){const e=k([],i,r,o),t=new MercatorCoordinate(e[0],e[1],tl(e[2],rl(e[1]))),s=(t.z+M([t.x-i[0],t.y-i[1],t.z-i[2]*n]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(s),this._centerAltitude=t.toAltitude(),this._center=this.coordinateLocation(t),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(e=!1){if(!this._elevation)return;const t=this._elevation,i=tl(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),n=t.getAtPointOrZero(new MercatorCoordinate(...r)),o=this.pixelsPerMeter/this.worldSize*n,s=this._minimumHeightOverTerrain(),a=r[2]-o;if(a<=s)if(a<0||e){const e=this.locationCoordinate(this._center,this._centerAltitude),t=[r[0],r[1],e.z-r[2]],i=M(t);t[2]-=(s-a)/this._pixelsPerMercatorPixel;const n=M(t);if(0===n)return;B(t,t,i/n*this._pixelsPerMercatorPixel),this._camera.position=[r[0],r[1],e.z*this._pixelsPerMercatorPixel-t[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const t=this.center;return t.lat=He(t.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(t.lng=He(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:i,y:r}=this.point;let n=0,o=i,s=r;const a=this.width/2,l=this.height/2,c=this.worldMinY*this.scale,u=this.worldMaxY*this.scale;if(r-l<c&&(s=c+l),r+l>u&&(s=u-l),u-c<this.height&&(n=Math.max(n,this.height/(u-c)),s=(u+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,r=this.worldSize/2-(e+t)/2;o=(i+r+this.worldSize)%this.worldSize-r,o-a<e&&(o=e+a),o+a>t&&(o=t-a),t-e<this.width&&(n=Math.max(n,this.width/(t-e)),o=(t+e)/2)}o===i&&s===r||this._allowWorldUnderZoom||(this.center=this.unproject(new Le(o,s))),n&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(n)),this._constrainCamera(),this._unmodified=t,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 e=this.centerOffset,t="globe"===this.projection.name,r=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=tl(1,this.center.lat)/tl(1,45));const n=Hd(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,n),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 o="meters"===this.projection.zAxisUnit?r:1,s=this._camera.getWorldToCamera(this.worldSize,o);let a;const h=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(h[8]=2*-e.x/this.width,h[9]=2*e.y/this.height,this.isOrthographic){let t=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),i=t*this.aspect,r=-i,n=-t;i-=e.x,r-=e.x,t+=e.y,n+=e.y,a=this._camera.getCameraToClipOrthographic(r,i,n,t,this._nearZ,this._farZ),((e,t,i,r)=>{for(let n=0;n<16;n++)e[n]=xr(t[n],i[n],r)})(a,a,h,It(this.pitch>=$v?1:this.pitch/$v))}else a=h;const g=A([],h,s);let x=A([],a,s);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),t=u([]);f(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),p(t,t,jd(this)),f(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),p(x,x,t),p(g,g,t),this.inverseAdjustmentMatrix=function(e){const t=jd(e,!0);return i([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=m([],x,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=x,this.invProjMatrix=d(new Float64Array(16),this.projMatrix),t){const t=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);t[8]=2*-e.x/this.width,t[9]=2*e.y/this.height,this.expandedFarZProjMatrix=A([],t,s)}else this.expandedFarZProjMatrix=this.projMatrix;const v=d([],a);this.frustumCorners=FrustumCorners.fromInvProjectionMatrix(v,this.horizonLineFromTop(),this.height),this.cameraFrustum=Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!t);const b=new Float32Array(16);u(b),m(b,b,[1,-1,1]),_(b,b,this._pitch),y(b,b,this.angle);const w=E(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=c(w);const T=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;w[8]=2*-e.x/this.width,w[9]=2*(e.y+T)/this.height,this.skyboxMatrix=p(b,w,b);const S=this.point,I=S.x,C=S.y,M=this.width%2/2,D=this.height%2/2,P=Math.cos(this.angle),L=Math.sin(this.angle),R=I-Math.round(I)+P*M+L*D,z=C-Math.round(C)+P*D+L*M,F=new Float64Array(x);if(f(F,F,[R>.5?R-1:R,z>.5?z-1:z,0]),this.alignedProjMatrix=F,x=l(),m(x,x,[this.width/2,-this.height/2,1]),f(x,x,[1,-1,0]),this.labelPlaneMatrix=x,x=l(),m(x,x,[1,-1,1]),f(x,x,[-1,-1,0]),m(x,x,[2/this.width,2/this.height,1]),this.glCoordMatrix=x,this.pixelMatrix=p(new Float64Array(16),this.labelPlaneMatrix,g),this._calcFogMatrices(),this._distanceTileDataCache={},x=d(new Float64Array(16),this.pixelMatrix),!x)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=x,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return Ec(t,i,e.worldSize,r,n)}(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=Z(e,e,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=x;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,t=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,n=[e,e,t];B(n,n,r),B(i,i,-1),z(i,i,n);const o=l();f(o,o,i),m(o,o,n),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],r=e[2];let n=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(n=Math.min((t-i)/r,1)),this._camera.position=k([],this._camera.position,e,n),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),n=tl(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(Oe(this._maxPitch)),s=Math.max((e[2]-n)/Math.cos(i),o),a=this._zoomFromMercatorZ(s);k(e,e,t,s),this._pitch=He(i,Oe(this.minPitch),Oe(this.maxPitch)),this.angle=$e(r,-Math.PI,Math.PI),this._setZoom(He(a,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new MercatorCoordinate(e[0],e[1],e[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(e){let t=0,i=Va,r=0,n=1/0;for(;i-t>1e-6&&i>t;){const o=t+.5*(i-t),s=this.tileSize*Math.pow(2,o),a=this.getCameraToCenterDistance(this.projection,o,s),l=this.scaleZoom(a/(Math.max(0,e)*this.tileSize)),c=Math.abs(o-l);c<n&&(n=c,r=o),o<l?t=o:i=o}return r}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(st("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,t){const i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),n=Math.min(e.y,t.y),o=Math.max(e.y,t.y);if(n<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const s=[new Le(i,n),new Le(r,o),new Le(i,o),new Le(r,n)],a=this.renderWorldCopies?-3:0,l=this.renderWorldCopies?4:1;for(const e of s){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const i=this.rayIntersectionCoordinate(t);if(i.x<a||i.y<0||i.x>l||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+Be(this.fovAboveCenter)>88||this.anyCornerOffEdge(new Le(0,0),new Le(this.width,this.height))}zoomDeltaToMovement(e,t){const i=M(J([],this._camera.position,e)),r=this._zoomFromMercatorZ(i)+t;return i-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function([e,t,i],r){const n=[e,t,i,1];se(n,n,r);const o=n[3]=Math.max(n[3],1e-6);return n[0]/=o,n[1]/=o,n[2]/=o,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new Le(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new Le(0,e))}}getCameraToCenterDistance(e,t=this.zoom,i=this.worldSize){const r=Hd(e,t,this.width,this.height,1024),n=e.pixelSpaceConversion(this.center.lat,i,r);let o=.5/Math.tan(.5*this._fov)*this.height*n;return this.isOrthographic&&(o=xr(1,o,It(this.pitch>=$v?1:this.pitch/$v))),o}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&p(e,e,this.globeMatrix),e}getFrustum(e){return Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,"meters"===this.projection.zAxisUnit)}}const Zv=(e,t)=>{if(t>0&&e.terrain&&st("Cutoff is currently disabled on terrain"),t<=0||e.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const i=e.transform,r=Math.max(Math.abs(i._zoom-(e.minCutoffZoom-1)),1),n=i.isLODDisabled(!1)?qe(60,45,i.pitch):qe(30,15,i.pitch),o=i._farZ-i._nearZ,s=t*i.height,a=((1-(l=n))*i.cameraToCenterDistance+l*(i._farZ+s))*r;var l;return{shouldRenderCutoff:n<1,uniformValues:{u_cutoff_params:[i._nearZ,i._farZ,(a-i._nearZ)/o,(a-s-i._nearZ)/o]}}},Wv=2048;class ShadowReceiver{constructor(e,t){this.aabb=e,this.lastCascade=t}}class ShadowReceivers{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 ShadowReceiver(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(e,t,i){const r=Aabb.fromPoints(e.points);let n=0;for(const e in this.receivers){const o=this.receivers[e];if(!o)continue;if(!r.intersectsAabb(o.aabb))continue;o.aabb.min=r.closestPoint(o.aabb.min),o.aabb.max=r.closestPoint(o.aabb.max);const s=o.aabb.getCorners();for(let e=0;e<i.length;e++){let r=!0;for(const n of s){const o=[n[0]*t,n[1]*t,n[2]];if(Z(o,o,i[e].matrix),o[0]<-1||o[0]>1||o[1]<-1||o[1]>1){r=!1;break}}if(o.lastCascade=e,n=Math.max(n,e),r)break}}return n+1}}class ShadowRenderer{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new ShadowReceivers,this._depthMode=new DepthMode(e.context.gl.LEQUAL,DepthMode.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(e,t){const i=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!t||!t.properties)return;const r=t.properties.get("shadow-intensity");if(!t.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=i.style.order.reduce(((t,r)=>{const n=i.style._mergedLayers[r];return t+(n.hasShadowPass()&&!n.isHidden(e.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const n=i.context,o=Wv,s=Wv;if(0===this._cascades.length||Wv!==this._cascades[0].texture.size[0]){this._cascades=[];for(let e=0;e<2;++e){const e=i._shadowMapDebug,t=n.gl,r=n.createFramebuffer(o,s,e?1:0,"texture"),a=new Texture(n,{width:o,height:s,data:null},t.DEPTH_COMPONENT16);if(r.depthAttachment.set(a.texture),e){const e=new Texture(n,{width:o,height:s,data:null},t.RGBA8);r.colorAttachment0.set(e.texture)}this._cascades.push({framebuffer:r,texture:a,matrix:[],far:0,boundingSphereRadius:0,frustum:new Frustum,scale:0})}}this.shadowDirection=Yv(t);let a=0;if(e.elevation){const t=e.elevation,i=[1e4,-1e4];t.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]&&(a=(i[1]-i[0])*t.exaggeration())}const l=1.5*e.cameraToCenterDistance,c=3*l,u=new Float64Array(16);for(let t=0;t<this._cascades.length;++t){const i=this._cascades[t];let r=e.height/50,n=1;0===t?n=l:(r=l,n=c);const[o,s]=Jv(e,this.shadowDirection,r,n,Wv,a);i.scale=e.scale,i.matrix=o,i.boundingSphereRadius=s,d(u,i.matrix),i.frustum=Frustum.fromInvProjectionMatrix(u,1,0,!0),i.far=n}const h=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[h].far,this._cascades[h].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=Wv,this._uniformValues.u_shadowmap_0=qv.ShadowMap0,this._uniformValues.u_shadowmap_1=qv.ShadowMap0+1,this._groundShadowTiles=i.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const p=i.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(p){const i=p.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(e,t){if(!this.enabled)return;const i=this.painter,r=i.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(i.transform.getFrustum(0),i.transform.worldSize,this._cascades),r.viewport.set([0,0,Wv,Wv]);for(let n=0;n<this._numCascadesToRender;++n){i.currentShadowCascade=n,r.bindFramebuffer.set(this._cascades[n].framebuffer.framebuffer),r.clear({color:Color.white,depth:1});for(const r of e.order){const n=e._mergedLayers[r];if(!n.hasShadowPass()||n.isHidden(i.transform.zoom))continue;const o=e.getLayerSourceCache(n),s=o?t[o.id]:void 0;("model"===n.type||s&&s.length)&&i.renderLayer(i,o,n,s)}}i.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;const e=this.painter,t=e.style,i=e.context,r=i.gl,n=t.directionalLight,o=t.ambientLight;if(!n||!o)return;const s=[],a=Zv(e,e.longestCutoffRange);a.shouldRenderCutoff&&s.push("RENDER_CUTOFF"),s.push("RENDER_SHADOWS","DEPTH_TEXTURE"),this.useNormalOffset&&s.push("NORMAL_OFFSET");const l=Kv(t,n,o),c=new DepthMode(r.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D),u=new StencilMode({func:r.EQUAL,mask:255},0,255,r.KEEP,r.KEEP,r.KEEP);for(const t of this._groundShadowTiles){const n=t.toUnwrapped(),o=e.isTileAffectedByFog(t),h=e.getOrCreateProgram("groundShadow",{defines:s,overrideFog:o});this.setupShadows(n,h),e.uploadCommonUniforms(i,h,n,null,a);const d={u_matrix:e.transform.calculateProjMatrix(n),u_ground_shadow_factor:l};h.draw(e,r.TRIANGLES,c,u,ColorMode.multiply,CullFaceMode.disabled,d,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,null,e.transform.zoom,null,null)}}getShadowPassColorMode(){return this.painter._shadowMapDebug?ColorMode.unblended:ColorMode.disabled}getShadowPassDepthMode(){return this._depthMode}getShadowCastingLayerCount(){return this._shadowLayerCount}calculateShadowPassMatrixFromTile(e){const t=this.painter.transform,i=t.calculatePosMatrix(e,t.worldSize);return p(i,this._cascades[this.painter.currentShadowCascade].matrix,i),Float32Array.from(i)}calculateShadowPassMatrixFromMatrix(e){const t=c(e);return p(t,this._cascades[this.painter.currentShadowCascade].matrix,e),t}setupShadows(e,t,i){if(!this.enabled)return;const r=this.painter.transform,n=this.painter.context,o=n.gl,s=this._uniformValues,a=new Float64Array(16),l=r.calculatePosMatrix(e,r.worldSize);for(let e=0;e<this._cascades.length;e++)p(a,this._cascades[e].matrix,l),s[0===e?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(a),n.activeTexture.set(o.TEXTURE0+qv.ShadowMap0+e),this._cascades[e].texture.bindExtraParam(o.LINEAR,o.LINEAR,o.CLAMP_TO_EDGE,o.CLAMP_TO_EDGE,o.GREATER);if(this.useNormalOffset=!!i,this.useNormalOffset){const t=cl(e.canonical),n=2/r.tileSize*Mn/Wv,o=n*this._cascades[0].boundingSphereRadius,a=n*this._cascades[this._cascades.length-1].boundingSphereRadius,l=("vector-tile"===i?1:3)*function(e,t,i,r,n){const o=He((e-22)/-22,0,1);return.125*(1-o)+4*o}(r.zoom);s.u_shadow_normal_offset=[t,o*l,a*l],s.u_shadow_bias=[1e-4,.0012,.012]}else s.u_shadow_bias=[36e-5,.0012,.012];t.setShadowUniformValues(n,s)}setupShadowsFromMatrix(e,t,i=!1){if(!this.enabled)return;const r=this.painter.context,n=r.gl,o=this._uniformValues,s=new Float64Array(16);for(let t=0;t<2;t++)p(s,this._cascades[t].matrix,e),o[0===t?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(s),r.activeTexture.set(n.TEXTURE0+qv.ShadowMap0+t),this._cascades[t].texture.bindExtraParam(n.LINEAR,n.LINEAR,n.CLAMP_TO_EDGE,n.CLAMP_TO_EDGE,n.GREATER);this.useNormalOffset=i,i?(o.u_shadow_normal_offset=[1,3,3],o.u_shadow_bias=[6e-5,.0012,.012]):o.u_shadow_bias=[36e-5,.0012,.012],t.setShadowUniformValues(r,o)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(e,t,i,r){if(r[2]>=0)return{};const n=function(e,t,i){const r=i/(1<<e.canonical.z);return new Aabb([e.canonical.x*r+e.wrap*i,e.canonical.y*r+e.wrap*i,0],[(e.canonical.x+1)*r+e.wrap*i,(e.canonical.y+1)*r+e.wrap*i,t])}(e,t,i).getCorners(),o=t/-r[2];r[0]<0?(L(n[0],n[0],[r[0]*o,0,0]),L(n[3],n[3],[r[0]*o,0,0])):r[0]>0&&(L(n[1],n[1],[r[0]*o,0,0]),L(n[2],n[2],[r[0]*o,0,0])),r[1]<0?(L(n[0],n[0],[0,r[1]*o,0]),L(n[1],n[1],[0,r[1]*o,0])):r[1]>0&&(L(n[2],n[2],[0,r[1]*o,0]),L(n[3],n[3],[0,r[1]*o,0]));const s={};return s.vertices=n,s.planes=[Xv(n[1],n[0],n[4]),Xv(n[2],n[1],n[5]),Xv(n[3],n[2],n[6]),Xv(n[0],n[3],n[7])],s}addShadowReceiver(e,t,i){this._receivers.add(e,Aabb.fromTileIdAndHeight(e,t,i))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function Xv(e,t,i){const r=q([],J([],i,t),J([],e,t)),n=M(r);return 0===n?[0,0,1,0]:(B(r,r,1/n),[r[0],r[1],r[2],-H(r,t)])}function Yv(e){const t=e.properties.get("direction"),i=ut(t.x,t.y,t.z);i[2]=He(i[2],0,75);const r=ct([i[0],i[1],i[2]]);return D(r.x,r.y,r.z)}function Kv(e,t,i){const r="none"===t.properties.get("color-use-theme"),n=t.properties.get("color"),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=[s.x,s.y,s.z],l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color"),u=i.properties.get("intensity"),h=Math.max(H([0,0,1],a),0),d=[0,0,0];B(d,c.toPremultipliedRenderColor(l?null:e.getLut(t.scope)).toArray01Linear().slice(0,3),u);const p=[0,0,0];return B(p,n.toPremultipliedRenderColor(r?null:e.getLut(i.scope)).toArray01Linear().slice(0,3),h*o),vt([d[0]>0?d[0]/(d[0]+p[0]):0,d[1]>0?d[1]/(d[1]+p[1]):0,d[2]>0?d[2]/(d[2]+p[2]):0])}function Jv(e,t,i,r,n,o){const s=e.zoom,a=e.scale,l=e.worldSize,c=1/l,h=e.aspect,m=Math.sqrt(1+h*h)*Math.tan(.5*e.fovX),_=m*m,g=r-i,y=r+i;let x,v;_>g/y?(x=r,v=r*m):(x=.5*y*(1+_),v=.5*Math.sqrt(g*g+2*(r*r+i*i)*_+y*y*_*_));const b=e.projection.pixelsPerMeter(e.center.lat,l),w=[0,0,-x*c];Z(w,w,e._camera.getCameraToWorldMercator());let T=v*c;const E=e._edgeInsets;if(!(0===E.left&&0===E.top&&0===E.right&&0===E.bottom||E.left===E.right&&E.top===E.bottom)){const t=e._camera.getWorldToCamera(e.worldSize,"meters"===e.projection.zAxisUnit?b:1),n=e._camera.getCameraToClipPerspective(e._fov,e.width/e.height,i,r);n[8]=2*-e.centerOffset.x/e.width,n[9]=2*e.centerOffset.y/e.height;const o=new Float64Array(16);A(o,n,t);const c=new Float64Array(16);d(c,o);const u=Frustum.fromInvProjectionMatrix(c,l,s,!0);for(const t of u.points){const i=((S=t)[0]/=a,S[1]/=a,S[2]=tl(S[2],e._center.lat),S);T=Math.max(T,te(R([],w,i)))}}var S;T*=n/(n-1);const I=Math.acos(t[2]),C=Math.atan2(-t[0],-t[1]),M=new FreeCamera;M.position=w,M.setPitchBearing(I,C);const P=M.getWorldToCamera(l,b),L=T*l,z=Math.min(e._mercatorZfromZoom(17)*l*-2,-2*L),F=M.getCameraToClipOrthographic(-L,L,-L,L,z,(L+o*b)/t[2]),O=new Float64Array(16);p(O,F,P);const k=.5*n,U=[0,0,0];Z(U,D(Math.floor(1e6*w[0])/1e6*l,Math.floor(1e6*w[1])/1e6*l,0),O),B(U,U,k);const V=[Math.floor(U[0]),Math.floor(U[1]),Math.floor(U[2])],N=[0,0,0];J(N,U,V),B(N,N,-1/k);const j=new Float64Array(16);return u(j),f(j,j,N),p(O,j,O),[O,L]}class ModelManager extends Evented{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(e,t){return Ld(this.requestManager.transformRequest(t,Ii.Model).url).then((i=>{if(!i)return;const r=dp(i),n=new Model(e,t,void 0,void 0,r);return n.computeBoundsAndApplyParent(),n})).catch((i=>{if(i&&404===i.status)return null;this.fire(new ErrorEvent(new Error(`Could not load model ${e} from ${t}: ${i.message}`)))}))}load(e,t,i={forceReload:!1}){this.models[t]||(this.models[t]={});const r=Object.keys(e),n=[],o=[];for(const s of r){const r=e[s];this.hasURLBeenRequested(r)&&!i.forceReload||(this.modelByURL[r]={modelId:s,scope:t},n.push(this.loadModel(s,r)),o.push(s)),this.models[t][s]||(this.models[t][s]={model:null,numReferences:1})}this.numModelsLoading[t]=(this.numModelsLoading[t]||0)+o.length,Promise.allSettled(n).then((e=>{for(let i=0;i<e.length;i++){const{status:r}=e[i];if("rejected"===r)continue;const{value:n}=e[i];this.models[t][o[i]]||(this.models[t][o[i]]={model:null,numReferences:1}),this.models[t][o[i]].model=n}this.numModelsLoading[t]-=o.length,this.fire(new Event("data",{dataType:"style"}))})).catch((e=>{this.fire(new ErrorEvent(new Error(`Could not load models: ${e.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 r=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===r)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(r)){const{scope:e,modelId:t}=this.modelByURL[r];this.models[e][t].numReferences++}else this.modelUris[i][e]=r,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(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i={};for(const r of e)this.hasModel(r,t,{exactIdMatch:!0})||this.hasURLBeenRequested(r)?this.models[t][r].numReferences++:this.modelUris[t][r]&&!this.hasURLBeenRequested(r)?i[r]=this.modelUris[t][r]:!this.hasURLBeenRequested(r)&&t_(r,!1)&&(this.modelUris[t][r]=this.requestManager.normalizeModelURL(r),i[r]=this.modelUris[t][r]);this.load(i,t)}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,r=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||r)){const r=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[r];const n=this.models[t][e].model;if(!n)return;delete this.models[t][e],n.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 Qv=Gs.colorTheme,eb=new Properties({data:new DataConstantProperty(Qv.data)});function tb(e){if(!e.metadata||!e.metadata.content_area)return;const t=Wt.devicePixelRatio,{left:i,top:r,width:n,height:o}=e.metadata.content_area,s=i*t,a=r*t;return[s,a,s+n*t,a+o*t]}function ib(e){if(e)return e.map((([e,t])=>[e*Wt.devicePixelRatio,t*Wt.devicePixelRatio]))}class ImageProvider{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 e=new Map;if(!this.sourceCache.loaded())return e;const t=this.sourceCache.getVisibleCoordinates();if(0===t.length)return e;const i=this.sourceCache.getSource();if(!(i instanceof RasterArrayTileSource))return e;const r=t.map((e=>this.sourceCache.getTile(e))),n=i.getImages(r,Array.from(this.pendingRequests));for(const[t,i]of n)e.set(ImageId.from({name:t,iconsetId:this.id}),i),this.pendingRequests.delete(t);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),e}}const rb=(e,t)=>Yg(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),nb=We(Hx,["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"]),ob=We(Hx,["setCenter","setZoom","setBearing","setPitch"]),sb=new Set(["background","sky","slot","custom"]),ab={version:8,layers:[],sources:{}},lb={duration:300,delay:0};class Style extends Evented{constructor(e,t={}){super(),this.map=e,this.scope=t.scope||"",this.globalId=null,this.fragments=[],this.importDepth=t.importDepth||0,this.importsCache=t.importsCache||new Map,this.resolvedImports=t.resolvedImports||new Set,this.transition=Object.assign({},lb),this._buildingIndex=new BuildingIndex(this),this.crossTileSymbolIndex=new CrossTileSymbolIndex,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=t.styleChanges||new StyleChanges,this._hasDataDrivenEmissive=!1,this.dispatcher=t.dispatcher?t.dispatcher:new Dispatcher(nd(),this),t.imageManager?this.imageManager=t.imageManager:(this.imageManager=new ImageManager(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=t.glyphManager?t.glyphManager:new GlyphManager(e._requestManager,t.localFontFamily?2:t.localIdeographFontFamily?1:0,t.localFontFamily||t.localIdeographFontFamily),t.modelManager?this.modelManager=t.modelManager:(this.modelManager=new ModelManager(e._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=t.configOptions?t.configOptions:new Map,this._configDependentLayers=t.configDependentLayers?t.configDependentLayers:new Set,this._indoorDependentLayers=t.indoorDependentLayers?t.indoorDependentLayers:new Set,this._config=t.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:t.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=t.initialConfig,this.dispatcher.broadcast("setReferrer",Ci());const i=this;this._rtlTextPluginCallback=Style.registerForPluginStateChange((e=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,t)=>{if(Bs(e),t&&t.every((e=>e)))for(const e in i._sourceCaches){const t=i._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||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(e){if(!e)return null;if("string"==typeof e){if(Pt(e))return e;const t=ci(e);if(!t.startsWith("http"))try{return new URL(t,location.href).toString()}catch(e){return t}return t}return`json://${pr(JSON.stringify(e))}`}_diffStyle(e,t,i){this.globalId=this._getGlobalId(e);const r=(e,t)=>{try{t(null,this.setState(e,i))}catch(e){t(e,!1)}};if("string"==typeof e){const i=this.map._requestManager.normalizeStyleURL(e),n=this.map._requestManager.transformRequest(i,Ii.Style);Di(n,((e,i)=>{e?this.fire(new ErrorEvent(e)):i&&r(i,t)}))}else"object"==typeof e&&r(e,t)}loadURL(e,t={}){this.fire(new Event("dataloading",{dataType:"style"}));const i="boolean"==typeof t.validate?t.validate:!Pt(e);this.globalId=this._getGlobalId(e),e=this.map._requestManager.normalizeStyleURL(e,t.accessToken),this.resolvedImports.add(e);const r=this.importsCache.get(e);if(r)return this._load(r,i);const n=this.map._requestManager.transformRequest(e,Ii.Style);this._request=Di(n,((t,r)=>{if(this._request=null,t)this.fire(new ErrorEvent(t));else if(r)return this.importsCache.set(e,r),this._load(r,i)}))}loadJSON(e,t={}){this.fire(new Event("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(e),this._request=Wt.frame((()=>{this._request=null,this._load(e,!1!==t.validate)}))}loadEmpty(){this.fire(new Event("dataloading",{dataType:"style"})),this._load(ab,!1)}_loadImports(e,t,i){if(this.importDepth>=4)return st("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const n of e){const e=this._createFragmentStyle(n),o=new Promise((t=>{e.once("style.import.load",t),e.once("error",t)})).then((()=>this.mergeAll()));if(r.push(o),this.resolvedImports.has(n.url)){e.loadEmpty();continue}const s=n.data||this.importsCache.get(n.url);s?(e.loadJSON(s,{validate:t}),this._isInternalStyle(s)&&(e.globalId=null)):n.url?e.loadURL(n.url,{validate:t}):e.loadEmpty();const a={style:e,id:n.id,config:n.config};if(i){const e=this.fragments.findIndex((({id:e})=>e===i));this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}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(e){const t=this.scope?aa(e.id,this.scope):e.id;let i;const r=this._initialConfig&&this._initialConfig[t];(e.config||r)&&(i=Object.assign({},e.config,r));const n=new Style(this.map,{scope:t,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:i,configOptions:this.options,colorThemeOverride:e["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(e,t){if(this._isInternalStyle(e)){const i=Object.assign({},ab,{imports:[{id:"basemap",data:e,url:""}]},e.center?{center:e.center}:{},e.bearing?{bearing:e.bearing}:{},e.pitch?{pitch:e.pitch}:{},e.zoom?{zoom:e.zoom}:{},e.light?{light:e.light}:{});return this._importedAsBasemap=!0,void this._load(i,t)}if(this.updateConfig(this._config,e.schema),t&&rb(this,Og(e)))return;this._loaded=!0,this.stylesheet=rt(e);const i=()=>{for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1,isInitialLoad:!0});if(e.iconsets)for(const t in e.iconsets)this.addIconset(t,e.iconsets[t]);e.sprite?this._loadIconset(e.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&e.glyphs&&this.glyphManager.setURL(e.glyphs);const i=Gx(this.stylesheet.layers);if(this._order=i.map((e=>e.id)),this.stylesheet.light&&st("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 Light(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Light(this.stylesheet.light)),this._layers={};for(const e of i){const t=m_(e,this.scope,this._styleColorTheme.lut,this.options);0!==t.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(t.fqid),t.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(t.fqid),this._hasAppearances=this._hasAppearances||0!==t.getAppearances().length,t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t;const i=this.getOwnLayerSourceCache(t),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();i&&t.canCastShadows()&&r&&(i.castsShadows=!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 Event("data",{dataType:"style"}));const n=this.isRootStyle();e.imports?this._loadImports(e.imports,t).then((()=>{this._reloadImports(),this.fire(new Event(n?"style.load":"style.import.load"))})).catch((e=>{this.fire(new ErrorEvent(new Error("Failed to load imports",e))),this.fire(new Event(n?"style.load":"style.import.load"))})):(this._reloadImports(),this.fire(new Event(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 e=this._evaluateColorThemeData(r);this._loadColorTheme(e).then((()=>{i()})).catch((e=>{st(`Couldn't load color theme from the stylesheet: ${e}`),i()}))}else this._styleColorTheme.lut=null,i()}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances||this.fragments.some((e=>e.style.hasAppearances()))}mergeAll(){let e,t,i,r,n,o,s,a,l,c;const u={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((h=>{if(h.stylesheet){if(null!=h.light&&(e=h.light),h.stylesheet.lights)for(const e of h.stylesheet.lights)"ambient"===e.type&&null!=h.ambientLight&&(t=h.ambientLight),"directional"===e.type&&null!=h.directionalLight&&(i=h.directionalLight);r=this._prioritizeTerrain(r,h.terrain,h.stylesheet.terrain),h.stylesheet.fog&&null!=h.fog&&(n=h.fog),h.stylesheet.snow&&null!=h.snow&&(o=h.snow),h.stylesheet.rain&&null!=h.rain&&(s=h.rain),null!=h.stylesheet.camera&&(c=h.stylesheet.camera),null!=h.stylesheet.projection&&(a=h.stylesheet.projection),null!=h.stylesheet.transition&&(l=h.stylesheet.transition),u[h.scope]=h._styleColorTheme}})),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=n,this.snow=o,this.rain=s,this._styleColorThemeForScope=u,null===r?delete this.terrain:this.terrain=r,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},lb,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 r=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||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 e={},t={},i={};this.forEachFragmentStyle((r=>{for(const t in r._sourceCaches){const i=aa(t,r.scope);e[i]=r._sourceCaches[t]}for(const e in r._otherSourceCaches){const i=aa(e,r.scope);t[i]=r._otherSourceCaches[e]}for(const e in r._symbolSourceCaches){const t=aa(e,r.scope);i[t]=r._symbolSourceCaches[e]}})),this._mergedSourceCaches=e,this._mergedOtherSourceCaches=t,this._mergedSymbolSourceCaches=i}mergeIndoor(){this.forEachFragmentStyle((e=>{if(e.stylesheet&&e.stylesheet.indoor)for(const t of Object.values(e.stylesheet.indoor)){const i=t,r=aa(i.sourceId,e.scope);this._mergedIndoor[r]=new Set(i.sourceLayers||[])}}))}mergeLayers(){const e={},t=[],i={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((i=>{for(const r of i._order){const n=i._layers[r];if("slot"===n.type){const t=la(r);if(e[t])continue;e[t]=[]}n.slot&&e[n.slot]?e[n.slot].push(n):t.push(n)}})),this._mergedOrder=[];let r=-1;const n=(t=[])=>{for(const o of t)if("slot"===o.type){const t=la(o.id);e[t]&&n(e[t]),this._mergedSlots.push(t)}else{const e=aa(o.id,o.scope);this._mergedOrder.push(e),i[e]=o,o.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===o.type&&(this._hasCircleLayers=!0),"symbol"===o.type&&(this._hasSymbolLayers=!0),"clip"===o.type&&(this._clipLayerPresent=!0)}};if(n(t),this._has3DLayers){const e={};for(let t=0;t<this._mergedOrder.length;++t){const n=this._mergedOrder[t];e[n]=t===r?1:t<r?i[n].hasOcclusionOpacityProperties?2:0:4}this._mergedOrder.sort(((t,i)=>e[t]-e[i]))}this._mergedLayers=i,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(e){return e.data?function(e,t,i,r){const n=Object.assign({},t);for(const e of Object.keys(Qv))void 0===n[e]&&(n[e]=Qv[e].default);const o=new Transitionable(eb,e,new Map(i));return o.setTransitionOrValue(n,i),o.untransitioned().possiblyEvaluate(new EvaluationParameters(0,{worldview:void 0}))}(this.scope,e,this.options).get("data"):null}_loadColorTheme(e){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const t=this._styleColorTheme.lutLoadingCorrelationID;return new Promise(((i,r)=>{const n="data:image/png;base64,";if(!e||0===e.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void i();let o=e;o.startsWith(n)||(o=n+o);const s=ImageId.from("mapbox-reserved-lut"),a=new Image;a.src=o,a.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"))},a.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==t)return void i();this._styleColorTheme.lutLoading=!1;const{width:n,height:o,data:l}=Wt.getImageData(a);if(o>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(n!==o*o)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(s)&&this.removeImage(s),this.addImage(s,{data:new RGBAImage({width:n,height:o},l),pixelRatio:1,sdf:!1,usvg:!1,version:0});const c=this.imageManager.getImage(s,this.scope);c?(this._styleColorTheme.lut={image:c.data,data:e},i()):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(e){this._spriteRequest=function(e,t,i){let r,n,o;const s=Wt.devicePixelRatio>1?"@2x":"";let a=Di(t.transformRequest(t.normalizeSpriteURL(e,s,".json"),Ii.SpriteJSON),((e,t)=>{a=null,o||(o=e,r=t,c())})),l=Oi(t.transformRequest(t.normalizeSpriteURL(e,s,".png"),Ii.SpriteImage),((e,t)=>{l=null,o||(o=e,n=t,c())}));function c(){if(o)i(o);else if(r&&n){const e=Wt.getImageData(n),t={};for(const i in r){const{width:n,height:o,x:s,y:a,sdf:l,pixelRatio:c,stretchX:u,stretchY:h,content:d}=r[i],p=new RGBAImage({width:n,height:o});RGBAImage.copy(e,p,{x:s,y:a},{x:0,y:0},{width:n,height:o},null),t[i]={data:p,pixelRatio:void 0!==c?c:1,sdf:void 0!==l&&l,stretchX:u,stretchY:h,content:d,usvg:!1,version:0}}i(null,t)}}return{cancel(){a&&(a.cancel(),a=null),l&&(l.cancel(),l=null)}}}(e,this.map._requestManager,((e,t)=>{if(this._spriteRequest=null,e)this.fire(new ErrorEvent(e));else if(t){const e=new Map;for(const i in t)e.set(ImageId.from(i),t[i]);this.addImages(e)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new Event("data",{dataType:"style"}))}))}addIconset(e,t){if("sprite"===t.type)return void this._loadSprite(t.url);const i=this.getOwnSourceCache(t.source);if(!i)return void this.fire(new ErrorEvent(new Error(`Source "${t.source}" as specified by iconset "${e}" does not exist and cannot be used as an iconset source`)));const r=i.getSource();if("raster-array"!==r.type)return void this.fire(new ErrorEvent(new Error(`Source "${t.source}" as specified by iconset "${e}" is not a "raster-array" source and cannot be used as an iconset source`)));r.partial=!1;const n=new ImageProvider(e,this.scope,i);this.imageManager.addImageProvider(n,this.scope)}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope)}_loadIconset(e){if(!Pt(e)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(e);const t="auto"===this.map._spriteFormat;var i,r;this._spriteRequest=(r=(i,r)=>{if(this._spriteRequest=null,i)t?this._loadSprite(e):this.fire(new ErrorEvent(i));else if(r){const e=new Map;for(const t in r)e.set(ImageId.from(t),r[t]);this.addImages(e)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new Event("data",{dataType:"style"}))},Pi((i=this.map._requestManager).transformRequest(i.normalizeIconsetURL(e),Ii.Iconset),((e,t)=>{if(e)return void r(e);const i={},n=new yf(t).readFields(E_,{icons:[]},void 0);for(const e of n.icons){const t={version:1,pixelRatio:Wt.devicePixelRatio,content:tb(e),stretchX:e.metadata?ib(e.metadata.stretch_x_areas):void 0,stretchY:e.metadata?ib(e.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:e};i[e.name]=t}r(null,i)})))}_validateLayer(e){const t=this.getOwnSource(e.source);if(!t)return;const i=e.sourceLayer;i&&("geojson"===t.type||t.vectorLayerIds&&-1===t.vectorLayerIds.indexOf(i))&&this.fire(new ErrorEvent(new Error(`Source layer "${i}" does not exist on source "${t.id}" as specified by style layer "${e.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(e){const t=this.getOwnLayer(e);if(t)return t;this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}_checkSource(e){const t=this.getOwnSource(e);if(t)return t;this.fire(new ErrorEvent(new Error(`The source '${e}' does not exist in the map's style.`)))}precompilePrograms(e,t){const i=this.map.painter;if(i)for(let r=e.minzoom||0;r<(e.maxzoom||25.5);r++){const r=e.getProgramIds();if(r)for(const n of r){const r=e.getDefaultProgramParams(n,t.zoom,this._styleColorTheme.lut);r&&(i.style=this,this.fog&&(i._fogVisible=!0,r.overrideFog=!0,i.getOrCreateProgram(n,r)),i._fogVisible=!1,r.overrideFog=!1,i.getOrCreateProgram(n,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,i.getOrCreateProgram(n,r)))}}}update(e){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(e),this.directionalLight&&this.directionalLight.recalculate(e);const t=this.calculateLightsBrightness();e.brightness=t||0,t!==this._brightness&&(this._brightness=t,this.dispatcher.broadcast("setBrightness",t)),e.worldview!==this._worldview&&(this._worldview=e.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const i=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const t=this._changes.getLayerUpdatesByScope();for(const e in t){const{updatedIds:i,removedIds:n}=t[e];(i||n)&&(this._updateWorkerLayers(e,i,n),r=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(e),this.light&&this.light.updateTransitions(e),this.ambientLight&&this.ambientLight.updateTransitions(e),this.directionalLight&&this.directionalLight.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this.snow&&this.snow.updateTransitions(e),this.rain&&this.rain.updateTransitions(e),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}for(const t of this._mergedOrder){const i=this._mergedLayers[t];if("none"!==i.visibility&&i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback((()=>{this.precompilePrograms(i,e)})):this.precompilePrograms(i,e))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&r&&this.mergeLayers();const o=this.imageManager.getPendingImageProviders();for(const e of o)e.sourceCache.used=!0;for(const e in n){const t=this._mergedSourceCaches[e];n[e]!==t.used&&t.getSource().fire(new Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}))}this.light&&this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.snow&&this.snow.recalculate(e),this.rain&&this.rain.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),i&&this.fire(new Event("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 r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:i||[],options:r.options})}setState(e,t){if(this._checkLoaded(),rb(this,Og(e)))return!1;(e=rt(e)).layers=Gx(e.layers);const i=function(e,t){if(!e)return[{command:Hx.setStyle,args:[t]}];let i=[];try{if(!Re(e.version,t.version))return[{command:Hx.setStyle,args:[t]}];if(Re(e.center,t.center)||i.push({command:Hx.setCenter,args:[t.center]}),Re(e.zoom,t.zoom)||i.push({command:Hx.setZoom,args:[t.zoom]}),Re(e.bearing,t.bearing)||i.push({command:Hx.setBearing,args:[t.bearing]}),Re(e.pitch,t.pitch)||i.push({command:Hx.setPitch,args:[t.pitch]}),Re(e.sprite,t.sprite)||i.push({command:Hx.setSprite,args:[t.sprite]}),Re(e.glyphs,t.glyphs)||i.push({command:Hx.setGlyphs,args:[t.glyphs]}),Re(e.imports,t.imports)||function(e=[],t=[],i){t=t||[];const r=(e=e||[]).map(Yx),n=t.map(Yx),o=e.reduce(Kx,{}),s=t.reduce(Kx,{}),a=r.slice();let l,c,u,h;for(l=0,c=0;l<r.length;l++)u=r[l],s.hasOwnProperty(u)?c++:(i.push({command:Hx.removeImport,args:[u]}),a.splice(a.indexOf(u,c),1));for(l=0,c=0;l<n.length;l++)u=n[n.length-1-l],a[a.length-1-l]!==u&&(o.hasOwnProperty(u)?(i.push({command:Hx.removeImport,args:[u]}),a.splice(a.lastIndexOf(u,a.length-c),1)):c++,h=a[a.length-l],i.push({command:Hx.addImport,args:[s[u],h]}),a.splice(a.length-l,0,u));for(const e of t){const t=o[e.id];t&&(delete t.data,Re(t,e)||i.push({command:Hx.updateImport,args:[e.id,e]}))}}(e.imports,t.imports,i),Re(e.transition,t.transition)||i.push({command:Hx.setTransition,args:[t.transition]}),Re(e.light,t.light)||i.push({command:Hx.setLight,args:[t.light]}),Re(e.fog,t.fog)||i.push({command:Hx.setFog,args:[t.fog]}),Re(e.snow,t.snow)||i.push({command:Hx.setSnow,args:[t.snow]}),Re(e.rain,t.rain)||i.push({command:Hx.setRain,args:[t.rain]}),Re(e.projection,t.projection)||i.push({command:Hx.setProjection,args:[t.projection]}),Re(e.lights,t.lights)||i.push({command:Hx.setLights,args:[t.lights]}),Re(e.camera,t.camera)||i.push({command:Hx.setCamera,args:[t.camera]}),Re(e.iconsets,t.iconsets)||function(e,t,i){let r;for(r in t=t||{},e=e||{})e.hasOwnProperty(r)&&(t.hasOwnProperty(r)||i.push({command:Hx.removeIconset,args:[r]}));for(r in t){if(!t.hasOwnProperty(r))continue;const n=t[r];e.hasOwnProperty(r)?Re(e[r],n)||(i.push({command:Hx.removeIconset,args:[r]}),i.push({command:Hx.addIconset,args:[r,n]})):i.push({command:Hx.addIconset,args:[r,n]})}}(e.iconsets,t.iconsets,i),!Re(e["color-theme"],t["color-theme"]))return[{command:Hx.setStyle,args:[t]}];const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||$x(n,i,r));for(n in t){if(!t.hasOwnProperty(n))continue;const o=t[n];e.hasOwnProperty(n)?Re(e[n],o)||("geojson"===e[n].type&&"geojson"===o.type&&Wx(e,t,n)?i.push({command:Hx.setGeoJSONSourceData,args:[n,o.data]}):Zx(n,t,i,r)):qx(n,t,i)}}(e.sources,t.sources,n,r);const o=[];e.layers&&e.layers.forEach((e=>{e.source&&r[e.source]?i.push({command:Hx.removeLayer,args:[e.id]}):o.push(e)}));let s=e.terrain;s&&r[s.source]&&(i.push({command:Hx.setTerrain,args:[void 0]}),s=void 0),i=i.concat(n),Re(s,t.terrain)||i.push({command:Hx.setTerrain,args:[t.terrain]}),function(e,t,i){t=t||[];const r=(e=e||[]).map(Yx),n=t.map(Yx),o=e.reduce(Kx,{}),s=t.reduce(Kx,{}),a=r.slice(),l=Object.create(null);let c,u,h,d,p,f,m;for(c=0,u=0;c<r.length;c++)h=r[c],s.hasOwnProperty(h)?u++:(i.push({command:Hx.removeLayer,args:[h]}),a.splice(a.indexOf(h,u),1));for(c=0,u=0;c<n.length;c++)h=n[n.length-1-c],a[a.length-1-c]!==h&&(o.hasOwnProperty(h)?(i.push({command:Hx.removeLayer,args:[h]}),a.splice(a.lastIndexOf(h,a.length-u),1)):u++,f=a[a.length-c],i.push({command:Hx.addLayer,args:[s[h],f]}),a.splice(a.length-c,0,h),l[h]=!0);for(c=0;c<n.length;c++)if(h=n[c],d=o[h],p=s[h],!l[h]&&!Re(d,p))if(Re(d.source,p.source)&&Re(d["source-layer"],p["source-layer"])&&Re(d.type,p.type)){for(m in Xx(d.layout,p.layout,i,h,null,Hx.setLayoutProperty),Xx(d.paint,p.paint,i,h,null,Hx.setPaintProperty),Re(d.slot,p.slot)||i.push({command:Hx.setSlot,args:[h,p.slot]}),Re(d.filter,p.filter)||i.push({command:Hx.setFilter,args:[h,p.filter]}),Re(d.minzoom,p.minzoom)&&Re(d.maxzoom,p.maxzoom)||i.push({command:Hx.setLayerZoomRange,args:[h,p.minzoom,p.maxzoom]}),d)d.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&"slot"!==m&&(0===m.indexOf("paint.")?Xx(d[m],p[m],i,h,m.slice(6),Hx.setPaintProperty):Re(d[m],p[m])||i.push({command:Hx.setLayerProperty,args:[h,m,p[m]]}));for(m in p)p.hasOwnProperty(m)&&!d.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&"slot"!==m&&(0===m.indexOf("paint.")?Xx(d[m],p[m],i,h,m.slice(6),Hx.setPaintProperty):Re(d[m],p[m])||i.push({command:Hx.setLayerProperty,args:[h,m,p[m]]}))}else i.push({command:Hx.removeLayer,args:[h]}),f=a[a.lastIndexOf(h)+1],i.push({command:Hx.addLayer,args:[p,f]})}(o,t.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:Hx.setStyle,args:[t]}]}return i}(this.serialize(),e).filter((e=>!(e.command in ob)));if(0===i.length)return!1;const r=i.filter((e=>!(e.command in nb)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((e=>e.command)).join(", ")}.`);const n=[];return i.forEach((e=>{n.push(this[e.command](...e.args))})),t&&Promise.all(n).then(t).catch(t),this.stylesheet=e,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(e){if(0===e.size)return this;for(const[t,i]of e.entries()){if(this.getImage(t))return this.fire(new ErrorEvent(new Error(`An image with the name "${t.name}" already exists.`)));this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope)}return this._updateWorkerImages(),this.fire(new Event("data",{dataType:"style"})),this}addImage(e,t){return this.getImage(e)?this.fire(new ErrorEvent(new Error(`An image with the name "${e.name}" already exists.`))):(this.imageManager.addImage(e,this.scope,t),this._changes.updateImage(e,this.scope),this._updateWorkerImages(),this.fire(new Event("data",{dataType:"style"})),this)}updateImage(e,t,i=!1){this.imageManager.updateImage(e,this.scope,t),i&&(this._changes.updateImage(e,this.scope),this._updateWorkerImages(),this.fire(new Event("data",{dataType:"style"})))}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e,this.scope),this._changes.updateImage(e,this.scope),this._updateWorkerImages(),this.fire(new Event("data",{dataType:"style"})),this):this.fire(new ErrorEvent(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(e){return this.modelManager.addModelURLs(e,this.getActualScope()),this._updateWorkerModels(),this.fire(new Event("data",{dataType:"style"})),this}addModel(e,t,i={}){return this._checkLoaded(),this._validate(Wg,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.getActualScope()),this.fire(new Event("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.getActualScope())}removeModel(e){return this.hasModel(e)?(this.modelManager.removeModel(e,this.getActualScope(),!1,!0),this.fire(new Event("data",{dataType:"style"})),this):this.fire(new ErrorEvent(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(e,t,i={}){if(this._checkLoaded(),void 0!==this.getOwnSource(e))throw new Error(`There is already a source with ID "${e}".`);if(!t.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(t.type)>=0&&this._validate(Bg,`sources.${e}`,t,null,i))return;this.map&&this.map._collectResourceTiming&&(t.collectResourceTiming=!0);const r=vx(e,t,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id})));const n=e=>{const t=(e?"symbol:":"other:")+r.id,i=aa(t,this.scope),n=this._sourceCaches[t]=new SourceCache(i,r,e);(e?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=n,n.onAdd(this.map)};n(!1),"vector"!==t.type&&"geojson"!==t.type||n(!0),r.onAdd&&r.onAdd(this.map),i.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(e){this._checkLoaded();const t=this.getOwnSource(e);if(!t)throw new Error("There is no source with this ID");for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===e)return this.fire(new ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const t=Object.entries(this.stylesheet.iconsets).find((([t,i])=>"source"===i.type&&i.source===e));if(t)return this.fire(new ErrorEvent(new Error(`Source "${e}" cannot be removed while iconset "${t[0]}" is using it.`)))}const i=this.getOwnSourceCaches(e);for(const e of i){const t=la(e.id);delete this._sourceCaches[t],this._changes.discardSourceCacheUpdate(e.id),e.fire(new Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles()}return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],this.mergeSources(),t.setEventedParent(null),t.onRemove&&t.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(e){if(this._checkLoaded(),!e)return delete this.ambientLight,void delete this.directionalLight;const t=this._getTransitionParameters();for(const i of e){if(this._validate(Ug,"lights",i))return;switch(i.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(i),e.updateTransitions(t)}else this.ambientLight=new Lights(i,hy||(hy=new Properties({color:new DataConstantProperty(Gs.properties_light_ambient.color),"color-use-theme":new DataConstantProperty({type:"string",default:"default","property-type":"data-constant"}),intensity:new DataConstantProperty(Gs.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(i),e.updateTransitions(t)}else this.directionalLight=new Lights(i,dy||(dy=new Properties({direction:new DirectionProperty(Gs.properties_light_directional.direction),color:new DataConstantProperty(Gs.properties_light_directional.color),"color-use-theme":new DataConstantProperty({type:"string",default:"default","property-type":"data-constant"}),intensity:new DataConstantProperty(Gs.properties_light_directional.intensity),"cast-shadows":new DataConstantProperty(Gs.properties_light_directional["cast-shadows"]),"shadow-quality":new DataConstantProperty(Gs.properties_light_directional["shadow-quality"]),"shadow-intensity":new DataConstantProperty(Gs.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const i=Object.assign(t,{worldview:this.map.getWorldview()}),r=new EvaluationParameters(this.z||0,i);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const e=this.directionalLight,t=this.ambientLight;if(!e||!t)return;const i=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=e.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),n=e.properties.get("intensity"),o=e.properties.get("direction"),s=1-ut(o.x,o.y,o.z)[2]/90,a=i(r)*n*s,l=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),c=t.properties.get("intensity"),u=i(l)*c;return Number(((a+u)/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(e){if(null==e||""===e&&this.isRootStyle())return this;if(sa(e)){const t=function(e){const t=e.lastIndexOf(oa);return t>=0?e.slice(t+1):""}(e),i=this.fragments.find((({id:e})=>e===t));if(!i)return;const r=la(e);return i.style.getFragmentStyle(r)}{const t=this.fragments.find((({id:t})=>t===e));return t?t.style:void 0}}setFeaturesetSelectors(e){if(!e)return;const t={},i=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const r in e){const n=this._featuresetSelectors[r]=[];for(const o of e[r].selectors){if(o.featureNamespace){const e=this.getOwnLayer(o.layer);if(!e){st(`Layer is undefined for selector: ${o.layer}`);continue}const n=i(e.source,e.sourceLayer);if(n in t&&t[n]!==o.featureNamespace){st(`"featureNamespace ${o.featureNamespace} of featureset ${r}'s selector is not associated to the same source, skip this selector`);continue}t[n]=o.featureNamespace}let e;if(o.properties)for(const t in o.properties){const i=ps(o.properties[t]);"success"===i.result&&(e=e||{},e[t]=i.value)}n.push({layerId:o.layer,namespace:o.featureNamespace,properties:e,uniqueFeatureID:o._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(e,t){const i=this.getFragmentStyle(t),r=i.stylesheet.featuresets;if(!r||!r[e])return this.fire(new ErrorEvent(new Error(`The featureset '${e}' does not exist in the map's style and cannot be queried.`))),[];const n=[];for(const t of r[e].selectors){const e=i.getOwnLayer(t.layer);e&&n.push(e)}return n}getConfigProperty(e,t){const i=this.getFragmentStyle(e);if(!i)return null;const r=aa(t,i.scope),n=i.options.get(r),o=n?n.value||n.default:null;return o?o.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(e,t){const i=aa(e,t);return this._mergedIndoor[i]}setIndoorData(e,t){this.map.indoor.setIndoorData(t)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(e,t,i){const r=this.getFragmentStyle(e);if(!r)return;const n=r.stylesheet.schema;if(!n||!n[t])return;const o=ps(i);if("success"!==o.result)return void rb(this,o.value);const s=o.value.expression,a=aa(t,r.scope),l=r.options.get(a);if(!l)return;let c;const{minValue:u,maxValue:h,stepValue:d,type:p,values:f}=n[t],m=ps(n[t].default);"success"===m.result&&(c=m.value.expression),c?(this.options.set(a,Object.assign({},l,{value:s,default:c,minValue:u,maxValue:h,stepValue:d,type:p,values:f})),this.updateConfigDependencies(t)):this.fire(new ErrorEvent(new Error(`No schema defined for the config option "${t}" in the "${e}" fragment.`)))}getConfig(e){const t=this.getFragmentStyle(e);if(!t)return null;const i=t.stylesheet.schema;if(!i)return null;const r={};for(const e in i){const i=aa(e,t.scope),n=t.options.get(i),o=n?n.value||n.default:null;r[e]=o?o.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(e,t){if(this._config=e,e||t)if(t)for(const i in t){let r,n;const o=ps(t[i].default);if("success"===o.result&&(r=o.value.expression),e&&void 0!==e[i]){const t=ps(e[i]);"success"===t.result&&(n=t.value.expression)}const{minValue:s,maxValue:a,stepValue:l,type:c,values:u}=t[i];if(r){const e=aa(i,this.scope);this.options.set(e,{default:r,value:n,minValue:s,maxValue:a,stepValue:l,type:c,values:u})}else this.fire(new ErrorEvent(new Error(`No schema defined for config option "${i}".`)))}else this.fire(new ErrorEvent(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(e,t,i={}){this._checkLoaded();const r=e.id;if(this._layers[r])return void this.fire(new ErrorEvent(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===e.type){if(rb(this,function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t}(e)))return;n=m_(e,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof e.source&&(this.addSource(r,e.source),e=rt(e),e=Object.assign(e,{source:r})),this._validate(Hg,`layers.${r}`,e,{arrayIndex:-1},i))return;n=m_(e,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}})}const o=aa(n.source,n.scope);0!==n.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o),n.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o);let s=this._order.length;if(t){const e=this._order.indexOf(t);if(-1===e)return void this.fire(new ErrorEvent(new Error(`Layer with id "${t}" does not exist on this map.`)));n.slot===this._layers[t].slot?s=e:st(`Layer with id "${t}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=n;const a=this.getOwnLayerSourceCache(n),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&n.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(n);if(c&&n.source&&a&&"custom"!==n.type){this._changes.discardLayerRemoval(n);const e=aa(n.source,n.scope);c.type!==n.type?this._changes.updateSourceCache(e,"clear"):(this._changes.updateSourceCache(e,"reload"),a.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),n.scope=this.scope,this.mergeLayers()}moveLayer(e,t){this._checkLoaded();const i=this._checkLayer(e);if(!i)return;if(e===t)return;const r=this._order.indexOf(e);this._order.splice(r,1);let n=this._order.length;if(t){const e=this._order.indexOf(t);if(-1===e)return void this.fire(new ErrorEvent(new Error(`Layer with id "${t}" does not exist on this map.`)));i.slot===this._layers[t].slot?n=e:st(`Layer with id "${t}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(n,0,e),this._changes.setDirty(),this._layerOrderChanged=!0,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._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}r.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 r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)))}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(e,t,i={}){this._checkLoaded();const r=this._checkLayer(e);if(r&&!Re(r.filter,t))return null==t?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(qg,`layers.${r.id}.filter`,t,{layerType:r.type},i)||(r.filter=rt(t),this._updateLayer(r)))}getFilter(e){const t=this._checkLayer(e);if(t)return rt(t.filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();const n=this._checkLayer(e);if(n&&!Re(n.getLayoutProperty(t),i)){if(null!=i&&(!r||!1!==r.validate)&&rb(n,Zg.call(Og,{key:`layers.${e}.layout.${t}`,layerType:n.type,objectKey:t,value:i,styleSpec:Gs,style:{glyphs:!0,sprite:!0}})))return;n.setLayoutProperty(t,i),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,r={}){this._checkLoaded();const n=this._checkLayer(e);n&&("appearances"===t?(n.setAppearances(i),this._changes.setDirty()):n.isPaintProperty(t)?this.setPaintProperty(e,t,i,r):this.setLayoutProperty(e,t,i,r))}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(e,t,i,r={}){this._checkLoaded();const n=this._checkLayer(e);if(!n)return;if(Re(n.getPaintProperty(t),i))return;if(null!=i&&(!r||!1!==r.validate)&&rb(n,$g.call(Og,{key:`layers.${e}.paint.${t}`,layerType:n.type,objectKey:t,value:i,styleSpec:Gs})))return;const o=n.setPaintProperty(t,i);0!==n.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(n.fqid),n.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(n.fqid),o&&this._updateLayer(n),this._changes.updatePaintProperties(n)}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(e,t){if(this._checkLoaded(),"target"in e){if("featuresetId"in e.target){const{featuresetId:i,importId:r}=e.target,n=this.getFragmentStyle(r),o=n.getFeaturesetLayers(i);for(const{source:i,sourceLayer:r}of o)n.setFeatureState({id:e.id,source:i,sourceLayer:r},t)}else if("layerId"in e.target){const{layerId:i}=e.target,r=this.getLayer(i);this.setFeatureState({id:e.id,source:r.source,sourceLayer:r.sourceLayer},t)}return}const i=e.source,r=e.sourceLayer,n=this._checkSource(i);if(!n)return;const o=n.type;if("geojson"===o&&r)return void this.fire(new ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new ErrorEvent(new Error("The feature id parameter must be provided.")));const s=this.getOwnSourceCaches(i);for(const i of s)i.setFeatureState(r,e.id,t)}removeFeatureState(e,t){if(this._checkLoaded(),"target"in e){if("featuresetId"in e.target){const{featuresetId:i,importId:r}=e.target,n=this.getFragmentStyle(r),o=n.getFeaturesetLayers(i);for(const{source:i,sourceLayer:r}of o)n.removeFeatureState({id:e.id,source:i,sourceLayer:r},t)}else if("layerId"in e.target){const{layerId:i}=e.target,r=this.getLayer(i);this.removeFeatureState({id:e.id,source:r.source,sourceLayer:r.sourceLayer},t)}return}const i=e.source,r=this._checkSource(i);if(!r)return;const n=r.type,o="vector"===n?e.sourceLayer:void 0;if("vector"===n&&!o)return void this.fire(new ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(t&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const s=this.getOwnSourceCaches(i);for(const i of s)i.removeFeatureState(o,e.id,t)}getFeatureState(e){if(this._checkLoaded(),"target"in e){let t;if("featuresetId"in e.target){const{featuresetId:i,importId:r}=e.target,n=this.getFragmentStyle(r),o=n.getFeaturesetLayers(i);for(const{source:i,sourceLayer:r}of o){const o=n.getFeatureState({id:e.id,source:i,sourceLayer:r});if(o&&!t)t=o;else if(!Re(t,o))return void this.fire(new ErrorEvent(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 e.target){const{layerId:i}=e.target,r=this.getLayer(i);t=this.getFeatureState({id:e.id,source:r.source,sourceLayer:r.sourceLayer})}return t}const t=e.source,i=e.sourceLayer,r=this._checkSource(t);if(r){if("vector"!==r.type||i)return void 0===e.id&&this.fire(new ErrorEvent(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(t)[0].getFeatureState(i,e.id);this.fire(new ErrorEvent(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)}serialize(){this._checkLoaded();const e=this.getTerrain(),t=e&&this.terrain&&this.terrain.scope===this.scope?e:this.stylesheet.terrain;return it({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:t,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,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(e){this._changes.updateLayer(e);const t=this.getLayerSourceCache(e),i=aa(e.source,e.scope),r=this._changes.getUpdatedSourceCaches();e.source&&!r[i]&&t&&"raster"!==t.getSource().type&&(this._changes.updateSourceCache(i,"reload"),t.pause()),e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,r={},n=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){r[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t)}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(t.layer&&r[t.layer.id]<s)break;o.push(t),n.pop()}else for(const t of e){const e=t[a];if(e)for(const t of e)o.push(t.feature)}}return o}queryRasterValue(e,t,i){const r=this.getOwnSource(e);return r?"raster-array"!==r.type?(this.fire(new ErrorEvent(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):r.queryRasterArrayValue(t,i):(this.fire(new ErrorEvent(new Error(`Source with id "${e}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(e,t,i){let r;t&&!Array.isArray(t)&&t.filter&&(this._validate(qg,"queryRenderedFeatures.filter",t.filter,null,t),r=Zs(t.filter));const n={},o=e=>{if(sb.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(t&&t.layers){if(!Array.isArray(t.layers))return this.fire(new ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const e of t.layers){const t=this._layers[e];if(!t)return this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];o(t)}}else for(const e in this._layers)o(this._layers[e]);const s=this._queryRenderedFeatures(e,n,i),a=this._flattenAndSortRenderedFeatures(s),l=[];for(const e of a)ca(e.layer.id)===this.scope&&l.push(e);return l}queryRenderedFeatureset(e,t,i){let r;t&&!Array.isArray(t)&&t.filter&&(this._validate(qg,"queryRenderedFeatures.filter",t.filter,null,t),r=Zs(t.filter));const n="mock",o=[];if(t&&t.target)o.push(Object.assign({},t,{targetId:n,filter:r}));else{const e=this.getFeaturesetDescriptors();for(const t of e)o.push({targetId:n,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)o.push({targetId:n,filter:r,target:e})}}const s=this.queryRenderedTargets(e,o,i),a=[],l=new Set;for(const e of s)for(const t of e.variants[n])wx(t,e,l)||a.push(new TargetFeature(e,t));return a}queryRenderedTargets(e,t,i){const r={},n=(e,t,i,n)=>{const o=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(o.layers[e.fqid]=o.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(o.has3DLayers=!0),!n)return i.uniqueFeatureID=!1,void o.layers[e.fqid].targets.push(i);o.layers[e.fqid].targets.push(Object.assign({},i,{namespace:n.namespace,properties:n.properties,uniqueFeatureID:n.uniqueFeatureID}))};for(const e of t)if("featuresetId"in e.target){const{featuresetId:t,importId:i}=e.target,r=this.getFragmentStyle(i);if(!r||!r._featuresetSelectors)continue;const o=r._featuresetSelectors[t];if(!o){this.fire(new ErrorEvent(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const t of o){const i=r.getOwnLayer(t.layerId);i&&!sb.has(i.type)&&n(i,r.getOwnLayerSourceCache(i),e,t)}}else if("layerId"in e.target){const{layerId:t}=e.target,i=this.getLayer(t);if(!i||sb.has(i.type))continue;n(i,this.getLayerSourceCache(i),e)}const o=this._queryRenderedFeatures(e,r,i);return this._flattenAndSortRenderedFeatures(o)}_queryRenderedFeatures(e,t,i){const r=[],n=!!this.map._showQueryGeometry,o=QueryGeometry.createFromScreenPoints(e,i);for(const e in t){const s=Tx(o,t[e],this._availableImages,i,n);Object.keys(s).length&&r.push(s)}if(this.placement)for(const e in t){if(!t[e].sourceCache._onlySymbols)continue;const i=Ex(o.screenGeometry,t[e],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(i).length&&r.push(i)}return r}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(qg,"querySourceFeatures.filter",i,null,t);let r=[];const n=this.getOwnSourceCaches(e);for(const e of n)r=r.concat(Sx(e,t));return r}addSourceType(e,t,i){return Style.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Style.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(e,t,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const t in e)if(!Re(e[t],r[t])){n=!0;break}if(!n)return;const o=this._getTransitionParameters();this.light.setLight(e,t,i),this.light.updateTransitions(o)}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=Wt.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&st("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(e,t=1){if(this._checkLoaded(),!e)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===t&&delete this.terrain,null===e?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let i=e;const r=!("source"in e)||null==e.source;if(1===t){if(this.disableElevatedTerrain)return;if("source"in i&&"object"==typeof i.source){const e="terrain-dem-src";this.addSource(e,i.source),i=rt(i),i=Object.assign(i,{source:e})}const e=Object.assign({},i),t={};if(this.terrain&&r){e.source=this.terrain.get().source;const i=this.terrain?this.getFragmentStyle(this.terrain.scope):null;i&&(t.style=i.serialize())}if(this._validate(Vg,"terrain",e,t))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&t!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,t),this.fire(new Event("data",{dataType:"style"}))}else{const t=this.terrain,r=t.get();for(const e of Object.keys(Gs.terrain))!i.hasOwnProperty(e)&&Gs.terrain[e].default&&(i[e]=Gs.terrain[e].default);for(const i in e)if(!Re(e[i],r[i])){t.set(e,this.options),this.stylesheet.terrain=e;const i=this._getTransitionParameters({duration:0});t.updateTransitions(i),this.fire(new Event("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Fog(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 py(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 fy(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(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const t=this.fog;if(!Re(t.get(),e)){t.set(e,this.options),this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}}else this._createFog(e);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(e){if(this._checkLoaded(),!e)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const t=this.snow;if(!Re(t.get(),e)){t.set(e,this.options),this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}}else this._createSnow(e);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(e){if(this._checkLoaded(),!e)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const t=this.rain;if(!Re(t.get(),e)){t.set(e,this.options),this.stylesheet.rain=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}}else this._createRain(e);this._markersNeedUpdate=!0}_reloadColorTheme(){const e=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles()},t=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!t)return this._styleColorTheme.lut=null,void e();const i=this._evaluateColorThemeData(t);this._loadColorTheme(i).then((()=>{this.fire(new Event("colorthemeset")),e()})).catch((e=>{st(`Couldn't set color theme: ${e}`)}))}setColorTheme(e){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&st("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=e,this._reloadColorTheme()}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme())}_getTransitionParameters(e){return{now:Wt.now(),transition:Object.assign(this.transition,e)}}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 ey(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_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(e,t,i,r,n={}){if(n&&!1===n.validate)return!1;const o=Object.assign({},this.serialize());return rb(this,e.call(Og,Object.assign({key:t,style:o,value:i,styleSpec:Gs},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),Us.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.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,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=Yv(this.directionalLight));const i=new Set,r=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];"building"===t.type&&i.add(t.source),t.hasElevation()&&!r.has(t.source)&&r.add(t.source)}for(const n in this._mergedSourceCaches){const o=this._mergedSourceCaches[n],s=r.has(o._source.id);i.has(o._source.id)&&(o._source.reparseOverscaled=!1),o.update(e,void 0,void 0,t,s)}}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(e,t,i,r,n,o,s=!1){let a=!1,l=!1;const c={},u={};for(const e of this._mergedOrder){const i=this._mergedLayers[e];if("symbol"!==i.type)continue;const r=aa(i.source,i.scope);let n=c[r];if(!n){const e=this.getLayerSourceCache(i);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));u[r]=t.slice(),n=c[r]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const o=this.crossTileSymbolIndex.addLayer(i,n,t.center.lng,t.projection);a=a||o}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),s=s||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new Event("neworder"));const h=Boolean(this.placement&&!t.equals(this.placement.transform)),d=Boolean(this.placement&&(0!==this.placement.lastReplacementSourceUpdateTime&&!o||this.placement.lastReplacementSourceUpdateTime!==o.updateTime)),p=(h||d||a||this.placement&&this.placement.isStale())&&0===r;if((s||!this.pauseablePlacement||p||0!==r&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Wt.now(),t.zoom))&&(this.pauseablePlacement=new PauseablePlacement(t,this._mergedOrder,s||0===r,i,r,n,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,c,u,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Wt.now()),l=!0),a&&this.pauseablePlacement.placement.setStale()),l||a){this._buildingIndex.onNewFrame(t.zoom);for(let e=0;e<this._mergedOrder.length;e++){const t=this._mergedLayers[this._mergedOrder[e]];if("symbol"!==t.type)continue;if("none"===t.visibility)continue;const i=this.isLayerClipped(t);this.placement.updateLayerOpacities(t,c[aa(t.source,t.scope)],e,i?o:null)}}return{needsRerender:!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Wt.now())}}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(e,t){this._checkLoaded();const i=this.stylesheet.imports=this.stylesheet.imports||[],r=i.findIndex((({id:t})=>t===e.id));if(-1!==r)return void this.fire(new ErrorEvent(new Error(`Import with id '${e.id}' already exists in the map's style.`)));if(!t)return i.push(e),this._loadImports([e],!0);const n=i.findIndex((({id:e})=>e===t));return-1===n&&this.fire(new ErrorEvent(new Error(`Import with id "${t}" does not exist on this map.`))),this.stylesheet.imports=i.slice(0,n).concat(e).concat(i.slice(n)),this._loadImports([e],!0,t)}updateImport(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],r=this.getImportIndex(e);return-1===r?this:"string"==typeof t?(this.setImportUrl(e,t),this):(t.url&&t.url!==i[r].url&&this.setImportUrl(e,t.url),Re(t.config,i[r].config)||this.setImportConfig(e,t.config,t.data.schema),Re(t.data,i[r].data)||this.setImportData(e,t.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const r=this.getImportIndex(e);if(-1===r)return this;const n=this.getImportIndex(t);if(-1===n)return this;const o=i[r],s=this.fragments[r];return i=i.filter((({id:t})=>t!==e)),this.fragments=this.fragments.filter((({id:t})=>t!==e)),this.stylesheet.imports=i.slice(0,n).concat(o).concat(i.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;i[r].url=t;const n=this.fragments[r];return n.style=this._createFragmentStyle(i[r]),n.style.on("style.import.load",(()=>this.mergeAll())),n.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete r[i].data,this.setImportUrl(e,r[i].url))}setImportConfig(e,t,i){this._checkLoaded();const r=this.getImportIndex(e),n=this.stylesheet.imports||[];if(-1===r)return this;t?n[r].config=t:delete n[r].config;const o=this.fragments[r];i&&o.style.stylesheet&&(o.style.stylesheet.schema=i);const s=o.style.stylesheet&&o.style.stylesheet.schema;return o.config=t,o.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(e){const t=(this.stylesheet.imports||[]).findIndex((t=>t.id===e));return-1===t&&this.fire(new ErrorEvent(new Error(`Import '${e}' does not exist in the map's style and cannot be updated.`))),t}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(e,t){const i=aa(e,t);return this._mergedOtherSourceCaches[i]}getLayerSourceCache(e){const t=aa(e.source,e.scope);return"symbol"===e.type?this._mergedSymbolSourceCaches[t]:this._mergedOtherSourceCaches[t]}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]),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(e,t,i){this.imageManager.getImages(t.images,t.scope,i),this._updateTilesForChangedImages();const r=e=>{if(e){const i=t.images.map((e=>ImageId.toString(e)));e.setDependencies(t.tileID.key,t.type,i)}},n=aa(t.source,t.scope);r(this._mergedOtherSourceCaches[n]),r(this._mergedSymbolSourceCaches[n]),t.images.some((e=>e.iconsetId))&&this.fire(new Event("data",{dataType:"style"}))}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i)}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(e,t,i){return Mi(t,i)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[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]),t}_isSourceCacheLoaded(e){const t=this.getOwnSourceCaches(e);return 0===t.length?(this.fire(new ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):t.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),r="building"===e.type;if(e.is3D(!!this.terrain)){if(i||r||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")}destroy(){this._clearWorkerCaches(),this.fragments.forEach((e=>{e.style._remove()})),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Style.getSourceType=function(e){return xx[e]},Style.setSourceType=function(e,t){xx[e]=t},Style.registerForPluginStateChange=function(e){return e({pluginStatus:Fs,pluginURL:Os}),Us.on("pluginStateChange",e),e};class IndoorManager extends Evented{constructor(e){super(),this._style=e,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},et(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(e){e===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=e,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(e){this._activeFloorsVisible=e,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(e){for(const[t,i]of Object.entries(e.buildings))if(this._buildings[t])for(const e of i.floorIds)this._buildings[t].floors[e]||(this._buildings[t].floors[e]=i.floors[e]);else this._buildings[t]=i;for(const t of e.activeFloors)this._activeFloors.add(t);this._updateIndoorSelector()}getIndoorTileOptions(e,t){const i=this._style.getIndoorSourceLayers(e,t);return i&&this._indoorState?{sourceLayers:i,indoorState:this._indoorState}:null}_updateUI(e,t,i){const r=function(e,t,i,r){let n=null,o=Number.MAX_SAFE_INTEGER;if(r<16)return null;for(const[r,s]of Object.entries(e)){const e=s.center;if(e){const s=t.distanceTo(LngLat.convert(e));s<o&&i.contains(e)&&(o=s,n=r)}}return n}(this._buildings,t,i,e);r!==this._closestBuildingId&&(this._closestBuildingId=r,this._updateIndoorSelector())}_updateIndoorSelector(){const e=this._buildings,t=this._closestBuildingId,i=t&&e?e[t]:void 0;if(!i)return void this.fire(new Event("selector-update",{selectedFloorId:null,activeFloorsVisible:this._activeFloorsVisible,floors:[]}));let r=null;for(const e of i.floorIds)if(this._activeFloors&&this._activeFloors.has(e)){r=e;break}const n=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));this.fire(new Event("selector-update",{selectedFloorId:r,activeFloorsVisible:this._activeFloorsVisible,floors:n}))}_updateActiveFloors(){const e=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:e,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var cb="\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",ub="\n#ifdef DUAL_SOURCE_BLENDING\nlayout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;\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\nvec4 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}\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;}",hb="\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);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const 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(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=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",db="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;}",pb="\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",fb="#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",mb="#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",_b="#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",gb="#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;}",yb="#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",xb="#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 vb=/#include\s+"([^"]+)"/g,bb=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,wb=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,Tb=new Set(["ifdef","ifndef","elif","if","defined"]),Eb=new Set;Lb(cb,Eb),Lb(hb,Eb),Lb(ub,Eb);const Sb={"_prelude_fog.vertex.glsl":fb,"_prelude_terrain.vertex.glsl":pb,"_prelude_shadow.vertex.glsl":yb,"_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":mb,"_prelude_shadow.fragment.glsl":xb,"_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":_b,"_prelude_raster_particle.glsl":gb},Ab={};Rb("",pb),Rb(mb,fb),Rb(xb,yb),Rb(_b,""),Rb(gb,"");const Ib=Rb(ub,hb),Cb=cb,Mb=["\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;",Cb,Ib.fragmentSource].join("\n"),Db=["precision highp float;",Cb,Ib.vertexSource].join("\n");var Pb={background:Rb('#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 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\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 vec2 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#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(a_pos);\n#endif\n}'),backgroundPattern:Rb('#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 vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),building:Rb('#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 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\nfloat hash12(in vec2 p) {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);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {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;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;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;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));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 vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;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) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;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=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\ncolor=applyCutout(color,v_pos.z);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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 vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out 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 vec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(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(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=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;\n#ifdef BUILDING_FAUX_FACADE\nv_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_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=(a_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=(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(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);float height=a_centroid_3.z;depth_offset=min(1000.0,height)*0.0000002;}\n#endif\nv_pos=a_pos_3f;\n#ifdef RENDER_CUTOFF\nvec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_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\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;}'),buildingBloom:Rb("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 vec2 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 vec2 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(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:Rb("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:Rb('#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 vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\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,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);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:Rb("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Rb('#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 vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\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(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\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:Rb("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 vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Rb("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 vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 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() {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(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_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,a_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+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:Rb("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 vec2 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;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Rb("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 vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),elevatedStructuresDepth:Rb("void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=vec4(0.);\n#endif\n}","in vec2 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:Rb("#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);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in vec2 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:Rb('#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;\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 shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor);\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);\n#endif\nglFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;in float a_height;in vec3 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=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(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(a_pos);\n#endif\n}'),fill:Rb('#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\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);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);\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 vec2 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(a_pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:Rb('#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;\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);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);\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 vec2 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(a_pos);\n#endif\n}'),fillOutlinePattern:Rb('#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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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\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);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);\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 vec2 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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\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);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\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(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(a_pos);\n#endif\n}'),fillPattern:Rb('#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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=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\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);\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);\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 vec2 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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 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 vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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);gl_Position=mix(u_matrix*vec4(a_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,a_pos);\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(a_pos);\n#endif\n}'),fillExtrusion:Rb('#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 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\ncolor=applyCutout(color,h);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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 vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nuniform highp float u_vertical_scale;out 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;vec3 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 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\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.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=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);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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;pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);\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 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_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_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.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.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}'),fillExtrusionDepth:Rb("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#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 vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 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\nout highp float v_depth;void 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 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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=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);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_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);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:Rb('#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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=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\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 vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=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);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_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.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:Rb('#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\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 vec2 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(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:Rb("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 vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float 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\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;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=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=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:Rb("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 vec2 a_pos;in vec2 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=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Rb('#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 vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:Rb('#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 lowp vec4 u_trim_color;in vec2 v_width2;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 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 lowp vec4 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 lowp vec4 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.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);alpha=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)/dash.z;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#ifdef MULTIPLY_LINE_GRADIENT_COLOR\nout_color*=color;\n#endif\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);out_color=mix(out_color,u_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\nfloat edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);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);}}\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);\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*opacity);\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);\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 vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec3 a_z_offset_width;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\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 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 float v_gamma_scale;out highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\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 lowp vec4 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 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\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth;\n#ifdef VARIABLE_LINE_WIDTH\nbool left=normal.y==1.0;halfwidth=(u_width_scale*(left ? a_z_offset_width.y : a_z_offset_width.z))/2.0;a_z_offset+=left ? side_z_offset : 0.0;v_normal=side_z_offset > 0.0 && left ? vec2(0.0) : v_normal;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\noffset=-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);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)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_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+a_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+a_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 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];highp float line_progress=a_packed[2];\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\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:Rb('#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 vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 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=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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 vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec3 a_z_offset_width;\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 vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(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;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_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+a_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+a_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/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(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:Rb('#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"\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#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 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;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\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);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);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=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;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)));}float 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);}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\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\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 RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:Rb('#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 vec2 a_pos;in vec2 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=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:Rb("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 float 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(a_index,u_particle_texture_side_len),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:Rb("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 vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Rb('#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 vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:Rb('#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#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\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\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\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);\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);\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 APPEARANCE_ICON 1.0\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 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#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\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance_icon=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance_icon==APPEARANCE_ICON) {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=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(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);float 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=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:Rb('#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 vec2 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:Rb("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:Rb('#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}',db),skyboxGradient:Rb('#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}',db),skyboxCapture:Rb("\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:Rb('#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 vec2 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:Rb('#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:Rb('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform 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 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);\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 vec4 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 vec4 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(pbr.xy);vec2 e_r_m=unpack_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(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:Rb("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\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\nv_depth=gl_Position.z/gl_Position.w;}"),stars:Rb("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_fade_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_fade_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:Rb("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:Rb("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:Rb("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:Rb("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 Lb(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(wb);if(i)for(const e of i)Tb.has(e)||t.add(e)}}function Rb(e,t){const i=new Set,r=[],n=[];e=e.replace(vb,((e,t)=>(n.push(t),""))),t=t.replace(vb,((e,t)=>(r.push(t),"")));let o=new Set(Eb);Lb(e,o),Lb(t,o);for(const e of[...r,...n])Ab[e]||(Ab[e]=new Set,Lb(Sb[e],Ab[e])),o=new Set([...o,...Ab[e]]);return{fragmentSource:e=e.replace(bb,((e,t,r,n,o)=>(i.add(o),"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${r} ${n} ${o};\n#else\nuniform ${r} ${n} u_${o};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${o}\n ${r} ${n} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${r} ${n} ${o};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(bb,((e,t,r,n,o)=>{const s=`MATERIAL_ATTRIBUTE_OFFSET_${o}`,a="float"===n?"vec2":n,l=`GET_ATTRIBUTE_${a}(a_${o}, materialInfo, ${s})`,c=o.match(/color/)?"color":a;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\nin ${r} ${n} a_${o};\n#endif\n`:i.has(o)?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${s})\n in ${r} ${a} a_${o};\n #endif\nout ${r} ${n} ${o};\n#else\nuniform ${r} ${n} u_${o};\n#endif\n`:"initialize"===t?"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${r} ${n} ${o} = u_${o};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${o})\n #ifdef ${s}\n ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${r} ${n} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${r} ${n} a_${o};\n out ${r} ${n} ${o};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${o} = a_${o};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${s})\n in ${r} ${a} a_${o};\n #endif\n#else\nuniform ${r} ${n} u_${o};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${o}0;\nin vec4 a_${o}1;\nin vec4 a_${o}2;\nin vec4 a_${o}3;\n#else\nuniform ${r} ${n} u_${o};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${r} ${a} a_${o};\n#else\nuniform ${r} ${n} u_${o};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${r} ${n} ${o} = a_${o};\n#endif\n`:"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${r} ${n} ${o} = ${l};\n #else\n ${r} ${n} ${o} = a_${o};\n #endif\n#else\n ${r} ${n} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${r} ${n} ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${r} ${n} ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${r} ${n} ${o} = u_${o};\n#endif\n`})),usedDefines:o,vertexIncludes:r,fragmentIncludes:n}}class VertexArrayObject{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,r,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[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!==n||this.boundVertexOffset!==o)this.freshBind(t,i,r,n,o,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));n&&n.dynamicDraw&&n.bind()}}freshBind(e,t,i,r,n,o,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=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o,t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,n);for(const t of i)t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,n);for(const t of o)t&&(t.enableAttributes(l,e),t.bind(),t.setVertexAttribPointers(l,e,n),s&&t.instanceCount&&t.setVertexAttribDivisor(l,e,s));r&&r.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function zb(e,t){const i=Math.pow(2,t.canonical.z),r=t.canonical.y;return[new MercatorCoordinate(0,r/i).toLngLat().lat,new MercatorCoordinate(0,(r+1)/i).toLngLat().lat]}function Fb(e,t,i,r,n,o,s){const a=e.context,l=a.gl,c=i.hillshadeFBO;if(!c)return;e.prepareDrawTile();const u=e.isTileAffectedByFog(t),h=[];e.terrain&&e.terrain.renderingToTexture&&"mrt-fallback"===e.emissiveMode&&h.push("USE_MRT1");const d=e.getOrCreateProgram("hillshade",{overrideFog:u,defines:h});a.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment0.get());const p=((e,t,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o="none"===i.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),s=i.paint.get("hillshade-highlight-color"),a="none"===i.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),l=i.paint.get("hillshade-accent-color"),c="none"===i.paint.get("hillshade-accent-color-use-theme").constantOr("default"),u=i.paint.get("hillshade-emissive-strength");let h=Oe(i.paint.get("hillshade-illumination-direction"));if("viewport"===i.paint.get("hillshade-illumination-anchor"))h-=e.transform.angle;else if(e.style&&e.style.enable3dLights()&&e.style.directionalLight){const t=e.style.directionalLight.properties.get("direction");h=Oe(ut(t.x,t.y,t.z)[1])}const d=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),d),u_image:0,u_latrange:zb(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),h],u_shadow:n.toPremultipliedRenderColor(o?null:i.lut),u_highlight:s.toPremultipliedRenderColor(a?null:i.lut),u_emissive_strength:u,u_accent:l.toPremultipliedRenderColor(c?null:i.lut)}})(e,i,r,e.terrain?t.projMatrix:null);e.uploadCommonUniforms(a,d,t.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:_}=e.getTileBoundsBuffers(i);d.draw(e,l.TRIANGLES,n,o,s,CullFaceMode.disabled,p,r.id,f,m,_)}function Ob(e,t,i){if(!t.needsDEMTextureUpload)return;const r=e.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||e.getTileTexture(i.stride);const o=i.getPixels();t.demTexture?t.demTexture.update(o,{premultiply:!1}):t.demTexture=new Texture(r,o,n.R32F,{premultiply:!1}),t.needsDEMTextureUpload=!1}function Bb(e,t,i){const r=e.context,n=r.gl;if(!t.dem)return;const o=t.dem;if(r.activeTexture.set(n.TEXTURE1),Ob(e,t,o),!t.demTexture)return;t.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE);const s=o.dim;r.activeTexture.set(n.TEXTURE0);let a=t.hillshadeFBO;if(!a){const e=new Texture(r,{width:s,height:s,data:null},n.RGBA8);e.bind(n.LINEAR,n.CLAMP_TO_EDGE),a=t.hillshadeFBO=r.createFramebuffer(s,s,1,"renderbuffer"),a.colorAttachment0.set(e.texture)}r.bindFramebuffer.set(a.framebuffer),r.viewport.set([0,0,s,s]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=e.getMercatorTileBoundsBuffers(),d=[];e.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),e.terrain&&e.terrain.renderingToTexture&&"mrt-fallback"===e.emissiveMode&&d.push("USE_MRT1"),e.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(e,n.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.unblended,CullFaceMode.disabled,((e,t)=>{const i=t.stride,r=l();return S(r,0,Mn,-Mn,0,0,1),f(r,r,[0,-Mn,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ}})(t.tileID,o),i.id,c,u,h),t.needsHillshadePrepare=!1}class BaseValue{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 ClearColor extends BaseValue{getDefault(){return Color.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 ClearDepth extends BaseValue{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class ClearStencil extends BaseValue{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class ColorMask extends BaseValue{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 DepthMask extends BaseValue{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class StencilMask extends BaseValue{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class StencilFunc extends BaseValue{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 StencilOp extends BaseValue{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 StencilTest extends BaseValue{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 DepthRange extends BaseValue{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 DepthTest extends BaseValue{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 DepthFunc extends BaseValue{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Blend extends BaseValue{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 BlendFunc extends BaseValue{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 BlendColor extends BaseValue{getDefault(){return Color.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 BlendEquation extends BaseValue{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 CullFace extends BaseValue{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 CullFaceSide extends BaseValue{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class FrontFace extends BaseValue{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let kb=class Program extends BaseValue{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class ActiveTextureUnit extends BaseValue{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Viewport extends BaseValue{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 BindFramebuffer extends BaseValue{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 BindRenderbuffer extends BaseValue{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 BindTexture extends BaseValue{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 BindVertexBuffer extends BaseValue{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 BindElementBuffer extends BaseValue{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class BindVertexArrayOES extends BaseValue{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class PixelStoreUnpack extends BaseValue{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 PixelStoreUnpackPremultiplyAlpha extends BaseValue{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 PixelStoreUnpackFlipY extends BaseValue{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 FramebufferAttachment extends BaseValue{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class ColorAttachment extends FramebufferAttachment{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 DepthRenderbufferAttachment extends FramebufferAttachment{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 DepthTextureAttachment extends FramebufferAttachment{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 DepthStencilAttachment extends DepthRenderbufferAttachment{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Ub=(e,t,i,r)=>({u_matrix:e,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:i,u_emissive_texture_available:r}),Vb=(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,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:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:_?Float32Array.from(_):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f,u_emissive_texture_available:m});function Nb(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const jb=new class VertexMorphing{constructor(){this.operations={}}newMorphing(e,t,i,r,n){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:r,phase:0,duration:n,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()}},Gb={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Hb(e,t,i){if(0===t)return 0;const r=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function qb(e,t){const i=1<<e.z;return!t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}function $b(e,t){if(!e.style||!e.style.enable3dLights())return;const i=e.context,r=i.gl;i.activeTexture.set(r.TEXTURE1),t?t.bind(r.LINEAR,r.CLAMP_TO_EDGE):e.emptyTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}const Zb=e=>({u_matrix:e});function Wb(e,t,i,r,n){if(n>0){const o=Wt.now(),s=(o-e.timeAdded)/n,a=t?(o-t.timeAdded)/n:-1,l=i.getSource(),c=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),u=!t||Math.abs(t.tileID.overscaledZ-c)>Math.abs(e.tileID.overscaledZ-c),h=u&&e.refreshedUponExpiration?1:He(u?s:1-a,0,1);return t?{opacity:1,mix:1-h,isFading:s<1}:{opacity:h,mix:0,isFading:s<1}}return{opacity:1,mix:0,isFading:!1}}class MockSourceCache extends SourceCache{constructor(e){const t=vx("mock-dem",{type:"raster-dem",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("mock-dem",t,!1),t.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class ProxySourceCache extends SourceCache{constructor(e){const t=vx("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new Tile(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom,void 0,void 0,this._source.worldview);t.state="loaded",this._tiles[i.key]=t}return t}),{});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 ProxiedTileID extends OverscaledTileID{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 Terrain extends Elevation{constructor(e,t){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,n]=function(e){const t=new StructArrayLayout2i4,i=new StructArrayLayout3ui6,r=131;t.reserve(17161),i.reserve(33800);const n=Mn/128,o=Mn+n/2,s=o+n;for(let e=-n;e<s;e+=n)for(let i=-n;i<s;i+=n){const r=i<0||i>o||e<0||e>o?24575:0,n=He(Math.round(i),0,Mn),s=He(Math.round(e),0,Mn);t.emplaceBack(n+r,s)}const a=(e,t)=>{const n=t*r+e;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+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]}(),o=e.context;this.gridBuffer=o.createVertexBuffer(i,oc.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=SegmentVector.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=SegmentVector.simpleSegment(0,0,i.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new ProxySourceCache(t.map),this.orthoMatrix=l(),S(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,Mn,0,Mn,0,1);const s=o.gl;this._overlapStencilMode=new StencilMode({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=t,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new MockSourceCache(t.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(e,t,i){if(e&&e.terrain){this._style!==e&&(this.style=e,this._evaluationZoom=void 0);const r=e.terrain.properties,n=0===e.terrain.drapeRenderMode,o=e.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=Wt.now();const s=e.terrain&&e.terrain.scope,a=r.get("source"),l=n?this._mockSourceCache:e.getSourceCache(a,s);if(!l)return void st(`Couldn't find terrain source "${a}".`);if(this.sourceCache=l,this._attenuationRange=e.terrain.getAttenuationRange(),this._exaggeration=o?this.calculateExaggeration(t):r.get("exaggeration"),!t.projection.requiresDraping&&o&&0===this._exaggeration)return void this._disable();this.enabled=!0;const c=()=>{this.sourceCache.used&&st(`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 e=this.getScaledDemTileSize();this.sourceCache.update(t,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,c(),this._initializing=!0),c(),t.updateElevation(!0,i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(t),this._emptyDEMTextureDirty=!0,this._previousZoom=t.zoom}else this._disable()}calculateExaggeration(e){if(this._attenuationRange&&e.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(e.zoom);const t=this._previousCameraAltitude,i=e.getFreeCameraOptions().position.z/e.pixelsPerMeter*e.worldSize;this._previousCameraAltitude=i;const r=null!=t?i-t:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const n=e.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(n);let s=n-this._previousZoom;const a=this._previousUpdateTimestamp;let l=n;null!=this._evaluationZoom&&(l=this._evaluationZoom,Math.abs(n-l)>.5&&(s=.5*(n-l+s)),s*r<0&&(l+=s)),this._evaluationZoom=l;const c=o.getExaggeration(l),u=c===o.getExaggeration(Math.max(0,l-.1));if(u&&Math.abs(c-this._exaggeration)<.01)return c;let h=Math.min(.1,.00375*(this._updateTimestamp-a));return(u||c<.1||Math.abs(s)<1e-4)&&(h=Math.min(.2,4*h)),xr(this._exaggeration,c,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(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const t=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(MercatorCoordinate.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=t.getIds().map((e=>{const r=t.getTileByID(e).tileID;return r.projMatrix=i.calculateProjMatrix(r.toUnwrapped()),r}));!function(e,t){const i=t.transform.pointCoordinate(t.transform.getCameraPoint()),r=new Le(i.x,i.y);e.sort(((e,t)=>{if(t.overscaledZ-e.overscaledZ)return t.overscaledZ-e.overscaledZ;const i=new Le(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),n=new Le(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=r.mult(1<<e.canonical.z);return o.x-=.5,o.y-=.5,o.distSqr(i)-o.distSqr(n)}))}(r,this.painter);const n=this.proxyToSource||{};this.proxyToSource={},r.forEach((e=>{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const o=this._style._mergedSourceCaches;for(const t in o){const i=o[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],n),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[t.id]=r.map((e=>new ProxiedTileID(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1;const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in s||(this._visibleDemTiles.push(t),s[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 r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Ob(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=o,!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 r=i.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const e=this.painter.context,t=e.gl;e.activeTexture.set(t.TEXTURE2);const i=this._getLoadedAreaMinimum(),r=new Float32Image({width:1,height:1},new Float32Array([i]));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new Texture(e,r,t.R32F,{premultiply:!1}),n}setupElevationDraw(e,t,i){const r=this.painter.context,n=r.gl,o={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.u_exaggeration=this.exaggeration();let s=null,a=null,l=1;if(i&&i.morphing&&this._useVertexMorphing){const t=i.morphing.srcDemTile,r=i.morphing.dstDemTile;l=i.morphing.phase,t&&r&&(this._prepareDemTileUniforms(e,t,o,"_prev")&&(a=t),this._prepareDemTileUniforms(e,r,o)&&(s=r))}const c=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?n.LINEAR:n.NEAREST;let u=null;var h;if(this.enabled?a&&s?(u=s.demTexture,r.activeTexture.set(n.TEXTURE4),a.demTexture.bind(c(a),n.CLAMP_TO_EDGE),o.u_dem_lerp=l):(s=this.terrainTileForTile[e.tileID.key],u=this._prepareDemTileUniforms(e,s,o)?s.demTexture:this.emptyDEMTexture):u=this.emptyDEMTexture,r.activeTexture.set(n.TEXTURE2),u&&(o.u_dem_size=1===(h=u).size[0]?1:h.size[0]-2,u.bind(c(s),n.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(i&&i.useDepthForOcclusion,t,o),i&&i.useMeterToDem&&s){const e=(1<<s.tileID.canonical.z)*tl(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;o.u_meter_to_dem=e}if(i&&i.labelPlaneMatrixInv&&(o.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),t.setTerrainUniformValues(r,o),"globe"===this.painter.transform.projection.name){const n=this.globeUniformValues(this.painter.transform,e.tileID.canonical,i&&i.useDenormalizedUpVectorScale);t.setGlobeUniformValues(r,n)}}globeUniformValues(e,t,i){const r=e.projection;return{u_tile_tl_up:r.upVector(t,0,0),u_tile_tr_up:r.upVector(t,Mn,0),u_tile_br_up:r.upVector(t,Mn,Mn),u_tile_bl_up:r.upVector(t,0,Mn),u_tile_up_scale:i?sc(1):r.upVectorScale(t,e.center.lat,e.worldSize).metersToTile}}renderToBackBuffer(e){const t=this.painter,i=this.painter.context;0!==e.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),t.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(e,t,i,r,n){if("globe"===e.transform.projection.name)!function(e,t,i,r,n){const o=e.context,s=o.gl;let a,c;const u=e.transform,h=Cc(e,0,u),d=(t,i)=>{if(c===i)return;const r=[Gb[i],"PROJECTION_GLOBE_VIEW"];h&&r.push("CUSTOM_ANTIALIASING");const n=e.isTileAffectedByFog(t);a=e.getOrCreateProgram("globeRaster",{defines:r,overrideFog:n}),c=i},p=e.colorModeForRenderPass(),f=new DepthMode(s.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);jb.update(n);const _=Sc(u),g=[Qa(u.center.lng),el(u.center.lat)],y=e.globeSharedBuffers,x=[u.width*Wt.devicePixelRatio,u.height*Wt.devicePixelRatio],v=Float32Array.from(u.globeMatrix),b={useDenormalizedUpVectorScale:!0};{const l=e.transform,u=Hb(l.zoom,t.exaggeration(),t.sourceCache._source.tileSize);c=-1;const h=s.TRIANGLES;for(const c of r){const r=i.getTile(c),m=StencilMode.disabled,w=t.prevTerrainTileForTile[c.key],T=t.terrainTileForTile[c.key];Nb(w,T)&&jb.newMorphing(c.key,w,T,n,250),$b(e,r.emissiveTexture),o.activeTexture.set(s.TEXTURE0),r.texture&&r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const E=jb.getMorphValuesForProxy(c.key),S=E?1:0;E&&Object.assign(b,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:Ue(E.phase)}});const A=mc(c.canonical),I=Dc(A.getCenter().lat),C=Mc(c.canonical,A,I,l.worldSize/l._pixelsPerMercatorPixel),M=vc(uc(c.canonical)),D="mrt-fallback"===e.emissiveMode?1:0,P=Vb(l.expandedFarZProjMatrix,v,_,M,Ac(l.zoom),g,l.frustumCorners.TL,l.frustumCorners.TR,l.frustumCorners.BR,l.frustumCorners.BL,l.globeCenterInViewSpace,l.globeRadius,x,u,l._farZ,D,C);if(d(c,S),a&&(t.setupElevationDraw(r,a,b),e.uploadCommonUniforms(o,a,c.toUnwrapped()),y)){const[t,i,r]=y.getGridBuffers(I,0!==u);a.draw(e,h,f,m,p,CullFaceMode.backCCW,P,"globe_raster",t,i,r)}}}if(y&&(e.renderDefaultNorthPole||e.renderDefaultSouthPole)){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&n.push("CUSTOM_ANTIALIASING"),a=e.getOrCreateProgram("globeRaster",{defines:n});for(const n of r){const{x:r,y:c,z:h}=n.canonical,d=0===c,_=c===(1<<h)-1,[v,w,T,E]=y.getPoleBuffers(h,!1);if(E&&(d||_)){const c=i.getTile(n);$b(e,c.emissiveTexture),o.activeTexture.set(s.TEXTURE0),c.texture&&c.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);let y=Ic(h,r,u);const S=vc(uc(n.canonical)),A="mrt-fallback"===e.emissiveMode?1:0,I=(t,i)=>t.draw(e,s.TRIANGLES,f,StencilMode.disabled,p,CullFaceMode.disabled,Vb(u.expandedFarZProjMatrix,y,y,S,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,x,0,u._farZ,A),"globe_pole_raster",i,T,E);t.setupElevationDraw(c,a,b),e.uploadCommonUniforms(o,a,n.toUnwrapped()),d&&e.renderDefaultNorthPole&&I(a,v),_&&e.renderDefaultSouthPole&&(y=m(l(),y,[1,-1,1]),I(a,w))}}}}(e,t,i,r,n);else{const o=e.context,s=o.gl;let a,l;const c=e.shadowRenderer,u=Zv(e,e.longestCutoffRange),h=t=>{if(l===t)return;const i=[];i.push(Gb[t]),u.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),c&&(i.push("RENDER_SHADOWS","DEPTH_TEXTURE"),c.useNormalOffset&&i.push("NORMAL_OFFSET")),a=e.getOrCreateProgram("terrainRaster",{defines:i}),l=t},d=e.colorModeForRenderPass(),p=new DepthMode(s.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);jb.update(n);const f=e.transform,m=Hb(f.zoom,t.exaggeration(),t.sourceCache._source.tileSize);let _=[0,0,0];if(c){const t=e.style.directionalLight,i=e.style.ambientLight;t&&i&&(_=Kv(e.style,t,i))}{l=-1;const g=s.TRIANGLES,[y,x]=[t.gridIndexBuffer,t.gridSegments];for(const l of r){const r=i.getTile(l),v=StencilMode.disabled,b=t.prevTerrainTileForTile[l.key],w=t.terrainTileForTile[l.key];Nb(b,w)&&jb.newMorphing(l.key,b,w,n,250),$b(e,r.emissiveTexture),o.activeTexture.set(s.TEXTURE0),r.texture&&r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const T=jb.getMorphValuesForProxy(l.key),E=T?1:0;let S;T&&(S={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:Ue(T.phase)}});const A="mrt-fallback"===e.emissiveMode?1:0,I=Ub(l.projMatrix,qb(l.canonical,f.renderWorldCopies)?m/10:m,_,A);if(h(E),!a)continue;t.setupElevationDraw(r,a,S);const C=l.toUnwrapped();c&&c.setupShadows(C,a),e.uploadCommonUniforms(o,a,C,null,u),a.draw(e,g,p,v,d,CullFaceMode.backCCW,I,"terrain_raster",t.gridBuffer,y,x)}}}}(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,t.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const t=this.painter,i=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],o=this._drapedRenderBatches.shift(),s=t.style.order,a=[];this._updateFBOs("mrt-fallback"===t.emissiveMode);let l=0;for(const c of n){const n=r.getTileByID(c.proxyTileKey),u=r.proxyCachedFBO[c.key]?r.proxyCachedFBO[c.key][e]:void 0,h=void 0!==u?r.renderCache[u]:this.pool[l++],d=void 0!==u;if(n.texture=h.tex,n.emissiveTexture=h.emissiveTex,d&&!h.dirty){a.push(n.tileID);continue}i.bindFramebuffer.set(h.fb.framebuffer);const p=i.gl;let f;p.drawBuffers("mrt-fallback"===t.emissiveMode?[p.COLOR_ATTACHMENT0,p.COLOR_ATTACHMENT1]:[p.COLOR_ATTACHMENT0]),this.renderedToTile=!1,h.dirty&&(i.clear({color:Color.transparent,stencil:0}),h.dirty=!1);for(let e=o.start;e<=o.end;++e){const r=t.style._mergedLayers[s[e]];if(r.isHidden(t.transform.zoom))continue;const n=t.style.getLayerSourceCache(r),o=n?this.proxyToSource[c.key][n.id]:[c];if(!o)continue;const a=o;i.viewport.set([0,0,h.fb.width,h.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(h,o,r,n),f=n?n.id:null),t.renderLayer(t,n,r,a)}if(p.drawBuffers([p.COLOR_ATTACHMENT0]),0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const r=t.style._mergedLayers[s[e]];if(r.isHidden(t.transform.zoom))continue;const n=t.style.getLayerSourceCache(r),o=n?this.proxyToSource[c.key][n.id]:[c];if(!o)continue;const a=o;i.viewport.set([0,0,h.fb.width,h.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(h,o,r,n),f=n?n.id:null),t.renderLayer(t,n,r,a)}this.renderedToTile?(h.dirty=!0,a.push(n.tileID)):d||--l,5===l&&(l=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),o.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,r=t;for(let n=0;n<t;++n)this._style.isLayerDraped(e._mergedLayers[e.order[n]])?i=Math.max(i,n):r=Math.min(r,n);return r>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 r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const n=r.tileID,o=1<<n.overscaledZ,{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,u=a/o,h=(a+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:r.dem.tree.raycastRoot(l,u,c,h,e,t,i),tile:r}}));r.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,t=e.gl,i=this.drapeBufferSize;e.activeTexture.set(t.TEXTURE0);const r=new Texture(e,{width:i[0],height:i[1],data:null},t.RGBA8);r.bind(t.LINEAR,t.CLAMP_TO_EDGE);const n=e.createFramebuffer(i[0],i[1],1,null);let o;return n.colorAttachment0.set(r.texture),this._emissiveTexture&&(o=new Texture(e,{width:i[0],height:i[1],data:null},t.R8),o.bind(t.LINEAR,t.CLAMP_TO_EDGE),n.createColorAttachment(e,1),n.colorAttachment1.set(o.texture)),n.depthAttachment=new DepthStencilAttachment(e,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:n,tex:r,emissiveTex:o,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(e,t){const i=e.fb,r=this.painter.context,n=r.gl,o=this.drapeBufferSize;if(t){const t=new Texture(r,{width:o[0],height:o[1],data:null},n.R8);t.bind(n.LINEAR,n.CLAMP_TO_EDGE),e.emissiveTex=t,i.createColorAttachment(r,1),i.colorAttachment1.set(t.texture)}else e.emissiveTex=void 0,i.removeColorAttachment(r,1);e.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 e=!1;for(const t of this._style.getSources())if(t instanceof VectorTileSource){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]],r=this._style.getLayerSourceCache(i);if(!r||t[r.id])continue;if(i.isHidden(this.painter.transform.zoom)||"line"!==i.type)continue;const n=i.widthExpression(),o=i.emissiveStrengthExpression();if(n instanceof ZoomDependentExpression||o instanceof ZoomDependentExpression){t[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 RasterTileSource){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]],r=this._style.getLayerSourceCache(i);if(!r||t[r.id])continue;if(i.isHidden(this.painter.transform.zoom)||"raster"!==i.type)continue;const n=i.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t){const t=Wb(r.getTile(e),r.findLoadedParent(e,0),r,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(r.id,e)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();const e=this._style.order,t=e.length;if(0===t)return;const i=[];this._pendingGroundEffectLayers=[];let r,n=0,o=this._style._mergedLayers[e[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<t;)o=this._style._mergedLayers[e[n]];for(;n<t;++n){const t=this._style._mergedLayers[e[n]];t.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(t)?void 0===r&&(r=n):("fill-extrusion"===t.type&&this._pendingGroundEffectLayers.push(n),void 0!==r&&(i.push({start:r,end:n-1}),r=void 0)))}if(void 0!==r&&i.push({start:r,end:n-1}),0!==i.length){const e=i[i.length-1],t=this._pendingGroundEffectLayers.every((t=>t>e.end));t||st("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=i}_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 r=Object.values(e[i]);t.renderCachePool.push(...r)}}return}this._clearRasterLayersFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.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[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.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:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.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):StencilMode.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(ColorMode.disabled),r.setDepthMode(DepthMode.disabled);const o=i.getOrCreateProgram("clippingMask");for(const r of e){const e=i._tileClippingMaskIDs[r.key]=--t;o.draw(i,n.TRIANGLES,DepthMode.disabled,new StencilMode({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),ColorMode.disabled,CullFaceMode.disabled,Zb(r.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(e){const t=this.painter.transform;if(e.x<0||e.x>t.width||e.y<0||e.y>t.height)return null;const i=[e.x,e.y,1,1];se(i,i,t.pixelMatrixInverse),ne(i,i,1/i[3]),i[0]/=t.worldSize,i[1]/=t.worldSize;const r=t._camera.position,n=tl(1,t.center.lat),o=[r[0],r[1],r[2]/n,0],s=R([],i.slice(0,3),o);G(s,s);const a=this.raycast(o,s,this._exaggeration);return null!==a&&a?(k(o,o,s,a),o[3]=o[2],o[2]*=n,o):null}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof ImageSource)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],n=this.proxyCoords;for(let t=0;t<n.length;t++){const o=n[t],s=this._findTileCoveringTileID(o,e);if(s){const t=this._createProxiedId(o,s,i[o.key]&&i[o.key][e.id]);r.push(t),this.proxyToSource[o.key][e.id]=[t]}}let o=!1;const s=new Set;for(let n=0;n<t.length;n++){const a=e.getTile(t[n]);if(!a||!a.hasData())continue;const l=this._findTileCoveringTileID(a.tileID,this.proxySourceCache);if(l&&l.tileID.canonical.z!==a.tileID.canonical.z){const t=this.proxyToSource[l.tileID.key][e.id],n=this._createProxiedId(l.tileID,a,i[l.tileID.key]&&i[l.tileID.key][e.id]);t?t.splice(t.length-1,0,n):this.proxyToSource[l.tileID.key][e.id]=[n];const c=this.proxyToSource[l.tileID.key][e.id];s.has(c)||s.add(c),r.push(n),o=!0}}if(this._sourceTilesOverlap[e.id]=o,o&&this._debugParams.sortTilesHiZFirst)for(const e of s)e.sort(((e,t)=>t.overscaledZ-e.overscaledZ))}_setupProxiedCoordsForImageSource(e,t,i){if(!e.getSource().loaded())return;const r=this.proxiedCoords[e.id]=[],n=this.proxyCoords,o=e.getSource(),s=o.tileID;if(!s)return;const a=new Le(s.x,s.y)._div(1<<s.z),l=o.coordinates.map(MercatorCoordinate.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-a.x),e.min.y=Math.min(e.min.y,t.y-a.y),e.max.x=Math.max(e.max.x,t.x-a.x),e.max.y=Math.max(e.max.y,t.y-a.y),e)),{min:new Le(Number.MAX_VALUE,Number.MAX_VALUE),max:new Le(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,t)=>{const i=e.wrap+e.canonical.x/(1<<e.canonical.z),r=e.canonical.y/(1<<e.canonical.z),n=Mn/(1<<e.canonical.z),o=t.wrap+t.canonical.x/(1<<t.canonical.z),s=t.canonical.y/(1<<t.canonical.z);return i+n<o+l.min.x||i>o+l.max.x||r+n<s+l.min.y||r>s+l.max.y};for(let o=0;o<n.length;o++){const s=n[o];for(let n=0;n<t.length;n++){const o=e.getTile(t[n]);if(!o||!o.hasData())continue;if(c(s,o.tileID))continue;const a=this._createProxiedId(s,o,i[s.key]&&i[s.key][e.id]),l=this.proxyToSource[s.key][e.id];l?l.push(a):this.proxyToSource[s.key][e.id]=[a],r.push(a)}}}_createProxiedId(e,t,i){let r=this.orthoMatrix;if(i){const e=i.find((e=>e.key===t.tileID.key));if(e)return e}if(t.tileID.key!==e.key){const i=e.canonical.z-t.tileID.canonical.z;let n,o,s;r=l();const a=t.tileID.wrap-e.wrap<<e.overscaledZ;i>0?(n=Mn>>i,o=n*((t.tileID.canonical.x<<i)-e.canonical.x+a),s=n*((t.tileID.canonical.y<<i)-e.canonical.y)):(n=Mn<<-i,o=Mn*(t.tileID.canonical.x-(e.canonical.x+a<<-i)),s=Mn*(t.tileID.canonical.y-(e.canonical.y<<-i))),S(r,0,n,0,n,0,1),f(r,r,[o,s,0])}return new ProxiedTileID(t.tileID,e.key,r)}_findTileCoveringTileID(e,t){let i=t.getTile(e);if(i&&i.hasData())return i;const r=this._findCoveringTileCache[t.id],n=r[e.key];if(i=n?t.getTileByID(n):null,i&&i.hasData()||null===n)return i;let o=i?i.tileID:e,s=o.overscaledZ;const a=t.getSource().minzoom,l=[];if(!n){const r=t.getSource().maxzoom;if(e.canonical.z>=r){const i=e.canonical.z-r;t.getSource().reparseOverscaled?(s=Math.max(e.canonical.z+2,t.transform.tileZoom),o=new OverscaledTileID(s,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i)):0!==i&&(s=r,o=new OverscaledTileID(s,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i))}o.key!==e.key&&(l.push(o.key),i=t.getTile(o))}const c=e=>{l.forEach((t=>{r[t]=e})),l.length=0};for(s-=1;s>=a&&(!i||!i.hasData());s--){i&&c(i.tileID.key);const e=o.calculateScaledKey(s);if(i=t.getTileByID(e),i&&i.hasData())break;const n=r[e];if(null===n)break;void 0===n?l.push(e):i=t.getTileByID(n)}return c(i?i.tileID.key:null),i&&i.hasData()?i: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 Xb(e,t,i){const r=function(e,t,i){const r=H(t,e),n=H(i,[.2126,.7152,.0722]),o=(e,t,i)=>(1-i)*e+i*t,s=o(1-.3*Math.min(n,1),1,Math.min(r+1,1));return o(.92,1,Math.asin(He(t[2],-1,1))/Math.PI+.5)*s}(e,[0,0,1],t),n=[0,0,0];B(n,i.slice(0,3),r);const o=[0,0,0];B(o,t.slice(0,3),e[2]);const s=[0,0,0];return L(s,n,o),vt(s)}const Yb=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Kb=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class Program{static cacheKey(e,t,i,r){const n=[t];r&&n.push(r.cacheKey);for(const t of i)e.usedDefines.has(t)&&n.push(t);return n.join("/")}constructor(e,t,i,r,n,o){const s=e.gl;this.program=s.createProgram(),this.configuration=r,this.name=t,this.fixedDefines=[...o];const a=`#version 300 es\n${(r?r.defines():[]).concat(o.map((e=>`#define ${e}`))).join("\n")}`,l=[a,Mb];for(const e of i.fragmentIncludes)l.push(Sb[e]);l.push(i.fragmentSource);const c=l.join("\n"),u=[a,Db];for(const e of i.vertexIncludes)u.push(Sb[e]);this.forceManualRenderingForInstanceIDShaders=e.forceManualRenderingForInstanceIDShaders&&i.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&u.push("uniform int u_instanceID;"),u.push(i.vertexSource);let h=u.join("\n");this.forceManualRenderingForInstanceIDShaders&&(h=h.replaceAll("gl_InstanceID","u_instanceID"));const d=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(d,c),s.compileShader(d),s.attachShader(this.program,d);const p=s.createShader(s.VERTEX_SHADER);s.isContextLost()?this.failedToCreate=!0:(s.shaderSource(p,h),s.compileShader(p),s.attachShader(this.program,p),this.attributes={},s.linkProgram(this.program),s.deleteShader(p),s.deleteShader(d),this.fixedUniforms=n(e),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=r?r.getUniforms(e):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(e=>({u_instanceID:new Uniform1i(e)}))(e)),(o.includes("TERRAIN")||t.includes("symbol")||t.includes("circle"))&&(this.terrainUniforms=(e=>({u_dem:new Uniform1i(e),u_dem_prev:new Uniform1i(e),u_dem_tl:new Uniform2f(e),u_dem_scale:new Uniform1f(e),u_dem_tl_prev:new Uniform2f(e),u_dem_scale_prev:new Uniform1f(e),u_dem_size:new Uniform1f(e),u_dem_lerp:new Uniform1f(e),u_exaggeration:new Uniform1f(e),u_depth:new Uniform1i(e),u_depth_size_inv:new Uniform2f(e),u_depth_range_unpack:new Uniform2f(e),u_occluder_half_size:new Uniform1f(e),u_occlusion_depth_offset:new Uniform1f(e),u_meter_to_dem:new Uniform1f(e),u_label_plane_matrix_inv:new UniformMatrix4f(e)}))(e)),o.includes("GLOBE")&&(this.globeUniforms=(e=>({u_tile_tl_up:new Uniform3f(e),u_tile_tr_up:new Uniform3f(e),u_tile_br_up:new Uniform3f(e),u_tile_bl_up:new Uniform3f(e),u_tile_up_scale:new Uniform1f(e)}))(e)),o.includes("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new UniformMatrix4f(e),u_fog_range:new Uniform2f(e),u_fog_color:new Uniform4f(e),u_fog_horizon_blend:new Uniform1f(e),u_fog_vertical_limit:new Uniform2f(e),u_fog_temporal_offset:new Uniform1f(e),u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_globe_pos:new Uniform3f(e),u_globe_radius:new Uniform1f(e),u_globe_transition:new Uniform1f(e),u_is_globe:new Uniform1i(e),u_viewport:new Uniform2f(e)}))(e)),o.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(e=>({u_cutoff_params:new Uniform4f(e)}))(e)),o.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(e=>({u_lighting_ambient_color:new Uniform3f(e),u_lighting_directional_dir:new Uniform3f(e),u_lighting_directional_color:new Uniform3f(e),u_ground_radiance:new Uniform3f(e)}))(e)),o.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(e=>({u_light_matrix_0:new UniformMatrix4f(e),u_light_matrix_1:new UniformMatrix4f(e),u_fade_range:new Uniform2f(e),u_shadow_normal_offset:new Uniform3f(e),u_shadow_intensity:new Uniform1f(e),u_shadow_texel_size:new Uniform1f(e),u_shadow_map_resolution:new Uniform1f(e),u_shadow_direction:new Uniform3f(e),u_shadow_bias:new Uniform3f(e),u_shadowmap_0:new Uniform1i(e),u_shadowmap_1:new Uniform1i(e)}))(e)))}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(e,t,i,r,n,o,s,a,l,c){const u=e.options.wireframe;if(!1===u.terrain&&!1===u.layers2D&&!1===u.layers3D)return;const h=e.context;if(!(()=>!(!u.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!u.layers2D||e._terrain&&e._terrain.renderingToTexture||!Yb.includes(this.name))||!(!u.layers3D||!Kb.includes(this.name)))())return;const d=h.gl,p=e.wireframeDebugCache.getLinesFromTrianglesBuffer(e.frameCounter,n,h);if(!p)return;const f=[...this.fixedDefines,"DEBUG_WIREFRAME"],m=e.getOrCreateProgram(this.name,{config:this.configuration,defines:f});h.program.set(m.program);const _=(e,t,i)=>{if(t[e]&&i[e])for(const r in t[e])i[e][r]&&i[e][r].set(i.program,r,t[e][r].current)};l&&l.setUniforms(m.program,h,m.binderUniforms,s,{zoom:a}),_("fixedUniforms",this,m),_("terrainUniforms",this,m),_("globeUniforms",this,m),_("fogUniforms",this,m),_("lightsUniforms",this,m),_("shadowUniforms",this,m),p.bind(),h.setColorMode(new ColorMode([d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE],Color.transparent,[!0,!0,!0,!1])),h.setDepthMode(new DepthMode(t.func===d.LESS?d.LEQUAL:t.func,DepthMode.ReadOnly,t.range)),h.setStencilMode(StencilMode.disabled);const g=3*o.primitiveLength*2,y=3*o.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=c||1;for(let t=0;t<e;++t)m.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",t),d.drawElements(d.LINES,g,d.UNSIGNED_SHORT,y)}else c&&c>1?d.drawElementsInstanced(d.LINES,g,d.UNSIGNED_SHORT,y,c):d.drawElements(d.LINES,g,d.UNSIGNED_SHORT,y);n.bind(),h.program.set(this.program),h.setDepthMode(t),h.setStencilMode(i),h.setColorMode(r)}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const r of Object.keys(i))if(!i[r].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${r} not set but required by ${t} being defined`)}draw(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const _=e.context,g=_.gl;if(this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(i),_.setStencilMode(r),_.setColorMode(n),_.setCullFace(o);for(const[e,t]of this.fixedUniformsEntries)t.set(this.program,e,s[e]);p&&p.setUniforms(this.program,_,this.binderUniforms,h,{zoom:d});const y={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const x=f||[],v=p?p.getPaintVertexBuffers():[],b=t===g.TRIANGLES&&c,w=m&&m>0?1:void 0;for(const o of u.get()){const s=o.vaos||(o.vaos={});if((s[a]||(s[a]=new VertexArrayObject)).bind(_,this,l,v,c,o.vertexOffset,x,w),this.forceManualRenderingForInstanceIDShaders){const e=m||1;for(let i=0;i<e;++i)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",i),c?g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2):g.drawArrays(t,o.vertexOffset,o.vertexLength)}else m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):c?g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2):g.drawArrays(t,o.vertexOffset,o.vertexLength);b&&this._drawDebugWireframe(e,i,r,n,c,o,h,d,p,m)}}}function Jb(e,t,i=0){const r=Math.pow(2,t.tileID.overscaledZ),n=t.tileSize*Math.pow(2,e.transform.tileZoom)/r,o=n*(t.tileID.canonical.x+t.tileID.wrap*r),s=n*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/Hp(t,1,e.transform.tileZoom),u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s],u_pattern_transition:i}}const Qb={terrain:0,flat:1},ew=l(),tw=(e,t,i,n,o,s,l,c,u,h,d,p,f,m,_,g,y,x)=>{const v=t.style.light,b=v.properties.get("position"),w=[b.x,b.y,b.z],T=r();"viewport"===v.properties.get("anchor")&&(a(T,-t.transform.angle),W(w,w,T));const E=v.properties.get("color").toPremultipliedRenderColor(null),S=t.transform,A={u_matrix:e,u_lightpos:w,u_lightintensity:v.properties.get("intensity"),u_lightcolor:[E.r,E.g,E.b],u_vertical_gradient:+i,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ew,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:Qb[h],u_base_type:Qb[d],u_ao:o,u_edge_radius:s,u_width_scale:l,u_flood_light_color:_,u_vertical_scale:g,u_flood_light_intensity:y,u_ground_shadow_factor:x};return"globe"===S.projection.name&&(A.u_tile_id=[c.canonical.x,c.canonical.y,1<<c.canonical.z],A.u_zoom_transition=p,A.u_inv_rot_matrix=m,A.u_merc_center=f,A.u_up_dir=S.projection.upVector(new CanonicalTileID(0,0,0),f[0]*Mn,f[1]*Mn),A.u_height_lift=u),A},iw=(e,t,i,r,n,o)=>({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:r,u_height_type:Qb[n],u_base_type:Qb[o]}),rw=(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g)=>{const y=tw(e,t,i,r,n,o,s,a,c,u,h,d,p,f,m,_,1,[0,0,0]),x={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(y,Jb(t,l,g),x)},nw=(e,t,i,r,n,o,s,a,l,c,u)=>({u_matrix:t,u_opacity:i,u_ao_pass:r?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:u,u_dynamic_offset:1}),ow=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i}),sw=(e,t,i,r,n,o=0)=>Object.assign(ow(e,t,n),Jb(i,r,o)),aw=(e,t,i,r)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:r}),lw=(e,t,i,r,n,o,s=0)=>Object.assign(sw(e,t,i,r,o,s),{u_world:n}),cw=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),uw=(e,t,i,r,n)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:r,u_reset_depth:n}),hw=(e,t,i,r,n,o,s,a,l)=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:r,u_camera_pos:n,u_tile_to_meter:o,u_facade_emissive_chance:s,u_flood_light_color:a,u_flood_light_intensity:l}),dw=e=>({u_matrix:e}),pw=e=>({u_matrix:e}),fw=(e,t,i,r,n,o,s,a)=>{const l=Mn/o.tileSize;return{u_matrix:e,u_inv_rot_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(a),u_extrude_scale:[i.pixelsToGLUnits[0]/l,i.pixelsToGLUnits[1]/l],u_zoom_transition:r,u_tile_id:s,u_merc_center:n}},mw=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),_w=l(),gw=(e,t,i,r,n,o,s)=>{const a=e.transform,l="globe"===a.projection.name,c=l?Tc(a.zoom,t.canonical)*a._pixelsPerMercatorPixel:Hp(i,1,o),u={u_matrix:t.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:_w,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=r,u.u_merc_center=n,u.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],u.u_zoom_transition=Ac(a.zoom);const e=n[0]*Mn,i=n[1]*Mn;u.u_up_dir=a.projection.upVector(new CanonicalTileID(0,0,0),e,i)}return u};function yw(e,[t,i,r,n],[o,s]){if(o===s)return[0,0,0,0];const a=255*(e-1)/(e*(s-o));return[t*a,i*a,r*a,n*a]}function xw(e,t,[i,r]){return i===r?0:.5/e+(t-i)*(e-1)/(e*(r-i))}const vw=(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:r,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity*h.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:h.paint.get("raster-brightness-min"),u_brightness_high:h.paint.get("raster-brightness-max"),u_saturation_factor:Et(h.paint.get("raster-saturation")),u_contrast_factor:Tt(h.paint.get("raster-contrast")),u_spin_weights:bw(h.paint.get("raster-hue-rotate")),u_perspective_transform:d,u_raster_elevation:p,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l,u_colorization_mix:yw(qm,m,g),u_colorization_offset:xw(qm,_,g),u_color_ramp:f,u_texture_offset:[x/(y+2*x),y/(y+2*x)],u_texture_res:[y+2*x,y+2*x],u_emissive_strength:v});function bw(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 ww=.05,Tw=(e,t,i,r,n,o,s,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:r,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Ew=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:r,u_color_ramp:o,u_velocity_res:n,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:[ww,ww]}),Sw=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:r,u_max_speed:n,u_speed_factor:o,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:[ww,ww]}),Aw=l(),Iw=(e,t,i,r,n,o,s,a,c,u,h,p,f,m,_,g,y,x,v,b,w,T,E,S)=>{const A=n.transform,I={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:A.getCameraToCenterDistance(v),u_rotate_symbol:+i,u_aspect_ratio:A.width/A.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:s,u_coord_matrix:a,u_is_text:+u,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:h,u_texsize_icon:p,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Aw,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Aw,u_up_vector:[0,-1,0],u_color_adj_mat:T,u_icon_transition:E||0,u_gamma_scale:r?n.transform.getCameraToCenterDistance(v)*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:Wt.devicePixelRatio,u_is_halo:1,u_scale_factor:S||1,u_ground_shadow_factor:b,u_inv_matrix:d(l(),s),u_normal_scale:w,u_lutTexture:qv.LUT};return"globe"===v.name&&(I.u_tile_id=[m.canonical.x,m.canonical.y,1<<m.canonical.z],I.u_zoom_transition=_,I.u_inv_rot_matrix=y,I.u_merc_center=g,I.u_camera_forward=A._camera.forward(),I.u_ecef_origin=function(e,t){const i=[0,0,0];return Z(i,i,vc(uc(t.canonical))),Z(i,i,e),i}(A.globeMatrix,m.toUnwrapped()),I.u_tile_matrix=Float32Array.from(A.globeMatrix),I.u_up_vector=x),I},Cw=(e,t,i,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:r}),Mw=(e,t,i,r,n,o,s,a,l)=>Object.assign(function(e,t,i,r,n,o){const{width:s,height:a}=r.imageManager.getPixelSize(t),l=Math.pow(2,o.tileID.overscaledZ),c=o.tileSize*Math.pow(2,r.transform.tileZoom)/l,u=c*(o.tileID.canonical.x+o.tileID.wrap*l),h=c*o.tileID.canonical.y;return{u_image:0,u_pattern_tl:i.tl,u_pattern_br:i.br,u_texsize:[s,a],u_pattern_size:i.displaySize,u_pattern_units_to_pixels:n?[r.transform.width,-1*r.transform.height]:[1/Hp(o,1,r.transform.tileZoom),1/Hp(o,1,r.transform.tileZoom)],u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(0,o,s,r,a,l),{u_matrix:e,u_emissive_strength:t,u_opacity:i}),Dw=new Float32Array(u([])),Pw=(e,t,i,n,o,s,l,c,u,h,d,p,f,m=[0,0,0],_,g,y)=>{const x=o.style.light,v=x.properties.get("position"),b=[-v.x,-v.y,v.z],w=r();"viewport"===x.properties.get("anchor")&&(a(w,-o.transform.angle),W(b,b,w));const T="MASK"===d.alphaMode,E=x.properties.get("color").toNonPremultipliedRenderColor(null),S=f.paint.get("model-ambient-occlusion-intensity"),A=f.paint.get("model-color").constantOr(Color.white).toNonPremultipliedRenderColor(null);return A.a=f.paint.get("model-color-mix-intensity").constantOr(0),y&&(A.r=y[0],A.g=y[1],A.b=y[2],A.a=y[3]),g&&(A.r=g.color.r,A.g=g.color.g,A.b=g.color.b,A.a=g.colorMix,p=g.emissionStrength,s*=g.opacity),{u_matrix:e,u_lighting_matrix:t,u_normal_matrix:i,u_node_matrix:n||Dw,u_lightpos:b,u_lightintensity:x.properties.get("intensity"),u_lightcolor:[E.r,E.g,E.b],u_camera_pos:m,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+T,u_alphaCutoff:d.alphaCutoff,u_baseColorFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:c.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:u,u_roughnessFactor:h,u_baseColorTexture:qv.BaseColor,u_metallicRoughnessTexture:qv.MetallicRoughness,u_normalTexture:qv.Normal,u_occlusionTexture:qv.Occlusion,u_emissionTexture:qv.Emission,u_lutTexture:qv.LUT,u_color_mix:A.toArray01(),u_aoIntensity:S,u_emissive_strength:p,u_occlusionTextureTransform:_||[0,0,0,0]}},Lw=(e,t=Dw,i=Dw)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Rw={fillExtrusion:e=>({u_matrix:new UniformMatrix4f(e),u_lightpos:new Uniform3f(e),u_lightintensity:new Uniform1f(e),u_lightcolor:new Uniform3f(e),u_vertical_gradient:new Uniform1f(e),u_opacity:new Uniform1f(e),u_edge_radius:new Uniform1f(e),u_width_scale:new Uniform1f(e),u_ao:new Uniform2f(e),u_height_type:new Uniform1i(e),u_base_type:new Uniform1i(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_up_dir:new Uniform3f(e),u_height_lift:new Uniform1f(e),u_flood_light_color:new Uniform3f(e),u_vertical_scale:new Uniform1f(e),u_flood_light_intensity:new Uniform1f(e),u_ground_shadow_factor:new Uniform3f(e)}),fillExtrusionDepth:e=>({u_matrix:new UniformMatrix4f(e),u_edge_radius:new Uniform1f(e),u_width_scale:new Uniform1f(e),u_vertical_scale:new Uniform1f(e),u_height_type:new Uniform1i(e),u_base_type:new Uniform1i(e)}),fillExtrusionPattern:e=>({u_matrix:new UniformMatrix4f(e),u_lightpos:new Uniform3f(e),u_lightintensity:new Uniform1f(e),u_lightcolor:new Uniform3f(e),u_vertical_gradient:new Uniform1f(e),u_height_factor:new Uniform1f(e),u_edge_radius:new Uniform1f(e),u_width_scale:new Uniform1f(e),u_ao:new Uniform2f(e),u_height_type:new Uniform1i(e),u_base_type:new Uniform1i(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_up_dir:new Uniform3f(e),u_height_lift:new Uniform1f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_tile_units_to_pixels:new Uniform1f(e),u_opacity:new Uniform1f(e),u_pattern_transition:new Uniform1f(e)}),fillExtrusionGroundEffect:e=>({u_matrix:new UniformMatrix4f(e),u_opacity:new Uniform1f(e),u_ao_pass:new Uniform1f(e),u_meter_to_tile:new Uniform1f(e),u_ao:new Uniform2f(e),u_flood_light_intensity:new Uniform1f(e),u_flood_light_color:new Uniform3f(e),u_attenuation:new Uniform1f(e),u_edge_radius:new Uniform1f(e),u_fb:new Uniform1i(e),u_fb_size:new Uniform1f(e),u_dynamic_offset:new Uniform1f(e)}),fill:e=>({u_matrix:new UniformMatrix4f(e),u_emissive_strength:new Uniform1f(e),u_ground_shadow_factor:new Uniform3f(e)}),fillPattern:e=>({u_matrix:new UniformMatrix4f(e),u_emissive_strength:new Uniform1f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_tile_units_to_pixels:new Uniform1f(e),u_ground_shadow_factor:new Uniform3f(e),u_pattern_transition:new Uniform1f(e)}),fillOutline:e=>({u_matrix:new UniformMatrix4f(e),u_emissive_strength:new Uniform1f(e),u_world:new Uniform2f(e),u_ground_shadow_factor:new Uniform3f(e)}),fillOutlinePattern:e=>({u_matrix:new UniformMatrix4f(e),u_emissive_strength:new Uniform1f(e),u_world:new Uniform2f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_tile_units_to_pixels:new Uniform1f(e),u_ground_shadow_factor:new Uniform3f(e),u_pattern_transition:new Uniform1f(e)}),building:e=>({u_matrix:new UniformMatrix4f(e),u_normal_matrix:new UniformMatrix4f(e),u_opacity:new Uniform1f(e),u_faux_facade_ao_intensity:new Uniform1f(e),u_camera_pos:new Uniform3f(e),u_tile_to_meter:new Uniform1f(e),u_facade_emissive_chance:new Uniform1f(e),u_flood_light_color:new Uniform3f(e),u_flood_light_intensity:new Uniform1f(e)}),buildingBloom:e=>({u_matrix:new UniformMatrix4f(e)}),buildingDepth:e=>({u_matrix:new UniformMatrix4f(e)}),elevatedStructuresDepth:e=>({u_matrix:new UniformMatrix4f(e),u_depth_bias:new Uniform1f(e)}),elevatedStructures:e=>({u_matrix:new UniformMatrix4f(e),u_ground_shadow_factor:new Uniform3f(e)}),elevatedStructuresDepthReconstruct:e=>({u_matrix:new UniformMatrix4f(e),u_camera_pos:new Uniform3f(e),u_depth_bias:new Uniform1f(e),u_height_scale:new Uniform1f(e),u_reset_depth:new Uniform1f(e)}),circle:e=>({u_camera_to_center_distance:new Uniform1f(e),u_extrude_scale:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_up_dir:new Uniform3f(e),u_emissive_strength:new Uniform1f(e)}),collisionBox:e=>({u_matrix:new UniformMatrix4f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_camera_to_center_distance:new Uniform1f(e),u_extrude_scale:new Uniform2f(e),u_zoom_transition:new Uniform1f(e),u_merc_center:new Uniform2f(e),u_tile_id:new Uniform3f(e)}),collisionCircle:e=>({u_matrix:new UniformMatrix4f(e),u_inv_matrix:new UniformMatrix4f(e),u_camera_to_center_distance:new Uniform1f(e),u_viewport_size:new Uniform2f(e)}),debug:e=>({u_color:new UniformColor(e),u_matrix:new UniformMatrix4f(e),u_overlay:new Uniform1i(e),u_overlay_scale:new Uniform1f(e)}),clippingMask:e=>({u_matrix:new UniformMatrix4f(e)}),heatmap:e=>({u_extrude_scale:new Uniform1f(e),u_intensity:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_up_dir:new Uniform3f(e)}),heatmapTexture:e=>({u_image:new Uniform1i(e),u_color_ramp:new Uniform1i(e),u_opacity:new Uniform1f(e)}),hillshade:e=>({u_matrix:new UniformMatrix4f(e),u_image:new Uniform1i(e),u_latrange:new Uniform2f(e),u_light:new Uniform2f(e),u_shadow:new UniformColor(e),u_highlight:new UniformColor(e),u_emissive_strength:new Uniform1f(e),u_accent:new UniformColor(e)}),hillshadePrepare:e=>({u_matrix:new UniformMatrix4f(e),u_image:new Uniform1i(e),u_dimension:new Uniform2f(e),u_zoom:new Uniform1f(e)}),line:e=>({u_matrix:new UniformMatrix4f(e),u_pixels_to_tile_units:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_width_scale:new Uniform1f(e),u_floor_width_scale:new Uniform1f(e),u_units_to_pixels:new Uniform2f(e),u_dash_image:new Uniform1i(e),u_gradient_image:new Uniform1i(e),u_image_height:new Uniform1f(e),u_texsize:new Uniform2f(e),u_tile_units_to_pixels:new Uniform1f(e),u_alpha_discard_threshold:new Uniform1f(e),u_trim_offset:new Uniform2f(e),u_trim_fade_range:new Uniform2f(e),u_trim_color:new Uniform4f(e),u_zbias_factor:new Uniform1f(e),u_tile_to_meter:new Uniform1f(e),u_ground_shadow_factor:new Uniform3f(e)}),linePattern:e=>({u_matrix:new UniformMatrix4f(e),u_texsize:new Uniform2f(e),u_pixels_to_tile_units:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_width_scale:new Uniform1f(e),u_floor_width_scale:new Uniform1f(e),u_image:new Uniform1i(e),u_units_to_pixels:new Uniform2f(e),u_tile_units_to_pixels:new Uniform1f(e),u_alpha_discard_threshold:new Uniform1f(e),u_trim_offset:new Uniform2f(e),u_trim_fade_range:new Uniform2f(e),u_trim_color:new Uniform4f(e),u_zbias_factor:new Uniform1f(e),u_tile_to_meter:new Uniform1f(e),u_ground_shadow_factor:new Uniform3f(e),u_pattern_transition:new Uniform1f(e)}),raster:e=>({u_matrix:new UniformMatrix4f(e),u_normalize_matrix:new UniformMatrix4f(e),u_globe_matrix:new UniformMatrix4f(e),u_merc_matrix:new UniformMatrix4f(e),u_grid_matrix:new UniformMatrix3f(e),u_tl_parent:new Uniform2f(e),u_scale_parent:new Uniform1f(e),u_fade_t:new Uniform1f(e),u_opacity:new Uniform1f(e),u_image0:new Uniform1i(e),u_image1:new Uniform1i(e),u_brightness_low:new Uniform1f(e),u_brightness_high:new Uniform1f(e),u_saturation_factor:new Uniform1f(e),u_contrast_factor:new Uniform1f(e),u_spin_weights:new Uniform3f(e),u_perspective_transform:new Uniform2f(e),u_raster_elevation:new Uniform1f(e),u_zoom_transition:new Uniform1f(e),u_merc_center:new Uniform2f(e),u_cutoff_params:new Uniform4f(e),u_colorization_mix:new Uniform4f(e),u_colorization_offset:new Uniform1f(e),u_color_ramp:new Uniform1i(e),u_texture_offset:new Uniform2f(e),u_texture_res:new Uniform2f(e),u_emissive_strength:new Uniform1f(e)}),rasterParticle:e=>({u_matrix:new UniformMatrix4f(e),u_normalize_matrix:new UniformMatrix4f(e),u_globe_matrix:new UniformMatrix4f(e),u_merc_matrix:new UniformMatrix4f(e),u_grid_matrix:new UniformMatrix3f(e),u_tl_parent:new Uniform2f(e),u_scale_parent:new Uniform1f(e),u_fade_t:new Uniform1f(e),u_opacity:new Uniform1f(e),u_image0:new Uniform1i(e),u_image1:new Uniform1i(e),u_raster_elevation:new Uniform1f(e),u_zoom_transition:new Uniform1f(e),u_merc_center:new Uniform2f(e),u_cutoff_params:new Uniform4f(e)}),rasterParticleTexture:e=>({u_texture:new Uniform1i(e),u_opacity:new Uniform1f(e)}),rasterParticleDraw:e=>({u_particle_texture:new Uniform1i(e),u_particle_texture_side_len:new Uniform1f(e),u_tile_offset:new Uniform2f(e),u_velocity:new Uniform1i(e),u_color_ramp:new Uniform1i(e),u_velocity_res:new Uniform2f(e),u_max_speed:new Uniform1f(e),u_uv_offset:new Uniform2f(e),u_data_scale:new Uniform2f(e),u_data_offset:new Uniform1f(e),u_particle_pos_scale:new Uniform1f(e),u_particle_pos_offset:new Uniform2f(e)}),rasterParticleUpdate:e=>({u_particle_texture:new Uniform1i(e),u_particle_texture_side_len:new Uniform1f(e),u_velocity:new Uniform1i(e),u_velocity_res:new Uniform2f(e),u_max_speed:new Uniform1f(e),u_speed_factor:new Uniform1f(e),u_reset_rate:new Uniform1f(e),u_rand_seed:new Uniform1f(e),u_uv_offset:new Uniform2f(e),u_data_scale:new Uniform2f(e),u_data_offset:new Uniform1f(e),u_particle_pos_scale:new Uniform1f(e),u_particle_pos_offset:new Uniform2f(e)}),symbol:e=>({u_is_size_zoom_constant:new Uniform1i(e),u_is_size_feature_constant:new Uniform1i(e),u_size_t:new Uniform1f(e),u_size:new Uniform1f(e),u_camera_to_center_distance:new Uniform1f(e),u_rotate_symbol:new Uniform1i(e),u_aspect_ratio:new Uniform1f(e),u_fade_change:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_label_plane_matrix:new UniformMatrix4f(e),u_coord_matrix:new UniformMatrix4f(e),u_is_text:new Uniform1i(e),u_elevation_from_sea:new Uniform1i(e),u_pitch_with_map:new Uniform1i(e),u_texsize:new Uniform2f(e),u_texsize_icon:new Uniform2f(e),u_texture:new Uniform1i(e),u_texture_icon:new Uniform1i(e),u_gamma_scale:new Uniform1f(e),u_device_pixel_ratio:new Uniform1f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_camera_forward:new Uniform3f(e),u_tile_matrix:new UniformMatrix4f(e),u_up_vector:new Uniform3f(e),u_ecef_origin:new Uniform3f(e),u_is_halo:new Uniform1i(e),u_icon_transition:new Uniform1f(e),u_color_adj_mat:new UniformMatrix4f(e),u_scale_factor:new Uniform1f(e),u_ground_shadow_factor:new Uniform3f(e),u_inv_matrix:new UniformMatrix4f(e),u_normal_scale:new Uniform1f(e),u_lutTexture:new Uniform1i(e)}),background:e=>({u_matrix:new UniformMatrix4f(e),u_emissive_strength:new Uniform1f(e),u_opacity:new Uniform1f(e),u_color:new UniformColor(e)}),backgroundPattern:e=>({u_matrix:new UniformMatrix4f(e),u_emissive_strength:new Uniform1f(e),u_opacity:new Uniform1f(e),u_image:new Uniform1i(e),u_pattern_tl:new Uniform2f(e),u_pattern_br:new Uniform2f(e),u_texsize:new Uniform2f(e),u_pattern_size:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_pattern_units_to_pixels:new Uniform2f(e)}),terrainRaster:e=>({u_matrix:new UniformMatrix4f(e),u_image0:new Uniform1i(e),u_image1:new Uniform1i(e),u_skirt_height:new Uniform1f(e),u_ground_shadow_factor:new Uniform3f(e),u_emissive_texture_available:new Uniform1f(e)}),skybox:e=>({u_matrix:new UniformMatrix4f(e),u_sun_direction:new Uniform3f(e),u_cubemap:new Uniform1i(e),u_opacity:new Uniform1f(e),u_temporal_offset:new Uniform1f(e)}),skyboxGradient:e=>({u_matrix:new UniformMatrix4f(e),u_color_ramp:new Uniform1i(e),u_center_direction:new Uniform3f(e),u_radius:new Uniform1f(e),u_opacity:new Uniform1f(e),u_temporal_offset:new Uniform1f(e)}),skyboxCapture:e=>({u_matrix_3f:new UniformMatrix3f(e),u_sun_direction:new Uniform3f(e),u_sun_intensity:new Uniform1f(e),u_color_tint_r:new Uniform4f(e),u_color_tint_m:new Uniform4f(e),u_luminance:new Uniform1f(e)}),globeRaster:e=>({u_proj_matrix:new UniformMatrix4f(e),u_globe_matrix:new UniformMatrix4f(e),u_normalize_matrix:new UniformMatrix4f(e),u_merc_matrix:new UniformMatrix4f(e),u_zoom_transition:new Uniform1f(e),u_merc_center:new Uniform2f(e),u_image0:new Uniform1i(e),u_image1:new Uniform1i(e),u_grid_matrix:new UniformMatrix3f(e),u_skirt_height:new Uniform1f(e),u_far_z_cutoff:new Uniform1f(e),u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_globe_pos:new Uniform3f(e),u_globe_radius:new Uniform1f(e),u_viewport:new Uniform2f(e),u_emissive_texture_available:new Uniform1f(e)}),globeAtmosphere:e=>({u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_horizon:new Uniform1f(e),u_transition:new Uniform1f(e),u_fadeout_range:new Uniform1f(e),u_atmosphere_fog_color:new Uniform4f(e),u_high_color:new Uniform4f(e),u_space_color:new Uniform4f(e),u_temporal_offset:new Uniform1f(e),u_horizon_angle:new Uniform1f(e)}),model:e=>({u_matrix:new UniformMatrix4f(e),u_lighting_matrix:new UniformMatrix4f(e),u_normal_matrix:new UniformMatrix4f(e),u_node_matrix:new UniformMatrix4f(e),u_lightpos:new Uniform3f(e),u_lightintensity:new Uniform1f(e),u_lightcolor:new Uniform3f(e),u_camera_pos:new Uniform3f(e),u_opacity:new Uniform1f(e),u_baseColorFactor:new Uniform4f(e),u_emissiveFactor:new Uniform4f(e),u_metallicFactor:new Uniform1f(e),u_roughnessFactor:new Uniform1f(e),u_baseTextureIsAlpha:new Uniform1i(e),u_alphaMask:new Uniform1i(e),u_alphaCutoff:new Uniform1f(e),u_baseColorTexture:new Uniform1i(e),u_metallicRoughnessTexture:new Uniform1i(e),u_normalTexture:new Uniform1i(e),u_occlusionTexture:new Uniform1i(e),u_emissionTexture:new Uniform1i(e),u_lutTexture:new Uniform1i(e),u_color_mix:new Uniform4f(e),u_aoIntensity:new Uniform1f(e),u_emissive_strength:new Uniform1f(e),u_occlusionTextureTransform:new Uniform4f(e)}),modelDepth:e=>({u_matrix:new UniformMatrix4f(e),u_instance:new UniformMatrix4f(e),u_node_matrix:new UniformMatrix4f(e)}),groundShadow:e=>({u_matrix:new UniformMatrix4f(e),u_ground_shadow_factor:new Uniform3f(e)}),stars:e=>({u_matrix:new UniformMatrix4f(e),u_up:new Uniform3f(e),u_right:new Uniform3f(e),u_intensity_multiplier:new Uniform1f(e)}),snowParticle:e=>({u_modelview:new UniformMatrix4f(e),u_projection:new UniformMatrix4f(e),u_time:new Uniform1f(e),u_cam_pos:new Uniform3f(e),u_velocityConeAperture:new Uniform1f(e),u_velocity:new Uniform1f(e),u_horizontalOscillationRadius:new Uniform1f(e),u_horizontalOscillationRate:new Uniform1f(e),u_boxSize:new Uniform1f(e),u_billboardSize:new Uniform1f(e),u_simpleShapeParameters:new Uniform2f(e),u_screenSize:new Uniform2f(e),u_thinningCenterPos:new Uniform2f(e),u_thinningShape:new Uniform3f(e),u_thinningAffectedRatio:new Uniform1f(e),u_thinningParticleOffset:new Uniform1f(e),u_particleColor:new Uniform4f(e),u_direction:new Uniform3f(e)}),rainParticle:e=>({u_modelview:new UniformMatrix4f(e),u_projection:new UniformMatrix4f(e),u_time:new Uniform1f(e),u_cam_pos:new Uniform3f(e),u_texScreen:new Uniform1i(e),u_velocityConeAperture:new Uniform1f(e),u_velocity:new Uniform1f(e),u_boxSize:new Uniform1f(e),u_rainDropletSize:new Uniform2f(e),u_distortionStrength:new Uniform1f(e),u_rainDirection:new Uniform3f(e),u_color:new Uniform4f(e),u_screenSize:new Uniform2f(e),u_thinningCenterPos:new Uniform2f(e),u_thinningShape:new Uniform3f(e),u_thinningAffectedRatio:new Uniform1f(e),u_thinningParticleOffset:new Uniform1f(e),u_shapeDirectionalPower:new Uniform1f(e),u_shapeNormalPower:new Uniform1f(e),u_mode:new Uniform1f(e)}),vignette:e=>({u_vignetteShape:new Uniform3f(e),u_vignetteColor:new Uniform4f(e)}),occlusion:e=>({u_matrix:new UniformMatrix4f(e),u_anchorPos:new Uniform3f(e),u_screenSizePx:new Uniform2f(e),u_occluderSizePx:new Uniform2f(e),u_color:new Uniform4f(e)})};class IndexBuffer{constructor(e,t,i,r){this.id=IndexBuffer.uniqueIdxCounter,IndexBuffer.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||r||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=IndexBuffer.uniqueIdxCounter,IndexBuffer.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)}}IndexBuffer.uniqueIdxCounter=0;const zw={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class VertexBuffer{constructor(e,t,i,r,n,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,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||n||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(let i=0;i<this.attributes.length;i++){const r=t.getAttributeLocation(e,this.attributes[i].name);-1!==r&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=t.getAttributeLocation(e,n.name);-1!==o&&e.vertexAttribPointer(o,n.components,e[zw[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}setVertexAttribDivisor(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=t.getAttributeLocation(e,this.attributes[r].name);-1!==n&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(n,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Framebuffer{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();r>0&&(this.colorAttachment0=new ColorAttachment(e,o,0)),r>1&&(this.colorAttachment1=new ColorAttachment(e,o,1)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new DepthRenderbufferAttachment(e,o):new DepthTextureAttachment(e,o))}createColorAttachment(e,t){0===t?this.colorAttachment0=new ColorAttachment(e,this.framebuffer,0):1===t&&(this.colorAttachment1=new ColorAttachment(e,this.framebuffer,1))}removeColorAttachment(e,t){const i=this.context.gl;let r;0===t?(r=this.colorAttachment0.get(),this.colorAttachment0=void 0):1===t&&(r=this.colorAttachment1.get(),this.colorAttachment1=void 0),r&&i.deleteTexture(r)}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)}e.deleteFramebuffer(this.framebuffer)}}class Context{constructor(e,t){this.gl=e,this.clearColor=new ClearColor(this),this.clearDepth=new ClearDepth(this),this.clearStencil=new ClearStencil(this),this.colorMask=new ColorMask(this),this.depthMask=new DepthMask(this),this.stencilMask=new StencilMask(this),this.stencilFunc=new StencilFunc(this),this.stencilOp=new StencilOp(this),this.stencilTest=new StencilTest(this),this.depthRange=new DepthRange(this),this.depthTest=new DepthTest(this),this.depthFunc=new DepthFunc(this),this.blend=new Blend(this),this.blendFunc=new BlendFunc(this),this.blendColor=new BlendColor(this),this.blendEquation=new BlendEquation(this),this.cullFace=new CullFace(this),this.cullFaceSide=new CullFaceSide(this),this.frontFace=new FrontFace(this),this.program=new kb(this),this.activeTexture=new ActiveTextureUnit(this),this.viewport=new Viewport(this),this.bindFramebuffer=new BindFramebuffer(this),this.bindRenderbuffer=new BindRenderbuffer(this),this.bindTexture=new BindTexture(this),this.bindVertexBuffer=new BindVertexBuffer(this),this.bindElementBuffer=new BindElementBuffer(this),this.bindVertexArrayOES=new BindVertexArrayOES(this),this.pixelStoreUnpack=new PixelStoreUnpack(this),this.pixelStoreUnpackPremultiplyAlpha=new PixelStoreUnpackPremultiplyAlpha(this),this.pixelStoreUnpackFlipY=new PixelStoreUnpackFlipY(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.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.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 IndexBuffer(this,e,t,i)}createVertexBuffer(e,t,i,r,n){return new VertexBuffer(this,e,t,i,r,n)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new Framebuffer(this,e,t,i,r)}clear({color:e,depth:t,stencil:i,colorMask:r}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(o)}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(e){Re(e.blendFunction,ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let Fw;function Ow(e,t,i,r,n,o,s){const a=e.context,c=a.gl,u=e.transform,h=[Qa(u.center.lng),el(u.center.lat)],d=i.layout.get("symbol-placement"),p=i.layout.get("text-variable-anchor"),f="map"===i.layout.get("icon-rotation-alignment"),m="map"===i.layout.get("text-rotation-alignment"),_="point"!==d,g=[];let y=0,x=0;for(let a=0;a<r.length;a++){const d=r[a],v=t.getTile(d),b=v.getBucket(i);if(!b)continue;const w=b.getProjection().createInversionMatrix(u,d.canonical),T=[],E=Qx(d,b,u),S=!s&&f&&_,I=s&&m&&_,C=p&&b.hasTextData(),M=b.hasIconTextFit()&&C&&b.hasIconData(),D=S||I||s&&C||M,P="globe"===b.projection.name,L=P?Ac(u.zoom):0;P&&(T.push("PROJECTION_GLOBE_VIEW"),D&&T.push("PROJECTED_POS_ON_VIEWPORT"));const R=e.getOrCreateProgram("collisionBox",{defines:T});let z=E;0===n[0]&&0===n[1]||(z=e.translatePosMatrix(E,v,n,o));const F=s?b.textCollisionBox:b.iconCollisionBox,O=b.collisionCircleArray;if(O.length>0){const e=l(),t=z;A(e,b.placementInvProjMatrix,u.glCoordMatrix),A(e,e,b.placementViewportMatrix),g.push({circleArray:O,circleOffset:x,transform:t,invTransform:e,projection:b.getProjection()}),y+=O.length/4,x=y}if(!F)continue;e.terrain&&e.terrain.setupElevationDraw(v,R);const B=P?[d.canonical.x,d.canonical.y,1<<d.canonical.z]:[0,0,0];R.draw(e,c.LINES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,fw(z,w,u,L,h,v,B,b.getProjection()),i.id,F.layoutVertexBuffer,F.indexBuffer,F.segments,null,u.zoom,null,[F.collisionVertexBuffer,F.collisionVertexBufferExt])}if(!s||!g.length)return;const v=e.getOrCreateProgram("collisionCircle"),b=new StructArrayLayout2f1f2i16;b.resize(4*y),b._trim();let w=0;for(const e of g)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,r=e.circleArray[i+0],n=e.circleArray[i+1],o=e.circleArray[i+2],s=e.circleArray[i+3];b.emplace(w++,r,n,o,s,0),b.emplace(w++,r,n,o,s,1),b.emplace(w++,r,n,o,s,2),b.emplace(w++,r,n,o,s,3)}(!Fw||Fw.length<2*y)&&(Fw=function(e){const t=2*e,i=new StructArrayLayout3ui6;i.resize(t),i._trim();for(let e=0;e<t;e++){const t=6*e;i.uint16[t+0]=4*e+0,i.uint16[t+1]=4*e+1,i.uint16[t+2]=4*e+2,i.uint16[t+3]=4*e+2,i.uint16[t+4]=4*e+3,i.uint16[t+5]=4*e+0}return i}(y));const T=a.createIndexBuffer(Fw,!0),E=a.createVertexBuffer(b,df.members,!0);for(const t of g){const r={u_matrix:t.transform,u_inv_matrix:t.invTransform,u_camera_to_center_distance:(S=u).getCameraToCenterDistance(t.projection),u_viewport_size:[S.width,S.height]};v.draw(e,c.TRIANGLES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,r,i.id,E,T,SegmentVector.simpleSegment(0,2*t.circleOffset,t.circleArray.length,t.circleArray.length/2),null,u.zoom)}var S;E.destroy(),T.destroy()}const Bw=l();function kw(e){const t=p([],e._camera.getWorldToCamera(e.worldSize,1),e.globeMatrix);d(t,t);const i=[0,0,0],r=[0,1,0,0];return se(r,r,t),i[0]=r[0],i[1]=r[1],i[2]=r[2],G(i,i),i}function Uw({width:e,height:t,anchor:i,textOffset:r,textScale:n},o){const{horizontalAlign:s,verticalAlign:a}=Ff(i),l=-(s-.5)*e,c=-(a-.5)*t,u=rm(i,r);return new Le((l/n+u[0])*o,(c/n+u[1])*o)}function Vw(e,t,i,r,n,o,s,a,l,c){const u=e.text.placedSymbolArray,h=e.text.dynamicLayoutVertexArray,d=e.icon.dynamicLayoutVertexArray,p={},f=e.getProjection(),m=ev(s,f,n),_=n.elevation,g=f.upVectorScale(s.canonical,n.center.lat,n.worldSize).metersToTile;h.clear();for(let d=0;d<u.length;d++){const y=u.get(d),{tileAnchorX:x,tileAnchorY:v,numGlyphs:b}=y,w=y.hidden||!y.crossTileID||e.allowVerticalPlacement&&!y.placedOrientation?null:r[y.crossTileID];if(w){let r=0,u=0,T=0;const E="road"===e.elevationType;if(_||E){const t=E?e.getElevationFeatureForText(d):null,i=Elevation.getAtTileOffset(s,new Le(x,v),_,t),[n,o,a]=f.upVector(s.canonical,x,v);r=i*n*g,u=i*o*g,T=i*a*g}let[S,A,I,C]=sv(y.projectedAnchorX+r,y.projectedAnchorY+u,y.projectedAnchorZ+T,i?m:o);const M=av(n.getCameraToCenterDistance(f),C);let D=Vf(e.textSizeData,l,y)*M/24;i&&(D*=e.tilePixelRatio/a);const P=Uw(w,D);i?(({x:S,y:A,z:I}=f.projectTilePoint(x+P.x,v+P.y,s.canonical)),[S,A,I]=sv(S+r,A+u,I+T,o)):(t&&P._rotate(-n.angle),S+=P.x,A+=P.y,I=0);const L=e.allowVerticalPlacement&&y.placedOrientation===zf.vertical?Math.PI/2:0;for(let e=0;e<b;e++)Dm(h,S,A,I,L);c&&y.associatedIconIndex>=0&&(p[y.associatedIconIndex]={x:S,y:A,z:I,angle:L})}else _v(b,h)}if(c){d.clear();const t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){const i=t.get(e),{numGlyphs:r}=i,n=p[e];if(i.hidden||!n)_v(r,d);else{const{x:e,y:t,z:i,angle:o}=n;for(let n=0;n<r;n++)Dm(d,e,t,i,o)}}e.icon.dynamicLayoutVertexBuffer.updateData(d)}e.text.dynamicLayoutVertexBuffer.updateData(h)}function Nw(e,t,i,r,n,o,s={}){const a=i.paint.get("icon-translate"),c=i.paint.get("text-translate"),u=i.paint.get("icon-translate-anchor"),h=i.paint.get("text-translate-anchor"),p=i.layout.get("icon-rotation-alignment"),f=i.layout.get("text-rotation-alignment"),m=i.layout.get("icon-pitch-alignment"),_=i.layout.get("text-pitch-alignment"),g=i.layout.get("icon-keep-upright"),y=i.layout.get("text-keep-upright"),x=i.paint.get("icon-color-saturation"),v=i.paint.get("icon-color-contrast"),b=i.paint.get("icon-color-brightness-min"),w=i.paint.get("icon-color-brightness-max"),T="sea"===i.layout.get("symbol-elevation-reference"),E="none"===i.layout.get("icon-image-use-theme"),S=e.context,A=S.gl,I=e.transform,C="map"===p,M="map"===f,D="map"===m,P="map"===_,L=void 0!==i.layout.get("symbol-sort-key").constantOr(1);let R=!1;const z=e.depthModeForSublayer(0,DepthMode.ReadOnly),F=new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D),O=[Qa(I.center.lng),el(I.center.lat)],B=i.layout.get("text-variable-anchor"),k="globe"===I.projection.name,U=[],V=[0,-1,0];for(const n of r){const r=t.getTile(n),o=r.getBucket(i);if(!o)continue;if("mercator"===o.projection.name&&k)continue;if(o.fullyClipped)continue;const p="globe"===o.projection.name,f=p?Ac(I.zoom):0,m=ev(n,o.getProjection(),I),_=I.calculatePixelsToTileUnitsMatrix(r),N=B&&o.hasTextData(),j=o.hasIconTextFit()&&N&&o.hasIconData(),G=o.getProjection().createInversionMatrix(I,n.canonical),H=(1<<r.tileID.canonical.z)*Mn/e.transform.worldSize,q=t=>{let i=[0,0,0];if(t){const t=e.style.directionalLight,r=e.style.ambientLight;t&&r&&(i=Kv(e.style,t,r))}return i},$=t=>{I.depthOcclusionForSymbolsAndCircles&&(i.hasOcclusionOpacityProperties||e.terrain)&&(t.push("DEPTH_D24"),t.push("DEPTH_OCCLUSION"))},Z=t=>{i.lut&&!E&&(i.lut.texture||(i.lut.texture=new Texture3D(e.context,i.lut.image,[i.lut.image.height,i.lut.image.height,i.lut.image.height],S.gl.RGBA8)),S.activeTexture.set(S.gl.TEXTURE0+qv.LUT),i.lut.texture&&i.lut.texture.bind(S.gl.LINEAR,S.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU"))},W=()=>{const t=C&&"point"!==i.layout.get("symbol-placement"),s=[];$(s),Z(s);const c=t||j,h="road"===o.elevationType,y=e.shadowRenderer,E=h&&D&&!!y&&y.enabled,S=q(E),M=h&&D&&!e.terrain?F:z,P=i.paint.get("icon-image-cross-fade");e.terrainRenderModeElevated()&&D&&s.push("PITCH_WITH_MAP_TERRAIN"),p&&(s.push("PROJECTION_GLOBE_VIEW"),c&&s.push("PROJECTED_POS_ON_VIEWPORT")),P>0&&o.hasAnySecondaryIcon&&s.push("ICON_TRANSITION"),!o.icon.zOffsetVertexBuffer||h&&e.terrain||s.push("Z_OFFSET"),0===x&&0===v&&0===b&&1===w||s.push("COLOR_ADJUSTMENT"),o.sdfIcons&&s.push("RENDER_SDF"),E&&s.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),h&&D&&!e.terrain&&o.icon.orientationVertexBuffer&&s.push("ELEVATED_ROADS");const L=o.icon.programConfigurations.get(i.id),R=e.getOrCreateProgram("symbol",{config:L,defines:s}),B=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],U=o.iconSizeData,N=Nf(U,I.zoom),W=D||!I.isOrthographic,X=rv(m,r.tileID.canonical,D,C,I,o.getProjection(),_),Y=ov(m,r.tileID.canonical,D,C,I,o.getProjection(),_),K=e.translatePosMatrix(Y,r,a,u,!0),J=e.translatePosMatrix(m,r,a,u),Q=c?Bw:X,ee=C&&!D&&!t;let te=V;!k&&!I.mercatorFromTransition||C||(te=kw(I));const ie=p?te:V,re=i.getColorAdjustmentMatrix(x,v,b,w),ne=Iw(U.kind,N,ee,D,e,J,Q,K,T,!1,B,[0,0],0,n,f,O,G,ie,o.getProjection(),S,H,re,P,null),oe=r.imageAtlasTexture?r.imageAtlasTexture:null,se=1!==i.layout.get("icon-size").constantOr(0)||o.iconsNeedLinear,ae=o.sdfIcons||e.options.rotating||e.options.zooming||se||W?A.LINEAR:A.NEAREST,le=o.sdfIcons&&0!==i.paint.get("icon-halo-width").constantOr(1),ce=e.terrain&&D&&t?d(l(),X):Bw;if(t&&o.icon){const t=Elevation.getAtTileOffsetFunc(n,I.center.lat,I.worldSize,o.getProjection()),s=nv(m,r.tileID.canonical,D,C,I,o.getProjection(),_),a=i.layout.get("icon-size-scale-range"),l=He(e.scaleFactor,a[0],a[1]);cv(o,m,e,!1,s,Y,D,g,t,n,l)}return{program:R,buffers:o.icon,uniformValues:ne,atlasTexture:oe,atlasTextureIcon:null,atlasInterpolation:ae,atlasInterpolationIcon:null,isSDF:o.sdfIcons,hasHalo:le,depthMode:M,tile:r,renderWithShadows:E,labelPlaneMatrixInv:ce}},X=()=>{const t=M&&"point"!==i.layout.get("symbol-placement"),s=[],a=t||B||j,u="road"===o.elevationType,g=e.shadowRenderer,x=u&&P&&!!g&&g.enabled,v=q(x),b=u&&P&&!e.terrain?F:z;e.terrainRenderModeElevated()&&P&&s.push("PITCH_WITH_MAP_TERRAIN"),p&&(s.push("PROJECTION_GLOBE_VIEW"),a&&s.push("PROJECTED_POS_ON_VIEWPORT")),!o.text.zOffsetVertexBuffer||u&&e.terrain||s.push("Z_OFFSET"),o.iconsInText&&s.push("RENDER_TEXT_AND_SYMBOL"),s.push("RENDER_SDF"),x&&s.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),u&&P&&!e.terrain&&o.text.orientationVertexBuffer&&s.push("ELEVATED_ROADS"),$(s);const w=o.text.programConfigurations.get(i.id),E=e.getOrCreateProgram("symbol",{config:w,defines:s});let S,C=[0,0],D=null;const L=o.textSizeData;o.iconsInText&&(C=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],D=r.imageAtlasTexture?r.imageAtlasTexture:null,S=P||!I.isOrthographic||e.options.rotating||e.options.zooming||"composite"===L.kind||"camera"===L.kind?A.LINEAR:A.NEAREST);const R=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],U=i.layout.get("text-size-scale-range"),N=He(e.scaleFactor,U[0],U[1]),Z=Nf(L,I.zoom,N),W=rv(m,r.tileID.canonical,P,M,I,o.getProjection(),_),X=ov(m,r.tileID.canonical,P,M,I,o.getProjection(),_),Y=e.translatePosMatrix(X,r,c,h,!0),K=e.translatePosMatrix(m,r,c,h),J=a?Bw:W,Q=M&&!P&&!t;let ee=V;!k&&!I.mercatorFromTransition||M||(ee=kw(I));const te=Iw(L.kind,Z,Q,P,e,K,J,Y,T,!0,R,C,0,n,f,O,G,p?ee:V,o.getProjection(),v,H,null,null,N),ie=r.glyphAtlasTexture?r.glyphAtlasTexture:null,re=A.LINEAR,ne=0!==i.paint.get("text-halo-width").constantOr(1),oe=e.terrain&&P&&t?d(l(),W):Bw;if(t&&o.text){const t=Elevation.getAtTileOffsetFunc(n,I.center.lat,I.worldSize,o.getProjection()),i=nv(m,r.tileID.canonical,P,M,I,o.getProjection(),_);cv(o,m,e,!0,i,X,P,y,t,n,N)}return{program:E,buffers:o.text,uniformValues:te,atlasTexture:ie,atlasTextureIcon:D,atlasInterpolation:re,atlasInterpolationIcon:S,isSDF:!0,hasHalo:ne,depthMode:b,tile:r,renderWithShadows:x,labelPlaneMatrixInv:oe}},Y=o.icon.segments.get().length,K=o.text.segments.get().length,J=Y&&!s.onlyText?W():null,Q=K&&!s.onlyIcons?X():null,ee=i.paint.get("icon-opacity").constantOr(1),te=i.paint.get("text-opacity").constantOr(1);if(L&&o.canOverlap){R=!0;const e=ee&&!s.onlyText?o.icon.segments.get():[],t=te&&!s.onlyIcons?o.text.segments.get():[];for(const t of e)U.push({segments:new SegmentVector([t]),sortKey:t.sortKey,state:J});for(const e of t)U.push({segments:new SegmentVector([e]),sortKey:e.sortKey,state:Q})}else s.onlyText||U.push({segments:ee?o.icon.segments:new SegmentVector([]),sortKey:0,state:J}),s.onlyIcons||U.push({segments:te?o.text.segments:new SegmentVector([]),sortKey:0,state:Q})}R&&U.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of U){const r=t.state;if(r)if(e.terrain?e.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:I.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:r.labelPlaneMatrixInv}):e.setupDepthForOcclusion(I.depthOcclusionForSymbolsAndCircles,r.program),S.activeTexture.set(A.TEXTURE0),r.atlasTexture&&r.atlasTexture.bind(r.atlasInterpolation,A.CLAMP_TO_EDGE,!0),r.atlasTextureIcon&&(S.activeTexture.set(A.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,A.CLAMP_TO_EDGE,!0)),r.renderWithShadows&&e.shadowRenderer.setupShadows(r.tile.tileID.toUnwrapped(),r.program,"vector-tile"),e.uploadCommonLightUniforms(e.context,r.program),r.hasHalo){const s=r.uniformValues;s.u_is_halo=1,jw(r.buffers,t.segments,i,e,r.program,r.depthMode,n,o,s,2),s.u_is_halo=0}else{if(r.isSDF){const s=r.uniformValues;r.hasHalo&&(s.u_is_halo=1,jw(r.buffers,t.segments,i,e,r.program,r.depthMode,n,o,s,1)),s.u_is_halo=0}jw(r.buffers,t.segments,i,e,r.program,r.depthMode,n,o,r.uniformValues,1)}}}function jw(e,t,i,r,n,o,s,a,l,c){const u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];n.draw(r,r.context.gl.TRIANGLES,o,s,a,CullFaceMode.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),u,c)}function Gw(e,t){const i=1<<e.canonical.z;return D((t.x*i-e.canonical.x-e.wrap*i)*Mn,(t.y*i-e.canonical.y)*Mn,nl(t.z,t.y))}function Hw(e,t,i,r,n){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const o=e.context.gl,s=new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D),a=new DepthMode(e.context.gl.GREATER,DepthMode.ReadWrite,e.depthRangeFor3D),l=function(e){let t=.01;return e.isOrthographic&&(t=xr(1e-4,t,It(e.pitch>=$v?1:e.pitch/$v))),2*t}(e.transform),c=e.transform.getFreeCameraOptions().position,u="elevatedStructuresDepthReconstruct",h=e.getOrCreateProgram(u,{defines:["DEPTH_RECONSTRUCTION"]}),d=e.getOrCreateProgram(u);for(const u of r){const r=t.getTile(u),p=r.getBucket(i);if(!p)continue;const f=p.elevatedStructures;if(!f)continue;const m=p.elevationBufferData.heightRange,_=Gw(u.toUnwrapped(),c),g=e.translatePosMatrix(u.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));let y,x,v,b;if("initialize"===n){if(!m||m.min>=1||0===f.depthSegments.segments[0].primitiveLength)continue;y=uw(g,_,l,1,0),x=s,v=f.depthSegments,b=h}else if("reset"===n){if(!m||m.min>=0||0===f.maskSegments.segments[0].primitiveLength)continue;y=uw(g,_,0,0,1),x=a,v=f.maskSegments,b=h}else if("geometry"===n){if(0===f.depthSegments.segments[0].primitiveLength)continue;y=uw(g,_,l,1,0),x=s,v=f.depthSegments,b=d}b.draw(e,o.TRIANGLES,x,StencilMode.disabled,ColorMode.disabled,CullFaceMode.disabled,y,i.id,f.vertexBuffer,f.indexBuffer,v,i.paint,e.transform.zoom)}}function qw(e,t,i,r){const{painter:n,sourceCache:o,layer:s,coords:a,colorMode:l,elevationType:c,terrainEnabled:u,pass:h}=e,d=n.context.gl,p=s.paint.get("fill-pattern"),f=s.paint.get("fill-pattern-cross-fade"),m=p.constantOr(null);let _=c;"road"!==c||t&&!u||(_="none");const g="road"===_,y=e.painter.shadowRenderer,x=g&&!!y&&y.enabled,v=new DepthMode(n.context.gl.LEQUAL,DepthMode.ReadOnly,n.depthRangeFor3D);let b=[0,0,0];if(x){const e=n.style.directionalLight,t=n.style.ambientLight;e&&t&&(b=Kv(n.style,e,t))}const w=p&&p.constantOr(1),T=n.terrain&&n.terrain.renderingToTexture,E=(e,h)=>{let p,_,E,S,A;h?(p=w&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",E=d.LINES):(p=w?"fillPattern":"fill",E=d.TRIANGLES);for(const I of a){const a=o.getTile(I);if(w&&!a.patternsLoaded())continue;const C=a.getBucket(s);if(!C)continue;const M=t?C.elevationBufferData:C.bufferData;if(M.isEmpty())continue;n.prepareDrawTile();const D=M.programConfigurations.get(s.id),P=n.isTileAffectedByFog(I),L=[],R=[];g&&(L.push("ELEVATED_ROADS"),R.push(M.elevatedLayoutVertexBuffer)),x&&L.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),T&&i&&L.push("USE_MRT1"),w&&(n.context.activeTexture.set(d.TEXTURE0),a.imageAtlasTexture&&a.imageAtlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),D.updatePaintBuffers());let z=!1;if(m&&a.imageAtlas){const e=a.imageAtlas,t=ResolvedImage.from(m),i=t.getPrimary().scaleSelf(Wt.devicePixelRatio).toString(),r=t.getSecondary(),n=e.patternPositions.get(i),o=r?e.patternPositions.get(r.scaleSelf(Wt.devicePixelRatio).toString()):null;z=!!n&&!!o,n&&D.setConstantPatternPositions(n,o)}f>0&&(z||D.getPatternTransitionVertexBuffer("fill-pattern"))&&L.push("FILL_PATTERN_TRANSITION");const F=n.getOrCreateProgram(p,{config:D,overrideFog:P,defines:L}),O=n.translatePosMatrix(I.projMatrix,a,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));x&&y.setupShadows(a.tileID.toUnwrapped(),F,"vector-tile");const B=s.paint.get("fill-emissive-strength");if(h){S=M.lineIndexBuffer,A=M.lineSegments;const e=n.terrain&&n.terrain.renderingToTexture?n.terrain.drapeBufferSize:[d.drawingBufferWidth,d.drawingBufferHeight];_="fillOutlinePattern"===p&&w?lw(O,B,n,a,e,b,f):aw(O,B,e,b)}else S=M.indexBuffer,A=M.triangleSegments,_=w?sw(O,B,n,a,b,f):ow(O,B,b);n.uploadCommonUniforms(n.context,F,I.toUnwrapped());let k=e;("road"===c&&!u||"offset"===c)&&(k=v),F.draw(n,E,k,r||n.stencilModeForClipping(I),l,CullFaceMode.disabled,_,s.id,M.layoutVertexBuffer,S,A,s.paint,n.transform.zoom,D,R)}};n.renderPass===h&&E(n.depthModeForSublayer(1,"opaque"===n.renderPass?DepthMode.ReadWrite:DepthMode.ReadOnly),!1),"none"===_&&"translucent"===n.renderPass&&s.paint.get("fill-antialias")&&E(n.depthModeForSublayer(s.getPaintProperty("fill-outline-color")?2:0,DepthMode.ReadOnly),!0)}function $w(e,t,i,r,n,o,s,a){i.resetLayerRenderingStats(e);const l=e.context,c=l.gl,u=e.transform,h=i.paint.get("fill-extrusion-pattern"),d=i.paint.get("fill-extrusion-pattern-cross-fade"),p=h.constantOr(null),f=h.constantOr(1),m=i.paint.get("fill-extrusion-opacity"),_=e.style.enable3dLights(),g=i.paint.get(_&&!f?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),g],x=i.layout.get("fill-extrusion-edge-radius"),v=x>0&&!i.paint.get("fill-extrusion-rounded-roof"),b=v?0:x,w="globe"===u.projection.name?Uh():0,T="globe"===u.projection.name,E=T?Ac(u.zoom):0,S=[Qa(u.center.lng),el(u.center.lat)],A="none"===i.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),I=i.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(A?null:i.lut).toArray01().slice(0,3),C=i.paint.get("fill-extrusion-flood-light-intensity"),M=i.paint.get("fill-extrusion-vertical-scale"),D=0!==i.paint.get("fill-extrusion-line-width").constantOr(1),P=i.paint.get("fill-extrusion-height-alignment"),L=i.paint.get("fill-extrusion-base-alignment"),R=Zv(e,i.paint.get("fill-extrusion-cutoff-fade-range")),z=[];let F;T&&z.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&z.push("FAUX_AO"),v&&z.push("ZERO_ROOF_RADIUS"),a&&z.push("HAS_CENTROID"),C>0&&z.push("FLOOD_LIGHT"),R.shouldRenderCutoff&&z.push("RENDER_CUTOFF"),D&&z.push("RENDER_WALL_MODE");const O="shadow"===e.renderPass,B=e.shadowRenderer,k=O&&!!B,U=O?CullFaceMode.disabled:CullFaceMode.backCCW;e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0);let V=[0,0,0];if(B){const t=e.style.directionalLight,i=e.style.ambientLight;t&&i&&(V=Kv(e.style,t,i)),O||(z.push("RENDER_SHADOWS","DEPTH_TEXTURE"),B.useNormalOffset&&z.push("NORMAL_OFFSET")),F=z.concat(["SHADOWS_SINGLE_CASCADE"])}const N=k?"fillExtrusionDepth":f?"fillExtrusionPattern":"fillExtrusion",j=i.getLayerRenderingStats();for(const h of r){const r=t.getTile(h),_=r.getBucket(i);if(!_||_.projection.name!==u.projection.name)continue;let g=!1;B&&(g=0===B.getMaxCascadeForTile(h.toUnwrapped()));const x=e.isTileAffectedByFog(h),v=_.programConfigurations.get(i.id);let A=!1;if(p&&r.imageAtlas){const e=r.imageAtlas,t=ResolvedImage.from(p),i=t.getPrimary().scaleSelf(Wt.devicePixelRatio).toString(),n=t.getSecondary(),o=e.patternPositions.get(i),s=n?e.patternPositions.get(n.scaleSelf(Wt.devicePixelRatio).toString()):null;A=!!o&&!!s,o&&v.setConstantPatternPositions(o,s)}d>0&&(A||v.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&z.push("FILL_EXTRUSION_PATTERN_TRANSITION");const k=e.getOrCreateProgram(N,{config:v,defines:g?F:z,overrideFog:x});if(e.terrain&&e.terrain.setupElevationDraw(r,k,{useMeterToDem:!0}),!_.centroidVertexBuffer){const e=k.getAttributeLocation(c,"a_centroid_pos");-1!==e&&c.vertexAttrib2f(e,0,0)}!O&&B&&B.setupShadows(r.tileID.toUnwrapped(),k,"vector-tile"),f&&(e.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),v.updatePaintBuffers());const G=i.paint.get("fill-extrusion-vertical-gradient"),H=1/_.tileToMeter;let q;if(O&&B){if(Jw(r.tileID,_.maxHeight,e))continue;const t=B.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());q=iw(t,b,H,M,P,L)}else{const t=e.translatePosMatrix(h.expandedProjMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),n=u.projection.createInversionMatrix(u,h.canonical);q=f?rw(t,e,G,m,y,b,H,h,r,w,P,L,E,S,n,I,M,d):tw(t,e,G,m,y,b,H,h,w,P,L,E,S,n,I,M,C,V)}e.uploadCommonUniforms(l,k,h.toUnwrapped(),null,R);let $=_.segments;if("mercator"===u.projection.name&&!O&&($=_.getVisibleSegments(r.tileID,e.terrain,e.transform.getFrustum(0)),!$.get().length))continue;if(j)if(O)for(const e of $.get())j.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of $.get())j.numRenderedVerticesInTransparentPass+=e.primitiveLength;const Z=[];(e.terrain||a)&&Z.push(_.centroidVertexBuffer),T&&Z.push(_.layoutVertexExtBuffer),D&&Z.push(_.wallVertexBuffer),k.draw(e,l.gl.TRIANGLES,n,o,s,U,q,i.id,_.layoutVertexBuffer,_.indexBuffer,$,i.paint,e.transform.zoom,v,Z)}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1)}class GroundEffectProperties{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Zw(e,t,i,r,n,o,s,a,l,c,u,h,d,p,m,_,g,y,x,v){const b=t.context,w=b.gl,T=t.transform,E=t.transform.zoom,S=[],A=e.translate,I=e.translateAnchor,C=e.edgeRadius,M=Zv(t,e.cutoffFadeRange);"clear"===u?(S.push("CLEAR_SUBPASS"),v&&(S.push("CLEAR_FROM_TEXTURE"),b.activeTexture.set(w.TEXTURE0),v.bind(w.LINEAR,w.CLAMP_TO_EDGE))):"sdf"===u?S.push("SDF_SUBPASS"):"emissive"===u&&(S.push("USE_MRT1"),b.activeTexture.set(w.TEXTURE0),v.bind(w.LINEAR,w.CLAMP_TO_EDGE)),y&&S.push("HAS_CENTROID"),M.shouldRenderCutoff&&S.push("RENDER_CUTOFF");const D=(e,i,n,u,f)=>{let x=S;null!=i.groundRadiusBuffer&&(x=S.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const w=i.programConfigurations.get(r.id),T=t.isTileAffectedByFog(e),A=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:w,defines:x,overrideFog:T}),I=nw(t,u,h,c,f,[d,p*f],m,_,g,E>=17?0:C*f,v?v.size[0]:0),D=[];y&&D.push(i.hiddenByLandmarkVertexBuffer),null!=i.groundRadiusBuffer&&D.push(i.groundRadiusBuffer),t.uploadCommonUniforms(b,A,e.toUnwrapped(),null,M),A.draw(t,b.gl.TRIANGLES,o,s,a,l,I,r.id,i.vertexBuffer,i.indexBuffer,n,r.paint,E,w,D)};for(const e of n){const n=i.getTile(e),o=n.getBucket(r);if(!o||o.projection.name!==T.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;const s=o.groundEffect,a=1/o.tileToMeter;{const i=t.translatePosMatrix(e.projMatrix,n,A,I),r=s.getDefaultSegment();D(e,s,r,i,a)}if(x)for(let o=0;o<4;o++){const s=tc[o](e),l=i.getTile(s);if(!l)continue;const c=l.getBucket(r);if(!c||c.projection.name!==T.projection.name||!c.groundEffect||c.groundEffect&&!c.groundEffect.hasData())continue;const u=c.groundEffect;let h,d;0===o?(h=[-Mn,0,0],d=1):1===o?(h=[Mn,0,0],d=0):2===o?(h=[0,-Mn,0],d=3):(h=[0,Mn,0],d=2);const p=u.regionSegments[d];if(!p)continue;const m=new Float32Array(16);f(m,e.projMatrix,h),D(e,u,p,t.translatePosMatrix(m,n,A,I),a)}}}function Ww(e,t,i,r,n,o,s){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const a=o?o.findDEMTileFor(i):null;if(!(a&&a.dem||s))return;o&&a&&a.dem&&r.selfDEMTileTimestamp!==a.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=a.dem._timestamp);const l=e=>new Le(Math.ceil((e+Eh)*Th),0),c=e=>{const i=t.getSource().minzoom,r=e=>{const i=t.getTileByID(e);if(i&&i.hasData())return i.getBucket(n)},o=[0,-1,1];for(const t of o){if(e.overscaledZ+t<i)continue;const n=r(e.calculateScaledKey(e.overscaledZ+t));if(n)return n}},u=[0,0,0],h=(e,t)=>(u[0]=Math.min(e.min.y,t.min.y),u[1]=Math.max(e.max.y,t.max.y),u[2]=Mn-t.min.x>e.max.x?t.min.x-Mn:e.max.x,u),d=(e,t)=>(u[0]=Math.min(e.min.x,t.min.x),u[1]=Math.max(e.max.x,t.max.x),u[2]=Mn-t.min.y>e.max.y?t.min.y-Mn:e.max.y,u),p=[(e,t)=>h(e,t),(e,t)=>h(t,e),(e,t)=>d(e,t),(e,t)=>d(t,e)],f=(e,t,r,n,s,l,c)=>{if(!o)return 0;const u=[[l?r:e,l?e:r,0],[l?r:t,l?t:r,0]],h=c<0?Mn+c:c,d=[l?h:(e+t)/2,l?(e+t)/2:h,0];return 0===r&&c<0||0!==r&&c>0?o.getForTilePoints(s,[d],!0,n):u.push(d),o.getForTilePoints(i,u,!0,a),Math.max(u[0][2],u[1][2],d[2])/o.exaggeration()};for(let e=0;e<4;e++){const t=r.borderFeatureIndices[e];if(0===t.length)continue;const n=tc[e](i),a=c(n);if(!(a&&a instanceof FillExtrusionBucket))continue;const u=o?o.findDEMTileFor(n):null;if(!(u&&u.dem||s))continue;if(o&&u&&u.dem&&r.borderDEMTileTimestamp[e]!==u.dem._timestamp&&(r.borderDoneWithNeighborZ[e]=-1,r.borderDEMTileTimestamp[e]=u.dem._timestamp),r.borderDoneWithNeighborZ[e]===a.canonical.z)continue;0===a.centroidVertexArray.length&&a.createCentroidsBuffer();const h=(e<2?1:5)-e,d=a.borderDoneWithNeighborZ[h]!==r.canonical.z,g=a.borderFeatureIndices[h];let y=0;if(r.canonical.z!==a.canonical.z){for(const e of t)r.showCentroid(r.featuresOnBorder[e]);if(d)for(const e of g)a.showCentroid(a.featuresOnBorder[e]);r.borderDoneWithNeighborZ[e]=a.canonical.z,a.borderDoneWithNeighborZ[h]=r.canonical.z}for(const i of t){const t=r.featuresOnBorder[i],o=r.centroidData[t.centroidDataIndex],c=t.borders[e];let d;for(;y<g.length;){d=a.featuresOnBorder[g[y]];const e=d.borders[h];if(e[1]>c[0]+3||e[0]>c[0]-3)break;a.showCentroid(d),y++}if(d&&y<g.length){const i=y;let x=0;for(;!(d.borders[h][0]>c[1]-3)&&(x++,++y!==g.length);)d=a.featuresOnBorder[g[y]];d=a.featuresOnBorder[g[i]];let v=!1;if(x>=1){const e=d.borders[h];Math.abs(c[0]-e[0])<3&&Math.abs(c[1]-e[1])<3&&(x=1,v=!0,y=i+1)}else if(0===x){r.showCentroid(t);continue}const b=a.centroidData[d.centroidDataIndex];s&&v&&(((m=o).flags|(_=b).flags)&wh?(m.flags|=wh,_.flags|=wh):(m.flags&=2147483647,_.flags&=2147483647));const w=t.intersectsCount()>1||d.intersectsCount()>1;if(x>1)y=i,o.centroidXY=b.centroidXY=new Le(0,0);else if(u&&u.dem&&!w){const t=p[e](o,b),i=e%2?Mn-1:0,r=f(t[0],Math.min(Mn-1,t[1]),i,u,n,e<2,t[2]);o.centroidXY=b.centroidXY=l(r)}else w?o.centroidXY=b.centroidXY=new Le(0,0):(o.centroidXY=r.encodeBorderCentroid(t),b.centroidXY=a.encodeBorderCentroid(d));r.writeCentroidToBuffer(o),a.writeCentroidToBuffer(b)}else r.showCentroid(t)}r.borderDoneWithNeighborZ[e]=a.canonical.z,a.borderDoneWithNeighborZ[h]=r.canonical.z}var m,_;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(e)}const Xw=[1,0,0],Yw=[0,1,0],Kw=[0,0,1];function Jw(e,t,i){const r=i.transform,n=i.shadowRenderer;if(!n)return!0;const o=e.toUnwrapped(),s=r.tileSize*n._cascades[i.currentShadowCascade].scale;let a=t;if(r.elevation){const t=r.elevation.getMinMaxForTile(e);t&&(a+=t.max)}const l=[...n.shadowDirection];l[2]=-l[2];const c=n.computeSimplifiedTileShadowVolume(o,a,s,l);if(!c)return!1;const u=[Xw,Yw,Kw,l,[l[0],0,l[2]],[0,l[1],l[2]]],h="globe"===r.projection.name,d=r.scaleZoom(s),p=Frustum.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,d,!h),f=n.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(c.vertices,c.planes,u)||0===f.intersectsPrecise(c.vertices,c.planes,u)}function Qw(e){const{painter:t,source:i,layer:r,coords:n}=e;let o=e.defines;const s=t.context,a="shadow"===t.renderPass,c="light-beam"===t.renderPass,u=t.shadowRenderer,p=al(t.transform.center.lat,t.transform.zoom),f=Zv(t,r.paint.get("building-cutoff-fade-range"));f.shouldRenderCutoff&&(o=o.concat("RENDER_CUTOFF")),e.floodLightIntensity>0&&(o=o.concat("FLOOD_LIGHT"));for(const _ of n){const n=i.getTile(_),g=n.getBucket(r);if(!g)continue;u&&0===u.getMaxCascadeForTile(_.toUnwrapped())&&(o=o.concat("SHADOWS_SINGLE_CASCADE"));const y=g.programConfigurations.get(r.id);let x,v,b,w=t.translatePosMatrix(_.expandedProjMatrix,n,[0,0],"map");if(w=m(l(),w,[1,1,e.verticalScale]),a&&u){if(Jw(n.tileID,g.maxHeight*p,t))continue;let i=u.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());i=m(l(),i,[1,1,e.verticalScale]),b=pw(i),x=v=t.getOrCreateProgram("buildingDepth",{config:y,defines:o,overrideFog:!1})}else if(c)x=v=t.getOrCreateProgram("buildingBloom",{config:y,defines:o,overrideFog:!1}),b=dw(w);else{const i=t.transform.calculatePosMatrix(_.toUnwrapped(),t.transform.worldSize);m(i,i,[1,1,e.verticalScale]);const r=l();m(r,i,[1,-1,1/p]),d(r,r),h(r,r);const n=t.transform.getFreeCameraOptions().position,s=1<<_.canonical.z;if(b=hw(w,r,e.opacity,e.facadeAOIntensity,[((n.x-_.wrap)*s-_.canonical.x)*Mn,(n.y*s-_.canonical.y)*Mn,n.z*s*Mn],g.tileToMeter,e.facadeEmissiveChance,e.floodLightColor,e.floodLightIntensity),v=t.getOrCreateProgram("building",{config:y,defines:o,overrideFog:!1}),!0===e.depthOnly)x=v;else{const e=o.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);x=t.getOrCreateProgram("building",{config:y,defines:e,overrideFog:!1})}u&&(u.setupShadowsFromMatrix(i,v,!0),x!==v&&u.setupShadowsFromMatrix(i,x,!0))}const T=(i,n)=>{if(c){const o=i.entranceBloom;n.draw(t,s.gl.TRIANGLES,e.depthMode,StencilMode.disabled,e.blendMode,CullFaceMode.disabled,b,r.id,o.layoutVertexBuffer,o.indexBuffer,o.segmentsBucket,r.paint,t.transform.zoom,y,[o.layoutAttenuationBuffer,o.layoutColorBuffer])}else{const o=i.segmentsBucket;let l=[i.layoutNormalBuffer,i.layoutCentroidBuffer,i.layoutColorBuffer,i.layoutFloodLightDataBuffer];i.layoutFacadePaintBuffer&&(l=l.concat([i.layoutFacadeDataBuffer,i.layoutFacadeVerticalRangeBuffer,i.layoutFacadePaintBuffer])),n.draw(t,s.gl.TRIANGLES,e.depthMode,StencilMode.disabled,e.blendMode,a?CullFaceMode.disabled:CullFaceMode.backCW,b,r.id,i.layoutVertexBuffer,i.indexBuffer,o,r.paint,t.transform.zoom,y,l)}};t.uploadCommonUniforms(s,v,_.toUnwrapped(),null,f),g.buildingWithoutFacade&&T(g.buildingWithoutFacade,v),g.buildingWithFacade&&(x!==v&&t.uploadCommonUniforms(s,x,_.toUnwrapped(),null,f),T(g.buildingWithFacade,x))}}function eT(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=e.context.gl,f=e.depthModeForSublayer(1,DepthMode.ReadOnly,p.LEQUAL,!0),m=.1*(1-(_=u))+3*_;var _;const g=e._showOverdrawInspector,y=h,x=new GroundEffectProperties;g||Zw(x,e,t,i,r,f,new StencilMode({func:p.ALWAYS,mask:255},255,255,p.KEEP,p.KEEP,p.REPLACE),new ColorMode([p.ONE,p.ONE,p.ONE,p.ONE],Color.transparent,[!1,!1,!1,!0],p.MIN),CullFaceMode.disabled,n,"sdf",o,s,a,l,c,m,y,!1);{const u=g?StencilMode.disabled:new StencilMode({func:p.EQUAL,mask:255},255,255,p.KEEP,p.DECR,p.DECR),h=g?e.colorModeForRenderPass():new ColorMode([p.ONE_MINUS_DST_ALPHA,p.DST_ALPHA,p.ONE,p.ONE],Color.transparent,[!0,!0,!0,!0]);Zw(x,e,t,i,r,f,u,h,CullFaceMode.disabled,n,"color",o,s,a,l,c,m,y,!1)}}function tT(e){return[e[0]*$m,e[1]*$m,e[2]*$m,0]}function iT(e,t,i,r,n,o,s,a,c){const u=r.getSource(),h=i.globeSharedBuffers;if(!h)return;let d,p,f;if(t&&(d=r.getTile(t)),u instanceof ImageSource?(p=u.texture,f=Ic(0,0,i.transform)):d&&t&&(p=d.texture,f=Ic(t.canonical.z,t.canonical.x,i.transform)),!p||!f)return;e||(f=m(l(),f,[1,-1,1]));const _=i.context,g=_.gl,y="nearest"===n.paint.get("raster-resampling")?g.NEAREST:g.LINEAR,x=i.colorModeForDrapableLayerRenderPass(o),v=s.defines;v.push("GLOBE_POLES");const b=new DepthMode(g.LEQUAL,DepthMode.ReadWrite,i.depthRangeFor3D),w=Float32Array.from(i.transform.expandedFarZProjMatrix),T=Float32Array.from(vc(uc(new CanonicalTileID(0,0,0))));i.terrain&&i.terrain.prepareDrawTile(),_.activeTexture.set(g.TEXTURE0),p.bind(y,g.CLAMP_TO_EDGE),_.activeTexture.set(g.TEXTURE1),p.bind(y,g.CLAMP_TO_EDGE),"useMipmap"in p&&_.extTextureFilterAnisotropic&&i.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,_.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,_.extTextureFilterAnisotropicMax);const[E,S,A,I]=t?h.getPoleBuffers(t.canonical.z,!1):h.getPoleBuffers(0,!0),C=n.paint.get("raster-elevation");let M;e?(M=E,i.renderDefaultNorthPole=0!==C):(M=S,i.renderDefaultSouthPole=0!==C);const D=tT(s.mix),P=((e,t,i,r,n,o,s,a,l,c,u,h,d)=>vw(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||[0,0],a,2,c,u,h,1,0,d))(w,T,f,Ac(i.transform.zoom),0,n,0,C,0,D,s.offset,s.range,o),L=i.getOrCreateProgram("raster",{defines:v});i.uploadCommonUniforms(_,L,null),L.draw(i,g.TRIANGLES,b,c,x,a,P,n.id,M,A,I)}function rT(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}function nT(e,t,i,r){if(e)return t instanceof RasterArrayTileSource&&e instanceof RasterArrayTile?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:tT(r.mix),offset:r.offset,buffer:0,tileSize:1}}var oT=_a([{name:"a_index",type:"Int16",components:1}]);class RasterParticleState{constructor(e,t,i,r){const n={width:i[0],height:i[1],data:null},o=e.gl;this.targetColorTexture=new Texture(e,n,o.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new Texture(e,n,o.RGBA8,{useMipmap:!1}),this.context=e,this.updateParticleTexture(t,r),this.lastInvalidatedAt=0}updateParticleTexture(e,t){if(this.particleTextureDimension===t.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const i=this.context.gl,r=t.width*t.height;this.particleTexture0=new Texture(this.context,t,i.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new Texture(this.context,t,i.RGBA8,{premultiply:!1,useMipmap:!1});const n=new StructArrayLayout1i2;n.reserve(r);for(let e=0;e<r;e++)n.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(n,oT.members,!0),this.particleSegment=SegmentVector.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=t.width}update(e){return!(this.lastInvalidatedAt<e&&(this.lastInvalidatedAt=Wt.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function sT(e,t,i){if(!e)return null;const r=t.getTextureDescriptor(e,i,!0);if(!r)return null;let{texture:n,mix:o,offset:s,tileSize:a,buffer:l,format:c}=r;if(!n||!c)return null;let u=!1;return"uint32"===c&&(u=!0,o[3]=0,o=yw(256,o,[0,i.paint.get("raster-particle-max-speed")]),s=xw(256,s,[0,i.paint.get("raster-particle-max-speed")])),{texture:n,textureOffset:[l/(a+2*l),a/(a+2*l)],tileSize:a,scalarData:u,scale:o,offset:s,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[c]]}}function aT(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}const lT=new Color(1,0,0,1),cT=new Color(0,1,0,1),uT=new Color(0,0,1,1),hT=new Color(1,0,1,1),dT=new Color(0,1,1,1);function pT(e,t,i,r,n,o){for(let s=0;s<i.length;s++)if(n){const n=1,a=.8,l=new Color(r.r*a,r.g*a,r.b*a,1);fT(e,t,i[s],r,-n,-n,o),fT(e,t,i[s],r,-n,n,o),fT(e,t,i[s],r,n,n,o),fT(e,t,i[s],r,n,-n,o),fT(e,t,i[s],l,0,0,o)}else fT(e,t,i[s],r,0,0,o)}function fT(e,t,i,r,n,o,s){const a=e.context,u=e.transform,h=a.gl,d="globe"===u.projection.name,f=d?["PROJECTION_GLOBE_VIEW"]:[];let m=c(i.projMatrix);if(d&&Ac(u.zoom)>0){const e=bc(dc(i.canonical,u));m=p(new Float32Array(16),u.globeMatrix,e),p(m,u.projMatrix,m)}const _=l();_[12]+=2*n/(Wt.devicePixelRatio*u.width),_[13]+=2*o/(Wt.devicePixelRatio*u.height),p(m,_,m);const g=e.getOrCreateProgram("debug",{defines:f}),y=t.getTileByID(i.key);e.terrain&&e.terrain.setupElevationDraw(y,g);const x=DepthMode.disabled,v=StencilMode.disabled,b=e.colorModeForRenderPass(),w="$debug";a.activeTexture.set(h.TEXTURE0),e.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),d?y._makeGlobeTileDebugBuffers(e.context,u):y._makeDebugTileBoundsBuffers(e.context,u.projection);const T=y._tileDebugBuffer||e.debugBuffer,E=y._tileDebugIndexBuffer||e.debugIndexBuffer,S=y._tileDebugSegments||e.debugSegments;if(g.draw(e,h.LINE_STRIP,x,v,b,CullFaceMode.disabled,mw(m,r.toPremultipliedRenderColor(null)),w,T,E,S,null,null,null,[y._globeTileDebugBorderBuffer]),s){const t=y.latestRawTileData,r=Math.floor((t&&t.byteLength||0)/1024);let n=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(n+=` => ${i.overscaledZ}`),n+=` ${y.state}`,n+=` ${r}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,n)}const A=t.getTile(i).tileSize,I=512/Math.min(A,512)*(i.overscaledZ/u.zoom)*.5,C=y._tileDebugTextBuffer||e.debugBuffer,M=y._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,D=y._tileDebugTextSegments||e.debugSegments;g.draw(e,h.TRIANGLES,x,v,ColorMode.alphaBlended,CullFaceMode.disabled,mw(m,Color.transparent.toPremultipliedRenderColor(null),I),w,C,M,D,null,null,null,[y._globeTileDebugTextBuffer])}function mT(e,t,i,r){gT(e,0,t+i/2,e.transform.width,i,r)}function _T(e,t,i,r){gT(e,t-i/2,0,i,e.transform.height,r)}function gT(e,t,i,r,n,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*Wt.devicePixelRatio,i*Wt.devicePixelRatio,r*Wt.devicePixelRatio,n*Wt.devicePixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}const yT=_a([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:xT}=yT;function vT(e,t,i,r){e.emplaceBack(t,i,r)}class SkyboxGeometry{constructor(e){this.vertexArray=new StructArrayLayout3f12,this.indices=new StructArrayLayout3ui6,vT(this.vertexArray,-1,-1,1),vT(this.vertexArray,1,-1,1),vT(this.vertexArray,-1,1,1),vT(this.vertexArray,1,1,1),vT(this.vertexArray,-1,-1,-1),vT(this.vertexArray,1,-1,-1),vT(this.vertexArray,-1,1,-1),vT(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=e.createVertexBuffer(this.vertexArray,xT),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=SegmentVector.simpleSegment(0,0,36,12)}}function bT(e,t,i,o,s,a){const l=e.context.gl,c=t.paint.get("sky-atmosphere-color"),u=t.paint.get("sky-atmosphere-halo-color"),h=t.paint.get("sky-atmosphere-sun-intensity"),d=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(n(r(),o),s,h,c.toPremultipliedRenderColor(null),u.toPremultipliedRenderColor(null));l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_CUBE_MAP_POSITIVE_X+a,t.skyboxTexture,0),i.draw(e,l.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.unblended,CullFaceMode.frontCW,d,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}const wT=_a([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class AtmosphereBuffer{constructor(e){const t=new StructArrayLayout5f20;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const i=new StructArrayLayout3ui6;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(t,wT.members),this.indexBuffer=e.createIndexBuffer(i),this.segments=SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const TT=_a([{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_fade_opacity",components:1}]);class StarsParams{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Atmosphere{constructor(e){this.colorModeAlphaBlendedWriteRGB=new ColorMode([1,kv,1,kv],Color.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new ColorMode([1,0,1,0],Color.transparent,[!1,!1,!1,!0]),this.params=new StarsParams,this.updateNeeded=!0}update(e){const t=e.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new AtmosphereBuffer(t);const e=this.params.sizeRange,i=this.params.intensityRange,r=function(e){const t=jo(30),i=[];for(let r=0;r<e;++r){const e=2*Math.PI*t(),r=Math.acos(1-2*t())-.5*Math.PI;i.push(D(Math.cos(r)*Math.cos(e),Math.cos(r)*Math.sin(e),Math.sin(r)))}return i}(this.params.starsCount),n=jo(300),o=new StructArrayLayout7f28,s=new StructArrayLayout3ui6;let a=0;for(let t=0;t<r.length;++t){const l=B([],r[t],200),c=Math.max(0,1+.01*e*(1*n()-.5)),u=Math.max(0,1+.01*i*(1*n()-.5));o.emplaceBack(l[0],l[1],l[2],-1,-1,c,u),o.emplaceBack(l[0],l[1],l[2],1,-1,c,u),o.emplaceBack(l[0],l[1],l[2],1,1,c,u),o.emplaceBack(l[0],l[1],l[2],-1,1,c,u),s.emplaceBack(a+0,a+1,a+2),s.emplaceBack(a+0,a+2,a+3),a+=4}this.starsVx=t.createVertexBuffer(o,TT.members),this.starsIdx=t.createIndexBuffer(s),this.starsSegments=SegmentVector.simpleSegment(0,0,o.length,s.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy()}drawAtmosphereGlow(e,t){const i=e.context,r=i.gl,n=e.transform,o=new DepthMode(r.LEQUAL,DepthMode.ReadOnly,[0,1]),s=Ac(n.zoom),a=e.style.getLut(t.scope),l="none"===t.properties.get("color-use-theme"),c=t.properties.get("color").toNonPremultipliedRenderColor(l?null:a),u="none"===t.properties.get("high-color-use-theme"),h=t.properties.get("high-color").toNonPremultipliedRenderColor(u?null:a),d="none"===t.properties.get("space-color-use-theme"),p=t.properties.get("space-color").toNonPremultipliedRenderColor(d?null:a),f=5e-4,m=He((t.properties.get("horizon-blend")-0)/1*.2495+(w=f),w,.25),_=Cc(e,0,n)&&m===f?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,g=e.frameCounter/1e3%1,y=M(n.globeCenterInViewSpace),x=Math.sqrt(Math.pow(y,2)-Math.pow(_,2)),v=Math.acos(x/y),b=t=>{const a="globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];t&&a.push("ALPHA_PASS");const l=e.getOrCreateProgram("globeAtmosphere",{defines:a}),u=((e,t,i,r,n,o,s,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:s,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:u,u_horizon_angle:h}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,s,m,c,h,p,g,v);e.uploadCommonUniforms(i,l);const d=this.atmosphereBuffer;d&&l.draw(e,r.TRIANGLES,o,StencilMode.disabled,t?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,CullFaceMode.backCW,u,t?"atmosphere_glow_alpha":"atmosphere_glow",d.vertexBuffer,d.indexBuffer,d.segments)};var w;b(!1),b(!0)}drawStars(e,t){const i=He(t.properties.get("star-intensity"),0,1);if(0===i)return;const r=e.context,o=r.gl,s=e.transform,a=e.getOrCreateProgram("stars"),l=le([]);ce(l,l,-s._pitch),he(l,l,-s.angle),ce(l,l,Oe(s._center.lat)),ue(l,l,-Oe(s._center.lng));const c=T(new Float32Array(16),l),u=p([],s.starsProjMatrix,c),h=(d=[],(C=(m=(f=n([],c))[0])*(S=(E=f[8])*(x=f[4])-(v=f[5])*(w=f[7]))+(_=f[1])*(A=-E*(y=f[3])+v*(b=f[6]))+(g=f[2])*(I=w*y-x*b))?(d[0]=S*(C=1/C),d[1]=(-E*_+g*w)*C,d[2]=(v*_-g*x)*C,d[3]=A*C,d[4]=(E*m-g*b)*C,d[5]=(-v*m+g*y)*C,d[6]=I*C,d[7]=(-w*m+_*b)*C,d[8]=(x*m-_*y)*C,d):null);var d,f,m,_,g,y,x,v,b,w,E,S,A,I,C;const M=[0,1,0];W(M,M,h),B(M,M,this.params.sizeMultiplier);const D=[1,0,0];W(D,D,h),B(D,D,this.params.sizeMultiplier);const P=((e,t,i,r)=>({u_matrix:Float32Array.from(e),u_up:t,u_right:i,u_intensity_multiplier:r}))(u,M,D,i);e.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(e,o.TRIANGLES,DepthMode.disabled,StencilMode.disabled,this.colorModeAlphaBlendedWriteRGB,CullFaceMode.disabled,P,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class BuildingTileBorderManager{constructor(){this.visibleTiles=[]}updateBorders(e,t){const i=[],r=[],n=e._getRenderableCoordinates(!1,!0);for(const o of n){const n=e.getTile(o);if(!n.hasData())continue;const s=n.getBucket(t);s&&(s.isEmpty()||(i.push(o.key),r.push({bucket:s,tileID:o.canonical})))}let o=i.length!==this.visibleTiles.length;if(!o){i.sort();for(let e=0;e<i.length;e++)if(i[e]!==this.visibleTiles[e]){o=!0;break}}if(!o)return;const s=new Set;this.visibleTiles=i,r.sort(((e,t)=>e.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y));for(const e of r){const t=new Array,i=new Array,r=e.bucket;for(const e of r.featuresOnBorder)s.has(e.featureId)?i.push(e.footprintIndex):(s.add(e.featureId),t.push(e.footprintIndex));r.updateFootprintHiddenFlags(t,2,!1),r.updateFootprintHiddenFlags(i,2,!0)}}}function ET(e,t){const i=[...e],r=t.cameraWorldSizeForFog/t.worldSize,n=u([]);return m(n,n,[r,r,1]),p(i,n,i),p(i,t.worldToFogMatrix,i),i}function ST(e,t,i,r,n){const o=i.material,s=r.context,{baseColorTexture:a,metallicRoughnessTexture:l}=o.pbrMetallicRoughness,{normalTexture:c,occlusionTexture:u,emissionTexture:h}=o;function d(t,i,r){if(t&&(e.push(i),s.activeTexture.set(s.gl.TEXTURE0+r),t.gfxTexture)){const{minFilter:e,magFilter:i,wrapS:r,wrapT:n}=t.sampler;t.gfxTexture.bindExtraParam(e,i,r,n)}}d(a,"HAS_TEXTURE_u_baseColorTexture",qv.BaseColor),d(l,"HAS_TEXTURE_u_metallicRoughnessTexture",qv.MetallicRoughness),d(c,"HAS_TEXTURE_u_normalTexture",qv.Normal),d(u,"HAS_TEXTURE_u_occlusionTexture",qv.Occlusion),d(h,"HAS_TEXTURE_u_emissionTexture",qv.Emission),n&&(n.texture||(n.texture=new Texture3D(r.context,n.image,[n.image.height,n.image.height,n.image.height],s.gl.RGBA8)),s.activeTexture.set(s.gl.TEXTURE0+qv.LUT),n.texture&&n.texture.bind(s.gl.LINEAR,s.gl.CLAMP_TO_EDGE),e.push("APPLY_LUT_ON_GPU")),i.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(i.texcoordBuffer)),i.colorBuffer&&(e.push(12===i.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(i.colorBuffer)),i.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(i.normalBuffer)),i.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(i.pbrBuffer)),"OPAQUE"!==o.alphaMode&&"MASK"!==o.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),o.defined||e.push("DIFFUSE_SHADED");const p=r.shadowRenderer;p&&(e.push("RENDER_SHADOWS","DEPTH_TEXTURE"),p.useNormalOffset&&e.push("NORMAL_OFFSET"))}function AT(e,t,i,r,n,o){const s=e.modelOpacity,a=t.context,l=new DepthMode(t.context.gl.LEQUAL,e.isLightMesh?DepthMode.ReadOnly:DepthMode.ReadWrite,t.depthRangeFor3D),c=t.transform,u=e.mesh,f=u.material,m=f.pbrMetallicRoughness,_=t.style.fog;let g;g="pixels"===t.transform.projection.zAxisUnit?[...e.nodeModelMatrix]:p([],r.zScaleMatrix,e.nodeModelMatrix),p(g,r.negCameraPosMatrix,g);const y=d([],g);h(y,y);const x="none"===i.paint.get("model-color-use-theme").constantOr("default"),v=i.paint.get("model-emissive-strength").constantOr(0),b=Pw(new Float32Array(e.worldViewProjection),new Float32Array(g),new Float32Array(y),null,t,s,m.baseColorFactor,f.emissiveFactor,m.metallicFactor,m.roughnessFactor,f,v,i,void 0,void 0,e.materialOverride,e.modelColor),w={defines:[]},T=[],E=t.shadowRenderer;E&&(E.useNormalOffset=!1),ST(w.defines,T,u,t,x?null:i.lut);let S=null;if(_){const i=ET(e.nodeModelMatrix,t.transform);if(S=new Float32Array(i),"globe"!==c.projection.name){const e=u.aabb.min,t=u.aabb.max,[r,n]=_.getOpacityForBounds(i,e[0],e[1],t[0],t[1]);w.overrideFog=r>=ry||n>=ry}}const A=Zv(t,i.paint.get("model-cutoff-fade-range"));A.shouldRenderCutoff&&w.defines.push("RENDER_CUTOFF");const I=t.getOrCreateProgram("model",w);t.uploadCommonUniforms(a,I,null,S,A),"shadow"!==t.renderPass&&E&&E.setupShadowsFromMatrix(e.nodeModelMatrix,I),I.draw(t,a.gl.TRIANGLES,l,n,o,u.material.doubleSided?CullFaceMode.disabled:CullFaceMode.backCCW,b,i.id,u.vertexBuffer,u.indexBuffer,u.segments,i.paint,t.transform.zoom,void 0,T)}function IT(e,t){return e.style._importedAsBasemap?"basemap":t.scope}function CT(e,t,i,r,n,o,s,a,l,c){const u=e.transform,h=!!t.isGeometryBloom&&t.isGeometryBloom;if(h&&"shadow"===e.renderPass)return;const d="globe"===u.projection.name?Yd(i,u):[...i];p(d,d,t.globalMatrix);const f=p([],r,d);if(t.meshes)for(const e of t.meshes){const t=a.get(e.material.name);if(t&&t.opacity<=0)continue;if("BLEND"!==e.material.alphaMode){s.push({mesh:e,depth:0,modelIndex:n,worldViewProjection:f,nodeModelMatrix:d,isLightMesh:h,materialOverride:t,modelOpacity:l,modelColor:c});continue}const i=Z([],e.centroid,f);!u.isOrthographic&&i[2]<=0||o.push({mesh:e,depth:i[2],modelIndex:n,worldViewProjection:f,nodeModelMatrix:d,isLightMesh:h,materialOverride:t,modelOpacity:l,modelColor:c})}if(t.children)for(const u of t.children)CT(e,u,i,r,n,o,s,a,l,c)}function MT(e,t,i,r){const n=i.shadowRenderer;if(!n)return;const o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),a=n.calculateShadowPassMatrixFromMatrix(t),l=Lw(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,StencilMode.disabled,s,CullFaceMode.disabled,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,i.transform.zoom,void 0,void 0)}function DT(e,t,i,r,n,o){for(const s of n){const n=Object.assign({},r);n.part=s;const a={type:"Unknown",id:t,properties:n},l={orientation:e.paint.get("model-rotation").evaluate(a,i)};o.set(s,l)}}function PT(e,t,i,r,n,o){for(const s of n){const n=Object.assign({},r);n.part=s;const a={type:"Unknown",id:t,properties:n},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)};o.set(s,l)}}function LT(e,t,i,r,n){let o=!1;for(const i of r)1!==i.modelOpacity&&(AT(i,e,t,n[i.modelIndex],StencilMode.disabled,ColorMode.disabled),o=!0);for(const i of r)AT(i,e,t,n[i.modelIndex],1!==i.modelOpacity?e.stencilModeFor3D():StencilMode.disabled,e.colorModeForRenderPass());o&&e.resetStencilClippingMasks();const s=ColorMode.additive;for(const r of i)AT(r,e,t,n[r.modelIndex],StencilMode.disabled,r.isLightMesh?s:e.colorModeForRenderPass())}function RT(e,t,i){const r=t.updateZoomBasedPaintProperties(),n=function(e,t,i){let r,n,o,s=e.terrain?e.terrain.exaggeration():0;if(e.terrain&&s>0){const t=e.terrain,n=t.findDEMTileFor(i);n&&n.dem?r=DEMSampler.create(t,i,n):s=0}if(0===s&&(t.terrainElevationMin=0,t.terrainElevationMax=0),s===t.validForExaggeration&&(0===s||r&&r._demTile&&r._demTile.tileID===t.validForDEMTile.id&&r._dem._timestamp===t.validForDEMTile.timestamp))return!1;for(const e in t.instancesPerModel){const i=t.instancesPerModel[e];for(let e=0;e<i.instancedDataArray.length;++e){const a=(r?s*r.getElevationAt(0|i.instancedDataArray.float32[16*e],0|i.instancedDataArray.float32[16*e+1],!0,!0):0)+i.instancesEvaluatedElevation[e];i.instancedDataArray.float32[16*e+6]=a,n=n?Math.min(t.terrainElevationMin,a):a,o=o?Math.max(t.terrainElevationMax,a):a}}return t.terrainElevationMin=n||0,t.terrainElevationMax=o||0,t.validForExaggeration=s,t.validForDEMTile=r&&r._demTile?{id:r._demTile.tileID,timestamp:r._dem._timestamp}:{id:void 0,timestamp:0},!0}(e,t,i);(r||n)&&(t.uploaded=!1,t.upload(e.context))}const zT={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new Aabb([0,0,0],[Mn,Mn,0])};function FT(e,t){const i=1<<e.canonical.z,r=t.getFreeCameraOptions().position,n=t.elevation,o=e.canonical.x/i,s=(e.canonical.x+1)/i,a=e.canonical.y/i,l=(e.canonical.y+1)/i;let c=t._centerAltitude;if(n){const t=n.getMinMaxForTile(e);t&&t.max>c&&(c=t.max)}const u=He(r.x,o,s)-r.x,h=He(r.y,a,l)-r.y,d=tl(c,t.center.lat)-r.z;return t._zoomFromMercatorZ(Math.sqrt(u*u+h*h+d*d))}function OT(e,t,i,r,n,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new DepthMode(a.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o),d="globe"===e.transform.projection.name;if(i.meshes)for(const p of i.meshes){const f=d?[]:["MODEL_POSITION_ON_GPU"],m=[];let _,g,y;const x=!d&&r.instancedDataArray.length>20;x&&f.push("INSTANCED_ARRAYS");const v=Zv(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)_=e.getOrCreateProgram("modelDepth",{defines:f}),g=Lw(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.globalMatrix)),y=c.getShadowPassColorMode();else{ST(f,m,p,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),_=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const r=p.material,l=r.pbrMetallicRoughness,u=t.paint.get("model-opacity").constantOr(1),d=t.paint.get("model-emissive-strength").constantOr(0);g=Pw(o.expandedProjMatrix,Float32Array.from(i.globalMatrix),new Float32Array(16),null,e,u,l.baseColorFactor,r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,d,t,n),c&&(s.shadowUniformsInitialized?_.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),_,"model-tile"),s.shadowUniformsInitialized=!0)),y=v.shouldRenderCutoff||u<1||"OPAQUE"!==r.alphaMode?ColorMode.alphaBlended:ColorMode.unblended}e.uploadCommonUniforms(a,_,o.toUnwrapped(),null,v);const b=p.material.doubleSided?CullFaceMode.disabled:CullFaceMode.backCCW;if(x)m.push(r.instancedDataBuffer),_.draw(e,a.gl.TRIANGLES,u,StencilMode.disabled,y,b,g,t.id,p.vertexBuffer,p.indexBuffer,p.segments,t.paint,e.transform.zoom,void 0,m,r.instancedDataArray.length);else{const i=l?"u_instance":"u_normal_matrix";for(let n=0;n<r.instancedDataArray.length;++n)g[i]=new Float32Array(r.instancedDataArray.arrayBuffer,64*n,16),_.draw(e,a.gl.TRIANGLES,u,StencilMode.disabled,y,b,g,t.id,p.vertexBuffer,p.indexBuffer,p.segments,t.paint,e.transform.zoom,void 0,m)}}if(i.children)for(const a of i.children)OT(e,t,a,r,n,o,s)}const BT=[1,-1,1];function kT(e,t,i,r){if(!i.modelManager)return!0;const n=i.modelManager;if(!i.shadowRenderer)return!0;const o=i.shadowRenderer,s=t.aabb;let a=!0,l=e.maxHeight;if(0===l){let t=0;for(const i in e.instancesPerModel){const e=n.getModel(i,r);e?t=Math.max(t,Math.max(Math.max(e.aabb.max[0],e.aabb.max[1]),e.aabb.max[2])):a=!1}l=e.maxScale*t*1.41+e.maxVerticalOffset,a&&(e.maxHeight=l)}s.max[2]=l,s.min[2]+=e.terrainElevationMin,s.max[2]+=e.terrainElevationMax,Z(s.min,s.min,t.tileMatrix),Z(s.max,s.max,t.tileMatrix);const c=s.intersects(o.getCurrentCascadeFrustum());return 0===i.currentShadowCascade&&(e.isInsideFirstShadowMapFrustum=2===c),0===c}function UT(e,t){const i=e.uniformValues.u_cutoff_params[0],r=e.uniformValues.u_cutoff_params[1],n=e.uniformValues.u_cutoff_params[2],o=e.uniformValues.u_cutoff_params[3];return r===i||o===n?1:He(((t-i)/(r-i)-n)/(o-n),0,1)}function VT(e,t,i,r){if(t.pitch<20)return 1;const n=t.getWorldToCameraMatrix();p(n,n,e);const o=re(i.min[0],i.min[1],i.min[2],1);let s=se(ie(),o,n),a=s,l=s;o[1]=i.max[1],s=se(ie(),o,n),a=s[1]<a[1]?s:a,l=s[1]>l[1]?s:l,o[0]=i.max[0],s=se(ie(),o,n),a=s[1]<a[1]?s:a,l=s[1]>l[1]?s:l,o[1]=i.min[1],s=se(ie(),o,n),a=s[1]<a[1]?s:a,l=s[1]>l[1]?s:l;const c=He(r[0],0,1),u=100*t.pixelsPerMeter*He(r[1],0,1),h=He(r[2],0,1),d=(f=ie(),x=(m=a)[1],v=m[2],b=m[3],f[0]=(y=m[0])+(g=c)*((_=l)[0]-y),f[1]=x+g*(_[1]-x),f[2]=v+g*(_[2]-v),f[3]=b+g*(_[3]-b),f);var f,m,_,g,y,x,v,b;const w=Math.tan(.5*t.fovX),T=-d[2]*w;if(0===u)return d[1]<-Math.abs(T)?h:1;const E=(e,t,i)=>(1-i)*e+i*t,S=He(E(1,h,(-Math.abs(T)-d[1])/u),h,1);return E(1,S,He((t.pitch-20)/20,0,1))}class CacheEntry{}class WireframeDebugCache{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(e,t,i){{const i=this._storage.get(t.id);if(i)return i.lastUsedFrameIdx=e,i.buf}const r=i.gl,n=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),o=new ArrayBuffer(n),s=new Int16Array(o);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(o));const a=new StructArrayLayout2ui4;for(let e=0;e<n/2;e+=3){const t=s[e],i=s[e+1],r=s[e+2];a.emplaceBack(t,i),a.emplaceBack(i,r),a.emplaceBack(r,t)}const l=i.bindVertexArrayOES.current,c=new CacheEntry;return c.buf=new IndexBuffer(i,a),c.lastUsedFrameIdx=e,this._storage.set(t.id,c),i.bindVertexArrayOES.set(l),c.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 OcclusionParams{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const NT=_a([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class PrecipitationRevealParams{constructor(e){this.revealStart=11,this.revealRange=2}}const jT=_a([{type:"Float32",name:"a_pos_2f",components:2}]);class Vignette{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(e,t){const i=e.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const t=new StructArrayLayout2f8,i=new StructArrayLayout3ui6;t.emplaceBack(-1,-1),t.emplaceBack(1,-1),t.emplaceBack(1,1),t.emplaceBack(-1,1),i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),this.vignetteVx=e.context.createVertexBuffer(t,jT.members),this.vignetteIdx=e.context.createIndexBuffer(i)}const r=SegmentVector.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){e.uploadCommonUniforms(e.context,i);const o={u_vignetteShape:(n={vignetteShape:[t.start,t.range,Math.pow(10,t.fadePower)],vignetteColor:[t.color.r,t.color.g,t.color.b,t.color.a*t.strength]}).vignetteShape,u_vignetteColor:n.vignetteColor};i.draw(e,e.context.gl.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.alphaBlended,CullFaceMode.disabled,o,"vignette",this.vignetteVx,this.vignetteIdx,r)}var n}}class Movement{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(e,t){const i=e.getFreeCameraOptions().position,r=i.toAltitude(),n=i.toLngLat(),o=Oe(n.lng),s=Oe(n.lat),a=e.pixelsPerMeter/t,l=o*Wa,c=Wa*Math.log(Math.tan(Math.PI/4+s/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+c,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+l)*a,this._accumulatedOffsetY+=e*a,this._accumulatedElevation+=t*a,this._offsetXPrev=l,this._offsetYPrev=c,this._elevationPrev=r}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function GT(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 HT(e){const t=jo(1323123451230),i=[];for(let r=0;r<e;++r){const e=2*t()-1,r=2*t()-1,n=2*t()-1;i.push(D(e,r,n))}return i}function qT(e,t,i,r,n){const o=He((n-i)/(r-i),0,1);return(1-o)*e+o*t}class PrecipitationBase{constructor(e){this._movement=new Movement,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new Vignette,this._ppmScaleFactor=e}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(e,i){const r=e.transform;this._movement.update(r,this._ppmScaleFactor);const n=r.starsProjMatrix,o=le([]);ce(o,o,Oe(90)-r._pitch),he(o,o,-r.angle);const s=T(new Float32Array(16),o);var a;const l=p([],h([],((a=new t(16))[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=0,a[6]=1,a[7]=0,a[8]=0,a[9]=-1,a[10]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a)),s),c=Date.now()/1e3;return this._accumulatedTimeFromStart+=(c-this._prevTime)*i,this._prevTime=c,{projectionMatrix:n,modelviewMatrix:l}}}class Rain extends PrecipitationBase{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 PrecipitationRevealParams("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(e){const t=e.context;if(!this.particlesVx){const e=HT(this.particlesCount),i=new StructArrayLayout9f36,r=new StructArrayLayout3ui6;let n=0;const o=jo(1323123451230);for(let t=0;t<e.length;++t){const s=e[t],a=[2*o()-1,o(),o(),o()];i.emplaceBack(s[0],s[1],s[2],-1,-1,...a),i.emplaceBack(s[0],s[1],s[2],1,-1,...a),i.emplaceBack(s[0],s[1],s[2],1,1,...a),i.emplaceBack(s[0],s[1],s[2],-1,1,...a),r.emplaceBack(n+0,n+1,n+2),r.emplaceBack(n+0,n+2,n+3),n+=4}this.particlesVx=t.createVertexBuffer(i,NT.members),this.particlesIdx=t.createIndexBuffer(r)}}draw(e){if(!this._params.overrideStyleParameters&&!e.style.rain)return;const t=this._params.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},i=e.transform.zoom;if(t.revealStart>i)return;const r=qT(0,1,t.revealStart,t.revealStart+t.revealRange,i);if(!this.particlesVx||!this.particlesIdx)return;const n=structuredClone(this._params);let o=[-n.direction.x,n.direction.y,-100];G(o,o);const s=structuredClone(this._vignetteParams);s.strength*=r,n.overrideStyleParameters||(n.intensity=e.style.rain.state.density,n.timeFactor=e.style.rain.state.intensity,n.color=structuredClone(e.style.rain.state.color),o=structuredClone(e.style.rain.state.direction),n.screenThinning.intensity=e.style.rain.state.centerThinning,n.dropletSizeX=e.style.rain.state.dropletSize[0],n.dropletSizeYScale=e.style.rain.state.dropletSize[1]/e.style.rain.state.dropletSize[0],n.distortionStrength=100*e.style.rain.state.distortionStrength,s.strength=1,s.color=structuredClone(e.style.rain.state.vignetteColor));const a=this.updateOnRender(e,n.timeFactor),l=e.context,c=l.gl,u=e.transform;this.screenTexture&&this.screenTexture.size[0]===e.width&&this.screenTexture.size[1]===e.height||(this.screenTexture=new Texture(l,{width:e.width,height:e.height,data:null},c.RGBA8)),n.distortionStrength>0&&(l.activeTexture.set(c.TEXTURE0),this.screenTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),c.copyTexSubImage2D(c.TEXTURE_2D,0,0,0,0,0,e.width,e.height));const h=e.getOrCreateProgram("rainParticle");e.uploadCommonUniforms(l,h),l.activeTexture.set(c.TEXTURE0),this.screenTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE);const d=[n.color.r,n.color.g,n.color.b,n.color.a],p=(t,i)=>{const r=GT(this._movement.getPosition(),t),s=n.dropletSizeX,l=n.dropletSizeX*n.dropletSizeYScale,p=e.width/2,f=e.height/2,m=qT(0,n.screenThinning.start,0,1,n.screenThinning.intensity),_=qT(.001,n.screenThinning.range,0,1,n.screenThinning.intensity),g=qT(0,n.screenThinning.particleOffset,0,1,n.screenThinning.intensity),y=(x={modelview:a.modelviewMatrix,projection:a.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:r,velocityConeAperture:n.velocityConeAperture,velocity:n.velocity,boxSize:t,rainDropletSize:[s,l],distortionStrength:n.distortionStrength,rainDirection:o,color:d,screenSize:[u.width,u.height],thinningCenterPos:[p,f],thinningShape:[m,_,Math.pow(10,n.screenThinning.fadePower)],thinningAffectedRatio:n.screenThinning.affectedRatio,thinningParticleOffset:g,shapeDirectionalPower:n.shapeDirPower,shapeNormalPower:n.shapeNormalPower,mode:i?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 v=Math.round(n.intensity*this.particlesCount),b=SegmentVector.simpleSegment(0,0,4*v,2*v);h.draw(e,c.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.alphaBlended,CullFaceMode.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,b)};n.distortionStrength>0&&p(n.boxSize,!0),p(n.boxSize,!1),this._vignette.draw(e,s)}}const $T=_a([{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 Snow extends PrecipitationBase{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 PrecipitationRevealParams("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(e){const t=e.context;if(!this.particlesVx){const e=HT(this.particlesCount),i=new StructArrayLayout11f44,r=new StructArrayLayout3ui6;let n=0;const o=jo(1323123451230);for(let t=0;t<e.length;++t){const s=e[t],a=o(),l=o(),c=o(),u=[t/e.length,a,l,c],h=[o(),o()];i.emplaceBack(s[0],s[1],s[2],-1,-1,...u,...h),i.emplaceBack(s[0],s[1],s[2],1,-1,...u,...h),i.emplaceBack(s[0],s[1],s[2],1,1,...u,...h),i.emplaceBack(s[0],s[1],s[2],-1,1,...u,...h),r.emplaceBack(n+0,n+1,n+2),r.emplaceBack(n+0,n+2,n+3),n+=4}this.particlesVx=t.createVertexBuffer(i,$T.members),this.particlesIdx=t.createIndexBuffer(r)}}draw(e){if(!this._params.overrideStyleParameters&&!e.style.snow)return;const t=structuredClone(this._params);let i=[-t.direction.x,t.direction.y,-100];G(i,i);const r=structuredClone(this._vignetteParams),n=t.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},o=e.transform.zoom;if(n.revealStart>o)return;const s=qT(0,1,n.revealStart,n.revealStart+n.revealRange,o);r.strength*=s,t.overrideStyleParameters||(t.intensity=e.style.snow.state.density,t.timeFactor=e.style.snow.state.intensity,t.color=structuredClone(e.style.snow.state.color),i=structuredClone(e.style.snow.state.direction),t.screenThinning.intensity=e.style.snow.state.centerThinning,t.billboardSize=2.79*e.style.snow.state.flakeSize,r.strength=1,r.color=structuredClone(e.style.snow.state.vignetteColor));const a=this.updateOnRender(e,t.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const l=e.context,c=l.gl,u=e.transform,h=e.getOrCreateProgram("snowParticle");e.uploadCommonUniforms(l,h),((t,r,n)=>{const o=GT(this._movement.getPosition(),t),s=u.width/2,l=u.height/2,d=qT(0,n.screenThinning.start,0,1,n.screenThinning.intensity),p=qT(.001,n.screenThinning.range,0,1,n.screenThinning.intensity),f=qT(0,n.screenThinning.particleOffset,0,1,n.screenThinning.intensity),m=(_={modelview:a.modelviewMatrix,projection:a.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:o,velocityConeAperture:n.velocityConeAperture,velocity:n.velocity,horizontalOscillationRadius:n.horizontalOscillationRadius,horizontalOscillationRate:n.horizontalOscillationRate,boxSize:t,billboardSize:1*n.billboardSize,simpleShapeParameters:[n.shapeFadeStart,n.shapeFadePower],screenSize:[u.width,u.height],thinningCenterPos:[s,l],thinningShape:[d,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:i},{u_modelview:Float32Array.from(_.modelview),u_projection:Float32Array.from(_.projection),u_time:_.time,u_cam_pos:_.camPos,u_velocityConeAperture:_.velocityConeAperture,u_velocity:_.velocity,u_horizontalOscillationRadius:_.horizontalOscillationRadius,u_horizontalOscillationRate:_.horizontalOscillationRate,u_boxSize:_.boxSize,u_billboardSize:_.billboardSize,u_simpleShapeParameters:_.simpleShapeParameters,u_screenSize:_.screenSize,u_thinningCenterPos:_.thinningCenterPos,u_thinningShape:_.thinningShape,u_thinningAffectedRatio:_.thinningAffectedRatio,u_thinningParticleOffset:_.thinningParticleOffset,u_particleColor:_.color,u_direction:_.direction});var _;const g=Math.round(n.intensity*this.particlesCount),y=SegmentVector.simpleSegment(0,0,4*g,2*g);this.particlesVx&&this.particlesIdx&&h.draw(e,c.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.alphaBlended,CullFaceMode.disabled,m,"snow_particles",this.particlesVx,this.particlesIdx,y)})(t.boxSize,0,t),this._vignette.draw(e,r)}}const ZT={symbol:function(e,t,i,r,n){if("translucent"!==e.renderPass)return;const o=StencilMode.disabled,s=e.colorModeForRenderPass(),a=i.layout.get("text-variable-anchor"),l=i.layout.get("text-size-scale-range"),c=He(e.scaleFactor,l[0],l[1]);a&&function(e,t,i,r,n,o,s,a){const l=t.transform,c="map"===n,u="map"===o;for(const t of e){const e=r.getTile(t),n=e.getBucket(i);if(!n||!n.text||!n.text.segments.get().length)continue;const o=Nf(n.textSizeData,l.zoom,a),h=ev(t,n.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(e),p=rv(h,e.tileID.canonical,u,c,l,n.getProjection(),d),f=n.hasIconTextFit()&&n.hasIconData();o&&Vw(n,c,u,s,l,p,t,Math.pow(2,l.zoom-e.tileID.overscaledZ),o,f)}}(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),n,c);const u=0!==i.paint.get("icon-opacity").constantOr(1),h=0!==i.paint.get("text-opacity").constantOr(1);void 0!==i.layout.get("symbol-sort-key").constantOr(1)&&(u||h)?Nw(e,t,i,r,o,s):(u&&Nw(e,t,i,r,o,s,{onlyIcons:!0}),h&&Nw(e,t,i,r,o,s,{onlyText:!0})),t.map.showCollisionBoxes&&(Ow(e,t,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),Ow(e,t,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),s=i.paint.get("circle-stroke-opacity"),a=void 0!==i.layout.get("circle-sort-key").constantOr(1),l=i.paint.get("circle-emissive-strength");if(0===n.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;const c=e.context,u=c.gl,h=e.transform,d=!(!e.terrain||!e.terrain.enabled),p=i.layout.get("circle-elevation-reference"),f=e.depthModeForSublayer(0,DepthMode.ReadOnly),m=new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D),_="none"===p||d?f:m,g=StencilMode.disabled,y=e.colorModeForDrapableLayerRenderPass(l),x="globe"===h.projection.name,v=[Qa(h.center.lng),el(h.center.lat)],b=[];for(let n=0;n<r.length;n++){const o=r[n],s=t.getTile(o),l=s.getBucket(i);if(!l||l.projection.name!==h.projection.name)continue;const c=l.programConfigurations.get(i.id),u=l.layoutVertexBuffer,d=l.globeExtVertexBuffer,p=l.indexBuffer,f=Uc(i),m=[d],_=e.isTileAffectedByFog(o);x&&f.push("PROJECTION_GLOBE_VIEW"),f.push("DEPTH_D24"),e.terrain&&h.depthOcclusionForSymbolsAndCircles&&f.push("DEPTH_OCCLUSION"),l.hasElevation&&!e.terrain&&(f.push("ELEVATED_ROADS"),m.push(l.elevatedLayoutVertexBuffer));const g=e.getOrCreateProgram("circle",{config:c,defines:f,overrideFog:_}),y=h.projection.createInversionMatrix(h,o.canonical),w={programConfiguration:c,program:g,layoutVertexBuffer:u,dynamicBuffers:m,indexBuffer:p,uniformValues:kc(e,o,s,y,v,i),tile:s};if(a){const e=l.segments.get();for(const t of e)b.push({segments:new SegmentVector([t]),sortKey:t.sortKey,state:w})}else b.push({segments:l.segments,sortKey:0,state:w})}a&&b.sort(((e,t)=>e.sortKey-t.sortKey));const w={useDepthForOcclusion:h.depthOcclusionForSymbolsAndCircles};for(const t of b){const{programConfiguration:r,program:n,layoutVertexBuffer:o,dynamicBuffers:s,indexBuffer:a,uniformValues:l,tile:d}=t.state,p=t.segments;e.terrain&&e.terrain.setupElevationDraw(d,n,w),e.uploadCommonUniforms(c,n,d.tileID.toUnwrapped()),n.draw(e,u.TRIANGLES,_,g,y,CullFaceMode.disabled,l,i.id,o,a,p,i.paint,h.zoom,r,s)}},heatmap:function(e,t,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const n=e.context,o=n.gl,s=StencilMode.disabled,a=new ColorMode([o.ONE,o.ONE,o.ONE,o.ONE],Color.transparent,[!0,!0,!0,!0]);!function(e,t,i,r){const n=e.gl,o=t.width*r,s=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,1,null),function(e,t,i,r,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),r.colorAttachment0.set(i)}(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment0.get()),e.bindFramebuffer.set(a.framebuffer)}(n,e,i,"globe"===e.transform.projection.name?.5:.25),n.clear({color:Color.transparent});const l=e.transform,c="globe"===l.projection.name,u=c?["PROJECTION_GLOBE_VIEW"]:[],h=c?CullFaceMode.frontCCW:CullFaceMode.disabled,d=[Qa(l.center.lng),el(l.center.lat)];for(let p=0;p<r.length;p++){const f=r[p];if(t.hasRenderableParent(f))continue;const m=t.getTile(f),_=m.getBucket(i);if(!_||_.projection.name!==l.projection.name)continue;const g=e.isTileAffectedByFog(f),y=_.programConfigurations.get(i.id),x=e.getOrCreateProgram("heatmap",{config:y,defines:u,overrideFog:g}),{zoom:v}=e.transform;e.terrain&&e.terrain.setupElevationDraw(m,x),e.uploadCommonUniforms(n,x,f.toUnwrapped());const b=l.projection.createInversionMatrix(l,f.canonical);x.draw(e,o.TRIANGLES,DepthMode.disabled,s,a,h,gw(e,f,m,b,d,v,i.paint.get("heatmap-intensity")),i.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,i.paint,e.transform.zoom,y,c?[_.globeExtVertexBuffer]:null)}n.viewport.set([0,0,e.width,e.height])}else"translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,t){const i=e.context,r=i.gl,n=t.heatmapFbo;if(!n)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment0.get()),i.activeTexture.set(r.TEXTURE1);let o=t.colorRampTexture;o||(o=t.colorRampTexture=new Texture(i,t.colorRamp,r.RGBA8)),o.bind(r.LINEAR,r.CLAMP_TO_EDGE),e.getOrCreateProgram("heatmapTexture").draw(e,r.TRIANGLES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,((e,t,i,r)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,t),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom)}(e,i))},line:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("line-opacity"),o=i.paint.get("line-width");if(0===n.constantOr(1)||0===o.constantOr(1))return;const s=i.paint.get("line-emissive-strength").isConstant(),a=i.paint.get("line-emissive-strength").constantOr(0),l=i.paint.get("line-occlusion-opacity"),c=i.layout.get("line-elevation-reference"),u="meters"===i.layout.get("line-width-unit"),h="sea"===c,d=!(!e.terrain||!e.terrain.enabled),p=e.context,f=p.gl;if(i.hasElevatedBuckets&&"globe"===e.transform.projection.name)return;const m=i.layout.get("line-cross-slope"),_=void 0!==m,g=m<1,y=e.colorModeForDrapableLayerRenderPass(s?a:null),x=e.terrain&&e.terrain.renderingToTexture,v=x?1:Wt.devicePixelRatio,b=i.paint.get("line-dasharray"),w=b.constantOr(1),T=i.layout.get("line-cap"),E=b.constantOr(null),S=T.constantOr(null),A=i.paint.get("line-pattern"),I=A.constantOr(1),C=i.paint.get("line-pattern-cross-fade"),M=A.constantOr(null),D=i.paint.get("line-opacity").constantOr(1);let P=!I&&1!==D||e.depthOcclusion&&l>0&&l<1;const L=i.paint.get("line-gradient"),R=I?"linePattern":"line",z=Yp(i);let F;if(x&&e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(P=!1),0!==l&&e.depthOcclusion){const e=i.paint._values["line-opacity"];e&&e.value&&"constant"===e.value.kind?F=e.value:st(`Occlusion opacity for layer ${i.id} is supported only when line-opacity isn't data-driven.`)}"constant"!==o.value.kind&&!1===o.value.isLineProgressConstant&&z.push("VARIABLE_LINE_WIDTH"),x&&("dual-source-blending"!==e.emissiveMode||s?"mrt-fallback"===e.emissiveMode&&z.push("USE_MRT1"):z.push("DUAL_SOURCE_BLENDING"));const O=(r,n,o,s,a,c)=>{for(const d of r){const r=t.getTile(d);if(I&&!r.patternsLoaded())continue;const m=r.getBucket(i);if(!m)continue;if("none"!==m.elevationType&&!a||"none"===m.elevationType&&a)continue;e.prepareDrawTile();const _=[...n],g=e.shadowRenderer,b="road"===m.elevationType&&!!g&&g.enabled;let T=[0,0,0];if(b){const t=e.style.directionalLight,i=e.style.ambientLight;t&&i&&(T=Kv(e.style,t,i)),_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const A=m.programConfigurations.get(i.id);let z=!1;if(M&&r.imageAtlas){const e=ResolvedImage.from(M),t=e.getPrimary().scaleSelf(v).toString(),i=r.imageAtlas.patternPositions.get(t),n=e.getSecondary(),o=n?r.imageAtlas.patternPositions.get(n.scaleSelf(v).toString()):null;z=!!i&&!!o,i&&A.setConstantPatternPositions(i,o)}C>0&&(z||A.getPatternTransitionVertexBuffer("line-pattern"))&&_.push("LINE_PATTERN_TRANSITION");const O=e.isTileAffectedByFog(d),B=e.getOrCreateProgram(R,{config:A,defines:_,overrideFog:O});if(!I&&E&&S&&r.lineAtlas){const e=r.lineAtlas.getDash(E,S);e&&A.setConstantPatternPositions(e)}b&&g.setupShadows(r.tileID.toUnwrapped(),B,"vector-tile");let[k,U]=i.paint.get("line-trim-offset");if("round"===S||"square"===S){const e=1;k!==U&&(0===k&&(k-=e),1===U&&(U+=e))}const V=x?d.projMatrix:null,N=u?1/m.tileToMeter/Hp(r,1,e.transform.zoom):1,j=u?1/m.tileToMeter/Hp(r,1,Math.floor(e.transform.zoom)):1,G=I?Zp(e,r,i,V,v,N,j,[k,U],T,C):$p(e,r,i,V,m.lineClipsArray.length,v,N,j,[k,U],T);if(L){const r=m.gradients[i.id];let n=r.texture;if(i.gradientVersion!==r.version){let o=256;if(i.stepInterpolant){const i=t.getSource().maxzoom,r=d.canonical.z===i?Math.ceil(1<<e.transform.maxZoom-d.canonical.z):1;o=He(Je(m.maxLineLength/Mn*1024*r),256,p.maxTextureSize)}r.gradient=Jc({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:o,image:r.gradient||void 0,clips:m.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new Texture(p,r.gradient,f.RGBA8),r.version=i.gradientVersion,n=r.texture}p.activeTexture.set(f.TEXTURE1),n.bind(i.stepInterpolant?f.NEAREST:f.LINEAR,f.CLAMP_TO_EDGE)}w&&(p.activeTexture.set(f.TEXTURE0),r.lineAtlasTexture&&r.lineAtlasTexture.bind(f.LINEAR,f.REPEAT),A.updatePaintBuffers()),I&&(p.activeTexture.set(f.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE),A.updatePaintBuffers()),a&&!h&&e.terrain.setupElevationDraw(r,B),e.uploadCommonUniforms(p,B,d.toUnwrapped());const H=t=>{null!=F&&(F.value=D*l),B.draw(e,f.TRIANGLES,o,t,y,CullFaceMode.disabled,G,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,e.transform.zoom,A,[m.layoutVertexBuffer2,m.patternVertexBuffer,m.zOffsetVertexBuffer]),null!=F&&(F.value=D)};if(P&&!a){const t=e.stencilModeForClipping(d).ref;0===t&&x&&p.clear({stencil:0});const i={func:f.EQUAL,mask:255};G.u_alpha_discard_threshold=.8,H(new StencilMode(i,t,255,f.KEEP,f.KEEP,f.INVERT)),G.u_alpha_discard_threshold=0,H(new StencilMode(i,t,255,f.KEEP,f.KEEP,f.KEEP))}else G.u_alpha_discard_threshold=P&&a&&c?.8:0,H(a?s:e.stencilModeForClipping(d))}};let B=e.depthModeForSublayer(0,DepthMode.ReadOnly);const k=new DepthMode(e.depthOcclusion?f.GREATER:f.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D);if(i.hasNonElevatedBuckets){const t=!x&&e.terrain;0!==l&&t?st(`Occlusion opacity for layer ${i.id} is supported on terrain only if the layer has line-z-offset enabled.`):t?st(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${i.id}.`):O(r,z,B,StencilMode.disabled,!1,!0)}if(i.hasElevatedBuckets){"hd-road-markup"===c?d||(B=k,z.push("ELEVATED_ROADS")):(z.push("ELEVATED"),B=k,_&&z.push(g?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),h&&z.push("ELEVATION_REFERENCE_SEA"));const t=P?e.stencilModeFor3D():StencilMode.disabled;e.forceTerrainMode=!0,O(r,z,B,t,!0,!0),P&&O(r,z,B,t,!0,!1),e.forceTerrainMode=!1}P&&(e.resetStencilClippingMasks(),x&&p.clear({stencil:0})),0===l||e.depthOcclusion||x||e.layersWithOcclusionOpacity.push(e.currentLayer)},fill:function(e,t,i,r){const n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity");if(0===o.constantOr(1))return;const s=i.paint.get("fill-emissive-strength"),a=e.colorModeForDrapableLayerRenderPass(s),l=i.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(Color.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";let u="none";"none"!==i.layout.get("fill-elevation-reference")?u="road":0!==i.paint.get("fill-z-offset").constantOr(1)&&(u="offset");const h=!(!e.terrain||!e.terrain.enabled),d={painter:e,sourceCache:t,layer:i,coords:r,colorMode:a,elevationType:u,terrainEnabled:h,pass:c};if("shadow"===e.renderPass)return void(e.shadowRenderer&&"road"===u&&!h&&function(e){const{painter:t,sourceCache:i,layer:r,coords:n}=e,o=t.context.gl,s=e.painter.shadowRenderer;for(const e of n){const n=i.getTile(e),a=n.getBucket(r);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(r.id),u=t.isTileAffectedByFog(e),h=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:u}),d=s.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,h,e.toUnwrapped());const p={u_matrix:d,u_depth_bias:0};h.draw(t,o.TRIANGLES,s.getShadowPassDepthMode(),StencilMode.disabled,s.getShadowPassColorMode(),CullFaceMode.disabled,p,r.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,r.paint,t.transform.zoom,c)}}(d));const p="mrt-fallback"===e.emissiveMode;if("offset"!==u){if(qw(d,!1,p),"road"===u){const n=!h&&"translucent"===e.renderPass;n&&Hw(e,t,i,r,"geometry"),qw(d,!0,p,StencilMode.disabled),n&&function(e){const{painter:t,sourceCache:i,layer:r,coords:n,colorMode:o}=e,s=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new DepthMode(t.context.gl.LEQUAL,DepthMode.ReadOnly,t.depthRangeFor3D);let u=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(u=Kv(t.style,e,i))}const h=e=>{for(const h of n){const n=i.getTile(h),d=n.getBucket(r);if(!d)continue;const p=d.elevatedStructures;if(!p)continue;let f,m;if(e?(f=p.renderableBridgeSegments,m=p.bridgeProgramConfigurations.get(r.id)):(f=p.renderableTunnelSegments,m=p.tunnelProgramConfigurations.get(r.id)),!f||0===f.segments[0].primitiveLength)continue;m.updatePaintBuffers(),t.prepareDrawTile();const _=t.isTileAffectedByFog(h),g=[];l&&g.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const y=t.getOrCreateProgram("elevatedStructures",{config:m,overrideFog:_,defines:g}),x=t.translatePosMatrix(h.projMatrix,n,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));l&&a.setupShadows(n.tileID.toUnwrapped(),y,"vector-tile");const v=cw(x,u);t.uploadCommonUniforms(t.context,y,h.toUnwrapped()),y.draw(t,s.TRIANGLES,c,StencilMode.disabled,o,CullFaceMode.backCCW,v,r.id,p.vertexBuffer,p.indexBuffer,f,r.paint,t.transform.zoom,m,[p.vertexBufferNormal])}};h(!0),h(!1)}(d)}}else qw(d,!1,p,e.stencilModeFor3D())},"fill-extrusion":function(e,t,i,r){const n=i.paint.get("fill-extrusion-opacity"),o=e.context,s=o.gl,a=e.terrain,l=a&&a.renderingToTexture;if(0===n)return;const c="mrt-fallback"===e.emissiveMode,u=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),h=e.style.order.indexOf(i.fqid);if(u&&function(e,t,i,r,n){for(const o of r){const r=t.getTile(o).getBucket(i);r&&(r.updateReplacement(o,e.replacementSource,n),r.uploadCentroid(e.context))}}(e,t,i,r,h),a||u)for(const n of r){const r=t.getTile(n).getBucket(i);r&&Ww(e.context,t,n,r,i,a,u)}if("shadow"===e.renderPass&&e.shadowRenderer){const o=e.shadowRenderer;if(a&&n<.65&&i._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof ZoomDependentExpression)return;const s=o.getShadowPassDepthMode(),l=o.getShadowPassColorMode();$w(e,t,i,r,s,StencilMode.disabled,l,u)}else if("translucent"===e.renderPass){const h=!i.paint.get("fill-extrusion-pattern").constantOr(1),d=i.paint.get("fill-extrusion-color").constantOr(Color.white);if(!l&&0!==d.a){const o=new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);1===n&&h?$w(e,t,i,r,o,StencilMode.disabled,ColorMode.unblended,u):($w(e,t,i,r,o,StencilMode.disabled,ColorMode.disabled,u),$w(e,t,i,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass(),u),e.resetStencilClippingMasks())}if(e.style.enable3dLights()&&h&&(!a&&"globe"!==e.transform.projection.name||l)){const n=i.paint.get("fill-extrusion-opacity"),h=i.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=i.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=i.paint.get("fill-extrusion-flood-light-intensity"),f="none"===i.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=i.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(f?null:i.lut).toArray01().slice(0,3),_=h>0&&d>0,g=p>0,y=(e,t,i)=>(1-i)*e+i*t,x=new GroundEffectProperties;x.translate=i.paint.get("fill-extrusion-translate"),x.translateAnchor=i.paint.get("fill-extrusion-translate-anchor"),x.edgeRadius=i.layout.get("fill-extrusion-edge-radius"),x.cutoffFadeRange=i.paint.get("fill-extrusion-cutoff-fade-range");const v=o=>{const a=e.depthModeForSublayer(1,DepthMode.ReadOnly,s.LEQUAL,!0),l=i.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),c=y(.1,3,l),f=e._showOverdrawInspector;if(!f){const l=new StencilMode({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),f=new ColorMode([s.ONE,s.ONE,s.ONE,s.ONE],Color.transparent,[!1,!1,!1,!0],s.MIN);Zw(x,e,t,i,r,a,l,f,CullFaceMode.disabled,o,"sdf",n,h,d,p,m,c,u,!1)}{const l=f?StencilMode.disabled:new StencilMode({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),_=f?e.colorModeForRenderPass():new ColorMode([s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA,s.ONE,s.ONE],Color.transparent,[!0,!0,!0,!0]);Zw(x,e,t,i,r,a,l,_,CullFaceMode.disabled,o,"color",n,h,d,p,m,c,u,!1)}};if(l){const l=()=>{const e=a.drapeBufferSize[0],t=a.drapeBufferSize[1];let i=a.framebufferCopyTexture;return i&&(!i||i.size[0]===e&&i.size[1]===t)||(i&&i.destroy(),i=a.framebufferCopyTexture=new Texture(o,new RGBAImage({width:e,height:t}),s.RGBA8)),i.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,0,0,e,t),i},f=(o,a,f)=>{const _=e.depthModeForSublayer(1,DepthMode.ReadOnly,s.LEQUAL,!1),g=i.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),v=y(.1,3,g);{const l=new ColorMode([s.ONE,s.ONE,s.ONE,s.ONE],Color.transparent,[!1,!1,!1,!0]);Zw(x,e,t,i,r,_,StencilMode.disabled,l,CullFaceMode.disabled,o,"clear",n,h,d,p,m,v,u,a)}{const l=new StencilMode({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),c=new ColorMode([s.ONE,s.ONE,s.ONE,s.ONE],Color.transparent,[!1,!1,!1,!0],s.MIN);Zw(x,e,t,i,r,_,l,c,CullFaceMode.disabled,o,"sdf",n,h,d,p,m,v,u,a)}c&&!o&&(f=l());{const l=o?s.ZERO:s.ONE_MINUS_DST_ALPHA,c=new StencilMode({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),f=new ColorMode([l,s.DST_ALPHA,s.ONE_MINUS_DST_ALPHA,s.ZERO],Color.transparent,[!0,!0,!0,!0]);Zw(x,e,t,i,r,_,c,f,CullFaceMode.disabled,o,"color",n,h,d,p,m,v,u,a)}if(!c||o){const l=new ColorMode([s.ONE,s.ONE,s.ONE,o?s.ZERO:s.ONE],Color.transparent,[!1,!1,!1,!0],o?s.FUNC_ADD:s.MAX);Zw(x,e,t,i,r,_,StencilMode.disabled,l,CullFaceMode.disabled,o,"clear",n,h,d,p,m,v,u,a,f)}else{s.drawBuffers([s.NONE,s.COLOR_ATTACHMENT1]);const l=new StencilMode({func:s.EQUAL,mask:255},254,255,s.KEEP,s.DECR,s.DECR),c=new ColorMode([s.ONE,s.ONE,s.ONE,s.ONE],Color.transparent,[!0,!1,!1,!1],s.MAX);Zw(x,e,t,i,r,_,l,c,CullFaceMode.disabled,o,"emissive",n,h,d,p,m,v,u,a,f),s.drawBuffers([s.COLOR_ATTACHMENT0])}};if(_||g){let t;e.prepareDrawTile(),c&&!_||(t=l()),_&&f(!0,!1,t),g&&f(!1,!0,t)}}else _&&v(!0),g&&v(!1),(_||g)&&e.resetStencilClippingMasks()}}},building:function(e,t,i,r){e.currentLayer<e.firstLightBeamLayer&&(e.firstLightBeamLayer=e.currentLayer);const n=i.paint.get("building-ambient-occlusion-ground-intensity"),o=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=n>0&&o>0,c=!0;const u=i.paint.get("building-vertical-scale");if(u<=0)return;e.shadowRenderer||(c=!1);const h=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),d=e.style.order.indexOf(i.fqid);if(function(e,t,i,r,n,o){for(const s of o){const o=t.getTile(s).getBucket(i);o&&(n&&o.updateReplacement(s,e.replacementSource,r),o.uploadUpdatedIndexBuffer(e.context))}}(e,t,i,d,h,r),function(e,t,i,r){for(const n of r){const r=t.getTile(n).getBucket(i);r&&r.needsEvaluation()&&r.uploadUpdatedColorBuffer(e.context)}}(e,t,i,r),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const n=e.shadowRenderer,o=[],s=n.getShadowPassDepthMode();Qw({painter:e,source:t,layer:i,coords:r,defines:o,blendMode:n.getShadowPassColorMode(),depthMode:s,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if("translucent"===e.renderPass){let d=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(d=d.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(d=d.concat("NORMAL_OFFSET"));const p=i.paint.get("building-facade-emissive-chance"),f=i.paint.get("building-ambient-occlusion-intensity"),m=i.paint.get("building-flood-light-intensity"),_="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),g=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(_?null:i.lut).toArray01().slice(0,3),y=i.paint.get("building-flood-light-ground-attenuation"),x=m>0,v=new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);a<1&&Qw({painter:e,source:t,layer:i,coords:r,defines:d,blendMode:ColorMode.disabled,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:g,depthOnly:!0});const b=e.colorModeForRenderPass();Qw({painter:e,source:t,layer:i,coords:r,defines:d,blendMode:b,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:g}),l&&eT(e,t,i,r,!0,a,n,o,m,g,s,h),x&&eT(e,t,i,r,!1,a,n,o,m,g,y,h)}else if("light-beam"===e.renderPass){const n=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],o=new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D);Qw({painter:e,source:t,layer:i,coords:r,defines:n,blendMode:ColorMode.alphaBlended,depthMode:o,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks()},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const n=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const r of a){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)Bb(e,n,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,DepthMode.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):s[r.overscaledZ];Fb(e,r,n,i,t,c,l)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,t,i,r,n,o){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;const s="globe"===e.transform.projection.name,a=0!==i.paint.get("raster-elevation"),l=a&&s;if(e.renderElevatedRasterBackface&&!l)return;const c=e.context,u=c.gl,h=t.getSource(),d=function(e,t,i,r,n){const o=t.paint.get("raster-color"),s="raster-array"===e.type,a=[],l=t.paint.get("raster-resampling"),c=t.paint.get("raster-color-mix");let u=t.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?r.NEAREST:r.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=r.NEAREST,!u&&e.rasterLayers)){const i=e.rasterLayers.find((({id:e})=>e===t.sourceLayer));i&&i.fields&&i.fields.range&&(u=i.fields.range)}if(u=u||[0,1],o){a.push("RASTER_COLOR"),i.activeTexture.set(r.TEXTURE2),t.updateColorRamp(u);let e=t.colorRampTexture;e||(e=t.colorRampTexture=new Texture(i,t.colorRamp,r.RGBA8)),e.bind(r.LINEAR,r.CLAMP_TO_EDGE)}return n&&a.push("USE_MRT1"),{mix:h,range:u,offset:d,defines:a,resampling:p}}(h,i,c,u,e.terrain&&e.terrain.renderingToTexture&&"mrt-fallback"===e.emissiveMode);if(h instanceof ImageSource&&!r.length&&!s)return;const p=i.paint.get("raster-emissive-strength"),f=e.colorModeForDrapableLayerRenderPass(p),m=e.terrain&&e.terrain.renderingToTexture,_=!e.options.moving,g="nearest"===i.paint.get("raster-resampling")?u.NEAREST:u.LINEAR;if(h instanceof ImageSource&&!r.length&&(h.onNorthPole||h.onSouthPole)){const r=a?e.stencilModeFor3D():StencilMode.disabled;return void iT(!!h.onNorthPole,null,e,t,i,p,d,CullFaceMode.disabled,r)}if(!r.length)return;const[y,x]=h instanceof ImageSource||m?[{},r]:e.stencilConfigForOverlap(r),v=x[x.length-1].overscaledZ;l&&d.defines.push("PROJECTION_GLOBE_VIEW"),a&&d.defines.push("RENDER_CUTOFF");const b=(r,n,x)=>{for(const b of r){const r=b.toUnwrapped(),w=t.getTile(b);if(m&&(!w||!w.hasData()))continue;c.activeTexture.set(u.TEXTURE0);const T=nT(w,h,i,d);if(!T||!T.texture)continue;const{texture:E,mix:S,offset:A,tileSize:I,buffer:C}=T;let M,D;m?(M=DepthMode.disabled,D=b.projMatrix):a?(M=new DepthMode(u.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D),D=s?Float32Array.from(e.transform.expandedFarZProjMatrix):e.transform.calculateProjMatrix(r,_)):(M=e.depthModeForSublayer(b.overscaledZ-v,1===i.paint.get("raster-opacity")?DepthMode.ReadWrite:DepthMode.ReadOnly,u.LESS),D=e.transform.calculateProjMatrix(r,_));const P=e.terrain&&m?e.terrain.stencilModeForRTTOverlap(b):y[b.overscaledZ],L=o?0:i.paint.get("raster-fade-duration");w.registerFadeDuration(L);const R=t.findLoadedParent(b,0),z=Wb(w,R,t,e.transform,L);let F,O;!z.isFading&&w.refreshedUponExpiration&&(w.refreshedUponExpiration=!1),e.terrain&&e.terrain.prepareDrawTile(),c.activeTexture.set(u.TEXTURE0),E.bind(g,u.CLAMP_TO_EDGE),c.activeTexture.set(u.TEXTURE1),R?(R.texture&&R.texture.bind(g,u.CLAMP_TO_EDGE),F=Math.pow(2,R.tileID.overscaledZ-w.tileID.overscaledZ),O=[w.tileID.canonical.x*F%1,w.tileID.canonical.y*F%1]):E.bind(g,u.CLAMP_TO_EDGE),"useMipmap"in E&&c.extTextureFilterAnisotropic&&e.transform.pitch>20&&u.texParameterf(u.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax);const B=e.transform;let k;const U=a?rT(B):[0,0,0,0];let V,N,j,G,H,q=0;if(l&&h instanceof ImageSource&&h.coordinates.length>3)V=Float32Array.from(vc(uc(new CanonicalTileID(0,0,0)))),N=Float32Array.from(B.globeMatrix),j=Float32Array.from(Sc(B)),G=[Qa(B.center.lng),el(B.center.lat)],k=h.elevatedGlobePerspectiveTransform,H=h.elevatedGlobeGridMatrix||new Float32Array(9);else if(l){const e=mc(b.canonical);q=Dc(e.getCenter().lat),V=Float32Array.from(vc(uc(b.canonical))),N=Float32Array.from(B.globeMatrix),j=Float32Array.from(Sc(B)),G=[Qa(B.center.lng),el(B.center.lat)],k=[0,0],H=Float32Array.from(Mc(b.canonical,e,q,B.worldSize/B._pixelsPerMercatorPixel))}else k=h instanceof ImageSource?h.perspectiveTransform:[0,0],V=new Float32Array(16),N=new Float32Array(9),j=new Float32Array(16),G=[0,0],H=new Float32Array(9);const $=vw(D,V,N,j,H,O||[0,0],Ac(e.transform.zoom),G,U,F||1,z,i,k,a?i.paint.get("raster-elevation"):0,2,S,A,d.range,I,C,p),Z=e.isTileAffectedByFog(b),W=e.getOrCreateProgram("raster",{defines:d.defines,overrideFog:Z});if(e.uploadCommonUniforms(c,W,r),h instanceof ImageSource){const t=h.elevatedGlobeVertexBuffer,r=h.elevatedGlobeIndexBuffer;if(m||!s)h.boundsBuffer&&h.boundsSegments&&W.draw(e,u.TRIANGLES,M,StencilMode.disabled,f,CullFaceMode.disabled,$,i.id,h.boundsBuffer,e.quadTriangleIndexBuffer,h.boundsSegments);else if(t&&r){const o=B.zoom<=Ua?h.elevatedGlobeSegments:h.getSegmentsForLongitude(B.center.lng);o&&W.draw(e,u.TRIANGLES,M,StencilMode.disabled,f,n,$,i.id,t,r,o)}}else if(l){M=new DepthMode(u.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D);const t=e.globeSharedBuffers;if(t){const[r,o,s]=t.getGridBuffers(q,!1);W.draw(e,u.TRIANGLES,M,x||P,e.colorModeForRenderPass(),n,$,i.id,r,o,s)}}else{const{tileBoundsBuffer:t,tileBoundsIndexBuffer:r,tileBoundsSegments:n}=e.getTileBoundsBuffers(w);W.draw(e,u.TRIANGLES,M,P,f,CullFaceMode.disabled,$,i.id,t,r,n)}}if(!(h instanceof ImageSource)&&l)for(const o of r){const r=o.canonical.y===(1<<o.canonical.z)-1;0===o.canonical.y&&iT(!0,o,e,t,i,p,d,n,x||StencilMode.disabled),r&&iT(!1,o,e,t,i,p,d,n===CullFaceMode.frontCW?CullFaceMode.backCW:CullFaceMode.frontCW,x||StencilMode.disabled)}};l?b(x,e.renderElevatedRasterBackface?CullFaceMode.backCW:CullFaceMode.frontCW,e.stencilModeFor3D()):b(x,CullFaceMode.disabled,void 0),e.resetStencilClippingMasks()},"raster-particle":function(e,t,i,r,n,o){"offscreen"===e.renderPass&&function(e,t,i,r){if(!r.length)return;const n=e.context,o=n.gl,s=t.getSource();if(!(s instanceof RasterArrayTileSource))return;const a=Math.ceil(Math.sqrt(i.paint.get("raster-particle-count")));let l=i.particlePositionRGBAImage;if(!l||l.width!==a){const e=function(e){const t=e*e,i=new Uint8Array(4*t),r=function(e){return e|=0,e=Math.imul(2747636419^e,2654435769),e=Math.imul(e^e>>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},n=1/1.1;for(let e=0;e<t;e++){const t=n*(r(2*e+0)+ww),o=n*(r(2*e+1)+ww),s=255*t%1,a=255*o%1,l=s,c=o-a/255,u=a;i[4*e+0]=255*(t-s/255),i[4*e+1]=255*l,i[4*e+2]=255*c,i[4*e+3]=255*u}return i}(a);l=i.particlePositionRGBAImage=new RGBAImage({width:a,height:a},e)}let c=i.particleFramebuffer;c?c.width!==a&&(c.destroy(),c=i.particleFramebuffer=n.createFramebuffer(a,a,1,null)):c=i.particleFramebuffer=n.createFramebuffer(a,a,1,null);const u=[];for(const e of r){const r=t.getTile(e);if(!(r instanceof RasterArrayTile))continue;const o=sT(r,s,i);if(!o)continue;const c=[r.tileSize,r.tileSize];let h=i.tileFramebuffer;h||(h=i.tileFramebuffer=n.createFramebuffer(c[0],c[1],1,null));let d=r.rasterParticleState;d||(d=r.rasterParticleState=new RasterParticleState(n,e,c,l));const p=d.update(i.lastInvalidatedAt);d.particleTextureDimension!==a&&d.updateParticleTexture(e,l);const f=d.targetColorTexture;d.targetColorTexture=d.backgroundColorTexture,d.backgroundColorTexture=f;const m=d.particleTexture0;d.particleTexture0=d.particleTexture1,d.particleTexture1=m,u.push([e,o,d,p])}if(0===u.length)return;const h=Wt.now(),d=i.previousDrawTimestamp?.001*(h-i.previousDrawTimestamp):.0167;if(i.previousDrawTimestamp=h,i.hasColorMap()){n.activeTexture.set(o.TEXTURE0+2);let e=i.colorRampTexture;e||(e=i.colorRampTexture=new Texture(n,i.colorRamp,o.RGBA8)),e.bind(o.LINEAR,o.CLAMP_TO_EDGE)}n.bindFramebuffer.set(i.tileFramebuffer.framebuffer),function(e,t,i){const r=e.context,n=r.gl,o=t.tileFramebuffer;r.activeTexture.set(n.TEXTURE0);const s={u_texture:0,u_opacity:1.05*(l=t.paint.get("raster-particle-fade-opacity-factor"))/(l+.05)},a=e.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var l;for(const l of i){const[,,i,c]=l;o.colorAttachment0.set(i.targetColorTexture.texture),r.viewport.set([0,0,o.width,o.height]),r.clear({color:Color.transparent}),c&&(i.backgroundColorTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),a.draw(e,n.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.alphaBlended,CullFaceMode.disabled,s,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments))}}(e,i,u),function(e,t,i,r){const n=e.context,o=n.gl,s=i.tileFramebuffer,a="globe"===e.transform.projection.name,l=i.paint.get("raster-particle-max-speed");for(const c of r){const[r,u,h]=c;n.activeTexture.set(o.TEXTURE0+0),u.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s.colorAttachment0.set(h.targetColorTexture.texture);const d=e.getOrCreateProgram("rasterParticleDraw",{defines:u.defines,overrideFog:!1});n.activeTexture.set(o.TEXTURE0+1);const p=u.scalarData?[]:[0,1,2,3].map((e=>tc[e](r)));p.push(r);const f=r.canonical.x,m=r.canonical.y;for(const n of p){const s=t.getTile(a?n.wrapped():n);if(!s)continue;const c=s.rasterParticleState;if(!c)continue;const h=n.canonical.x+(1<<n.canonical.z)*(n.wrap-r.wrap),p=n.canonical.y;c.particleTexture0.bind(o.NEAREST,o.CLAMP_TO_EDGE);const _=Ew(1,c.particleTexture0.size[0],[h-f,p-m],0,u.texture.size,2,l,u.textureOffset,u.scale,u.offset);d.draw(e,o.POINTS,DepthMode.disabled,StencilMode.disabled,ColorMode.alphaBlended,CullFaceMode.disabled,_,i.id,c.particleIndexBuffer,void 0,c.particleSegment)}}}(e,t,i,u),n.bindFramebuffer.set(i.particleFramebuffer.framebuffer),function(e,t,i,r){const n=e.context,o=n.gl,s=t.paint.get("raster-particle-max-speed"),a=r*t.paint.get("raster-particle-speed-factor")*.15,l=function(e){return Math.pow(e,6)}(.01+1*t.paint.get("raster-particle-reset-rate-factor")),c=t.particleFramebuffer;n.viewport.set([0,0,c.width,c.height]);for(const r of i){const[,i,u]=r;n.activeTexture.set(o.TEXTURE0+0),i.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE0+1);const h=u.particleTexture0;h.bind(o.NEAREST,o.CLAMP_TO_EDGE);const d=Sw(1,h.size[0],0,i.texture.size,s,a,l,i.textureOffset,i.scale,i.offset);c.colorAttachment0.set(u.particleTexture1.texture),n.clear({color:Color.transparent}),e.getOrCreateProgram("rasterParticleUpdate",{defines:i.defines}).draw(e,o.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.unblended,CullFaceMode.disabled,d,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments)}}(e,i,u,d)}(e,t,i,r),"translucent"===e.renderPass&&(function(e,t,i,r,n){const o=e.context,s=o.gl,a=t.getSource().tileSize,l=5*(1-qe(Va,Va+1,e.transform.zoom))*a+i.paint.get("raster-particle-elevation"),c=!e.options.moving,u="globe"===e.transform.projection.name;if(!r.length)return;const[h,d]=e.stencilConfigForOverlap(r),p=[];u&&p.push("PROJECTION_GLOBE_VIEW");const f=e.stencilModeFor3D();for(const r of d){const n=r.toUnwrapped(),a=t.getTile(r);if(!a.rasterParticleState)continue;const d=a.rasterParticleState,m=100;a.registerFadeDuration(m);const _=t.findLoadedParent(r,0),g=Wb(a,_,t,e.transform,m);let y,x;e.terrain&&e.terrain.prepareDrawTile(),o.activeTexture.set(s.TEXTURE0),d.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),o.activeTexture.set(s.TEXTURE1),_&&_.rasterParticleState?(_.rasterParticleState.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),y=Math.pow(2,_.tileID.overscaledZ-a.tileID.overscaledZ),x=[a.tileID.canonical.x*y%1,a.tileID.canonical.y*y%1]):d.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const v=u?Float32Array.from(e.transform.expandedFarZProjMatrix):e.transform.calculateProjMatrix(n,c),b=e.transform,w=aT(b),T=mc(r.canonical),E=Dc(T.getCenter().lat);let S,A,I,C,M;u?(S=Float32Array.from(vc(uc(r.canonical))),A=Float32Array.from(b.globeMatrix),I=Float32Array.from(Sc(b)),C=[Qa(b.center.lng),el(b.center.lat)],M=Float32Array.from(Mc(r.canonical,T,E,b.worldSize/b._pixelsPerMercatorPixel))):(S=new Float32Array(16),A=new Float32Array(9),I=new Float32Array(16),C=[0,0],M=new Float32Array(9));const D=Tw(v,S,A,I,M,x||[0,0],Ac(e.transform.zoom),C,w,y||1,g,l),P=e.isTileAffectedByFog(r),L=e.getOrCreateProgram("rasterParticle",{defines:p,overrideFog:P});if(e.uploadCommonUniforms(o,L,n),u){const t=new DepthMode(s.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D),r=0,n=e.globeSharedBuffers;if(n){const[o,a,l]=n.getGridBuffers(E,0!==r);L.draw(e,s.TRIANGLES,t,f,ColorMode.alphaBlended,e.renderElevatedRasterBackface?CullFaceMode.frontCCW:CullFaceMode.backCCW,D,i.id,o,a,l)}}else{const t=e.depthModeForSublayer(0,DepthMode.ReadOnly),n=h[r.overscaledZ],{tileBoundsBuffer:o,tileBoundsIndexBuffer:l,tileBoundsSegments:c}=e.getTileBoundsBuffers(a);L.draw(e,s.TRIANGLES,t,n,ColorMode.alphaBlended,CullFaceMode.disabled,D,i.id,o,l,c)}}e.resetStencilClippingMasks()}(e,t,i,r),e.style.map.triggerRepaint())},background:function(e,t,i,r){const n=i.paint.get("background-color"),o="none"===i.paint.get("background-color-use-theme").constantOr("default"),s=i.paint.get("background-opacity"),a=i.paint.get("background-emissive-strength"),l="viewport"===i.paint.get("background-pitch-alignment");if(0===s)return;const c=e.context,h=c.gl,d=e.transform,p=d.tileSize,f=i.paint.get("background-pattern");let m;if(void 0!==f){if(null===f)return;if(m=e.imageManager.getPattern(ImageId.from(f.toString()),i.scope,e.style.getLut(i.scope)),!m)return}const _=!f&&1===n.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==_)return;const g=StencilMode.disabled,y=e.depthModeForSublayer(0,"opaque"===_?DepthMode.ReadWrite:DepthMode.ReadOnly),x=e.colorModeForDrapableLayerRenderPass(a),v=f?"backgroundPattern":"background";let b,w=r;w||(b=e.getBackgroundTiles(),w=Object.values(b).map((e=>e.tileID))),f&&(c.activeTexture.set(h.TEXTURE0),e.imageManager.bind(e.context,i.scope));const T=[];if(e.terrain&&e.terrain.renderingToTexture&&"mrt-fallback"===e.emissiveMode&&T.push("USE_MRT1"),l){const t=e.getOrCreateProgram(v,{overrideFog:!1,overrideRtt:!0,defines:T}),r=new Float32Array(u([])),c=new OverscaledTileID(0,0,0,0,0),d=f?Mw(r,a,s,e,0,i.scope,m,l,{tileID:c,tileSize:p}):Cw(r,a,s,n.toPremultipliedRenderColor(o?null:i.lut));t.draw(e,h.TRIANGLES,y,g,x,CullFaceMode.disabled,d,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments)}else for(const u of w){const _=e.isTileAffectedByFog(u),w=e.getOrCreateProgram(v,{overrideFog:_,defines:T}),E=u.toUnwrapped(),S=r?u.projMatrix:e.transform.calculateProjMatrix(E);e.prepareDrawTile();const A=t?t.getTile(u):b?b[u.key]:new Tile(u,p,d.zoom,e),I=f?Mw(S,a,s,e,0,i.scope,m,l,{tileID:u,tileSize:p}):Cw(S,a,s,n.toPremultipliedRenderColor(o?null:i.lut));e.uploadCommonUniforms(c,w,E);const{tileBoundsBuffer:C,tileBoundsIndexBuffer:M,tileBoundsSegments:D}=e.getTileBoundsBuffers(A);w.draw(e,h.TRIANGLES,y,g,x,CullFaceMode.disabled,I,i.id,C,M,D)}},sky:function(e,t,i){const r=e._atmosphere?Ac(e.transform.zoom):1,n=i.paint.get("sky-opacity")*r;if(0===n)return;const o=e.context,s=i.paint.get("sky-type"),a=new DepthMode(o.gl.LEQUAL,DepthMode.ReadOnly,[0,1]),l=e.frameCounter/1e3%1;"atmosphere"===s?"offscreen"===e.renderPass?i.needsSkyboxCapture(e)&&(function(e,t,i,r){const n=e.context,o=n.gl;let s=t.skyboxFbo;if(!s){s=t.skyboxFbo=n.createFramebuffer(32,32,1,null),t.skyboxGeometry=new SkyboxGeometry(n),t.skyboxTexture=n.gl.createTexture(),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR);for(let e=0;e<6;++e)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,o.RGBA,32,32,0,o.RGBA,o.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(s.framebuffer),n.viewport.set([0,0,32,32]);const a=t.getCenter(e,!0),l=e.getOrCreateProgram("skyboxCapture"),c=new Float64Array(16);u(c),g(c,c,.5*-Math.PI),bT(e,t,l,c,a,0),u(c),g(c,c,.5*Math.PI),bT(e,t,l,c,a,1),u(c),_(c,c,.5*-Math.PI),bT(e,t,l,c,a,2),u(c),_(c,c,.5*Math.PI),bT(e,t,l,c,a,3),u(c),bT(e,t,l,c,a,4),u(c),g(c,c,Math.PI),bT(e,t,l,c,a,5),n.viewport.set([0,0,e.width,e.height])}(e,i),i.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,i,a,n,l):"gradient"===s&&"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skyboxGradient");t.skyboxGeometry||(t.skyboxGeometry=new SkyboxGeometry(o)),o.activeTexture.set(s.TEXTURE0);let c=t.colorRampTexture;c||(c=t.colorRampTexture=new Texture(o,t.colorRamp,s.RGBA8)),c.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=((e,t,i,r,n)=>({u_matrix:e,u_color_ramp:0,u_center_direction:t,u_radius:Oe(i),u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),t.paint.get("sky-gradient-radius"),r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.backCW,u,"skyboxGradient",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,i,a,n,l)},custom:function(e,t,i,r){const n=e.context,o=i.implementation;if(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes("custom")||e.terrain&&(e.terrain.renderingToTexture||"offscreen"===e.renderPass)&&i.isDraped(t)){if("offscreen"===e.renderPass){const t=o.prerender;if(t){if(e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),"globe"===e.transform.projection.name){const i=e.transform.pointMerc;t.call(o,n.gl,e.transform.customLayerMatrix(),e.transform.getProjection(),e.transform.globeToMercatorMatrix(),Ac(e.transform.zoom),[i.x,i.y],e.transform.pixelsPerMeterRatio)}else t.call(o,n.gl,e.transform.customLayerMatrix());n.setDirty(),e.setBaseState()}}else if("translucent"===e.renderPass){if(e.terrain&&e.terrain.renderingToTexture){const t=o.renderToTile;if(t){const i=r[0].canonical,s={x:i.x+r[0].wrap*(o.wrapTileId?0:1<<i.z),y:i.y,z:i.z};n.setDepthMode(DepthMode.disabled),n.setStencilMode(StencilMode.disabled),n.setColorMode(e.colorModeForRenderPass()),e.setCustomLayerDefaults(),t.call(o,n.gl,s),n.setDirty(),e.setBaseState()}return}e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(StencilMode.disabled);const t="3d"===o.renderingMode?new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D):e.depthModeForSublayer(0,DepthMode.ReadOnly);if(n.setDepthMode(t),"globe"===e.transform.projection.name){const t=e.transform.pointMerc;o.render(n.gl,e.transform.customLayerMatrix(),e.transform.getProjection(),e.transform.globeToMercatorMatrix(),Ac(e.transform.zoom),[t.x,t.y],e.transform.pixelsPerMeterRatio)}else o.render(n.gl,e.transform.customLayerMatrix());n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null)}}else st("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(t,i,r,n){if("opaque"===t.renderPass)return;const o=r.paint.get("model-opacity").constantOr(1),s=r.paint.get("model-elevation-reference"),a="ground"===s,c="ground"===s;if(0===o)return;const _=r.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!_)return;if(t.terrain&&o<.65&&r._transitionablePaint._values["model-opacity"].value.expression instanceof ZoomDependentExpression)return}const g=t.shadowRenderer,y=r.paint.get("model-receive-shadows");g&&(g.useNormalOffset=!0,y||(g.enabled=!1));const v=()=>{g&&(g.useNormalOffset=!0,y||(g.enabled=!0))},T=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==T.type)return;if("vector"===T.type||"geojson"===T.type)return function(t,i,r,n,o){const s=t.transform,a="globe"===s.projection.name,c=s.getFreeCameraOptions().position;if(!t.modelManager)return;const h=t.modelManager;r.modelManager=h;const d=t.shadowRenderer;if(!r._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const p=r._unevaluatedLayout._values["model-id"],m=Object.assign({},r.layout.get("model-id").parameters),_=t.style.order.indexOf(r.fqid),g=r.paint.get("model-opacity").constantOr(1);for(const S of n){const n=i.getTile(S).getBucket(r);if(!n||n.projection.name!==s.projection.name)continue;const A=n.getModelUris();if(A&&!n.modelsRequested&&(h.addModelsFromBucket(A,o),n.modelsRequested=!0),a)m.zoom=S.overscaledZ;else{const e=FT(S,s);m.zoom=e}const I=p.possiblyEvaluate(m);if(RT(t,n,S),zT.shadowUniformsInitialized=!1,zT.useSingleShadowCascade=!!d&&0===d.getMaxCascadeForTile(S.toUnwrapped()),"shadow"===t.renderPass&&d){if(1===t.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;const e=s.calculatePosMatrix(S.toUnwrapped(),s.worldSize);if(zT.tileMatrix.set(e),zT.shadowTileMatrix=Float32Array.from(d.calculateShadowPassMatrixFromMatrix(e)),zT.aabb.min=[0,0,0],zT.aabb.max[0]=zT.aabb.max[1]=Mn,zT.aabb.max[2]=0,kT(n,zT,t,r.scope))continue}const C=1<<S.canonical.z,M=[((c.x-S.wrap)*C-S.canonical.x)*Mn,(c.y*C-S.canonical.y)*Mn,c.z*C*Mn];t.conflationActive&&Object.keys(n.instancesPerModel).length>0&&t.style.isLayerClipped(r,i.getSource())&&n.updateReplacement(S,t.replacementSource,_,r.scope)&&(n.uploaded=!1,n.upload(t.context));let D=0;const P=new Array,L=new Array,R=new Array;for(let i in n.instancesPerModel){const s=n.instancesPerModel[i];s.features.length>0&&!a&&(i=I.evaluate(s.features[0].feature,{}));const d=h.getModel(i,o);if(d||h.hasURLBeenRequested(i)||n.modelUris.includes(i)||(n.modelUris.push(i),n.modelsRequested=!1),d&&d.uploaded)if(a){const i=B([],[c.x,c.y,c.z],t.transform.worldSize);j(i,i);for(let r=0;r<s.instancedDataArray.length;++r){const o=[0,0,0],a=[1,1,1],c=ae(),h=s.tileCoordinatesForInstance(r),p=s.transformForInstance(r);b(a,p),w(c,p),y=o,v=c,void 0,void 0,T=2*Math.acos(v[3]),(E=Math.sin(T/2))>e?(y[0]=v[0]/E,y[1]=v[1]/E,y[2]=v[2]/E):(y[0]=1,y[1]=0,y[2]=0);const m=s.translationForInstance(r),_=new LngLat(0,0);d_(n.canonical,_,h.x,h.y);const S=l();Qd(S,d,t.transform,_,o,a,m,!0,!1,!1);const A=s.colorForInstance(r),I=u([]),C=x([],[1,1,1/al(_.lat,t.transform.zoom)]);f(I,I,i),R.push({zScaleMatrix:C,negCameraPosMatrix:I});for(const e of d.nodes)CT(t,e,S,t.transform.expandedFarZProjMatrix,D,P,L,d.materialOverrides,g,A);++D}}else for(const e of d.nodes)OT(t,r,e,s,M,S,zT)}if(a)if("shadow"===t.renderPass){for(const e of L)MT(e.mesh,e.nodeModelMatrix,t,r);for(const e of P)MT(e.mesh,e.nodeModelMatrix,t,r)}else LT(t,r,P,L,R)}var y,v,T,E}(t,i,r,n,IT(t,r)),void v();if(!T.loaded())return;if("batched-model"===T.type)return function(e,t,i,r){i.resetLayerRenderingStats(e);const n=e.context,o=e.transform,s=e.style.fog,a=e.shadowRenderer;if("mercator"!==o.projection.name)return void st(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`);const l=e.transform.getFreeCameraOptions().position,c=B([],[l.x,l.y,l.z],e.transform.worldSize),_=j([],c),g=u([]),y=al(o.center.lat,o.zoom),v=x([],[1,1,1/y]);f(g,g,_);const b=i.paint.get("model-opacity").constantOr(1),w=new DepthMode(n.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D),T=new DepthMode(n.gl.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D),E=new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),S="shadow"===e.renderPass,A=S&&a?a.getCurrentCascadeFrustum():o.getFrustum(o.scaleZoom(o.worldSize)),C=i.paint.get("model-front-cutoff"),M=C[2]<1,D=Zv(e,i.paint.get("model-cutoff-fade-range")),P=i.getLayerRenderingStats();(function(e,t,i,r){const n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const s of r){const r=t.getTile(s).getBucket(i);r&&(r.setFilter(i.filter),e.conflationActive&&r.updateReplacement(s,e.replacementSource),r.evaluateTransform(e,i),e.terrain&&n>0&&r.elevationUpdate(e.terrain,n,s,i.source),r.needsReEvaluation(e,o,i)&&r.evaluate(i))}})(e,t,i,r),function(){let l,u,_;M?(l=r.length-1,u=-1,_=-1):(l=0,u=r.length,_=1);const x=new Float64Array(16),L=I(),R=new Le(0,0);for(let I=l;I!==u;I+=_){const l=r[I],u=t.getTile(l).getBucket(i);if(!u||!u.uploaded)continue;let _=!1;a&&(_=0===a.getMaxCascadeForTile(l.toUnwrapped()));const z=o.calculatePosMatrix(l.toUnwrapped(),o.worldSize),F=u.modelTraits;!S&&M&&(d(x,z),Z(L,c,x),R.x=L[0],R.y=L[1]);const O=[];u.setFilter(i.filter);for(const t of u.getNodesInfo()){if(t.hiddenByReplacement)continue;if(!t.node.meshes)continue;const i=t.node;let r=0;e.terrain&&i.elevation&&(r=i.elevation*e.terrain.exaggeration());const n=(()=>{const e=t.aabb;return E.min=[...e.min],E.max=[...e.max],E.min[2]+=r,E.max[2]+=r,Z(E.min,E.min,z),Z(E.max,E.max,z),E})(),s=t.evaluatedScale;if(s[0]<=1&&s[1]<=1&&s[2]<=1&&0===n.intersects(A))continue;if(!S&&M){const e=1/6;t.cameraCollisionOpacity=c[0]>n.min[0]&&c[0]<n.max[0]&&c[1]>n.min[1]&&c[1]<n.max[1]&&c[2]*y<n.max[2]&&i.footprint&&ph(R,i.footprint)?Math.max(t.cameraCollisionOpacity-e,0):Math.min(1,t.cameraCollisionOpacity+e)}const a=[...z],u=1/cl(l.canonical),h=i.anchor?i.anchor[0]:0,d=i.anchor?i.anchor[1]:0;f(a,a,[h*(s[0]-1)+t.evaluatedTranslation[0]*u,d*(s[1]-1)+t.evaluatedTranslation[1]*u,r+t.evaluatedTranslation[2]]),K(s,Jd)||m(a,a,s);const _=p([],a,i.globalMatrix),g=p([],o.expandedFarZProjMatrix,_),x=p([],o.expandedFarZProjMatrix,a),v=se([],[h,d,r,1],g)[2];i.hidden=!1;let w=b;S||(M&&(w*=t.cameraCollisionOpacity,w*=VT(a,o,t.aabb,C)),w*=UT(D,v)),0!==w?O.push({nodeInfo:t,depth:v,opacity:w,wvpForNode:g,wvpForTile:x,nodeModelMatrix:_,tileModelMatrix:a}):i.hidden=!0}S||O.sort(((e,t)=>!M||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 t of O){const r=t.nodeInfo,l=r.node;let c=p([],v,t.tileModelMatrix);p(c,g,c);const u=d([],c);h(u,u),m(u,u,BT),c=p(c,c,l.globalMatrix);const f="light-beam"===e.renderPass,y="none"===i.paint.get("model-color-use-theme").constantOr("default"),x=4&F,b=x?0:r.evaluatedRMEA[0][2];for(let h=0;h<l.meshes.length;++h){const d=l.meshes[h],p=h===l.lightMeshIndex;let m=t.wvpForNode;if(p){if(!f&&!e.terrain&&e.shadowRenderer){e.currentLayer<e.firstLightBeamLayer&&(e.firstLightBeamLayer=e.currentLayer);continue}m=t.wvpForTile}else if(f)continue;const g={defines:[]},v=[];if(!S&&a&&(a.useNormalOffset=!!d.normalBuffer),ST(g.defines,v,d,e,y?null:i.lut),x||g.defines.push("DIFFUSE_SHADED"),_&&g.defines.push("SHADOWS_SINGLE_CASCADE"),P&&(S?P.numRenderedVerticesInShadowPass+=d.vertexArray.length:P.numRenderedVerticesInTransparentPass+=d.vertexArray.length),S){MT(d,t.nodeModelMatrix,e,i);continue}let E=null;if(s){const i=ET(t.nodeModelMatrix,e.transform);if(E=new Float32Array(i),"globe"!==o.projection.name){const e=d.aabb.min,t=d.aabb.max,[r,n]=s.getOpacityForBounds(i,e[0],e[1],t[0],t[1]);g.overrideFog=r>=ry||n>=ry}}const A=d.material;let I;A.occlusionTexture&&A.occlusionTexture.offsetScale&&(I=A.occlusionTexture.offsetScale,g.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const C=e.getOrCreateProgram("model",g);!S&&a&&a.setupShadowsFromMatrix(t.tileModelMatrix,C,a.useNormalOffset),e.uploadCommonUniforms(n,C,null,E);const M=A.pbrMetallicRoughness;M.metallicFactor=.9,M.roughnessFactor=.5;const D=Pw(new Float32Array(m),new Float32Array(c),new Float32Array(u),new Float32Array(l.globalMatrix),e,t.opacity,M.baseColorFactor,A.emissiveFactor,M.metallicFactor,M.roughnessFactor,A,b,i,[0,0,0],I);!p&&(r.hasTranslucentParts||t.opacity<1)&&C.draw(e,n.gl.TRIANGLES,w,StencilMode.disabled,ColorMode.disabled,CullFaceMode.backCCW,D,i.id,d.vertexBuffer,d.indexBuffer,d.segments,i.paint,e.transform.zoom,void 0,v),C.draw(e,n.gl.TRIANGLES,p?T:w,StencilMode.disabled,p||t.opacity<1||r.hasTranslucentParts?ColorMode.alphaBlended:ColorMode.unblended,CullFaceMode.backCCW,D,i.id,d.vertexBuffer,d.indexBuffer,d.segments,i.paint,e.transform.zoom,void 0,v)}}}}()}(t,i,r,n),void v();if("model"!==T.type)return;const E=T.getModels(),S=[],A=t.transform.getFreeCameraOptions().position,C=B([],[A.x,A.y,A.z],t.transform.worldSize);j(C,C);const M=[],D=[];let P=0;for(const e of E){const n=i.getFeatureState("",e.id),o={type:"Unknown",id:e.id,properties:e.featureProperties},s=r.paint.get("model-rotation").evaluate(o,n),l=r.paint.get("model-scale").evaluate(o,n),h=r.paint.get("model-translation").evaluate(o,n),d=r.paint.get("model-opacity").evaluate(o,n);DT(r,e.id,n,e.featureProperties,e.nodeOverrideNames,e.nodeOverrides),PT(r,e.id,n,e.featureProperties,e.materialOverrideNames,e.materialOverrides),e.nodeOverrides.size>0&&e.computeBoundsAndApplyParent(),e.computeModelMatrix(t,s,l,h,c,a,!1);const p=u([]),m=x([],[1,1,1/al(e.position.lat,t.transform.zoom)]);f(p,p,C),S.push({zScaleMatrix:m,negCameraPosMatrix:p});for(const i of e.nodes)CT(t,i,e.matrix,t.transform.expandedFarZProjMatrix,P,M,D,e.materialOverrides,d);P++}if(M.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass)LT(t,r,M,D,S),v();else{for(const e of D)MT(e.mesh,e.nodeModelMatrix,t,r);for(const e of M)MT(e.mesh,e.nodeModelMatrix,t,r);v()}}},WT={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 r of i){const i=t.getTile(r).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 r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(i.modelManager&&i.modelManager.upload(i,IT(i,e)));if("batched-model"===r.type)return;if("model"!==r.type)return;const n=r.getModels();for(const e of n)e.upload(i.context)},raster:function(e,t,i){const r=t.getSource();if(!(r instanceof RasterArrayTileSource&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const t of s)t.updateNeeded(e.id,o)&&r.prepareTile(t,n,e.id,o)},"raster-particle":function(e,t,i){const r=t.getSource();if(!(r instanceof RasterArrayTileSource&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-particle-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const t of s)t.updateNeeded(e.id,o)&&r.prepareTile(t,n,e.id,o)}},XT={fill:Hw},YT={fill:function(e,t,i,r){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const n=e.context.gl,o=new DepthMode(n.LEQUAL,DepthMode.ReadOnly,e.depthRangeFor3D),s=new StencilMode({func:n.ALWAYS,mask:255},255,255,n.KEEP,n.KEEP,n.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of r){const r=t.getTile(c),u=r.getBucket(i);if(!u)continue;const h=u.elevatedStructures;if(!h||0===h.depthSegments.segments[0].primitiveLength)continue;const d=Gw(c.toUnwrapped(),a),p=e.translatePosMatrix(c.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),f=uw(p,d,0,1,0);l.draw(e,n.TRIANGLES,o,s,ColorMode.disabled,CullFaceMode.disabled,f,i.id,h.vertexBuffer,h.indexBuffer,h.depthSegments,i.paint,e.transform.zoom)}}};class Painter{constructor(e,t,i,r,n){this.context=new Context(e,t),this.transform=i,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=Wt.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const o=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const e of o)this._debugParams.enabledLayers[e]=!0;for(const e of o);this.occlusionParams=new OcclusionParams,this.setup(),this.numSublayers=SourceCache.maxUnderzooming+SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new ReplacementSource,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new ShadowRenderer(this),this._wireframeDebugCache=new WireframeDebugCache,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const s=new RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new Texture(this.context,s,e.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,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 Terrain(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.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,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}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 Terrain(this,this.style)),this._forceTerrainMode=e}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(e,t){if(this.width=e*Wt.devicePixelRatio,this.height=t*Wt.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 e=this.context,t=new StructArrayLayout2i4;t.emplaceBack(0,0),t.emplaceBack(Mn,0),t.emplaceBack(0,Mn),t.emplaceBack(Mn,Mn),this.tileExtentBuffer=e.createVertexBuffer(t,oc.members),this.tileExtentSegments=SegmentVector.simpleSegment(0,0,4,2);const i=new StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(Mn,0),i.emplaceBack(0,Mn),i.emplaceBack(Mn,Mn),this.debugBuffer=e.createVertexBuffer(i,oc.members),this.debugSegments=SegmentVector.simpleSegment(0,0,4,5);const r=new StructArrayLayout2i4;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(r,oc.members),this.viewportSegments=SegmentVector.simpleSegment(0,0,4,2);const n=new StructArrayLayout4i8;n.emplaceBack(0,0,0,0),n.emplaceBack(Mn,0,Mn,0),n.emplaceBack(0,Mn,0,Mn),n.emplaceBack(Mn,Mn,Mn,Mn),this.mercatorBoundsBuffer=e.createVertexBuffer(n,Nm.members),this.mercatorBoundsSegments=SegmentVector.simpleSegment(0,0,4,2);const o=new StructArrayLayout3ui6;o.emplaceBack(0,1,2),o.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(o);const s=new StructArrayLayout1ui2;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=e.createIndexBuffer(s),this.emptyTexture=new Texture(e,new RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA8),this.identityMat=l();const a=this.context.gl;this.stencilClearMode=new StencilMode({func:a.ALWAYS,mask:0},0,255,a.ZERO,a.ZERO,a.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,DepthMode.disabled,this.stencilClearMode,ColorMode.disabled,CullFaceMode.disabled,Zb(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 r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(ColorMode.disabled),r.setDepthMode(DepthMode.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),r=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,n.TRIANGLES,DepthMode.disabled,new StencilMode({func:n.ALWAYS,mask:0},r,255,n.KEEP,n.KEEP,n.REPLACE),ColorMode.disabled,CullFaceMode.disabled,Zb(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 StencilMode({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 StencilMode({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)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;i<n;i++)e[i+r]=new StencilMode({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,i]}return[{[r]:StencilMode.disabled},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const t=1/8;return new ColorMode([e.CONSTANT_COLOR,e.ONE,e.CONSTANT_COLOR,e.ONE],new Color(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?ColorMode.unblended:ColorMode.alphaBlended}colorModeForDrapableLayerRenderPass(e){const t=this.context.gl;return(()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?null!=e&&"mrt-fallback"!==this.emissiveMode||"constant"===this.emissiveMode?new ColorMode([t.ONE,t.ONE_MINUS_SRC_ALPHA,t.CONSTANT_ALPHA,t.ONE_MINUS_SRC_ALPHA],new Color(0,0,0,null!=e?e:0),[!0,!0,!0,!0]):"dual-source-blending"===this.emissiveMode?new ColorMode([t.ONE,t.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,t.ONE_MINUS_SRC_ALPHA],Color.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,r=!1){if(this.depthOcclusion)return new DepthMode(this.context.gl.GREATER,DepthMode.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!r)return DepthMode.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new DepthMode(i||this.context.gl.LEQUAL,t,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const e=this.context.gl,t=Math.ceil(this.width),i=Math.ceil(this.height),r=this.context.bindFramebuffer.get(),n=e.getParameter(e.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===t&&this.depthFBO.height===i||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),0!==t&&0!==i&&(this.depthFBO=new Framebuffer(this.context,t,i,0,"texture"),this.depthTexture=new Texture(this.context,{width:t,height:i,data:null},e.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(r),e.bindTexture(e.TEXTURE_2D,n),this.depthFBO&&(e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),e.blitFramebuffer(0,0,t,i,0,0,t,i,e.DEPTH_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.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(e,t){const i=Wt.now();this._dt=i-this._timeStamp,this._timeStamp=i,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=e.map.repaint,this.style=e,this.options=t;const r=this.style._mergedLayers,n=!(!this.terrain||!this.terrain.enabled),o=()=>this.style._getOrder(n).filter((e=>{const t=r[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]}));let s=o(),a=!1,l=!1,c=null,u=0,h=!1;for(const e of s){const t=r[e];"none"!==t.visibility&&("circle"===t.type?a=!0:"building"===t.type?(c=t,++u):"symbol"===t.type&&(t.hasOcclusionOpacityProperties?l=!0:a=!0))}this.updateEmissiveMode();let d=s.map((e=>r[e]));const p=this.style._mergedSourceCaches;this.imageManager=e.imageManager,this.modelManager=e.modelManager,this.symbolFadeChange=e.placement.symbolFadeChange(Wt.now()),this.imageManager.beginFrame();for(const e in p){const t=p[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++u)}let f=!1;for(const e of d)e.isHidden(this.transform.zoom)||("clip"===e.type&&(f=!0),this.prepareLayer(e));const m={},_={},g={},y={},x={};for(const e in p){const t=p[e];m[e]=t.getVisibleCoordinates(),_[e]=m[e].slice().reverse(),g[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),x[e]=t.sortCoordinatesByDistance(m[e])}const v=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(u||f||this._clippingActiveLastFrame){const e=[],t=[];let i=0;for(const r of d)this.isSourceForClippingOrConflation(r,v(r))&&(e.push(r),t.push(i)),i++;if(e&&(f||e.length>1)||this._clippingActiveLastFrame){f=!1;const i=[];for(let r=0;r<e.length;r++){const n=e[r],o=t[r],s=this.style.getLayerSourceCache(n);if(!s||!s.used||!s.getSource().usedInConflation&&"clip"!==n.type&&"building"!==n.type)continue;let a=th,l=0;const c=[];let u=!0;if("building"===n.type)a=ih;else if("clip"===n.type){a=o;for(const e of n.layout.get("clip-layer-types"))l|="model"===e?1:"symbol"===e?2:4;for(const e of n.layout.get("clip-layer-scope"))c.push(e);n.isHidden(this.transform.zoom)?u=!1:f=!0}u&&i.push({layer:n.fqid,cache:s,order:a,clipMask:l,clipScope:c})}this.replacementSource.setSources(i),h=!0}}this._clippingActiveLastFrame=f,h||this.replacementSource.clear(),this.conflationActive=h,this.minCutoffZoom=0,this.longestCutoffRange=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let e=0;e<d.length;e++){const t=d[e];if("none"===t.visibility)continue;const i=t.cutoffRange();if(this.longestCutoffRange=Math.max(i,this.longestCutoffRange),i>0){const e=v(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 b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(g),this.opaquePassCutoff=0,s=o(),d=s.map((e=>r[e])));const w=this._shadowRenderer;if(w){w.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),w.addShadowReceiver(t.toUnwrapped(),e.min,e.max)}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new GlobeSharedBuffers(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Atmosphere(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const T=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),E=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(T&&!this._snow&&(this._snow=new Snow(this)),!T&&this._snow&&(this._snow.destroy(),delete this._snow),E&&!this._rain&&(this._rain=new Rain(this)),!E&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),c){this.buildingTileBorderManager||(this.buildingTileBorderManager=new BuildingTileBorderManager);const e=this.style.getLayerSourceCache(c);this.buildingTileBorderManager.updateBorders(e,c)}if(!nr.has(this.context.gl))return;this.renderPass="offscreen";for(const t of d){const i=e.getLayerSourceCache(t);if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;const r=i?_[i.id]:void 0;("custom"===t.type||"raster"===t.type||"raster-particle"===t.type||t.isSky()||r&&r.length)&&this.renderLayer(this,i,t,r)}this.depthRangeFor3D=[0,1-(d.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 S="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),A=(()=>{if(t.showOverdrawInspector)return Color.black;const e=this.style.fog;if(e&&this.transform.projection.supportsFog){const t=this.style.getLut(e.scope);if(!S){const i="none"===e.properties.get("color-use-theme"),r=e.properties.get("color").toNonPremultipliedRenderColor(i?null:t).toArray01();return new Color(...r)}if(S){const i="none"===e.properties.get("space-color-use-theme"),r=e.properties.get("space-color").toNonPremultipliedRenderColor(i?null:t).toArray01();return new Color(...r)}}return Color.transparent})();if(this.context.clear({color:A,depth:1}),this.clearStencil(),this._showOverdrawInspector=t.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&S&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const t=d[this.currentLayer],i=e.getLayerSourceCache(t);if(t.isSky())continue;const r=i?(t.is3D(n)?x:_)[i.id]:void 0;this._renderTileClippingMasks(t,i,r),this.renderLayer(this,i,t,r)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&S&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||Ac(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const t=d[this.currentLayer],i=e.getLayerSourceCache(t);t.isSky()&&this.renderLayer(this,i,t,i?_[i.id]:void 0)}function I(e,t){let i;return t&&(i=("symbol"===e.type?g:e.is3D(n)?x:_)[t.id]),i}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<s.length;){const t=d[this.currentLayer];if("raster"===t.type||"raster-particle"===t.type){const i=e.getLayerSourceCache(t);this.renderLayer(this,i,t,I(t,i))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let C=0;w&&(C=w.getShadowCastingLayerCount());let M=!1,D=-1;for(let e=0;e<s.length;++e){const t=d[e];t.isHidden(this.transform.zoom)||t.is3D(n)&&(D=e)}l&&-1===D&&(a=!0);let P=!1;for(;this.currentLayer<s.length;){const t=d[this.currentLayer],i=e.getLayerSourceCache(t);if(t.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(t)){if(t.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&&t.is3D(n)&&!n){const e=this.currentLayer,t=e=>{for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){const t=d[this.currentLayer];if(XT[t.type]){const i=this.style.getLayerSourceCache(t);XT[t.type](this,i,t,I(t,i),e)}}};t("initialize"),t("reset"),this.currentLayer=e,P=!0}if(a&&!M&&this.terrain&&!this.transform.isOrthographic&&(M=!0,this.blitDepth()),l&&-1!==D&&this.currentLayer===D+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(t,i,i?m[i.id]:void 0),this.renderLayer(this,i,t,I(t,i)),!this.terrain&&w&&C>0&&t.hasShadowPass()&&0==--C){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){const e=d[this.currentLayer];if(YT[e.type]){const t=this.style.getLayerSourceCache(e);YT[e.type](this,t,e,I(e,t))}}this.currentLayer=e}if(w.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){const t=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=t;this.currentLayer++){const t=d[this.currentLayer];if(!t.hasLightBeamPass())continue;const i=e.getLayerSourceCache(t);this.renderLayer(this,i,t,i?_[i.id]:void 0)}this.currentLayer=t,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const t=this.currentLayer;this.depthOcclusion=!0;for(const t of this.layersWithOcclusionOpacity){this.currentLayer=t;const i=d[this.currentLayer],r=e.getLayerSourceCache(i),n=r?_[r.id]:void 0;this.terrain||this._renderTileClippingMasks(i,r,r?m[r.id]:void 0),this.renderLayer(this,r,i,n)}this.depthOcclusion=!1,this.currentLayer=t,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 t=null;d.forEach((i=>{const r=e.getLayerSourceCache(i);r&&!i.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!t||t.getSource().maxzoom<r.getSource().maxzoom)&&(t=r)})),t&&this.options.showTileBoundaries&&pT(this,t,t.getVisibleCoordinates(),Color.red,!1,this.options.showParseStatus)}this.terrain&&this._debugParams.showTerrainProxyTiles&&pT(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new Color(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(e){const t=e.transform.padding;mT(e,e.transform.height-(t.top||0),3,lT),mT(e,t.bottom||0,3,cT),_T(e,t.left||0,3,uT),_T(e,e.transform.width-(t.right||0),3,hT);const i=e.transform.centerPoint;!function(e,t,i,r){gT(e,t-1,i-10,2,20,r),gT(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,dT)}(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()),h||(this.conflationActive=!1)}prepareLayer(e){this.gpuTimingStart(e);const{unsupportedLayers:t}=this.transform.projection,i=!t||!t.includes(e.type);if(WT[e.type]&&(i||this.terrain&&"custom"===e.type)){const t=this.style.getLayerSourceCache(e);WT[e.type](e,t,this)}this.gpuTimingEnd()}renderLayer(e,t,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||"model"===i.type||"raster"===i.type||"raster-particle"===i.type||r&&r.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||ZT[i.type](e,t,i,r,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 r=this.gpuTimers[e.id];r||(r=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:i.createQuery()}),r.calls++,i.beginQuery(t.TIME_ELAPSED_EXT,r.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 r=e[i],n=this.context.extTimerQuery,o=n.getQueryParameter(r.query,this.context.gl.QUERY_RESULT)/1e6;n.deleteQueryEXT(r.query),t[i]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.gl;let i=0;for(const r of e)i+=t.getQueryParameter(r,t.QUERY_RESULT)/1e6,t.deleteQuery(r);return i}translatePosMatrix(e,t,i,r,n){if(!i[0]&&!i[1])return e;const o=n?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(o){const e=Math.sin(o),t=Math.cos(o);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}const s=[n?i[0]:Hp(t,i[0],this.transform.zoom),n?i[1]:Hp(t,i[1],this.transform.zoom),0],a=new Float32Array(16);return f(a,e,s),a}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 r=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,n=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(n.push("LIGHTING_3D_MODE"),n.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||n.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass&&(this._shadowMapDebug||n.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(n.push("TERRAIN"),this.linearFloatFilteringSupported()&&n.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&n.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||n.push("FOG","FOG_DITHERING"),r&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],r=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=Program.cacheKey(Pb[e],e,n,r);return this.cache[o]||(this.cache[o]=new Program(this.context,e,Pb[e],r,Rw[e],n)),this.cache[o]}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 Texture(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(e,t){if(this.style.enable3dLights()){const i=this.style.directionalLight,r=this.style.ambientLight;if(i&&r){const n=((e,t,i)=>{const r=e.properties.get("direction"),n="none"===e.properties.get("color-use-theme"),o=e.properties.get("color").toNonPremultipliedRenderColor(n?null:i.getLut(e.scope)).toArray01(),s=e.properties.get("intensity"),a="none"===t.properties.get("color-use-theme"),l=t.properties.get("color").toNonPremultipliedRenderColor(a?null:i.getLut(t.scope)).toArray01(),c=t.properties.get("intensity"),u=[r.x,r.y,r.z],h=xt(l,c),d=xt(o,s);return{u_lighting_ambient_color:h,u_lighting_directional_dir:u,u_lighting_directional_color:d,u_ground_radiance:Xb(u,d,h)}})(i,r,this.style);t.setLightsUniformValues(e,n)}}}uploadCommonUniforms(e,t,i,r,n){if(this.uploadCommonLightUniforms(e,t),this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const n=o.getOpacity(this.transform.pitch),s=((e,t,i,r,n,o,s,a,l,c,u,h)=>{const d=e.transform,p="none"===t.properties.get("color-use-theme"),f=t.properties.get("color").toNonPremultipliedRenderColor(p?null:e.style.getLut(t.scope)).toArray01();f[3]=r;const m=e.frameCounter/1e3%1,[_,g]=t.properties.get("vertical-range");return{u_fog_matrix:i?d.calculateFogTileMatrix(i):h||e.identityMat,u_fog_range:t.getFovAdjustedRange(d._fov),u_fog_color:f,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_,g),g],u_fog_temporal_offset:m,u_frustum_tl:n,u_frustum_tr:o,u_frustum_br:s,u_frustum_bl:a,u_globe_pos:l,u_globe_radius:c,u_viewport:u,u_globe_transition:Ac(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,o,i,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*Wt.devicePixelRatio,this.transform.height*Wt.devicePixelRatio],r);t.setFogUniformValues(e,s)}n&&t.setCutoffUniformValues(e,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 e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)t[r.key]=e[r.key]||new Tile(r,512,this.transform.tileZoom,this,void 0,this.worldview);return t}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]>=ry||t[1]>=ry}setupDepthForOcclusion(e,t,i){const r=this.context,n=r.gl,o=!!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}),r.activeTexture.set(n.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(n.NEAREST,n.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(n.NEAREST,n.CLAMP_TO_EDGE),r.activeTexture.set(n.TEXTURE0),o||t.setTerrainUniformValues(r,i)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const e=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=e?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function KT(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}class Hash{constructor(e){this._hashName=e&&encodeURIComponent(e),et(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=KT(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=JT(e);if(this._hashName){const e=this._hashName;let i=!1;const r=location.hash.slice(1).split("&").map((r=>{const n=r.split("=")[0];return n===e?(i=!0,`${n}=${t}`):r})).filter((e=>e));return i||r.push(`${e}=${t}`),`#${r.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 JT(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${s}/${a}/${r}`:`${r}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const QT={linearity:.3,easing:je(0,0,.3,1)},eE=Object.assign({deceleration:2500,maxSpeed:1400},QT),tE=Object.assign({deceleration:20,maxSpeed:1400},QT),iE=Object.assign({deceleration:1e3,maxSpeed:360},QT),rE=Object.assign({deceleration:1e3,maxSpeed:90},QT);class HandlerInertia{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Wt.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=Wt.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,pan:new Le(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)t.zoom+=e.zoomDelta||0,t.bearing+=e.bearingDelta||0,t.pitch+=e.pitchDelta||0,e.panDelta&&t.pan._add(e.panDelta),e.around&&(t.around=e.around),e.pinchAround&&(t.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(t.pan.mag()){const n=oE(t.pan.mag(),i,Object.assign({},eE,e||{}));r.offset=t.pan.mult(n.amount/t.pan.mag()),r.center=this._map.transform.center,nE(r,n)}if(t.zoom){const e=oE(t.zoom,i,tE);r.zoom=this._map.transform.zoom+e.amount,nE(r,e)}if(t.bearing){const e=oE(t.bearing,i,iE);r.bearing=this._map.transform.bearing+He(e.amount,-179,179),nE(r,e)}if(t.pitch){const e=oE(t.pitch,i,rE);r.pitch=this._map.transform.pitch+e.amount,nE(r,e)}if(r.zoom||r.bearing){const e=void 0===t.pinchAround?t.around:t.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function nE(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function oE(e,t,i){const{maxSpeed:r,linearity:n,deceleration:o}=i,s=He(e*n/(t/1e3),-r,r),a=Math.abs(s)/(o*n);return{easing:i.easing,duration:1e3*a,amount:s*(a/2)}}class MapMouseEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){const n=ni(t.getCanvasContainer(),i),o=t.unproject(n);super(e,Object.assign({point:n,lngLat:o,originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}}class MapTouchEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){const r="touchend"===e?i.changedTouches:i.touches,n=oi(t.getCanvasContainer(),r),o=n.map((e=>t.unproject(e))),s=n.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new Le(0,0));super(e,{points:n,point:s,lngLats:o,lngLat:t.unproject(s),originalEvent:i}),this._defaultPrevented=!1}}class MapWheelEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}}class MapEventHandler{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new MapWheelEvent(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new MapMouseEvent(e.type,this._map,e))}mouseup(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new MapMouseEvent(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new MapMouseEvent(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new MapMouseEvent(e.type,this._map,e))}mouseover(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}mouseout(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}touchstart(e){return this._firePreventable(new MapTouchEvent(e.type,this._map,e))}touchmove(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}touchend(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}touchcancel(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class BlockableMapEventHandler{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new MapMouseEvent("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new MapMouseEvent(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class BoxZoomHandler{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&&(ei(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,r=this._startPos,n=this._lastPos;if(!r||!n||n.equals(i)||!this._box&&i.dist(r)<this._clickTolerance)return;this._lastPos=i,this._box||(this._box=Xt("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const o=Math.min(r.x,i.x),s=Math.max(r.x,i.x),a=Math.min(r.y,i.y),l=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=l-a+"px")}))}mouseupWindow(e,t){if(!this._active)return;const i=this._startPos,r=t;if(i&&0===e.button){if(this.reset(),ri(),i.x!==r.x||i.y!==r.y)return this._map.fire(new Event("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}}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),ti(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Event(e,{originalEvent:t}))}}function sE(e,t){const i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}class SingleTapRecognizer{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){const t=new Le(0,0);for(const i of e)t._add(i);return t.div(e.length)}(t),this.touches=sE(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=sE(i,t);for(const e in this.touches){const t=r[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 TapRecognizer{constructor(e){this.singleTap=new SingleTapRecognizer(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 r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class TapZoomHandler{constructor(){this._zoomIn=new TapRecognizer({numTouches:1,numTaps:2}),this._zoomOut=new TapRecognizer({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 r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return 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})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{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 aE={0:1,2:2},lE={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class MouseHandler{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=si(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=aE[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&&si(e)===this._eventButton&&(this._moved&&ri(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class MousePanHandler extends MouseHandler{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 MouseRotateHandler extends MouseHandler{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?lE[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 MousePitchHandler extends MouseHandler{constructor(e){super(e),this._pitchRotateKey=e.pitchRotateKey?lE[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 TouchPanHandler{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._minTouches=1,this._clickTolerance=t.clickTolerance||1,this.reset(),et(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new Le(0,0)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length&&!mt())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return e.cancelable&&e.preventDefault(),this._calculateTransform(e,t,i)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);const r=sE(i,t),n=new Le(0,0),o=new Le(0,0);let s=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(n._add(t),o._add(t.sub(i)),s++,r[e]=t)}if(this._touches=r,s<this._minTouches||!o.mag())return;const a=o.div(s);return this._sum._add(a),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(s),panDelta:a}}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=Xt("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 TwoTouchHandler{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 r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,s=cE(i,t,n),a=cE(i,t,o);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[r,n]=this._firstTwoTouches,o=cE(i,t,r),s=cE(i,t,n);o&&s||(this._active&&ri(),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 cE(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function uE(e,t){return Math.log2(e/t)}class TouchZoomHandler extends TwoTouchHandler{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(uE(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:uE(this._distance,i),pinchAround:t}}}function hE(e,t){return 180*e.angleWith(t)/Math.PI}class TouchRotateHandler extends TwoTouchHandler{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:hE(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 r=hE(e,i);return Math.abs(r)<t}}function dE(e){return Math.abs(e.y)>Math.abs(e.x)}class TouchPitchHandler extends TwoTouchHandler{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,dE(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){const r=this._lastPoints;if(!r)return;const n=e[0].sub(r[0]),o=e[1].sub(r[1]);return this._map._cooperativeGestures&&!mt()&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return dE(e)&&dE(t)&&o}}const pE={panStep:100,bearingStep:15,pitchStep:10};class KeyboardHandler{constructor(){const e=pE;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,r=0,n=0,o=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(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:fE,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*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 fE(e){return e*(2-e)}const mE=4.000244140625,_E=1/450;class ScrollZoomHandler{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._handler=t,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=_E,et(["_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(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||mt()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=Wt.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%mE==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=window.setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.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=ni(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 e=this._map.transform;"wheel"===this._type&&e.projection.wrap&&(e._center.lng>=180||e._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const t=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>mE?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n=t(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:t(),r=this._startZoom,n=this._easing;let o,s=!1;if("wheel"===this._type&&r&&n){const e=Math.min((Wt.now()-this._lastWheelEventTime)/200,1);o=xr(r,i,n(e)),e<1?this._frameId||(this._frameId=!0):s=!0}else o=i,s=!0;this._active=!0,s&&(this._active=!1,this._finishTimeout=window.setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200));let a=o-t();return a*this._lastDelta<0&&(a=0),{noInertia:!0,needsRenderFrame:!s,zoomDelta:a,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=Ge;if(this._prevEase){const e=this._prevEase,i=(Wt.now()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;t=je(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:Wt.now(),duration:e,easing:t},t}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Xt("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 DoubleClickZoomHandler{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 ClickZoomHandler{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 TapDragZoomHandler{constructor(){this._tap=new TapRecognizer({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 r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/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 DragPanHandler{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 DragRotateHandler{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 TouchZoomRotateHandler{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,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 gE=e=>e.zoom||e.drag||e.pitch||e.rotate;class RenderFrameEvent extends Event{}class TrackingEllipsoid{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,t){const i=J([],t,e);this.radius=M(i[2]<0?ee([],i,this.constants):[i[0],i[1],0])}projectRay(e){ee(e,e,this.constants),G(e,e),Q(e,e,this.constants);const t=B([],e,this.radius);if(t[2]>0){const e=B([],[0,0,1],H(t,[0,0,1])),i=B([],G([],[t[0],t[1],0]),this.radius),r=L([],t,B([],J([],L([],i,e),t),2));t[0]=r[0],t[1]=r[1]}return t}}function yE(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class HandlerManager{constructor(e,t){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new HandlerInertia(e),this._bearingSnap=t.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new TrackingEllipsoid,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(t),et(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,r,i)}}destroy(){for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,r,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new MapEventHandler(t,e));const r=t.boxZoom=new BoxZoomHandler(t,e);this._add("boxZoom",r);const n=new TapZoomHandler,o=new ClickZoomHandler;t.doubleClickZoom=new DoubleClickZoomHandler(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new TapDragZoomHandler;this._add("tapDragZoom",s);const a=t.touchPitch=new TouchPitchHandler(t);this._add("touchPitch",a);const l=new MouseRotateHandler(e),c=new MousePitchHandler(e);t.dragRotate=new DragRotateHandler(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new MousePanHandler(e),h=new TouchPanHandler(t,e);t.dragPan=new DragPanHandler(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new TouchRotateHandler,p=new TouchZoomHandler;t.touchZoomRotate=new TouchZoomRotateHandler(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new BlockableMapEventHandler(t));const f=t.scrollZoom=new ScrollZoomHandler(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new KeyboardHandler;this._add("keyboard",m);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!!gE(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<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,r=i?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?oi(this._el,a):i?void 0:ni(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,h,i,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=r);this._previousActiveHandlers=s,(Object.keys(c).length||yE(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||yE(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,r,n){if(!i)return;Object.assign(e,i);const o={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o)}_applyChanges(){const e={},t={},i={};for(const[r,n,o]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new Le(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.aroundCoord&&(e.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),Object.assign(t,n),Object.assign(i,o);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){const r=this._map,n=r.transform,o=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!yE(e)){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),!yE(e))return void this._fireEvents(t,i,!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,around:u,aroundCoord:h,pinchAround:d}=e;n._isCameraConstrained&&(a>0&&(a=0),n._isCameraConstrained=!1),void 0!==d&&(u=d),(a||(e=>t[e]&&!this._eventsInProgress[e])("drag"))&&u&&(this._dragOrigin=o(n.pointCoordinate3D(u)),this._originalZoom=n.zoom,this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),u=u||r.transform.centerPoint,l&&(n.bearing+=l),c&&(n.pitch+=c),n._updateCameraState();const p=[0,0,0];if(s)if("mercator"===n.projection.name){const e=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(u).dir),t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(u.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1]}else{const e=n.pointCoordinate(u);if("globe"===n.projection.name){s=s.rotate(-n.angle);const t=n._pixelsPerMercatorPixel/n.worldSize;p[0]=-s.x*ll(rl(e.y))*t,p[1]=-s.y*ll(n.center.lat)*t}else{const t=n.pointCoordinate(u.sub(s));e&&t&&(p[0]=t.x-e.x,p[1]=t.y-e.y)}}const f=n.zoom,m=[0,0,0];if(a){const e=o(h||n.pointCoordinate3D(u)),t={dir:G([],J([],e,n._camera.position))};if(t.dir[2]<0){const i=n.zoomDeltaToMovement(e,a);B(m,t.dir,i)}}const _=L(p,p,m);n._translateCameraConstrained(_),a&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_fireEvents(e,t,i){const r=gE(this._eventsInProgress),n=gE(e),o={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in o)this._fireEvent(e,o[e]);n&&this._fireEvent("move",n.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const s={};let a;for(const e in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[e];this._handlersById[i].isActive()||(delete this._eventsInProgress[e],a=t[i]||r,s[`${e}end`]=a)}for(const e in s)this._fireEvent(e,s[e]);const l=gE(this._eventsInProgress);if(i&&(r||n)&&!l){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;e?(t(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:a})):(this._map.fire(new Event("moveend",{originalEvent:a})),t(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new Event(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new RenderFrameEvent("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const xE="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Camera extends Evented{constructor(e,t){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=t.bearingSnap,this._respectPrefersReducedMotion=!1!==t.respectPrefersReducedMotion,et(["_renderFrameCallback"],this)}getCenter(){return new LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(e,t,i){return e=Le.convert(e).mult(-1),this.panTo(this.transform.center,Object.assign({offset:e},t),i)}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(e,t){e=LngLatBounds.convert(e);const i=t&&t.bearing||0,r=t&&t.pitch||0,n=e.getNorthWest(),o=e.getSouthEast();return this._cameraForBounds(this.transform,n,o,i,r,t)}_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],r=t.max[1]-t.min[1];return i/r>e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(e,t,i,r,n,o){const s=e.clone(),a=this._extendCameraOptions(o);s.bearing=r,s.pitch=n;const l=LngLat.convert(t),c=LngLat.convert(i),u=.5*(l.lat+c.lat),h=.5*(l.lng+c.lng),f=Za(u,h),m=G([],f),_=G([],q([],m,[0,1,0])),g=q([],_,m),y=[_[0],_[1],_[2],0,g[0],g[1],g[2],0,m[0],m[1],m[2],0,0,0,0,1],x=[f,Za(l.lat,l.lng),Za(c.lat,l.lng),Za(c.lat,c.lng),Za(l.lat,c.lng),Za(u,l.lng),Za(u,c.lng),Za(l.lat,h),Za(c.lat,h)];let v=Aabb.fromPoints(x.map((e=>[H(_,e),H(g,e),H(m,e)])));const b=Z([],v.center,y);0===N(b)&&P(b,0,0,1),G(b,b),B(b,b,ka),s.center=function([e,t,i]){const r=Math.hypot(e,t,i),n=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/r);return new LngLat(Be(n),Be(o))}(b);const w=s.getWorldToCameraMatrix(),T=d(new Float64Array(16),w);v=Aabb.applyTransform(v,p([],w,y));const E=this._extendAABB(v,s,a,r);if(!E)return void st("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=E,Z(b,b,w);const S=.5*(v.max[2]-v.min[2]),A=this._minimumAABBFrustumDistance(s,v),I=B([],[0,0,1],S),C=L(I,b,I),D=A+(0===s.pitch?0:U(b,C)),R=s.globeCenterInViewSpace,z=J([],b,[R[0],R[1],R[2]]);G(z,z),B(z,z,D);const F=L([],b,z);Z(F,F,T);const O=Wa/ka,k=M(F),V=tl(Math.max(k*O-Wa,Number.EPSILON),0),j=Math.min(s.zoomFromMercatorZAdjusted(V),a.maxZoom);return j>.5*(Ua+Va)?(s.setProjection({name:"mercator"}),s.zoom=j,this._cameraForBounds(s,t,i,r,n,o)):{center:s.center,zoom:j,bearing:r,pitch:n}}_extendAABB(e,t,i,r){const n=.5*((i.padding.left||0)+(i.padding.right||0)),o=.5*((i.padding.top||0)+(i.padding.bottom||0)),s=o,a=n,l=n,c=o,u=t.width-(a+l),h=t.height-(s+c),d=J([],e.max,e.min),p=Math.min(u/d[0],h/d[1]),f=Math.min(t.scaleZoom(t.scale*p),i.maxZoom);if(isNaN(f))return null;const m=t.scale/t.zoomScale(f),_=new Aabb([e.min[0]-a*m,e.min[1]-c*m,e.min[2]],[e.max[0]+l*m,e.max[1]+s*m,e.max[2]]),g=("number"==typeof i.offset.x&&"number"==typeof i.offset.y?new Le(i.offset.x,i.offset.y):Le.convert(i.offset)).rotate(-Oe(r));return _.center[0]-=g.x*m,_.center[1]+=g.y*m,_}queryTerrainElevation(e,t){const i=this.transform.elevation;return i?(t=Object.assign({},{exaggerated:!0},t),i.getAtPoint(MercatorCoordinate.fromLngLat(e),null,t.exaggerated)):null}_cameraForBounds(e,t,i,r,n,o){if("globe"===e.projection.name)return this._cameraForBoundsOnGlobe(e,t,i,r,n,o);const s=e.clone(),a=this._extendCameraOptions(o);s.bearing=r,s.pitch=n;const l=LngLat.convert(t),c=LngLat.convert(i),u=new LngLat(l.lng,c.lat),h=new LngLat(c.lng,l.lat),p=s.project(l),f=s.project(c),m=this.queryTerrainElevation(l),_=this.queryTerrainElevation(c),g=this.queryTerrainElevation(u),y=this.queryTerrainElevation(h),x=[[p.x,p.y,Math.min(m||0,_||0,g||0,y||0)],[f.x,f.y,Math.max(m||0,_||0,g||0,y||0)]];let v=Aabb.fromPoints(x);const b=s.getWorldToCameraMatrix(),w=d(new Float64Array(16),b);v=Aabb.applyTransform(v,b);const T=this._extendAABB(v,s,a,r);if(!T)return void st("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=T;const E=.5*J([],v.max,v.min)[2],S=this._minimumAABBFrustumDistance(s,v),A=[0,0,1,0];se(A,A,b),oe(A,A);const I=B([],A,S+E),C=L([],v.center,I);Z(v.center,v.center,w),Z(C,C,w);const M=s.unproject(new Le(v.center[0],v.center[1])),D=$d(s.projection,M),P=Math.pow(2,D),R=Math.min(s._zoomFromMercatorZ(C[2]*s.pixelsPerMeter*P/s.worldSize),a.maxZoom);return s.mercatorFromTransition&&R<.5*(Ua+Va)?(s.setProjection({name:"globe"}),s.zoom=R,this._cameraForBounds(s,t,i,r,n,o)):{center:M,zoom:R,bearing:r,pitch:n}}fitBounds(e,t,i){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,i)}fitScreenCoordinates(e,t,i,r,n){const o=Le.convert(e),s=Le.convert(t),a=new Le(Math.min(o.x,s.x),Math.min(o.y,s.y)),l=new Le(Math.max(o.x,s.x),Math.max(o.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,s))return this;const c=this.transform.pointLocation3D(a),u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(new Le(a.x,l.y)),d=this.transform.pointLocation3D(new Le(l.x,a.y)),p=[Math.min(c.lng,u.lng,h.lng,d.lng),Math.min(c.lat,u.lat,h.lat,d.lat)],f=[Math.max(c.lng,u.lng,h.lng,d.lng),Math.max(c.lat,u.lat,h.lat,d.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,p,f,i,m,r);return this._fitInternal(_,r,n)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(e,t){this.stop();const i=e.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,o=!1;"zoom"in e&&i.zoom!==+e.zoom&&(r=!0,i.zoom=+e.zoom),void 0!==e.center&&(i.center=LngLat.convert(e.center)),"bearing"in e&&i.bearing!==+e.bearing&&(n=!0,i.bearing=+e.bearing),"pitch"in e&&i.pitch!==+e.pitch&&(o=!0,i.pitch=+e.pitch);const s="number"==typeof e.padding?this._extendPadding(e.padding):e.padding;if(null!=e.padding&&!i.isPaddingEqual(s))if(!1===e.retainPadding){const e=i.clone();e.padding=s,i.setLocationAtPoint(i.center,e.centerPoint)}else i.padding=s;return e.preloadOnly?(this._preloadTiles(i),this):(this.fire(new Event("movestart",t)).fire(new Event("move",t)),r&&this.fire(new Event("zoomstart",t)).fire(new Event("zoom",t)).fire(new Event("zoomend",t)),n&&this.fire(new Event("rotatestart",t)).fire(new Event("rotate",t)).fire(new Event("rotateend",t)),o&&this.fire(new Event("pitchstart",t)).fire(new Event("pitch",t)).fire(new Event("pitchend",t)),this.fire(new Event("moveend",t)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||st(xE),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const i=this.transform;if(!i.projection.supportsFreeCamera)return st(xE),this;this.stop();const r=i.zoom,n=i.pitch,o=i.bearing;i.setFreeCameraOptions(e);const s=r!==i.zoom,a=n!==i.pitch,l=o!==i.bearing;return this.fire(new Event("movestart",t)).fire(new Event("move",t)),s&&this.fire(new Event("zoomstart",t)).fire(new Event("zoom",t)).fire(new Event("zoomend",t)),l&&this.fire(new Event("rotatestart",t)).fire(new Event("rotate",t)).fire(new Event("rotateend",t)),a&&this.fire(new Event("pitchstart",t)).fire(new Event("pitch",t)).fire(new Event("pitchend",t)),this.fire(new Event("moveend",t)),this}easeTo(e,t){this._stop(!1,e.easeId),(!1===(e=Object.assign({offset:[0,0],duration:500,easing:Ge},e)).animate||this._prefersReducedMotion(e))&&(e.duration=0);const i=this.transform,r=this.getZoom(),n=this.getBearing(),o=this.getPitch(),s=this.getPadding(),a="zoom"in e?+e.zoom:r,l="bearing"in e?this._normalizeBearing(e.bearing,n):n,c="pitch"in e?+e.pitch:o,u=this._extendPadding(e.padding),h=Le.convert(e.offset);let d,p,f;if("globe"===i.projection.name){const t=MercatorCoordinate.fromLngLat(i.center),r=h.rotate(-i.angle);t.x+=r.x/i.worldSize,t.y+=r.y/i.worldSize;const n=t.toLngLat(),o=LngLat.convert(e.center||n);this._normalizeCenter(o),d=i.centerPoint.add(r),p=new Le(t.x,t.y).mult(i.worldSize),f=new Le(Qa(o.lng),el(o.lat)).mult(i.worldSize).sub(p)}else{d=i.centerPoint.add(h);const t=i.pointLocation(d),r=LngLat.convert(e.center||t);this._normalizeCenter(r),p=i.project(t),f=i.project(r).sub(p)}const m=i.zoomScale(a-r);let _,g;e.around&&(_=LngLat.convert(e.around),g=i.locationPoint(_));const y=this._zooming||a!==r,x=this._rotating||n!==l,v=this._pitching||c!==o,b=!i.isPaddingEqual(u),w=!1===e.retainPadding?i.clone():i,T=i=>T=>{if(y&&(i.zoom=xr(r,a,T)),x&&(i.bearing=xr(n,l,T)),v&&(i.pitch=xr(o,c,T)),b&&(w.interpolatePadding(s,u,T),d=w.centerPoint.add(h)),_)i.setLocationAtPoint(_,g);else{const e=i.zoomScale(i.zoom-r),t=a>r?Math.min(2,m):Math.max(.5,m),n=Math.pow(t,1-T),o=i.unproject(p.add(f.mult(T*n)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?o.wrap():o,d)}return e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(T,e.duration,i);return this._preloadTiles(t),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=v,this._padding=b,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,E),this._ease(T(i),(e=>{"sea"===i.cameraElevationReference&&i.recenterOnTerrain(),this._afterEase(t,e)}),e),this}_prepareEase(e,t,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),t||i.moving||this.fire(new Event("movestart",e)),this._zooming&&!i.zooming&&this.fire(new Event("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new Event("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new Event("move",e)),this._zooming&&this.fire(new Event("zoom",e)),this._rotating&&this.fire(new Event("rotate",e)),this._pitching&&this.fire(new Event("pitch",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new Event("zoomend",e)),r&&this.fire(new Event("rotateend",e)),n&&this.fire(new Event("pitchend",e)),this.fire(new Event("moveend",e))}flyTo(e,t){if(this._prefersReducedMotion(e)){const i=We(e,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(i,t)}this.stop(),e=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:Ge},e);const i=this.transform,r=this.getZoom(),n=this.getBearing(),o=this.getPitch(),s=this.getPadding(),a="zoom"in e?He(+e.zoom,i.minZoom,i.maxZoom):r,l="bearing"in e?this._normalizeBearing(e.bearing,n):n,c="pitch"in e?+e.pitch:o,u=this._extendPadding(e.padding),h=i.zoomScale(a-r),d=Le.convert(e.offset);let p=i.centerPoint.add(d);const f=i.pointLocation(p),m=LngLat.convert(e.center||f);this._normalizeCenter(m);const _=i.project(f),g=i.project(m).sub(_);let y=e.curve;const x=Math.max(i.width,i.height),v=x/h,b=g.mag();if("minZoom"in e){const t=He(Math.min(e.minZoom,r,a),i.minZoom,i.maxZoom),n=x/i.zoomScale(t-r);y=Math.sqrt(n/b*2)}const w=y*y;function T(e){const t=(v*v-x*x+(e?-1:1)*w*w*b*b)/(2*(e?v:x)*w*b);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function S(e){return(Math.exp(e)+Math.exp(-e))/2}const A=T(0);let I=function(e){return S(A)/S(A+y*e)},C=function(e){return x*((S(A)*(E(t=A+y*e)/S(t))-E(A))/w)/b;var t},M=(T(1)-A)/y;if(Math.abs(b)<1e-6||!isFinite(M)){if(Math.abs(x-v)<1e-6)return this.easeTo(e,t);const i=v<x?-1:1;M=Math.abs(Math.log(v/x))/y,C=function(){return 0},I=function(e){return Math.exp(i*y*e)}}e.duration="duration"in e?+e.duration:1e3*M/("screenSpeed"in e?+e.screenSpeed/y:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0);const D=n!==l,P=c!==o,L=!i.isPaddingEqual(u),R=!1===e.retainPadding?i.clone():i,z=i=>h=>{const f=h*M,y=1/I(f);i.zoom=1===h?a:r+i.scaleZoom(y),D&&(i.bearing=xr(n,l,h)),P&&(i.pitch=xr(o,c,h)),L&&(R.interpolatePadding(s,u,h),p=R.centerPoint.add(d));const x=1===h?m:i.unproject(_.add(g.mult(C(f))).mult(y));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,p),i._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(z,e.duration,i);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=D,this._pitching=P,this._padding=L,this._prepareEase(t,!1),this._ease(z(i),(()=>this._afterEase(t)),e),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(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=Wt.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((Wt.now()-this._easeStart)/this._easeOptions.duration,1),t=this._onEaseFrame;t&&t(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,t){e=$e(e,-180,180);const i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}_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(e){return this._respectPrefersReducedMotion&&Wt.prefersReducedMotion&&!(e&&e.essential)}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}_preloadTiles(e,t){}}class AttributionControl{constructor(e={}){this.options=e,et(["_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=Xt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=Xt("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const r=Xt("span","mapboxgl-ctrl-icon",this._compactButton);return r.setAttribute("aria-hidden","true"),r.setAttribute("title",i),this._innerContainer=Xt("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 e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const t=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||Mt.ACCESS_TOKEN}];if(e){const i=t.reduce(((e,i,r)=>(i.value&&(e+=`${i.key}=${i.value}${r<t.length-1?"&":""}`),e)),"?");e.href=`${Mt.FEEDBACK_URL}/${i}#${JT(this._map,!0)}`,e.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 r=t[i];if(r.used){const t=r.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 r=i+1;r<e.length;r++)if(e[r].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("*")).forEach((e=>{const i=e.textContent||"";if("A"!==e.tagName)return void e.replaceWith(t.createTextNode(i));const r=e.getAttribute("href");if(!r||!/^(https?:|mailto:)/i.test(r))return void e.replaceWith(t.createTextNode(i));const n=t.createElement("a");n.href=r,n.textContent=i,n.rel="noopener nofollow";const o=e.getAttribute("class");o&&(n.className=o),e.replaceWith(n)})),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 LogoControl{constructor(){et(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=Xt("div","mapboxgl-ctrl");const t=Xt("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 IndoorControl{constructor(){et(["_onIndoorUpdate"],this)}onAdd(e){return this._map=e,this._container=Xt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",(e=>this._onIndoorUpdate(e))),this._container}_createButton(e,t){const i=Xt("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_createSeparator(){return Xt("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(e,t){this._map&&(e.setAttribute("aria-label",t),e.textContent=t)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(e){if(!e||!e.floors)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block",this._container.style.borderRadius="8px",t&&Array.from(this._container.children).forEach((e=>e.remove())),e.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(e.floors,e.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const e=this._createButton("mapboxgl-ctrl-buildings-toggle",(()=>{const e=this._map;this._model&&e&&e._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)}));Xt("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(e),this._createSeparator()}_updateBuildingsButtonState(){const e=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");e&&this._model&&(this._model.activeFloorsVisible?e.classList.remove("mapboxgl-ctrl-level-button-selected"):e.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(e,t){for(let i=0;i<e.length;i++){const r=e[i],n=this._createButton("mapboxgl-ctrl-level-button",(()=>{this._map._selectIndoorFloor(r.id)}));this._setButtonTitle(n,r.zIndex.toString()),this._model&&r.id===this._model.selectedFloorId&&t&&n.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(n),i<e.length-1&&this._createSeparator()}}}class TaskQueue{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 EasedVariable{constructor(e){this.jumpTo(e)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const t=Ue((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-t)+this._end*t}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 vE={"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 InteractionEvent extends Event{constructor(e,t,i,r){const{point:n,lngLat:o,originalEvent:s,target:a}=e;super(e.type,{point:n,lngLat:o,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault()},this.id=t,this.interaction=i,this.feature=r}}class InteractionSet{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(e,t){if(this.typeById.has(e))throw new Error(`Interaction id "${e}" already exists.`);const i=t.filter;let r=t.type;i&&this.filters.set(e,Zs(i)),"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(e,t)):0===n.size&&this.map.on(r,this.handleType),0===n.size&&this.interactionsByType.set(r,n),n.set(e,t),this.typeById.set(e,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,r]of t)r.target&&i.push({targetId:e,target:r.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(e,t){const i="mouseenter"===e.type;if(i&&!this.interactionsByType.has(e.type))return void st("mouseenter interaction required for mouseleave to work.");const r=Array.from(this.interactionsByType.get(e.type)).reverse(),n=!!t;t=t||this.queryTargets(e.point,r);let o=!1;const s=new Set;for(const a of t){for(const[t,l]of r){if(!l.target)continue;const r=a.variants?a.variants[t]:null;if(r){for(const c of r){if(wx(c,a,s,t))continue;const r=new TargetFeature(a,c),u=bx(c,a,t);n&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const h=i?this.prevHoveredFeatures.get(u):null,d=new InteractionEvent(e,t,l,r),p=h?h.stop:l.handler(d);if(i&&this.hoveredFeatures.set(u,{feature:a,stop:p}),!1!==p){o=!0;break}}if(o)break}}if(o)break}if(!o)for(const[t,i]of r){const{handler:r,target:n}=i;if(!n&&!1!==r(new InteractionEvent(e,t,i,null)))break}}}function bE(e,t){if(Array.isArray(e)&&Array.isArray(t)){const i=new Set(e),r=new Set(t);return i.size===r.size&&e.every((e=>r.has(e)))}return Re(e,t)}const wE={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,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},TE={showCompass:!0,showZoom:!0,visualizePitch:!1};class MouseRotateWrapper{constructor(e,t,i=!1){this._clickTolerance=10,this.element=t,this.mouseRotate=new MouseRotateHandler({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,i&&(this.mousePitch=new MousePitchHandler({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),et(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),ei()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}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(){ti(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(Object.assign({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),ni(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,ni(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=oi(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=oi(this.element,e.targetTouches)[0],this.move({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 EE(e,t,i){if(e=new LngLat(e.lng,e.lat),t){const r=new LngLat(e.lng-360,e.lat),n=new LngLat(e.lng+360,e.lat),o=360*Math.ceil(Math.abs(e.lng-i.center.lng)/360),s=i.locationPoint3D(e).distSqr(t),a=t.x<0||t.y<0||t.x>i.width||t.y>i.height;i.locationPoint3D(r).distSqr(t)<s&&(a||Math.abs(r.lng-i.center.lng)<o)?e=r:i.locationPoint3D(n).distSqr(t)<s&&(a||Math.abs(n.lng-i.center.lng)<o)&&(e=n)}for(;Math.abs(e.lng-i.center.lng)>180;){const t=i.locationPoint3D(e);if(t.x>=0&&t.y>=0&&t.x<=i.width&&t.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e}const SE={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%)"},AE={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Marker extends Evented{constructor(e,t){super(),(e instanceof HTMLElement||t)&&(e=Object.assign({element:e},t)),et(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:i="center",color:r="#3FB1CE",scale:n=1,draggable:o=!1,clickTolerance:s=0,rotation:a=AE.rotation,rotationAlignment:l=AE.rotationAlignment,pitchAlignment:c=AE.pitchAlignment,occludedOpacity:u=AE.occludedOpacity,altitude:h=AE.altitude}=e||{};this._anchor=i,this._color=r,this._scale=n,this._draggable=o,this._clickTolerance=s,this._rotation=a,this._rotationAlignment=l,this._pitchAlignment=c,this._occludedOpacity=u,this._altitude=h,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),e&&e.element?(this._element=e.element,this._offset=Le.convert(e&&e.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=Le.convert(e&&e.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 d=this._element.classList;for(const e in SE)d.remove(`mapboxgl-marker-anchor-${e}`);d.add(`mapboxgl-marker-anchor-${this._anchor}`);const p=e&&e.className?e.className.trim().split(/\s+/):[];d.add(...p),this._popup=null}_createDefaultMarker(){const e=Xt("div"),t=Yt("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=Yt("radialGradient",{id:"shadowGradient"},Yt("defs",{},t));Yt("stop",{offset:"10%","stop-opacity":.4},e),Yt("stop",{offset:"100%","stop-opacity":.05},e),Yt("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},t)}return Yt("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),Yt("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),Yt("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(e){return this._lngLat=LngLat.convert(e),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||AE.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,r=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":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],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),r=e.getFreeCameraOptions();if(!r.position)return!1;const n=r.position.toLngLat();return n.distanceTo(i)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const t=this._pos;if(!t||t.x<0||t.x>e.transform.width||t.y<0||t.y>e.transform.height)return void this._clearFadeTimer();const i=e.unproject(t,this._altitude);let r;e._showingGlobe()&&Rc(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(i),e.transform._terrainEnabled()&&e.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 ${SE[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const e=this._pos,t=this._map,i=this.getPitchAlignment();if(!t||!e||"map"!==i)return"";if(!t._showingGlobe()){const e=t.getPitch();return e?`rotateX(${e}deg)`:""}const r=Be(Lc(t.transform,this._lngLat)),n=e.sub(Pc(t.transform)),o=Math.abs(n.x)+Math.abs(n.y);if(0===o)return"";const s=r/o;return`rotateX(${-n.y*s}deg) rotateY(${n.x*s}deg)`}_calculateZTransform(){const e=this._pos,t=this._map;if(!t||!e)return"";let i=0;const r=this.getRotationAlignment();if("map"===r)if(t._showingGlobe()){const e=t.project(new LngLat(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=t.project(new LngLat(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(e);i=Be(Math.atan2(r.y,r.x))-90}else i=-t.getBearing();else if("horizon"===r){const r=qe(4,6,t.getZoom()),n=Pc(t.transform);n.y+=r*t.transform.height;const o=e.sub(n),s=Be(Math.atan2(o.y,o.x));i=(s>90?s-270:s+90)*(1-r)}return i+=this._rotation,i?`rotateZ(${i}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=EE(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(e){return this._offset=Le.convert(e),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(e){const t=this._map;if(!t)return;const i=this._pointerdownPos,r=this._positionDelta;if(i&&r){if(!this._isDragging){const r=this._clickTolerance||t._clickTolerance;if(e.point.dist(i)<r)return;this._isDragging=!0}this._pos=e.point.sub(r),this._lngLat=t.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new Event("dragstart"))),this.fire(new Event("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new Event("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||AE.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||AE.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||AE.pitchAlignment,this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||AE.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const IE={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},CE={maxWidth:100,unit:"metric"},ME={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},DE={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},PE=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function LE(e=new Le(0,0),t="bottom"){if("number"==typeof e){const i=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(t){case"top":return new Le(0,e);case"top-left":return new Le(i,i);case"top-right":return new Le(-i,i);case"bottom":return new Le(0,-e);case"bottom-left":return new Le(i,-i);case"bottom-right":return new Le(-i,-i);case"left":return new Le(e,0);case"right":return new Le(-e,0)}return new Le(0,0)}return e instanceof Le||Array.isArray(e)?Le.convert(e):Le.convert(e[t]||[0,0])}const RE={version:Ct,supported:Vt.supported,setRTLTextPlugin:function(e,t,i=!1){if(Fs===Ps||Fs===Ls||Fs===Rs)throw new Error("setRTLTextPlugin cannot be called multiple times.");Os=Wt.resolveURL(e),Fs=Ps,zs=t,ks(),i||Ns()},getRTLTextPluginStatus:Vs,Map:class Map extends Camera{constructor(e){Ot.mark(Ft.create);const t=e;if(null!=(e=Object.assign({},wE,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==ft){const t=e.navigator?e.navigator.userAgent:null;ft=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return ft}(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/)))}(window)&&(e.antialias=!1,st("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Transform(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies,null,null),e),this._repaint=!!e.repaint,this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._collectResourceTiming=e.collectResourceTiming,this._language=this._parseLanguage(e.language),this._worldview=e.worldview,this._renderTaskQueue=new TaskQueue,this._domRenderTaskQueue=new TaskQueue,this._controls=[],this._markers=[],this._popups=[],this._mapId=Ye(),this._locale=Object.assign({},vE,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._performanceMetricsCollection=e.performanceMetricsCollection,this._tessellationStep=e.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=e.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new EasedVariable(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=e.scaleFactor,this._requestManager=new RequestManager(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,this._contextCreateOptions=e.contextCreateOptions?Object.assign({},e.contextCreateOptions):{},"string"==typeof e.container){const t=document.getElementById(e.container);if(!t)throw new Error(`Container '${e.container.toString()}' not found.`);this._container=t}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&st("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."),e.maxBounds&&this.setMaxBounds(e.maxBounds),this._spriteFormat=e.spriteFormat,et(["_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 HandlerManager(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,(e.style||!e.testMode)&&this.setStyle(e.style||Mt.DEFAULT_STYLE,{config:e.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),e.hash&&(this._hash=new Hash("string"==typeof e.hash&&e.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==t.center&&null==t.zoom||(this.transform._unmodified=!1),this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch});const i=e.bounds;i&&(this.resize(),this.fitBounds(i,Object.assign({},e.fitBoundsOptions,{duration:0})))}this.resize(),e.attributionControl&&this.addControl(new AttributionControl({customAttribution:e.customAttribution})),this._logoControl=new LogoControl,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new Event(`${e.dataType}dataloading`,e))})),this._interactions=new InteractionSet(this)}_getMapId(){return this._mapId}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return-1!==t.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){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 t=!this._moving;return t&&this.fire(new Event("movestart",e)).fire(new Event("move",e)),this.fire(new Event("resize",e)),t&&this.fire(new Event("moveend",e)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=e??-2)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()<e?this.setZoom(e):this.fire(new Event("zoomstart")).fire(new Event("zoom")).fire(new Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=e??22)>=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new Event("zoomstart")).fire(new Event("zoom")).fire(new Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=e??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()<e?this.setPitch(e):this.fire(new Event("pitchstart")).fire(new Event("pitch")).fire(new Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=e??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new Event("pitchstart")).fire(new Event("pitch")).fire(new Event("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._scaleFactorChanged=!0,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.reloadSources(),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 e=this.transform,t=e.projection.name;let i;"globe"===t&&e.zoom>=Va?(e.setMercatorFromTransition(),i=!0):"mercator"===t&&e.zoom<Va&&(e.setProjection({name:"globe"}),i=!0),i&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0))}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(e){let t;const i=this.transform.mercatorFromTransition;t="globe"===e.name&&this.transform.zoom>=Va?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&i!==this.transform.mercatorFromTransition;return(t||r)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(e,t){return this.transform.locationPoint3D(LngLat.convert(e),t)}unproject(e,t){return this.transform.pointLocation3D(Le.convert(e),t)}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 r=e=>{let i=[];if(Array.isArray(t)){const r=t.filter((e=>this.getLayer(e)));i=r.length?this.queryRenderedFeatures(e,{layers:r}):[]}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let n=!1;const o=t=>{const o=r(t.point);o.length?n||(n=!0,i.call(this,new MapMouseEvent(e,this,t.originalEvent,{features:o}))):n=!1};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const o=t=>{r(t.point).length?n=!0:n&&(n=!1,i.call(this,new MapMouseEvent(e,this,t.originalEvent)))},s=t=>{n&&(n=!1,i.call(this,new MapMouseEvent(e,this,t.originalEvent)))};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:s}}}{const n=e=>{const t=r(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features)};return{listener:i,targets:t,delegates:{[e]:n}}}}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 r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.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 r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.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 r=this._delegatedListeners?this._delegatedListeners[e]:void 0;return r&&(e=>{for(let r=0;r<e.length;r++){const n=e[r];if(n.listener===i&&bE(n.targets,t)){for(const e in n.delegates)this.off(e,n.delegates[e]);return e.splice(r,1),this}}})(r),this}queryRenderedFeatures(e,t){if(!this.style)return[];if(void 0===e||e instanceof Le||Array.isArray(e)||void 0!==t||(t=e,e=void 0),e=e||[[0,0],[this.transform.width,this.transform.height]],!t){const t=this.style.queryRenderedFeatures(e,void 0,this.transform),i=this.style.queryRenderedFeatureset(e,void 0,this.transform);return t.concat(i)}let i=!0;if(t.target&&(i=this._isTargetValid(t.target),i&&!t.layers))return this.style.queryRenderedFeatureset(e,t,this.transform);let r=!0;if(t.layers&&Array.isArray(t.layers)){for(const e of t.layers)if(!this._isValidId(e)){r=!1;break}if(r&&!t.target)return this.style.queryRenderedFeatures(e,t,this.transform)}let n=[];return r&&(n=n.concat(this.style.queryRenderedFeatures(e,t,this.transform))),i&&(n=n.concat(this.style.queryRenderedFeatureset(e,t,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(e){const{name:t}=this.transform.projection;return"globe"!==t&&"mercator"!==t&&st(`${t} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(Le.convert(e))}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(e,t){return t=Object.assign({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},t),this.style&&e&&!1!==t.diff&&t.localFontFamily===this._localFontFamily&&t.localIdeographFontFamily===this._localIdeographFontFamily&&!t.config?(this.style._diffStyle(e,((i,r)=>{i?(st(`Unable to perform style diff: ${"string"==typeof i?i:i instanceof Error?i.message:i.error}. Rebuilding the style from scratch.`),this._updateStyle(e,t)):r&&this._update(!0)}),(()=>this._postStyleLoadEvent())),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._updateStyle(e,t))}_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 Style(this,i).load(e),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Style(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():(st("There is no style added to the map."),!1)}_isValidId(e){return null==e?(this.fire(new ErrorEvent(new Error("IDs can't be empty."))),!1):!sa(e)||(this.fire(new ErrorEvent(new Error(`IDs can't contain special symbols: "${e}".`))),!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(e,t,{pixelRatio:i=1,sdf:r=!1,stretchX:n,stretchY:o,content:s}={}){this._lazyInitEmptyStyle();const a=ImageId.from(e);if(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap){const{width:e,height:l,data:c}=Wt.getImageData(t);this.style.addImage(a,{data:new RGBAImage({width:e,height:l},c),pixelRatio:i,stretchX:n,stretchY:o,content:s,sdf:r,version:0,usvg:!1})}else if(void 0===t.width||void 0===t.height)this.fire(new ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:c}=t,u=t;this.style.addImage(a,{data:new RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:i,stretchX:n,stretchY:o,content:s,sdf:r,usvg:!1,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}updateImage(e,t){this._lazyInitEmptyStyle();const i=ImageId.from(e),r=this.style.getImage(i);if(!r)return void this.fire(new ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap?Wt.getImageData(t):t,{width:o,height:s,data:a}=n;if(void 0===o||void 0===s)return void this.fire(new ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||s!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new ErrorEvent(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const l=!(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap);let c=!1;r.usvg?(r.data=new RGBAImage({width:o,height:s},new Uint8Array(a)),r.usvg=!1,r.icon=void 0,c=!0):r.data.replace(a,l),this.style.updateImage(i,r,c)}hasImage(e){return e?!!this.style&&!!this.style.getImage(ImageId.from(e)):(this.fire(new ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(ImageId.from(e))}loadImage(e,t){Oi(this._requestManager.transformRequest(e,Ii.Image),((e,i)=>{t(e,i instanceof HTMLImageElement?Wt.getImageData(i):i)}))}listImages(){return this.style.listImages().map((e=>e.name))}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(e){return e?this.style.hasModel(e):(this.fire(new ErrorEvent(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(e,t){return this.style.addImport(e,t).catch((e=>this.fire(new ErrorEvent(new Error("Failed to add import",e))))),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,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setLayerProperty(e,t,i,r={}){return this._isValidId(e)?("appearances"===t&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(e,t,i,r),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)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(LngLat.convert(e),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.indoor.selectFloor(e)}_setIndoorActiveFloorsVisibility(e){this.indoor.setActiveFloorsVisibility(e)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new IndoorControl),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,r,n,o=this._container;for(;o&&(!r||!n);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(r=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(n=i[3])),o=o.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=n?Math.abs(t/n):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&st("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/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new IndoorManager(this.style),this.on("load",(()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",(()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})),this.on("idle",(()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}))})))}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=Xt("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=Xt("div","mapboxgl-canvas-container",e);this._canvas=Xt("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=Xt("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach((e=>{r[e]=Xt("div",`mapboxgl-ctrl-${e}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t){const i=Wt.devicePixelRatio||1;this._canvas.width=i*Math.ceil(e),this._canvas.height=i*Math.ceil(t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}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 e=Object.assign({},Vt.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl2",e);t?(or(t,!0),this.painter=new Painter(t,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),vi.testSupport(t)):this.fire(new ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){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.reloadModels(),this.style.clearSources()),this._update(),this.fire(new Event("webglcontextrestored",{originalEvent:e}))}_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(e){let t;this.fire(new Event("renderstart")),++this._frameId;const i=this.painter.context.extTimerQuery,r=Wt.now(),n=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(t=n.createQuery(),n.beginQuery(i.TIME_ELAPSED_EXT,t)),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(e),this._domRenderTaskQueue.run(e),this._removed)return;this._updateProjectionTransition();const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,t=this.transform.pitch,i=Wt.now(),r=new EvaluationParameters(e,{now:i,fadeDuration:o,pitch:t,transition:this.style.transition,worldview:this._worldview});this.style.update(r)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(r),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(r);const a=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,o,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),a&&(this._placementDirty=a.needsRerender),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:o,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 Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,Ot.mark(Ft.load),this.fire(new Event("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(),t){const e=Wt.now()-r;n.endQuery(i.TIME_ELAPSED_EXT),setTimeout((()=>{const i=n.getQueryParameter(t,n.QUERY_RESULT)/1e6;n.deleteQuery(t),this.fire(new Event("gpu-timing-frame",{cpuTime:e,gpuTime:i}))}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const t=this.painter.queryGpuTimers(e);this.fire(new Event("gpu-timing-layer",{layerTimes:t}))}),50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const t=this.painter.queryGpuTimeDeferredRender(e);this.fire(new Event("gpu-timing-deferred-render",{gpuTime:t}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(l||this._repaint)this.triggerRepaint();else{const e=this.idle();if(e&&(s=this._updateAverageElevation(r,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,Ot.mark(Ft.fullLoad),this._performanceMetricsCollection&&tr(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 r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){rr(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===ki||401===e.status)){const e=this.painter.context.gl;or(e,!1),this._logoControl instanceof LogoControl&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),Zi(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_postStyleLoadEvent(){this.style.globalId&&Xi(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Ki(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){Qi(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,r=i.createFramebuffer();function n(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,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o<t.length;o++){const s=t[o];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);r+=(i[o+2]-i[o+1])*(1-a/n)}return r}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.indoor&&this.indoor.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 e=this.painter.context.gl.getExtension("WEBGL_lose_context");e&&e.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),nr.delete(this.painter.context.gl),ir.remove(),$i.remove(),this._removed=!0,this.fire(new Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(e){this._renderNextFrame=this._renderNextFrame||e,this.style&&!this._frame&&(this._frame=Wt.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(e){return Ze(this.style?this.style.getSourceCaches():[],((t,i)=>t._preloadTiles(e,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(e,t){!function(e,t){hi=e,di=t}(e,t)}get version(){return Ct}},NavigationControl:class NavigationControl{constructor(e={}){this.options=Object.assign({},TE,e),this._container=Xt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(et(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),Xt("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})})),Xt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(et(["_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=Xt("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(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.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 MouseRotateWrapper(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=Xt("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 GeolocateControl extends Evented{constructor(e={}){super();const t=navigator.geolocation;this.options=Object.assign({geolocation:t},IE,e),et(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=KT(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=Xt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){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(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new Event("geolocate",Object.assign({coords:e.coords,timestamp:e.timestamp},e.toJSON?{toJSON:e.toJSON.bind(e)}:{}))),this._finish()}}_updateCamera(e){const t=new LngLat(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=this._map.getBearing(),n=Object.assign({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(i),n,{geolocateSource:!0})}_updateMarker(e){if(e){const t=new LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,t=tl(1,e._center.lat)*e.worldSize,i=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}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(e){if(this._map){if(this.options.trackUserLocation)if(1===e.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===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=Xt("button","mapboxgl-ctrl-geolocate",this._container),Xt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){st("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}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=Xt("div","mapboxgl-user-location"),this._dotElement.appendChild(Xt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(Xt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Marker({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Xt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Marker({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new Event("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 st("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 Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let 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.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){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,ScaleControl:class ScaleControl{constructor(e={}){this.options=Object.assign({},CE,e),et(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),s=n.distanceTo(o);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 r=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),n=r/t;this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(r):`${r} ${ME[i]}`,this._container.style.width=e*n+"px"}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=Xt("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 FullscreenControl{constructor(e={}){this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:st("Full screen control 'container' must be a DOM element.")),et(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=Xt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",st("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=Xt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Xt("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,Popup:class Popup extends Evented{constructor(e){super(),this.options=Object.assign(Object.create(DE),e),this._altitude=this.options.altitude,et(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),e._addPopup(this),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),e._canvasContainer&&e._canvasContainer.classList.remove("mapboxgl-track-pointer"),e._removePopup(this),this._map=void 0),this.fire(new Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._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 r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);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=Xt("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=Xt("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='<span aria-hidden="true">×</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,r=this._pos;if(!t||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.x<n/2,a=r.x>t.transform.width-n/2;if(r.y+e<o)return s?"top-left":a?"top-right":"top";if(r.y>t.transform.height-o){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(e){const t=this._map,i=this._content;if(!t||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=Xt("div","mapboxgl-popup",t.getContainer()),this._tip=Xt("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=EE(this._lngLat,this._pos,t.transform)),!this._trackPointer||e){const i=this._pos=this._trackPointer&&e instanceof Le?e:t.project(this._lngLat,this._altitude),r=LE(this.options.offset),n=this._anchor=this._getAnchor(r.y),o=LE(this.options.offset,n),s=i.add(o).round();t._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${SE[n]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&t._showingGlobe()){const e=Rc(t.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(PE);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,Style,LngLat,LngLatBounds,Point:Le,MercatorCoordinate,FreeCameraOptions,Evented,config:Mt,prewarm:function(){nd().acquire(td)},clearPrewarmedResources:function(){const e=id;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(td),id=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 Mt.ACCESS_TOKEN},set accessToken(e){Mt.ACCESS_TOKEN=e},get baseApiUrl(){return Mt.API_URL},set baseApiUrl(e){Mt.API_URL=e},get workerCount(){return WorkerPool.workerCount},set workerCount(e){WorkerPool.workerCount=e},get maxParallelImageRequests(){return Mt.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){Mt.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){!function(e){const t=_i();if(!t)return;const i=t.delete(ui);e&&i.then((()=>e())).catch(e)}(e)},get workerUrl(){return ed.workerUrl},set workerUrl(e){ed.workerUrl=e},get workerClass(){return ed.workerClass},set workerClass(e){ed.workerClass=e},get workerParams(){return ed.workerParams},set workerParams(e){ed.workerParams=e},get dracoUrl(){return md()},set dracoUrl(e){!function(e){ad=Wt.resolveURL(e),hd||(hd=new Dispatcher(nd(),new Evented)),hd.broadcast("setDracoUrl",ad)}(e)},get meshoptUrl(){return _d()},set meshoptUrl(e){!function(e){cd=Wt.resolveURL(e),hd||(hd=new Dispatcher(nd(),new Evented)),hd.broadcast("setMeshoptUrl",cd)}(e)},setNow:Wt.setNow,restoreNow:Wt.restoreNow};return RE},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).mapboxgl=t();
|
||
//# sourceMappingURL=mapbox-gl-csp.js.map
|